This file contains 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 NativeCall; | |
use Terminal::ANSIColor; | |
# Compile the c code on windows | |
# $ gcc -c setcolor.c | |
# $ gcc -shared -o setcolor.dll setcolor.o | |
constant LIBPATH = "$*CWD/setcolor"; | |
sub restoreConsole() is native(LIBPATH) { * } | |
sub setupconsole() is native(LIBPATH) { * } | |
setupconsole(); | |
my $psych = "Yo, I got your psychedelia right here!" |
This file contains 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 %hash = | |
key1 => { | |
mutual1 => 'value1', | |
mutual2 => 'value2' | |
}, | |
key2 => { | |
mutual1 => 'value1a', | |
mutual2 => 'value2a' | |
}; | |
# now we want to get the value of mutual1 in (key1,key2) |
This file contains 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
# Powershell escaped | |
write "https://google.com/?`nhttps://google.com/?a=1`nhttps://google.com/?param=value#frag" | raku -e "$*IN.lines.map(-> `$url { `$url ~~ /['?'[(<-[`=`&]>+)*%'=']*%'&']/;put ($/[0] ?? `$url.substr(0,$/.from + 1) ~ $/[0].rotor(2).map({.[0] ~ '=' ~ @*ARGS[0] }).join('&') !! `$url);})" REPLACE | |
# OR | |
# removed $url and used the topic variable for shorter version | |
write "https://google.com/?`nhttps://google.com/?a=1`nhttps://google.com/?param=value#frag" | raku -e "$*IN.lines.map({ / ['?' [ (<-[`=`&]>+) * % '=' ] * % '&' ] /;put ($/[0] ?? .substr(0,$/.from + 1) ~ $/[0].rotor(2).map({.[0] ~ '=' ~ @*ARGS[0] }).join('&') !! `$_);})" REPLACE | |
# OUTPUT : |
This file contains 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 post-review($post)> | |
<article class="post"> | |
<h4><$post.title></h4> | |
<div class="media"> | |
<div class="media-left"> | |
<p class="image is-32x32"> | |
<img src="<$post.author.img>"> | |
</p> | |
</div> | |
<div class="media-content"> |
This file contains 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 TextInput { | |
has $.value is rw is default(2); | |
method value() is rw { | |
return Proxy.new: | |
FETCH => sub ($) { return $!value }, | |
STORE => sub ($, $new) { | |
X::OutOfRange .new( | |
:range(0..50 ), | |
:got($new), |
This file contains 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 Tweaked { | |
has $.a; | |
has $.b; | |
has $.mod; | |
submethod TWEAK() { | |
$!mod = "Modified : " ~ $!mod | |
} | |
method clone() { | |
my $mod = %_<mod>:delete; |
This file contains 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
file_lines = ['a line','another one ','',' ','last','> we want this','> and this'] | |
print("First Code said \n") | |
# Get lines that starts with ">" and not empty | |
for line in (l for l in file_lines if l.strip() and l.startswith(">") ) : | |
print(line) | |
# An empty line dosen't start with a ">" so the code can be shortened to | |
print("Second code said \n") |
This file contains 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
<div class="container"> | |
<div class="notification"></div> | |
<button>Increment Notifications</button> | |
</div> |