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
;; Transducer a portmanteau of transform and reducer? | |
(defn reducing-fn | |
([] | |
;; this 0 arity is called when no initial coll is provided to a transducer | |
;; This should return the starting state | |
(transient #{})) | |
([ans] |
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
;; get, get-in, keyword accessor, destructuring etc all work as expected | |
(get-in (transient {:a (transient {:b 2})}) [:a :b]) ;; => 2 | |
(get-in (transient {:a {:b 2}}) [:a :b]) ;; => 2 | |
(get-in (transient {:a (transient {:b (transient [10 11 12])})}) [:a :b 1]) ;; => 11 | |
((transient {:a 1}) :a) ;; => 1 | |
(:a (transient {:a 1})) ;; => 1 |
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 | |
;; NB. it can be helpful to do `sudo id` on the cmdline before running this script so that the privileged commands work | |
;; Spire doesn't yet have the ability to ask for a password when sudo is used | |
;; | |
;; | |
;; This script is an example of how to use babashka and spire to automate project setup for local development. | |
;; Sets up the local development environment so that necessary software is installed and https can be used. | |
;; You would tailor it to your needs. |
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
####################################################################### | |
# 1. Generate public and private keys | |
# ```shell | |
# openssl genpkey -algorithm ED25519 -out ed25519.pem | |
# openssl pkey -in ed25519.pem -pubout > ed25519.pem.pub | |
# ``` | |
# 2. Register the public key with the remote service | |
# 3. Ensure python requirements | |
# ```shell | |
# pip install requests cryptography |
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
/* | |
# 1. Generate public and private keys | |
# ```shell | |
# openssl genpkey -algorithm ED25519 -out ed25519.pem | |
# openssl pkey -in ed25519.pem -pubout > ed25519.pem.pub | |
# ``` | |
# 2. Register the public key with the remote service | |
# 3. Ensure node requirements | |
# ```shell | |
# npm install axios |
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
/* | |
# 1. Generate public and private keys | |
# ```shell | |
# openssl genpkey -algorithm ED25519 -out ed25519.pem | |
# openssl pkey -in ed25519.pem -pubout > ed25519.pem.pub | |
# ``` | |
# 2. Register the public key with the remote service | |
# 3. Compile | |
# ```shell | |
# javac DigitalSignature |
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 digital-signature | |
(:require [clojure.string :as str]) | |
(:import (java.security.spec PKCS8EncodedKeySpec X509EncodedKeySpec) | |
(java.security PublicKey PrivateKey Signature KeyFactory KeyPairGenerator) | |
(java.util Base64))) | |
(defn gen-key | |
[pem algo] | |
(let [priv-header "-----BEGIN PRIVATE KEY-----" |
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 roaring-bitmap | |
(:refer-clojure :exclude [contains? empty? min max seq]) | |
(:import (java.io | |
DataInput | |
DataOutput) | |
(java.nio | |
ByteBuffer) | |
(org.roaringbitmap | |
Container | |
ContainerPointer |
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 test-db | |
"Example of using testcontainers and launching a postgres container with flyway migrations. | |
NB. databases are created but not destroyed which can be handy for debugging tests. | |
* Connecting to template1 from psql for example will cause create database to fail | |
* Based on ideas from https://github.com/opentable/otj-pg-embedded" | |
(:require [clj-test-containers.core :as tc] | |
[clojure.java.jdbc :as jdbc] | |
[clojure.string :as str]) | |
(:import (org.flywaydb.core | |
Flyway))) |
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 aes256gcm | |
(:require ["crypto" :as crypto] | |
[clojure.string :as str])) | |
(defn url-safe-base64-encode | |
[s] | |
(-> s | |
(str/replace "+" "-") | |
(str/replace "/" "_"))) |
NewerOlder