Skip to content

Instantly share code, notes, and snippets.

Enrico Deleo enricodeleo

Block or report user

Report or block enricodeleo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@enricodeleo
enricodeleo / destructuring.js
Created May 19, 2017 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
View destructuring.js
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@enricodeleo
enricodeleo / .htaccess
Created Nov 7, 2016
Compressing + caching with htaccess
View .htaccess
# Deflate
<IfModule mod_filter.c>
#Add deflate
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
View wp-query-ref.php
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@enricodeleo
enricodeleo / angular-jst.js
Created Jun 17, 2016
Angular 1.x module that takes advantage of JST for templating
View angular-jst.js
angular
.module('angularJst', [])
.config([
'$provide',
function($provide) {
$provide.decorator('$templateCache', function($delegate, $sniffer) {
var originalGet = $delegate.get;
$delegate.get = function(key) {
var value;
@enricodeleo
enricodeleo / countWatchers.js
Created Jun 15, 2016
Count Angularjs 1.x watchers
View countWatchers.js
(function countWatchers()
{
var root = angular.element(document.getElementsByTagName('body')).injector().get('$rootScope');
var count = root.$$watchers ? root.$$watchers.length : 0; // include the current scope
var pendingChildHeads = [root.$$childHead];
var currentScope;
while (pendingChildHeads.length)
{
currentScope = pendingChildHeads.shift();
@enricodeleo
enricodeleo / arrayAppend.js
Created Nov 30, 2015
Extend an Array appending elements of another Array in Javascript
View arrayAppend.js
// Shorthand function
Array.prototype.append = function(array) {
this.push.apply(this, array)
}
// Example
var a = [1,2];
var b = [3,4];
a.append(b); // 'a' bacames [ 1, 2, 3, 4 ]
@enricodeleo
enricodeleo / sdxc-reload.sh
Created Jun 22, 2015
Reload SD Card reader on OS X
View sdxc-reload.sh
sudo kextunload /System/Library/Extensions/AppleStorageDrivers.kext/Contents/PlugIns/AppleUSBCardReader.kext;
sudo kextload /System/Library/Extensions/AppleStorageDrivers.kext/Contents/PlugIns/AppleUSBCardReader.kext
@enricodeleo
enricodeleo / smart-log.js
Last active Aug 29, 2015
A hopefully smart solution for console.logging messages during development without affecting production apps
View smart-log.js
DEVELOPMENT = true; //global variable, I use this to adapt my js app behavior accordingly
// I want console.log just during development
if ( DEVELOPMENT ) {
smLog = function(log, type) {
var args = [ 'log', 'info', 'debug', 'warn', 'error' ]; // valid methods for `console`
var type = type || 'log'; // the second argument is optional, defaults to log
var type = ( args.indexOf( type ) ) > -1 ? type : 'log'; // defaults to log if the second argument is not valid (eg a typo)
console[type](log);
};
@enricodeleo
enricodeleo / margin-padding.sass
Last active Nov 17, 2017
Loop that generates margin and padding class helpers
View margin-padding.sass
// loop that generates margin ad padding helper classes
// the output is like .margin-5, .margin-top-5, margin-right-5 etc...
$properties: (margin, padding);
$sides: (top, right, bottom, left);
@each $prop in $properties {
@for $i from 1 through 14 {
.#{$prop}-#{$i*5} {
#{$prop}: #{$i*5}px !important;
}
@each $side in $sides {
@enricodeleo
enricodeleo / .bash_profile
Last active Dec 4, 2015
Bash Profile OS X
View .bash_profile
# Brew bash complation (brew install bash-completion)
# you must install brew http://brew.sh/
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Brew's NVM (brew install nvm)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
You can’t perform that action at this time.