Skip to content

Instantly share code, notes, and snippets.

View jef-sure's full-sized avatar

Anton Petrusevich jef-sure

  • Germany
View GitHub Profile
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
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 {
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();
#!/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) {
#!/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);
#!/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{$_}++;
#!/usr/bin/perl
use v5.14;
use Data::Dumper;
my @msgs = ({
id => 1,
msg => 'a',
}, {
id => 2,
msg => 'b',
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 {
use JSON;
use JSV::Compiler;
use v5.10;
use strict;
use warnings;
use Data::Dumper;
my $s = JSV::Compiler->new;
# 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;
}