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 Raylib::Bindings; | |
| use ECS; | |
| constant $screen-width = 1024; | |
| constant $screen-height = 450; | |
| my $white = init-white; | |
| my $background = init-skyblue; | |
| init-window($screen-width, $screen-height, "Bouncing Camelias"); | |
| my $string = "./camelia.png"; |
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 Cro::HTTP::Client; | |
| use Cro::Uri; | |
| use DOM::Tiny; | |
| my Cro::HTTP::Client $client .= new; | |
| sub scrap($url is copy) { | |
| $url = Cro::Uri.parse: $url if $url ~~ Str; | |
| return unless $url.defined && $url.scheme.starts-with: "http"; | |
| gather { |
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
| raku -MCro::HTTP::Server -MCro::HTTP::Router -MCro::HTTP::Client -e ' | |
| my &where = -> Int $i, Int $actual { say "$actual == $i -> { $actual == $i }"; $actual == $i } | |
| Cro::HTTP::Server.new( | |
| host => "127.0.0.1", | |
| port => 10001, | |
| application => route { | |
| post -> {request-body -> $data? { content "test/plain", "ok!" } } | |
| } | |
| ).start; | |
| Promise.in(5).then: { Cro::HTTP::Client.post: "http://127.0.0.1:10001", :headers["Content-Type" => "application/x-www-form-urlencoded"] } # breaks the server |
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
| $ raku -MCro::HTTP::Server -MCro::HTTP::Router -e ' | |
| Cro::HTTP::Server.new( | |
| host => "127.0.0.1", | |
| port => 10001, | |
| application => route {my $CRO-ROUTER-RESPONSE = $*CRO-ROUTER-RESPONSE; | |
| get -> {content "test/plain", "ok!"} | |
| ^3 .map: -> $i { | |
| post -> Int $a where { say "$_ == $i -> { $_ == $i }"; $_ == $i } { | |
| CATCH { default { say "ERROR: $_" } } |
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
| raku -I. -MRed -MRed::Type -MRed::AST::Value -MJSON::Fast -e ' | |
| red-defaults "SQLite"; | |
| my $*RED-DEBUG = True; | |
| enum Currency <USD GBP BRL>; | |
| class Money { has Rat() $.value; has Currency() $.currency } | |
| class DBMoney does Red::Type { | |
| method inflator { -> $_ is copy --> Money { given .&from-json { Money.new: :value(.<value>), :currency(Currency::{ .<currency> }) } } } |
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
| $ raku -I. -MRed -MRed::Type -MRed::AST::Value -MJSON::Fast -e ' | |
| red-defaults "SQLite"; | |
| #my $*RED-DEBUG = True; | |
| enum Currency <USD GBP BRL>; | |
| class Money { has Rat() $.value; has Currency() $.currency } | |
| class DBMoney does Red::Type { | |
| method inflator { -> $_ is copy --> Money { given .&from-json { Money.new: :value(.<value>), :currency(Currency::{ .<currency> }) } } } |
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 Singleton; | |
| say Singleton.new.WHERE |
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
| class Agg does Callable { | |
| has Callable @.subs; | |
| has Signature $.signature = Signature.new: :params[|@!subs.map: |*.signature.params], :returns(Parameter.new(:type(Map()))); | |
| method CALL-ME(|c) { | |
| %( | |
| |@.subs.map: { | |
| my @names = .signature.params.grep({ .named }).map(|*.named_names); | |
| my %params := (c.hash{@names}:p).Map; |
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 $interval = .run-at: :5mins-running, :off, -> :$rule, :$time { | |
| $rule.stop; | |
| say "$time.hh-mm-ss(): interval has finished" | |
| } | |
| .run-at: :25mins-running, -> :$rule, :$time { | |
| $rule.stop; say "$time.hh-mm-ss(): Time to relax"; | |
| $interval.start | |
| } |
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 App::RakuCron::Configuration; | |
| use App::RakuCron::Rule; | |
| use Lumberjack; | |
| sub print-example(Str $msg = "Generic message", :$rule, +@params, :$time, :$delta-secs = "None", :$something-else = "") { | |
| $rule.log-warn: "$msg (@params[]) ({ $something-else }): ", $time.hh-mm-ss, " -> { $delta-secs }" | |
| } | |
| Lumberjack.dispatchers = [ | |
| Lumberjack::Dispatcher::Console.new: :colour |
NewerOlder