Skip to content

Instantly share code, notes, and snippets.

Hiroaki Nakamura hnakamur

Block or report user

Report or block hnakamur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hnakamur
hnakamur / console.log
Created Jan 4, 2020
Example for passing pre-allocated buf to hash.Sum(b []byte) in Go
View console.log
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
BenchmarkHashNewSum-2 5807700 205 ns/op 112 B/op 2 allocs/op
BenchmarkHashNewSum2-2 8323488 142 ns/op 0 B/op 0 allocs/op
BenchmarkHashSum-2 8817842 134 ns/op 0 B/op 0 allocs/op
BenchmarkHashSum2-2 7696573 155 ns/op 16 B/op 1 allocs/op
PASS
ok _/home/hnakamur/hash-benchmark 5.402s
$ go version
@hnakamur
hnakamur / Dockerfile
Created Nov 30, 2019
OpenResty lua split benchmarkを自分でも試してみた
View Dockerfile
FROM openresty/openresty:1.15.8.1-3-alpine-fat
ADD nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
@hnakamur
hnakamur / foo_test.go
Created Nov 25, 2019
Go test example for comparing JSON results
View foo_test.go
package foo
import (
"testing"
"github.com/nsf/jsondiff"
)
var jsondiffOpts = jsondiff.DefaultConsoleOptions()
@hnakamur
hnakamur / delete-vm.ps1
Last active Oct 30, 2019
Launch Ubuntu bionic VM with Hyper-V
View delete-vm.ps1
$VMName = "Ubuntu Test"
# Delete the VM if it is around
If ((Get-VM -Name $VMName).Count -gt 0) {stop-vm $VMName -TurnOff -Confirm:$false -Passthru | Remove-VM -Force}
@hnakamur
hnakamur / bench_test.go
Created Oct 3, 2019
Go benchmark StringBuilder with Fprintf
View bench_test.go
package main
import (
"fmt"
"strconv"
"strings"
"testing"
)
func dummy(s string) {}
@hnakamur
hnakamur / main.go
Created Sep 27, 2019
go exponential random distribution example
View main.go
package main
import (
crand "crypto/rand"
"encoding/binary"
"fmt"
"time"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/stat/distuv"
@hnakamur
hnakamur / index.html
Last active May 27, 2019
cytoscape network weathermap experiment
View index.html
<!DOCTYPE>
<html>
<head>
<title>network weathermap demo using cytoscape.js</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>
<script src="https://unpkg.com/cytoscape-automove@1.10.1/cytoscape-automove.js"></script>
<style>
#cy {
position: absolute;
@hnakamur
hnakamur / main.go
Created Mar 9, 2018
a go example for waiting file lock, based on github.com/lomik/go-carbon
View main.go
package main
import (
"flag"
"fmt"
"log"
"os"
"syscall"
"time"
)
@hnakamur
hnakamur / index.html
Created Sep 18, 2017
await in loop experiment
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Async await loop experiment</title>
<script>
function foo(i) {
return new Promise((resolve, reject) => {
console.log('foo', i);
resolve();
@hnakamur
hnakamur / memo.md
Last active May 27, 2019
badger, goleveldb, boltdb benchmark
View memo.md
hnakamur@express:~/go/src/github.com/zchee/go-benchmarks/db$ go test -count=10 -run='^$' -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/zchee/go-benchmarks/db
BenchmarkGetBadger-2             5000000               399 ns/op          22.50 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               390 ns/op          23.04 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               390 ns/op          23.03 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               391 ns/op          22.97 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               391 ns/op          22.96 MB/s          40 B/op          2 allocs/op
You can’t perform that action at this time.