Skip to content

Instantly share code, notes, and snippets.

View BBischof's full-sized avatar

Bryan Bischof BBischof

  • current: Theory Ventures | prev: Hex, Weights and Biases, Stitch Fix, Blue Bottle, QuasiCoherent Labs, IBM
  • Berkeley, California
  • X @bebischof
View GitHub Profile
@BBischof
BBischof / .block
Last active July 16, 2016 05:08
Housing Violations Data - 2012
license: gpl-3.0
height: 700
scrolling: yes
@BBischof
BBischof / .block
Created June 26, 2016 23:39
Orthographic Clipping
license: gpl-3.0
@BBischof
BBischof / d3.hive.min.js
Created May 24, 2016 03:06
International Travel Visa Topology -- Hive Plot Visualization
d3.hive={},d3.hive.link=function(){function t(t,s){var u,h=a(r,this,t,s),i=a(n,this,t,s);h.a>i.a&&(u=i,i=h,h=u),i.a-h.a>Math.PI&&(h.a+=2*Math.PI);var e=h.a+(i.a-h.a)/3,c=i.a-(i.a-h.a)/3;return h.r0-h.r1||i.r0-i.r1?"M"+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0+"L"+Math.cos(h.a)*h.r1+","+Math.sin(h.a)*h.r1+"C"+Math.cos(e)*h.r1+","+Math.sin(e)*h.r1+" "+Math.cos(c)*i.r1+","+Math.sin(c)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1+"L"+Math.cos(i.a)*i.r0+","+Math.sin(i.a)*i.r0+"C"+Math.cos(c)*i.r0+","+Math.sin(c)*i.r0+" "+Math.cos(e)*h.r0+","+Math.sin(e)*h.r0+" "+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0:"M"+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0+"C"+Math.cos(e)*h.r1+","+Math.sin(e)*h.r1+" "+Math.cos(c)*i.r1+","+Math.sin(c)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1}function a(t,a,r,n){var e=t.call(a,r,n),c=+("function"==typeof s?s.call(a,e,n):s)+i,o=+("function"==typeof u?u.call(a,e,n):u),M=u===h?o:+("function"==typeof h?h.call(a,e,n):h);return{r0:o,r1:M,a:c}}var r=function(t){return t.source},n=f
@BBischof
BBischof / delete_it.sh
Created May 12, 2016 00:20
deleting a specific git commit
#how to deal with this obnoxious issue.
git log
#look for the <commmit-id> of the offending commit
git rebase --onto <commit-id>^ <commit-id> HEAD
@BBischof
BBischof / takeWhileSumLess.scala
Created April 12, 2016 22:07
I like this example of grabbing elements from a List until you reach your desired sum.
{ var sum = 0; (1 to 10000) takeWhile { i => sum += i; sum <= 100 } }
@BBischof
BBischof / shitty_dt_formatter.scala
Last active May 12, 2016 00:21
This is the result of JODA not being serializable in scala, resorting to utter bullshit, assumes year is 2016.
def fake_dt_formatter(month: String, day: String, time: String): Int = {
val YEAR_2016 = 1451606400
val days: List[Int] = List(0,31,60,91,121,152,182,213,243,274,304,335)
val month_num = days("JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(month) / 3) * 86400
val day_num = (day.toInt-1) * 86400
val time_vals = time.split(":")
val time_num = time_vals(0).toInt * 3600 + time_vals(1).toInt * 60 + time_vals(2).toInt
return YEAR_2016 + month_num + time_num + day_num
}
@BBischof
BBischof / bean_counter.scala
Created April 1, 2016 18:47
Computing the amount of beans for the hopper
def bean_counter(output_shots: Int) : Int = {
if (output_shots >= 0) {
return (output_shots/2)*20 + output_shots%2*16
} else {
throw new IllegalArgumentException("Not a valid number of shots.")
}
}
@BBischof
BBischof / expandIt.py
Created March 22, 2016 19:05
A solution to a codefights daily puzzle that was amusing and might be useful to reference
# You are given a string s composed of letters and numbers, which was compressed with some algorithm. Every letter in s is followed by a number (possibly with leading zeros), which represents the number of times this letter occurs consecutively. For example, "aaaaaaaabbbbbbcc" would be given as "a8b6c2".
# Decompress s, sort its letters and return the kth (1-based) letter of the obtained string.
# Note: each letter occurs in s no more than 251 times.
# Example
# Expand_It("a2b3c2a1", 2) = "a"
@BBischof
BBischof / hist.sh
Last active March 9, 2016 01:45
Makes a little histogram in bash from your data. Uses = for bars
while read d n
do
printf "%s\t%${n}s" "$d" = | tr ' ' '=' ;
echo " $n" ;
done < data.txt
def memoize(f):
cache = {}
def decorated_function(*args):
if args in cache:
return cache[args]
else:
cache[args] = f(*args)
return cache[args]
return decorated_function