Skip to content

Instantly share code, notes, and snippets.

View borkdude's full-sized avatar

Michiel Borkent borkdude

View GitHub Profile
@mmzsource
mmzsource / babashka-maze-solving-clojure-asciinema.md
Last active February 26, 2021 23:21
coding dojo - maze solving

asciicast

@codeasone
codeasone / clojure-require-ordering-via-pre-commit-hook.org
Last active November 11, 2020 14:52
Maintaining order of namespace :require forms via pre-commit hook
@zelark
zelark / torrent-viewer.clj
Last active July 13, 2021 13:53
babashka script for viewing torrents files
#!/usr/bin/env bb
(require '[clojure.java.io :as io])
(require '[bencode.core :refer [read-bencode]])
(require '[clojure.walk :refer [prewalk]])
(require '[clojure.pprint :refer [pprint]])
(import 'java.io.PushbackInputStream)
(defn bytes->strings [coll]
(prewalk #(if (bytes? %) (String. % "UTF-8") %) coll))
@MrGung
MrGung / gitlab.clone-group.clj
Created November 10, 2020 15:31
Gitlab: Clone all repositories in group
(ns gitlab.clone-group
(:require
[cheshire.core :as json]
[gitlab.api :refer [get-config]]
[babashka.curl :as curl]
[clojure.java.io :as io]
[clojure.tools.cli :refer [parse-opts]]
[babashka.process :refer [$]]))
(defn clone-all-repos-from-group [{:keys [gitlab-token gitlab-root group-id local-root]}]
@justone
justone / circle-artifacts
Last active November 2, 2020 18:15
Script to grab artifacts for a given CircleCI project. Call like this: ./circle-artifacts github borkdude grasp linux
#!/usr/bin/env bb
(require '[babashka.curl :as curl])
(require '[cheshire.core :as json])
(def recent-build-count 40)
(defn recent-builds-url
[ci user project limit status]
(str "https://circleci.com/api/v1.1/project/" ci "/" user "/" project "?limit=" limit "&filter=" status))
@malcolmsparks
malcolmsparks / backup-photos.clj
Last active June 29, 2021 19:10
A babashka script for sorting and de-duping a photo collection on Linux.
#_( ;; Allow this script to be executed directly
"exec" "bb" -o "--classpath" "." "$0" "$@"
)
;; Copyright © 2020, Malcolm Sparks
;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the “Software”), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@hansbugge
hansbugge / lint.clj
Created September 26, 2020 10:34
Code Quality report for Clojure projects in Gitlab using babashka and clj-kondo.
#!/usr/bin/env bb
(ns script
"Make a 'Code Quality' report from clj-kondo for use in GitLab CI.
JSON issue format:
https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool
Usage:
Add the following job in .gitlab-ci.yml:
@snorremd
snorremd / passphrase.clj
Last active January 2, 2025 15:31
Passphrase in babashka using /dev/urandom and /usr/share/dict/words
#!/usr/bin/env bb
(defn random-bytes
[n]
(with-open [in (io/input-stream (io/file "/dev/urandom"))]
(let [buf (byte-array n)]
(.read in buf)
buf)))
(defn random-number
@KGOH
KGOH / convert.clj
Last active November 21, 2025 09:01
convert.clj -- babashka edn/json/yaml to edn/json/yaml converter
#!/usr/bin/env bb
;; convert.clj -- babashka edn/json/yaml to edn/json/yaml converter
;; Author: github.com/KGOH/
;; Source: gist.github.com/KGOH/50c0f66022fea2ac173518a143238058
;; Version: 2020.4
; Usage example:
; In Emacs: i.imgur.com/TIEDmga.mp4
; $ convert.clj edn <<< '{"foo": "bar"}'
; {:foo "bar"}
.ONESHELL:
test: .SHELLFLAGS := -i
test: SHELL := bb
test:
(println :wow)
(require '[clojure.string :as s])
(s/reverse (slurp "./Makefile"))