Skip to content

Instantly share code, notes, and snippets.

ctx=new AudioContext();c=ctx.createConvolver();i=document.createElement("input");i.setAttribute("type","file");r=new FileReader();i.onchange=()=>r.readAsArrayBuffer(i.files[0]);r.onload=()=>{ctx.decodeAudioData(r.result,(b)=>{c.buffer=b;c.connect(ctx.destination);m=ctx.createMediaElementSource(document.querySelector("video"));m.connect(c)})};i.click()
@zipcode
zipcode / flightdata.json
Created May 5, 2017 01:21
API results on a plane
{
"td_id_decompression":"0",
"td_id_weight_on_wheels":"0",
"td_id_all_doors_closed":"1",
"td_id_x2_pa_state":"0",
"td_id_fltdata_ground_speed":"0518",
"td_id_fltdata_time_to_destination":"0375",
"td_id_fltdata_wind_speed":"-037",
"td_id_fltdata_mach":"0847",
"td_id_fltdata_true_heading":"0299",
@zipcode
zipcode / monads.md
Last active April 26, 2017 19:47
Lies we're told about monads

What the hell are monads?

Monads are a useful tool in functional programming. Unfortunately, they're a pain in the ass to understand. I don't think they're actually that complicated, it's just that nobody seems to explain them well.

A monad is a collection which implements a flatMap method. That's it.

flatMap is a function made out of flatten and map:

@zipcode
zipcode / cloud-config
Last active November 2, 2017 00:22
More generic cloud-config for setting up a bare IPSec/IKEv2 VPN
#cloud-config
# Edit line 52 to list your users
# Edit line 70 to remove --staging and insert your email address
packages:
- strongswan
- strongswan-plugin-eap-mschapv2
- letsencrypt
package_upgrade: true
@zipcode
zipcode / log.txt
Last active February 26, 2017 07:44
ipsec with certificates playthrough
New instance somewhere in the cloud, using Ubuntu:
#cloud-config
packages:
- strongswan
package_upgrade: true
Create root cert locally:
@zipcode
zipcode / ipsec.conf
Last active January 20, 2017 10:06
Quick 'n dirty IPSec w/ keys config
## Install strongswan and use this config file
## How to do key management:
## Make a root CRT. Do this on a secure machine, not the VPN endpoint.
# openssl req -x509 -newkey rsa:4096 -days 90 -subj "/CN=My VPN root" -out root.crt
## Make a conf file
# cat > openssl.cnf << EOF
# [ usr_cert ]
# basicConstraints=CA:FALSE
# nsComment = "OpenSSL Generated Certificate"
@zipcode
zipcode / primes.clj
Created July 29, 2016 22:53
corecursive infinite list of primes in clojure
(defn divides?
[x y]
(and (= 0 (mod x y)) (not (= x y))))
(def primes
(lazy-cat
[2 3]
(filter
(fn [x]
(not (some
@zipcode
zipcode / slackemoji.user.js
Created September 10, 2015 17:43
Clicking on an emoji in the emoji list opens the original image
// ==UserScript==
// @name Slack emoji downloader
// @namespace http://zip.sexy
// @version 0.1
// @description Clickable slack emoji on the config page
// @author @zip
// @match https://*.slack.com/customize/emoji
// @grant none
// ==/UserScript==
@zipcode
zipcode / pulse.js
Created August 10, 2015 05:45
Pulse inserted nodes in the DOM
function pulse(node, time) {
if (!node) throw new Error("node was falsy");
if (node.constructor && node.constructor == NodeList) {
var nodes = Array.prototype.slice.call(node);
nodes.forEach(function (node) { pulse(node, time); });
return;
}
if (!node.style) return;
@zipcode
zipcode / parsing.coffee
Created March 15, 2015 20:55
messing about with parsimmon
{string, lazy, alt, regex, optWhitespace, seq, succeed} = require "Parsimmon"
lbrace = string '<'
rbrace = string '>'
slash = string '/'
identifier = regex /[a-z-]+/i
opentag = lbrace.then(identifier).skip(optWhitespace).skip(rbrace)
closetag = (tag) -> lbrace.then(slash).then(string tag).skip(rbrace)
selftag = lbrace.then(identifier).skip(optWhitespace).skip(slash).skip(rbrace).map (s) -> "<#{s}/>"