Skip to content

Instantly share code, notes, and snippets.

View maurobringolf's full-sized avatar
⛰️

Mauro Bringolf maurobringolf

⛰️
  • Zürich, Switzerland
View GitHub Profile
#!/usr/bin/env bash
git branch | grep -v "^*" | xargs git branch -D
#!/usr/bin/env bash
git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | xargs git branch -D
function filter(arr, fn) {
 return arr.reduce((acc, item) => fn(item) ? […acc, item] : acc, [])
}
function map(arr, fn) {
 return arr.reduce((acc, item) => […acc, fn(item)], [])
}
function find(arr, fn) {
 return arr.reduce((acc, item) => fn(item) ? acc || item : acc, undefined)
}
class myComponent extends React.Component {
constructor() {
super()
// Replace existing method with hardbound version of it
this.someMethod = someMethod.bind(this)
}
someMethod() {
// Do something that relies on 'this'
<?php
/**
* Plugin Name: Singleton Example
* Plugin URI: https://github.com/maurobringolf/wordpress-plugin-singleton
* Description: An empty illustration of a WordPress plugin implemented as singleton
* Author: Mauro Bringolf
* Author URI: https://maurobringolf.ch
* Version: 1.0
* Text Domain: singleton
* Domain Path: languages
<?php
esc_html( $str ); //https://developer.wordpress.org/reference/functions/esc_html/
esc_attr( $str ); //https://developer.wordpress.org/reference/functions/esc_attr/
esc_url( $str ); //https://developer.wordpress.org/reference/functions/esc_url/
esc_js( $str ); //https://developer.wordpress.org/reference/functions/esc_js/
esc_textarea( $str ); //https://developer.wordpress.org/reference/functions/esc_textarea/
<?php
sanitize_text_field( $str ); //https://developer.wordpress.org/reference/functions/sanitize_text_field/
sanitize_title( $str ); //https://developer.wordpress.org/reference/functions/sanitize_title/
sanitize_email( $str ); //https://developer.wordpress.org/reference/functions/sanitize_email/
sanitize_file_name( $str ); //https://developer.wordpress.org/reference/functions/sanitize_file_name/
<?php
is_numeric( $var ); //http://php.net/manual/de/function.is-numeric.php
is_array( $var ); //http://php.net/manual/de/function.is-array.php
is_object( $var ); //http://php.net/manual/de/function.is-object.php
is_string( $var ); //http://php.net/manual/de/function.is-string.php
isset( $data['key'] ); //http://php.net/manual/de/function.isset.php
in_array( $var, $arr ); //http://php.net/manual/de/function.is-array.php