Skip to content

Instantly share code, notes, and snippets.

View helins's full-sized avatar

Adam Helinski helins

View GitHub Profile
@helins
helins / gist:3d1fcb280e2c62df067cd8dac0fb8e3e
Created December 22, 2022 12:47
BB Vs Clojure - `-Sdescribe`
$ clojure -Sdescribe
{:version "1.11.1.1149"
:config-files ["/nix/store/w0fqc8djks9is9ar13r23g2frdld70c6-clojure-1.11.1.1149/deps.edn" "/var/lib/gitlab-runner/.clojure/deps.edn" "deps.edn" ]
:config-user "/var/lib/gitlab-runner/.clojure/deps.edn"
:config-project "deps.edn"
:install-dir "/nix/store/w0fqc8djks9is9ar13r23g2frdld70c6-clojure-1.11.1.1149"
:config-dir "/var/lib/gitlab-runner/.clojure"
:cache-dir ".cpcache"
:force false
:repro false
@helins
helins / circle-ci_babashka.yaml
Last active June 5, 2021 14:47
Command for installing and caching Babashka on CircleCI
commands:
install_bb:
description: "Install Babashka"
parameters:
version:
default: "0.4.4"
type: string
steps:
- restore_cache:
keys:
ava.lang.Error: IO exception from Etch
at etch.EtchStore.refForHash(EtchStore.java:88)
at etch.EtchStore.storeRef(EtchStore.java:118)
at etch.EtchStore.lambda$storeRef$0(EtchStore.java:128)
at convex.core.data.SignedData.updateRefs(SignedData.java:224)
at convex.core.data.SignedData.updateRefs(SignedData.java:45)
at etch.EtchStore.storeRef(EtchStore.java:133)
at etch.EtchStore.storeTopRef(EtchStore.java:99)
at convex.core.data.ACell.createPersisted(ACell.java:431)
at convex.core.data.ACell.createPersisted(ACell.java:444)
;; Decompiling and pretty printing a WASM program such as "my_program.wasm":
;;
;; $ bb babashka_wasm.clj my_program.wasm
;;
;; Following WASM specs 1.1
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {io.helins/wasm {:mvn/version "0.0.0-alpha2"}}})
@helins
helins / binf_bb_mmap.clj
Created April 14, 2021 19:12
BB 0.3.5-SNAPSHOT - Memory mapping
;; Test should fail because it requires `java.nio.DirectByteBufferR`
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {io.helins/binf {:mvn/version "1.0.0-beta1"}}})
(ns helins.binf.example.mmap-file
"Using BinF for writing and reading to a memory-mapped file on the JVM.
BinF protocols are implemented for ByteBuffer, parent of MappedByteBuffer."
@helins
helins / bb_task_interceptors.edn
Created March 17, 2021 08:30
Interceptor-like twist for a Babashka task runner
;; For instance, build tasks produce garbage and an interceptor-like interface is a great match
;;
{:tasks {:build-something {:enter {:babashka/process ["bash" "-c" "touch file.txt"]}
:leave {:babashka/process ["bash" "-c" "rm file.txt"]}}}}
;; Clearer than splitting the task in two
;;
{:tasks {:create-file {:babashka/process ["bash" "-c" "touch file.txt"]}
:delete-file {:babashka/process ["bash" "-c" "rm file.txt"]}
:build-something {:babashka/args [:do :create-file
@helins
helins / gist:ffbb4e46eaf5b4adbfc960952ac577e9
Created March 2, 2021 12:14
Segfaulting the JVM using `wasmer-java`
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fe1df8c4f91, pid=27960, tid=27980
#
# JRE version: OpenJDK Runtime Environment (Zulu11.39+15-CA) (11.0.7+10) (build 11.0.7+10-LTS)
# Java VM: OpenJDK 64-Bit Server VM (11.0.7+10-LTS, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [wasmer_jni2309101336629026624.lib+0x5ef91] _$LT$hashbrown..raw..RawTable$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hfb03333fcdd0f7eb+0x31
#
(ns hooks.fulcro
""
{:author "Adam Helins"}
(:require [clj-kondo.hooks-api :as hook]))
(defn defmutation
[{:keys [node]}]
(let [[_call
sym
& arg+] (:children node)
(defn split-with
"Semi lazy alternative to `split-with`"
[pred coll]
(let [acc (transient [])]
(loop [[v
:as vs] coll]
(if (seq vs)