Skip to content

Instantly share code, notes, and snippets.

View .gitconfig
[diff "clj"]
xfuncname = "^(\\((def|ns)([^\\[])*).*$"
@cddr
cddr / ns.clj
Created Apr 16, 2020
Enumerate parameters permitted by some clojure spec
View ns.clj
(ns scratch.ns
(:require
[clojure.spec.alpha :as s]))
(s/def ::foo string?)
(s/def ::bar string?)
(s/def ::baz string?)
(s/def ::yolo (s/keys :req-un [::foo ::bar]
:opt-un [::baz]))
View mock-avro-mvp.clj
(ns mock-avro-example
(:require
[clojure.data.json :as json]
[jackdaw.streams :as k]
[jackdaw.serdes.avro :as avro]
[jackddaw.serdes.avro.schema-registry :as reg]
[jackdaw.test :as jdt]))
(def foo-schema
{:type :record
View gist:b6f0c566c8aa6dec6a8851368a385a33
Saturday 31 August 2019
Dear Stephen Kerr,
Can you please just look at the devastation and anxiety you are causing thousands of innocent people around the UK. How can you sleep at night knowing that you have caused this? And for what?
https://uk.reuters.com/article/uk-britain-eu-immigration-insight/where-do-i-go-eu-citizens-face-legal-limbo-after-decades-in-britain-idUKKCN1VK0CV
I know first-hand how much it costs to move overseas, not only financially but emotionally and physically. I am beyond rage at this point on behalf of the friends and colleagues who have come to this country to improve our health service, build our houses, cook our food, develop our IT systems and so on. Each day I read stories about the impossible situation we have put these people in. They would like to stay here but they simply do not know whether they will be allowed.
View threaded-style.clj
(def client-impl
{:alter-topics* (fn [this topics]
(d/future
(->> (.alterConfigs this topics)
.all deref)))
:create-topics* (fn [this topics]
(d/future
(->> (.createTopics this topics)
.all deref)))
:delete-topics* (fn [this topics]
View avro2ddl.clj
(ns cddr.avro2ddl
(:require
[clojure.string :as string]
[clojure.java.io :as io]
[clojure.data.json :as json])
(:gen-class))
(def home (System/getProperty "user.home"))
(def loan (-> (format "%s/Projects/avro-schemas/schemas/loan-3.json"
@cddr
cddr / schema-for.sh
Last active Dec 9, 2018
Show the schema loaded by the app contained in the specified docker image
View schema-for.sh
#!/bin/bash
function cleanup () {
docker rm -f $pg >/dev/null
}
trap cleanup EXIT
PARAMS=""
while (( "$#" )); do
@cddr
cddr / startup.log
Last active Oct 10, 2017
clojure startup times
View startup.log
# traditional way to run program via lein
$ time lein run -m clojure.main -e '(println "yolo")'
yolo
real 0m6.678s
user 0m9.845s
sys 0m0.961s
# new clojure script (supported by tools.deps.alpha)
# in this test, we force clojure to compute the classpath before running the script
@cddr
cddr / schema.txt
Last active Feb 27, 2017
silly schema
View schema.txt
tweet-published
id
user-id
msg
unique-key: id
partition-key: id
record-key: ?
user-mentioned
id
View puma.clj
(defn holdings-manager
"Returns a collection of kstreams, one for each different way in which
loan ownership state may be updated"
[puma-events]
(let [ownership-store (k/store "loan-ownership")]
(-> (k/kstream puma-events)
(k/transform (update-ownership ownership-store))
(k/branch [trade-result?
repayment-result?]))])