Skip to content

Instantly share code, notes, and snippets.

View stoeffel's full-sized avatar
🦔

Christoph Hermann stoeffel

🦔
View GitHub Profile
@staltz
staltz / introrx.md
Last active July 28, 2025 11:58
The introduction to Reactive Programming you've been missing
@stoeffel
stoeffel / extjs5-bind-emptyText.js
Last active August 29, 2015 14:02
extjs5 bind emptytext (ViewModel)
// bind needs a getter to update the property.
// emptytext has no setter. So you need to create one
Ext.define('Override.Textfield', {
override: 'Ext.form.field.Text',
setEmptyText: function(emptyText) {
this.emptyText = emptyText;
this.applyEmptyText();
}
});
var Option = require('fantasy-options')
var Some = Option.Some;
var None = Option.None;
var Compose = function(x){
this.val = x;
}
Compose.prototype.map = function(f){
return new Compose(this.val.map(function(u){return u.map(f); }));
@stoeffel
stoeffel / javascript function text-object for vim
Created May 9, 2014 15:17
javascript function text-object for vim
function! TextObjectFunction()
normal! ]}%
execute "normal ?function\<CR>"
normal! vf{%
endfunction
vnoremap af :<C-U>silent! :call TextObjectFunction()<CR>
omap af :normal vaf<CR>
@jeffmo
jeffmo / gist:054df782c05639da2adb
Last active January 11, 2024 06:05
ES Class Property Declarations
@branneman
branneman / better-nodejs-require-paths.md
Last active June 24, 2025 22:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@andyhd
andyhd / lens.js
Created February 11, 2012 01:48
Javascript Lenses
function lens(get, set) {
var f = function (a) { return get(a); };
f.set = set;
f.mod = function (f, a) { return set(a, f(get(a))); };
return f;
}
var first = lens(
function (a) { return a[0]; },
function (a, b) { return [b].concat(a.slice(1)); }
@tbtlr
tbtlr / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',