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 / BartAndLambda.md
Last active May 23, 2023 08:48
AI's are Writing in Raku, now!

I went to [bart.gooogle.com] and asked it: "How do you write lambda functions in Raku?"

Here's how it responded:

===

To write lambda functions in Raku, you can use the following syntax:

Code snippet

@Xliff
Xliff / Need RakuAST.md
Last active May 17, 2023 14:46
The need for ::Need
raku -Ilib -e 'use experimental :rakuast; use MONKEY-SEE-NO-EVAL; my $ast = RakuAST::Statement::Need.new( module-names => [ RakuAST::Name.from-identifier(RakuAST::Name.from-identifier("GLib::Raw::Definitions")) ] ); EVAL $ast; import ::("GLib::Raw::Definitions"); glib.say'

This is the exact testing data. It's execution ready if you clone p6-GLib, you should only need to change into the project directory and run the above. Otherwise you will have to create a .rakumod file with a constant declaration and replace the glib in the above script with the name of that constant.

@Xliff
Xliff / comp-unit-symbol-table.md
Last active March 19, 2023 12:02
Accessing a CompUnits Symbol Table

So I needed to access the symbol table of one of my modules, recently. After a few hours on the web (and after wracking my brain for a bit) I came up with the following:

sub getSymbolTable (\T, $cu-name) is export {
  return Nil unless $cu-name;

  my $nodes = $cu-name.split('::').Array;
  my $fn    = $nodes.shift;
 my $st = T.WHO{$fn};
@Xliff
Xliff / ParameterDEPARSE.md
Created February 7, 2023 17:59
Patch for RakuAST::Deparse for where clause and literal parameters

Does anyone see a problem with this? If so, I will submit the PR.

diff --git a/src/core.c/RakuAST/Deparse.pm6 b/src/core.c/RakuAST/Deparse.pm6
index ef073dbba..62410a414 100644
--- a/src/core.c/RakuAST/Deparse.pm6
+++ b/src/core.c/RakuAST/Deparse.pm6
@@ -619,6 +619,9 @@ class RakuAST::Deparse {
         my $target := $ast.target;
 
@Xliff
Xliff / rakuast-dir.md
Last active May 24, 2023 22:58
The RakuAST Node Directory (and Cheatsheet) as of Jan 22, 2023

Version 0.0.2 - Now includes attributes!

RakuAST::ApplyDottyInfix                                  - (ast/expressions.rakumod - 923)

	Attributes
		RakuAST::DottyInfixish $.infix
		RakuAST::Expression    $.left
		RakuAST::Postfixish    $.right
@Xliff
Xliff / CookieButStr.md
Created January 10, 2023 22:19
Cro Error: Expected CookieValue but got Str
Type check failed in assignment to $!value; expected CookieValue but got Str ("\"2|1:0|10:16721936...)
in submethod BUILD at /home/cbwood/Projects/cro-http/lib/Cro/HTTP/Cookie.pm6 (Cro::HTTP::Cookie) line 155
  in method unpack-cookie at /home/cbwood/Projects/cro-http/lib/Cro/HTTP/Request.pm6 (Cro::HTTP::Request) line 167
  in method cookie-value at /home/cbwood/Projects/cro-http/lib/Cro/HTTP/Request.pm6 (Cro::HTTP::Request) line 189
  in method add-csrf-protection at /home/cbwood/Projects/cro-webapp/lib/Cro/WebApp/Form.rakumod (Cro::WebApp::Form) line 657
  in method HTML-RENDER-DATA at /home/cbwood/Projects/cro-webapp/lib/Cro/WebApp/Form.rakumod (Cro::WebApp::Form) line 459
@Xliff
Xliff / Gtk4Editor.md
Created January 4, 2023 06:53
My Quick 'n' Dirty Editor in GTK4

I wrote up a quick and dirty editor as a test case for some my GTK4 work.

Heres a sample screenie:

image

And here's what the code looks like:

use v6.c;
@Xliff
Xliff / EasyCron.md
Created October 18, 2022 02:42
A Simple Cron

Here's something I wrote for guifa a couple of days ago. I am thinking of turning it into a simple Rakuish event loop for my projects.

Is this a fairly decent implementation, or is this just NIH for cron?

Please share your thoughts.

my %suppliers;
@Xliff
Xliff / ParameterAliases.md
Created October 12, 2022 05:32
On Named Parameter Aliases...

Have I told you how wonderful I think Raku is?

Well I don't have enough words to do that.

However even the best languages have thier faults, and one of Raku's the following:

sub a ( :name(:named(:$names)) ) { ... }
@Xliff
Xliff / CroControllerMethods.md
Last active August 25, 2022 11:19
Methods as Cro Controllers

So I was looking through what I have written for $dayJob, as far as my work with a Cro-based application server is concerned.

It occurred to me that we might be able to clean up what is already a fairly clean Cro dispatch handler.

Consider this example:

  route {
    get ->                { ... }
    get -> '2'            { ... }