Skip to content

Instantly share code, notes, and snippets.

@nobonobo
nobonobo / makecert.sh
Last active September 29, 2016 07:30
1行でオレオレ証明書を作る
go run $(go env GOROOT)/src/crypto/tls/generate_cert.go --host localhost
@nobonobo
nobonobo / server.py
Created February 16, 2016 05:33
python3でwebsocketsでjsonrpcのサンプル
import asyncio
import websockets
from websockets.exceptions import ConnectionClosed
from jsonrpc import JSONRPCResponseManager, dispatcher
@dispatcher.add_method
def hello(*params):
return 'hello'+repr(params)
@nobonobo
nobonobo / goroutinebench.go
Created February 18, 2016 02:59
バージョン別にgoroutineの中の処理が始まる遅延とgoステートメントの次の処理が始まる遅延を測ってみた。
package main
import (
"fmt"
"sync"
"time"
)
func BenchmarkGo(n int) time.Duration {
ch := make(chan time.Duration, n)
@nobonobo
nobonobo / dvl-build.sh
Created March 26, 2016 07:16
delveのインストール&セットアップ
xcode-select --install
go get -d github.com/derekparker/delve
# dlv-certという名前でコード署名証明書の作成とコード署名として常に信頼する。
cd $GOPATH/src/github.com/derekparker/delve
GO15VENDOREXPERIMENT=1 CERT=dlv-cert make install
sudo killall taskgated
dlv debug
@nobonobo
nobonobo / main.go
Created March 29, 2016 10:40
httpクライアントBodyの読み残し問題
package main
import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
# docker の GC 以下のコマンドをsystemdのtimerか、crondにセット
$(docker ps -f status=exited -q) | xargs -r docker rm; $(docker images --filter "dangling=true" -q) | xargs -r rmi
# go-1.6.2 をdocker経由で使う。本物と違うのは$PWDより親フォルダにアクセスできない(/tmpも)
alias go='docker run -it -v $PWD:$PWD -w $PWD golang:1.6.2-alpine go'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nobonobo
nobonobo / install.sh
Created June 14, 2016 08:26
CentOS等に素早くPython3.5をインストールする
curl -sL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh > /tmp/install.sh
sudo bash /tmp/install.sh -b -p /opt/python
echo "PATH=/opt/python/bin:\$PATH" >> ~/.bashrc
@nobonobo
nobonobo / docker-tags.sh
Last active September 29, 2016 06:09
dockerリポジトリのtag一覧を引くツール
#!/bin/sh
user=$(dirname $1 | sed 's|\.|library|')
name=$(basename $1)
curl -sL https://registry.hub.docker.com/v2/repositories/$user/$name/tags | jq -r '.results[].name'
@nobonobo
nobonobo / staticbuild.sh
Created June 23, 2016 03:19
golang muslスタティックリンク
sudo pacman -S musl
CC=/usr/bin/musl-gcc go build --ldflags '-linkmode external -extldflags "-static"' sample.go
ldd sample
動的実行ファイルではありません