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
# Load the rails application | |
require File.expand_path('../application', __FILE__) | |
require 'objspace' | |
require 'digest/md5' | |
require 'base64' | |
# Initialize the rails application | |
MyApp::Application.initialize! | |
objs = File.open("/tmp/objs.txt", 'w') | |
at_exit { |
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
require 'fileutils' | |
start_time = Time.now | |
SOURCE_DB = { | |
:name => 'db_name', | |
:user => 'db_user', | |
:password => 'db_pass', | |
:host => 'localhost' |
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
mv ~/.ssh/id_rsa ~/.ssh/id_rsa.old | |
openssl pkcs8 -topk8 -v2 des3 -in ~/.ssh/id_rsa.old -out ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
rm ~/.ssh/id_rsa.old |
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
require 'priority_queue' | |
require 'set' | |
class Node | |
def initialize(x, y) | |
@x = x | |
@y = y | |
@obstacle = false | |
@g_score = Float::INFINITY | |
end |
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
#pos is the number of positive ratings | |
#n is the total number of ratings | |
def score_ratings(pos, n) | |
#modified shamelessly from http://evanmiller.org/how-not-to-sort-by-average-rating.html | |
return 0 if n == 0 | |
# require 'statistics2' | |
# z = Statistics2.pnormaldist(1-(1-confidence)/2) | |
# the z score refers to a confidence: pick 0.95 to have a 95% chance that your lower bound is correct, 0.975 to have a 97.5% chance, etc. |
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
sudo tcpflow -c -n en1 src or dst host api.example.com | |
EM.run do | |
request = EventMachine::HttpRequest.new('http://api.example.com/') | |
deferrable = request.get :path => '/api/v2/chickens.json' | |
deferrable.callback { puts "It worked"; EM.stop } | |
deferrable.errback { puts "It failed"; EM.stop } | |
end |
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
require 'bundler' | |
Bundler.require | |
url = 'http://0.0.0.0:9000/images/avatar.png' | |
EM.run do | |
http = EventMachine::HttpRequest.new(url).get | |
http.stream {|chunk| print [:chunk, chunk.size] } | |
http.headers {|h| p [:headers, h] } |
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
create a Procfile << app: ruby script/app | |
rvmsudo foreman export upstart /etc/init -a app -u achaudhry |
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
sudo tcpdump -vi eth0 port 53 |
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
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' |