Skip to content

Instantly share code, notes, and snippets.

View abdollar's full-sized avatar

Abdul Chaudhry abdollar

View GitHub Profile
@abdollar
abdollar / gist:7132292
Created October 24, 2013 06:33
ObjectSpace - record rails allocations
# 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 {
@abdollar
abdollar / Delete by Query - SOLR
Created March 8, 2011 04:16
Delete by Query to delete from SOLR
delete from solr - delete by query
curl http://hostname:port/solr/update --data-binary '<delete><query>id:123456</query></delete>' -H 'Content-type:text/xml; charset=utf-8'
curl http://hostname:port/solr/update --data-binary '<commit waitFlush="false" waitSearcher="false" expungeDeletes="true"/>' -H 'Content-type:text/xml; charset=utf-8'
@abdollar
abdollar / tensorflow101.ipynb
Created March 14, 2017 06:26 — forked from fuglede/tensorflow101.ipynb
TensorFlow 101
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
" 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)
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@abdollar
abdollar / gist:5646361
Created May 24, 2013 20:37
protect private ssh key
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
@abdollar
abdollar / astar.rb
Created February 25, 2013 06:11 — forked from mburst/astar.rb
require 'priority_queue'
require 'set'
class Node
def initialize(x, y)
@x = x
@y = y
@obstacle = false
@g_score = Float::INFINITY
end
@abdollar
abdollar / gist:2295194
Created April 3, 2012 20:09
wilson score confidence interval - what percentage of people took some sort of action
#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.
@abdollar
abdollar / gist:1860869
Created February 18, 2012 19:59
Debugging http with tcpflow
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
@abdollar
abdollar / client.rb
Created January 23, 2012 20:24 — forked from igrigorik/client.rb
chunked file stream with goliath
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] }