This file contains 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 dialog | |
"Display a Yes/No dialog, which appears on the very top of every app and grabs | |
the focus and also gives it back to the REPL, after making the choice, unlike | |
a Swing dialog, for example. | |
It's useful for confirming irreversible operations, like file or DB deletion. | |
It uses AppleScript, so it only works on macOS and on a local REPL." | |
(:require | |
[clojure.java.shell :as shell])) |
This file contains 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
;; A macro to create a decorator (wrapper) for a objects implementing a Java interface | |
;; Disclaimer: The code most certainly is not perfect and does not handle some corner cases | |
;; License: The Unlicense http://unlicense.org/ | |
(require '[clojure.string :as str]) | |
(defn type->tag [parameter-type] | |
(let [array? (-> parameter-type name (str/ends-with? "<>")) | |
primitive? '#{int long float double short boolean byte char} | |
type (if array? | |
(-> parameter-type name (str/replace #"<>$" "") symbol) |
This file contains 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 myapp.tailwind | |
(:require | |
[clojure.spec.alpha :as s] | |
[clojure.string :as str] | |
[vl.config :as config])) | |
(s/def ::class (s/or :string string? :vector vector?)) | |
(s/def ::cs sequential?) ;; shorthand for classes | |
(s/def ::dim #{:screen :fill :h :vh :w :vw}) | |
(s/def ::position #{:x-center :y-center :center}) ;; position utils for relative elements |
This file contains 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 oidc-client | |
"Get end-user access token from an OIDC provider, caching the access/refresh token in an encrypted file. Code in https://babashka.org | |
Usage: | |
/path/to/oidc_client.clj | |
When there are no cached, valid tokens, it will open a browser with the OIDC provider login URL and start a HTTPS-enabled | |
callback server on localhost. Make sure that the resulting redirect_uri is registered with your provider. | |
This file contains 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 | |
(require '[babashka.deps :as deps]) | |
(deps/add-deps '{:deps {jasentaa/jasentaa | |
{:git/url "https://github.com/borkdude/jasentaa" | |
:sha "7161b0bd8029eb29760abd1eb3026a48a8cde318"}}}) | |
(ns jasentaa.worked-example-1 | |
(:require |
This file contains 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 | |
(require '[babashka.deps :as deps]) | |
(deps/add-deps '{:deps {org.blancas/kern {:git/url "https://github.com/borkdude/kern" | |
:sha "34a8c2f0c1ec5ab3e0e9aac56e6278abc3ed5a0b"}}}) | |
(use 'blancas.kern.core | |
'blancas.kern.lexer.basic) |
This file contains 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 | |
;; Inspired from https://book.babashka.org/#_running_tests | |
(require '[clojure.test :as t] | |
'[clojure.string :as string] | |
'[babashka.classpath :as cp] | |
'[babashka.fs :as fs]) | |
(cp/add-classpath "src:test") |
This file contains 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 fun.clojure.paillier | |
(:import [java.math BigInteger] | |
[java.security SecureRandom] | |
[java.nio.charset StandardCharsets])) | |
(defn- random-number! [end] | |
(let [start (BigInteger/valueOf 2) | |
interval (.subtract end start) | |
i (BigInteger. (.bitCount interval) (SecureRandom.))] | |
(.add start i))) |
This file contains 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 | |
(require | |
'[babashka.pods :as pods] | |
'[babashka.curl :as curl] | |
'[cheshire.core :as json] | |
'[clojure.java.shell :refer [sh]]) | |
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9") | |
(require |
This file contains 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))) |
NewerOlder