This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use PDF::Haru; | |
use Text::QRCode; | |
use POSIX 'floor'; | |
use strict; | |
use warnings; | |
# create new document | |
my $pdf = PDF::Haru::New(); | |
#$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf", HPDF_TRUE); | |
# add page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub _php_jquery_param { | |
my ($root, $path, $value) = @_; | |
my @struct = $path =~ /\[?([^\[\]]+)\]?/g; | |
return if !@struct; | |
my $sl = \$root; | |
for my $key (@struct) { | |
if ($key =~ /^\d+$/) { | |
$$sl //= []; | |
$sl = \$$sl->[$key]; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use PDF::Haru; | |
use POSIX 'floor'; | |
use strict; | |
use warnings; | |
# create new document | |
my $pdf = PDF::Haru::New(); | |
#$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf", HPDF_TRUE); | |
# add page | |
my $page = $pdf->AddPage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Benchmark qw(cmpthese); | |
use Config; | |
use Inline C => Config => | |
# BUILD_NOISY => 1, | |
# FORCE_BUILD => 1, | |
OPTIMIZE => " -O3 -march=native"; | |
use Inline C => <<'END_OF_C_CODE'; | |
SV* lines_in_string(SV* sv) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.20; | |
use B; # qw(object_2svref); | |
use Inline C => <<'END_OF_C_CODE'; | |
char* typeof_sv(SV* sv) { | |
SvGETMAGIC (sv); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
sub fnr_chars { | |
my $str = shift; | |
my @nr; | |
my %h; | |
join '', map { | |
push @nr, $_ if not exists $h{$_}; | |
$h{$_}++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use Data::Dumper; | |
my @msgs = ({ | |
id => 1, | |
msg => 'a', | |
}, { | |
id => 2, | |
msg => 'b', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use JSON; | |
use JSV::Compiler; | |
use v5.10; | |
my $s = JSV::Compiler->new; | |
$s->load_schema({minimum => 4}); | |
my $code = $s->compile(coercion => 1, input_symbole => "\$iv"); | |
my $tsub = <<EOS; | |
sub { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use JSON; | |
use JSV::Compiler; | |
use v5.10; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
my $s = JSV::Compiler->new; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Perl vs PHP | |
# Perl (with signatures) | |
sub encode_burl($param) { | |
my $burl = encode_base64($param, ""); | |
$burl =~ tr|+/|-_|; | |
my $padd = $burl =~ tr|=||d; | |
return $burl . $padd; | |
} |