Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

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.

var config = {
ga: 'UA-54546159-4'
};
/**
* Botinder
*/
// Init app
var Botinder = Ember.Application.create({
rootElement: '#app'
"use strict";
var ApplicationConfiguration = function() {
var applicationModuleName = "backer-news",
applicationModuleVendorDependencies = ["ngResource", "ngCookies", "ngAnimate", "ngTouch", "ngSanitize", "ui.router", "ui.bootstrap", "ui.utils"],
registerModule = function(moduleName, dependencies) {
angular.module(moduleName, dependencies || []), angular.module(applicationModuleName).requires.push(moduleName)
};
return {
applicationModuleName: applicationModuleName,
applicationModuleVendorDependencies: applicationModuleVendorDependencies,

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@dvliman
dvliman / raymond
Last active August 29, 2015 14:09
new
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class Person {
protected:
string name;
string address;
@dvliman
dvliman / main.go
Last active August 29, 2015 14:11 — forked from nmerouze/main.go
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"

Journey

I was using Boot2Docker 1.2 (OSX) and wanted to use volume for MongoDB. First nothing was happening because 1.2 has no Guest Additions and volumes don't work. There is a workaround by making a boot2docker.iso from master which has Guest Additions.

But then Mongo didn't like putting data on VirtualBox's shared folders:

[initandlisten] 	WARNING: This file system is not supported. For further information see:
[initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
# rob houses (3,5,1,7,9) where the rule is
# you can not rob adjacent houses and the goal
# is to get the maximum sum value
# 3 => 3
# 3, 5 => 5
# 3, 5, 1 => 5
# 3, 5, 1, 7 => 12
# ...
# 3, 5, 1, 7, 9
drwxr-xr-x 7 dv staff 238B Jul 18 2014 HackerSwifter
drwxr-xr-x 27 dv staff 918B Aug 17 15:46 NewsBlur
drwxr-xr-x 11 dv staff 374B Jun 24 2014 ScalaWebscraper
drwx------@ 6 dv staff 204B May 10 2014 ScrapeBox
drwxr-xr-x 20 dv staff 680B Jul 18 2014 SwiftHN
drwxr-xr-x 18 dv staff 612B Dec 25 14:06 atlas
drwxr-xr-x 24 dv staff 816B Sep 9 10:53 beansdb
drwxr-xr-x 33 dv staff 1.1K Aug 21 21:44 bolt
drwxr-xr-x 11 dv staff 374B Jul 16 2014 buggy
drwxr-xr-x 10 dv staff 340B Sep 8 22:05 cloudtunes
@dvliman
dvliman / gist:cd43db0419f400725fbd
Created February 19, 2015 00:05
uninstall-node-pkg
if you installed node pkg from official website, here is how to uninstall
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
brew install node