This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env/bb | |
;; script for creating DigitalOcean's droplet snapshot | |
(require '[babashka.curl :as curl]) | |
(require '[cheshire.core :as json]) | |
(def token (System/getenv "DO_TOKEN")) | |
(def droplet-id (System/getenv "DO_DROPLET_ID")) | |
(when (not token) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; If it's a record-like thing then we want to emphasize | |
;; that it's a key-lookup, so use (:key coll) | |
(:uri req) | |
(:email member) | |
;; Some collections behave more like functions, here use (coll key), | |
;; that way someone reading the code without context can understand it, | |
;; without having to know that it's really a map or set | |
(def allowed-role? #{:admin :mod}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example.counter | |
(:require | |
[shadow.experiments.grove :as sg :refer (defc <<)])) | |
(defc ui-counter [] | |
;; create a local state atom once on mount | |
(bind state-ref | |
(atom 0)) | |
;; watch state-ref and bind deref result to val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; code related to a youtube video: | |
;; https://youtu.be/3euk0-JF_tc | |
(ns qblock.main | |
(:require [clojure.string :as st] | |
[scad-clj.model :refer :all] | |
[scad-clj.scad :refer [write-scad]])) | |
(fn! 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(ns update-deps | |
(:require [clojure.edn :as edn] | |
[clojure.java.io :as io] | |
[clojure.pprint :as pp :refer [pprint]] | |
[clojure.walk :as walk])) | |
(defn- merge-defaults [deps defaults] | |
(let [ff (some-fn deps (complement (partial contains? deps))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(ns vidwiz.main | |
"This is a prototype script for automating a portion of my video editing using ffmpeg." | |
(:require [clojure.java.shell :refer [sh]] | |
[clojure.string :as st] | |
[cheshire.core :refer [parse-string]])) | |
;; util | |
(defn get-extension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logger) | |
(defmacro log [& msgs] | |
(let [m (meta &form) | |
_ns (ns-name *ns*) ;; can also be used for logging | |
file *file*] | |
`(binding [*out* *err*] ;; or bind to (io/writer log-file) | |
(println (str ~file ":" | |
~(:line m) ":" | |
~(:column m)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.match :refer [match]] | |
'[clojure.string :as str] | |
'[hiccup2.core :refer [html]] | |
'[org.httpkit.server :as server]) | |
(defn router [req] | |
(let [paths (vec (rest (str/split (:uri req) #"/")))] | |
(match [(:request-method req) paths] | |
[:get ["users" id]] {:body (str (html [:div id]))} | |
:else {:body (str (html [:html "Welcome!"]))}))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; source code related to the project shown in this video: | |
;; https://youtu.be/_XiEc0g2wL8 | |
;; author: adam-james | |
(ns hc.main) | |
(defn hiccup? | |
[item] | |
(and (vector? item) | |
(keyword? (first item)))) |