Skip to content

Instantly share code, notes, and snippets.

View greymd's full-sized avatar
😉
Nanchatte

Yasuhiro Yamada greymd

😉
Nanchatte
View GitHub Profile
@greymd
greymd / test.sh
Created February 13, 2017 01:10
VimShell-gei study
$ seq 10 | vim - -es +'2,4!xargs' +'4,6!awk "\$0=\$0*2" | xargs' +'$!gfactor' +%p +q! | sed 1d
@greymd
greymd / gist:4483de16fe563d8ee8c2b57c1a247fc7
Last active February 28, 2017 15:48
Build curl on Linux
# CentOS
$ yum install autoconf automake libtool libtool-ltdl openssl-devel tar
$ curl -sL https://github.com/curl/curl/archive/curl-7_20_0.tar.gz | tar zxv
$ cd curl-curl-7_20_0/
$ ./buildconf
$ ./configure --enable-libcurl-option
$ make && make install
# Ubuntu
$ apt-get update
$ git tag | grep -E 'curl-[0-9]+_[0-9]+_[0-9]$' | awk -F'_' '{if(!a[$1_$2]){print} a[$1_$2]++}' | tr '_' ' ' | sort -k1,1n -k2,2n -k3,3n | tr ' ' '_'
curl-7_1_1
curl-7_4_1
curl-6_5_1
curl-7_5_2
curl-7_6_1
curl-7_7_1
curl-7_8_1
curl-7_9_1
curl-7_10_1
@greymd
greymd / versions.sh
Last active March 8, 2017 11:17
bash & zsh versions
$ curl -so- https://ftp.gnu.org/gnu/bash/ | perl -nle '/(bash-.*?tar.gz)/ and print $1' | grep -v doc | uniq
bash-1.14.7.tar.gz
bash-2.0.tar.gz
bash-2.01.1.tar.gz
bash-2.01.tar.gz
bash-2.02.1.tar.gz
bash-2.02.tar.gz
bash-2.03.tar.gz
bash-2.04.tar.gz
bash-2.05.tar.gz
@greymd
greymd / tree_full_path.md
Last active March 13, 2017 07:42
convert tree result to have full path.

tree -f でいいじゃんという話。

$ tree test | awk 'NF{depth=gsub("[│├└]","&",$0); if(last_depth < depth){dirs[depth]=last_dir;}else if(last_depth > depth){dirs[last_depth]="";} last_dir=$NF;last_depth=depth;pdir=".";for (i in dirs){pdir=pdir"/"dirs[i];} gsub("/$","",pdir);$NF=pdir"/"$NF;print}' | sed '$d'

Preparation

$ mkdir test/{aaa,bbb}
$ touch test/aaa/{aaa1,aaa2,aaa3}
@greymd
greymd / cure.glue
Created March 27, 2017 13:37
cure.glue
import /usr/bin/ as ub
proc cure = /usr/local/bin/docker 'run' '-i' 'greymd/cureutils' 'cure' argv[1]
proc cure_date_stdin = /usr/local/bin/docker 'run' '-i' 'greymd/cureutils' 'cure' 'date' '-f' '-' argv[1]
ub.seq '1' '365' >>=
ub.sed 's/$/ days ago/' >>=
this.cure_date_stdin '+%F @P' >>=
this.cure 'grep' >>=
ub.sed 's|/.*$||' >>= ub.head
@greymd
greymd / shifts.md
Created April 20, 2017 12:09
shift within multiple functions with bash
parse1() {
    echo "$1"
    shift
    parse2 "$@"
    echo "$1"
}

parse2() {
 echo "$1"
@greymd
greymd / gist:873a66a45a42858706452fb81227da2c
Last active April 24, 2017 10:42
最初に見つけた3つの言葉が「あなたが人生で手に入れたいもの」(https://goo.gl/SVT1Cs)
て た ぎ う な し む ぞ あ ふ こ う じ ぷ ど
く ぴ ど か の ご う ぱ ご に つ も さ が あ
ぞ ん き ぼ う ふ こ と お く め ゆ い を い
が ざ か ね よ ぽ う ぶ し や ん う り く よ
た と ふ す め き ぴ さ な ま び え ん ふ ず
づ ん ち よ せ い こ う ぎ ゆ ね つ な ん お
せ き さ ゆ ぶ は ぐ つ す わ か さ じ し く
ぬ い そ う い め つ は ま り ち い こ ね よ
お ぷ じ ふ う あ こ け う る せ ど し あ う
へ い わ つ そ ど ち よ ん い ろ う ぷ ん り
@greymd
greymd / dir_permission.md
Last active April 26, 2017 11:48
書き込みと読み込み権限のみを持ったディレクトリ(rw-)ってどんな動作すんの?

読み込み、書き込み権限のみで、実行権限がない状態のディレクトリ(drw-)の動作が気になったのでメモ。色々検索してもこのケースは無かったので。 そもそも、wがついててxがついてないディレクトリってみないなと思ったので。

環境

Dockerコンテナで検証 イメージはubuntu:16.04

先に結論

@greymd
greymd / setu.bash
Last active May 1, 2017 05:15
difference between "${1+$@}" and ${1+"$@"}
#!/bin/bash
set -u
argtest() {
printf '$@: '
echo "$@"
printf '$# '
echo $#
printf '$1 '
echo $1 ;shift