Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
[[[0.01, -0.17, 1.63], [0.01, -0.18, 1.62], [0.02, -0.18, 1.61], [0.02, -0.17, 1.6], [0.03, -0.16, 1.59], [0.03, -0.15, 1.58], [0.04, -0.14, 1.58], [0.05, -0.13, 1.57], [0.05, -0.12, 1.57], [0.06, -0.11, 1.57], [0.07, -0.1, 1.57], [0.08, -0.1, 1.57], [0.09, -0.09, 1.59], [0.1, -0.09, 1.6], [0.1, -0.09, 1.62], [0.09, -0.08, 1.63], [0.08, -0.07, 1.66], [0.07, -0.06, 1.68], [0.06, -0.06, 1.69], [0.05, -0.06, 1.69], [0.04, -0.07, 1.67], [0.03, -0.07, 1.65], [0.03, -0.07, 1.63], [0.02, -0.07, 1.61], [0.01, -0.07, 1.59], [0.01, -0.07, 1.58], [-0.0, -0.08, 1.58], [-0.01, -0.08, 1.59], [-0.02, -0.07, 1.61], [-0.02, -0.06, 1.64], [-0.01, -0.05, 1.68], [0.0, -0.03, 1.71], [0.01, -0.02, 1.73], [0.02, -0.01, 1.74], [0.02, -0.01, 1.74], [0.03, -0.01, 1.75], [0.04, -0.01, 1.76], [0.04, -0.02, 1.76], [0.04, -0.03, 1.76], [0.03, -0.03, 1.76], [0.03, -0.03, 1.75], [0.02, -0.04, 1.75], [0.02, -0.03, 1.74], [0.01, -0.03, 1.73], [0.01, -0.03, 1.73], [0.02, -0.02, 1.72], [0.02, -0.01, 1.71], [0.03, -0.01, 1.7], [0.04, -0.0, 1.69]
@duhaime
duhaime / notes.txt
Last active March 27, 2021 01:58
sqlite.py
# use in memory
connection = sqlite3.connect(':memory:')
cursor = connection.cursor()
# parameterized query
results = list(cursor.execute('SELECT * FROM table WHERE field = ?', (interpolate_me,)))
@duhaime
duhaime / tree.py
Created May 7, 2019 20:22
build-tree-on-disk.py
'''
method:
compose one string from each row in the input metadata
find all sequences of one word and two consecutive words in each row
for each such sequence, break the sequence down into a sequence of characters
make a nested directory structure on disk that represents this tree
store the ids for each record at the root level for its branch
'''
@duhaime
duhaime / listen.js
Created May 6, 2019 19:55
watch all events
window.addEventListener('message', function(event) { console.log(event) })
@duhaime
duhaime / babel.min.js
Last active May 6, 2019 17:32
Minimal React Router without Babel
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Babel=t():e.Babel=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var r=t.slice(1),n=e[t[0]];return function(e,t,i){n.apply(this,[e,t,i].concat(r))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,r){"use strict";function n(e,t){return g(t)&&"string"==typeof t[0]?e.hasOwnProperty(t[0])?[e[t[0]]].concat(t.slice(1)):void 0:"string"==typeof t?e[t]:t}function i(e){var t=(e.presets||[]).map(function(e){var t=n(E,e);if(!t)throw new Error('Invalid preset specified in Babel options: "'+e+'"');return g(t)&&"object"===h(t[0])&&t[
@duhaime
duhaime / raw.py
Created May 3, 2019 22:00
raw_vae
from keras.layers import Lambda, Input, Dense, Reshape
from keras.models import Model
from keras.losses import mse
from keras import backend as K
import numpy as np
# reparameterization trick
# instead of sampling from Q(z|X), sample epsilon = N(0,I)
# z = z_mean + sqrt(var) * epsilon
def sampling(args):
@duhaime
duhaime / bezier_curves.py
Created April 30, 2019 09:58 — forked from astrojuanlu/bezier_curves.py
Interactive Bézier curves with Python using just matplotlib.
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
@duhaime
duhaime / .block
Last active May 14, 2019 14:41
word-to-viz
scrolling: yes
@duhaime
duhaime / a.jpg
Created April 23, 2019 13:16
Image Histograms
a.jpg
@duhaime
duhaime / edges.json
Last active May 13, 2019 13:03
Three.js LineSegments with RawShaderMaterial
{"16384": [19052, 19053], "1": [19967], "16386": [19086, 19087, 19088, 19089, 19090, 19091, 19092, 19093, 19094], "10923": [10023, 10024, 12740, 12741, 12742, 12743, 12744, 12745], "16389": [20421], "6": [18180], "24583": [23487, 23513, 24030, 24073, 24100, 24126, 24279, 24329, 24415, 24581, 24584, 24660, 24757, 24817, 24818, 24994, 25255, 25261, 25507, 25508, 25662, 25736, 25825, 25860, 25916, 26095, 26183, 26553, 26632, 26652, 26956, 26965, 26967, 26969, 26972, 26975, 27002, 27004, 27006, 27224, 27267, 27273, 27322, 27329, 27425, 27524, 27568, 27569, 27676, 27884], "8201": [6879, 8202, 8203, 8204], "11784": [15369], "8203": [9911, 9912, 9913, 9914, 9915, 9916, 10962, 10963, 10964, 10965, 10966, 10967, 10968], "8205": [7250, 9723, 9725, 9726, 9727], "16": [24628], "17": [24893, 26771], "18": [20103], "19": [17414], "20": [18463], "21": [23109], "22": [19344], "23": [20914], "24": [17714], "25": [17062], "26": [16653], "8219": [7846, 10258, 10259], "28": [16671], "29": [24614], "30": [27250], "31": [26203], "