Skip to content

Instantly share code, notes, and snippets.

View ismaild's full-sized avatar
🥊
Building Things...

Ismail Dhorat ismaild

🥊
Building Things...
View GitHub Profile
@ismaild
ismaild / confirmations_controller.rb
Last active December 14, 2015 13:59
Delayed Job
def create
if @confirmation.save
OrderMailer.delay.order_notification(@order)
@ismaild
ismaild / error_rspec.txt
Created February 28, 2013 07:54
Get the following error when trying to run rspec without using spork, if i disable better_errors & binding of caller this error goes away.
/Users/idhorat/.rvm/gems/ruby-1.9.3-p362@chow/gems/better_errors-0.3.2/lib/better_errors/core_ext/exception.rb:9: [BUG] Segmentation fault
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin11.4.2]
-- Control frame information -----------------------------------------------
c:0061 p:---- s:0194 b:0194 l:000193 d:000193 CFUNC :callers
c:0060 p:0072 s:0191 b:0191 l:000fc0 d:000950 LAMBDA /Users/idhorat/.rvm/gems/ruby-1.9.3-p362@chow/gems/better_errors-0.3.2/lib/better_errors/core_ext/exception.rb:9
c:0059 p:---- s:0188 b:0188 l:000187 d:000187 FINISH
c:0058 p:---- s:0186 b:0186 l:000185 d:000185 CFUNC :new
c:0057 p:---- s:0184 b:0184 l:000183 d:000183 CFUNC :require
c:0056 p:0012 s:0180 b:0180 l:000c08 d:000158 BLOCK /Users/idhorat/.rvm/gems/ruby-1.9.3-p362@chow/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251
@ismaild
ismaild / deploy_error.txt
Last active December 14, 2015 06:59
Assets precompile fails in production after enabling unicorn
Running: rake assets:precompile
rake aborted!
undefined method `match' for nil:NilClass
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions/factory.rb:103:in `new'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions/factory.rb:103:in `parse'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions/factory.rb:62:in `create_session'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions/factory.rb:43:in `default'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid/sessions.rb:109:in `default'
/tmp/build_pz2syblot4iq/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.23/lib/mongoid.rb:124:in `default_session'
@ismaild
ismaild / capybara_test_console.rb
Created January 3, 2013 21:44
for debugging capybara and rspec tests
# run rails c test
require 'capybara/dsl'
Capybara.app = app.instance_variable_get("@app")
cap = Object.new.instance_eval { extend Capybara::DSL; self }
cap.visit '/'
cap.page.find 'tr'
@ismaild
ismaild / sim_monty_hall.py
Created December 14, 2012 09:25
run simulation for monty hall problem
import random, pylab
#set line width
pylab.rcParams['lines.linewidth'] = 6
#set font size for titles
pylab.rcParams['axes.titlesize'] = 20
#set font size for labels on axes
pylab.rcParams['axes.labelsize'] = 20
#set size of numbers on x-axis
pylab.rcParams['xtick.major.size'] = 5
@ismaild
ismaild / models.py
Created November 29, 2012 08:35
mongoengine models
import datetime
from flask import url_for
from dashboard import db
class Page(db.Document):
title = db.StringField(max_length=100, required=True)
slug = db.StringField(max_length=100, required=True)
parent = db.StringField(max_length=100, required=False, default='')
@ismaild
ismaild / README.txt
Created November 25, 2012 14:58
README
Place holder
@ismaild
ismaild / urn.py
Created November 25, 2012 14:52
Monte Carlo Simulation for Urn Models
import random
def noReplacementSimulation(numTrials):
'''
Runs numTrials trials of a Monte Carlo simulation
of drawing 3 balls out of a bucket containing
3 red and 3 green balls. Balls are not replaced once
drawn. Returns the a decimal - the fraction of times 3
balls of the same color were drawn.
'''
count_matches = 0
@ismaild
ismaild / birthday.py
Created November 25, 2012 13:32
Bisection Search, Calculate Prob
def collision_prob(numIndices, numInsertions):
'''
Given the number of buckets and the number of items to insert,
calculates the probability of a collision.
'''
prob = 1.0
for i in range(1, numInsertions):
prob = prob * ((numIndices - i) / float(numIndices))
return 1 - prob
@ismaild
ismaild / __init__.py
Created November 23, 2012 12:32
tests for flask
from flask import Flask
app = Flask(__name__)