Skip to content

Instantly share code, notes, and snippets.

@xcoderzach
xcoderzach / function_bind_syntax.js
Last active August 29, 2015 14:15
Function Bind Syntax
import _ from 'lodash'
function ooify(fn) {
return function() {
return fn.apply(this, [this].concat([].slice.call(arguments)))
}
}
var methods = _.zipObject(_.map(_.keys(_.prototype), methodName => {
return [methodName, ooify(_[methodName])]
}))
@janecakemaster
janecakemaster / empirejs.md
Last active August 29, 2015 14:20
empire js notes 2015

EmpireJS 2015 - takeaways and resources

Day 1

Rudy Jahchan - Getting Started in VR with JS (art, vr, physical)

  • slides
  • it would be cool to get our hands on google cardboard and experiment with 3d-ish video!
@PatrickJS
PatrickJS / rxPipeRegistry.ts
Last active November 12, 2015 16:51
rx support for Angular 2 Async Pipe
/// <reference path="../../typings/tsd.d.ts" />
///
import {PipeFactory} from 'angular2/src/change_detection/pipes/pipe';
import {async} from 'angular2/src/change_detection/change_detection';
import {NullPipeFactory, Pipe, PipeRegistry, defaultPipes} from 'angular2/change_detection';
import {bind} from 'angular2/di';
import {ObservablePipe} from 'angular2/pipes';
import * as Rx from 'rx';
export function isObservable(obs) {
@callumacrae
callumacrae / rand.js
Created March 29, 2013 12:52
Random number generator.
/**
* Returns random numbers. See individual functions for docs.
*
* This function can be used as a shortcut function: by default, it will call
* rand.int() using the arguments given to it. You can change which method it
* will call by changing the rand.default string to any of the method names.
*/
function rand(length) {
"use strict";
function loadSomeStuff(id) {
// We return basic-stream https://github.com/rpominov/basic-streams
return _sink => {
let sink = _sink
const onSuccess = data => sink({type: 'success', data})
const onError = error => sink({type: 'error', error})
stuffLoadingService.load(id).done(onSuccess, onError)
return () => {
// We can't unsubscribe from a Promise, so we simply make sink() a noop
sink = () => {}
@rpominov
rpominov / fl2.md
Last active March 24, 2016 14:29

Setoid

  1. S.equals(a, a) = true (reflexivity)
  2. S.equals(a, b) = S.equals(b, a) (symmetry)
  3. If S.equals(a, b) and S.equals(b, c), then S.equals(a, c) (transitivity)

Semigroup

  1. S.concat(S.concat(a, b), c) is equivalent to S.concat(a, S.concat(b, c)) (associativity)
@Dorus
Dorus / samples.js
Created May 4, 2016 22:52
Marble samples
var source$ = Rx.Observable.marble("1--23--456--7890--");
var enter$ = Rx.Observable.marble("-e-----e----------");
var exit$ = Rx.Observable.marble("---x-------x------");
var sampler$ = Rx.Observable.marble("a--b--c--d--e--f--");
var full$ = Rx.Observable.marble("01234567890abcdefg");
source$.draw('source', '#container')
.debounceTime(1050).draw('debounceTime(1)', '#container');
source$.auditTime(1050).draw('auditTime(1)', '#container');
source$.throttleTime(1050).draw('throttleTime(1)', '#container');
@stoeffel
stoeffel / These.elm
Last active May 26, 2016 20:59
data.these in elm
import Html exposing (..)
type These a b
= This a
| That b
| Both a b
| Neither
@zudov
zudov / AffEventuallyPromises.md
Last active June 17, 2016 12:04
Aff vs. Promises vs. Eventual values.

I recently read this interesting post about eventual values. One thing that struck me and which I failed to understand is:

  • Eventual Values can be interacted with like normal values.
  • If an Eventual Value is part of a simple value operation, then that expression resolves to a new Eventual > Value which resolves when all its Eventual Values are resolved.

If I understood the author correctly, that is supposed to be solving several problems:

  1. "I don’t know if this is a Promise or not" (I don't know if it's the resolved result of the action, or the action itself).
  2. "I’d really like to write code that interacts with values, and not Promises, and leave the machinery to the computer to work out".
@ekmett
ekmett / MonadHom.hs
Created July 23, 2016 17:06
monad homomorphisms and stuff
{-# language ConstraintKinds #-}
{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language LambdaCase #-}
{-# language MultiParamTypeClasses #-}
{-# language PolyKinds #-}
{-# language RankNTypes #-}
{-# language ScopedTypeVariables #-}
{-# language TupleSections #-}
{-# language TypeFamilies #-}