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
holyjak / Beginner-friendly Clojure.md
Last active May 10, 2019
Beginner-friendly Clojure
View Beginner-friendly Clojure.md

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
holyjak / Issue-AWS_EKS_No_avail_zone.md
Last active May 2, 2019
Kubernetes resources on AWS EKS having the "no available volume zone" problem
View Issue-AWS_EKS_No_avail_zone.md

Resources for https://stackoverflow.com/questions/54439356/node-has-no-available-volume-zone-in-aws-eks

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
holyjak / blog-clj-data-over-java-types.md
Last active Apr 10, 2019
Benefits of Clojure's use of generic data structures over Java's object graphs
View blog-clj-data-over-java-types.md

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.

Groovy

@holyjak
holyjak / blog.md
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)
View blog.md
title tags
It will only take one hour... (On why programmers suck at estimating and the perils of software development)
development
effectivity
process

"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
holyjak / README.md
Last active Dec 14, 2018
Java: Simulating various connection problems with Toxiproxy
View README.md

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 ... .

Results:

System: openjdk 11.0.1 2018-10-16

  1. (.setConnectTimeout 1) => java.net.SocketTimeoutException: connect timed out
@holyjak
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
(:require
[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}"
[ds]
@holyjak
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
(:require
[incanter.core :refer :all]
[incanter.charts :refer :all]
[clj-charting.usage-chart-preparation :refer [read-usage-data moving-window-means]])
(:import
[org.jfree.chart JFreeChart]
[org.jfree.chart.plot XYPlot]
(org.jfree.chart.axis ValueAxis NumberAxis NumberTickUnit TickUnitSource TickUnit)
(java.text NumberFormat DecimalFormat FieldPosition)))
@holyjak
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
(:require
[incanter.core :refer :all]
[incanter.stats :as s]
[incanter.io :as io]))
(defn- resolve-unit-suffix
"Replace values such as 333k, 800m, 1.2g with the corresponding value in bytes"
[val-suffixed]
(if-let [[_ val unit] (and
@holyjak
holyjak / README.md
Created Nov 1, 2018
Incanter: show bytes as kB/MB/GB on an axis
View README.md

Modify an axis to display the number of bytes with scale suffixes such as kB, MB, GB, and display more reader-friendly ticks such as "500MB" instead of "496M".

The trick is to supply a custom "tick source" that tells JFreeChart what ticks it should prefer. I cheat a little and reuse the existing IntegerTickUnitSource, optimally I would rewrite it to work with multiples of 2 rather than 10.

@holyjak
holyjak / async-context.js
Created Nov 1, 2018
Async hooks on Nodejs
View async-context.js
const asyncHooks = require('async_hooks'); // Node 8.9+
const querystring = require('querystring');
const crypto = require("crypto");
const context = {};
function createHooks() {
function init(asyncId, type, triggerId, resource) {
// if (context[triggerId]) {
// context[asyncId] = context[triggerId];
You can’t perform that action at this time.