Skip to content

Instantly share code, notes, and snippets.

View xtetsuji's full-sized avatar

OGATA Tetsuji xtetsuji

View GitHub Profile
@xtetsuji
xtetsuji / table-sort-pref.pl
Created January 31, 2024 14:35
Japanese prefecture name sort on some Japanese character sets.
View table-sort-pref.pl
#!/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]
View README.md

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
View one-liner.txt
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
View gh-noreply-address
#!/bin/bash
set -eu
gh api /user | jq -r '"\(.id)+\(.login)@users.noreply.github.com"'
View docker-setup-ubuntu.sh
#!/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.
View majide.js
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`
View defaultgw
#!/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
View output.txt
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 / recursive-spf.pl
Created January 21, 2021 13:16
count given domain "include" consider recursive "include"
View recursive-spf.pl
#!/usr/bin/env perl
use strict;
use warnings;
my $check_mail_domain = shift;
if ( !$check_mail_domain || $check_mail_domain =~ / / ) {
die "1st argument is required as mail domain\n";
}
@xtetsuji
xtetsuji / add-music.js
Created December 30, 2020 11:03
Simple music files importer for Apple macOS new Music.app
View add-music.js
#!/usr/bin/osascript -l JavaScript
function run(argv) {
const music = Application("Music");
for ( const file of argv ) {
console.log(`add: "${file}"`);
music.add(file);
}
}