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
#!/bin/bash | |
rake db:migrate | |
git init | |
git add --all | |
git commit -m "generate rails app" | |
cat ~/dotfiles/Gemfile_template >> Gemfile | |
git add --all | |
git commit -m "add required testing gems" | |
rm -rf test |
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 ruby | |
class TimeMachine | |
def initialize(dir) | |
@dir = dir | |
end | |
def start! | |
unless File.exists?("#{@dir}/.git") | |
init_backup! |
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
var fs = require("fs"); | |
var addBasePath = function(path) { | |
if (/\/$/.test(path)) { | |
return function(dir) { return path + dir }; | |
} else { | |
return function(dir) { return path + "/" + dir }; | |
} | |
}; |
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
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |
# Uncomment if you are using Rails' asset pipeline | |
# load 'deploy/assets' | |
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
load 'config/deploy' # remove this line to skip loading any of the default tasks |
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
$ bundle exec cap deploy | |
triggering load callbacks | |
* 2014-05-15 09:49:58 executing `staging' | |
triggering start callbacks for `deploy' | |
* 2014-05-15 09:49:58 executing `multistage:ensure' | |
* 2014-05-15 09:49:58 executing `deploy' | |
* 2014-05-15 09:49:58 executing `deploy:update' | |
** transaction: start | |
* 2014-05-15 09:49:58 executing `deploy:update_code' | |
updating the cached checkout on all servers |
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
add = (x, y) -> x+y | |
squared = (x) -> x*x | |
console.log f.curry(add)(1)(2) | |
console.log f.curry(Array::map, [1,2,3])(squared) | |
f.flip(f.join)((-> console.log "hi"), (-> console.log "there"))() |
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
import Foundation | |
// Build 100 random numbers between 0 and 100 | |
var numbers = Int[]() | |
for i in 1..100 { | |
let n = Int(arc4random() % 101) | |
numbers.append(n) | |
} | |
func elementsInRange<T>(a: T[], start: Int, end: Int) -> (T[]) { |
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
mergesort = (-> | |
merge = (x, y, acc = []) -> | |
if x.length == 0 | |
acc.concat(y) | |
else if y.length == 0 | |
acc.concat(x) | |
else if x[0] < y[0] | |
merge x[1..-1], y, acc.concat x[0] | |
else | |
merge x, y[1..-1], acc.concat y[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
#pragma mark - validation | |
- (BOOL)validateForInsert:(NSError *__autoreleasing *)error { | |
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init]; | |
[userInfo setObject:@"Cannot add more than 10 moves" forKey:NSLocalizedFailureReasonErrorKey]; | |
[userInfo setObject:self forKey:NSValidationObjectErrorKey]; | |
NSError *tooManyMovesError = [NSError errorWithDomain:@"TenMovesDomain" code:NSManagedObjectValidationError userInfo:userInfo]; | |
if (*error == nil) { |