Skip to content

Instantly share code, notes, and snippets.

View clojure-17151214060258308065.edn
"Execution error (NoSuchFileException) at sun.nio.fs.UnixException/translateToIOException (\n/root/.gitlibs/libs/org.clojure/spec-alpha2/2f84e3a37cab76d44c58785ff4481597429bc1d3/${project.basedir}/src/main/java\n",
{:clojure.error/class java.nio.file.NoSuchFileException,
:clojure.error/line 92,
:clojure.error/source "",
mtnygard /
Last active Jul 18, 2020
Get gcloud instances in default project as /etc/hosts format
gcloud compute instances list --format "table[no-heading](networkInterfaces[0].accessConfigs[0].natIP, name)"
mtnygard / scratch.clj
Created Jul 5, 2020
Convert leiningen style deps vector into deps.edn map
View scratch.clj
(defn lein-deps->deps-map [deps-vector]
(reduce merge {}
(for [d deps-vector
:let [[prj mvn-version & _] d]]
{prj {:mvn/version mvn-version}})))
(def d '[[org.clojure/clojure "1.9.0-alpha13"]
[org.clojure/core.async "0.2.391"]
View install_win_apps.bat
@echo off
winget install Dropbox.Dropbox
winget install Canonical.Ubuntu
winget install Axosoft.GitKraken
winget install Docker.DockerDesktop
winget install 7zip.7zip
winget install Git.Git
winget install GitExtensionsTeam.GitExtensions
winget install Google.Chrome
winget install Microsoft.PowerToys
mtnygard / Export to Markdown.ajs
Created Dec 3, 2019 — forked from smileham/Export to Markdown.ajs
Export an ArchiMate diagram to Markdown format.
View Export to Markdown.ajs
* Export View to Markdown
* Requires jArchi -
* Markdown -
* Version 2: Updated to support Diagram Groups
* Version 2.1: Add check for Selected View
* Version 2.2: Change to regex, added date of export
mtnygard / responses.clj
Last active Jul 16, 2019
Build Pedestal response maps for every standard HTTP status code.
View responses.clj
(defn response
([status body]
{:status status
:headers {}
:body body}))
(defmacro http-status [code sym]
`(def ~sym (partial response ~code)))
(defmacro http-statuses [& pairs]
mtnygard / multimethod_selector.clj
Created Aug 23, 2018
A clojure.spec.gen.alpha generator that picks a multimethod implementation from the known set.
View multimethod_selector.clj
(defn multimethod-selector
"Returns a generator that picks one dispatch value from the known
dispatch values of a multimethod. Defers the lookup of dispatch
values until sampling time, so any defmethods evaluated after the
generator is created may still be selected."
(fn [i]
(let [ms (keys (methods s))]
mtnygard / main.clj
Created Apr 3, 2018
Use macros to make nested try/catch with values less of an eyesore.
View main.clj
(defn -main
[& args]
(let [file (try-> args
(:! clojure.lang.ExceptionInfo ei (fe/print-other-exception ei))
(when (and file (not= ::try/exit file))
(try-> file
(:! fnfe (fe/print-error-message (str "File not found: " (pr-str (.getMessage fnfe)))))
mtnygard /
Last active May 9, 2018
Create a dependency matrix of Clojure namespaces.

The dependency matrix shows the strength of coupling at a var-by-var level between namespaces.

If you pull the CSV output into a spreadsheet, the numbers in the cells show how many var->var dependencies there are between the namespaces.

If you want to just look at namespace->namespace dependencies (e.g., to create a visualization) then just consider any cell > 0 as a dependency.

mtnygard / deps.edn
Last active May 27, 2020 — forked from athos/deps.edn
Friendly REPL. Run with `clojure -Sdeps '{:deps {hello-clojure {:git/url "" :sha "774314af2d28261af4a52ac270136d5ba21ff046"}}}' -m frenpl`
View deps.edn
{:paths ["." "src" "test"]
:deps {expound {:mvn/version "0.8.4"}
clansi {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.24.0"}
refactor-nrepl {:mvn/version "2.5.0"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}}