Skip to content

Instantly share code, notes, and snippets.

View holyjak's full-sized avatar
💓
Loving Clojure

Jakub Holý holyjak

💓
Loving Clojure
View GitHub Profile
@holyjak
holyjak / klipse-issue.html
Last active December 17, 2019 15:52
Klipse - #355
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns#">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-97603551-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
@holyjak
holyjak / clojure-5269077379395073972.edn
Created December 11, 2019 12:38
nrepl over drawbridge client error
{:clojure.main/message "Execution error (ClassCastException) at clj-http.client/parse-url (client.clj:175).\nclass java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')\n",
:clojure.main/triage {:clojure.error/class java.lang.ClassCastException,
:clojure.error/line 175,
:clojure.error/cause "class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')",
:clojure.error/symbol clj-http.client/parse-url,
:clojure.error/source "client.clj",
:clojure.error/phase :execution},
:clojure.main/trace {:via [{:type java.lang.ClassCastException, :message "class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')",
@holyjak
holyjak / blog.scss
Last active November 20, 2023 15:35
Cryogen customization: autolink headings etc.
#post a.anchor, #custom-page a.anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
}
@holyjak
holyjak / clojure.spec.alpha.clj
Last active October 2, 2019 16:30
Override clojure.spec.alpha/gensub for friendly exceptions for failed such-that - see https://clojure.atlassian.net/browse/CLJ-2097
;; 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))]
(gfn))
@holyjak
holyjak / CloudWatchMetricsExportAutoConfiguration4SpringBoot1_5.groovy
Created September 13, 2019 08:48
CloudWatchMetricsExportAutoConfiguration for Spring Boot 1.5 (not supported out of the box)
package myapp.spring.micrometer.cloudwatch;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsync;
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsyncClient;
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
holyjak / Beginner-friendly Clojure.md
Last active May 10, 2019 21:44
Beginner-friendly Clojure

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 09:46
Kubernetes resources on AWS EKS having the "no available volume zone" problem

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 April 10, 2019 20:05
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.

Groovy

@holyjak
holyjak / blog.md
Last active February 12, 2019 13:16
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)
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 December 14, 2018 11:50
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 ... .

Results:

System: openjdk 11.0.1 2018-10-16

  1. (.setConnectTimeout 1) => java.net.SocketTimeoutException: connect timed out