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
$ bex rails benchmarker 1000 "Artwork.where(:_id.in => [<...100 doc ids...>]).map(&:title)" "[<...100 doc ids...>].map{|id| Artwork.find(id) }.map(&:title)" | |
user system total real | |
#1 112.410000 1.470000 113.880000 (116.483996) | |
#2 151.740000 4.310000 156.050000 (166.557997) |
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
# Display current git branch, nicely colored, in the prompt (with a * if there are changes) | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
export PS1='\u:\[\033[31;40m\]\w\[\033[0;33m\]$(parse_git_branch)\[\e[0m\]$ ' | |
export EDITOR='mate -w' |
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
# install git | |
sudo apt-get install g++ curl libssl-dev apache2-utils | |
sudo apt-get install git-core | |
# download the Node source, compile and install it | |
git clone https://github.com/joyent/node.git | |
cd node | |
./configure | |
make | |
sudo make install | |
# install the Node package manager for later use |
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
def log_to_console | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
reload! | |
end | |
def sql(query) | |
ActiveRecord::Base.connection.select_rows(query) | |
end | |
def log_mongo_to_console |
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
# DirectoryGenerator.new.generate(Rails.root.join('src'), Rails.root.join('public', 'dest')) | |
class DirectoryGenerator | |
include Rails.application.routes.url_helpers | |
include ActionView::Helpers::TagHelper | |
default_url_options[:host] = 'www.example.com' | |
def generate(source, destination) | |
FileUtils.rmtree(destination) |
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
(in /Users/joey/devprojects/weplay) | |
Switched to branch 'staging' | |
Total 0 (delta 0), reused 0 (delta 0) | |
To git@github.com:weplay/weplay.git | |
39049f4..b8e52a9 staging -> staging | |
Switched to branch 'master' | |
./bin/ey deploy -e weplay_staging -r staging --no-migrate --verbose | |
Beginning deploy for 'weplay' in 'weplay_staging' on server... | |
(/usr/local/ey_resin/ruby/bin/gem list engineyard-serverside | grep 'engineyard-serverside ' | egrep -q '1\.3\.5[,)]') || (sudo sh -c 'cd `mktemp -d` && /usr/local/ey_resin/ruby/bin/gem install engineyard-serverside --no-rdoc --no-ri -v 1.3.5') | |
/usr/local/ey_resin/ruby/bin/engineyard-serverside _1.3.5_ deploy --app weplay --config '{"copy_exclude":[".git",".gitmodules",".gitignore","/features","/spec","/doc","/cookbooks"]}' --framework-env staging --instance-names ec2-184-72-222-254.compute-1.amazonaws.com:daemons ec2-72-44-44-248.compute-1.amazonaws.com:redismaster --instance-roles ec2-184-72-222-254.compute-1.amazonaws.com:util ec2-72-44-44-248.compute-1.amazonaws.com:util lo |
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
# Implements the algorithm used by the National Resident Matching Program | |
# (NRMP) to match residency and fellowship applicants to programs. The | |
# algorithm is described here: | |
# http://www.nrmp.org/fellow/algorithm.html | |
# and again here: | |
# http://www.nrmp.org/res_match/about_res/algorithms.html | |
# | |
# The Test class computes the example match scenario described on those pages. | |
module Match |
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
SELECT id, first_name, last_name, location, created_at, updated_at | |
INTO OUTFILE '/tmp/petition_signatures.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' | |
FROM petition_signatures; |
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 ruby | |
# Evaluates a sample of keys/values from each redis database, computing statistics for each key pattern: | |
# keys: number of keys matching the given pattern | |
# size: approximation of the associated memory occupied (based on size/length of value) | |
# percent: the proportion of this 'size' relative to the sample's total | |
# | |
# Copyright Weplay, Inc. 2010. Available for use under the MIT license. | |
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
# $ cloud console | |
> type = 'm1.large'; days=30; y AWS::EC2::Base.new(:access_key_id => ENV['EC2_ACCESS_KEY'], :secret_access_key => ENV['EC2_SECRET_KEY']).describe_spot_price_history(:instance_type => type, :product_description => "Linux/UNIX", :start_time => Time.now - 60*60*24*days)['spotPriceHistorySet']['item'].inject({}){|result, hash| result[hash['timestamp']] = hash['spotPrice']; result } |