Skip to content

Instantly share code, notes, and snippets.

@ugexe
ugexe / rakudoc-grant.md
Created June 9, 2024 23:39
Grant Proposal - Make documentation installable and accessible

Grant Proposal - Make documentation installable and accessible

Raku has code for handling the installation of distributions through CompUnit::Repository::Installation. It handles the part of the installation process that involves copying the files into their final location, path normalization, precompilation, as well as providing an interface for querying what is installed. Unfortunately it does not yet handle anything related to documentation.

Benefits to the Raku community

Developers can query for documentation

Currently there is no useful way of finding documentation for Raku distributions. There is a program called rakudoc, but it is generally only useful for core documentation. This would allow developers to query for documentation similar to how they can query for module names.

@ugexe
ugexe / meta6-tips-2024-draft.md
Created May 25, 2024 03:22
Draft of a potential future blog post about lesser known META6.json tips in 2024

META6.json Tips and Suggestions for 2024


Considering using - instead of :: in your distribution name

Using :: usually makes sense for module names, but does it make sense for most distribution names? It isn't friendly for urls or in file names on certain file systems, so when you have a distribution named Foo::Bar it'll have a tar file named like Foo-Bar.tar.gz and extract to e.g. ./Foo-Bar. These path names aren't round-tripable to the original distribution name... a distribution named Foo::My-Baz would be Foo-My-Baz.tar.gz which could be mistaken for Foo::My::Baz. Similarly you can't use :: in git repo names, and most people want their distribution name as part of the repo name.

As an example: I'm the author of a distribution named Net::HTTP and I have no expectation that it interops with anything else in the Net:: namespace. But I've unfortunately somewhat implied it by using :: in the name. Net-HTTP would have been a name in retrospect. I think it still makes sens

use v6.d;
use NativeCall;
class winsize is repr('CStruct') {
has uint16 $.rows;
has uint16 $.cols;
has uint16 $.xpixels;
has uint16 $.ypixels;
method gist() {
#ifdef _WIN32
#include <windows.h>
#endif
#define MAX_PATH_LENGTH 260
void transform_path(char *path) {
#ifdef _WIN32
// Check if path is already a long path
if (strlen(path) >= 7 && strncmp(path, "\\\\?\\", 4) == 0) {
@ugexe
ugexe / gist:b1b72ed0fd57069ff5533dfc03a95532
Last active December 8, 2021 02:16
Don't include e.g. home or root directories as a module path
C:\Users\ugexe>raku --ll-exception -e "use lib '.'; use Test;"
read from dirhandle failed: 123
at SETTING::src/core.c/Rakudo/Internals.pm6:1345 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.c.setting.moarvm:next)
from SETTING::src/core.c/Rakudo/Internals.pm6:1374 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.c.setting.moarvm:pull-one)
from SETTING::src/core.c/Any-iterable-methods.pm6:326 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.c.setting.moarvm:pull-one)
from SETTING::src/core.c/Any-iterable-methods.pm6:335 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.c.setting.moarvm:pull-one)
from SETTING::src/core.c/CompUnit/Repository/FileSystem.pm6:283 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.c.setting.moarvm:dist-from-ls)
from SETTING::src/core.c/CompUnit/Repository/FileSystem.pm6:238 (C:\Users\ugexe\.rakudobrew\moar-2021.10\install\share\perl6\runtime/CORE.
@ugexe
ugexe / words.pl
Last active April 18, 2019 01:48
Polyglot Perl5/6 print words that can be spelled from given input letters
# perl|perl6 words.pl word_list.txt f o o b a r b a z
my @ARGV = do { sub eval { &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) };
sub polyslurp ($_) { "0" and (return "{$_.IO.slurp}") or (return do { open(my $fh, $_[0]); join("", <$fh>); }) };
my $filename = shift(@ARGV);
my @words = split("\n", polyslurp($filename));
my $input_letters = {};
$input_letters{lc($_)} += 1 for @ARGV;
@ugexe
ugexe / pi.pl
Last active April 18, 2019 01:35
Polyglot Perl5/6 print pi digits based on script size
sub eval($_) { &EVAL($_) };
sub polyint($_) { "0" and (return Int($_[0])) or (return int($_[0])) };
sub script_size { "0" and (return 0+eval('$*PROGRAM.IO.s')) or (return 0+eval('-s $0')) };
#`() use isms; sub infix:«<<»($a,$b) { $a +< $b };
my $digits = script_size() + 1;
my (@out, @a);
my ($b, $c, $d, $e, $f, $g, $i, $d4, $d3, $d2, $d1);
$b = $d = $e = $g = $i = 0;
@ugexe
ugexe / hamming.pl
Created April 11, 2019 02:56
Polyglot Perl5/6 hamming numbers
my @ARGV = do { sub eval { &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) };
my $numbers_tried = 0;
my $numbers_found = 0;
NUMBERS: while ($numbers_found != @ARGV[0]) {
$numbers_tried++;
my $state = $numbers_tried;
while ($state != 1) {
@ugexe
ugexe / pascal.pl
Last active April 11, 2019 02:55
Polyglot Perl 5/6 pascals triangle
my @ARGV = do { sub eval { &EVAL(@_) }; eval( ("0" and q|@*ARGS| or q|@ARGV|) ) };
my @state = (1,);
for (1 .. @ARGV[0]) {
print(join(" ", @state), "\n");
my @row = map &{ sub ($_) { @state[$_] + (@state[$_ + 1] // 0) } }.(), (0 .. ($_ - 2));
@state = ();
push(@state, 1);
push(@state, $_) for @row;
push(@state, 1);
}
@ugexe
ugexe / dld.pl
Last active April 6, 2019 07:02
Polyglot Perl 5/6 levenshtein damerau algorithm implementation
sub polymin (*@_) { (@_[0] > @_[1]) and (return @_[1]) or (return @_[0]) }
sub polymax (*@_) { (@_[0] > @_[1]) and (return @_[0]) or (return @_[1]) }
sub polychars (*@_) { 0+grep &{ sub ($_) { $_ ne "" } }.(), split("", @_[0]) }
sub polytern (*@_) { (@_[0]) and (return @_[1]) or (return @_[2]) }
sub dld (*@_) {
my $source = @_[0];
my $target = @_[1];
my $max = @_[2];
my $sourceLength = polychars($source);