Skip to content

Instantly share code, notes, and snippets.

View littleli's full-sized avatar

Aleš Najmann littleli

View GitHub Profile
@littleli
littleli / prefix_tree.clj
Created September 22, 2025 12:34 — forked from rahulpilani/prefix_tree.clj
Prefix tree creation and traversal in Clojure
(ns prefix-tree)
;Record representing a node in the prefix tree.
;strings: The set of strings that the present node represents
;edges: Map representing edges emanating from this node.
;The key being the first letter of the label and the value being the label and the actual node being pointed to."
(defrecord Node [strings edges])
(defn shorter-string [a b]
"Return the shorter string of the two being passed in."
@littleli
littleli / youtube.md
Created July 25, 2025 08:28 — forked from bitsurgeon/youtube.md
Markdown cheatsheet for YouTube

Embed YouTube Video in Markdown File

  1. Markdown style
[![Watch the video](https://img.youtube.com/vi/nTQUwghvy5Q/default.jpg)](https://youtu.be/nTQUwghvy5Q)
  1. HTML style
<a href="http://www.youtube.com/watch?feature=player_embedded&v=nTQUwghvy5Q" target="_blank">
@littleli
littleli / Shapes.java
Created July 31, 2024 19:33
ADT in Java
public sealed interface Shape permits Shape.Rectangle, Shape.Square, Shape.Circle {
record Circle(double radius) implements Shape {}
record Rectangle(double length, double width) implements Shape {}
record Square(double side) implements Shape {}
}
public class Main {
public static double calculateArea(Shape shape) {
return switch (shape) {
@littleli
littleli / webdav.clj
Created July 21, 2023 14:59 — forked from jackrusher/webdav.clj
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..."
@littleli
littleli / AAA-README.md
Created February 19, 2023 15:27 — forked from jackrusher/AAA-README.md
Clojure + FUSE

Meld

A minimal example of creating a (mostly) working FUSE filesystem using Clojure. NOTE: I have only tested this with OSX, and it assumes you have already installed libfuse.

Trying it out

Create an empty directory at /tmp/meld to serve as your mount point, put these files in a directory called meld, then:

@littleli
littleli / radix_trie.clj
Created July 5, 2022 21:31 — forked from samuelclay/radix_trie.clj
A Radix Trie (aka PATRICIA trie) implemented in Clojure. For my JavaScript implementation, see this interactive JS fiddle: http://jsfiddle.net/jCYAw/
(ns radix
(:require [clojure.string :as string]))
(use 'clojure.java.io)
(use 'clojure.pprint)
(println "Loading names... ")
(time (def names
(with-open
[rdr (reader
"/usr/share/dict/ProperNames")]
@littleli
littleli / shell
Created June 24, 2022 16:16
clj -Ttools install io.github.babashka/http-server '{:git/tag "v0.1.4"}' :as serve
~ $ clj -Ttools install io.github.babashka/http-server '{:git/tag "v0.1.4"}' :as serve
Checking out: https://github.com/clojure/tools.tools.git at 9c5baa56cff02de98737a71d4dab098b268cd68b
Error building classpath. Failed to read artifact descriptor for org.clojure:tools.deps.alpha:jar:0.14.1212
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:tools.deps.alpha:jar:0.14.1212
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:259)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:175)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:255)
at clojure.tools.deps.alpha.extensions.maven$read_descriptor.invokeStatic(maven.clj:115)
at clojure.tools.deps.alpha.extensions.maven$fn__1137.invokeStatic(maven.clj:143)
@littleli
littleli / example.cljs
Created April 8, 2022 11:36
Bitcoinjs-lib example
(ns example
(:require ["bitcoinjs-lib$default" :as btc]
["tiny-secp256k1" :as secp]
["ecpair$default" :as ecpair]
["axios$default" :as axios]
[promesa.core :as p]
[cljs-bean.core :refer [->clj]]))
(def ecpf (ecpair/ECPairFactory. secp))
@echo off
set ARGS=%*
bb.exe -f gh_releases.clj %ARGS%
@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*))]