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 / producer.py
Created September 27, 2012 13:37
Producer for PyF
import os
import csv
f = os.path.join('/Users/ismail/sandbox/repos_own/pyf/','tmp.txt')
FIELDS = [
'A',
'B',
'C',
'D'
@ismaild
ismaild / app.py
Created November 21, 2012 22:47
My App Code
charts_dict = {
'inactivity': {
'title': 'Inactivity Aging Summary' ,
'url': 'inactivity.json',
'container': 'inactivity',
'width': '100%',
'height': '250'
}
}
@app.route('/dashboard')
@ismaild
ismaild / __init__.py
Created November 23, 2012 12:32
tests for flask
from flask import Flask
app = Flask(__name__)
@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 / 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 / README.txt
Created November 25, 2012 14:58
README
Place holder
@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 / 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 / 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 / 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'