Skip to content

Instantly share code, notes, and snippets.

@bmatsuo
bmatsuo / whatcd_singleep_of_the_w.user.js
Created October 10, 2010 02:12
Single/EP of the week that looks like the Featured Album box.
// ==UserScript==
// @name What.cd Single/EP of the Week
// @namespace http://google.com
// @description See the latest Single/EP of the week on the what.cd homepage.
// @include http*://*what.cd/index.php
// ==/UserScript==
//Thanks to dieselpowered for making it more like the Featured Album box!
function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
@bmatsuo
bmatsuo / popenrunner.rb
Created September 8, 2011 23:37
Windows capable PopenRunner subclass for the handbrake ruby gem.
require "rubygems"
require "handbrake"
require 'rbconfig'
$on_mswin = Config::CONFIG['target_os'].match(/^mingw/)
require 'win32/open3' if $on_mswin
class MyRunner < HandBrake::CLI::PopenRunner
def command(args)
return super if !$on_mswin
@bmatsuo
bmatsuo / desired_test.go
Created January 10, 2012 05:58
Golang "testing" file:line prefix
package main
import (
"fmt"
"path/filepath"
"runtime"
"testing"
)
func flushTestConnections() {}
@bmatsuo
bmatsuo / vmsetup.sh
Last active December 28, 2015 04:59
#!/bin/env bash
# usage: bash <(curl https://gist.github.com/bmatsuo/7446833/raw)
sudo apt-get update
sudo apt-get install ssh git curl vim
git clone git@github.com:bmatsuo/home.git
bash -c 'cd home && bash install.sh'
// The trouble with specialized map types... I need a better name.
package main
import "fmt"
type I interface {
M()
}
type IFunc func()
@bmatsuo
bmatsuo / opendbi.go
Created June 11, 2014 19:11
This results in a runtime panic "opening dbi :MDB_BAD_VALSIZE: Too big key/data, key is empty, or wrong DUPFIXED size"
package main
import (
"log"
"os"
mdb "github.com/szferi/gomdb"
)
func main() {
@bmatsuo
bmatsuo / README.md
Last active August 29, 2015 14:04
go-snappystream benchmark comparisons for branch bmatsuo:snappy-go/optimize

Benchmarks were given two seconds to run. Allocations were recorded for each benchmark.

go test -test.benchtime=2s -test.benchmem=true -run=NONE -bench=. > [old,new].bench.txt

Benchmarks are compared with benchcmp

benchcmp old.bench.txt new.bench.txt

@bmatsuo
bmatsuo / snappy-go-index.err
Created September 8, 2014 01:55
This gist demonstrates several panics in the snappy-go package resulting from passing the Decode function malformed input. The snappy-go rev is 12e4b4183793, current at the time these tests were run.
panic: runtime error: index out of range
goroutine 16 [running]:
runtime.panic(0x4b9d80, 0x546cbc)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
code.google.com/p/snappy-go/snappy.Decode(0x0, 0x0, 0x0, 0x7f713339ceb5, 0xb, 0xb, 0x0, 0x0, 0x0, 0x0, ...)
/home/bryan/src/code.google.com/p/snappy-go/snappy/decode.go:49 +0xb0c
main.main()
/home/bryan/src/github.com/bmatsuo/sandbox/snappy-go-panic/snappy-go-index/main.go:11 +0x9c
@bmatsuo
bmatsuo / bench.old.txt
Last active August 29, 2015 14:10
Reader benchmarks from the master branch (9438ff5)
PASS
BenchmarkReaderManpage 1000000 20223 ns/op 126.09 MB/s
BenchmarkReaderManpage_buffered 1000000 20176 ns/op 126.39 MB/s
BenchmarkReaderManpageNoCopy 1000000 20179 ns/op 126.36 MB/s
BenchmarkReaderJSON 50000 320459 ns/op 76.23 MB/s
BenchmarkReaderJSON_buffered 50000 332016 ns/op 68.00 MB/s
BenchmarkReaderJSONNoCopy 50000 334736 ns/op 67.45 MB/s
BenchmarkReaderRandom 10000 1859415 ns/op 5640.66 MB/s
BenchmarkReaderRandom_buffered 10000 1837270 ns/op 5707.95 MB/s
BenchmarkReaderRandomNoCopy 10000 2782352 ns/op 3769.13 MB/s
@bmatsuo
bmatsuo / bench.new.txt
Last active August 29, 2015 14:10
without inlining the copyWriter struct literal
PASS
BenchmarkReaderManpage 1000000 19525 ns/op 130.60 MB/s
BenchmarkReaderManpage_buffered 1000000 19605 ns/op 130.07 MB/s
BenchmarkReaderManpageNoCopy 1000000 19686 ns/op 129.53 MB/s
BenchmarkReaderJSON 50000 314747 ns/op 77.61 MB/s
BenchmarkReaderJSON_buffered 50000 330732 ns/op 68.27 MB/s
BenchmarkReaderJSONNoCopy 50000 332856 ns/op 67.83 MB/s
BenchmarkReaderRandom 10000 1893232 ns/op 5539.91 MB/s
BenchmarkReaderRandom_buffered 10000 1842477 ns/op 5691.82 MB/s
BenchmarkReaderRandomNoCopy 10000 2765457 ns/op 3792.16 MB/s