Skip to content

Instantly share code, notes, and snippets.

Loving Clojure

Jakub Holy holyjak

Loving Clojure
Block or report user

Report or block holyjak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
holyjak / clojure.spec.alpha.clj
Last active Oct 2, 2019
Override clojure.spec.alpha/gensub for friendly exceptions for failed such-that - see
View clojure.spec.alpha.clj
;; Normally the exception thrown by such-that does not point to the failed spec, which makes it useless
;; Eval this to override it and include `path` to the spec (and `form`, not sure which better)
(in-ns 'clojure.spec.alpha)
(defn- gensub
[spec overrides path rmap form]
;;(prn {:spec spec :over overrides :path path :form form})
(let [spec (specize spec)]
(if-let [g (c/or (when-let [gfn (c/or (get overrides (c/or (spec-name spec) spec))
(get overrides path))]
holyjak / CloudWatchMetricsExportAutoConfiguration4SpringBoot1_5.groovy
Created Sep 13, 2019
CloudWatchMetricsExportAutoConfiguration for Spring Boot 1.5 (not supported out of the box)
View CloudWatchMetricsExportAutoConfiguration4SpringBoot1_5.groovy
package myapp.spring.micrometer.cloudwatch;
import com.amazonaws.auth.AWSCredentialsProvider;
import io.micrometer.cloudwatch.CloudWatchConfig;
import io.micrometer.cloudwatch.CloudWatchMeterRegistry;
import io.micrometer.core.instrument.Clock;
import io.micrometer.spring.autoconfigure.CompositeMeterRegistryAutoConfiguration;
import io.micrometer.spring.autoconfigure.MetricsAutoConfiguration;
holyjak / Beginner-friendly
Last active May 10, 2019
Beginner-friendly Clojure
View Beginner-friendly

Setup optimized for beginner friendliness.

BEWARE: Too many extra libraries can eventually cause problems of their own, with dependency conflicts etc.

Editor with REPL integration


  • Use Parinfer
holyjak /
Last active May 2, 2019
Kubernetes resources on AWS EKS having the "no available volume zone" problem

Resources for

The eks-pod-no-avail-volume-zone.yml file is nearly the same as the one we use in prod, only difference is hostname and "prod" / "stage" so this file is most likely not the source of the problem.

The storage is defined and AWS console shows I do have a gp2 volume attached to each worker node.

One difference between stage (broken) and prod (working): the former runs Kubernetes 1.11, the latter 1.10.

Cause & Solution

holyjak /
Last active Apr 10, 2019
Benefits of Clojure's use of generic data structures over Java's object graphs

WIP - collecting examples that show the benefit of using generic data structures over types and object graphs

Case 1

Task: Combine data usage amounts for individual subscribers together. If a subscriber appears multiple times, their amounts should be summed. SubscribersWithUsage.subscriberUsage is essentially a map of <user id> -> (map of <category> -> (map of <amount name> -> amount)). Most subscribers appear only once in the input but some do multiple times, in which case we sum all their usage amounts.


holyjak /
Last active Feb 12, 2019
Blog DRAFT: It will only take one hour... (On why programmers suck at estimating and the perils of software development) (WIP)
title tags
It will only take one hour... (On why programmers suck at estimating and the perils of software development)

"It will only take about an hour," I said to her. Two days later, a pull request awaits review. Where has all that time gone? What are the sources of delay in software development and how can we make it faster?

Our story

(If you are in a hurry and not interested in the details, feel free to jump to Obstacles and speed-ups)

holyjak /
Last active Dec 14, 2018
Java: Simulating various connection problems with Toxiproxy

Java: Simulating various connection problems with Toxiproxy

Simulate various connection issues with Toxiproxy and Java's HttpURLConnection to see what kind of errors get produced: connect timed out vs. read timed out vs. connection refused ... .


System: openjdk 11.0.1 2018-10-16

  1. (.setConnectTimeout 1) => connect timed out
holyjak / oz.clj
Created Nov 4, 2018
Comparison of gnuplot, Incanter, oz/vega-lite for plotting usage data - Oz
View oz.clj
(ns clj-charting.oz
[oz.core :as oz]
[incanter.core :refer :all]
[clj-charting.usage-chart-preparation :refer [read-usage-data moving-window-means]]))
(defn dataset->map-list
"Incanter dataset into a list of maps like
{\"0\" 1541065398391, \"1\" 446693376, \"2\" 99.9, \"cpu_mean\" 89}"
holyjak / incanter.clj
Last active Nov 4, 2018
Comparison of gnuplot, Incanter, oz/vega-lite for plotting usage data - Incanter
View incanter.clj
(ns clj-charting.incanter
[incanter.core :refer :all]
[incanter.charts :refer :all]
[clj-charting.usage-chart-preparation :refer [read-usage-data moving-window-means]])
[org.jfree.chart JFreeChart]
[org.jfree.chart.plot XYPlot]
(org.jfree.chart.axis ValueAxis NumberAxis NumberTickUnit TickUnitSource TickUnit)
(java.text NumberFormat DecimalFormat FieldPosition)))
holyjak / usage-chart-preparation.clj
Last active Nov 4, 2018
Incanter - prepare usage data
View usage-chart-preparation.clj
(ns clj-charting.usage-chart-preparation
[incanter.core :refer :all]
[incanter.stats :as s]
[ :as io]))
(defn- resolve-unit-suffix
"Replace values such as 333k, 800m, 1.2g with the corresponding value in bytes"
(if-let [[_ val unit] (and
You can’t perform that action at this time.