Skip to content

Instantly share code, notes, and snippets.

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

Jan Olaf Martin hybrist

Modules. Modules everywhere.
View GitHub Profile
// 1. Variable declaration
def myValue = 'value, immutable';
def myObjectValue = { a: 10 };
myObjectValue.b = 20; // TypeError
myObjectValue.a = 12; // TypeError
def myArrayValue = [ 10, 20 ];
myArrayValue.slice(1); // is okay, slice is pure
myArrayValue.pop(); // TypeError
myArrayValue.splice(); // TypeError
@hybrist
hybrist / cjsify.js
Last active December 31, 2015 11:59
POC commonjs everywhere grunt task
'use strict';
var DESC = 'Generate bundle from commonjs-everywhere';
var escodegenFormat = {
indent: {
style: ' ',
base: 0
},
renumber: true,
@hybrist
hybrist / 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;
});
}
@hybrist
hybrist / 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';
@hybrist
hybrist / 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."
},
@hybrist
hybrist / 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