Skip to content

Instantly share code, notes, and snippets.

View Xliff's full-sized avatar
🏠
Working from home

Xliff Xliff

🏠
Working from home
View GitHub Profile
@Xliff
Xliff / progress-bars-raku.md
Created May 28, 2025 14:52
Weird Grid Errors

Lookit! Perdy colors...

Now if only I can figure out why the labels are so far to the right...

#!/usr/bin/env raku
use v6;

use Color;
@Xliff
Xliff / jg-bt-full.md
Created May 27, 2025 10:38
JSON-GLib backtraces

Backtrace #1

0x00007ffff796c2e7 in mi_free (p=0x555555573a5c) at 3rdparty/mimalloc/src/free.c:156
156       const bool is_local = (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id));
(gdb) bt
#0  0x00007ffff796c2e7 in mi_free (p=0x555555573a5c) at 3rdparty/mimalloc/src/free.c:156
#1  0x00007ffff78aa2e1 in MVM_free (p=<optimized out>) at src/core/alloc.h:60
#2  gc_cleanup (tc=<optimized out>, st=<optimized out>, data=0x26c5b069850) at src/6model/reprs/CArray.c:156
#3  gc_free (tc=<optimized out>, obj=0x26c5b069838) at src/6model/reprs/CArray.c:166
@Xliff
Xliff / tp-progress-line.md
Created May 26, 2025 05:48
Attempting to Draw using Terminal::Print

Here's code that should draw a progress bar and a label. It's not working. What am I doing wrong?

#!/usr/bin/env raku

#| A command-line program to display a customizable, colorful progress bar
#| Usage: raku progress-bar.raku <percentage>
#| Example: raku progress-bar.raku 75

use v6;
@Xliff
Xliff / Raku-ZZ.md
Created May 22, 2025 04:35
Raku - An annoying thing about <Z>

An annoying thing about Z, zip, and roundrobin is that they don't allow you to use lists of differing sizes. I whipped up this custom infix to solve the problem:

multi sub infix:<ZZ> ($a is copy, $b is copy) {
  my ($larger, $smaller) = ($a, $b);

  if $a.elems != $b.elems {
    ($larger, $smaller) = ($a, $b) if $a.elems > $b.elems;
@Xliff
Xliff / GLib-Need-AST.md
Created May 18, 2025 22:26
Automatically Generating a List of `need` Statements from a List of CompUnits

I have a list of compunits that I place in an array, and it needs to generate sometihng like the following:

need GLib::Raw::Debug;
need GLib::Raw::Definitions;
need GLib::Raw::Enums;
need GLib::Raw::Exceptions;
need GLib::Raw::Object;
need GLib::Raw::Structs;
need GLib::Raw::Subs;
@Xliff
Xliff / BrowserDetect.md
Created March 21, 2025 11:04
Browser Detection in Raku

Here's a snippet of untested code that one should be able to use to detect what type of browser you have based on the User Agent string:

use v6.d;

# Written by the Repl.It AI with prompts created by Clifton Wood
# Further exits for Racquet authored by Clifton Wood

#| A class to detect browser information from User-Agent strings
@Xliff
Xliff / Is this internal.md
Created September 15, 2024 00:06
Difficult raku error?
Stage start      :   0.000
Type check failed in binding to parameter '$address'; expected Str but got Any (Any)
   at SETTING::src/core.c/Exception.rakumod:65  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/runtime/CORE.c.setting.moarvm:throw)
 from src/Perl6/Metamodel/Configuration.nqp:72  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/lib/Perl6/Metamodel.moarvm:throw_or_die)
 from src/Perl6/bootstrap.c/BOOTSTRAP.nqp:261  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/lib/Perl6/BOOTSTRAP/v6c.moarvm:)
 from src/Perl6/bootstrap.c/BOOTSTRAP.nqp:5750  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/lib/Perl6/BOOTSTRAP/v6c.moarvm:)
 from SETTING::src/core.c/Distribution/Locally.rakumod:4  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/runtime/CORE.c.setting.moarvm:content)
 from SETTING::src/core.c/traits.rakumod:442  (/home/cbwood/.rakubrew/versions/moar-blead/install/share/perl6/runtime/CORE.c.setting.moarvm:<anon>)
 from SE
@Xliff
Xliff / MacrosAndReuse.md
Created July 9, 2024 21:34
Reusable Code as Macros in Raku

I'm trying to write a generic macro that can produce code like the following:

method setAppName ($name) {
  $appName = $name;
  self.Applications::Bizzell::Inventory::Roles::DB::Threshold::setAppName(
    $name
  );
}
method appName { $appName }
@Xliff
Xliff / FunWithGrammars.md
Created July 7, 2024 14:04
Fun (and problems) with grammars

Where I have trouble with parsing an SQL create statement:

https://tio.run/##nVZbT9swFH7vrzhCSE6BlsCmbUAbVKDbqpXCSniYGGpDa4pF4oTEQauA385OfGlc1sK2KIpv37l/tpPQNPzw/BxNYTW7C/cqlUkaRFGQwtldeJjSQNAzgZ@IcgEPFYA0Dyn4J6dyAEAO@@2W3yZA/NZBF9vVhgiuQsqDiHrNBhujHBNTD4hDpABAYxSHecS9dTNOUoYGp7VbOvXM3KxPqgSUylqciKyYfKrgR8S3lINSVaxof3aZbC4AtCbCYwE8D0OixvBoFoJcxAPGR6kMTnl3adTLMJV2rdmKpSGmCfVMIIV1b23eL0zARNxoyZ/j9UWrtSyhI5NGB6NU054M2TzzgowLW@qCRHTM8ojAI5DsJk6F7AnGpwQuCVNRlfEUbhtRk5@G0ekZB9RoH0jOMzbhdEz2y6TdBynZJ6MbbObxJWSMdBEsokT7b2VVR6ETaWIfEqiv7ctWKcHRvMQ1o@FY1t8UIwvzNFFkQCMzYEmUBcAZSs7BA9qxZy0aGs9O@53jVv8HsvtbG7@YqzH9peMlG@RlccyiXVRrB1Tnq2HZ0dpLgtmGjCUVp0XMGo/nQn1JUJMdNFnJgims9FF2t4i7MP0ENez@ucvrSZBm1KnfB2FON5S9pidlqvUJywQ8rRRlvY5TVd1ZOdWDWDIMrvKMpgM2HpINCZLUK58CpLhbkPRtCMy4uBQ7o91SBHK3IK6z7bpVjbLOD4PqnfjQO@92lyNeHBxzOFOSF1mARZHo3aFPGVicP1iag3@WAxMatM79k0Gnh2f3cbvnk72K3qr4LiVEcT0oAtSRTHhRdHodX14a0IS7XRFvnn3vbqIGdSOAvA9Ae5QNwZFG/s9DFfAwf0NKw1hS4GSp321XS51H7c@t864PRCdwmOVXHDnzd@AkmMhbbQglj17DC4zZcHIBbGvno1tzt/AF192Vr5HE9G
@Xliff
Xliff / RakuBlender.md
Created July 4, 2024 22:48
Blender and Raku via Python

Would it be possible to access blender using Raku by having Raku emit python?

I'm thinking yes.

That way this:

view_layer = bpy.context.view_layer

# Create new light datablock.