This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding:utf-8 | |
| import functools | |
| import time | |
| # 関数をメモ化します | |
| # すべての引数はハッシュ可能でなければなりません | |
| def memoize(f): | |
| memo = {} # キャッシュ | |
| @functools.wraps(f) # 関数fのメタ情報(定義名やパラメタなど)を関数gに引き継ぐ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hss() { | |
| conf="$HOME/.ssh/$1.config" # ~/.ssh/なまえ.config としてconfigを配置しておく | |
| case $# in | |
| 1) # configに定義されているホスト一覧 | |
| awk '/^Host/{print$2}' $conf | column | |
| ;; | |
| 2) # ホストに接続 | |
| ssh -F $conf $2 | |
| ;; | |
| *) # つかいかた |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while true; do (echo "HTTP/1.0 200 OK";echo;echo;echo "meow.") | nc -l 10000; [ $? -ne 0 ] && break; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for x in 0 1 4 5 7 8; do for i in $(seq 30 37); do for a in $(seq 40 47); do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| oneTimeSetUp() | |
| { | |
| echo oneTimeSetUp | |
| } | |
| oneTimeTearDown() | |
| { | |
| echo oneTimeTearDown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| E0="ズン";E1="ドコ";while :;do eval echo "\$E$(($(od -vAn -N1 -tu4</dev/random)%2))";done|awk '{print}/ズン/{z++}/ドコ/{if(4<=z){print"キ・ヨ・シ!";exit(0)};z=0}'|tr '\n' ' ';echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { echo '2016/03/21' '振替休日'; | |
| curl -s http://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv | | |
| nkf | | |
| gtail -n+3 | | |
| gawk -F',' '$2{print$2,$1}{fflush()}' | | |
| while read d s; do echo "$(gdate -d"$d" +'%Y/%m/%d') $s"; done; | |
| gseq 20160101 20161231 | | |
| gdate -f - +'%Y/%m/%d %w' 2> /dev/null | | |
| gawk '$2=="0"{print$1,"日曜日"}$2=="6"{print$1,"土曜日"}{fflush()}'; | |
| } | gsort -k1,1 -u |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Mac | |
| brew install xz coreutils findutils homebrew/dupes/diffutils homebrew/dupes/grep gnu-sed gawk gnu-tar parallel nkf jq nmap openssl | |
| $(brew --prefix coreutils)/libexec/gnubin | |
| $(brew --prefix findutils)/libexec/gnubin | |
| $(brew --prefix gnu-sed)/libexec/gnubin | |
| $(brew --prefix gawk)/bin | |
| # Other | |
| # GNU Parallel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defaults write -g InitialKeyRepeat -int 12 | |
| defaults write -g KeyRepeat -int 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nkf timelog.csv | awk -v Date="2016/05/23" -F',' 'BEGIN{OFS="\t"}$2==Date{print$1,$4,$5,$6;d=$2;h+=$7;l++}END{;print l" Rows";print h"[h]",h/8"[day/man]";print d}' | tail -r | tee >(tail -n+4 | pbcopy) | |
| pbpaste | sed -E -e $'s/^[\t\s]*//' | awk -F'\t' '$2~/[0-9]{4}\/[0-9]{2}\/[0-9]{2}/' | awk -F'\t' '{k=$2;gsub(/\//,"",k);d[k]=$2;r[k]=r[k]$1"\t"$4"\t"$5"\t"$6"\n";h[k]+=$7;l[k]++}END{OFS="\t";for(k in d){print d[k],h[k]"[h]",h[k]/8"[day/man]",l[k]" Rows";print r[k]}}' |