Skip to content

Instantly share code, notes, and snippets.

View rjeczalik's full-sized avatar
💭
defer sleep()

Rafal Jeczalik rjeczalik

💭
defer sleep()
View GitHub Profile
@rjeczalik
rjeczalik / golang-debug-utils.go
Last active August 29, 2015 14:01
Battle proven debugging utilities
package dbgutil
import (
"os"
"runtime"
"strings"
)
func stacktrace(max int) []string {
pc, stack := make([]uintptr, max), make([]string, 0, max)
@rjeczalik
rjeczalik / jobs-batch-remove.go
Created May 20, 2014 19:01
jobs-batch-remove.go
package main
import (
"fmt"
"sort"
)
type T string
func rm(t []T, idx []int) []T {
@rjeczalik
rjeczalik / gocompress.go
Created May 22, 2014 13:37
Command line interface to compress/* packages.
package main
import (
"compress/flate"
"compress/gzip"
"compress/lzw"
"compress/zlib"
"fmt"
"io"
"os"
@rjeczalik
rjeczalik / benchmark-go-bindata.md
Last active July 8, 2022 15:03
Benchmark of NFS directory traversing for n=1061 and depth=7 directory tree.

go-bindata benchmark

bind-all-the-things

Test was performed on $GOPATH over NFS share /mnt/nfs:

The NFS:

/mnt/nfs/ $ bonnie++ -d /mnt/nfs/bonnie -r 2048 -u rjeczalik
@rjeczalik
rjeczalik / main.go
Last active August 29, 2015 14:03
fixture: licstat/scheduler/queue_test.go
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
@rjeczalik
rjeczalik / main.go
Last active August 29, 2015 14:03
fixture: licstat/scheduler/all_test.go
package main
import (
"fmt"
"io"
"math/rand"
"os"
"strconv"
"text/template"
"time"
=== RUN TestScheduler-8
0: *scheduler.BarEvent=*scheduler.BarEvent: {Level=1, Priority=4}
1: *scheduler.BarEvent=*scheduler.BarEvent: {Level=4, Priority=6}
2: *scheduler.BarEvent=*scheduler.BarEvent: {Level=4, Priority=0}
0: *scheduler.FooEvent=*scheduler.FooEvent: {Level=4, Priority=4}
3: *scheduler.BarEvent=*scheduler.BarEvent: {Level=2, Priority=7}
1: *scheduler.FooEvent=*scheduler.FooEvent: {Level=4, Priority=3}
4: *scheduler.BarEvent=*scheduler.BarEvent: {Level=1, Priority=6}
2: *scheduler.FooEvent=*scheduler.FooEvent: {Level=0, Priority=1}
5: *scheduler.BarEvent=*scheduler.BarEvent: {Level=3, Priority=6}
@rjeczalik
rjeczalik / .plantuml.cfg
Created July 9, 2014 20:25
PlantUML exec script + skin configuration
skinparam {
monochrome true
defaultFontName Consolas
defaultFontSize 12
noteBackgroundColor #C0C0C0
noteFontName Courier
sequenceBoxBackgroundColor #EEEEEE
sequenceLifeLineBackgroundColor #DDDDDD
}
@rjeczalik
rjeczalik / gorelease
Created July 12, 2014 20:54
For building release archives + Markdown output.
#!/usr/bin/env bash
#
# Usage:
#
# ~ $ gorelease linux:windows 386:amd64 github.com/rjeczalik/bin/cmd/gobin
# ~/src/github.com/rjeczalik/bin/cmd/gobin $ gorelease linux:windows 386:amd64
die() {
if [ ! -z "${*}" ]; then
echo "gocross: ${*}" 1>&2
@rjeczalik
rjeczalik / misc-one-liners.md
Last active August 29, 2015 14:03
Misc one-liners.

Guessing import path for Go executables

~ $ go tool objdump -s main.main "$(which godoc)" \
    | grep -E '^TEXT main.main' | cut -d' ' -f3 \
    | sed -e 's/.*\/src\/\(.*\)\/[^\/]*/\1/'
code.google.com/p/go.tools/cmd/godoc

List all github.com packages the executable uses