Skip to content

Instantly share code, notes, and snippets.

View alf-ytakada's full-sized avatar
🏠
Working from home

Yuki Takada alf-ytakada

🏠
Working from home
View GitHub Profile
@alf-ytakada
alf-ytakada / main.go
Created January 11, 2022 07:58
nil has type, it can be a receiver.
package main
import "fmt"
type A struct {
a string
}
func NewA(strp *string) *A {
if strp == nil {
@alf-ytakada
alf-ytakada / benchmark.md
Created December 16, 2021 04:28
golang snappy encode/decode
$  go test -bench . -benchmem
goos: linux
goarch: amd64
pkg: a
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Benchmark_snappy_encode-8                        8189756               145.9 ns/op           176 B/op          1 allocs/op
Benchmark_snappy_decode-8                       14360095                77.73 ns/op          112 B/op          1 allocs/op
Benchmark_snappy_decode_and_json_unmarshal-8      211792              5511 ns/op            2128 B/op         32 allocs/op
Benchmark_json_unmarshal-8 234332 4878 ns/op 2016 B/op 31 allocs/op
@alf-ytakada
alf-ytakada / config.yml
Created April 21, 2020 08:48
envoyをstandaloneで動かしてみる
# CentOS7へのインストール
# https://www.getenvoy.io/install/envoy/centos/
# config参考
# https://qiita.com/TokyoYoshida/items/8f614dc5051926bda605
# https://i-beam.org/2019/02/03/envoy-static-load-balancer/
# このコンフィグを、下記コマンドで動かそうとすると、
# $ envoy --config-yaml config.yml
# error initializing configuration '': Unable to convert YAML as JSON: config.yml
# と言われてしまったので、jsonに変換して動かす。
# $ envoy -c config.json
@alf-ytakada
alf-ytakada / nginx.conf
Created July 5, 2019 14:00
UDP proxy nginx config
worker_processes 1;
# worker_rlimit_nofile 65535;
events {
worker_connections 10240;
}
error_log logs/error.log;
pid logs/nginx.pid;

vscodeのオススメ拡張

  • prettierのキーバインド
Usage
Using Command Palette (CMD/CTRL + Shift + P)
1. CMD + Shift + P -> Format Document
OR
import (
"bufio"
"fmt"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintln(os.Stderr, "Usage: go run main.go filename")
@alf-ytakada
alf-ytakada / keybindings.json
Created February 26, 2017 06:46
vscode emacsのカーソル移動が可能な設定。 vimプラグイン導入済み
// 既定値を上書きするには、このファイル内にキー バインドを挿入します
[
{ "key": "ctrl+d", "command": "deleteRight",
"when": "editorTextFocus && !editorReadonly" },
{ "key": "ctrl+h", "command": "deleteLeft",
"when": "editorTextFocus && !editorReadonly" },
{ "key": "ctrl+f", "command": "cursorRight",