Skip to content

Instantly share code, notes, and snippets.

@dakkar
dakkar / obj.sh
Created July 10, 2020 11:47
I seem to have build a perl-like OO system in bash
#!/bin/bash
set -e
function class() {
current_class="$1"
}
declare -A _inheritance
function extends() {
_inheritance[$current_class]="$*"
#!/usr/bin/env perl
use v5.26;
use strict;
use warnings;
package My::Thing {
use Moo;
has value => ( is => 'ro', required => 1 );
};
@dakkar
dakkar / winsize.raku
Last active March 7, 2023 17:27
winsize ioctl in Raku
use v6.d;
use NativeCall;
class winsize is repr('CStruct') {
has uint16 $.rows;
has uint16 $.cols;
has uint16 $.xpixels;
has uint16 $.ypixels;
method gist() {
@dakkar
dakkar / matching-with-macros.raku
Last active February 22, 2024 16:18
role to execute a matching sub in raku
use v6.d;
use experimental :macros;
role mmm {
method ACCEPTS(Code:D: |c) {
dd self;dd c; # debugging!
return False unless c ~~ self.signature;
self.(|c);
return True;
}