Skip to content

Instantly share code, notes, and snippets.

@MrGung
MrGung / git.rebase.remove-noap.clj
Created February 2, 2023 09:24
Automatically modifying (certain) git commit-messages during a rebase.
(ns git.rebase.remove-noap
"Ersetzt bei einem Rebase evtl. vorhandene \\[noap\\S*?\\]\\s*
Aufruf mit `git rebase --exec \"bb -m git.rebase.remove-noap/do!\" origin/develop`"
(:require
[babashka.fs :as fs]
[clojure.string :as str]
[git.core :as git]
[common-file :as cof]
[git.hooks.impl.logging :as log]))
@MrGung
MrGung / get_all_issues.clj
Created December 6, 2022 08:52
Get paginated list of issues from gitlab with clojure/babashka
(defn get-all-issues
"Holt alle Issues. Verwendet `iteration` für die Pagination."
[gitlab-config project-id]
(let [{:keys [gitlab-token gitlab-root]} gitlab-config
curl-options {:raw-args ["--insecure"]
:debug true
:throw false
:headers {:PRIVATE-TOKEN gitlab-token
:Content-Type "application/json; charset=utf-8"}}
step (fn step [marker-token]
;; https://stackoverflow.com/questions/24897818/how-to-add-docstring-support-to-defn-like-clojure-macro
(defn resolve-params
"Takes parameters to a def* macro, allowing an optional docstring and opts by sorting
out which parameter is which.
Returns the params, body, docstring, and opts it found."
[args]
(let [[docstring args] (if (string? (first args))
[(first args) (rest args)]
[nil args])
[params args] [(first args) (rest args)]

Instructions

  • Modify deps.edn to contain the dependencies you need.
  • Call bb zip <zipname> to create the ZIP-file, omitting the extension .zip.
@MrGung
MrGung / convert_remote_images_to_local.clj
Created April 16, 2022 08:33
download remote #logseq media and replace links to point to local assets. converting from #logseq web-app to desktop-app. written in #clojure, executable with #babashka.
(ns logseq.convert-remote-images-to-local
(:require
[babashka.fs :as fs]
[babashka.curl :as curl]
[clojure.java.io :as io]
[clojure.string :as str]))
;; download remote #logseq media and replace links to point to local assets.
;; converting from #logseq web-app to desktop-app.
@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]}]
@MrGung
MrGung / cop_db.clj
Created August 12, 2012 11:41
Datenbankzugriff (netz/lokal) per Context Oriented Programming
;; ------------------------------------------------------------------------------------------ some context-oriented-programming-magic
(cop/deflayer local-layer)
(cop/deflayer net-layer)
;; make-writable
(cop/deflayered make-writable [& args] (apply du/make-writable args))
(cop/deflayered make-writable net-layer [& args] nil)
;; detach
(cop/deflayered detach [& args] (apply ad/detach args))
@MrGung
MrGung / config.clj
Created August 11, 2012 10:16
Configuration with functions (and without macro)
(configure-for-ns 'gf.job.project.datenbank.simple-patch-db
(extends ['config.db-server
'gf.job.datenbank.db-patch]
(let [
;; in dieses Verzeichnis werden die Trafo-Skripte generiert und von hier werden sie in das Project-Entwicklungsverzeichnis kopiert
trafo-gen-dir "c:\\Users\\me\\Documents\\Scratch\\Database\\Trafos\\1.0A_patches\\"
;; Hier landen die EXE-Patches.
patches-dst-dir "q:\\Current\\Job.Project\\Current\\Datenbank\\Dev-Patches\\"
db-patches-raw (:db-patches (from-ns-config 'gf.job.project.datenbank.db-patches))
@MrGung
MrGung / config.clj
Created August 11, 2012 10:16
Configuration with macro
(configure-for-ns gf.job.project.datenbank.simple-patch-db
(extends [config.db-server
gf.job.datenbank.db-patch]
(let [
;; in dieses Verzeichnis werden die Trafo-Skripte generiert und von hier werden sie in das Project-Entwicklungsverzeichnis kopiert
trafo-gen-dir "c:\\Users\\me\\Documents\\Scratch\\Database\\Trafos\\1.0A_patches\\"
;; Hier landen die EXE-Patches.
patches-dst-dir "q:\\Current\\Job.Project\\Current\\Datenbank\\Dev-Patches\\"
db-patches-raw (:db-patches (from-ns-config 'gf.job.project.datenbank.db-patches))
@MrGung
MrGung / combine_XPS_files.fsx
Created August 27, 2011 18:31
Combining/Merging XPS files with F#
#r "ReachFramework.dll"
#r "WindowsBase.dll"
#r "PresentationFramework.dll"
#r "PresentationCore.dll"
#r "System.Xaml.dll"
#r "System.Printing.dll"
open System.Windows.Xps.Packaging
open System.Windows.Documents