Skip to content

Instantly share code, notes, and snippets.

@ul
ul / rAF.js
Created August 22, 2014 19:18 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@ul
ul / debounce.cljs.hl
Last active August 29, 2015 14:27 — forked from micha/throttle.cljs.hl
Create a cell that only updates at most once every so many milliseconds
(defn debounce [c ms]
(let [queued? (atom false)]
(with-let [ret (cell @c)]
(add-watch c (gensym)
#(when-not @queued?
(reset! queued? true)
(with-timeout ms
(reset! queued? false)
(reset! ret @c)))))))
@ul
ul / kahn.clj
Last active August 27, 2015 06:40 — forked from alandipert/kahn.clj
Kahn's topological sort in Clojure
;; Copyright (c) Alan Dipert. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns alandipert.kahn
(:require [clojure.set :refer [difference union intersection]]))
(defn config-files
"Returns a sequence of configuration files
that should be loaded by Immuconf."
([]
(config-files (env :environment)))
([current-env]
(let [converter (comp (map (partial str "config/"))
(map io/resource)
(remove nil?))
@ul
ul / asciidoc.js
Created November 23, 2015 19:47 — forked from espadrine/asciidoc.js
// Parts from Ace; see <https://raw.githubusercontent.com/ajaxorg/ace/master/LICENSE>
CodeMirror.defineMode("asciidoc", function(cmCfg, modeCfg) {
// Ace highlight rules function imported below.
var HighlightRules = function() {
var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b";
this.$rules = {
"start": [
{token: "empty", regex: /$/},
@ul
ul / check.cljs
Created November 27, 2015 15:39 — forked from swannodette/check.cljs
(defn my-get
"@param {*} m
@param {*} k
@return {nil|Object}"
[m k]
(get m k))
(defn foo
"@param {!Object} x" ;; non-nullable
[x] x)
@ul
ul / README.md
Created March 29, 2016 03:05 — forked from olivergeorge/Nicer Assert README.md
Assert macro patch to show details about failed assertions.

This is an attempt to make assert more friendly by including more details in the assertion error.

  • show the result of the assertion expression
  • show local variable values used in assertion form

In other words, this should make assertion errors easier to reason about:

AssertionError Assert failed: Should be equal
@ul
ul / README.md
Created November 14, 2016 11:34 — forked from fasiha/README.md
Pitch (fundamental frequency) detection using (1) harmonic product spectrum, (2) Blackman-Tukey spectral estimator, and (3) Welch spectral estimator.

Experimenting with pitch detection and spectral estimators

See the question and discussion on StackOverflow: How to get the fundamental frequency using Harmonic Product Spectrum?.

We’re trying to estimate the fundamental frequency of a voiced A4 note (440 Hz). (See the question for link to audio clip.)

Harmonic product spectrum

Result: full data, 0 to 2 KHz

@ul
ul / Multi.re
Created April 10, 2017 06:18 — forked from wyze/Multi.re
More than one React component in a Reason file (module).
module WrapperA = {
module A = {
include ReactRe.Component;
let name = "A";
type props = ();
let render _ => <div>(ReactRe.stringToElement "A")</div>;
};