Skip to content

Instantly share code, notes, and snippets.

View stoeffel's full-sized avatar
🦔

Christoph Hermann stoeffel

🦔
View GitHub Profile
@stoeffel
stoeffel / index.html
Created December 17, 2014 13:43
var self = this; // source http://jsbin.com/mafofa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var l = function(func) {
cond([
[isTrue(foo), doStuffFoo],
[isTrue(bar), doStuffBar],
[always(true), otherwise]
]);
//or
cond(
[isTrue(foo), doStuffFoo],
[isTrue(bar), doStuffBar],
@stoeffel
stoeffel / gist:9007f68c2a63f0c42e42
Last active August 29, 2015 14:14
reactive-gulp
var gulp = require('reactive-gulp')(require('gulp'));
gulp.task('default', '**/*.js')
.pipe(mocha())
.pipe(uglify())
.dest('./dist/');
// is the same as
var gulp = require('gulp');
gulp.task('default', function() {
function compose2(fn1, fn2) {
return (...args) => fn1(fn2.apply(null, args));
}
function compose(...fns) {
let head = fns.shift();
let tail = fns;
if (head && tail.length === 0) {
return head;
@stoeffel
stoeffel / index.js
Last active August 29, 2015 14:16
requirebin sketch
var curry = require('101/curry')
var compose = require('101/compose')
var set = require('101/set')
var clone = require('101/clone')
var insert = compose(curry(set, 3), clone);
var obj = { foo: 1 }
var cloned = insert(obj)('bar', 2)
var cloned2 = insert(cloned)('baz', 3)
@stoeffel
stoeffel / index.js
Created March 8, 2015 09:27
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var get = require('101/pluck');
var set = require('101/set');
var lense = function(key) {
var l = get(key);
l.set = set(key);
l.mod = function(mod, obj) {
return l.set(mod(l(obj)));
@stoeffel
stoeffel / index.js
Created March 8, 2015 09:45
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var get = require('101/pluck');
var set = require('101/set');
var clone = require('101/clone');
var lense = function(key) {
var l = get(key);
l.set = function(value, obj) { return set(clone(obj), key, value); };
l.mod = function(mod, obj) {
@stoeffel
stoeffel / index.js
Created June 17, 2015 07:09
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var Enum = require('enum');
cameraType=new Enum({'HIKVISION':"HikVision", 'DAHUA':"Dahua", "FOSCAM":"Foscam"});
console.log(cameraType.enums);
cameraType.enums.forEach(function(element) {
@stoeffel
stoeffel / curry-this.md
Last active August 29, 2015 14:26
nmotw curry-this

Curry-this

Curry-this makes creating curryied function simple and expresive by invoking curry with the function bind syntax ::. Apart from the expresive way of creating a curried function, the main feature are placeholders. A placeholder (_) is a Symbol which allows to curry specific arguments of a function.

Install it: npm install --save curry-this

Basic usage