Skip to content

Instantly share code, notes, and snippets.

View littleli's full-sized avatar

Aleš Najmann littleli

View GitHub Profile
@littleli
littleli / spike-day-02-03-20.md
Created March 23, 2020 21:32 — forked from cldwalker/spike-day-02-03-20.md
GraalVM dive in Clojure at work

Spike

I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.

GraalVM Build Tools

@littleli
littleli / strdist.clj
Last active June 6, 2020 23:42
String distance function
(ns strdist
(:require [clojure.core.match :refer [match]]
[clojure.string :as str]))
(defn -distance
[s1 s2]
(match [s1 s2]
[nil _] (.length s2)
[_ nil] (.length s1)
[([l & ls] :seq) ([r & rs] :seq)] (min (+ (if (= l r) 0 1) (-distance ls rs))
@littleli
littleli / output.calva-repl
Last active October 6, 2020 15:56
Calva error reporting
clj::littleli.clj-dremel=>
; Syntax error compiling deftype* at (src/littleli/clj_dremel.clj:50:1).
; Unable to resolve symbol: IDeref in this context
[{:file "Compiler.java" :line 7115 :method "analyzeSeq" :flags [:tooling :java]}
{:file "Compiler.java" :line 6789 :method "analyze" :flags [:tooling :java]}
{:file "Compiler.java" :line 6745 :method "analyze" :flags [:dup :tooling :java]}
{:file "Compiler.java" :line 6118 :method "parse" :flags [:tooling :java]}
...]
@littleli
littleli / SoABenchmark.java
Created January 18, 2021 21:16 — forked from twolfe18/SoABenchmark.java
Does SoA (structure of arrays) beat AoS (array of structures) for Java?
package sandbox;
import java.util.Arrays;
import java.util.Random;
public class SoABenchmark {
public static Random rand = new Random(9001);
public static int NUM_LABELS = 10;
public static Struct[] aos;
@littleli
littleli / paillier.clj
Last active July 20, 2021 11:49
The implementation of Paillier cryptosystem for Clojure and Babashka
(ns fun.clojure.paillier
(:import [java.math BigInteger]
[java.security SecureRandom]
[java.nio.charset StandardCharsets]))
(defn- random-number! [end]
(let [start (BigInteger/valueOf 2)
interval (.subtract end start)
i (BigInteger. (.bitCount interval) (SecureRandom.))]
(.add start i)))
@littleli
littleli / vlang-install.md
Created September 21, 2021 12:03
Install V lang on Windows 10 using scoop installer

There is a way how to install V lang on Windows using Scoop installer. I prepared the manifest myself and put it to bucket maintained by me.

scoop bucket add scoop-littleli https://github.com/littleli/Scoop-littleli.git
scoop install vlang

There is also an option to bootstrap V lang using llvm-mingw which contains stable Clang. I successfully recompiled V lang with it.

@littleli
littleli / hello.clj
Last active September 27, 2021 12:50
Say hello
(println "Hello world from Babashka")
@littleli
littleli / gh_releases.clj
Created September 27, 2021 22:09
List github releases
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {borkdude/gh-artifacts
{:git/url "https://github.com/borkdude/gh-release-artifact"
:git/sha "2f8898d84126a4e922c490f8614211a8b0cf67cd"}}})
(assert (System/getenv "GITHUB_TOKEN") "GITHUB_TOKEN env var not set")
(require '[borkdude.gh-release-artifact :as gh])
(def args
(into {}
(for [[arg-name arg-val] (partition 2 (rest *command-line-args*))]
@echo off
set ARGS=%*
bb.exe -f gh_releases.clj %ARGS%