This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| bump: { | |
| options: {}, | |
| files: ['package.json'] | |
| }, | |
| prompt: { | |
| bump: { | |
| options: { | |
| questions: [{ | |
| config: 'bump.options.level', | |
| type: 'list', |
| macro ?. { | |
| rule infix { | |
| $lhs:expr | $rhs:expr | |
| } => { | |
| $lhs && $lhs.$rhs | |
| } | |
| } | |
| // obj?.possiblyNullProperty |
| // 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) { |
| { [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]]]; }]' } |
| // 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( |
| 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) { |
| 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 |
| 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); | |
| }; | |
| } |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| . /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 && ( |