{{ message }}

Instantly share code, notes, and snippets.

# Alberto Zaccagni lazywithclass

Created Jan 29, 2014
Version bump compliant with semver with prompt to the dev
View version bump with prompt offered
 bump: { options: {}, files: ['package.json'] }, prompt: { bump: { options: { questions: [{ config: 'bump.options.level', type: 'list',
Created Feb 3, 2014
First version of CoffeeScript's ?. in JavaScript thanks to sweet.js
View ?. in JavaScript
 macro ?. { rule infix { \$lhs:expr | \$rhs:expr } => { \$lhs && \$lhs.\$rhs } } // obj?.possiblyNullProperty
Last active Aug 29, 2015
My take in explaining to myself the Y Combinator
View Describing Y Combinator
 // the original Y Combinator is here: https://leanpub.com/javascript-allonge/read#y // have a look at that soup of function and return // I refactored it down to the below version // I hope is correct, too tired now. // used like this var factorial = Y( // next function(fac) { return function(n) {
Created Jun 16, 2015
elastic search http://stackoverflow.com/q/30845571/57095 related error
View gist:099ef5ec61f870a07e56
 { [Error: SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[2sj2k_hAQWKeObWgAzBZhw][events][0]: SearchParseException[[events][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"filtered":{"filter":{"geo_distance":{"distance":"1km", "geopoint":{"lat":48.507351,"lon":-0.127758}}}}}]]]; nested: SearchParseException[[events][0]: from[-1],size[-1]: Parse Failure [No parser for elemen t [filtered]]]; }]] status: '400', message: 'SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[2sj2k_hAQWKeObWgAzBZhw][events][0 ]: SearchParseException[[events][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"filtered":{"filter":{"geo_distance":{"distance":"1km ","geopoint":{"lat":48.507351,"lon":-0.127758}}}}}]]]; nested: SearchParseException[[events][0]: from[-1],size[-1]: Parse Failure [No parser for elem ent [filtered]]]; }]' }
Last active Sep 24, 2015
 // these are to be pasted into the console // remove by clicking on the up arrow // the useful thing is that you remove comments and add the removed id to // an array, so next time you know exactly what you've considered // (use case might be monthly "Who is hiring?") function remove(id) { document.getElementById(id).parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.remove(); } [].forEach.call(
Last active Sep 24, 2015
Traversing a graph whose elements you get from API calls, using a token that expires after 10 calls. Leaves contain a secret message.
View challenge.js
 var async = require('async'), request = require('request'); function traverse(start, token) { var queue = []; queue.unshift(start); async.forever(function(next) { if (queue.length === 0) next('no more items'); var item = queue.pop(); getAdjacents(item, token, function(err, adjacents) {
Created Jul 24, 2011
Append c to a command and see its output copyed in the clipboard (xclip needed)
View c for copy
 command_not_found_handle() { if [ \$(echo \$1 | cut -d' ' -f1 | grep ".*c\$") ]; then echo "copying \$(echo \$1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') results in your clipboard..." exec \$(echo \$1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') | copy #just pasted the body of the system-wide function to handle c-n-f #if the command-not-found package is installed, use it elif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found ]; then # check because c-n-f could've been removed in the meantime if [ -x /usr/lib/command-not-found ]; then /usr/bin/python /usr/lib/command-not-found -- \$1
Created Aug 22, 2011
Partial function application
View partial
 function partial(func /*, 0..n args */) { var args = Array.prototype.slice.call(arguments, 1); return function() { var allArguments = args.concat(Array.prototype.slice.call(arguments)); return func.apply(this, allArguments); }; }
Created Oct 19, 2011 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer