Skip to content

Instantly share code, notes, and snippets.

View brydavis's full-sized avatar

Bryan Davis brydavis

View GitHub Profile
package main
import "regexp"
func CleanQuery(q string) string {
r1 := regexp.MustCompile(`\s+`)
r2 := regexp.MustCompile(`--[^\n]*\n`)
q = r2.ReplaceAllString(q, "")
return r1.ReplaceAllString(q, " ")
}
// heavily borrowed from Rosetta Code example
package main
import "fmt"
type row map[string]interface{}
var (
tableA = []row{
row{"name": "Jonah", "age": 27},
// heavily borrowed from Rosetta Code example
package main
import (
"fmt"
)
type row map[string]interface{}
var (
# 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?"))