This file contains 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
class Counter(object): | |
"""Increment-only counter""" | |
def __init__(self, peer_id): | |
self._peer_id = peer_id | |
self._counters = {peer_id: 0} | |
def increment(self): | |
self._counters[self._peer_id] += 1 | |
def value(self): |
This file contains 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
user=> (def items [{:id 1 :data "hi"} | |
{:id 2 :data "ho"} | |
{:id 3 :data "test"}]) | |
#'user/items | |
user=> (first-where items :id = 1) | |
{:data "hi", :id 1} | |
user=> (first-where items :id > 1) ; will return only the first matching item | |
{:data "ho", :id 2} | |
user=> (get-where items :id > 1) ; will return all matching items | |
[{:data "ho", :id 2} |
This file contains 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
;; Eclipse Public License 1.0 http://opensource.org/licenses/eclipse-1.0.php | |
(defn make-wrapped-component | |
"Wrap a React component in such a way that the raw JS component is accessible. | |
Useful for for calling methods on the native React component." | |
[component] | |
(fn [attrs & children] | |
(r/create-class | |
{:component-did-mount | |
(fn [this] |
This file contains 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 child [props owner {:keys [ch]}] | |
(reify | |
om/IInitState | |
(init-state [_] | |
{:text ""}) | |
om/IRenderState | |
(render-state [_ {:keys [text editable?]}] | |
(dom/div nil | |
(if editable? | |
(dom/input ...) |
NewerOlder