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
'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 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
{ | |
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 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 | |
} |
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
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
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
#!/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
# 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
defaultOptions = | |
'normalizeGmail': true | |
'lowerCaseLocal': true | |
'stripTags': true | |
'stripComments': true | |
class EmailNormalizer | |
constructor: ( @email, options = {} ) -> | |
@options = defaultOptions | |
for own k, v of options |
NewerOlder