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
create a Procfile << app: ruby script/app | |
rvmsudo foreman export upstart /etc/init -a app -u achaudhry |
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
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 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
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 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
#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 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
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 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
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 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
require 'fileutils' | |
start_time = Time.now | |
SOURCE_DB = { | |
:name => 'db_name', | |
:user => 'db_user', | |
:password => 'db_pass', | |
:host => 'localhost' |
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 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 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
" copy all this into a vim buffer, save it, then... | |
" source the file by typing :so % | |
" Now the vim buffer acts like a specialized application for mastering vim | |
" There are two queues, Study and Known. Depending how confident you feel | |
" about the item you are currently learning, you can move it down several | |
" positions, all the way to the end of the Study queue, or to the Known | |
" queue. | |
" type ,, (that's comma comma) |
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
angular.module('myApp', | |
['ngRoute', 'myApp.services', 'myApp.directives'] | |
) | |
.config(function(AWSServiceProvider) { | |
AWSServiceProvider.setArn('arn:aws:iam::<ACCOUNT_ID>:role/google-web-role'); | |
}) | |
.config(function(StripeServiceProvider) { | |
StripeServiceProvider.setPublishableKey('pk_test_YOURKEY'); | |
}) | |
.config(function($routeProvider) { |