Skip to content

Instantly share code, notes, and snippets.

Pavel Repin paxan

Block or report user

Report or block paxan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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 / get-daemontools-heroku-16.md
Created Mar 9, 2017
How to get daemontools onto a dyno running heroku-16 stack
View get-daemontools-heroku-16.md
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
@paxan
paxan / getin.java
Last active Aug 15, 2016
Get the element in an arbitrarily nested JSON structure by following a path of keys (inspired by Clojure's get-in function)
View getin.java
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 / ae.clj
Last active Nov 25, 2016
AEAD decryption process using AWS KMS & AES/GCM/NoPadding cipher
View ae.clj
;; 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 / kmstool.py
Last active Jan 26, 2016
A tool for storing secrets on disk securely using AWS KMS
View kmstool.py
from __future__ import absolute_import, print_function
import boto3
import errno
import json
import os
import re
import shlex
import sys
import tempfile
@paxan
paxan / tornado_force_https.py
Last active Nov 23, 2015
A hack to make Tornado web server redirect http requests to https for Heroku or similar reverse-proxied deployments
View tornado_force_https.py
from __future__ import absolute_import, print_function
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
def create_server(*args, **kwargs):
'''
@paxan
paxan / dynamic-jar-loading
Created Jun 12, 2015
Example of loading a local jar file dynamically using boot-clj
View dynamic-jar-loading
#!/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
commons-net
net.java.dev.jets3t/jets3t
org.slf4j/slf4j-api
tomcat/jasper-compiler
@paxan
paxan / runtime-metrics.clj
Created May 23, 2015
boot.clj Heroku runtime metrics
View runtime-metrics.clj
{: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
@paxan
paxan / demo
Last active Aug 29, 2015
try-let
View demo
```
> (try-let [x (/ 5 1) y (/ 5 2)] [x y])
[5 5/2]
> (try-let [x (/ 5 1) y (/ 5 0)] [x y])
#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
```
@paxan
paxan / librato.go
Created Dec 5, 2014
HACK: Librato measurement sender
View librato.go
package main
import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"log"
"net/http"
"regexp"
You can’t perform that action at this time.