Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use Text::ANSITable;
use strict;
my %Flag;
foreach (
'durian', 'rambutan', 'salak', 'belimbing', 'mangga'
) { $Flag { $_ } = undef; }
@perlancar
perlancar / pgp-merge-drv
Created October 9, 2019 05:51 — forked from ewa/pgp-merge-drv
Git merge driver to decrypt (and re-encrypt) files before merging.
#!/bin/bash
# WARNING: This creates and manipulates clear text copies of the
# encrypted files. It tries to clean up afterwards, but lots can go
# wrong. If you are seriously worried about the secrecy of the files,
# don't trust this!
ANCESTOR=$1
MINE=$2
OTHER=$3
+--------------+-----+----------+-------+--------------+--------------+---------+--------+--------------------+--------------------+------------------+----------------+------------+----------+--------------+
| size | c | buy_from | buy_c | buy_pross_p | buy_net_p | sell_to | sell_c | sell_gross_price | sell_net_price | sell_gross_p_usd | sell_net_p_usd | profit_pct | profit_c | profit |
+--------------+-----+----------+-------+--------------+--------------+---------+--------+--------------------+--------------------+------------------+----------------+------------+----------+--------------+
| 0.29805085 | ETH | gdax | USD | 470.68000000 | 472.09204000 | indodax | IDR | 6,793,000.00000000 | 6,772,621.00000000 | 488.89221000 | 487.42553337 | 3.2480 | USD | 4.57016073 |
| 0.29625196 | ETH | gdax | USD | 470.84000000 | 472.25252000 | indodax | IDR | 6,793,000.00000000 | 6,772,621.00000000 | 488.89221000 | 487.42553337 | 3.2129 | USD |
+------------+-----+----------+-------+----------------+----------------+---------+--------+---------------------+---------------------+------------------+----------------+------------+----------+----------------+
| size | c | buy_from | buy_c | buy_pross_p | buy_net_p | sell_to | sell_c | sell_gross_price | sell_net_price | sell_gross_p_usd | sell_net_p_usd | profit_pct | profit_c | profit |
+------------+-----+----------+-------+----------------+----------------+---------+--------+---------------------+---------------------+------------------+----------------+------------+----------+----------------+
| 0.00099906 | BTC | gdax | USD | 6,251.00000000 | 6,266.62750000 | indodax | IDR | 90,783,000.00000000 | 90,510,651.00000000 | 6,533.65251000 | 6,514.05155247 | 3.9483 | USD | 0.24719147 |
| 0.01602933 | BTC | gdax | USD | 6,251.00000000 | 6,266.62750000 | indodax | IDR | 90,703,000.00000000 | 90,430,891.00000000 | 6,527.89491000 | 6,508.311225
plackup -s Starman --listen :8000 \
--enable-ssl --ssl-cert server.crt --ssl-key server.key \
-MPlack::App::Directory -e'Plack::App::Directory->new(root=>".")'
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Tiny;
use JSON::PP ();
use DDP;
my $name = shift || "cpm";
my $query = {
"fields" => [
% pwd
/home/s1/repos/perl-Perinci-CmdLine-Lite
% git log -1
commit b5b4616e17fd6d27fb11636150a66d24677b05e0
Author: perlancar (@pc-office) <perlancar@gmail.com>
Date: Wed Sep 28 12:47:50 2016 +0700
Release v1.61
% bencher -Ilib -m URIEscaping --include-dataset ascii53
+--------------------------------+-----------+-----------+------------+---------+---------+
| participant | rate (/s) | time (μs) | vs_slowest | errors | samples |
+--------------------------------+-----------+-----------+------------+---------+---------+
| URI::Encode::uri_encode | 2390 | 418 | 1 | 2.1e-07 | 20 |
| URI::Escape::uri_escape_utf8 | 82100 | 12.18 | 34.336 | 4.6e-11 | 20 |
| URI::Escape::uri_escape | 85100 | 11.7 | 35.6 | 1.1e-08 | 27 |
| URI::Escape::XS::uri_escape | 1300000 | 0.75 | 560 | 8.4e-10 | 79 |
| URI::XSEscape::uri_escape_utf8 | 1390000 | 0.72 | 581 | 3.7e-10 | 26 |
| URI::XSEscape::uri_escape | 3000000 | 0.33 | 1300 | 3.5e-10 | 115 |
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
my ($opr, %res);
sub parse {
state $RE =
qr{
% bencher -Ilib -m Perl/Hash --include-participant insert --multiperl
+-------------------+-----------+-----------+------------+---------+---------+
| perl | rate (/s) | time (μs) | vs_slowest | errors | samples |
+-------------------+-----------+-----------+------------+---------+---------+
| perl-5.22.0 | 6.4e+04 | 15.6 | 1 | 6.1e-09 | 24 |
| perl-5.22.1 | 64393.4 | 15.5295 | 1.00692 | 0 | 20 |
| cperl-5.22.1 | 67317.8 | 14.8549 | 1.05264 | 1e-11 | 23 |
| stableperl-5.22.0 | 6.83e+04 | 14.6 | 1.07 | 1.5e-08 | 105 |
+-------------------+-----------+-----------+------------+---------+---------+