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 ...) |
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
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
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
postwalk comes from clojure.walk/postwalk (namespace might be cljs.walk in cljs, you'll have to check) | |
may need to look at prewalk, i didn't test so dunno. also didn't pay attention to which (pre or post) is more efficient in this case (if they both work) | |
(postwalk | |
(fn [item] | |
(let [t (:type item)] | |
(if (or (not (map? item)) | |
(nil? t) | |
(= t filter-type)) | |
item |
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
; ok | |
(println foo | |
bar | |
baz | |
quux) | |
; ok | |
(println | |
foo | |
bar |
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 infect [{inputs :pathogen/infected | |
immune :pathogen/immune | |
traits :pathogen/diseases | |
:as c}] | |
;'([protocol [output-key output-fn]] [protocol [output-key output-fn]]) | |
(->> | |
(for [infected (->> (or (seq inputs) (keys c)) | |
(filter (complement (or immune #{}))) | |
(map (partial get c))) | |
[protocol [output-key output-fn]] traits] |
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
template <typename T> constexpr T bitfield (T bit) { return 1 << bit; } | |
namespace Telemetry { | |
enum TelemetryType { | |
Guage = bitfield(0), | |
Counter = bitfield(1), | |
Debug = bitfield(2), | |
Info = bitfield(3), | |
Warn = bitfield(4), | |
Error = bitfield(5) |
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
(def rui-components | |
{'list rui/list | |
'list-item rui/list-item}) | |
(def component-registry | |
(merge | |
rui-components | |
{})) | |
(def my-template |
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
#ifndef HELPERS_H | |
#define HELPERS_H | |
#include <core/Godot.hpp> | |
#include <core/Dictionary.hpp> | |
#include <core/String.hpp> | |
#include <Node.hpp> | |
namespace helpers { |
OlderNewer