Skip to content

Instantly share code, notes, and snippets.

View staltz's full-sized avatar

André Staltz staltz

View GitHub Profile
@staltz
staltz / gist:78140b885f366886d9b5
Last active August 29, 2015 14:19
Terse Cycle.js

Terse Cycle.js

Take Cycle's primal example, on the README:

import Cycle from 'cyclejs';
let {Rx, h} = Cycle;

let name$ = Cycle.createStream(function model(changeName$) {
@staltz
staltz / index.ios.js
Created April 7, 2015 06:43
Experiment with Cycle.js and React Native
'use strict';
var React = require('react-native');
var Cycle = require('cyclejs');
var {Rx, h} = Cycle;
var createExperimentalIOSRenderer = require('./src/ios-renderer.ios.js');
var {StyleSheet, Text, TextInput, View} = React;
var styles = StyleSheet.create({
container: {
@staltz
staltz / about-mercury.md
Last active August 29, 2015 14:14
El Mercurio

Rough sketch of how is the flow of data in Mercury.

                           │
  Event channels  <───────────── dom-delegator (events)
       │                   │           ^
       V  (imperative)                 │
  View state               │          DOM
@staltz
staltz / gist:2f0704b1ecadc42fb0ab
Last active August 29, 2015 14:13
Cycle components decouple abstraction from implementation

Cycle custom elements decouple the component's abstraction from its implementation.

When you use a React component like

<div>
  <NewHotness />
</div>

You are pulling in that specific NewHotness component. You actually had to explicity import the NewHotness component before using it.

@staltz
staltz / delayUntil.xtend
Created September 24, 2014 17:10
.delayUntil() for RxJava
/**
* Delays all items from the source Observable up until when the other Observable
* emits its first item. After the other Observable emitted its first item,
* the source items are not delayed.
*
* source: ---s-s---s----------s---s----s---s---s--|>
* other: ------------o------o-------o------o-----|>
* result: ------------sss-----s---s----s---s---s--|>
*
* @param first
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@staltz
staltz / promises-pyramid.js
Created May 3, 2014 06:05
Q promises pyramid of doom
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / single-err-catcher.js
Created May 3, 2014 05:59
Q promises single error catcher
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / point-wise-err-handlers.js
Last active August 29, 2015 14:00
Q promises point-wise error handling
var Q = require('q');
function delaydo(x) {
var deferred = Q.defer();
setTimeout(function() {
if (x === 2) {
console.log("reject: "+x);
deferred.reject(x);
}
else {
@staltz
staltz / gist:7473252
Last active March 6, 2018 05:23
Code glossary

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.