Skip to content

Instantly share code, notes, and snippets.

View staltz's full-sized avatar

André Staltz staltz

View GitHub Profile
@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 / 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 / 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 / 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: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$) {
h('div.container', [
h('label.nameLabel', 'Name:'),
h('input.myinput', {attributes: {type: 'text'}}),
h('hr'),
h('h1.greeting', `Hello ${name}`)
])
// or
div('.container', [
@staltz
staltz / .vimrc
Last active December 23, 2015 06:39
vim syntax highlighting for git-done TODO
" Append these to your .vimrc
syntax enable
au BufRead,BufNewFile *.todo setfiletype todo
au BufRead,BufNewFile TODO setfiletype todo
@staltz
staltz / cycle-bmi.coffee
Created March 3, 2016 15:32
Cycle.js example in CoffeeScript
{run} = require '@cycle/core'
{Observable} = require 'rx'
{div, input, h2, makeDOMDriver} = require '@cycle/dom'
intent = (domSource) =>
changeWeight$ = domSource
.select('#weight').events('input')
.map((ev) => ev.target.value)
changeHeight$ = domSource
.select('#height').events('input')

Keybase proof

I hereby claim:

  • I am staltz on github.
  • I am andrestaltz (https://keybase.io/andrestaltz) on keybase.
  • I have a public key whose fingerprint is C83A 1721 7B3E 3DE2 23F2 F4C6 A1F0 0911 A32F D4DD

To claim this, I am signing this object:

@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: {