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/env perl | |
| use Mojo::Base -strict, -signatures; | |
| use Mojo::UserAgent; | |
| use Mojo::Headers; | |
| use Mojo::JSON qw(encode_json); | |
| use Mojo::Util qw(b64_encode); | |
| use Time::Piece (); | |
| { | |
| package BedrockTokenUA; |
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/env perl | |
| use Mojolicious::Lite -signatures; | |
| use Mojo::Pg; | |
| use Mojo::Promise; | |
| # Keep database access in a small model. These catalog views exist in every | |
| # PostgreSQL database, so no sample tables or migrations are needed. | |
| { | |
| package Sample::Model; | |
| use Mojo::Base -base, -signatures; |
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
| package Mojo::Tar::File; | |
| use Mojo::Base -base, -signatures; | |
| use Carp qw(croak); | |
| use Exporter qw(import); | |
| use Mojo::File (); | |
| use Scalar::Util qw(blessed); | |
| use constant DEBUG => !!$ENV{MOJO_TAR_DEBUG}; |
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
| package Mojo::S3::ResumableMultipartUpload; | |
| use Mojo::Base -base, -signatures; | |
| use Carp qw(croak); | |
| use File::Basename qw(basename); | |
| use File::Spec; | |
| use File::Temp qw(tempfile); | |
| use Mojo::File qw(path); | |
| use Mojo::JSON qw(decode_json encode_json); |
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/env perl | |
| use v5.22; | |
| use strict; | |
| use warnings; | |
| use feature 'signatures'; | |
| use MIME::Base64 qw(encode_base64); | |
| use constant { | |
| POLY => 0x9A6C9329AC4BC9B5, |
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
| # $ MOJO_LOG_LEVEL=info perl -Ilib -Mojo -MUtil=sq -E 'BEGIN { $Util::log = app->log; } a("/:n" => sub { $_->render(text => sq) })->start' get /5 | |
| # 36 | |
| # $ MOJO_LOG_LEVEL=trace perl -Ilib -Mojo -MUtil=sq -E 'BEGIN { $Util::log = app->log; } a("/:n" => sub { $_->render(text => sq) })->start' get /5 | |
| # [2026-06-08 17:10:33.96373] [87592] [trace] 6^2 = 36 | |
| # 36 | |
| package Util; | |
| use Mojo::Base -strict, -signatures; | |
| use Exporter qw(import); |
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/env perl | |
| use v5.40; | |
| use strict; | |
| use warnings; | |
| use Fcntl qw(SEEK_CUR); | |
| use IO::Uncompress::Gunzip qw(gunzip $GunzipError); | |
| use IO::Uncompress::Bunzip2 qw(bunzip2 $Bunzip2Error); | |
| use IO::Uncompress::UnXz qw(unxz $UnXzError); | |
| use Time::Piece qw(localtime); |
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
| // bytecut.c | |
| // cc -O2 -Wall -Wextra -o bytecut bytecut.c | |
| // $ head -c1024 /dev/urandom | bytecut -b 1-4,9- | wc -c | |
| // 1020 | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <errno.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
| Perl’s pack and unpack templates define how binary data is converted to and from Perl scalars. Below are practical examples for the most commonly used templates. | |
| Basic Integer Templates | |
| Signed / Unsigned 8-bit | |
| c — signed char | |
| my $bin = pack('c', -5); | |
| my $num = unpack('c', $bin); | |
| print "$num\n"; # -5 |
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/env perl | |
| # chmod +x bindiff.pl | |
| # ./bindiff.pl old.bin new.bin | |
| # Difference range: 0x00000010 - 0x0000001f | |
| # old.bin: | |
| # 00000010 41 42 43 00 ff 10 20 7e |ABC... ~| | |
| # new.bin: | |
| # 00000010 41 42 44 00 fe 10 21 7e |ABD...!~| |
NewerOlder