View Gemfile
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
source :rubygems | |
gem 'bench_press' | |
gem 'multi_json' | |
gem 'json' | |
gem 'yajl-ruby' | |
gem 'msgpack' | |
gem 'ruby-protocol-buffers' | |
gem 'bson' | |
gem 'bson_ext' |
View Gemfile
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
source "http://rubygems.org" | |
gem 'bundler', ">= 1.2.1" | |
gem 'redis', ">= 3.0.2" | |
gem 'hiredis', ">= 0.4.5" | |
gem 'bench_press', ">= 0.3.1" | |
View build_atlas.sh
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
# UPDATE to Get the latest versions | |
wget http://www.netlib.org/lapack/lapack-3.4.2.tgz | |
wget http://sourceforge.net/projects/math-atlas/files/Stable/3.10.0/atlas3.10.0.tar.bz2/download?use_mirror=ufpr | |
tar -vxf atlas3.10.0.tar.bz2 | |
cd ATLAS | |
mkdir build | |
cd build | |
################################## -t 8 means 8 threads. depending on the ec2 instance you can choose more threads | |
### V 448 means SSE1/2/3 support. A14 means x86SSE364SSE2 architecture. check the documentation for more information | |
### if you run smaller instances you may get 32 bit machines. in this case you need to build -b 32, too and install the |
View gist:4030891
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
grep "XXXXXXX" file.log | cut -d"," -f5 | sort | awk '{a[$0]++} END{for (i in a) if (a[i]>1) printf "%10d\t%5.2f%%\t%s\n", a[i], 100*a[i]/NR, i}' | sort -rn |
View gist:4030943
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
tail -f file.log |perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}' |
View humanize.rb
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 humanize(milliseconds) | |
[[1000, :milliseconds], [60, :seconds], [60, :minutes], [24, :hours], [365, :days], [+1.0/0.0, :years]].inject([]){ |m, (count, name)| | |
if milliseconds > 0 | |
milliseconds, n = milliseconds.divmod(count) | |
m.unshift "#{n.to_i} #{name}" | |
end | |
m | |
}.join(' ') | |
end |
View StreamingStats.rb
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
# Check: http://www.johndcook.com/standard_deviation.html | |
module OmniRPC | |
module Util | |
class StreamingStats | |
attr_reader :min, :max | |
def initialize | |
@m_n = 0.0 | |
@max = -Float::INFINITY | |
@min = Float::INFINITY |
View extract_mongo_id.sh
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
cat users.in | cut -f1 | ruby -e "ARGF.each_line { |line|puts Time.at(line[0...8].to_i(16)).strftime(\"%Y%m%d\") }" | sort -r | uniq -c |
View convert_number_to_base.rb
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 convert(number, base=10) | |
raise "base must be between 2 and 36" if base < 2 || base > 36 | |
negative = number < 0 | |
number = number.abs | |
number_array = [] | |
loop do | |
number_array.unshift("0123456789abcdefghijklmnopqrstuvwxyz"[number % base]) | |
number /= base | |
break if number == 0 | |
end |
View encrypted_attribute_helper.rb
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 defined?(ActiveRecord::Base) | |
module AttrEncrypted | |
module Adapters | |
module ActiveRecord | |
protected | |
class EncryptedAttributeClassWrapper | |
attr_reader :klass | |
def initialize(klass); @klass = klass; end | |
end |
OlderNewer