Snippets Collections
// place the codes in functions.php and call the function wherever you want.

function philosophy_pagination()
{
   global $wp_query;
   $links = paginate_links(array(
      'current'      => max(1, get_query_var('paged')),
      'total'        => $wp_query->max_num_pages,
      'type'         => 'list',
      'mid_size'     => 3,
   ));
   $links = str_replace('page-numbers', 'pgn__num', $links);
   $links = str_replace("<ul class='pgn__num'>", "<ul>", $links);
   $links = str_replace('next pgn__num', 'pgn__next', $links);
   $links = str_replace('prev pgn__num', 'pgn__prev', $links);
   echo wp_kses_post($links);
}
// Les briques de base que nous allons composer
const double = x => x + x;
const triple = x => 3 * x;
const quadruple = x => 4 * x;

// Une fonction qui permet d'appliquer une composition
const pipe = (...functions) => input => functions.reduce(
    (acc, fn) => fn(acc),
    input
);

// On crée des fonctions pour multiplier par un facteur donné
const multiply6 = pipe(double, triple);
const multiply9 = pipe(triple, triple);
const multiply16 = pipe(quadruple, quadruple);
const multiply24 = pipe(double, triple, quadruple);

// Utilisation
multiply6(6); // 36
multiply9(9); // 81
multiply16(16); // 256
multiply24(10); // 240
#!/bin/bash
#####################################################################
#Author:Irfan Khan
#Description:this function will used to donwload & move that file to
#desired location
#####################################################################
download(){
    #$url=$1
    wget -cO - https://gist.github.com/chales/11359952/archive/25f48802442b7986070036d214a2a37b8486282d.zip > dbtest.zip
    if [[ -f dbtest.zip ]];
    then
        mv dbtest.zip ./mydb_data
        exit 0
    else
        echo "hey file not moved some thing went wrong.."
    fi
}

download  #calling the function
cell.cellButton.tag = indexPath.row
            cell.cellButton.addTarget(self, action: #selector(yourFunc(sender:)), for: UIControl.Event.touchUpInside)
                                                            
@objc func yourFunc(sender: UIButton){
    let buttonTag = sender.tag
}
const pipe = (...ops) => {
  const _pipe = (a, b) => (arg) => b(a(arg));
  let bundle = ops.reduce((prevOp, nextOp) => {
    return _pipe(prevOp,nextOp);
  });
  return bundle;
}
const textBlock = 0.37645448;
  const pageWidth = $('.container').width();
  const pageHeight = $('.container').height();
	
  if (pageWidth <= 1920 && pageHeight <= 1080) {
    $('.container').css()
  } else {
    $('.container').css('max-width', '100%')
  }
rmsval = df.loc[:, 'c1':'c4']
def getrms(row):  
  a = np.sqrt(sum(row**2/4))
  return a
df['rms'] = df.apply(getrms,axis=1)
df.head()
for c in df_drop.columns:
    df_drop[c] = df_drop[c].str.replace('[^\w\s]+', '')
df_drop = df_drop.astype(str)
df_drop.head()
add_action( 'wp_body_open', 'wpdoc_add_custom_body_open_code' );
 
function wpdoc_add_custom_body_open_code() {
    echo '<!-- Google Tag Manager (noscript) --> ... <!-- End Google Tag Manager (noscript) -->';
}
def byte_size(string):

  return(len(string.encode('utf-8')))

byte_size('😀’) # 4
byte_size('Hello World') # 11
Use functools.reduce() to perform right-to-left function composition. The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
from functools import reduce

1.def compose(*fns):
  2.return reduce(lambda f, g: lambda *args: f(g(*args)), fns)
EXAMPLES
add5 = lambda x: x + 5
multiply = lambda x, y: x * y
multiply_and_add_5 = compose(add5, multiply)

multiply_and_add_5(5, 2) # 15
#define a function 
 Def cube(num)
      #write the formula of cube
      return num*num*num
     #give the number to calculate the cube 
     cube(3)
   # print the cube of that number simply by using print command
    print(cube(3))
     “return” keyword means that function have to return          value
 # give a name of function after def
 1.def sayhi():
      #put the statement in the function  
     2.print(“hello world”)
#call function by name:
3.sayhi()


Output: 
Hello world
#define function
defall_unique(lst):

   return len(lst) == len(set(lst))
   
x = [1,1,2,2,3,2,3,4,5,6]


y = [1,2,3,4,5]


all_unique(x) # False
all_unique(y) # True
This method gets vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) found in a string.
   
#make a function:
def get_vowels(string):

#return is the keyword which means function have to return value: 
 return [each for each in string if each in 'aeiou']


#assign the words and function will return vowels words.
get_vowels('foobar') # ['o', 'o', 'a']


get_vowels('gym') # []
#define a function 
 1.Def cube(num)
      #write the formula of cube
      2.return num*num*num
     #give the number to calculate the cube 
     3.cube(3)
   # print the cube of that number simply by using print command
    4.print(cube(3))
     5.“return” keyword means that function have to return value         
def when(predicate, when_true):
  return lambda x: when_true(x) if predicate(x) else x
  
EXAMPLES
double_even_numbers = when(lambda x: x % 2 == 0, lambda x : x * 2)
double_even_numbers(2) # 4
double_even_numbers(1) # 1
def unfold(fn, seed):
  def fn_generator(val):
    while True: 
      val = fn(val[1])
      if val == False: break
      yield val[0]
  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, -50]
