Skip to content

Instantly share code, notes, and snippets.

@randylien
randylien / loading.md
Last active August 29, 2015 14:10 — forked from thomasboyt/loading.md

I've been struggling to come up with a good pattern for handling loading state in Flux (specifically using Fluxxor, though I think this is an issue for any implementation).

When I say "loading state," what I mean is state in a store that tracks:

  • Whether the data handled by the store was loaded
  • Whether the store is currently attempting to load data
  • Whether the data loaded successfully or errored
  • The error message, if it errored

Here's my first (very simple) pass at this, a store mixin called LoadingStoreMixin.js:

@randylien
randylien / introrx.md
Last active August 29, 2015 14:14 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

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.

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

; Haversine formula
; a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
; c = 2 ⋅ atan2( √a, √(1−a) )
; d = R ⋅ c
; where φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);
(defn haversine
"Implementation of Haversine formula. Takes two sets of latitude/longitude pairs and returns the shortest great circle distance between them (in km)"
[{lon1 :lng lat1 :lat} {lon2 :lng lat2 :lat}]
(let [R 6378.137 ; Radius of Earth in km
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="WRONG_COMMIT_EMAIL"
CORRECT_NAME="YOUR_COMMIT_NAME"
CORRECT_EMAIL="YOUR_COMMIT_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@randylien
randylien / a_nucleus_example.cljs
Last active September 21, 2015 06:28 — forked from loganlinn/a_nucleus_example.cljs
nucleus - a tiny flux-like architecture in clojurescript
(ns a-nucleus-example
(:require-macros
[cljs.core.async.macros :refer [go go-loop]]
[nucleus.action :refer [defaction]])
(:require
[nucleus.core :as nucleus :refer [dispatch! perform!]]
[nucleus.model :as model]
[om.core :as om]
[om-tools.core :refer-macros [defcomponent]]
[om-tools.dom :as dom :include-macros true]
@randylien
randylien / gist:889095
Created March 27, 2011 09:52
程式設計師懺情錄(上)

發信人: xeon.bbs@bbs.tnfsh.tn.edu.tw ()
日期: Fri Mar 29 12:05:03 2002
標題: [轉貼] [轉錄]程式設計師懺情錄(上)

作者: erictsai (連備取都沒有的白痴!) 站內: TFcis
標題: [轉錄]程式設計師懺情錄(上) --eric要我轉的
時間: Thu Mar 28 20:54:12 2002

※ 本文轉錄自 [erictsai] 信箱

@randylien
randylien / LICENSE.txt
Created May 24, 2011 10:11 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE