Skip to content

Instantly share code, notes, and snippets.

View joshuacerbito's full-sized avatar
🔥
🎸🎛🎛🎚🔊

Joshua Cerbito joshuacerbito

🔥
🎸🎛🎛🎚🔊
View GitHub Profile
@joshuacerbito
joshuacerbito / wp_remove_emojis.php
Last active August 27, 2018 18:54
Wordpress Remove Emoji Scripts
<?php
/*
* REMOVE WORDPRESS' CRAPPY EMOJI
*/
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
const ObjectSingleton = {
_instance: null,
get instance() {
if (!this._instance) {
this._instance = {
singletonMethod() {
return 'singletonMethod';
},
_type: 'ObjectSingleton',
@joshuacerbito
joshuacerbito / array_shuffle.js
Last active January 16, 2018 17:39
An extension to the Array class that returns a shuffled version of an array
/*
* Array.shuffle
*
* Usage:
* const arr1 = [1, 2, 3, 4, 5];
* const arr2 = Array.shuffle(arr1);
* const arr3 = arr1.shuffle();
*
* @TODO:
* - Add callback functionality to Array.prototype.shuffle
@joshuacerbito
joshuacerbito / pubsub.js
Last active January 11, 2023 08:05
Publish/Subscribe Snippet 2023
const PubSub = (() => {
const topics = {};
const hOP = topics.hasOwnProperty;
return {
subscribe(topic, listener) {
// Create the topic's object if not yet created
if(!hOP.call(topics, topic)) topics[topic] = [];
// Add the listener to queue
@joshuacerbito
joshuacerbito / Contract Killer 3.md
Created June 10, 2017 14:10
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@joshuacerbito
joshuacerbito / module-exporter.js
Created May 18, 2017 16:37
JS Module Exporter (AMD, CommonJS, Globals)
(function(globals){
// module name
const MODULE_NAME = 'moduleName';
// define your functions here
const functions = {
fn1: alert,
fn2: console.log
};
@joshuacerbito
joshuacerbito / MessageBus.js
Last active March 3, 2021 14:20
A topic-based subscribe-publish library written in JavaScript.
/*
* Observer.js
*
* SYNTAX:
* const EventHandler = new MessageBus( context );
* ---
* context: identifier for the event handler
* ---
* USAGE:
* var handler = new MessageBus( document );
@joshuacerbito
joshuacerbito / .htaccess
Created October 20, 2016 13:22 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@joshuacerbito
joshuacerbito / html5-dataset.js
Created September 28, 2016 06:30 — forked from brettz9/html5-dataset.js
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
@joshuacerbito
joshuacerbito / get_set_data_attribute.js
Created September 28, 2016 05:33
IE-compatible data attribute getter/setter
Object.prototype.data = function (prop, val) {
var _return,
notIE = ( this.dataset !== undefined );
return ( notIE )? // not IE
( typeof val === "undefined" ) ? // get data value
this.dataset[prop] : this.dataset[prop] = val
: // is IE
( typeof val === "undefined" ) ? // get data value
this.getAttribute('data-' + prop) : this.setAttribute('data-' + prop, val);