Skip to content

Instantly share code, notes, and snippets.

set fileencodings=ucs-bom,utf-8,cp51932,euc-jp-ms,cp932,gb18030
autocmd BufReadPost * if search('\%x1b\(\$[B@]\|([BJI]\)', 'w') > 0 |
\ e ++enc=cp50221 | endif
autocmd BufReadPost * if &fileencoding ==# 'cp50221' |
\ setlocal fileencoding=iso-2022-jp | endif
autocmd BufReadPost * if &fileencoding ==# 'cp51932' |
\ setlocal fileencoding=euc-jp | endif
autocmd BufReadPost * if &fileencoding ==# 'euc-jp-ms' |
\ setlocal fileencoding=euc-jp | endif
#!/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 <[email protected]>
Date: Fri, 25 Jan 2019 15:17:18 +0900
Subject: [PATCH] Parse SKIP directives to produce "<skipped />"
Signed-off-by: Shin Kojima <[email protected]>
---
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