Skip to content

Instantly share code, notes, and snippets.

@bsless
bsless / yt-mpv.el
Created February 5, 2019 10:58
Opening YouTube Links In MPV from Emacs
(defun mpv-play-url (url &rest args)
""
(interactive)
(start-process "mpv" nil "mpv" url))
(setq browse-url-browser-function
(quote
(("youtu\\.?be" . mpv-play-url)
("." . eww-browse-url))))
@bsless
bsless / vpn-setup.sh
Last active February 16, 2026 18:19
Set up a bunch of OpenVPN connections using nmcli with username and password
#!/usr/bin/env bash
USERNAME="$1"
PASS="$2"
for f in *.ovpn
do
name=`basename -s .ovpn $f`;
nmcli connection import type openvpn file $f
nmcli connection modify "${name}" +vpn.data connection-type=password-tls
@bsless
bsless / lines_reducible.clj
Created October 13, 2025 11:51
Create a reducible over a file in JVM Clojure
(defn lines-reducible
[f]
(let [fr (java.io.FileReader. f)
br (java.io.BufferedReader. fr)]
(reify clojure.lang.IReduceInit
(reduce [_ rf init]
(loop [init init]
(let [line (java.io.BufferedReader/.readLine br)]
(if (nil? line)
init
@bsless
bsless / ex.clj
Created February 3, 2024 10:55
Compare and contrast unclebob/functor ur example and different implementation tradeoffs
;; Baseline
(defn encrypt-if-direct-message [content tags]
(if (re-find #"^D \#\[\d+\]" content)
(let [reference-digits (re-find #"\d+" content)
reference-index (Integer/parseInt reference-digits)
p-tag (get tags reference-index)]
(if (nil? p-tag)
[content 1]
(let [recipient-key (hex-string->num (second p-tag))
@bsless
bsless / ytdl.clj
Created May 9, 2021 13:20
Babashka wrapper for youtube-dl, mainly for parallelism
(ns ytdl
(:require
[babashka.fs :as fs]
[babashka.process :refer [process]]
[cheshire.core :as json]
[clojure.core.async :as async]
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.tools.cli :refer [parse-opts]]
[clojure.string :as str]))
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
metosin/reitit {:mvn/version "0.6.0"}
info.sunng/ring-jetty9-adapter {:mvn/version "0.30.0"}
http-kit/http-kit {:mvn/version "2.7.0"}}
:aliases
{:dev {:jvm-opts ["--enable-preview"]}
:run {:exec-fn server/go
:exec-args {}}}}
@bsless
bsless / README.md
Created August 31, 2023 12:44
Clojure app startup performance

Why

Simple experiment to test the effects of different techniques and options on application start up time

Class Data Sharing (CDS)

The goal of CDS is to reduce the startup time of the JVM by loading from a pre-processed archive of Java classes and JVM metadata that is used during the initialization process. https://dev.java/learn/jvm/cds-appcds/

Clojure compiler options

see

Meta elision

(require 'lsp)
(defcustom-lsp lsp-unison-lsp-port 5757
"The port of a running UCM language server. You can overwride thise by setting the UNISON_LSP_PORT environment variable when running UCM."
:type 'number
:group 'lsp-unison
:package-version '(lsp-mode . "8.0.1")
:lsp-path "unison.lspPort")
(defcustom-lsp lsp-unison-trace-server "off"
(defn qualify-definitions
[d prefix]
(let [p (str prefix ".")
p' (str "#/definitions/" p)]
(into
{}
(map (fn [[k v]]
[(str p k)
(walk/postwalk
(fn [o]
@bsless
bsless / build-modules.clj
Last active April 28, 2022 16:10
Build independent Clojure module as part of same repository
(ns build
(:refer-clojure :exclude [test])
(:require
[clojure.tools.build.api :as b]
[org.corfield.build :as bb]))
(def version (format "0.0.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")