Skip to content

Instantly share code, notes, and snippets.

View eschwartz's full-sized avatar

Edan Schwartz eschwartz

View GitHub Profile
@eschwartz
eschwartz / SassMeister-input-HTML.html
Created December 3, 2013 15:23
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<a class="closeBtn">.closeBtn</a>
<div class="acme-app">
<a class="closeBtn">.acme-app .closeBtn</a>
</div>
<div class="acme-app">
<div class="reset">
<a class="closeBtn">.acme-app .reset .closeBtn</a>
</div>
@eschwartz
eschwartz / listenTo.js
Last active January 1, 2016 19:09
WireJS Plugin: ListenTo Facet
View listenTo.js
define([
'vendor/underscore',
'when'
], function(_, when) {
/**
* Helper class for
* the listenTo facet.
*
* @param proxy
@eschwartz
eschwartz / typeHelpers
Last active August 29, 2015 13:56
Handlebars helpers for parsing object types for YUIDocs templates
View typeHelpers
var NATIVES = {
'Array': 1,
'Boolean': 1,
'Date': 1,
'decodeURI': 1,
'decodeURIComponent': 1,
'encodeURI': 1,
'encodeURIComponent': 1,
'eval': 1,
'Error': 1,
@eschwartz
eschwartz / MarkerCollections.html
Last active August 29, 2015 13:57
Aeris.js MarkerCollections
View MarkerCollections.html
<!DOCTYPE html>
<html>
<head>
<title>Aeris.js MarkerCollection example</title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
View MarkerCollection-amd.js
require.config({
paths: {
aeris: 'bower_components/aerisjs/src',
// Aeris.js dependencies
underscore: 'bower_components/underscore/underscore',
jquery: 'bower_components/jquery/jquery',
backbone: 'bower_components/backbone/backbone',
leaflet: '//cdn.leafletjs.com/leaflet-0.7.2/leaflet-src',
'leaflet-markercluster': 'bower_components/leaflet.markercluster/dist/leaflet.markercluster-src',
@eschwartz
eschwartz / tsd-amd Grunt Task
Created February 5, 2015 14:44
A grunt task for when you need to use RequireJS `paths` config in a TypeScript project.
View tsd-amd Grunt Task
module.exports = function(grunt) {
var path = require('path');
grunt.registerMultiTask(
'tsd-amd',
'Generates a TypeScript definition file for a set of *.ts files. ' +
'The output will contain declared modules for every *.ts file, ' +
'which are named according to their AMD ids.',
function() {
var options = this.options({
@eschwartz
eschwartz / drag-drop.css
Last active January 15, 2016 16:06
Drag and Drop
View drag-drop.css
/* Prevent the text contents of draggable elements from being selectable. */
[draggable] {
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
/* Required to make elements draggable in old WebKit */
-khtml-user-drag: element;
-webkit-user-drag: element;
}
@eschwartz
eschwartz / assert-ext.js
Created February 22, 2016 16:49
Extend assert
View assert-ext.js
const assert = require('assert');
// Wrap `assert()`
const assertExt = (val, msg) => assert(val, msg);
// Extend assert properties
Object.assign(assertExt, assert, {
someCustomAssertion: require('./assert/some-custom-assertion')
});
@eschwartz
eschwartz / promise-series
Created February 23, 2016 15:47
Promise Series: run an async fn in series an arbitrary number of times
View promise-series
const _ = require('lodash');
function series(count, asyncFn) {
return _.range(0, count)
.reduce((lastRun_, i) => {
return lastRun_.then(() => asyncFn(i))
}, Promise.resolve());
}
series(10, (i) => {
@eschwartz
eschwartz / cluster.js
Last active May 2, 2016 17:10
Node cluster
View cluster.js
#!/usr/bin/env node
/**
* Usage:
*
* node cluster.js ./worker-script.js
*/
const cluster = require('cluster');
const path = require('path');
function startCluster(runWorker, opts) {