Skip to content

Instantly share code, notes, and snippets.

View cpdean's full-sized avatar

Conrad cpdean

View GitHub Profile

Collecting examples that break or do not break.

Next step is refactoring the broken bq example into the https requests example using the same http lib that bq does.

need to get to the root of why SSLErrors are thrown

which?

$ which which
/usr/bin/which
$ which $(!!)
which $(which which)
/usr/bin/which
$ which $(!!)
which $(which $(which which))
/usr/bin/which
@cpdean
cpdean / .bash_profile
Created August 5, 2015 20:30
source aws creds from the cred file
export AWS_CREDENTIAL_FILE=/Users/deanc/.aws_credential_file
export AWS_SECRET_ACCESS_KEY=$(cat $AWS_CREDENTIAL_FILE | grep -i secret | cut -d "=" -f 2)
export AWS_ACCESS_KEY_ID=$(cat $AWS_CREDENTIAL_FILE | grep -i access | cut -d "=" -f 2)
@cpdean
cpdean / gist:888994
Created March 27, 2011 06:46
line 28 is some bullshit
def fib(n):
if n in (0,1):
return n
else:
return fib(n-1) + fib(n-2)
def memoize(n):
cache = {}
def helper(x):
if x not in cache:
@cpdean
cpdean / collatz.py
Created September 9, 2011 15:29 — forked from msalahi/collatz.py
oheyandy
import time
bound,mem = 1000000,{}
def collatz(n):
if n==1: return [1]
else: return [n] + collatz(n/2 if (n%2==0) else 3*n+1) if (n>1) else [1]
def collatzCount_recursive_memoized(n):
if n not in mem: mem[n]= 1 + collatzCount_recursive_memoized(n/2 if (n%2==0) else 3*n+1) if (n>1) else 1
return mem[n]
@cpdean
cpdean / guy.py
Created September 9, 2011 16:53
python optimizations
import time
import itertools
import hashlib
def regular_for_loop(bound):
_md5 = hashlib.md5()
for i in itertools.repeat("foo", bound):
_md5.update(i)
@cpdean
cpdean / isabundant.py
Created September 14, 2011 17:51
another speedup challenge
import math
def isAbundant(n,f): #make this run fast
div = f(n)
return True if sum(div)>n else False
def factors_for_loop_plus_operator(n):
# bug, feed this a perfect square and the square root
# will be counted twice
div = [1]
@cpdean
cpdean / tests.py
Created September 15, 2011 22:40
testing the 'in' operator #science
from time import time
def test(iterable):
start = time()
for i in range(scale):
if i in iterable:
a = 90.0 + 6000
return time()-start
def aggregate(count,f,a):
@cpdean
cpdean / muradWeek8.py
Created September 23, 2011 17:41 — forked from msalahi/muradWeek8.py
MuradWeek8Solution
from time import time
from math import sqrt
def disproves(n):
i=2
while i*i*2<n:
diff = n-i*i*2
if not any(diff%j==0 for j in xrange(3,int(sqrt(diff))+1,2)) :return False
i+=1
return True
n=3
@cpdean
cpdean / Tracer.js
Created October 23, 2011 03:24
disecting that clipboard hijacker
Tynt = window.Tynt || [];
if (typeof Tynt.TIL == "undefined") {
(function() {
var Ja = function() {
var h = document,
l = h.body,
p = h.documentElement,
aa = eval("/*@cc_on!@*/false"),
ba = function(a, b) {