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
using System; | |
using System.Text.RegularExpressions; | |
public class Example | |
{ | |
public static void Main() | |
{ | |
string pattern = "^\\d+$"; | |
string numbers = "௫๓௫๓"; | |
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 raku | |
role ObserverSignal { | |
} | |
multi sub trait_mod:<is> ( Method $m, :$observer-signal! ) { | |
$m does ObserverSignal; | |
} | |
role Observable { |
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
# Or if you want to be check each element then you can | |
# create a subset that does so | |
subset ArrayOfInt of Array where { .all ~~ Int }; | |
sub d(Int $a, Int $b --> ArrayOfInt) { | |
[$a, $b]; | |
} | |
say d(1, 2); |
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; | |
my $c; | |
react { | |
whenever Cro::HTTP::Client.get("http://cannibal.local") -> $v { | |
whenever $v.body-text -> $m { | |
$c = $m; | |
done; | |
} | |
} |
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::Router; | |
use Cro::HTTP::Server; | |
use JSON::Class; | |
use Cro::HTTP::BodySerializerJSONClass; | |
class Foo does JSON::Class { | |
has DateTime $.date is marshalled-by('Str') = DateTime.now; | |
} | |
my $app = route { |
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::BodySerializers; | |
use JSON::Class; | |
class Foo::HTTP::BodySerializerJSONClass does Cro::HTTP::BodySerializer { | |
method is-applicable(Cro::HTTP::Message $message, $body --> Bool) { | |
with $message.content-type { | |
(.type eq 'application' && .subtype eq 'json' || .suffix eq 'json') && ($body ~~ JSON::Class ); | |
} | |
else { | |
False |
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 Tuple does Positional { | |
has $.a; | |
has $.b; | |
multi method AT-POS(0) { | |
$!a; | |
} | |
multi method AT-POS(1) { | |
$!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 Cro::MQTT; | |
my $subscriptions = subscriptions { | |
subscribe 'hello-world', { | |
consume -> $m { say "GOT HELLO WORLD ", $m.message.decode } | |
} | |
subscribe 'another-world', { | |
consume -> $m { say "GOT ANOTHER WORLD ", $m.message.decode } | |
} | |
} |
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
PROFILE_SCRIPT=/etc/profile.d/$PKG_NAME.sh | |
/usr/bin/cat - <<EOSCR >$PROFILE_SCRIPT | |
RAKUDO_PATHS=$INSTALL_PREFIX/bin | |
for TOP in raku perl6 | |
do | |
if [ -d $INSTALL_PREFIX/share/\$TOP ] | |
then | |
for REP in site vendor core |
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
# Inspired by https://dev.to/harleypadua/recursion-recursion-recursion-1501 | |
multi shoot-gun(Str $sound, Int $num where * > 0 --> Str ) { | |
return $sound ~ ' ' ~ shoot-gun($sound, $num - 1); | |
} | |
multi shoot-gun($, 0 --> '') { | |
} | |
say shoot-gun('bang', 5); |
NewerOlder