This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
json.success true | |
json.data do | |
json.auth_token @user.authentication_token | |
json.message "login successful" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Monad chain macro in Rust | |
//! | |
//! A typical usage is to avoid nested match expressions. | |
//! | |
//! Supports: | |
//! - Pattern matching | |
//! - Or expressions (A | B => ...) | |
//! - Guarded statements (x if <cond> => ...) | |
#[feature(macro_rules)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(0 until 12).drop(4).filter(_ % 2 == 0) | |
(->> (range 12) (drop 4) (filter #(= (mod % 2) 0))) | |
LongStream.range(0, 12).skip(4).filter((n) -> (n % 2) == 0) | |
// of course for the Java the whole story is: | |
import java.util.Arrays; | |
import java.util.stream.LongStream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Complete schema history for a live Datomic database. | |
(require | |
'[clojure.pprint :as pp] | |
'[clojure.set :as set] | |
'[datomic.api :as d]) | |
;; fill this in with your own database connection | |
(def uri "datomic:dev://localhost:4334/my-db") | |
(def conn (d/connect uri)) | |
(def db (d/db conn)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DeepLinkState = { | |
linkState: function(path) { | |
function setPath(obj, path, value) { | |
var leaf = resolvePath(obj, path); | |
leaf.obj[leaf.name] = value; | |
} | |
function getPath(obj, path) { | |
var leaf = resolvePath(obj, path); | |
return leaf.obj[leaf.name]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TodoItem = require('../templates/todoItem.jsx'); | |
//in render fn... | |
var todoItems = mori.into_array(mori.map(function (todo) { | |
idx++; | |
return TodoItem.call(this, todo, idx); | |
}.bind(this), shownTodos)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn show-form [data _] | |
(om/component | |
(let [schema (:current-form data) | |
alpaca-html (.html (.alpaca (js/jQuery. "<div/>") (clj->js {:schema schema}))) | |
form-html (js/React.DOM.div (clj->js {:dangerouslySetInnerHTML {:__html alpaca-html}}))] | |
form-html))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* react-catalyst.js | |
* | |
* LinkedState for Facebook's React UI Library. Add support for | |
* deep path state access. | |
* | |
* Author: Tung Dao <[email protected]> | |
* | |
* Usage: | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
/** | |
* Our component structure will look like the following: | |
* - WikiBox | |
* -- AutoCompleteBox | |
* --- AutoComplete | |
*/ | |
// this component renders a single entity coming from wikipedia |