Skip to content

Instantly share code, notes, and snippets.

View ngbinh's full-sized avatar

Binh Nguyen ngbinh

  • Anduin Transactions Inc
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.

@ngbinh
ngbinh / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-progress/paper-progress.html">
@ngbinh
ngbinh / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../topeka-elements/avatars.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-profile.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
@ngbinh
ngbinh / designer.html
Created September 16, 2014 17:35
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
class ApiController {
protected def getConfig() {
getGrailsApplication().config
}
protected def jsonData(data = null, otherData = null) {
([data: data] + (otherData ?: [:])) as JSON
}
protected def renderUnacceptable() {
@ngbinh
ngbinh / Model.scala
Last active August 29, 2015 14:19
Model ADT
sealed trait Id[T <: Id[T]]
trait Mid[T <: Mid[T]] extends Id[Mid[T]]
trait Sid[T <: Mid[T]] extends Id[Sid[T]]
case class AMid() extends Mid[AMid]
case class CSid() extends Sid[AMid]
@ngbinh
ngbinh / gist:f8c4897578eeee9c1ce9
Created April 22, 2015 18:55
`deisclt journal controller` after getting 502
ore@ip-172-31-27-128 ~ $ deisctl journal controller
-- Logs begin at Fri 2015-03-27 11:53:17 UTC. --
Apr 22 18:53:20 ip-172-31-7-103.ec2.internal sh[6958]: 2015-04-22T18:53:18Z 797b456cfb34 confd[91]: ERROR template: confd_settings.py:21:58: executing "confd_settings.py" at <getv "/deis/registry...>: error calling getv: key does not exist
Apr 22 18:53:20 ip-172-31-7-103.ec2.internal sh[6958]: 2015-04-22T18:53:18Z 797b456cfb34 confd[91]: ERROR template: confd_settings.py:21:58: executing "confd_settings.py" at <getv "/deis/registry...>: error calling getv: key does not exist
Apr 22 18:53:20 ip-172-31-7-103.ec2.internal sh[6958]: 2015-04-22T18:53:18Z 797b456cfb34 confd[91]: ERROR template: confd_settings.py:21:58: executing "confd_settings.py" at <getv "/deis/registry...>: error calling getv: key does not exist
Apr 22 18:53:20 ip-172-31-7-103.ec2.internal sh[6958]: 2015-04-22T18:53:18Z 797b456cfb34 confd[91]: ERROR template: confd_settings.py:21:58: executing "confd_settings.py" at <getv "/deis/registry...>: er
@ngbinh
ngbinh / gist:ae7734f01aa333b9de0d
Created April 22, 2015 19:13
deisctl status deis-registry@1
deisctl status deis-registry@1
● deis-registry@1.service - deis-registry
Loaded: loaded (/run/fleet/units/deis-registry@1.service; linked-runtime; vendor preset: disabled)
Active: active (running) since Wed 2015-04-22 19:02:25 UTC; 9min ago
Process: 12222 ExecStartPre=/bin/sh -c docker inspect deis-registry >/dev/null 2>&1 && docker rm -f deis-registry || true (code=exited, status=0/SUCCESS)
Process: 12169 ExecStartPre=/bin/sh -c IMAGE=`/run/deis/bin/get_image /deis/registry` && docker history $IMAGE >/dev/null 2>&1 || docker pull $IMAGE (code=exited, status=0/SUCCESS)
Process: 12154 ExecStartPre=/usr/bin/etcdctl mkdir /deis/cache >/dev/null 2>&1 (code=exited, status=4)
Main PID: 12231 (sh)
CGroup: /system.slice/system-deis\x2dregistry.slice/deis-registry@1.service
├─12231 /bin/sh -c IMAGE=`/run/deis/bin/get_image /deis/registry` && docker run --name deis-registry --rm -p 5000:5000 -e EXTERNAL_PORT=5000 -e HOST=$COREOS_PRIVATE_IPV4 $IMAGE
etcdctl ls / --recursive
/deis
/deis/migrations
/deis/migrations/data
/deis/migrations/data/0001
/deis/platform
/deis/platform/domain
/deis/platform/sshPrivateKey
/deis/platform/version
/deis/registry
fleetctl cat deis-registry@1
[Unit]
Description=deis-registry
[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=30m
ExecStartPre=-/usr/bin/etcdctl mkdir /deis/cache >/dev/null 2>&1
ExecStartPre=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/registry` && docker history $IMAGE >/dev/null 2>&1 || docker pull $IMAGE"
ExecStartPre=/bin/sh -c "docker inspect deis-registry >/dev/null 2>&1 && docker rm -f deis-registry || true"