Skip to content

Instantly share code, notes, and snippets.

View bitmage's full-sized avatar

Brandon Mason bitmage

View GitHub Profile
@bitmage
bitmage / mix.exs
Created April 3, 2016 20:40
project with benchfella
defmodule BM.Mixfile do
use Mix.Project
def project do
[app: :benchmarks,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
@bitmage
bitmage / index.js
Last active April 4, 2016 22:59
Some math tests with floats vs. bignums and seneca vs. raw.
require('babel-register')
require('./src/test')
@bitmage
bitmage / config.js
Created January 21, 2015 00:58
config.js for alternate loopback loading
// related discussion: https://github.com/strongloop/strong-pm/issues/45
var _ = require('lodash')
, e = process.env
, join = require('path').join;
var envConfigs = {
development: {
config: {
host: "0.0.0.0",
@bitmage
bitmage / initial_data.js
Last active August 29, 2015 14:13
simple seed data script
module.exports = {
Student: [
{name: 'Bob', email: 'bob@foo.com'},
{name: 'Susy', email: 'susy@foo.com'}
]
};
@bitmage
bitmage / umd.js
Created November 14, 2014 23:53
The uglified umd preamble inserted by Browserify, broken down to a line by line interpretation.
require=(
// t = mapping
// n = cache?
// r = entry points?
function e(t,n,r){
// s = global require
// o = module name
// u = ???
function s(o,u){
// can we find it in the cache?
@bitmage
bitmage / afterCreate.js
Last active February 16, 2017 01:01
Loopback Model - afterCreate hook to auto-save related models instantiated using build()
var async = require('async');
Project.afterCreate = function(done) {
var self = this;
function createRelation(rel, next, name) {
self[name].create(rel, next);
};
objMapAsync(this.__cachedRelations, createRelation, done);
@bitmage
bitmage / sandbox.clj
Created May 1, 2014 05:08
sandbox experiment for tonight's meetup
(defn make-seq [item]
(if (coll? item)
item
(list item)))
(defn flatten-once [items]
(apply concat (map make-seq items)))
(defn flatten-all [items]
(let [res (flatten-once items)]
@bitmage
bitmage / sauce output.txt
Created July 30, 2013 05:37
sauce output for stampit
$ npm test
> stampit@0.3.3 test /Users/brandon/Projects/Code/js/stampit
> scripts/test.sh
Running "browserify:dist/stampit.js" (browserify) task
>> Bundled dist/stampit.js
Running "connect:server" (connect) task
Started connect web server on localhost:4445.
@bitmage
bitmage / mongo_stream.js
Created July 1, 2013 23:46
testing Mongo stream API
var mongo = require('mongodb');
var client = new mongo.Db('test', new mongo.Server('localhost', 27017), {w: 1});
// connect to DB and insert a record
client.open(function(err) {
client.collection('users', function(err, users) {
users.insert({email: 'graham@daventry.com'}, function(err) {
// listen for changes
var stream = users.find().stream();
@bitmage
bitmage / function identity proof.coffee
Created June 26, 2013 18:11
Inside the node.js EventEmitter implimentation, the === operator is used within removeListener to determine which listener should be removed. I wanted to test if it remains true to the actual function instance. Here is an example where functions are created in a loop, but each one has a different closure and therefore returns a different result.…
collector = []
compare = (target) ->
->
console.log 'in timeout, collector length:', collector.length
for fn, i in collector
console.log "#{i}:", (fn is target)
for i in [1..3]
do (i) ->