Skip to content

Instantly share code, notes, and snippets.

@pithyless
pithyless / i18n-impl.cljs
Last active Jun 24, 2021 — forked from isaksky/i18n-impl.cljs
Handling translations in ClojureScript
View i18n-impl.cljs
(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)
View 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 Sep 1, 2021
A CLJC version of potemkin/import-vars
View import-vars.cljc
(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 Apr 6, 2018
Pedestal sync vs async error-handling
View README.md

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 Apr 3, 2018 — forked from favila/datomic-mysql-bootstrap.sql
Better MySQL bootstrap setup for datomic's datomic_kvs table
View datomic-mysql-bootstrap.sql
-- 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
View background.clj
(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 Jan 4, 2018
Test executable docstrings à la Python's doctest.
View doctest.clj
(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 Nov 11, 2016
CLJS lein-doo not flushing correctly?
View doo-bug.md

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 Apr 6, 2016 — forked from iaintshine/latency.markdown
Latency numbers every programmer should know
View latency.markdown

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

View 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;