Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh -e
printf "Input (no echo):\n" >&2
stty -echo; read -r Input; stty echo; printf "\n" >&2
[ ${#Input} -gt 16 ] || exit 23
Sha256=$(printf '%s' "$Input" | sha256sum | cut -d " " -f 1)
Prefix="3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420"
BcIn=$(printf '%s%s' "$Prefix" "$Sha256" | tr a-f A-F | sed -e 's/../&;/g')
Fmt=$(printf 'obase=8;ibase=16;%s' "$BcIn" | bc | tr \\n \\ | sed -e 's/.$//' -e 's/^/\\/')
Base64=$(printf '%b' "$Fmt" | base64 -w 64)
printf '\055----BEGIN PRIVATE KEY-----\n%s\n-----END PRIVATE KEY-----\n' "$Base64"
@sg2342
sg2342 / sendfile_tc.escript
Created April 23, 2015 19:16
erlang sendfile FreeBSD testcase
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable
%%
-module(sendfile_tc).
-export([main/1]).
main([]) ->
@sg2342
sg2342 / gist:3aa7eee90c45e09455e5
Created December 17, 2014 10:49
FreeBSD 10.1 RELEASE jackline bootstrap
--- STARTING with an empty FreeBSD10.1 RELEASE on amd64, install gmake git and ocaml ---
root@FreeBSD10:~ # pkg info
pkg-1.3.8_3 Package manager
root@FreeBSD10:~ # pkg install devel/gmake devel/git lang/ocaml
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100% 944 B 0.9k/s 00:01
Fetching digests.txz: 100% 2 MB 688.7k/s 00:03
Fetching packagesite.txz: 100% 5 MB 1.3M/s 00:04
@sg2342
sg2342 / min_tor_jail.sh
Last active April 8, 2021 22:17
FreeBSD: jailed static tor
#!/bin/sh
#
# install minimal tor jail
#
# prerequisites:
#
# * pkg(8) for pkg info and pkg query
#
# * security/tor package built with STATIC_TOR enabled
# or
@sg2342
sg2342 / snapcheck.sh
Created May 21, 2014 23:38
recursively check if zfs is different from it's latest snapshot
#!/bin/sh -efu
usage() {
printf >&2 "usage: %s [-hvm] filesystem\n" "$0"; exit 1
}
help() {
printf "usage: %s [-v] [-m] <filesystem>\n" "$0"
printf "recursively for all zfs filesystems starting with <filesystem>:\n"
printf " if property 'written' is not '0' and snapshots exists:\n"