Skip to content

Instantly share code, notes, and snippets.

@mtnygard
mtnygard / deps.edn
Last active April 9, 2024 11:51 — forked from athos/deps.edn
Friendly REPL. Run with `clojure -Sdeps '{:deps {hello-clojure {:git/url "https://gist.github.com/mtnygard/9b2dd3c88b3309d82210b84f33ee954d" :sha "774314af2d28261af4a52ac270136d5ba21ff046"}}}' -m frenpl`
{: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"}}}
@mtnygard
mtnygard / find_mirrors.sh
Created July 24, 2021 18:38
Find arm mirrors of Ubuntu
#!/bin/bash
# URL of the Launchpad mirror list
MIRROR_LIST=https://launchpad.net/ubuntu/+archivemirrors
# Set to the architecture you're looking for (e.g., amd64, i386, arm64, armhf, armel, powerpc, ...).
# See https://wiki.ubuntu.com/UbuntuDevelopment/PackageArchive#Architectures
ARCH=$1
# Set to the Ubuntu distribution you need (e.g., precise, saucy, trusty, ...)
# See https://wiki.ubuntu.com/DevelopmentCodeNames
@mtnygard
mtnygard / Github_Issues_in_Org.md
Created November 16, 2021 21:14
GitHub Issues as org-agenda TODOs w/ links & searchable/filterable labels.

GitHub Issues as org-agenda TODOs w/ links & searchable/filterable labels

gh issue list --limit 10000 --json number,title,url,labels \
    | jq -r '.[]|"** TODO [["+.url+"]["+(.number|tostring)+"]] "+.title+" "+":"+(.labels|map(.name)|join(":"))+":"' \
    | sed 's|::||g'

Credit to @dysinger

@mtnygard
mtnygard / main.clj
Created April 3, 2018 14:13
Use macros to make nested try/catch with values less of an eyesore.
(defn -main
[& args]
(let [file (try-> args
parse-args
(:! clojure.lang.ExceptionInfo ei (fe/print-other-exception ei))
:filename)]
(when (and file (not= ::try/exit file))
(try-> file
fern/load-from-file
(:! java.io.FileNotFoundException fnfe (fe/print-error-message (str "File not found: " (pr-str (.getMessage fnfe)))))
;; A Working Thing (singleton)
(defsc Thing [this {:thing/keys [label contents] :as props}]
{:query [:thing/label :thing/contents]
:ident (fn [_] [:component/id :thing])
:initial-state (fn [{:keys [label contents]}]
{:thing/label label :thing/contents contents})}
(div :.ui.container.segment
(h3 (str "Thing " label))
(dom/input {:value contents
{:clojure.main/message
"Execution error (NoSuchFileException) at sun.nio.fs.UnixException/translateToIOException (UnixException.java:92).\n/root/.gitlibs/libs/org.clojure/spec-alpha2/2f84e3a37cab76d44c58785ff4481597429bc1d3/${project.basedir}/src/main/java\n",
:clojure.main/triage
{:clojure.error/class java.nio.file.NoSuchFileException,
:clojure.error/line 92,
:clojure.error/cause
"/root/.gitlibs/libs/org.clojure/spec-alpha2/2f84e3a37cab76d44c58785ff4481597429bc1d3/${project.basedir}/src/main/java",
:clojure.error/symbol
sun.nio.fs.UnixException/translateToIOException,
:clojure.error/source "UnixException.java",
@mtnygard
mtnygard / gcloud-instances-hosts.sh
Last active July 18, 2020 15:08
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
mtnygard / scratch.clj
Created July 5, 2020 20:28
Convert leiningen style deps vector into deps.edn map
(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"]
@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
mtnygard / Export to Markdown.ajs
Created December 3, 2019 17:02 — forked from smileham/Export to Markdown.ajs
Export an ArchiMate diagram to Markdown format.
/*
* Export View to Markdown
*
* Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
*
* Markdown - https://www.markdownguide.org/
*
* 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