from functools import reduce

def compose(*fns):
  return reduce(lambda f, g: lambda *args: f(g(*args)), fns)


EXAMPLES
add5 = lambda x: x + 5
multiply = lambda x, y: x * y
multiply_and_add_5 = compose(add5, multiply)

multiply_and_add_5(5, 2) # 15
star

Sat May 14 2022 10:38:29 GMT+0000 (UTC)

#pagination #function
star

Sat Feb 12 2022 14:41:52 GMT+0000 (UTC) https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce

#function #composition
star

Sun Dec 26 2021 19:54:30 GMT+0000 (UTC) undefined

#javascript #pipe #function
star

Sat Mar 06 2021 03:42:11 GMT+0000 (UTC) https://rckflr.com

#wordpress #google #tag #manager #function
star

Mon Apr 20 2020 13:45:46 GMT+0000 (UTC) https://towardsdatascience.com/30-helpful-python-snippets-that-you-can-learn-in-30-seconds-or-less-69bb49204172

#python #python #function #bytesize #return
star

Mon Apr 20 2020 13:38:08 GMT+0000 (UTC) https://www.30secondsofcode.org/python/s/compose/

#python #python #function #composition
star

Mon Apr 20 2020 13:32:07 GMT+0000 (UTC) https://www.youtube.com/watch?v=rfscVS0vtbw&t=5s

#python #python #function #return
star

Mon Apr 20 2020 13:17:59 GMT+0000 (UTC) https://www.youtube.com/watch?v=rfscVS0vtbw&t=5s

#python #function #python #def
star

Tue Mar 31 2020 11:40:31 GMT+0000 (UTC) https://towardsdatascience.com/30-helpful-python-snippets-that-you-can-learn-in-30-seconds-or-less-69bb49204172

#python #python #function #return #allunique
star

Tue Mar 31 2020 11:35:03 GMT+0000 (UTC) https://towardsdatascience.com/30-helpful-python-snippets-that-you-can-learn-in-30-seconds-or-less-69bb49204172

#python #python #strings #vowels #function
star

Tue Mar 31 2020 05:43:21 GMT+0000 (UTC) https://www.youtube.com/watch?v=rfscVS0vtbw&t=5s

#python #function #returnfunction
star

Sat Jan 11 2020 20:54:48 GMT+0000 (UTC) https://www.30secondsofcode.org/python/s/when/

#python #function
star

Fri Jan 10 2020 19:00:00 GMT+0000 (UTC) https://www.30secondsofcode.org/python/s/unfold/

#python #lists #function
star

Thu Jan 09 2020 19:00:00 GMT+0000 (UTC) https://www.30secondsofcode.org/python/s/compose/

#python #function

Save snippets that work with our extensions

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