Skip to content

Instantly share code, notes, and snippets.

var jsdom = require('jsdom').jsdom;
global.document = jsdom();
global.window = document.parentWindow;
var Backbone = require('backbone');
Backbone.$ = require('jquery');
@akre54
akre54 / draw-circles.coffee
Last active August 29, 2015 14:04
Draw circles on canvas
{requestInterval, clearRequestInterval} = require './animation-helpers'
NUM_CIRCLES = 2500
MAX_RADIUS = 80
MIN_RADIUS = 4
bgCanvas = document.getElementById "bg"
fgCanvas = document.getElementById "fg"
bg = bgCanvas.getContext "2d"
fg = fgCanvas.getContext "2d"
@akre54
akre54 / frank.txt
Created May 23, 2014 13:22
Frank Costanza lines
Today, I went record shopping in Greenwich Village.
I bought this record, but I can't seem to find the hi-fi.
Didn't I give you my old record player?
Cosmo?
Who's Cosmo?
Well, I want it back.
I wanna listen to that cha-cha record.
(putting down the bowl) Lemme change my shirt.
Thank you, Kramer.
(indicating a chair) Put it over there.
@akre54
akre54 / handlebars_helper.js
Created April 22, 2014 15:11
Handlebars for mocha with browserify
var Handlebars = require('handlebars'),
fs = require('fs');
require.extensions['.hbs'] = function (module, filename) {
var raw = fs.readFileSync(filename, 'utf8');
return Handlebars.compile(raw);
}
@akre54
akre54 / parser.coffee
Created March 29, 2014 15:26
KML to GeoJSON
fs = require 'fs'
xml2js = require('xml2js').parseString
fs.readFile "#{__dirname}/history.kml", (err, data) ->
xml2js data, (err, result) ->
doc = result.kml.Document[0].Placemark[0]['gx:Track'][0]
points =
type: "Feature"
properties: {}
@akre54
akre54 / dropdown-option.hbs
Last active August 29, 2015 13:56
Chaplin dropdown
<label>
<input class="dropdown__item__toggle" type="checkbox"></input>
{{title}}
</label>
var rules = [], each = [].forEach;
each.call(document.styleSheets, function(s) {
s.cssRules && each.call(s.cssRules, function(rule) {
rule.media && rules.push(rule.media[0]);
})
});
@akre54
akre54 / Slider.js
Last active December 28, 2015 00:49
var runner = document.querySelector('.ticker'), // a <ul>
frames = runner.children,
timeout = 4000; // in ms
var cycleFrames = function() {
var child = runner.removeChild(frames[0]).cloneNode(true);
runner.appendChild(child);
}
// from https://gist.github.com/joelambert/1002116
@akre54
akre54 / index.html
Last active December 26, 2015 22:19
var SelectView = Backbone.View.extend({
el: '#my-select',
events: {
'change': 'addToList'
},
render: function() {
this.collection.each(function(item) {
var optionView = new OptionView({model: item});
@akre54
akre54 / moviepass-theaters.js
Last active December 12, 2015 01:48
get all theaters moviepass works at in manhattan.
var allTheaters = [];
var nycZips = [
// Greenpoint
11211, 11222,
// Bushwick & Williamsburg
11206, 11221, 11237,
// Greenwich Village & Soho