Skip to content

Instantly share code, notes, and snippets.

View hirasso's full-sized avatar
👋

Rasso Hilber hirasso

👋
View GitHub Profile
@stevegrunwell
stevegrunwell / one-time-hooks.php
Created February 14, 2017 20:06
Enables action and filter callbacks to be executed exactly once via the WordPress Plugin API. https://engineering.growella.com/one-time-callbacks-wordpress-plugin-api/
<?php
/**
* Registers the "One time hook" functionality.
*
* Note that this file is intentionally in the *global* namespace!
*
* @author Growella
* @license MIT
*/
@tyru
tyru / promise-is-resolved.js
Last active December 4, 2023 02:54
Check whether a promise is finished / resolved / rejected
function delay(msec, value) {
return new Promise(done => window.setTimeout((() => done(value)), msec));
}
function isResolved(promise) {
  return Promise.race([delay(0, false), promise.then(() => true, () => false)]);
}
function isRejected(promise) {
  return Promise.race([delay(0, false), promise.then(() => false, () => true)]);
@yratof
yratof / load.php
Last active January 30, 2023 08:41
ACF Load layouts into flex field
<?php
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' );
static function craft_content_layouts( $field ) {
// Remove the layouts
// that are named in this list
$remove_list = [
'paragraph',
'banner',
@lmeyer
lmeyer / gist:f506a67462bf7614877a205db431bd55
Created October 13, 2016 16:21
Make WP Super Cache works with Bedrock
define( 'WP_CACHE', true );
define( 'WPCACHEHOME', $webroot_dir . '/app/plugins/wp-super-cache/');
@xposedbones
xposedbones / map.js
Last active May 1, 2024 11:15
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@theMikeD
theMikeD / acf_add_notes.php
Created September 15, 2016 12:44
Adds a section to the ACF field groups page fora notes section
<?php
// Add additional setting option called "Notes"
add_action('acf/render_field_group_settings', 'my_acf_add_field_group_notes');
function my_acf_add_field_group_notes($field_group){
acf_render_field_wrap(array(
'label' => __('Notes','acf'),
'instructions' => __('Notes','acf'),
'type' => 'textarea',
'name' => 'notes',
'prefix' => 'acf_field_group',
@Bat-Chat
Bat-Chat / overriding old tag
Created July 11, 2016 15:07
overriding old tag (move tag to latest commit)
Use the -f option to git tag:
-f
--force
Replace an existing tag with the given name (instead of failing)
You probably want to use -f in conjunction with -a to force-create an annotated tag instead of a non-annotated one.
Example
@dsdsdsdsdsds
dsdsdsdsdsds / cursor.css
Last active November 1, 2023 11:45
CSS: Cross Browser hires/retina cursor image
.cursor {
cursor: url("cursor.png") 0 0, pointer; /* Legacy */
cursor: url("cursor.svg") 0 0, pointer; /* FF */
cursor: -webkit-image-set(url("cursor.png") 1x, url("cursor@2x.png") 2x) 0 0, pointer; /* Webkit */
}
@jonsuh
jonsuh / .bash_profile
Last active February 16, 2024 17:17
Bash echo in color
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
@nathansearles
nathansearles / isAutoplaySupported.js
Last active December 13, 2022 11:06
Test if HTML5 video autoplay is supported
// isAutoplaySupported(callback);
// Test if HTML5 video autoplay is supported
isAutoplaySupported = function(callback) {
// Is the callback a function?
if (typeof callback !== 'function') {
console.log('isAutoplaySupported: Callback must be a function!');
return false;
}
// Check if sessionStorage exist for autoplaySupported,
// if so we don't need to check for support again