sh/makefun
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* Description / これは何? [#b422f6d7]
Makes feces (FUN, 糞 as Japanese) that overlap as many a...
標準入力から受け取った数だけ重なった、糞を作ります。
#prism(bash){{{
$ echo 3 | makefun
(
(_)
(___)
$ echo 5 | makefun
(
(_)
(___)
(_____)
(_______)
}}}
* Usage / 使い方 [#xd130c62]
Install / インストール
#prism(bash){{{
$ (cd /tmp; wget https://gist.githubusercontent.com/kemas...
5e/makefun; chmod a+x makefun; sudo install makefun /usr/...
or
$ wget -O /tmp/makefun https://bit.ly/3zFmITB; chmod a+x ...
-- snip --
2021-09-02 10:35:34 (11.4 MB/s) - ‘makefun’ saved [183/183]
}}}
Draw / 描画する
#prism(bash){{{
$ echo 3 | makefun
(
(_)
(___)
}}}
Uninstall / アンインストール
#prism(bash){{{
$ sudo rm /usr/local/bin/makefun; hash -r
$ makefun
makefun: command not found
}}}
* server化 [#a3c2109c]
** start server / サーバ起動 [#i3c94484]
#prism(bash){{{
socat tcp-l:19876,reuseaddr,fork exec:/usr/local/bin/make...
}}}
** test / 動作確認 [#yb7dd612]
#prism(bash){{{
$ echo 5 | socat - tcp:localhost:19876
(
(_)
(___)
(_____)
(_______)
}}}
** Call from another host / 他のホストから呼び出し [#b9e9...
#prism(batch){{{
C:\>
echo 3 | wsl socat - tcp:172.27.195.99:19876
(
(_)
(___)
}}}
** stop server / サーバ停止 [#taa525d1]
#prism(bash){{{
kill %$(jobs | awk -F'[][]' '/19876/{print $2}') 2>/dev/n...
}}}
* Implimentation / 解説 [#pef04db4]
Goal / 肝となる部分
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(
(_)
(___)
(_____)
(_______)
}}}
** n から 1 まで、2n-1 個の下線を引く [#j19da82c]
Underline (2 * n - 1) from 'n' to 1
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say "_" x ($_*2-1)}'
_________
_______
_____
___
_
}}}
** N行目の先頭に N-1 個のスペースを入れる [#ye280a17]
Insert (N - 1) spaces at the beginning of the Nth line
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
_________
_______
_____
___
_
}}}
** 前後を括弧に置き換える [#wf3ae003]
Replace before and after with parentheses
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(_______)
(_____)
(___)
(_)
(
}}}
** ひっくり返す [#ka7aacef]
Turn over
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(
(_)
(___)
(_____)
(_______)
}}}
** 申し訳程度のサニタイジングやパラメータ制限を入れておく...
Put in minimum sanitizing and parameter restrictions
- tr -dc 0-9
- exit if ($_ > 100);
#prism(bash){{{
#!/bin/sh
tr -dc 0-9 |
perl -nE '
exit if ($_ > 100);
for($i=$_; $i>0; $i--){
say $s."_" x ($i*2-1);
$s.=" ";
}' |
sed 's/_/(/;s/_$/)/' |
tac
}}}
終了行:
* Description / これは何? [#b422f6d7]
Makes feces (FUN, 糞 as Japanese) that overlap as many a...
標準入力から受け取った数だけ重なった、糞を作ります。
#prism(bash){{{
$ echo 3 | makefun
(
(_)
(___)
$ echo 5 | makefun
(
(_)
(___)
(_____)
(_______)
}}}
* Usage / 使い方 [#xd130c62]
Install / インストール
#prism(bash){{{
$ (cd /tmp; wget https://gist.githubusercontent.com/kemas...
5e/makefun; chmod a+x makefun; sudo install makefun /usr/...
or
$ wget -O /tmp/makefun https://bit.ly/3zFmITB; chmod a+x ...
-- snip --
2021-09-02 10:35:34 (11.4 MB/s) - ‘makefun’ saved [183/183]
}}}
Draw / 描画する
#prism(bash){{{
$ echo 3 | makefun
(
(_)
(___)
}}}
Uninstall / アンインストール
#prism(bash){{{
$ sudo rm /usr/local/bin/makefun; hash -r
$ makefun
makefun: command not found
}}}
* server化 [#a3c2109c]
** start server / サーバ起動 [#i3c94484]
#prism(bash){{{
socat tcp-l:19876,reuseaddr,fork exec:/usr/local/bin/make...
}}}
** test / 動作確認 [#yb7dd612]
#prism(bash){{{
$ echo 5 | socat - tcp:localhost:19876
(
(_)
(___)
(_____)
(_______)
}}}
** Call from another host / 他のホストから呼び出し [#b9e9...
#prism(batch){{{
C:\>
echo 3 | wsl socat - tcp:172.27.195.99:19876
(
(_)
(___)
}}}
** stop server / サーバ停止 [#taa525d1]
#prism(bash){{{
kill %$(jobs | awk -F'[][]' '/19876/{print $2}') 2>/dev/n...
}}}
* Implimentation / 解説 [#pef04db4]
Goal / 肝となる部分
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(
(_)
(___)
(_____)
(_______)
}}}
** n から 1 まで、2n-1 個の下線を引く [#j19da82c]
Underline (2 * n - 1) from 'n' to 1
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say "_" x ($_*2-1)}'
_________
_______
_____
___
_
}}}
** N行目の先頭に N-1 個のスペースを入れる [#ye280a17]
Insert (N - 1) spaces at the beginning of the Nth line
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
_________
_______
_____
___
_
}}}
** 前後を括弧に置き換える [#wf3ae003]
Replace before and after with parentheses
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(_______)
(_____)
(___)
(_)
(
}}}
** ひっくり返す [#ka7aacef]
Turn over
#prism(bash){{{
$ echo 5 | perl -nE 'for(; $_>0; $_--){say $s."_" x ($_*2...
(
(_)
(___)
(_____)
(_______)
}}}
** 申し訳程度のサニタイジングやパラメータ制限を入れておく...
Put in minimum sanitizing and parameter restrictions
- tr -dc 0-9
- exit if ($_ > 100);
#prism(bash){{{
#!/bin/sh
tr -dc 0-9 |
perl -nE '
exit if ($_ > 100);
for($i=$_; $i>0; $i--){
say $s."_" x ($i*2-1);
$s.=" ";
}' |
sed 's/_/(/;s/_$/)/' |
tac
}}}
ページ名: