Skip to content

Instantly share code, notes, and snippets.

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f5dae393268>
Traceback (most recent call last):
File "/home/randylien/Envs/htccms/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/randylien/Envs/htccms/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/randylien/Envs/htccms/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/randylien/Envs/htccms/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
@randylien
randylien / GraphQL-Relay-Redux.md
Created February 17, 2016 08:49 — forked from idibidiart/GraphQL-Architecture.md
GraphQL/Relay: The End of Redux? ... Perhaps.

GraphQL allows us to define a model of our data on the server using a graph schema, which is the most natural way of describing the stuctures and relationships in our data. To feed our model with data, we define resolvers that use the db's own query language (SQL, NoSQL, or Graph query language, etc) or in-memory objects to resolve queries from the UI against the graph data model we define.

With each components in the UI component tree declaring its own data dependencies, GraphQL/Relay creates a projection of the graph data model that maps to the UI component tree, thus allowing us to have an application-agnostic data layer on the server, while at once giving us and UI-specific projection of the data. The queries from GraphQL server to the database are composed in an efficient manner based on the aggregate data dependencies that are declared by each component in the UI component tree, thus eliminating redundant queries to the database.

@randylien
randylien / clojure_thoughts.md
Created January 19, 2016 16:18 — forked from KevinGreene/clojure_thoughts.md
Thoughts on Clojure after introductory talk

Hey all,

Thanks for coming out and talking about Clojure and ClojureScript! I'm not going to be posting the source code for the project, as I'm still not 100% if it will end up monetized at all, but it will probably make it's way to GitHub eventually.

If you want to learn more about Clojure, ClojureScript, and how they can help you, you have a ton of options:

Intro:

Living Clojure by Carin Meier - http://www.amazon.com/Living-Clojure-Carin-Meier/dp/1491909048 - Also available at GRPL

@randylien
randylien / core.cljs
Created October 7, 2015 17:17 — forked from bhauman/core.cljs
Helpful patterns when developing with ClojureScript Figwheel and Express js
(ns todo-server.core
(:require
[cljs.nodejs :as nodejs]
[figwheel.client :as fw]))
(nodejs/enable-util-print!)
(defonce express (nodejs/require "express"))
(defonce serve-static (nodejs/require "serve-static"))
(defonce http (nodejs/require "http"))
@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]
#!/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
; 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

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).

@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.

@randylien
randylien / react-component-template.jsx.js
Last active November 18, 2015 23:11
React Life Cycle Template
'use strict';
var React = require('react');
var ReactComponentName = React.createClass({
getDefaultProps: function() {
return {
};