Skip to content

Instantly share code, notes, and snippets.

View spencewood's full-sized avatar

Tyler Spencewood spencewood

  • Minneapolis, MN
View GitHub Profile
I am attesting that this GitHub handle spencewood is linked to the Tezos account tz1S5KnFCBLzjPK1ysdH4x1L9pskqi6JRZu3 for tzprofiles
sig:edsigu1gro5JTNEE4C1bBv3rJdh8gJ9HhDfBjoE9xW6EkZxiHiBQ1cZr8wb7K5r7FvQy9MGGsTKMkhweSH9JhZopkX4FEDfRyer

Keybase proof

I hereby claim:

  • I am spencewood on github.
  • I am spencewood (https://keybase.io/spencewood) on keybase.
  • I have a public key ASArd6_IG7kmq270KYuda8hsGensCA4yfBGZtxJlti9azwo

To claim this, I am signing this object:

@spencewood
spencewood / Nested pluck mixin
Created January 10, 2014 07:19
Underscore nested pluck mixin. Takes an array as the first argument and any number of keys as additional arguments. E.g.: _.nestedPluck(arr, 'person', 'name', 'first');
_.mixin({
nestedPluck: function nestedPluck(arr) {
var plucks = _.rest(arguments);
if (plucks.length > 0) {
var a = _.flatten(_.pluck(arr, plucks.shift()), true);
return nestedPluck.apply(null, [a].concat(plucks));
}
return arr;
}
});
@spencewood
spencewood / Average
Created December 27, 2013 10:36
Underscore mixin for averaging array numbers.
_.mixin({
average: function (arr) {
return _.reduce(arr, function (memo, num) {
return memo + num;
}, 0) / arr.length;
}
});
@spencewood
spencewood / Pipeline
Last active December 30, 2015 19:09
Pipeline mixin for underscore/lodash. Takes a seed as an initial value and any number of functions as parameters. The seed value is passed to the first function, and the return value of each function is passed as the parameter to the next.
_.mixin({
pipeline: function (seed) {
return _.rest(_.toArray(arguments)).reduce(function (l, r) {
return r(l);
}, seed);
}
});
@spencewood
spencewood / .bashrc
Last active December 17, 2015 23:59 — forked from henrik/.bashrc
Git branch prompt for Bash
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"