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
| function debounce(func, wait, immediate) { | |
| var timeout; | |
| return function () { | |
| var obj = this, argus = arguments; | |
| function delayed () { | |
| if (!immediate) { | |
| func.apply(obj, argus); | |
| } | |
| timeout = null; | |
| } |
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
| // For Parent.js | |
| var Parent = React.createClass({ | |
| render: function () { | |
| return ( | |
| <div><input onchange="" type="text" value="Parent"></input><child></child></div> | |
| ); | |
| } | |
| }); | |
| // For Child.js |
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
| // For Parent.js | |
| var Parent = React.createClass({ | |
| getInitialState: function () { | |
| return { | |
| changedValue: "" | |
| }; | |
| }, | |
| // the callback function for changing the text in <input type="text"></input> | |
| changeHandler: function (event) { |
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
| // For Parent.js | |
| var Parent = React.createClass({ | |
| getInitialState: function () { | |
| return { childRef: "childRef" }; | |
| }, | |
| changeHandler: function () { | |
| // use ref to call the instance of Child | |
| this.refs[this.state.childRef].getChildValue(); | |
| }, |
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
| // For Parent.js | |
| var Parent = React.createClass({ | |
| getInitialState: function () { | |
| return { parentValue: "" }; | |
| }, | |
| // the callback function is passed to Child as props | |
| passValueFunc: function (para) { | |
| if (this.state[para] != undefined) { | |
| return this.state[para]; |
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
| // For Parent.js | |
| var Parent = React.createClass({ | |
| getInitialState: function () { | |
| return { parentValue: "" }; | |
| }, | |
| // the callback function is passed to Child as props | |
| passValueFunc: function (para) { | |
| // handle the passed value from Child | |
| }, |
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 memoize | |
| [f] | |
| (let [mem (atom {})] | |
| (fn [& args] | |
| (if-let [e (find @mem args)] | |
| (val e) | |
| (let [ret (apply f args)] | |
| (swap! mem assoc args ret) | |
| ret))))) |
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
| (def sync-source (chan)) | |
| (def sync-sink (debounce sync-source 10000)) | |
| (defn handle-event! [event] | |
| (when-let | |
| [handler (case (:type event) | |
| :one-event function-wanna-call | |
| unknown-event)] | |
| (try | |
| (apply handler (:args event)) |
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
| (ns experiment.infra.election | |
| (:use [datomic.api :only [q] :as d]) | |
| (:require [experiment.system :as sys] | |
| [experiment.infra.data :as data] | |
| [experiment.infra.protocols :as p])) | |
| ;; | |
| ;; Reserve - Simple peer coordination mechanism | |
| ;; | |
| ;; Reservations support multiple peers trying to distribution operations |
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
| #!/usr/bin/env node | |
| var request = require('request'), | |
| fs = require("fs"); | |
| var skamSesongSubtitles = [["1", 'MSUB1912', '16AW', 11], | |
| ["2", 'MYNT1500', '16AA', 12], | |
| ["3", 'MYNT1520', '16AA', 10]]; | |
| // get the subtitle content with given sesong number, episode, url, saving folder and callback function |