Skip to content

Instantly share code, notes, and snippets.

@pithyless
pithyless / i18n-impl.cljs
Last active June 24, 2021 09:49 — forked from isaksky/i18n-impl.cljs
Handling translations in ClojureScript
(ns front.utilities.i18n-impl
(:require [front.i18n]))
(defn build-domain-index [text-vec]
(let [by-msgid (atom (transient {}))
by-msg (atom (transient {}))]
(doseq [{:keys [s_message s_message_id] :as text} text-vec]
(when-not (clojure.string/blank? s_message_id)
(swap! by-msgid assoc! s_message_id text))
(when-not (clojure.string/blank? s_message)
@pithyless
pithyless / keybase.md
Created February 21, 2020 16:25
keybase.md

Keybase proof

I hereby claim:

  • I am pithyless on github.
  • I am pithyless (https://keybase.io/pithyless) on keybase.
  • I have a public key ASAXUfguy_endzUnkeC8v1Gc1dOmBl6wgRunTYVSyUlnOAo

To claim this, I am signing this object:

@pithyless
pithyless / import-vars.cljc
Last active September 1, 2021 19:07
A CLJC version of potemkin/import-vars
(ns my.util.namespace
#?(:cljs (:require-macros [my.util.namespace]))
(:require
#?(:clj [potemkin :as potemkin])))
(defmacro cljs-import-vars [& syms]
(let [unravel (fn unravel [x]
(if (sequential? x)
(->> x
@pithyless
pithyless / README.md
Last active April 6, 2018 13:09
Pedestal sync vs async error-handling

I expected the async error to be handled by the error-handler interceptor (i.e. [OK] Handling error.).

❯ clj -m dev

Do some work...
[OK] Got a response.
{:async :ok, :sync :ok}
@pithyless
pithyless / datomic-mysql-bootstrap.sql
Created April 3, 2018 15:50 — forked from favila/datomic-mysql-bootstrap.sql
Better MySQL bootstrap setup for datomic's datomic_kvs table
-- Optimized MYSQL schema for datomic
-- Unfortunately the bin/sql/mysql-*.sql bootstrapping files for datomic are not
-- very good, and can actually cause failures if not adjusted.
-- One symptom of this is the following error:
-- SQL Error (1071): Specified key was too long; max key length is 767 bytes.
-- Reported here: https://support.cognitect.com/entries/28462168-MySQL-Caveats
-- This is caused by the default collation for the `id` column possibly being
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@pithyless
pithyless / doctest.clj
Created January 4, 2018 13:35
Test executable docstrings à la Python's doctest.
(ns sursolid.fribble.doctest
"Test executable docstrings à la Python's doctest.
Inspired by Python's doctest, this namespace provides tools to
turn your regular docstrings into REPL sessions that will be
run and checked via your regular testing suite.
## Formatting the docstring
@pithyless
pithyless / doo-bug.md
Last active November 11, 2016 09:21
CLJS lein-doo not flushing correctly?

Running lein node test once (but also happens in auto watch-mode).

10 items map - OK

(deftest foo-test
  (is (= 'foo
         (reduce #(assoc %1 %2 inc) {} (range 10)))))
@pithyless
pithyless / latency.markdown
Created April 6, 2016 10:12 — forked from iaintshine/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@pithyless
pithyless / core.cljs
Last active August 29, 2015 14:20 — forked from luxbock/core.cljs
(ns freactive-datascript.core
(:require [datascript :as d]
[datascript.core :as dc]
[clojure.data :as data]
[freactive.core :as f :refer [IReactive
*invalidate-rx*
*trace-capture*]]))
;;; Playground ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;