Skip to content

Instantly share code, notes, and snippets.

View hnakamur's full-sized avatar

Hiroaki Nakamura hnakamur

View GitHub Profile
@hnakamur
hnakamur / main.go
Created September 27, 2019 19:11
go exponential random distribution example
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 18:46
cytoscape network weathermap experiment
<!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/[email protected]/cytoscape-automove.js"></script>
<style>
#cy {
position: absolute;
@hnakamur
hnakamur / main.go
Created March 9, 2018 03:15
a go example for waiting file lock, based on github.com/lomik/go-carbon
package main
import (
"flag"
"fmt"
"log"
"os"
"syscall"
"time"
)
@hnakamur
hnakamur / index.html
Created September 18, 2017 02:20
await in loop experiment
<!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 10:46
badger, goleveldb, boltdb benchmark
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
@hnakamur
hnakamur / benchmark_test.go
Created July 21, 2017 11:51
benchmark of github.com/ybubnov/go-uuid and github.com/google/uuid
package main
import (
"testing"
"github.com/google/uuid"
linuxuuid "github.com/ybubnov/go-uuid"
)
func BenchmarkLinuxKernelUUIDv4(b *testing.B) {
@hnakamur
hnakamur / etcd-config-memo.md
Last active July 3, 2017 08:58
etcd v3の設定メモ

etcd01:/etc/etcd/etcd.yaml

debug: true
name: etcd01
data-dir: /var/lib/etcd
initial-advertise-peer-urls: https://10.155.92.228:2380
listen-peer-urls: https://10.155.92.228:2380
advertise-client-urls: https://10.155.92.228:2379
listen-client-urls: https://10.155.92.228:2379
@hnakamur
hnakamur / index.html
Last active April 10, 2020 01:50
Noto Sans CJK JP local font and webfont experiment
<!DOCTYPE html>
<meta charset="utf-8">
<style>
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 300;
src: local("Noto Sans CJK JP"),
/* NOTE: you need to use v5 (not v6) to have effect of font-feature-settings: "palt" */
url(//fonts.gstatic.com/ea/notosansjapanese/v5/NotoSansJP-Light.woff2) format('woff2'),
@hnakamur
hnakamur / memo.txt
Created June 23, 2017 00:32
trafficserverでis_response_cacheableの呼び出し元をたどるコードリーディング
対象バージョンは6.2.0
bool
HttpTransact::is_response_cacheable(State *s, HTTPHdr *request, HTTPHdr *response)
の実装
https://github.com/apache/trafficserver/blob/6.2.0/proxy/http/HttpTransact.cc#L6127
is_response_cacheable の検索結果
```
@hnakamur
hnakamur / go-carbon-carbonapi-grafana-setup-memo.txt
Last active November 3, 2019 18:43
go-carbon with built-in carbonserver enabled, carbonapi and grafana setup memo
# setup go
curl -sS https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz | tar zxf - -C /usr/local
export PATH=/usr/local/go/bin:$HOME/go/bin:$PATH
yum install -y make git
# setup go-carbon
go get -d github.com/lomik/go-carbon
cd $HOME/go/src/github.com/lomik/go-carbon