Skip to content

Instantly share code, notes, and snippets.

View jkrems's full-sized avatar
Modules. Modules everywhere.

Jan Olaf Martin jkrems

Modules. Modules everywhere.
View GitHub Profile
@jkrems
jkrems / intend.js
Created December 4, 2013 22:03
Clarity of intend
function getUser(id) {
// implementation unknown
}
function getUserName(id) {
// is getUser(id) returning Promise[String]? String? - both work fine
return when(when(id, getUser), function(user) {
return user.name;
});
}
@jkrems
jkrems / util.js
Last active December 21, 2015 14:09
Transparent function and generator proxy
var toString$ = Object.prototype.toString;
// Ported from angular.js
var COMMENTS_PATTERN = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,
ARGS_PATTERN = /^function\s*(\*)?\s*[^\(]*\(\s*([^\)]*)\)/m,
ARG_PATTERN = /^\s*(_?)(\S+?)\1\s*$/;
module.exports = {
isGenerator: function isGenerator(obj) {
return toString$.call(obj).slice(8, -1) === 'Generator';
@jkrems
jkrems / stream.json
Created March 31, 2013 01:09
Blocked in DE? But why?! :(
{
"items": [
{
"id": "WdrXcikNdQU",
"kind": "youtube#video",
"snippet": {
"publishedAt": "2013-03-05T02:04:29.000Z",
"title": "International TableTop Day Live Stream - pt. 2 on March 30th!",
"description": "Join Wil Wheaton and friends from 3pm Pacific to 7pm Pacific as they play awesome games like SMASH UP, STAR TREK CATAN, and 7 WONDERS. Stream goes live ON March 30th.\n\nWant to participate in #TableTopDay? Go to TableTopDay.com and check out the events in your area going on all day."
},
@jkrems
jkrems / Vagrantfile
Created July 27, 2012 08:03
Simple vagrant setup with debian and puppet
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Map NFS uid/gid to current user. This can be used to create a
# user inside the VM with matching uid/gid which makes file access
# a lot easier.
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid