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 wrap-highlighted | |
"Return a vector of string parts where highlighted runs are replaced with (f highlighted-string)." | |
[f s] | |
(->> (re-seq #"<em>(.+?)</em>|.+?(?=<em>|$)" s) | |
(map (fn [[all highlighted]] | |
(if (nil? highlighted) | |
all | |
(f highlighted)))))) |
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
(defmacro cond-assoc-from | |
"Using a source ILookup (map, vector, etc) and a target IAssoc (map), for each | |
clause bind the value of source at given source-key to a binding expression | |
and assoc the target-expression (evaluated with bindings) to the target under target-key. | |
If the source-key's value is nil, skip the clause. Example: | |
(cond-assoc-from {:a [1 2]} {} | |
[a-1 a-2] :a :A (inc a-2) | |
b :b :B (inc b)) | |
;=> {:A 3}" |
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 '[java.util.concurrent.atomic AtomicInteger]) | |
(set! *unchecked-math* :warn-on-boxed) | |
(def ^AtomicInteger counter (AtomicInteger.)) | |
(defn next-tempid-idx [^AtomicInteger i] | |
(unchecked-subtract -1000000 (bit-and (.getAndIncrement i) 0x7fffffff))) | |
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
;; Result of bootstrap-txes function above under datomic 0.9.5173 | |
;; Bootstrap transactions are 0, | |
;; More bootstrap transactions or datoms may be added in later datomic versions. | |
;; First non-bootstrap transaction is always T >= 1000. | |
;; Format is [[t [[e a v tx added] ...] ...] ...] | |
[[0 | |
[[0 10 :db.part/db 13194139533312 true] | |
[1 10 :db/add 13194139533312 true] | |
[2 10 :db/retract 13194139533312 true] |
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>xforms dependency algorithm</title> | |
</head> | |
<body> | |
<div> | |
<form action="" method="post" accept-charset="utf-8"> | |
<ol style="list-style-type:lower-latin"> |
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 favila.datomic-util.restore-datoms | |
"A \"manual\" datomic database restore. | |
Writes raw datoms (stored in a stream written by d/datoms) to an empty database. | |
Useful for memory databases: you can write out all the datoms in it, then read | |
them into another database. (Note mem dbs have no log or retractions)." | |
(:require [datomic.api :as d] | |
[clojure.edn :as edn])) | |
(defrecord datom [e a v tx added?]) |
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
#!/bin/sh | |
# Generate datomic transactor properties file and command line arguments. | |
# Specific scenario: using Google Mysql Cloud storage with SSL and client | |
# authentication. | |
OUTFILE='transactor.properties' | |
#TRANSACTOR_ARGS_FILE='transactor-arguments.txt' |
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
#!/bin/sh | |
# A netcat-based logging http server for debugging. | |
# | |
# Writes raw http requests to individual files and replies with a 204. | |
PORT=${1-"8085"} | |
OUTFILEPREFIX=${2-"request"} | |
REPLY='HTTP/1.1 204 NO CONTENT\r\nconnection: close\r\n\r\n' | |
OUTFILE='' | |
cleanup () { |
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
-- 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 |
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
;; These colors are colorblind-safe | |
(def visual-uuid-colors #js ["#f0e442" "#0072b2" "#d55e00" "#cc79a7"]) | |
(def visual-uuid-shapes "▄▌▀▐" #_"◢◣◤◥" #_" █▖▗▘▝▚▞") | |
(defcomponent VisualUUID | |
"Draw an iconographic representation of a uuid meant for easy visual | |
recognition and comparision. | |
Every 4 bits becomes a color+shape; full uuid is an 8x4 grid of shapes." | |
[uuid] |