Skip to content

Instantly share code, notes, and snippets.

@dustin
dustin / mut.go
Last active January 1, 2016 11:49
fuse bug
package main
import (
"io/ioutil"
"log"
"os"
"path/filepath"
)
func main() {
@dustin
dustin / avl.go
Last active December 31, 2015 07:49
word list -> BST JSON for a project I was working on
package main
import (
"bufio"
"encoding/json"
"fmt"
"io"
"log"
"os"
)
@dustin
dustin / massjoin
Created October 25, 2013 22:26
dehumanizing/rewriting/combining sizing stuff
#!/usr/bin/env python
import re
import string
import fileinput
import collections
abbrevs = (
(1<<50L, 'PB'),
(1<<40L, 'TB'),
@dustin
dustin / Dockerfile
Last active February 7, 2021 17:07
How I built couchbase 2.2 for docker
FROM ubuntu
MAINTAINER Dustin Sallings "dustin@spy.net"
ADD http://cbfs-ext.hq.couchbase.com/couchbase-dist/couchbase-server-enterprise_2.2.0_x86_64.deb /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb
RUN apt-get update
RUN apt-get install -y librtmp0 python-httplib2
RUN dpkg -i /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb
RUN rm /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb
RUN /etc/init.d/couchbase-server stop
@dustin
dustin / make-go-compilers
Last active December 20, 2015 22:39
my x-compile script
#!/bin/sh
hg purge -v --all
./make.bash
for os in darwin freebsd linux netbsd openbsd plan9 windows
do
for arch in 386 amd64 arm
do
env GOOS=$os GOARCH=$arch ./make.bash --no-clean
@dustin
dustin / ptar.go
Created July 19, 2013 05:49
I literally wrote this passing out. Seems to work. I've got a bunch of files in the format of something/yyyy-mm-dd-... and I want to make somethingelse/{yyyy}.tar files out of them. This does it.
package main
import (
"archive/tar"
"flag"
"io"
"log"
"os"
"path/filepath"
)
@dustin
dustin / progress.go
Last active December 19, 2015 16:18
Uploading a ton of stuff to S3, I decided I wanted something that would take this boring *os.File and give me a progress indicator. Here's the thing I threw together. Sends this sort of thing to stdout ('\r'ing over itself every second): 10MB/72MB (14.6%)
package main
import (
"fmt"
"io"
"os"
"time"
"github.com/dustin/go-humanize"
)
@dustin
dustin / bug2md
Last active December 19, 2015 13:29
cbugg-cli -T /tmp/bug2md -query='tags:cbfs AND status:(open OR new)' | pbcopy
{{ range $b := .}}# {{$b.Id}} - {{ $b.Title }}{{ range $t := $b.Tags }} [{{$t}}](http://cbugg.hq.couchbase.com/tag/{{$t}}){{end}}
{{ $b.Description }}
Original bug: [{{$b.Id}}](http://cbugg.hq.couchbase.com/bug/{{$b.Id}})
{{end}}
@dustin
dustin / results.txt
Last active December 19, 2015 09:59
Measuring `io.Writer` vs. `io.ReaderFrom`
BenchmarkNaiveWriter 10000000 157 ns/op 425060032.69 MB/s
BenchmarkAwesomeWriter 500 5721802 ns/op 11728.62 MB/s
BenchmarkDiscard 500 5735134 ns/op 11701.36 MB/s
@dustin
dustin / gist:5925577
Last active December 19, 2015 08:29
SIGINFO -- because awesome.
load: 5.23 cmd: cbfsclient 14765 running 17.08u 48.76s
00:15:00.098757 In-flight HTTP requests:
00:15:00.098816 servicing "http://192.168.1.97:8484/.cbfs/blob/f2f087a936fe8065f3fc9b19a4532340b085bbd1" for 23.842203119s
00:15:00.098840 servicing "http://192.168.1.97:8484/.cbfs/blob/b1c4fc4d3e95a7db30f5530efbf24877ae089da2" for 26.327956223s
00:15:00.098860 servicing "http://192.168.1.97:8484/.cbfs/blob/87faa6a364c7afbbeb7ea2f096f2eb03be31d8ed" for 27.054090798s
00:15:00.098881 servicing "http://192.168.1.97:8484/.cbfs/blob/d5c35b95137ac7be80f262963f27d3fb4691331b" for 25.977938698s
00:15:00.098901 servicing "http://192.168.1.97:8484/.cbfs/blob/7e5ec14b1490b12b5a59c4f114bfa51b16d43b5c" for 26.496670189s
00:15:00.098919 servicing "http://192.168.1.97:8484/.cbfs/blob/c8cd908912f929a724fa0b7604d5983e24c872dd" for 26.914814016s