Skip to content

Instantly share code, notes, and snippets.

@CIAvash
CIAvash / caller_of_functions.raku
Created September 17, 2021 13:03
Raku - Call returned functions from a function on arguments
#!/usr/bin/env raku
sub infix:<.%>(&func, +@args) {
my $r = &func;
my $capture;
my $start = 0;
loop {
my $end = +@args;
@CIAvash
CIAvash / switch_connection.sh
Created November 27, 2021 18:45
Switch internet connection using `rofi` and network manager's `nmcli`. Dependencies: `ripgrep`, `hck`, `nmcli`, `rofi`
#!/usr/bin/env bash
connections=$(nmcli connection show | rg -v NAME)
selected_connection_line=$(echo "$connections" | rofi -dmenu -i -p 'Select connection: ')
rofi_exit_code=$?
selected_connection=$(echo "$selected_connection_line" | hck -d ' {2,}' -f 1)
# Disconnect on Alt-1
@CIAvash
CIAvash / wordle_solver.raku
Created April 12, 2022 05:29
Manual wordle solver!
#!/usr/bin/env raku
#| Manual wordle solver!
unit sub MAIN (Str :c(:$contains), Str :e(:$exclude), Str :a(:$at), Str :n(:$not-at));
USAGE() and exit unless @*ARGS;
.put for '/usr/share/dict/words'.IO.lines.grep: {
.chars == 5
and /^<:Ll>/
@CIAvash
CIAvash / awesome-tray-flymake-info.el
Last active May 16, 2022 06:10
Flymake module for awesome-tray package
(defface my/awesome-tray-flymake-error
'((t (:foreground "#FF564A")))
"Flymake error face."
:group 'awesome-tray)
(defface my/awesome-tray-flymake-warning
'((t (:foreground "#FF9800")))
"Flymake warning face."
:group 'awesome-tray)
(defface my/awesome-tray-flymake-note
'((t (:foreground "#2196F3")))
my @symbols_to_remove = Q:w「- _ ! , : / ( ) [ ] . ' + ? = * \ " # $ % & { } | ; ~ \ < > @ ` ^」;
my @terms_to_ignore = <for and the with from that your git bin this not svn who can you like into all more one any
over non them are very when about yet many its also most lets just>;
my &sanitize = *.trans(@symbols_to_remove => ' ').lc.words.grep(
{ .chars ≥ 3 and not /^ <[0..9]>+ $/ and /^ <[a..z] + [0..9]>+ $/ }
).grep(none @terms_to_ignore).unique;
say sanitize "The.quick 'brown' 🦊 jumps-OvER th 1337 QUICK <dog>!";