Skip to content

Instantly share code, notes, and snippets.

@hyponymous
hyponymous / index.html
Created April 12, 2020 00:35
Multilane Timeline in d3
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"> </script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<style type="text/css">
.timeline {
pointer-events: all;
}
#!/usr/bin/env python
import itertools
import numpy as np
N = 1000
d = 500
x_normal = np.random.multivariate_normal([0], [[1]], [N, d]).reshape([N, d])
x_spherical = x_normal / np.linalg.norm(x_normal, axis=1)[:, np.newaxis]
import copy
# fun from Ernest!
#
# Given two strings s and t, determine whether some anagram of t is a substring of s.
# For example: if s = "udacity" and t = "ad", then the function returns True.
# Your function definition should look like: question1(s, t) and return a boolean True or False.
def q_mike(s, t):
def add_to_hist(c, hist):
@hyponymous
hyponymous / gridworld.js
Last active February 10, 2017 00:06
Gridworld I — SARSA(λ)
/* global d3, _ */
var CONFIG = {
transitionDuration: 0,
stepDelay: 10,
// learning rate
alpha: 0.1,
// deviation from greediness
epsilon: 1e-2,
// reward discount factor
@hyponymous
hyponymous / three-way.sh
Created June 3, 2016 18:39
One-liner that creates two diffs of a conflicted file (whose name is in the paste buffer) and opens them side by side in vim – for resolving merge conflicts
file=$(pbpaste); git diff -b -M :1:$file :2:$file >~/tmp/left.diff; git diff -b -M :1:$file :3:$file >~/tmp/right.diff; vim -O ~/tmp/left.diff ~/tmp/right.diff # ;three-way
@hyponymous
hyponymous / edit-conflicted.sh
Created June 3, 2016 18:36
One-liner that opens all files with git conflicts in vim, highlighting the conflict boundaries
vim +/"^[<>|=]\{7}" $(git status -sb | grep "^UU" | cut -d' ' -f 2) # ;edit-conflicted
@hyponymous
hyponymous / base85-pass.sh
Created June 3, 2016 18:31
A one-liner that prints a base85-encoded string containing 120 random bits
head -c 15 </dev/random | python3 -c "import sys, base64; sys.stdout.write('{}\n'.format(base64.b85encode(sys.stdin.buffer.read()).decode('utf-8')))" # ;b85-pass

Run the server:

npm run start

Test the server by loading http://localhost:8080/ in a browser, or run

time curl http://localhost:8080/
@hyponymous
hyponymous / README.md
Last active October 7, 2015 04:34 — forked from mbostock/.block
Letter Scrambles
@hyponymous
hyponymous / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block
Voronoi Color Sampling