Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# See: https://github.com/textlint/textlint/issues/852
import json
import subprocess
import sys
from functools import cache
from os import getenv
from unicodedata import east_asian_width
r"""

Johnの起床シーケンス

  • JohnはAliceからの通信をtriggerに起床します
  • Johnは起床後、Bobに通知を送ります
sequenceDiagram
    participant Alice
    participant Bob
 Alice->>John: Hello John, how are you?
@ernix
ernix / cert-domains.py
Created December 18, 2019 05:54
cert-domains.py
#!/usr/bin/env python3
import socket
import ssl
import sys
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.x509.oid import NameOID
@ernix
ernix / defaultdict.pl
Last active November 11, 2019 13:36
perl implementation of python's collection.defaultdict
#!/usr/bin/perl
use strict;
use warnings;
{
package Tie::DefaultDict;
require Tie::Hash;
our @ISA = qw(Tie::ExtraHash);
sub TIEHASH {
function luhn(value) {
return value.split('').reduce(function (s, d, i) {
var n = (!(i & 1) + 1) * d;
if (n > 9) n -= 9;
return s + n;
}, 0) % 10 === 0;
}
console.log(luhn('1234567890123452'));
@ernix
ernix / 0001-Parse-SKIP-directives-to-produce-skipped.patch
Created January 25, 2019 06:20
TAP::Format::JUnit: Parse SKIP directives to produce "<skipped />"
From 88d965c5740c5ad09a97e1e576fe3bc14abcc382 Mon Sep 17 00:00:00 2001
From: Shin Kojima <shin@kojima.org>
Date: Fri, 25 Jan 2019 15:17:18 +0900
Subject: [PATCH] Parse SKIP directives to produce "<skipped />"
Signed-off-by: Shin Kojima <shin@kojima.org>
---
lib/TAP/Formatter/JUnit/Result.pm | 1 +
lib/TAP/Formatter/JUnit/Session.pm | 13 +++++++++++++
t/data/tap/junit/skip | 5 ++++-
@ernix
ernix / test_dumper.pl
Created January 19, 2019 15:02 — forked from dtonhofer/test_dumper.pl
Comparing behaviour of Perl Data::Dumper when using "Pure Perl" and "XS" mode for non-iso-8859-1 codepoints
#!/usr/bin/perl
use strict;
use warnings;
use utf8; # Meaning "This lexical scope (i.e. file) contains utf8"
use open qw(:std :utf8);
use autodie;
use Encode;
use File::Temp qw(tempdir);
@ernix
ernix / weld.pl
Last active October 19, 2018 01:15
weld.pl - join(1), with less options, but for 3 or more files
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
our $VERSION = '0.02';
my $app = App::Weld->new;
$app->run;
@ernix
ernix / inet.sh
Last active September 24, 2020 08:00
#/bin/sh
set -eu
ip2dec () {
local ip="$1"
if test -z "$ip"; then
printf "Argument required" 1>&2
return 1
fi
@ernix
ernix / gist:12394d28a1282ca022a62dcbee8ac7aa
Created August 1, 2017 00:24
neomutt won't work with notmuch
✔ kojima:kojiMac ~$ mutt
dyld: Library not loaded: /usr/local/opt/notmuch/lib/libnotmuch.4.dylib
Referenced from: /usr/local/bin/mutt
Reason: image not found
mutt: warning: mutt crashed, killed by SIGABRT.
mutt itself has not crashed, but for transparency,
it will now kill itself (without dumping core) with the same signal
warnings can be silenced by the --no-warnings (-n) option