Skip to content

Instantly share code, notes, and snippets.


André Staltz staltz

View GitHub Profile
View pull-stream-to-observable.ts
export function drained$<T>(pullStream: Function): Rx.Observable<T> {
return Rx.Observable.create(function subscribe(observer: Rx.Observer<T>) {
const drain = function drain(read: Function) {
read(null, function more(end: any | boolean, data: T) {
if (end === true) {
if (end) {
staltz / main.js
Created Mar 4, 2016
Cycle.js demo with MIDI and Web Audio
View main.js
import {Observable, Disposable} from 'rx';
import {run} from '@cycle/core'
const jsondiffpatch = require('jsondiffpatch').create({
objectHash: function(obj) {
function generateCurve(steps){
var curve = new Float32Array(steps)
staltz / .bashrc
Created Oct 16, 2017
Put this in your ~/.bashrc (or equivalent) file. Then run `reactnativedev ""`
View .bashrc
# Tweak tap coordinates as you wish
function reactnativedev() {
adb shell input keyevent 82;
sleep 0.1;
adb shell input tap 150 1401;
sleep 0.1;
adb shell input tap 150 1401;
sleep 0.1;
adb shell input text "$1";
sleep 0.1;
staltz / gist:7473252
Last active Mar 6, 2018
Code glossary
View gist:7473252

Code glossary

A useful list of programming jargon to solve your naming problems.

Adapter: a design pattern that translates one interface for a class into a compatible interface.

Admin: short for 'administrator'; very commonly used in speech or online to refer to the systems person in charge on a computer. Common constructions on this include sysadmin and site admin (emphasizing the administrator's role as a site contact for email and news).

Counter: a variable or user interface that counts occurrences or repetitions of some phenomena or event.

staltz /
Last active Feb 22, 2018
Call this from your Django settings file to import environment variables from '.env'. Useful if you use PyCharm and want an automatic solution to recognize your env variables.
import os
def import_env_vars(project_root):
"""Imports some environment variables from a special .env file in the
project root directory.
if len(project_root) > 0 and project_root[-1] != '/':
staltz / app.kt
Last active Jan 26, 2018
Cycle giving baby steps into Kotlin
View app.kt
import kotlin.browser.document
import kotlin.browser.window
// Type definitions
val Cycle : dynamic = noImpl
fun h(tagName: String) : VTree = noImpl
View xstream-to-pull-stream.ts
function xstreamToPullStream<T>(stream: Stream<T>): Readable<T> {
let hasBufferVal: boolean;
let bufferVal: T;
let bufferEndOrErr: any;
let callback: Callback<T>;
const listener: Listener<T> = {
next: t => {
console.log('pull stream Listener for xstream', t);
if (callback) {
console.log('pull stream direct', t);
staltz /
Last active Oct 26, 2017
How to debug Mocha tests written in Babel, running only in Node.js

Run this in one shell

./node_modules/.bin/mocha --debug-brk --compilers js:babel-register test/node

Then this in another shell


Then open the browser

staltz / slim-cycle-core.js
Created Sep 22, 2015
Cycle.js without sanity checks and comments in a single file. Don't use this, use normal Cycle.js. :-)
View slim-cycle-core.js
let Rx = require(`rx`)
function makeRequestProxies(drivers) {
let requestProxies = {}
for (let name in drivers) {
if (drivers.hasOwnProperty(name)) {
requestProxies[name] = new Rx.ReplaySubject(1)
return requestProxies
staltz / streamio.js
Created Oct 3, 2016
Playful Haskell Stream I/O with ES6 Generators
View streamio.js
function *main() {
const confirmRequest = {
type: 'confirm',
value: 'Are you sure?',
const confirmResponse = yield confirmRequest;
if (confirmResponse === true) {
const consoleRequest = {
type: 'console',
You can’t perform that action at this time.