Skip to content

Instantly share code, notes, and snippets.

View StephanHoyer's full-sized avatar
🏠
Working from home

Stephan Hoyer StephanHoyer

🏠
Working from home
View GitHub Profile
@barneycarroll
barneycarroll / app.js
Last active March 24, 2016 11:59 — forked from tobyzerner/app.js
Mithril ES6 Components
// No dependencies! + 1 point
// Only one API to reference! + 1 point
const Widget = {
// Expose desired data directly using destructuring! + 1 point
controller({initialValue}) {
// No more retrieving references buried by the superclass! + 1 point
this.counter = initialValue;
// Two less methods! + 2 points
},
@webcss
webcss / mithril-touch.js
Last active May 26, 2020 15:34
mithril-touch, consume touch and mouse events evenly with mithril
/*****************************************
/* DOM touch support module
/*****************************************/
if (!window.CustomEvent) {
window.CustomEvent = function (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
};
@barneycarroll
barneycarroll / modulator.js
Last active August 4, 2022 11:08
Modulator: a light-touch API (with heavy internals) for auto-instantiating Mithril modules. Makes Mithril lifecycle management more user-friendly.
var mod = ( function initModulator(){
if( !Map ){
// A naive shim for maps functionality
var Map = shim;
var WeakMap = shim;
}
// Registry of instantiation contexts
var contexts = new WeakMap();
// All automated counts
@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2024 10:15
Essential JavaScript Links
@avimar
avimar / gist:3092732
Created July 11, 2012 19:37
install node.js from source with salt
nodejs-deps:
pkg.installed:
- names:
- g++
- curl
- libssl-dev
- apache2-utils
require:
- pkg: git
@domenic
domenic / example.js
Last active May 25, 2018 10:17
Promise chaining example
// `promise` is some operation that may succeed (fulfill) or fail (reject)
var newPromise = promise.then(
function () {
return delay(1000);
},
writeError
);
// If `promise` fulfills, `newPromise` will fulfill in 1000 ms.
// If `promise` rejects and writing to the error log succeeds,