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 / main.c
Created May 11, 2020
try to print time on every second on realtime clock
View main.c
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
const int sec_in_nsec = 1000000000;
#define ITERMAX 10000
typedef long long nanotime_t;
@hnakamur
hnakamur / bls.cgo2.c
Created Mar 24, 2020
output of "go tool cgo -debug-gcc -- -I include bls.go"
View bls.cgo2.c
#line 1 "cgo-builtin-prolog"
#include <stddef.h> /* for ptrdiff_t and size_t below */
/* Define intgo when compiling with GCC. */
typedef ptrdiff_t intgo;
#define GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; intgo n; } _GoString_;
typedef struct { char *p; intgo n; intgo c; } _GoBytes_;
@hnakamur
hnakamur / README.txt
Last active Mar 6, 2020
Diff from github.com/getlantern/systray@6f0e5a3 to github.com/rupor-github/wsl-ssh-agent@a305054
View README.txt
After I read https://github.com/rupor-github/wsl-ssh-agent/tree/a305054739d6ce1fa6261a8b4cb673df083b160e/systray
I was curious about modification made for systray bundled in wsl-ssh-agent and here are diffs.
@hnakamur
hnakamur / swap-myth.txt
Created Feb 15, 2020
example Japanese text which is not rendred properly on Windows Terminal
View swap-myth.txt
> スワップは遅くて非効率という意味で「悪」と考えられており、システムがスワップを定常的に使う必要があるのであれば、それは明らかに十分なメモリを持っていないということです。 […] > あなたの要求を全て処理するのに十分な RAM があり、それを超えることが絶対起こらないと言え るなら、スワップスペースなしでシステムを稼働することは完全に安全と言えるでしょう。
@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"
You can’t perform that action at this time.