Skip to content

Instantly share code, notes, and snippets.

Avatar

Kazumasa Utashiro kaz-utashiro

View GitHub Profile
@kaz-utashiro
kaz-utashiro / miyako-shukuhaku.js
Created March 12, 2019 04:59
宮古島トライアスロン宿泊先登録用ブックマークレット
View miyako-shukuhaku.js
javascript: {
const info = new Map([
[ 'HNAME', 'ホテルサザンコースト宮古島' ],
[ 'HTEL', '0980-75-3335' ],
[ 'ARRDATEY', '2019' ],
[ 'ARRDATEM', '4' ],
[ 'ARRDATED', '12' ],
[ 'DPTDATEY', '2019' ],
[ 'DPTDATEM', '4' ],
[ 'DPTDATED', '16' ]
@kaz-utashiro
kaz-utashiro / .cdifrc
Last active September 16, 2020 19:14
Word や PowerPoint のファイルを grep したり diff したりする ref: https://qiita.com/kaz-utashiro/items/30594c16ed6d931324f9
View .cdifrc
option default --mecab
@kaz-utashiro
kaz-utashiro / file0.txt
Last active November 18, 2019 03:19
Perl で子プロセスが入力を読めない問題 ref: https://qiita.com/kaz-utashiro/items/80fc83e56e645f19e927
View file0.txt
$_ = do { local $/; <> };
if (open(CHLD, '|-') == 0) {
print <>;
exit;
}
print CHLD $_;
@kaz-utashiro
kaz-utashiro / file0.txt
Last active August 29, 2015 14:07
Mavericks コマンドラインキッチンタイマー「ゴージャスラーメン」オプション ref: http://qiita.com/kaz-utashiro/items/72f9e4c089c46210dec4
View file0.txt
tir -rGRc10
@kaz-utashiro
kaz-utashiro / file0.txt
Created April 26, 2014 08:21
Perl の @- と @+ のペナルティが高すぎる ref: http://qiita.com/kaz-utashiro/items/2facc87ea9ba25e81cd9
View file0.txt
while (/pattern/g) {
my($s, $e) = ($-[0], $+[0]);
...
@kaz-utashiro
kaz-utashiro / cdif.el
Created April 3, 2014 08:04
Emacs のバッファに対して cdif を実行する関数。本当は、コマンドの実行にした場合のエラー処理を入れたいんだが、やり方がわからない。失敗したら undo してください。
View cdif.el
;;; cdif.el --- cdif and ansi-color interface
;;; Code:
(autoload 'ansi-color-apply-on-region "ansi-color" nil t)
(defun cdif-buffer (&optional prefix)
"Execute cdif command on current buffer and apply ansi-color."
(interactive "P")
(if prefix
@kaz-utashiro
kaz-utashiro / very-simple-battle-monster.pl
Last active January 3, 2016 06:09
中学生の息子に、ゲームプログラムはどうやって作るんだと訊かれた。俺もやったことないからわからないから、じゃあ作ってみるかと一緒に10分程で作ってみたプログラム。最初は乱数を発生して上か下かを選ぶプログラムだったんけど、わかりにくいようだったので対戦形式にしてみた。
View very-simple-battle-monster.pl
#!/usr/bin/perl -CSD
use strict;
use warnings;
use utf8;
my %モンスター = (
0 => "ゼクロム",
1 => "ワンリキー",
2 => "ニョロモ",
@kaz-utashiro
kaz-utashiro / print_wdiff.pl
Last active January 1, 2016 13:59
print function to remove wdiff control sequence for greple command
View print_wdiff.pl
sub print_wdiff {
my %arg = @_;
my @matched = @{$arg{matched}};
for (my $i = $#matched; $i >= 0; $i--) {
my($s, $e) = @{$matched[$i]};
my $t = substr($_, $s, $e - $s);
if ($t =~ s/\A (?:\{\+|\[\-) (.*) (?:\+\}|\-\]) \Z/$1/sx) {
substr($_, $s, $e - $s) = $t;
$matched[$i][0] = $s - $i * 4;
@kaz-utashiro
kaz-utashiro / App::Greple::diff.pm
Last active March 27, 2018 01:13
Greple command module for colorise diff output.
View App::Greple::diff.pm
package App::Greple::diff;
1;
=head1 NAME
diff - greple module for diff command output
=head1 SYNOPSIS
@kaz-utashiro
kaz-utashiro / temp var declaration
Last active March 12, 2019 09:35
1行しか必要でない変数をどうやって宣言するかという話。カッコいい書き方はないものだろうか。
View temp var declaration
## なんとなく嫌だ
my %seen;
@opt_icode = grep { not $seen{$_}++ } @opt_icode;
## ダサい
{
my %seen;
@opt_icode = grep { not $seen{$_}++ } @opt_icode;
}