Skip to content

Instantly share code, notes, and snippets.

@piranha
Last active January 20, 2025 12:28
Show Gist options
  • Save piranha/21efba5146fabf381cede6878001cedb to your computer and use it in GitHub Desktop.
Save piranha/21efba5146fabf381cede6878001cedb to your computer and use it in GitHub Desktop.
Single-file Clojure script with dependencies
#!/usr/bin/env clojure -M
;;; setup
;; this classloader stuff is needed so that `add-lib` sees the DynamicClassLoader that's used by `require`
(.setContextClassLoader (Thread/currentThread) (clojure.lang.RT/baseLoader))
(require '[clojure.repl.deps :as deps])
(binding [clojure.core/*repl* true]
(deps/add-lib 'http-kit {:mvn/version "2.8.0"}))
;;; actual script
(require '[org.httpkit.client :as http])
(println (:headers @(http/get "https://example.org/")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment