Skip to content

Instantly share code, notes, and snippets.

View littleli's full-sized avatar

Aleš Najmann littleli

View GitHub Profile
@vdikan
vdikan / vega-serv.bb
Last active September 13, 2022 10:34
Single-script Vega-Lite plotter made with Babashka (Clojure). A remix of wee-httpd.
#!/usr/bin/env bb
(ns vega-serv)
(import (java.net ServerSocket))
(require '[clojure.string :as string]
'[clojure.java.io :as io]
'[cheshire.core :as json]
'[clojure.tools.cli :refer [parse-opts]])
@jackrusher
jackrusher / trinity.js
Created March 29, 2021 09:23
A fast, minimal JS triple store implementation in ~70 lines of code
// three indices to efficiently support all lookups
function createDB() {
return {eav: new Map(),
ave: new Map(),
vea: new Map()};
}
function addToIndex(xs, x, y, z, triple) {
let ys = xs.get(x);
if(ys == undefined) {
;; 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"}}})
@borkdude
borkdude / SetEnv.java
Last active May 21, 2021 08:16
C's setenv called from Java in a native image
import org.graalvm.nativeimage.c.function.CFunction;
import org.graalvm.nativeimage.c.function.CFunction.Transition;
import org.graalvm.nativeimage.c.function.CLibrary;
import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.type.CCharPointer;
import com.oracle.svm.core.c.ProjectHeaderFile;
import org.graalvm.nativeimage.c.type.CTypeConversion;
import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder;
import java.util.List;
import java.util.Collections;
@jackrusher
jackrusher / webdav.clj
Last active June 18, 2025 20:13
A minimal webdav server/synthetic filesystem that works with JVM Clojure and babashka. See comments for instructions!
(ns webdav
(:require [clojure.string :as str]
[clojure.data.xml :as xml]
[org.httpkit.server :as hk-server]))
;; add the XML namespace that we'll use later
(xml/alias-uri 'd "DAV:")
(defn dissoc-in
"Should be in the standard library..."
@trvswgnr
trvswgnr / compress_video
Last active February 5, 2025 20:37
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in