Skip to content

Instantly share code, notes, and snippets.

// Based on https://github.com/LinusU/base32-encode/blob/master/index.js
function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ''; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; }
console.clear();
console.warn("Here's your Authy tokens:");
var data = appManager.getModel().map(function(i) {
var secretSeed = i.secretSeed;
if (typeof secretSeed == 'undefined') {
secretSeed = i.encryptedSeed;
#!/bin/sh -ex
## create new sparese image
dd if=/dev/zero of=ubbie-raw.img bs=1 count=0 seek=1G
## partition the disk
parted -s ubbie-raw.img mklabel gpt
parted -s ubbie-raw.img mkpart primary fat32 1MiB 501MiB
parted -s ubbie-raw.img mkpart primary ext4 501MiB 5GiB
parted -s ubbie-raw.img mkpart primary ext4 5GiB 100%
FROM alpine:latest AS build
ARG hugo_version=0.62.2
## fetch and install hugo
RUN wget -q -O - \
https://github.com/gohugoio/hugo/releases/download/v${hugo_version}/hugo_${hugo_version}_Linux-64bit.tar.gz \
| tar -zxf - hugo && \
mv hugo /usr/local/bin/hugo && \
chmod 0755 /usr/local/bin/hugo
#!/usr/bin/env bash
## upstream-update.sh
## file revision $Id$
#
## upstream origin
UPSTREAM_ORIGIN="upstream"
## fork origin
FORKED_ORIGIN="origin"
@aaronhurt
aaronhurt / foo.go
Last active April 17, 2018 22:05
HCL heredoc stuff
package main
import (
"fmt"
"github.com/hashicorp/hcl"
)
const myHCL = `foo {
bar = [<<EOF
"adsf asdf"
@aaronhurt
aaronhurt / find.go
Last active January 15, 2018 18:50
find and filter files
package find
import (
"os"
"path/filepath"
"regexp"
)
// File wraps the os.FileInfo struct to include a path reference
type File struct {
@aaronhurt
aaronhurt / local-consul-cluster.md
Created December 20, 2017 22:26
local dual datacenter consul cluster

alias the ips...

ifconfig lo0 inet 127.0.0.100 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.110 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.120 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.200 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.210 netmask 255.255.255.0 alias
ifconfig lo0 inet 127.0.0.220 netmask 255.255.255.0 alias
Last login: Mon Apr 17 09:19:45 2017 from 96.4.0.206
FreeBSD 11.0-RELEASE-p2 (GENERIC) #0: Mon Oct 24 06:55:27 UTC 2016
, ,
/( )`
\ \___ / |
/- _ `-/ '
(/\/ \ \ /\
/ / | ` \
@aaronhurt
aaronhurt / haproxy-multi-dc.ctmpl
Last active November 25, 2016 08:36
HAProxy configuration generated from consul via consul-template to generate frontend/backend services across multiple datacenters
##
## NOTE: Configuration generated by consul-template
## local changes will be overwritten.
##{{$myDc := key "env/dc"}}
## lb/haproxy/global
global{{range ls "lb/haproxy/global"}}{{if ne .Key "rawText"}}
{{.Key}} {{.Value}}
{{- end}}{{end -}}
{{range $key, $pairs := tree "lb/haproxy/global" | byKey}}{{range $pair := $pairs}}
@aaronhurt
aaronhurt / gist:9494e5e7831fa927803e
Created December 9, 2014 20:34
swagger and go-restful
// registration function
func (ml mlResource) register(container *restful.Container) {
// new service object
ws := new(restful.WebService)
// set the path
ws.Path(path.Join(ml.Config.Service.BasePath, "/rules")).
Doc("Get managed LAN rule set documents").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
// list available configuration data