Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
nhunzaker / animationLoop
Created August 27, 2012 00:07
JS: requestAnimationFrame Loop Pattern
/*
TIME BASED ANIMATION:
---------------------
To keep things moving at a constant time-based rate instead of varying
frame-based, multiply your movement by APP.deltaTime
BAD: 100 pixels per frame (BOO... movement is tied to framerate)
var velocity = 100;
BETTER: 100 pixels per second (Horray! Framerate independence!)
/**
* Kalman Filters
*
* Uses a series of measurements observed over time, containing
* statistical noise and other inaccuracies, and produces a more
* accurate estimate.
*
*
* http://www.cs.unc.edu/~welch/kalman/Levy1997/index.html
*/
(defun nh/today-as-string ()
"Today, as a string."
(format-time-string "%y.%m.%d"))
(defun current-workbook ()
"Location of the current workbook log file."
(concat "~/.org/worklog/" (nh/today-as-string) ".org"))
(defun workbook ()
"Opens up my workbook."
### Keybase proof
I hereby claim:
* I am nhunzaker on github.
* I am nhunzaker (https://keybase.io/nhunzaker) on keybase.
* I have a public key ASBfUd8iUn88ILVhWT4YszwRcQdnFkBaambe5RhIYg4jDwo
To claim this, I am signing this object:
@nhunzaker
nhunzaker / Makefile
Last active February 7, 2019 04:13
Access LMU light sensor on Mac. Also includes the Emacs plugin I use for automatically updating my theme according to ambient light.
all:
gcc light.m -std=c99 -framework Foundation -framework IOKit -o light
clean:
rm -f light
@nhunzaker
nhunzaker / init.el
Created November 7, 2011 14:39
Enable line numbering on the left-hand side in Emacs
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Line Numbering
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Note: I'm doing this in Emacs 24 on OSX
;; Swap line numbers using C-<f5>, you can change this of course
(autoload 'linum-mode "linum" "toggle line numbers on/off" t)
(global-set-key (kbd "C-<f5>") 'linum-mode)
var _ = require('underscore');
var Backbone = require('backbone');
var cheerio = require('cheerio');
var request = require('request');
Backbone.ajax = function(options) {
options.json = true;
return request(options, function(error, result) {
if (error) {

Next Microcosm

I've had a couple of things on my mind with regard to the next version of Microcosm.

A client-side version of GraphQL

I want to be able to build out a Microcosm state tree using GraphQL. A single document would automatically produce a fast, well documented, easily configurable Microcosm setup. For example:

type Author {
describe('Jest Electron Runner', function() {
it('has access to the window', function() {
expect(window).toEqual(global)
})
it('has access to the document', function() {
expect(document).toEqual(global.document)
})
@nhunzaker
nhunzaker / react-dom.cjs.js
Last active August 16, 2017 12:30
Current as of 7e297e9b20d75ee9cc39aadf7e83133af1869881
/*
Modernizr 3.0.0pre (Custom Build) | MIT
*/
var aa = require("react"),
ba = require("fbjs/lib/invariant"),
l = require("fbjs/lib/ExecutionEnvironment"),
n = require("object-assign"),
ca = require("fbjs/lib/EventListener"),
w = require("fbjs/lib/emptyFunction"),
da = require("fbjs/lib/emptyObject"),