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 / pathom3_lab_notes.adoc
Last active April 13, 2024 07:25
Pathom3 + Fulcro Lab Notes - experiences and tips from working with Pathom 3 with Fulcro

Various, unsorted notes from using and struggling with Pathom 3 with Fulcro.

Troubleshooting P3/F

Troubleshooting auto-generated Fulcro RAD id resolvers in Pathom 3

When something doesn’t work, I try to simplify it as much as possible. Often it starts working at some point. Then I try to find the exact point where it starts/stop working by bringing the broken and working alternatives closer together. And this is exactly what I did when my auto-generated RAD id-resolver did not return the expected data. It might be useful to know the steps along this path for any future troubleshooting.

This problem has two dimensions - the parser and the resolver. Here I move mostly along the parser dimension, while in the end I discovered the problem was with the resolver. Still, it is a valuable knowledge.

@holyjak
holyjak / oidc_client.clj
Last active January 31, 2024 09:43
A stateful CLI tool for getting access token from an OIDC provider
#!/usr/bin/env bb
(ns oidc-client
"Get end-user access token from an OIDC provider, caching the access/refresh token in an encrypted file. Code in https://babashka.org
Usage:
/path/to/oidc_client.clj
When there are no cached, valid tokens, it will open a browser with the OIDC provider login URL and start a HTTPS-enabled
callback server on localhost. Make sure that the resulting redirect_uri is registered with your provider.
@holyjak
holyjak / plot-usage.gp
Last active January 30, 2024 22:28
Gnuplot script to plot memory, CPU usage of a process from `top`
#!/usr/bin/env -S gnuplot --persist -c
# Plot memory and CPU usage over time. Usage:
# usage-plot.gp <input file> [<output .png file>]
# where the input file has the columns `<unix time> <memory, with m/g suffix> <% cpu>`
# To create the input file, see https://gist.github.com/jakubholynet/931a3441982c833f5f8fcdcf54d05c91
# Arguments:
infile=ARG1
outfile=ARG2
set term x11
@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 / s3_multipart_upload.py
Last active October 24, 2023 21:32 — forked from teasherm/s3_multipart_upload.py
boto3 S3 Multipart Upload with the ability to resume the upload after a failure
#!/usr/bin/env python3
# See https://gist.github.com/teasherm/bb73f21ed2f3b46bc1c2ca48ec2c1cf5
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB
@holyjak
holyjak / about-sci-playground-demo-gist.md
Last active October 3, 2023 07:57
SCI Playground demo gist

A sample gist that can be loaded into the SCI Playground.

DON'T DELETE! - referred to by the playground.

;; Based on https://github.com/borkdude/fly_io_clojure
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'cz.holyjak.rohan-erp/app)
(def version "0.0.1")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
@holyjak
holyjak / fulcro-rad-notes.md
Last active August 2, 2023 16:45
Fulcro RAD - assorted notes

Unsorted notes on Fulcro RAD.

Reports

Displaying to-one :ref attributes

Tony advises:

There are two primary ways to do this. If it is a true to one relationship, then you can simply make a resolver from person ID to address ID in pathom and then you can just include address things as columns. The other option, which works for any cardinality, is to use the report option ro/column-EQL and write a join that pulls the information you want to format in the column, and then supply a column formatter to do the formatting of the nested data.

@holyjak
holyjak / Fulcro_Field_Notes.adoc
Last active July 26, 2023 17:55
Assorted notes from learning and experimenting with Fulcro [WIP]
@holyjak
holyjak / http-server.bb
Last active March 19, 2023 04:36
Babashka HTTP server for serving static files, similar to `python -m http.server` but more flexible :)
#!/usr/bin/env bb
#_" -*- mode: clojure; -*-"
;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj
(ns http-server
(:require [babashka.fs :as fs]
[clojure.java.browse :as browse]
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[org.httpkit.server :as server]