Skip to content

Instantly share code, notes, and snippets.

@aduth
aduth / simple-preact-slots.js
Created May 31, 2017 23:53
Simple Preact / React Slot & Fill Pattern
/**
* External dependencies
*/
import { createElement, Component } from 'preact';
const slots = {};
const fills = {};
let toUpdate = [],
nextUpdate;
@developit
developit / unistore.js
Last active September 8, 2020 15:13
Update: the newer & better version of this is published: https://github.com/developit/unistore
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/
@Avaq
Avaq / combinators.js
Last active September 26, 2024 18:53
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@jmaicher
jmaicher / geofix
Created March 11, 2013 09:07
Simple tcl script for sending geo locations to the android emulator via telnet. Usage: geofix lng lat [port]
#!/usr/bin/expect
log_user 0 # supress output
switch -regexp [llength $argv] {
[0,1] {
puts "Usage: geofix lng lat \[port\]"
exit
}
3 { set port [lindex $argv 2] }
@roidrage
roidrage / oauth.coffee
Created May 23, 2011 08:21
Example of using Express and node-oauth to do OAuth with Twitter
express = require "express"
sys = require "sys"
util = require "util"
oauth = require "oauth"
fs = require "fs"
app = module.exports = express.createServer()
app.configure('development', () ->
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))