Skip to content

Instantly share code, notes, and snippets.

@xgrommx
xgrommx / expandRecursive.js
Created November 23, 2015 15:14 — forked from trxcllnt/expandRecursive.js
Ix/Rx expandRecursive is a depth-first recursive expansion on the sequences.
var Ix = require('ix'),
Rx = require('rx'),
Enumerable = Ix.Enumerable,
Enumerator = Ix.Enumerator,
Observable = Rx.Observable;
Observable.permute = function(root, hasPermutation, resultSelector) {
return Observable
.returnValue({ value: root, depth: -1 })
.expandRecursive(function(wrapper) {
@xgrommx
xgrommx / post.md
Created December 15, 2015 00:35 — forked from justinwoo/post.md
How to make a Cycle.js + Elm hybrid Etch-a-Sketch app. Original: http://qiita.com/kimagure/items/d6ac01e6258ecd363ffe

How to make a Cycle.js + Elm hybrid Etch-a-Sketch app

A couple of days ago, I wrote a Cycle.js app using Elm to render stuff to the page. This was pretty fun and got some attention, so I might as well write about it some.

Writing this thing

Overview

A Cycle.js application consists of three parts: your main function declaration, your drivers setup, and your application initialization with Cycle.run (which sets up the "Cycle" part of your application). We'll do the following in our app:

@xgrommx
xgrommx / rxjs_operators_by_example.md
Created March 30, 2016 11:07 — forked from btroncone/rxjs_operators_by_example.md
RxJS 5 Operators By Example

#RxJS 5 Operators By Example A (soon to be) complete list of RxJS 5 operators with easy to understand explanations and runnable examples.

(I will be adding one operator per day until all operators are included.)

Table of Contents

@xgrommx
xgrommx / _usage.js
Created April 25, 2016 01:10 — forked from jethrolarson/_usage.js
xface - Functional Interface library for typed common apis
//Some fantasy implementations
const Just = require('./just')
const Cant = require('./cant')
const List = require('./list')
//Spec file that defines what arguments are used for type identification
const fantasy = require('./fantasy')
//The magic.
const {chain, map, index} = require('../../src/xface')(fantasy, [Just, Cant])
@xgrommx
xgrommx / countdown.rx.js
Created April 25, 2016 01:13 — forked from Willmo36/countdown.rx.js
countdown with rx
const now = moment();
const end = now.clone().add(2, 'minutes');
const diff = (end - now) / 1000;
const tick$ = Rx.Observable.timer(0,1000)
.scan((acc) => {
return acc - 1;
}, diff)
.take(diff);
@xgrommx
xgrommx / signal.js
Created April 25, 2016 01:16 — forked from L8D/signal.js
function Signal(sub) {
this.sub = sub;
}
Signal.prototype = {
/**
* Applies the given function over each event.
*/
map: function(fn) {
var sub = this.sub;
@xgrommx
xgrommx / gist:83b187124cfb9adca453320ae3e513a2
Created May 24, 2016 23:00 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.22/rx.all.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
font-family: Sans-serif;
module Main where
import Control.Applicative
import Data.Monoid
import Data.Traversable
import Data.Foldable
-- Say I define a Binary Tree data structure
data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
@xgrommx
xgrommx / 01-future.js
Created June 26, 2016 20:52 — forked from spion/01-future.js
Future and ReaderT with auto-lifting and example
class Future {
constructor(computation) {
this.fork = computation
this.__future__ = true;
}
static is(val) {
return (val != null && val.__future__ === true)
}
static of(value) {
if (Future.is(value)) return value;