Skip to content

Instantly share code, notes, and snippets.

View xtetsuji's full-sized avatar

OGATA Tetsuji xtetsuji

View GitHub Profile
@xtetsuji
xtetsuji / chrome-bookmark.pl
Created February 27, 2015 09:48
Google Chrome bookmark dumper for Mac OS X environment.
#!/usr/bin/env perl
# 2015/02/27 OGATA Tetsuji (@xtetsuji)
# MIT License
use strict;
use warnings;
use Encode;
use JSON::PP;
@xtetsuji
xtetsuji / table-sort-pref.pl
Created January 31, 2024 14:35
Japanese prefecture name sort on some Japanese character sets.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
use utf8;
binmode STDOUT, ':utf8';
use Encode;
# 都道府県の漢字表記を北海道から沖縄県まで
my @prefs = (
@xtetsuji
xtetsuji / README.md
Last active January 4, 2024 13:55
Postfix mailq viewer. queue_ids -> [From, To, Date, Subject]

mailq-list.pl - Postfix mailq viewer.

DESCRIPTION

mailq-list.pl is Postfix mailq viewer.

Normal Postfix mailq command shows only envelope information. If you want to know header information, you run postcat command every each time.

maiq-list.pl supports that you can show all queues' header information.

@xtetsuji
xtetsuji / one-liner.txt
Last active December 9, 2023 14:03
1209 powered by 2023
perl -MMath::BigInt -E 'say Math::BigInt->new("1209")->bpow("2023")->to_base(10) =~ s/(?<=\d)(?=(?:\d\d\d)+(?!\d))/,/gr =~ s/((?:\d\d\d,){10})/$1\n/gr'|
@xtetsuji
xtetsuji / gh-noreply-address
Last active November 22, 2023 19:13
show my GitHub noreply address by gh-cli
#!/bin/bash
set -eu
gh api /user | jq -r '"\(.id)+\(.login)@users.noreply.github.com"'
#!/bin/bash
# https://docs.docker.com/engine/install/ubuntu/
set -eu
# root でなかったら終了
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." 1>&2
exit 1
fi
@xtetsuji
xtetsuji / majide.js
Created June 21, 2023 02:45
MajiDe time-based event driven interface by Japanese named class and its methods.
class MajiDe {
/**
* MajiDe オブジェクトを作成する
* @param {Function} func - コールバック
*/
constructor(func) {
if ( !func || typeof func !== "function" ) {
throw new Error("第一引数は関数にして下さい");
}
this.func = func;
@xtetsuji
xtetsuji / defaultgw
Last active December 17, 2022 04:33
print default gateway. and open browser if argument has `-w`
#!/bin/bash
set -eu
browser=open
default_gw=$( route -n get 0.0.0.0 | grep gateway | sed -e 's/.*: //' )
if [ "_${1:-}" = "_-w" ] ; then
"$browser" "http://$default_gw/"
fi
@xtetsuji
xtetsuji / output.txt
Created November 28, 2022 05:03
square-sum-1128.pl
2^2 + 10^2 + 32^2 = 1128
2^2 + 32^2 + 10^2 = 1128
10^2 + 2^2 + 32^2 = 1128
10^2 + 32^2 + 2^2 = 1128
14^2 + 16^2 + 26^2 = 1128
14^2 + 26^2 + 16^2 = 1128
16^2 + 14^2 + 26^2 = 1128
16^2 + 26^2 + 14^2 = 1128
26^2 + 14^2 + 16^2 = 1128
26^2 + 16^2 + 14^2 = 1128
@xtetsuji
xtetsuji / maillog-hashnize.pl
Last active October 11, 2022 08:08
enhancement of "pflog" for parsing maillog of postfix 2.3 or higher version.
#!/usr/bin/perl
# "pflog" enhancement for parsing maillog of postfix 2.3 or higher version.
# "pflog" see: http://www.tmtm.org/ruby/pflog/pflog-0.3
use strict;
use warnings;
use Time::Local;
use Getopt::Long;
#use Data::Dumper;