Skip to content

Instantly share code, notes, and snippets.

View paxan's full-sized avatar

Pavel Repin paxan

  • Seattle, WA
View GitHub Profile
paxan / main.go
Last active April 26, 2023 00:41
HTTP middlewares in Go from the first principles
package main
import (
paxan / .gitconfig
Created August 17, 2022 03:02
ff = only
ff = false

Keybase proof

I hereby claim:

  • I am paxan on github.
  • I am paxan ( on keybase.
  • I have a public key ASCofZ0PjVQOf9m_rtS0h2_iLGunooGXCW3FPvNSZUgdKQo

To claim this, I am signing this object:

paxan /
Created March 9, 2017 18:15
How to get daemontools onto a dyno running heroku-16 stack
curl -sO
dpkg-deb -x daemontools_0.76-6ubuntu1_amd64.deb daemontools
paxan /
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 java.util.Arrays;
import java.util.Optional;
class SomeClass {
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
;; 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 /
Last active January 26, 2016 00:48
A tool for storing secrets on disk securely using AWS KMS
from __future__ import absolute_import, print_function
import boto3
import errno
import json
import os
import re
import shlex
import sys
import tempfile
paxan /
Last active August 15, 2023 01:24
A hack to make Tornado web server redirect http requests to https for Heroku or similar reverse-proxied deployments
from __future__ import absolute_import, print_function
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
def create_server(*args, **kwargs):
paxan / dynamic-jar-loading
Created June 12, 2015 23:38
Example of loading a local jar file dynamically using boot-clj
#!/usr/bin/env boot
;; -*- mode: clojure -*-
(set-env! :dependencies '[[org.apache.hadoop/hadoop-common "2.4.0"]
[org.apache.pig/pig "0.12.0"
:exclusions [commons-logging
paxan / runtime-metrics.clj
Created May 23, 2015 17:40
boot.clj Heroku runtime metrics
{:time #inst "2015-05-23T16:45:35.294Z", :from "run.6221", :text "source=run.6221 sample#memory_total=7.62MB sample#memory_rss=0.66MB sample#memory_cache=6.96MB sample#memory_swap=0.00MB sample#memory_pgpgin=2512pages sample#memory_pgpgout=561pages"}
{:time #inst "2015-05-23T16:45:56.995Z", :from "run.6221", :text "source=run.6221 sample#memory_total=259.27MB sample#memory_rss=220.50MB sample#memory_cache=38.77MB sample#memory_swap=0.00MB sample#memory_pgpgin=91599pages sample#memory_pgpgout=25225pages"}
{:time #inst "2015-05-23T16:46:19.082Z", :from "run.6221", :text "source=run.6221 sample#load_avg_1m=1.36"}
{:time #inst "2015-05-23T16:46:19.082Z", :from "run.6221", :text "source=run.6221 sample#memory_total=627.97MB sample#memory_rss=481.32MB sample#memory_cache=7.44MB sample#memory_swap=139.21MB sample#memory_pgpgin=208632pages sample#memory_pgpgout=83508pages"}
{:time #inst "2015-05-23T16:46:19.083Z", :from "run.6221", :text "Process running mem=627M(122.7%)"}
{:time #inst "2015-05-23T16:46:19.083Z", :fr