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 assoc-in* | |
"God forgive me." | |
[m ks v] | |
(let [k (first ks)] | |
(if (> (count ks) 0) | |
(assoc m k (assoc-in* (get m k) (rest ks) v)) | |
(assoc m k v)))) |
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
[master][~/code/wrk]$ ./wrk -c50 -t20 -d15s http://localhost:8080/ | |
Running 15s test @ http://localhost:8080/ | |
20 threads and 50 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 0.00us 0.00us 0.00us -nan% | |
Req/Sec 0.00 0.00 0.00 -nan% | |
1799 requests in 15.30s, 1.95MB read | |
Requests/sec: 117.61 | |
Transfer/sec: 130.81KB |
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 ?assoc-transform | |
"(?assoc-transform {:a 1} :a 2 sequential? vector) => {:a [1 2]}" | |
[m k v test transform] | |
(let [val (m k)] | |
(if-let [okay (test val)] | |
(assoc m k v) | |
(assoc m k (transform val v))))) |
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 vectorish [left right] | |
(if (sequential? left) | |
(conj left right) | |
(vector left right))) | |
(defn ?assoc-transform | |
"(?assoc-transform {:a 1} :a 2 sequential? vector) => {:a [1 2]}" | |
[m k v transform] | |
(assoc m k (transform (m k) v))) |
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 learn-korma.core-test | |
(:require [clojure.test :refer :all] | |
[korma.core :refer :all] | |
[korma.db :refer :all])) | |
(defdb db | |
(postgres {:db "learnkorma"})) | |
(defentity posts | |
(pk :id) |
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
;; fuck yo JavaScript Numbers son | |
(defn ends-in-0 [n] | |
(contains? #{0.0 0} (mod n 1))) | |
(defn maybe-int [n] | |
(or (and (ends-in-0 n) (int n)) n)) | |
(defmethod response |
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 fake.is.awesome.config | |
(:require [environ.core :refer [env]])) | |
(defn kenv | |
([key] | |
(kenv key nil)) | |
([key fallback] | |
(keyword (env key fallback)))) | |
(defn string->boolean [s] |
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
##### dev.env | |
export database_url="fake" | |
export rabbitmq_host="fakehost" | |
export fake_start_consumers="true" | |
export fake_start_web="true" | |
export push_schema="true" | |
export rabbitmq_fake_qname="fake" | |
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 get_request(): | |
""" | |
blindly walks up the stack looking for | |
request.user | |
""" | |
for i in itertools.count(): | |
try: | |
frame = sys._getframe(i) | |
except ValueError: | |
frame = None |
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
import edn | |
inc_id_gen = """ | |
[{:db/id #db/id [:db.part/user] | |
:db/ident :auto-id-generator | |
:db/fn #db/fn {:lang "clojure" | |
:params [db e attr prefix] | |
:code "(let [key (keyword (str \\"increment/\\" prefix)) | |
counter (first (datomic.api/q '[:find ?e ?val :in $ ?key :where [?e ?key ?val]] db key)) | |
c-entity (first counter) |