Skip to content

Instantly share code, notes, and snippets.

View khalidelboray's full-sized avatar
😈
..

Khalid Mohamed Elborai khalidelboray

😈
..
View GitHub Profile
@khalidelboray
khalidelboray / index.html
Created April 27, 2022 23:19
Notification Bell
<div class="container">
<div class="notification"></div>
<button>Increment Notifications</button>
</div>
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")
@khalidelboray
khalidelboray / custom-clone.p6
Created May 31, 2020 12:53
Raku `.clone` note
class Tweaked {
has $.a;
has $.b;
has $.mod;
submethod TWEAK() {
$!mod = "Modified : " ~ $!mod
}
method clone() {
my $mod = %_<mod>:delete;
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),
<: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">
@khalidelboray
khalidelboray / replace params value
Last active May 24, 2020 07:32
Chenge Values of all params with one value
# 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 :
@khalidelboray
khalidelboray / hash_subscripts.raku
Last active May 10, 2020 20:30
Raku multiple dimensions hash and subscripts
my %hash =
key1 => {
mutual1 => 'value1',
mutual2 => 'value2'
},
key2 => {
mutual1 => 'value1a',
mutual2 => 'value2a'
};
# now we want to get the value of mutual1 in (key1,key2)
@khalidelboray
khalidelboray / color.p6
Created June 29, 2019 21:18
Enable ANSI escape codes
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!"