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 format-error(X::Cro::HTTP::Error $_) { | |
| my $status-line = .response.Str.lines.first; | |
| my $resp-body = do { await .response.body-blob }.decode; | |
| my $req-method = .request.method; | |
| my $req-target = .request.target; | |
| my $req-body = do { await .request.body-blob }.decode; | |
| "ERROR $status-line WITH $resp-body FOR $req-method $req-target WITH $req-body" | |
| } | |
| sub server-post($data) { |
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
| constant NUMBER-OF-RETRIES = 3; # YMMV | |
| constant COOLING-OFF-PERIOD = 2; # this is plenty to stall this thread | |
| sub server-post($data) { | |
| our $cro; | |
| do { | |
| my $r = await $cro.post: "{SERVER-URI}/{DATA-PATH}", body => $data; | |
| my $count = NUMBER-OF-RETRIES; | |
| while $count-- and $r.status == 503|401 { | |
| sleep COOLING-OFF-PERIOD; |
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 server-login() { | |
| my Lock \l .= new; | |
| our $cro; | |
| l.protect: { | |
| my $c = Cro::HTTP::Client.new: | |
| base-uri => SERVER-URL, | |
| content-type => JSON, | |
| user-agent => 'honking/2022.2.1', | |
| timeout => %( | |
| connection => 240, |
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 MAIN(Str $input) { | |
| my @r = lazy read-csv $input; | |
| server-login; | |
| react { | |
| whenever supply { | |
| .emit for @r.hyper(:8degree, :16batch) | |
| .map(&csv-to-yaml) | |
| } { | |
| server-post $_ | |
| } |
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 read-csv(IO() $file) { | |
| gather { | |
| my $f = $file.open: :r :!chomp; | |
| with Text::CSV.new { | |
| .header: $f, munge-column-names => { S:g /\W+//.samemark('x').lc }; | |
| while my $row = .getline-hr: $f { take $row } | |
| } | |
| } | |
| } |
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 MAIN (Str :$fi = '', Str :$fo = '') { | |
| # some genes in the binary | |
| my token gen1 {'InterfaceSpeedTester9Calc'} | |
| my token gen2 {'ScheduledCtrl9UpdateJobERK'} | |
| my token gen3 {'ScanHardwareInfoPSt'} | |
| my regex sparkling2 { | |
| [ | |
| <gen1>|<gen2>|^<gen3>$ |
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
| my $c = 1; | |
| for "$fo/$fi".IO.lines -> $line { | |
| # If the line contains the gene, print it | |
| if $line ~~ &sparkling_goblin {say "Sparkling Goblin found: "; say $line; say "in line $c"; say "in file $fi"; say " "; } | |
| #if $line ~~ &sparkling2 {say "Sparkling Goblin complex regex found: "; say $line; say "in line $c"; say " "; } | |
| $c++; | |
| } |
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::Lite; | |
| use PDF::Font::Loader; | |
| my @pdfs = <list of pdf files to combine>; | |
| # create a new pdf to hold the entire collection | |
| my $pdf = PDF::Lite.new; | |
| $pdf.media-box = 'Letter'; | |
| my $centerx = 4.25*72; # horizontal center of the page | |
| # the cover | |
| my PDF::Lite::Page $page = $pdf.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
| use Pod::Lite; | |
| use Pod::To::PDF::Lite; | |
| use RakupodObject; | |
| my $pod-object = rakupod2object $pod-doc; | |
| # pod2pdf $pod-object # args ... |
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
| # By Tom Browder https://github.com/tbrowder | |
| use Markdown::Grammar:ver<0.4.0>; | |
| my $markdown-doc = "poem.md"; | |
| my $pod-doc = "poem.rakudoc"; | |
| $pod-doc = from-markdown $markdown-doc, :to("pod"); |
NewerOlder