Skip to content

Instantly share code, notes, and snippets.

@paxan
paxan / ae.clj
Last active November 25, 2016 21:31
AEAD decryption process using AWS KMS & AES/GCM/NoPadding cipher
;; CAVEAT: Ensure your JDK/JRE is configured with Java Cryptography
;; Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
;; Visit http://www.oracle.com/technetwork/java/javase/downloads/index.html
;; and look for "JCE".
;; Given a ciphertext (produced by AES/GCM/NoPadding cipher), a nonce,
;; and a KMS-encrypted content encrypting key (cek), here is the
;; process for producing the plaintext:
(defn b64dec [x] (javax.xml.bind.DatatypeConverter/parseBase64Binary x))
@paxan
paxan / getin.java
Last active August 15, 2016 23:45
Get the element in an arbitrarily nested JSON structure by following a path of keys (inspired by Clojure's get-in function)
package some.package;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import java.util.Arrays;
import java.util.Optional;
class SomeClass {
/**
@paxan
paxan / get-daemontools-heroku-16.md
Created March 9, 2017 18:15
How to get daemontools onto a dyno running heroku-16 stack
curl -sO https://mirrors.kernel.org/ubuntu/pool/universe/d/daemontools/daemontools_0.76-6ubuntu1_amd64.deb
dpkg-deb -x daemontools_0.76-6ubuntu1_amd64.deb daemontools

Keybase proof

I hereby claim:

  • I am paxan on github.
  • I am paxan (https://keybase.io/paxan) on keybase.
  • I have a public key ASCofZ0PjVQOf9m_rtS0h2_iLGunooGXCW3FPvNSZUgdKQo

To claim this, I am signing this object:

@paxan
paxan / main.go
Last active April 26, 2023 00:41
HTTP middlewares in Go from the first principles
package main
import (
"context"
"fmt"
"log"
"net/http"
"sync/atomic"
)