Skip to content

Instantly share code, notes, and snippets.

View lufia's full-sized avatar

KADOTA, Kyohei lufia

View GitHub Profile
@lufia
lufia / nix-cleanup.bash
Created February 13, 2017 01:20
cleanup nixpkgs generations except latest generation
#!/usr/bin/env bash
c=/nix/var/nix/profiles/per-user/$USER/channels
nix-env --delete-generations -p $c old
nix-env --delete-generations old
nix-store --gc
@lufia
lufia / .npmrc
Last active February 20, 2017 01:30
NodeJS settings
prefix = ~/pkg/nodejs
@lufia
lufia / doing.rc
Last active March 15, 2017 16:41
doing
#!/usr/bin/env rc
# usage: doing [-d yyyy-mm-dd] [message ...]
# ラベル
# 開始時間
# 終了時間
# (空行)
dir=$home/lib/doing
boundary=4 # 日付をまたぐ時間[0..$boundary][$boundary+1..23]
@lufia
lufia / golangkyoto1.md
Created April 30, 2017 06:56
「そうだGo、京都。」の参考リンクまとめ
@lufia
lufia / secstore-backup.bash
Last active July 24, 2017 01:24
use password from keychain into secstore
#!/usr/bin/env bash
sudo -p 'Password for %u:' bash -c "
cd $PLAN9/secstore
if [[ ! -d .git ]]
then
git init
git remote add origin git@ghe.fenrir-inc.com:$USER/secstore.git
fi
if [[ -z \$(git status -s) ]]
@lufia
lufia / 9load.md
Last active October 9, 2017 13:14
Plan 9のディスクブートメモ

Plan 9のブート

  1. ディスクからブートする場合、diskload.cのtrydiskboot()を呼ぶ
  2. trybootfile()でBoot構造体のstateはINITKERNELにセットされる
  3. fs.cのfsboot()でブートを開始する(最終的にカーネルの実行に移るので戻らない)
  4. fsboot()found 9pcflop.gz のようなメッセージを出力する
  5. カーネルを8KBずつ読み込み、bootpass()に渡す(bufはnon-nil)
@lufia
lufia / logger.go
Created November 14, 2017 10:19
verbose logger for gin framework
type responseWriter struct {
gin.ResponseWriter
buf bytes.Buffer
}
func (w *responseWriter) Write(b []byte) (int, error) {
w.buf.Write(b)
return w.ResponseWriter.Write(b)
}
@lufia
lufia / fields.bash
Created December 7, 2017 07:07
convert empty line separated key value pair files to table
#!/usr/bin/env bash
flagh=0
case $1 in
-h) flagh=1
shift
;;
-*) echo usage: $(basename $0) [-h] [file ...] >&2
exit 1
@lufia
lufia / goinstall.bash
Created December 20, 2017 08:42
Install go-gettable packages with temporary GOPATH
#!/usr/bin/env bash
# usage: goinstall [pkg ...]
if [[ -z $GOPATH ]]
then
echo $(basename $0): requires GOPATH >&2
exit 1
fi
IFS=: paths=($GOPATH)
@lufia
lufia / clw.bash
Last active February 5, 2018 04:32
clear window content of acme
#!/usr/bin/env bash
# ref https://groups.google.com/forum/#!topic/comp.os.plan9/dL9RQnlY6So
w=acme/$winid
echo -n Edit ,d | 9p write $w/body
echo -n /Edit ,d/ | 9p write $w/addr
echo -n 'dot=addr' | 9p write $w/ctl
9p read $w/addr | awk '{printf("MX%s %s\n", $1, $2)}' | 9p write $w/event