createMessageDispatcher
creates a message listener which will call a method on the
handler
argument, based on the contents of the message that's passed from elsewhere.
It does this by injecting the (potentially error causing) method into a promise chain,
by sticking it inside a custom thenable,
which gives us much nicer error handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
def octet?(str) | |
(0...256) === str.to_i | |
end | |
def octets(str, current = [], output = []) | |
# bail if there's nothing left to get | |
if str.nil? || str.empty? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
STOP_QUOTED_RE = /(?:[^"]|"{2})(",)/ | |
STOP_NORMAL_RE = /(,)/ | |
# returns [chunk, rest], rest is nil at the end | |
def read_chunk(line) | |
quoted = line[0] == '"' | |
start = quoted ? 1 : 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; https://soundcloud.com/jonathan-raphaelson/overtone-experiment-1 | |
(ns overtonetute.core | |
[:use [overtone.live]]) | |
(use 'overtone.inst.drum) | |
(definst swave [freq 440 attack 0.001 sustain 0.4 release 0.1 vol 0.005] | |
(lpf (* (env-gen (env-lin attack sustain release) 1 1 0 1) | |
(sin-osc freq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns my.env | |
(:require [clojure.edn :as edn])) | |
(defn- get-resource [path] | |
(let [classloader (java.lang.ClassLoader/getSystemClassLoader)] | |
(.getResource classloader path))) | |
(defn- read-config-file [] | |
(let [url (get-resource "config.edn")] | |
(slurp url))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require) { | |
var React = require('react'); | |
var paramRegex = /__(\d)+/; | |
var parser = new DOMParser(); | |
var errorDoc = parser.parseFromString('INVALID', 'text/xml'); | |
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI; | |
// turns the array of string parts into a DOM | |
// throws if the result is an invalid XML document. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Watch and rank links coming from twitter's public timeline. | |
# Currently this doesn't really work all that well, as we can only get 20 | |
# tweets a minute, but it's an idea. | |
# Requires the following non-standard python libs: (install with easy_install) | |
# * simplejson | |
# * functional | |
# * sqlalchemy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Name: vimproject.vim | |
" Version: 0.1 | |
" Author: Jon Raphaelson | |
" Summary: Loads a project specific vimrc when starting vim inside that | |
" project's directory tree. | |
" Licence: This program is free software; you can redistribute it and/or | |
" modify it under the terms of the GNU General Public License. | |
" See http://www.gnu.org/copyleft/gpl.txt | |
" Section: Documentation {{{1 | |
" Description: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package video; | |
import java.awt.Image; | |
import java.awt.image.BufferedImage; | |
import java.awt.image.DataBuffer; | |
import java.awt.image.WritableRaster; | |
import quicktime.QTRuntimeException; | |
import quicktime.QTRuntimeHandler; | |
import quicktime.QTSession; | |
import quicktime.qd.PixMap; |