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 / catching-transduce.clj
Created July 10, 2020 17:57
catching-transduce and a mysterious freeze
;; catching-transduce - works most of the time but blocks forever in some case(s)
;; If I interrupt it, it is at line 26, i.e. inside `(a/<!! errors-ch)`
;; inside core.async ... CountDownLatch.await
(with-test
(defn catching-transduce
"Similar to `core.async/transduce` but returns the reduced value and
captures 'anomalies' (i.e. exceptions sent as data) in the `chan` data and
captures exceptions in `xf` and `f`, stopping at the first one.
Returns the result or throws if there was any anomaly / exception."
@holyjak
holyjak / fulcro-rad-report-needs.md
Last active March 24, 2020 16:07
Fulcro-RAD report needs

I am making a PoC of an app with a number of linked "reports" (mostly master-detail). Some of the features I will need:

  • Ability to sort the tables by one or multiple columns
  • Ability to filter the tables (e.g. "only show people from Norway")
  • Pagination
  • Eventually allow the user to hide some columns (and remember this for the user, e.g. in a cookie / localStorage / server)

As far as I know, fulcro-rad does not support that yet so here are some thoughts about how this could be configured.

@holyjak
holyjak / X Fulcro mystery 2.md
Last active February 10, 2020 09:48
Fulcro mystery 2 - why isn't the initial state normalized in the DB?

Solution

L14 is wrong, it should have been wrapped in {..} and thus a join: :query [{:people [(comp/get-query Person)]}]

@holyjak
holyjak / X Fulcro Mystery 1.md
Last active February 10, 2020 09:47
Fulcro mystery - why is initial state not normalized in the DB?

Solution

There are 2 problems:

  1. L14 should have been {:query [:people (comp/get-query Person)]
  2. L15 mixes the template and lambda forms; it should have been either
:initial-state (fn [_] {:people [(comp/get-initial-state Person {:id 0 :name "Sally" :city "Nowhere" :state "GA"})
 (comp/get-initial-state Person {:id 1 :name "Tom" :city "There" :state "OH"})]}
@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 / 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