Skip to content

Instantly share code, notes, and snippets.

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

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / introrx.md
Created January 19, 2016 22:07 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
{-|
> ```
Consider a simple model for whether a person has the flu or not. Let F=1
indicate that a person has the flu and F=0 indicate that they don't have the
flu. Let C=1 indicate that the person has a cough and C=0 indicate that they
don't have a cough. Let M=1 indicate that the person has muscle pain and M=0
indicate that they don't have muscle pain. Assume that C and M are conditionally
independent given F so that the probability model is
P(C=c,M=m,F=f)=P(C=c|F=f)P(M=m|F=f)P(F=f).
Suppose that we ask two different doctors to supply probabilities for this model
-- paste into http://elm-lang.org/try and click "compile"
-- http://imgur.com/gallery/W6TwgZw
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Text
import Color exposing (..)
import Time
import Signal
@chrisbuttery
chrisbuttery / frp.md
Created November 1, 2015 09:17 — forked from ohanhi/frp.md
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Foreword

@chrisbuttery
chrisbuttery / using_mailboxes_in_elm.md
Created November 1, 2015 07:23 — forked from mgold/using_mailboxes_in_elm.md
Using Mailboxes in Elm: a tutorial blog post

Using Mailboxes in Elm

Max Goldstein | July 30, 2015 | Elm 0.15.1

In Elm, signals always have a data source associated with them. Window.dimensions is exactly what you think it is, and you can't send your own events on it. You can derive your own signals from these primitives using map, filter, and merge, but the timing of events is beyond your control.

This becomes a problem when you try to add UI elements. We want to be able to add checkboxes and dropdown menus, and to receive the current state of these elements as a signal. So how do we do that?

The Bad Old Days

@chrisbuttery
chrisbuttery / .travis.yml
Created October 26, 2015 10:36 — forked from MoOx/.travis.yml
Run tap/tape tests using saucelabs
language: node_js
node_js:
- iojs
env:
global:
# https://docs.saucelabs.com/ci-integrations/travis-ci/
# SAUCE_USERNAME
- secure: Daa...
import test from 'tape';
const before = test;
const after = test;
// beforeEach/afterEach rely on shared state.
// That's a big anti-pattern for testing.
// It's also silly to run something before and after
// ever test -- many of your tests won't need it.

So I was curious how mocha implements their: "be synchronous if callback is undefined, be async if callback is defined". The way to do this is by using Function.length

// fn, fn -> null
function detect (fn, cb) {
  if (fn.length) return fn(() => cb())
  fn() && cb()
}
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"ecmaFeatures": {
"modules": [2]
},
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}