Skip to content

Instantly share code, notes, and snippets.

View voronianski's full-sized avatar

Dmytro Voronianski voronianski

View GitHub Profile
@voronianski
voronianski / augment.js
Created March 9, 2014 14:09
Smallest and fastest classical JavaScript inheritance pattern.
(function (global, factory) {
if (typeof define === "function" && define.amd) define(factory);
else if (typeof module === "object") module.exports = factory();
else global.augment = factory();
}(this, function () {
"use strict";
var Factory = function () {};
var slice = Array.prototype.slice;
/*1397564784,180664133,JIT Construction: v1206444,en_US*/
/**
* Copyright Facebook Inc.
*
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
try {window.FB || (function(window) {
var self = window, document = window.document;

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@voronianski
voronianski / mongo_install.sh
Created September 24, 2014 14:06
Mongodb install on Ubuntu 12.04
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
apt-get -y update
apt-get -y install mongodb-10gen
@voronianski
voronianski / fibMemo.js
Last active August 29, 2015 14:09
Fibbonaci with caching as basic memoization example. Special thanks goes to https://twitter.com/ljsloz!
/*
* The 1st and 2nd Fibonacci numbers are both 1.
* Each Fibonacci number from the 3rd onwards is equal to the sum of the
* previous 2 Fibonacci numbers.
*
* The first 10 Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55.
*
* So fib(1) should return 1, fib(4) should return 3, fib(9) should return 34.
*
*/
@voronianski
voronianski / flattenArray.js
Last active August 29, 2015 14:10
Flatten arrays recursively and not-recursively (with type limitations) in JS - http://collabedit.com/rvkr8
// input = [1, {a: [2, 3]}, 4, [5, [6]], [[7], 8, 9], 10];
// output = [1, {a: [2, 3]}, 4, 5, 6, 7, 8, 9, 10];
// result = [1, {a: [2, 3]}, 4, 5, 6];
// result = [5];
// result = [6];
// result = [5, 6]
function transform0 (arr) {
@voronianski
voronianski / spiralMatrix.js
Last active August 29, 2015 14:18
Traverse spiral matrix
var matrix = [
[11, 12, 13, 14, 15],
[21, 22, 23, 24, 25],
[31, 32, 33, 34, 35],
[41, 42, 43, 44, 45]
];
function traverse (matrix) {
var startRow = matrix[0];
var output = [];
@voronianski
voronianski / soundplayer-test.html
Last active August 29, 2015 14:23
SoundPlayer widget script
<script>
/* * * CONFIGURATION VARIABLES * * */
var sb_soundplayer_client_id = '08f79801a998c381762ec5b15e4914d5';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function(d, s, id) {
if (d.getElementById(id)) return;
var js, p, fjs = d.getElementsByTagName(s)[0];
p = /^http:/.test(d.location) ? 'http' : 'https';
js = d.createElement(s);
@voronianski
voronianski / soundplayer_test2.html
Last active August 29, 2015 14:23
SoundPlayer embed widget
<div data-url="https://soundcloud.com/shura/shura-indecision-12-edit-1" class="sb-soundplayer-widget"></div>
@voronianski
voronianski / Progress.js
Last active August 29, 2015 14:23
SoundPlayer.js <Progress /> component
/** @jsx dom */
import { dom } from ‘deku’;
export default {
defaultProps: {
value: 0
},
propTypes: {