Skip to content

Instantly share code, notes, and snippets.

View jperkelens's full-sized avatar

Jan Paul Erkelens jperkelens

  • Jamplify
  • Brooklyn, NY
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jperkelens on github.
  • I am thepurplemonk (https://keybase.io/thepurplemonk) on keybase.
  • I have a public key whose fingerprint is 70D1 0CCD 0817 9100 E014 7511 1BE9 81FF B725 8BE8

To claim this, I am signing this object:

@jperkelens
jperkelens / keybase.md
Created October 1, 2014 20:04
keybase

Keybase proof

I hereby claim:

  • I am jperkelens on github.
  • I am thepurplemonk (https://keybase.io/thepurplemonk) on keybase.
  • I have a public key whose fingerprint is B362 0CA0 1D49 295A BFFC 1F23 D87D 9F9B 450A 2E28

To claim this, I am signing this object:

@jperkelens
jperkelens / 0_reuse_code.js
Created June 2, 2014 16:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jperkelens
jperkelens / sorter.coffee
Created April 25, 2013 16:09
coffee encapsulation
class Sorter
place = (domino) =>
one_idx = @key_index[domino[0]]
sort: (dominoes) ->
@sorted_dominoes = []
@key_index = (0 for i in [0..9])
@jperkelens
jperkelens / model.js
Created January 24, 2013 21:00
Safe security decision?
function SecModel() {
var user = getCurrentUser() //server call to user
return {
allowEdit: function() {
return user == profile.user
}
}
}
@jperkelens
jperkelens / overload.js
Created January 12, 2013 00:52
method overloading based on defined params
function addMethod(obj, name, fn) {
var old = obj[name]
obj[name] = function() {
if (fn.length === arguments.length)
return fn.apply(this, arguments)
else if (typeof old == 'function')
return old.apply(this, arguments)
}
}
@jperkelens
jperkelens / cache.js
Created November 19, 2012 19:53
TinyCache
module.exports = function() {
var cache = {}
var timeouts = {}
function replaceTimeout(key) {
clearTimeout(timeouts[key])
timeouts[key] = setTimeout(function() {
delete cache[key]
}, 5000)
}
@jperkelens
jperkelens / api.js
Created September 13, 2012 23:09
Class in VanillaJS
var Datomic = module.exports = function(server, port, alias, name) {
root = blah
this.db_uri = blah
this.createDatabase = function(done) {...}
}
@jperkelens
jperkelens / Makefile
Created April 26, 2012 20:53
Mocha Makefile
file=*.test.js
files=`find test/unit -name '$(file)' -type f -print0 | xargs -0 echo`
default: all
all: unit peanut
ci: unit-ci peanut-ci
unit:
var saveUser = function(callback) {
User.update({_id: this._id}, this, callback);
}
User.findOne = function(selector, callback) {
MongoHelper.findOne(selector, collectionName, function(err, result) {
if (err) return callback(err);
result.save = saveUser;
return callback(null, result);