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 / openresty-1.11.2.1-nginx-github.diff
Created Nov 9, 2016
diff between nginx 1.11.2 on github and nginx in openresty 1.11.2.1
View openresty-1.11.2.1-nginx-github.diff
diff -ruN -x '*.orig' nginx-1.11.2/README openresty-srpm/openresty-1.11.2.1/bundle/nginx-1.11.2/README
--- nginx-1.11.2/README 1970-01-01 00:00:00.000000000 +0000
+++ openresty-srpm/openresty-1.11.2.1/bundle/nginx-1.11.2/README 2016-08-25 00:20:57.000000000 +0000
@@ -0,0 +1,38 @@
+This is an Nginx fork that adds dtrace USDT probes.
+
+Installation:
+
+ ./configure --with-dtrace-probes \
+ --with-dtrace=/usr/sbin/dtrace \
@hnakamur
hnakamur / main.go
Created Nov 9, 2016
An Go example to read a rational number from yaml.
View main.go
package main
import (
"log"
"math/big"
"os"
"gopkg.in/yaml.v2"
"github.com/pkg/errors"
@hnakamur
hnakamur / tree.go
Created Oct 29, 2016
list directory contents like tree command in Go
View tree.go
package main
import (
"flag"
"fmt"
"io"
"os"
"path/filepath"
"sort"
"strings"
@hnakamur
hnakamur / main.go
Last active Sep 29, 2016
Validate certificate key pair and hostname in Go
View main.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"log"
"golang.org/x/net/idna"
@hnakamur
hnakamur / main.go
Created Sep 19, 2016
parse JSON field which may be string or number in Go
View main.go
package main
import (
"bytes"
"encoding/json"
"fmt"
)
func main() {
data := `[
@hnakamur
hnakamur / main.go
Last active Sep 5, 2016
An example of using github.com/fedesog/webdriver
View main.go
package main
import (
"github.com/fedesog/webdriver"
)
func main() {
chromeDriver := webdriver.NewChromeDriver("/usr/local/bin/chromedriver")
err := chromeDriver.Start()
if err != nil {
@hnakamur
hnakamur / lxd-bridge-release-all-unused-addresses.sh
Last active Aug 11, 2016
Release all unused addresses of lxd-bridge DHCP
View lxd-bridge-release-all-unused-addresses.sh
#!/bin/sh
set -eu
# Set value of LXD_BRIDGE
. /etc/default/lxd-bridge
addr_list_file=/tmp/lxd-addr-list.`date +%Y-%m-%dT%H:%M:%S`
lxc list | awk '$4=="RUNNING"{print $6}' > $addr_list_file
cleanup() {
rm $addr_list_file
@hnakamur
hnakamur / multi_lxc
Created Jul 13, 2016
tmuxで複数のLXDコンテナ用にペインを開いて同時にキー入力するスクリプト
View multi_lxc
#!/bin/bash
# copied from http://tech.naviplus.co.jp/2014/01/09/tmux%E3%81%A7%E8%A4%87%E6%95%B0%E3%82%B5%E3%83%BC%E3%83%90%E3%81%AE%E5%90%8C%E6%99%82%E3%82%AA%E3%83%9A%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3/
# and modified for LXD
if [ -n "$SESSION_NAME" ];then
session=$SESSION_NAME
else
session=multi-lxc-`date +%s`
fi
@hnakamur
hnakamur / define_example.lua
Created Jul 2, 2016
cofuで独自リソースを定義する例
View define_example.lua
define "my_resource" {
version = "default_version",
foo = "default_foo",
bar = "deafult_bar",
function(attrs)
print("hello my_resource")
for k, v in pairs(attrs) do
print("k=" .. tostring(k) .. ", v=" .. tostring(v))
end
end,
View cryptorand_test.go
package main_test
import (
"crypto/rand"
"runtime"
"testing"
)
func BenchmarkBaseline(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
You can’t perform that action at this time.