Skip to content

Instantly share code, notes, and snippets.

View bcoe's full-sized avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
@bcoe
bcoe / main.js
Last active August 29, 2015 14:01
main.js
var $ = window.jQuery = require('jquery');
var typeahead = require('typeahead.js'),
npmUrl = 'https://www.npmjs.org';
$(document).ready(function() {
// Create the engine, used to interact
// with our search backend.
var engine = new Bloodhound({
name: 'packages',
@bcoe
bcoe / callback-hell.js
Created May 11, 2014 19:44
callback-hell.js
a(b, function(err, c) {
// wait for a to finish.
d(c, function(err, e) {
// wait for d to finish.
f(e, function(err, g) {
// do something with the result of f.
})
})
})
@bcoe
bcoe / un-nested-callbacks.js
Created May 11, 2014 20:08
un-nested-callbacks.js
function a(b, cb) {
d(null, b * 2, cb);
}
function d(err, c, cb) {
if (err) cb(err);
else f(null, c * 2, cb);
}
function f(err, e, cb) {
@bcoe
bcoe / recreate.sql
Created May 18, 2014 19:22
re-create tables in psql
drop schema public cascade;
create schema public;
// var packages = ['thumbd', 'underscore', 'request'];
var async = require('async');
function IssuePopulator(packages) {
this.interval = 1000; // try to grab more packages every second.
this.workSize = 10;
this.packages = packages;
};
IssuePopulator.prototype.doWork = function() {
@bcoe
bcoe / package.js
Created July 7, 2014 18:35
Proposal for environment extension to package.json
// Problem: there are a class of packages on npm that are best described as "services", e.g., statsd, thumbd.
// there is not a straight-forward, machine-readable, way to setup the necessary dependencies for these services.
//
// Solution: the various parties that are building tools for deploying these services (Heroku, Node OS, ndm) should agree
// on a standard for programatically describing environment dependencies in the package.json.
//
// What Jacob and I came up with:
{
"name": "statsd",
"dependencies": {
@bcoe
bcoe / combiner.js
Created July 14, 2014 17:30
combiner.js
var _ = require('lodash');
function Combiner(opts) {
_.extend(this, {
inputs: [], // generators providing audio.
weights: [],
binding: null, // binding to audio native or gyp.
}, opts);
this.v1 = this.binding.allocateVector(),
@bcoe
bcoe / unpublished-scoped.bash
Created August 8, 2014 00:29
unpublish-scoped.bash
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'unpublish',
npm verb cli '@npm/apple@0.0.33',
npm verb cli '--verbose' ]
npm info using npm@1.5.0-alpha-4
npm info using node@v0.10.26
npm verb gentlyRm vacuuming /Users/benjamincoe/.npm/@npm/apple/0.0.33
npm verb mapToRegistry name @npm%2fapple
@bcoe
bcoe / user-test.js
Created August 13, 2014 19:09
user-test.js
var connection = require('../../lib/connection')(),
Customer = require('../../lib/models/customer'),
helper = require('../test-helper'),
Lab = require('lab'),
lab = exports.lab = Lab.script();
// See prepare-tests.js, for follower feed ordering.
lab.experiment('Customer', function() {
lab.before(function(done) {
@bcoe
bcoe / dancejs.md
Created September 6, 2014 18:22
dancejs.md

DanceJS

Mission Statement

  1. To build a community of music lovers, visual artists, and JavaScript hackers.
  2. To create shared spaces for community members to practice, collaborate, program, and perform.
  3. Build some cool open-source music software in Node.js.

Motivation