Skip to content

Instantly share code, notes, and snippets.

View hnakamur's full-sized avatar

Hiroaki Nakamura hnakamur

View GitHub Profile
@hnakamur
hnakamur / openssl-1.1.1h-apple-m1-mac-mini.log.md
Last active November 21, 2020 14:53
openssl speed -evp aes-128-ctr | aes-128-gcm | chacha20-poly1305 のApple M1 Mac miniでの結果
% sysctl -n hw.model
Macmini9,1
% /usr/libexec/PlistBuddy -c 'print :"CPU Names"' ~/Library/Preferences/com.apple.SystemProfiler.plist | awk -F ' = ' '{prevlast=last; last=$2} END{print prevlast}' 
Mac mini (M1, 2020)
@hnakamur
hnakamur / Dockerfile
Created June 11, 2020 00:27
Dockefile to build nginx-quic with BoringSSL on Ubuntu 20.04 LTS
FROM ubuntu:20.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install git mercurial build-essential cmake ninja-build golang-go zlib1g-dev libpcre3-dev
RUN git clone https://github.com/google/boringssl \
&& cd boringssl \
&& mkdir build \
&& cd build \
&& cmake -GNinja .. \
@hnakamur
hnakamur / test.py
Last active June 10, 2020 13:39
LXD REST API example via unix socket using python3 socket
#!/usr/bin/env python3
import socket
target_host = "localhost"
socket_path = "/var/snap/lxd/common/lxd/unix.socket"
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect(socket_path)
# send some data
@hnakamur
hnakamur / main.c
Created May 11, 2020 11:55
try to print time on every second on realtime clock
#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 March 24, 2020 10:06
output of "go tool cgo -debug-gcc -- -I include bls.go"
#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 March 6, 2020 00:25
Diff from github.com/getlantern/systray@6f0e5a3 to github.com/rupor-github/wsl-ssh-agent@a305054
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 February 15, 2020 01:52
example Japanese text which is not rendred properly on Windows Terminal
> スワップは遅くて非効率という意味で「悪」と考えられており、システムがスワップを定常的に使う必要があるのであれば、それは明らかに十分なメモリを持っていないということです。 […] > あなたの要求を全て処理するのに十分な RAM があり、それを超えることが絶対起こらないと言え るなら、スワップスペースなしでシステムを稼働することは完全に安全と言えるでしょう。
@hnakamur
hnakamur / console.log
Created January 4, 2020 14:50
Example for passing pre-allocated buf to hash.Sum(b []byte) in Go
$ 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 November 30, 2019 21:03
OpenResty lua split benchmarkを自分でも試してみた
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 November 25, 2019 20:22
Go test example for comparing JSON results
package foo
import (
"testing"
"github.com/nsf/jsondiff"
)
var jsondiffOpts = jsondiff.DefaultConsoleOptions()