Skip to content

Instantly share code, notes, and snippets.

@benma
benma / secrecy.rs
Last active October 17, 2020 01:47
use secrecy::{ExposeSecret, Secret};
#[derive(Debug)]
struct EncryptionKey(Secret<[u8; 32]>);
fn get_encryption_key() -> EncryptionKey {
let key = EncryptionKey(Secret::new(*b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
println!("Pointer at creation: {:p}", key.0.expose_secret().as_ptr());
key
}
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Daniel, this is benma. 2020-08-26.
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEELYh2gQqwkuRR3KiUgEU4kow36ugFAl9GQ+sACgkQgEU4kow3
6uhwgA/6A+eZwuZNFV42usp62lly3xE8liFZIKeG0ZfPtQyO9LYSOB+LaOnp0rwC
tYRYkOTZMEmpMKOx9ZoKdwbwqzRfttXxctsX3mtAWnO2tsXjT6ObOF6JjRH4GLjI
@benma
benma / keybase.md
Created August 13, 2019 09:25
keybase.md

Keybase proof

I hereby claim:

  • I am benma on github.
  • I am benma (https://keybase.io/benma) on keybase.
  • I have a public key whose fingerprint is 2260 E482 8888 2C76 AFAA 319D 67A2 B160 F74D B275

To claim this, I am signing this object:

@benma
benma / test.go
Created July 28, 2016 14:58
ed255519 -> curve25519
package main
import (
"crypto/rand"
"fmt"
"github.com/agl/ed25519"
"github.com/agl/ed25519/extra25519"
"github.com/monetas/gotary/util/enc"
)
@benma
benma / cleandocker.sh
Created May 24, 2016 07:48
cleandocker.sh
cleandocker() {
docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
docker rmi `docker images -aq --filter "dangling=true"`
}
@benma
benma / sqlest.sh
Last active April 26, 2016 11:37
postgres serialiazation errors where none should happen (false negatives)
#!/bin/bash
DBNAME=dbname
DBUSER=dbuser
N=150
sql () {
echo $1 | psql -h localhost $DBNAME $DBUSER
}
@benma
benma / virtualenv_xapian.sh
Last active August 29, 2015 14:16 — forked from josezambrana/install xapian inside virtualenv
install xapian inside virtualenv
#!/bin/sh
sudo apt-get install zlib1g-dev
sudo apt-get install g++
sudo apt-get install uuid-dev
export VENV=$VIRTUAL_ENV
curl -O http://oligarchy.co.uk/xapian/1.2.18/xapian-core-1.2.18.tar.xz
curl -O http://oligarchy.co.uk/xapian/1.2.18/xapian-bindings-1.2.18.tar.xz
@benma
benma / settings.py
Created January 24, 2015 16:29
external settings verifier
# ....
# in settings.py (oder sonst eine versionierte datei)
import settings_sensitive
class ImproperlyConfigured(Exception):
pass
try:
@benma
benma / coverage.sh
Created January 15, 2015 13:44
go coverage
#!/bin/sh
go test -coverprofile=cov.out
go tool cover -html=cov.out
import Control.Monad.RWS
import Data.Map
import qualified Data.Map as Map
type Knot k s a = RWS k k s a
tie :: Knot k s a -> s -> (a, s, k)
tie knot s0 =
let (a, s1, k) = runRWS knot k s0 -- this is fucking interesting
in (a, s1, k)