Skip to content

Instantly share code, notes, and snippets.

View asalant's full-sized avatar

Alon Salant asalant

  • Good Eggs
  • San Francisco
View GitHub Profile
@asalant
asalant / piglatin.js
Created October 4, 2012 19:36
Alex Piglatin
var assert = require('assert');
function pigLatin(input)
{
var result = input;
result = result.replace(/(\w+)/g, function(match)
{
var firstChar = match.charAt(0),
firstCharCode = firstChar.charCodeAt(0),
@asalant
asalant / gist:3710244
Created September 12, 2012 21:58
brandon piglatin
function pigTranslate(phrase){
return phrase.split(" ").map(function(item){
return wordTranslate(item);
}).join(" ");
}
function wordTranslate(word){
var firstLetter = word.substring(0,1);
var restOfWord = word.substring(1);
if(firstLetter.match(/[A-Z]/)){
firstLetter = firstLetter.toLowerCase();
@asalant
asalant / setup.sh
Created June 7, 2012 20:41
Good Eggs dev workstation setup with chef soloist
# bash <(curl -s https://raw.github.com/gist/2891426)
read -p "Install Xcode (from the App store) and gcc for Lion (http://github.com/kennethreitz/osx-gcc-installer) and press enter to continue."
# setup your ssh keys for github
if ! [ -e "$HOME/.ssh/id_rsa.pub" ]
then
echo "Generating ssh key..."
read -p "Please enter the email you want to associate with your ssh key: " email
ssh-keygen -t rsa -C "$email"
@asalant
asalant / sync.sh
Created April 28, 2012 15:31
imapsync script for copying one one google apps account to another
# See:
# http://www.linux-france.org/prj/imapsync_list/msg00616.html
# http://www.linux-france.org/prj/imapsync_list/msg00639.html
imapsync \
--fast \
[email protected] [email protected] \
--password1 password1 \
[email protected] [email protected] \
--password2 password2 \
@asalant
asalant / heroku-app.sh
Created February 18, 2012 06:13
Bash/zsh/... function for simpler heroku command line usage with multiple apps for the same project.
# Alias heroku for simpler multi-app projects
heroku-app() {
args=("$@")
if [ "${args[1]}" = "staging" ]; then
args+=("--app" "goodeggs-garbanzo-staging")
index=1
elif [ "${args[1]}" = "production" ]; then
args+=("--app" "goodeggs-garbanzo")
index=1
else
@asalant
asalant / async_helper.coffee
Created November 26, 2011 04:02
Provide better asynchronous support for jasmine-node
# Monkey patch jasmine.Env to wrap spec ('it', 'beforeEach', 'afterEach')
# in async handler if it expects a done callback
withoutAsync = {}
for jasmineFunction in [ "it", "beforeEach", "afterEach"]
do (jasmineFunction) ->
withoutAsync[jasmineFunction] = jasmine.Env.prototype[jasmineFunction]
jasmine.Env.prototype[jasmineFunction] = (args...) ->
specFunction = args.pop()
# No async callback expected, so not async
if specFunction.length == 0
@asalant
asalant / example2.coffee
Created November 26, 2011 03:50
Asynchronous jasmine-node example 2
describe 'User', ->
describe '#save()', ->
it 'should save without error', (done) ->
user = new User('Luna')
user.save(done)
@asalant
asalant / example1.coffee
Created November 26, 2011 03:49
Asynchronous jasmine-node example 1
describe 'User', ->
describe '#save()', ->
it 'should save without error', (done) ->
user = new User('Luna')
user.save (error) ->
expect(error).toBeNull()
done();
@asalant
asalant / spec_helper.coffee
Created November 7, 2011 07:10
Require jasmine runner if jasmine has not already been loaded
process.env.NODE_ENV = 'test' unless process.env.NODE_ENV?
require './jasmine_runner' unless jasmine?
#...
@asalant
asalant / gist:1344358
Created November 7, 2011 06:58
Debug spec with coffeescript
coffee --nodejs --debug-brk spec/app.spec.coffee