This file contains 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 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 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
'use strict'; | |
const Promise = require('bluebird'); | |
const _ = require('lodash'); | |
const path = require('path'); | |
const fs = Promise.promisifyAll(require('fs')); | |
const DEBUG = true; | |
const FILENAME = './gc'; | |
const RUBBISH_THRESHOLD = 5; | |
const ALPHA_REGEX = /^[a-zA-Z\s]+$/; |
This file contains 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 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
{ | |
init: function(elevators, floors) { | |
function getLeastBusyElevator(elevators) { | |
return elevators.reduce(function (currentLeast, thisElevator) { | |
if (thisElevator.destinationQueue.length < currentLeast.destinationQueue.length && | |
thisElevator.loadFactor() < 0.75 | |
) { | |
return thisElevator; | |
} else { | |
return currentLeast; |
This file contains 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 | |
} |
This file contains 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 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 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' |
NewerOlder