Skip to content

Instantly share code, notes, and snippets.

View dogenpunk's full-sized avatar

Matthew M. Nelson dogenpunk

  • Parenthetically Unbalanced
  • Madison, WI
View GitHub Profile

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.

#! /usr/bin/env python
import sys, subprocess, os, pytz
from datetime import datetime, timedelta
from optparse import OptionParser
from dateutil.parser import parse as dateparse
def get_dates_and_shas(branch, start, end, interval):
"""Gets the relevant shas given the start date, end date and interval on
the given branch.
// limit .data number parsing to canonical representations
// fixes jQuery tickets #7579; #11297; #10174
(function( $ ) {
var fnData = $.fn.data;
$.fn.data = function( key, value ) {
if ( value === undefined ) {
// parse data attributes on every element (including forms with unfortunately-named controls)
// before the official jQuery.fn.data gets a chance to
@dogenpunk
dogenpunk / catalog_test.js
Created December 3, 2012 06:18 — forked from pamelafox/catalog_test.js
Coursera catalog view test
describe('catalogyBody', function() {
var chai = require('chai');
var path = require('path');
var env = require(path.join(testDir, 'lib', 'environment'));
var requirejs = env.requirejs(staticDir);
var sinon = requirejs('js/lib/sinon');
var fs = require('fs');
var server;
var router;
@dogenpunk
dogenpunk / Class.js
Created August 7, 2012 12:17
Simple Javascript Inheritance
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@dogenpunk
dogenpunk / FilteredCollection.js
Created August 7, 2012 12:17
Backbone.js Collection with filters
RailsCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'url');
},
url: function() {
var base = this.baseUrl || this.model.prototype.baseUrl;
if(!this.params) {
return base;
@dogenpunk
dogenpunk / StreamingCollection.js
Created August 7, 2012 12:17
Backbone.js StreamingCollection
var StreamCollection = Backbone.Collection.extend({
stream: function(options) {
this.unstream();
var _update = _.bind(function() {
this.fetch(options);
this._intervalFetch = window.setTimeout(_update, options.interval || 1000);
}, this);
_update();
},
@dogenpunk
dogenpunk / Asset.js
Created August 7, 2012 12:17
JS 'new' Object instantiation protection
function Something () {
if (! (this instanceof arguments.callee)) {
return arguments.callee(arguments);
}
}
// Guarantees that the object will be instantiated via new Object method.
@dogenpunk
dogenpunk / Asset.js
Created August 7, 2012 12:17
Cross-browser logging function
function log() {
try {
console.log.apply( console, arguments );
}
catch( e ) {
try {
opera.postError.apply( opera, arguments );
}
catch( e ) {
alert(Array.prototype.join.call( arguments, " " ));