Skip to content

Instantly share code, notes, and snippets.

@akanehara
akanehara / range.pl
Created December 2, 2016 06:12
長さと分割数から範囲のリストを生成(Perl)
#!/usr/bin/perl
# 長さと分割数から範囲のリストを生成します
#
# 例: 長さ100を5区間に
# $ range.pl 100 5
# 1 0 19 │
# 2 20 39 │
# 3 40 59 │
# 4 60 79 │
@akanehara
akanehara / interval.pl
Last active November 16, 2016 05:17
指定時間間隔で任意コマンドを繰り返し実行する(コマンド実行時間が次の周期にさしかかった場合はスキップする)
#!/usr/bin/perl
# 指定時間間隔で任意コマンドを繰り返し実行する(コマンド実行時間が次の周期にさしかかった場合はスキップする)
use strict;
use warnings;
use POSIX ":sys_wait_h";
my $interval = shift @ARGV;
@akanehara
akanehara / traverse-yaml.pl
Last active October 25, 2016 02:27
YAMLのノードをトラバース
#!/usr/bin/perl
use strict;
use warnings;
use YAML;
use File::Basename 'basename', 'dirname';
sub usage {
my $script = basename $0;
@akanehara
akanehara / A.pm
Last active August 2, 2018 10:04
ミニマルなPerlのOOメモ (B extends A)
package A;
use strict;
use warnings;
#use fields();
sub new {
my $class = shift;
my $self = {
echo 'echo-sd --center "PlayStation®VR発売まで" "あと$((($(gdate +%s -d '\''2016-10-13'\'') - $(gdate +%s))/(60*60*24)))日!"' | tee -a $(for f in ~/.zprofile ~/.bash_profile ~/.profile ;[ -e $f ] && echo $f)
@akanehara
akanehara / gist:fff90fe2a48c81194c04225895b8b1bd
Last active September 2, 2016 02:06
Yum チートシート
# リポジトリ一覧
yum repolist all
# リポジトリ無効
yum-config-manager --disable $REPOS
# 一時的にリポジトリを利用する
yum --enablerepo $REPOS install $PACKAGE
@akanehara
akanehara / vol23.bash
Created August 27, 2016 05:03
シェル芸勉強会第24回
#!/bin/bash
lsof -oo 20 $FILE
@akanehara
akanehara / gist:1960c50ff32c05bfd0bcc5ac0d0a560c
Created August 9, 2016 05:49
思いつきメモ:単純なBotは単なるフィルタコマンドとして書くことができないか?
mkfifo response; cat response | wsta ws://echo.websocket.org | tee /dev/tty | mybotscript | tee response
@akanehara
akanehara / gist:e7ecb3e4503611a2d48af30af7131a4e
Created July 26, 2016 01:43
AWKワンライナースニペット
# 時間ごと集計
seq 10 | awk '{t=$1} t0&&t!=t0{print t0,a; a=0} {a++;t0=t}'