Skip to content

Instantly share code, notes, and snippets.

View brydavis's full-sized avatar

Bryan Davis brydavis

View GitHub Profile
# coding: utf-8
# In[70]:
import re
ssn_data = [
["000115464","000135464"], # 4
["763415464", "165415464"], #6
@brydavis
brydavis / account.lua
Created May 2, 2016 23:49
Basic Bank Accounts in Lua
local MAX_ACCOUNT_ID = 1
function withdraw(self, v)
self.balance = self.balance - v
end
function deposit (self, v)
self.balance = self.balance + v
end
@brydavis
brydavis / csv.lua
Created May 3, 2016 06:40
Package for Parsing CSV Files
CSV = {}
function CSV:load (filename, headers)
headers = headers or false
-- if not headers then
file = io.open(filename, "r") -- "test.csv"
linecount = 0
panel = {}
setmetatable(panel, self)
@brydavis
brydavis / compfin.py
Created June 1, 2016 21:20
CompFin via Coursera
from __future__ import division
import math
def future_value(V, R, n, m=1):
return V * (1+(R/m))**(n*m)
def present_value(FV, R, n):
return FV / ((1+R)**n)
0000000 000 0000000
111111111 11111111100 000 111111111
00000 111111111111111111 00000 000000
000 1111111111111111111111111100000 000
000 1111 1111111111111111100 000
000 11 0 1111111100 000
000 1 00 1 000
000 00 00 1 000
000 000 00000 1 000
00000 0000 00000000 1 00000
package main
import (
"container/ring"
"fmt"
"os"
"time"
)
func main() {
package main
import "fmt"
func main() {
a := A{}
a.N = "hello"
fmt.Println(a.Method.O("world"))
fmt.Println(a.Method.I("whatup!"))
fmt.Println(a.Method.F("wtf?"))
# coding: utf-8
# In[39]:
import re
import pymysql
import pandas as pd
original_headers = """NPI","Entity Type Code","Replacement NPI","Employer Identification Number (EIN)","Provider Organization Name (Legal Business Name)","Provider Last Name (Legal Name)","Provider First Name","Provider Middle Name","Provider Name Prefix Text","Provider Name Suffix Text","Provider Credential Text","Provider Other Organization Name","Provider Other Organization Name Type Code","Provider Other Last Name","Provider Other First Name","Provider Other Middle Name","Provider Other Name Prefix Text","Provider Other Name Suffix Text","Provider Other Credential Text","Provider Other Last Name Type Code","Provider First Line Business Mailing Address","Provider Second Line Business Mailing Address","Provider Business Mailing Address City Name","Provider Business Mailing Address State Name","Provider Business Mailing Address Postal Code","Provider Business Mailing Address Country Code (If outside U.S.)","Provider Business Mailing A
# http://machinelearningmastery.com/naive-bayes-classifier-scratch-python/
import pandas as pd
import random
pima = pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data", header=None)
pima.columns = [
"num_pregnant",
"plasma_glucose",
"diastolic_bp",
def fac(n):
return int(n * fac(n-1)) if (n-1) > 0 else n
def perm(n,r): # n! / (n-r)!
return int(fac(n) / fac(n-r))
def comb(n,r): # n! / r!(n-r)!
return int(fac(n) / (fac(r)*fac(n-r)))