Skip to content

Instantly share code, notes, and snippets.

@xgrommx
xgrommx / y.js
Created October 16, 2015 15:06 — forked from kevincennis/y.js
Y Combinator
// Y Combinator
// λf.(λg.f(λy.g g y))(λg.f(λy.g g y))
//
// derives the fixed-point of the input function
// such that Y( f ) and f( Y( f ) ) are computationally equivalent
function Y( f ) {
return (function( g ) {
return f(function( y ) {
@xgrommx
xgrommx / 01_folds.fs
Created October 19, 2015 06:10 — forked from cloudRoutine/01_folds.fs
F# Transducers - they work for the most part
open System.Collections.Generic
open Microsoft.FSharp.Collections
[<RequireQualifiedAccess>]
module Folds =
// These are the fast implementations we actually want to use
@xgrommx
xgrommx / gist:ef52242cebf225913a60
Created October 28, 2015 14:52 — forked from pH200/gist:4474bf7d8d2075c56317
RxJS for full screen image resizing
var gestureObservable = Rx.Observable.createWithDisposable(function (observer) {
var gesture = new MSGesture();
gesture.target = gestureTarget;
var pointerSub = Rx.Observable.fromEvent(gestureTarget, "pointerdown")
.subscribe((ev: any) => gesture.addPointer(ev.pointerId));
var gestureSub = Rx.Observable.fromEvent(gestureTarget, "MSGestureTap")
.subscribe((ev: MSGestureEvent) => observer.onNext(ev));
return new Rx.CompositeDisposable(
pointerSub,
@xgrommx
xgrommx / react-slider.jsx
Created October 28, 2015 15:55 — forked from bobpace/react-slider.jsx
React Slider with Rx Observable implementation of drag and drop
var React = require('react');
var Input = require('react-bootstrap/src/Input');
var Glyphicon = require('react-bootstrap/src/Glyphicon');
var _ = require('lodash');
var Rx = require('rx');
var canUseDom = require('can-use-dom');
var changeCase = require('change-case');
function events(event) {
return canUseDom ? Rx.Observable.fromEvent(document, event) : Rx.Observable.empty;
@xgrommx
xgrommx / examples.md
Created November 1, 2015 20:01 — forked from mattpodwysocki/examples.md
RxJS Demos

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {
@xgrommx
xgrommx / ReactiveExtensionsNotes.md
Created November 6, 2015 21:58 — forked from rbirkby/ReactiveExtensionsNotes.md
Reactive Extensions notes
-- 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
@xgrommx
xgrommx / functional-utils.js
Created November 13, 2015 14:54 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@xgrommx
xgrommx / producer-consumer.js
Created November 18, 2015 15:41 — forked from narqo/producer-consumer.js
"Producer-Consumer" example implementation using generators. See http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators for more about coroutine
/* jshint esnext:true */
/**
* "Producer-Consumer" implementation using generators.
* @see http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators
*/
var SIZE = 3,
queue = newQueue();