Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active July 4, 2018 16:34
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/8ad63f256e6f834f812b86a2c0e36415 to your computer and use it in GitHub Desktop.
Save borkdude/8ad63f256e6f834f812b86a2c0e36415 to your computer and use it in GitHub Desktop.
Execute all in one clj script
deps=`awk '/^;; deps.edn$/{flag=1;next}/^;; end deps.edn$/{flag=0}flag' $1`
script=`awk '/^;; script$/{flag=1;next}/^;; end script$/{flag=0}flag' $1`
clj -Sdeps "$deps" -e "$script"
# initial usage
$ time ./script.clj
2018-03-03T21:16:06.869Z
./script.clj 10.43s user 0.55s system 280% cpu 3.911 total
# notice the speedup due to classpath caching in clj 1.9.0.358
$ time ./script.clj
2018-03-03T21:16:25.889Z
./script.clj 3.77s user 0.22s system 259% cpu 1.536 total
#!/usr/bin/env cljscript
;; deps.edn
{:deps {clj-time {:mvn/version "0.14.2"}}}
;; end deps.edn
;; script
(require '[clj-time.core :as t])
(println (str (t/now)))
;; end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment