ミニマリストのコーディングスタイル(Perl)
- 寿命の短すぎる変数を使わない
# before
$filename='/foo/bar/config.txt';
open(FP, '<', $filename) || die $@;
#
# after
open(FP, '<', '/foo/bar/config.txt') || die $@;
from m5stack import * | |
from m5ui import * | |
from uiflow import * | |
import time | |
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]) | |
list = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] | |
def push_five(x): |
// Amazon で使った金額の合計を出す奴 | |
// | |
// 使い方: | |
// 1. 全部コピーする (右上の Raw をクリックした先でやるのが楽) | |
// 2. Amazon の注文履歴ページ ( https://www.amazon.co.jp/gp/css/order-history/ ) を開く | |
// 3. F12 または 右クリ→要素の検証 とかで出てくる開発者ツールのコンソール (JavaScript REPL) にペースト | |
// 4. エンターで実行 | |
// (Firefox はなんか allow pasting とタイプしろみたいなことを言われるので従う) | |
// 5. しばらく待つと alert で合計金額を表示 | |
// |
sync: | |
kill -0 `tail -1 sync.pid` || $(MAKE) sync_do | |
sync_do: | |
ps -p $$$$ -o ppid > sync.pid | |
rsync -auz /opt/data remotesite:/opt/remote-data/ | |
clean: |
LIST=cat dog horse cow | |
do_it: | |
@LIST="$(LIST)";\ | |
for x in $$LIST; do\ | |
touch $$x ;\ | |
done |
%data = map { shift @$_, $_ } map { [ split(/,\s*/, $_) ]} split(/\n/, $contents); |
#!/usr/bin/perl | |
$|=1; | |
while(<>){ | |
open(PIPE, "|/usr/bin/curl --data-urlencode source\@- https://idobata.io/hook/.......") || next; | |
print PIPE $_; | |
close(PIPE); | |
} |
#!/usr/bin/perl -s | |
# photohop 等で作成するpng には | |
# 長さ0のIDAT チャンクが作成される事がある | |
# ImageMagick等でエラーとなり読み込めない事があるので取り除く | |
# | |
$src = shift || usage(); | |
$dst = shift || usage(); | |
sub usage { | |
print "Remove IDAT chunk of size 0\n"; |
ミニマリストのコーディングスタイル(Perl)
# before
$filename='/foo/bar/config.txt';
open(FP, '<', $filename) || die $@;
#
# after
open(FP, '<', '/foo/bar/config.txt') || die $@;
mt_rand(); // より良い乱数
VectorからTeraTermをダウンロードします。
http://www.vector.co.jp/soft/win95/net/se320973.html
接続する時には次の項目を指定する。
通常のssh接続の場合は括弧内を指定する