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
ipSort = ( ipAddressArray ) -> | |
ipAddressArray.sort ( a, b ) -> | |
a = a.split '.' | |
b = b.split '.' | |
for i of a | |
if ( a[i] = parseInt a[i] ) < ( b[i] = parseInt b[i] ) | |
return -1 | |
else if a[i] > b[i] | |
return 1 | |
return 0 |
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
Number.prototype.formatNum = ( decimal = true, millionify = 1 ) -> | |
if @ > 999999 && millionify | |
"#{( Math.round( @ / 100000 ) / 10 ).formatNum decimal, millionify - 1}m" | |
else | |
[n,d] = "#{@}".split '.' | |
reg = /(\d+)(\d{3})/ | |
while reg.test n | |
n = n.replace reg, '$1,$2' | |
n + if d? and decimal then ( if not decimal then ".#{d.substr( 0 , decimal )}" else ".#{d}" ) else '' |
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
defaultOptions = | |
'normalizeGmail': true | |
'lowerCaseLocal': true | |
'stripTags': true | |
'stripComments': true | |
class EmailNormalizer | |
constructor: ( @email, options = {} ) -> | |
@options = defaultOptions | |
for own k, v of options |
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
# Just add new languages to this object | |
Date.locale = | |
'en': | |
'months': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | |
'days': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] | |
'ordinals': ['th', 'st', 'nd', 'rd'] | |
# Get current locale | |
Date.prototype.getLocale = ( lang ) -> |
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
#!/usr/bin/env bash | |
# Check we've got command line arguments | |
if [ -z "$*" ] ; then | |
echo "Need to specify ssh options" | |
exit 1 | |
fi | |
# Start trying and retrying | |
((count = 100)) |
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
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
$bckgrnd = "DarkRed" | |
$shellchar = "#" | |
} else { | |
$bckgrnd = "DarkBlue" | |
$shellchar = "$" | |
} | |
$Host.UI.RawUI.BackgroundColor = $bckgrnd | |
$Host.UI.RawUI.ForegroundColor = 'White' |
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
updateWindowTitle() | |
{ | |
echo -ne "\033];Home - ${HOSTNAME}:${PWD/$HOME/~}\007"; | |
}; | |
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh | |
# Aliases | |
alias cd="pushd" | |
alias bd="popd" |
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
numberize = (fn) -> (a, b) -> fn Number(a), Number(b) | |
changeDirection = (pos, direction) -> | |
if direction is '?' then direction = '^v<>'[parseInt Math.random() * 4] | |
[pos.dx, pos.dy] = {'^': [0,-1], 'v': [0,1], '<': [-1,0], '>': [1,0]}[direction] | |
pos | |
operations = | |
'+': numberize (a, b) -> a + b | |
'-': numberize (a, b) -> b - a | |
'*': numberize (a, b) -> a * b |
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 () { | |
// Limit the number of events to be attached | |
var limits = { | |
'keydown': 100 | |
}; | |
// Skip this number of events | |
var skips = { | |
'keydown': 1 | |
} |
OlderNewer