This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _annotate() { | |
echo "$(tput setaf 4)>>$(tput sgr0) $@" | |
eval $@ | |
} | |
function gup() { | |
branch=$([[ -n "$1" ]] && echo "$1" || git rev-parse --abbrev-ref HEAD) | |
dirty=$(git diff --shortstat 2> /dev/null | tail -n1) | |
_annotate git fetch || return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this replace method can take multiple finds and one or multiple replacements at a time | |
//if find is an array, replace will be called on every find | |
//if replace is an array, the indexes must match with find to do replacements. | |
//if replace is a string, it will be used for all replace calls if find is an array | |
//if find and replace are both strings, this will simply mimmick a normal str.replace(find, replace) call | |
//the result of all replacements will be returned at the end | |
_.mixin({ | |
replace: function(str, find, replace){ | |
//if str is null, just give up now | |
if (str === null){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.format = function(d, format, custom_months, custom_days){ | |
var months = custom_months || ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | |
,days = custom_days || ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
,replacements = [ | |
//day | |
[ '%d', (d.getDate() < 10 ? '0' : '') + d.getDate() ] //leading 0: 01-31 | |
, [ '%D', days[ d.getDay() ].substr(0, 3) ] //3 letter representation (Mon-Sun) | |
, [ '%j', d.getDate() ] //no leading 0: 1-31 | |
, [ '%l', days[ d.getDay() ] ] //[lowercase L], full textual representation (Monday-Sunday) | |
, [ '%N', (d.getDay() + 1) ] //day #: 1-7 (1=monday, 7=sunday) |