Skip to content

Instantly share code, notes, and snippets.

View azumakuniyuki's full-sized avatar
🐈
On vacation

azuma, kuniyuki azumakuniyuki

🐈
On vacation
View GitHub Profile
@azumakuniyuki
azumakuniyuki / find-multibyte-characters
Last active May 2, 2024 07:14
Find multibyte characters from the specified files
#!/usr/bin/env perl
# macOSの/usr/bin/grepでマルチバイト文字の検索が上手くいかないのでPerlでどうにかする
use strict;
use warnings;
use IO::File;
die sprintf("Usage: %s file1 [file2 [file3 ...]]\n", $0) unless @ARGV;
for my $fn ( @ARGV ) {
# ファイルが無い・読めない・空の場合は無視する
next unless -f $fn;
@azumakuniyuki
azumakuniyuki / named-capture.pl
Created May 8, 2022 05:56
Use $+{'neko'} instead of $1
#!/usr/bin/env perl
# Captured $1 vs. ${^MATCH}
use strict;
use warnings;
use Benchmark ':all';
use Test::More 'no_plan';
my $q = 'neko-nyaan-cat';
sub doller {
#!/usr/bin/env perl
# Captured $1 vs. ${^MATCH}
use strict;
use warnings;
use Benchmark ':all';
use Test::More 'no_plan';
my $q = ' neko nyaan cat ';
sub s3 {
my $v = shift;
@azumakuniyuki
azumakuniyuki / match-variable.pl
Created May 8, 2022 05:54
${^MATCH} variable with /p modifier
#!/usr/bin/env perl
# Captured $1 vs. ${^MATCH}
use strict;
use warnings;
use Benchmark ':all';
use Test::More 'no_plan';
my $q = 'neko-nyaan-cat';
sub cv {
@azumakuniyuki
azumakuniyuki / lexical-subs.pl
Created May 7, 2022 23:35
How is faster the Lexical Subroutine
#!/usr/bin/env perl
# my $p = sub {} vs. my sub p {}
use strict;
use warnings;
use Benchmark ':all';
use Test::More 'no_plan';
sub sr1 {
my $p = sub { return 2 * shift };
return $p->(shift);
@azumakuniyuki
azumakuniyuki / postfix-dereference.pl
Created May 7, 2022 22:30
How is faster The Postfix Dereference
#!/usr/bin/env perl
# @{ $neko->{'nyaan'} } vs. $neko->{'nyaan'}->@*
use strict;
use warnings;
use Benchmark ':all';
use Test::More 'no_plan';
my $neko1 = { 'nyaan' => \'2', 'cat' => [1..10] };
my $neko2 = { 'nyaan' => \'2', 'cat' => [1..10] };
@azumakuniyuki
azumakuniyuki / smtpauth-password.go
Created May 5, 2022 13:54
Make a string for SMTP "AUTH PLAIN" from an username and a password
// _ _ _ _
// ___ _ __ ___ | |_ _ __ __ _ _ _| |_| |__ _ __ __ _ ___ _____ _____ _ __ __| |
// / __| '_ ` _ \| __| '_ \ / _` | | | | __| '_ \ _____| '_ \ / _` / __/ __\ \ /\ / / _ \| '__/ _` |
// \__ \ | | | | | |_| |_) | (_| | |_| | |_| | | |_____| |_) | (_| \__ \__ \\ V V / (_) | | | (_| |
// |___/_| |_| |_|\__| .__/ \__,_|\__,_|\__|_| |_| | .__/ \__,_|___/___/ \_/\_/ \___/|_| \__,_|
// |_| |_|
package main
// Usage:
// $ go run ./smtpauth-password username@example.jp password-string-for-smtp-authentication
@azumakuniyuki
azumakuniyuki / make-amazon-ses-smtp-password.pl
Created April 21, 2022 07:39
Make an SMTP password from an access secret key and a region name for Amazon SES
#!/usr/bin/env perl
use strict;
use warnings;
use MIME::Base64;
use Digest::SHA;
my $secret = shift or die('The 1st argument should be an access secret key');
my $region = shift or die('The 2nd argument should be a valid region name');
my $params = {
'date' => '11111111',
#!/usr/bin/env perl
use strict;
use warnings;
my $p = shift;
if( $p =~ /(\d+)/ ) {
printf("西暦%d年ぐらい???\n", int($1) + int(rand(2000)) + int(rand(1800)) + int(rand(50)));
}
From: Microsoft Outlook <postmaster@outlook.com>
To: <azumakuniyuki@outlook.example.com>
Date: Mon, 21 May 2018 05:07:55 +0000
Content-Type: multipart/report; report-type=delivery-status;
boundary="b44278a2-9d96-4fd5-bba1-efd949e0de68"
Content-Language: en-US
Message-ID: <267295c3-c241-44d7-a5b0-202dff1de5b6@SG2APC01HT247.mail.protection.outlook.com>
MIME-Version: 1.0
--b44278a2-9d96-4fd5-bba1-efd949e0de68