Skip to content

Instantly share code, notes, and snippets.

View digash's full-sized avatar
🐽
digging

Dig Gashinsky digash

🐽
digging
View GitHub Profile
@leifericf
leifericf / bb.edn
Last active January 9, 2024 20:21
Consuming 3rd Party APIs Using Clojure (Babashka)
{:paths ["src"]
:deps {org.babashka/json {:mvn/version "0.1.1"}}}
@digash
digash / get-latest-meta-data-json.clj
Last active December 2, 2021 17:45
Read all meta-data on AWS EC2
#!/bin/env bb
(let [cgb #(->> % (cons "http://169.254.169.254/latest") (str/join "/") curl/get :body)
try-json #(try (json/parse-string %) (catch Exception _ %))
dir? #(str/ends-with? (last %) "/")
paths (fn [p] (->> (cgb p)
str/split-lines
(map #(->> (str/split % #"=") first (conj p)))))
trimlslash #(str/replace % #"/$" "")]
(json/generate-stream
@borkdude
borkdude / bipe
Last active April 9, 2024 21:21
vipe for babashka - see https://github.com/juliangruber/vipe
#!/usr/bin/env bash
# temp file
t=/tmp/bipe.$$.txt
touch $t
# read from stdin
if [ ! -t 0 ]; then
cat > $t
@laurio
laurio / reorder.clj
Created April 5, 2021 08:42
babashka script for reordering requires and imports in clojure files
#!/usr/bin/env bb
(ns reorder
(:require [clojure.java.io :as io]
[clojure.string :as string]
[rewrite-clj.node :as n]
[rewrite-clj.zip :as z]
[rewrite-clj.zip.subedit :as zsub])
(:import (java.io File StringWriter)))
(defn- top? [loc]
@holyjak
holyjak / http-server.bb
Last active May 20, 2025 08:49
Babashka HTTP server for serving static files, similar to `python -m http.server` but more flexible :)
#!/usr/bin/env bb
#_" -*- mode: clojure; -*-"
;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj
(ns http-server
(:require [babashka.fs :as fs]
[clojure.java.browse :as browse]
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[org.httpkit.server :as server]
@derjohn
derjohn / update-huawei-matebook-firmware-linux.md
Last active July 19, 2025 16:18
Update your Huawei Matebook Pro X (and others) from the Linux shell with fwupd

Huawei Matebook BIOS update with Linux

Tested with Huawei Matebook X Pro (MACH-WX9) This is more or less a step by step tutorial, written 02/2021. Sadly at the moment Huawei does not ship a package in Linux Vendor Firmware Service.

WARNING

Please note that you can damage ("brick") your device if something goes wrong or is done incorrectly. This is for the advanced user! I can only say that I flashed the new firmware 0.1.33 to my MACH-WX9 successfully.

Original docs

dennemann.blog THX!!!

@lukaszkorecki
lukaszkorecki / Dockerfile
Created February 17, 2021 17:04
AWS Lambda + babashka + minimal container image
FROM alpine:3.11.3
RUN apk update && apk add curl ca-certificates unzip && rm -rf /var/cache/apk/*
RUN curl -L 'https://github.com/babashka/babashka/releases/download/v0.2.10/babashka-0.2.10-linux-static-amd64.zip' -o /tmp/bb.zip && \
unzip /tmp/bb.zip && \
mv bb /usr/bin/bb && \
chmod +x /usr/bin/bb
RUN mkdir -p /app
@borkdude
borkdude / api_diff_bb.clj
Created January 8, 2021 10:13
Print API breakage warnings
#!/usr/bin/env bb
;; Example usage:
;; api_diff_bb.clj org.clojure/clojure "1.9.0" "1.10.1"
;; Output:
;; clojure/core_deftype.clj:587:1: warning: Arity 4 of clojure.core/emit-method-builder was removed.
;; clojure/core/reducers.clj:24:1: warning: clojure.core.reducers/compile-if was removed.
(require '[babashka.pods :as pods])
@eneroth
eneroth / cf_dsl.clj
Last active March 15, 2022 03:48
Minimal DSL for CloudFormation templates
;; DSL
;; ############################
(ns example.lib.cloudformation
(:require [camel-snake-kebab.core :refer [->PascalCase]]))
(defmacro defresource
"Defines a resource. The CF name of the resource will be the same
as the name given to it, except Pascal-cased, since that seems
to be the style favoured by CF. Optionally, a literal name
in the form of a keyword can be given as second argument to