Skip to content

Instantly share code, notes, and snippets.

Alberto Zaccagni lazywithclass

Block or report user

Report or block lazywithclass

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
@lazywithclass
lazywithclass / version bump with prompt offered
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',
@lazywithclass
lazywithclass / ?. in JavaScript
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
@lazywithclass
lazywithclass / Describing Y Combinator
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) {
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]]]; }]' }
@lazywithclass
lazywithclass / remove-as-read.js
Last active Sep 24, 2015
Marking comments as read on HN, the hacky way
View remove-as-read.js
// 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(
@lazywithclass
lazywithclass / challenge.js
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) {
@lazywithclass
lazywithclass / c for copy
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
@lazywithclass
lazywithclass / partial
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);
};
}
@lazywithclass
lazywithclass / about.md
Created Oct 19, 2011 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
View about.md
@lazywithclass
lazywithclass / gist:1372959
Created Nov 17, 2011
Version control aware ps1
View gist:1372959
. /etc/bash_completion.d/git
function customW {
echo $PWD | sed 's|.*/\([a-Z0-9][a-Z0-9]*/[a-Z0-9][a-Z0-9]*\)|\1|'
}
function hasToPush {
git diff-index --quiet --cached HEAD &>/dev/null &&
(git svn dcommit --dry-run 2>/dev/null | grep -q "diff-tree" && echo "")
}
function hasToPull {
git diff-index --quiet --cached HEAD &>/dev/null && (
You can’t perform that action at this time.