Skip to content

Instantly share code, notes, and snippets.

Avatar

David Fernig davefernig

View GitHub Profile
View geometric_series_runtime.py
from __future__ import division
from random import randint
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
SAMPLES_PER_N_VALUE = 10000
N_VALUES = [2**n for n in (range(10))]
View statcan
# Before executing this script, run the following in your terminal:
# virtualenv .
# source bin/activate
# pip install beautifulsoup4
from bs4 import BeautifulSoup
import urllib2
path = "http://www12.statcan.gc.ca/census-recensement/2016/as-sa/98-200-x/2016001/98-200-x2016001-eng.cfm"
View numpy array to string and back
def __numpy_to_string(A):
return A.tostring().hex()
def __string_to_numpy(S):
return np.frombuffer(bytes.fromhex(S), dtype=np.float32)
@davefernig
davefernig / dpll
Last active Apr 12, 2021
Full code for solving SAT in Python
View dpll
import seaborn as sns
import pandas as pd
import pylab as plt
import numpy as np
import itertools
import random
import time
def brute_force(cnf):
View perudo-script
"""
A tool to calculate probabilities in Perudo.
David Fernig, 2018
"""
from __future__ import division
import scipy.special
class Round(object):
@davefernig
davefernig / gce_setup_script.sh
Last active Aug 11, 2017
set up data science tools on ubuntu on gce
View gce_setup_script.sh
#### commands to provision the instance ####
# install gcc and make
sudo apt-get update
sudo apt-get install gcc
sudo apt-get install build-essential
# install python3; pip
sudo apt-get install python3-setuptools
sudo apt-get install python3-tk