Skip to content

Instantly share code, notes, and snippets.

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 / dropdown-option.hbs
Last active August 29, 2015 13:56
Chaplin dropdown
<label>
<input class="dropdown__item__toggle" type="checkbox"></input>
{{title}}
</label>
@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 / 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 / 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"
var jsdom = require('jsdom').jsdom;
global.document = jsdom();
global.window = document.parentWindow;
var Backbone = require('backbone');
Backbone.$ = require('jquery');
@akre54
akre54 / typing.coffee
Created April 3, 2015 20:00
Get a notification when a user starts and stops typing on the passed-in `el`.
# Get a notification when a user starts and stops typing on the passed-in `el`.
#
# Based on https://github.com/narfdotpl/jquery-typing
module.exports = (el, {delay, start, stop}) ->
delay ||= 400
typing = false
timeout = null
@akre54
akre54 / README.md
Created July 8, 2015 15:27
Reflux REST mixin

Call actions on stores RESTfully:

// C
BotActions.save(null, {name: 'Curly', age: 26}); // POST a model without an id

// R
BotActions.fetch(); // GET the whole Collection

BotActions.fetch(2); // GET a single model by id
@akre54
akre54 / .gitignore
Last active October 27, 2015 13:23
Backbone deps test
node_modules
out.js*
@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.