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 / update_dict.py
Created December 18, 2017 05:59
Finally a clean way to update dictionaries in python if you're unsure all keys exist
your_dict = {}
for i in some_iterator:
your_dict[i] = new_value if i not in your_dict else your_dict[i]+new_value
'''a version with the new value coming from a new dict'''
your_dict = {}
for i in some_iterator:
your_dict[i] = new_values[i] if i not in your_dict else your_dict[i]+new_values[i]
'''a kinda dumb example; letter frequencies'''
@BBischof
BBischof / create_kernel.sh
Created January 1, 2018 03:29
create a kernel from a pip_reqs
experiment_name=$1
pip_reqs_file=$2
mkdir $experiment_name
cd $experiment_name
cp $pip_reqs_file .
venv_name="venv_"$experiment_name
virtualenv -p python $venv_name
source $venv_name/bin/activate
pip install -r ../$pip_reqs_file
pip install ipykernel
@BBischof
BBischof / isprime_variants_2-999.csv
Created January 14, 2018 01:50
four variations of isprime for the first thousand integers, shuffled and rotated counts don't include original in their counts, but require it
num isprime shuffledprime_count rotatedprime_count reversedprime
2 1 0 0 1
3 1 0 0 1
4 0 0 0 0
5 1 0 0 1
6 0 0 0 0
7 1 0 0 1
8 0 0 0 0
9 0 0 0 0
10 0 0 0 0
@BBischof
BBischof / coffee_ICO_location.csv
Last active April 12, 2018 05:56
Coffee ISO Code Location Lookup
Exporting Member Country code Certifying Agent Port code Port name Lat Long
Angola 158 Instituto Nacional do Café de Angola (INCA) 1 Cabinda -5.5775197 12.1927103
Angola 158 Instituto Nacional do Café de Angola (INCA) 4 Luanda -8.839987599999999 13.2894368
Angola 158 Instituto Nacional do Café de Angola (INCA) 5 Porto Amboin -10.7330115 13.7694692
Angola 158 Instituto Nacional do Café de Angola (INCA) 7 Porto Lobito -12.3477219 13.5473065
Benin 22 Société nationale pour la promotion agricole (SONAPRA) 1 Cotonou 6.3702928 2.3912362
Bolivia 1 Cámara Nacional de Exportadores de Bolivia (CANEB) 1 Arica -17.9769831 -67.1036668
Bolivia 1 Cámara Nacional de Exportadores de Bolivia (CANEB) 2 Antofagasta -17.371468 -66.27724289999999
Bolivia 1 Cámara Nacional de Exportadores de Bolivia (CANEB) 3 Matarani - Bolivia -17.8032338 -65.800331
Bolivia 1 Cámara Nacional de Exportadores de Bolivia (CANEB) 4 Villazón -22.0853991 -65.5975218
local_date_id ferry_bfstba_aprict_pre ferry_bfstba_aprict_post mint_bfstba_aprict_pre mint_bfstba_aprict_post linden_bfstba_aprict_pre linden_bfstba_aprict_post webster_bfstba_aprict_pre webster_bfstba_aprict_post morse_bfstba_aprict_pre morse_bfstba_aprict_post palo_alto_bfstba_aprict_pre palo_alto_bfstba_aprict_post market_sq_bfstba_aprict_pre market_sq_bfstba_aprict_post sansome_bfstba_aprict_pre sansome_bfstba_aprict_post instagram_bfstba_aprict_pre instagram_bfstba_aprict_post berkeley_bfstba_aprict_pre berkeley_bfstba_aprict_post south_park_bfstba_aprict_pre south_park_bfstba_aprict_post pacific_heights_bfstba_aprict_pre pacific_heights_bfstba_aprict_post old_oak_bfstba_aprict_pre old_oak_bfstba_aprict_post ferry_bfstba_stlmar_pre ferry_bfstba_stlmar_post mint_bfstba_stlmar_pre mint_bfstba_stlmar_post linden_bfstba_stlmar_pre linden_bfstba_stlmar_post webster_bfstba_stlmar_pre webster_bfstba_stlmar_post morse_bfstba_stlmar_pre morse_bfstba_stlmar_post palo_alto_bfstba_stlmar_pre palo_alto_bfstba_stlmar_
@BBischof
BBischof / .block
Last active June 14, 2018 15:01
Parallel Coordinates
license: gpl-3.0
@BBischof
BBischof / .block
Last active November 9, 2018 01:57
Bay Area Climb Rankings Parallel Coordinates
license: mit
@BBischof
BBischof / date_id_2_date
Created August 22, 2018 19:44
Tableau Magic to cast Date_Id to a convenient date format, assumed YYYYMMDD
DATE(DATEADD('day',[date_id] % 100 - 1,
DATEADD('month', INT(([date_id] % 10000) / 100) - 1,
DATEADD('year', INT([date_id] / 10000) - 1900,
#1900-01-01#))))
@BBischof
BBischof / lightswitch_simulation_probabilities.json
Created November 22, 2018 00:18
probabilities data for a xor simulation
{ "4": [
{"Initial_lights":0,"Remaining_lights":0,"probability":0.81450625},
{"Initial_lights":0,"Remaining_lights":1,"probability":0.17147500000000004},
{"Initial_lights":0,"Remaining_lights":2,"probability":0.013537500000000004},
{"Initial_lights":0,"Remaining_lights":3,"probability":0.0004750000000000001},
{"Initial_lights":0,"Remaining_lights":4,"probability":0.000006250000000000003},
{"Initial_lights":1,"Remaining_lights":0,"probability":0.04286875},
{"Initial_lights":1,"Remaining_lights":1,"probability":0.821275},
{"Initial_lights":1,"Remaining_lights":2,"probability":0.1289625},
{"Initial_lights":1,"Remaining_lights":3,"probability":0.006775000000000002},
@BBischof
BBischof / lightswitch_simulation_convergences.json
Created November 22, 2018 00:44
convergence rates for the lightswitch simulations
{ "4": [
{"j":0,"conv_value_for_mean":16,"conv_value_for_median":12,"conv_value_for_mode":12},
{"j":1,"conv_value_for_mean":8,"conv_value_for_median":6,"conv_value_for_mode":8},
{"j":2,"conv_value_for_mean":6,"conv_value_for_median":6,"conv_value_for_mode":6},
{"j":3,"conv_value_for_mean":7,"conv_value_for_median":7,"conv_value_for_mode":7},
{"j":4,"conv_value_for_mean":11,"conv_value_for_median":7,"conv_value_for_mode":7}]
, "5": [
{"j":0,"conv_value_for_mean":26,"conv_value_for_median":14,"conv_value_for_mode":14},
{"j":1,"conv_value_for_mean":12,"conv_value_for_median":10,"conv_value_for_mode":12},
{"j":2,"conv_value_for_mean":6,"conv_value_for_median":6,"conv_value_for_mode":9},