Snippets Collections
PHP
$global_var = '...long string of random characters...'; 
eval(base64_decode($global_var)); 
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
 const isRequired = () => { throw new Error('param is required'); };

const hello = (name = isRequired()) => { console.log(`hello ${name}`) };

// These will throw errors
hello();
hello(undefined);

// These will not
hello(null);
hello('David');
The idea here is that it uses default parameters, like how the b parameter here has a default if you don’t send it anything:
function multiply(a, b = 1) {
  return a * b;
}                               
                                
#In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists.
# define function:
1.def unfold(fn, seed):
  2.def fn_generator(val):
    3.while True: 
      4.val = fn(val[1])
     5.-5 if val == False: break
      6.yield val[0]
  7.return [i for i in fn_generator([None, seed])]
EXAMPLES
f = lambda n: False if n > 50 else [-n, n + 10]
unfold(f, 10) # [-10, -20, -30, -40,
from datetime import datetime

datetime_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
star

Sun Feb 18 2024 10:03:14 GMT+0000 (Coordinated Universal Time)

#functions
star

Mon Nov 15 2021 15:49:41 GMT+0000 (Coordinated Universal Time) https://medium.com/@giuliamalaroda/7-javascript-functions-to-master-objects-manipulation-and-make-your-code-cleaner-cc142a269b13

#javascript #object #functions
star

Fri Oct 22 2021 16:30:17 GMT+0000 (Coordinated Universal Time) https://developer.wordpress.org/reference/functions/add_action/

#php #wordpress #functions #documentation #prority
star

Wed Sep 30 2020 12:02:11 GMT+0000 (Coordinated Universal Time)

#php #functions
star

Fri Apr 24 2020 11:32:35 GMT+0000 (Coordinated Universal Time) https://css-tricks.com/snippets/javascript/required-parameters-for-functions-in-javascript/

#javascript #javascript #functions #parameters
star

Mon Mar 30 2020 12:18:27 GMT+0000 (Coordinated Universal Time) https://www.30secondsofcode.org/python/s/unfold/

#python #python #iterator #functions
star

Wed Jan 22 2020 18:52:28 GMT+0000 (Coordinated Universal Time) https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime

#python #dates #functions #python3.8

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension