Skip to content

Instantly share code, notes, and snippets.

@arnehormann
arnehormann / test-rand.go
Last active August 26, 2015 17:49
benchmarks for possible implementations for github.com/golang/go/issues/6721
package main
import (
"math"
"testing"
)
const bits32 = 24
const step32 float32 = 1 / (1 << bits32)
const mask32 uint32 = (1 << bits32) - 1
package mysql
import (
"errors"
"fmt"
"runtime"
"time"
)
var trace = false
@arnehormann
arnehormann / brew-sigmavpn.rb
Created May 8, 2014 14:15
A (broken) brew for sigmavpn
require "formula"
class Sigmavpn < Formula
homepage "http://frozenriver.net/SigmaVPN"
url "https://codeload.github.com/neilalexander/sigmavpn/tar.gz/0.3alpha1"
sha1 "49020d4db52878756fbbc45c05c2deeedaa7b6d2"
head do
url 'https://github.com/neilalexander/sigmavpn.git'
end
func Path(v interface{}, ks ...interface{}) (reflect.Value, error) {
val := reflect.ValueOf(v)
for i, k := range ks {
switch key := k.(type) {
case string: // struct field
if val.Kind() != reflect.Struct {
return reflect.ValueOf(nil), fmt.Errorf("Error at %v[%d]: must be struct", ks, i)
}
val = val.FieldByName(key)
case reflect.Kind: // type
@arnehormann
arnehormann / mysql12f.sh
Last active August 29, 2015 14:02
Startup MySQL
#!/bin/bash
set -e -u -o pipefail
PWD=`pwd`
WHOAMI=`whoami`
BASEDIR=${MYSQL_SERVER_BASEDIR?missing MYSQL_SERVER_BASEDIR}
# default directories are subdirectories of where this script was run from
@arnehormann
arnehormann / repostats.sh
Created June 13, 2014 09:42
count LOC in .git folders per language
#!/bin/bash
set -e -u -o pipefail # -x
echo $'Project\tCommit\tBranch\tFiletype\tLines'
for dir in *.git; do
export GIT_DIR="$dir"
export PREFIX=$(git for-each-ref --count=1 --sort=committerdate --format=$'%(objectname)\t%(refname)')
export BRANCH=$(echo -e "${PREFIX}" | cut -d $'\t' -f 1)
##### from these filetypes #####
for filetype in java cs rb go py as php html htm css js json xml conf cnf; do
echo -n -e "${dir}\t${PREFIX}\t${filetype}\t"
package main
import (
"errors"
"fmt"
"os"
"time"
pipe "gopkg.in/pipe.v2"
)
@arnehormann
arnehormann / envflag-example.go
Last active August 29, 2015 14:10
Just an example for envflag (soon to be expanded at github.com/confactor/envflag)
// see http://godoc.org/github.com/arnehormann/goof/envflag
package main
import (
"fmt"
"io"
"os"
"sort"
"strings"
"text/tabwriter"
@arnehormann
arnehormann / int-ranges.go
Created December 4, 2014 09:26
Support code for tests in confactor/envflags
package main
import (
"fmt"
"io"
"math/big"
"os"
)
func generateIntBounds(w io.Writer) {