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 gumball.core) | |
(defn xy-coords [x-max y-max word-len] | |
(for [x (range (inc (- x-max word-len))) | |
y (range (inc (- y-max word-len)))] | |
(for [n (range word-len)] | |
[(+ x n) (+ y n)]))) | |
(defn yx-coords [x-max y-max word-len] | |
(for [x (range word-len x-max) |
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
<?php | |
class Bomb { | |
function disarm() { | |
echo "Disarming...\n"; | |
} | |
function __call($method, $args) { | |
echo "Bomb::__call('$method', ...)\n"; | |
} | |
} |
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
<?php | |
$a = array(); | |
$vals = [ | |
['"" ', ""], | |
['0 (int) ', 0], | |
['0.0 (float) ', 0.0], | |
['"0" (string) ', "0"], | |
['FALSE ', false], | |
['NULL ', 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
(ns dining-philosophers) | |
(def log-agent (agent 0)) | |
(defn do-log [msg-id message] | |
(println message) | |
(inc msg-id)) | |
(defn log [& strs] | |
(send-off log-agent do-log (apply str strs))) |
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
-------------------------------------------------------------------------------- | |
-- PHP-style serialization in PostgreSQL | |
-- Making a better situation of someone else's bad decision | |
-- See examples at bottom | |
-------------------------------------------------------------------------------- | |
-------------------------------------------------------------------------------- | |
-- Serialization function per type | |
CREATE OR REPLACE FUNCTION php_serialize(boolean) RETURNS text |
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 with-channels | |
(:require | |
[om.core :as om] | |
[cljs.core.async :as async])) | |
(defn get-channels [owner] | |
(assert (.-state owner) "Component state not found. Are you calling from getInitialState?") | |
(aget (.-state owner) "__with-channels_channels")) | |
(defn chan |
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 examples.unmount.core | |
(:require [om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(enable-console-print!) | |
(def app-state (atom {:widget :a})) | |
(defn widget-a [data owner] | |
(reify |
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
(deftest ops-test | |
(testing "mult with closed tap" | |
(go | |
(let [a (chan 4) | |
b (chan 4) | |
src (chan 1) | |
m (async/mult src)] | |
(async/tap m a) | |
(async/tap m b) |
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 history | |
"Light wrappers and utils for js/history") | |
(defn back! [] (.back js/history)) | |
(defn forward! [] (.forward js/history)) | |
(defn go! [idx] (.go js/history idx)) | |
(defn replace-state! |
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
(defmixin async-widget | |
(will-mount [] ...)) | |
(defcomponent widget [data owner] | |
(:mixins [async-widget]) | |
(render [_] ... )) | |
;; constructor calls om/build | |
(->widget widget-data) | |
(->widget widget-data widget-opts) |