Skip to content

Instantly share code, notes, and snippets.

@ugexe
ugexe / InstallationWithHook.pm6
Last active July 7, 2018 01:14
Perl6 post-install hook
# PERL6LIB="/Users/ugexe/repos/CompUnit-Repository-InstallationWithHook/lib"\
# perl6 -I /Users/ugexe/repos/zef /Users/ugexe/repos/zef/bin/zef\
# -to="CompUnit::Repository::InstallationWithHook#/Users/ugexe/.rakudobrew/moar-blead-master/install/share/perl6/site"\
# install /Users/ugexe/repos/zef
class CompUnit::Repository::InstallationWithHook is CompUnit::Repository::Installation {
method short-id { 'inst-with-hook' }
method path-spec { $.short-id ~ '#' }
multi method install(Distribution $dist) {
return unless my $result = callsame();
@ugexe
ugexe / zef-web-api-poc-gql.pl6
Created October 15, 2017 06:10
Perl 6 module metadata microservice that uses installed modules as the data source to both RESTful-ish and GraphQL APIs
#!/usr/bin/env perl6
use v6;
use Cro::HTTP::Server;
use Cro::HTTP::Router;
use Cro::HTTP::BodyParser;
use GraphQL;
require GraphQL::GraphiQL;
# THE DATABASE/MODEL READS/INDEXES DIRECTLY FROM THE MODULES INSTALLED ON YOUR SYSTEM
@ugexe
ugexe / zef-web-api-poc.pl6
Last active October 14, 2017 00:59
Perl 6 module metadata microservice that uses installed modules as the data source
#!/usr/bin/env perl6
use v6;
use Cro::HTTP::Server;
use Cro::HTTP::Router;
use Cro::HTTP::BodyParser;
# View all available distributions
# curl http://localhost:3000/installed
@ugexe
ugexe / meta-and-dep-specs.md
Last active September 22, 2017 17:18
Notes on perl6 meta and dependency specs
                                                {                                           ________________________________ 
                                                    "meta-spec" : "1",                                                      | (not sure if CUR needs to know meta-spec version)
                                                    "perl"      : "6.c",                                                    |       ------------
                                                                                __                                          |                   |
                                                    "name" : "Foo",               |                                         |                   |
                                             __                                   |                                         |                   |
                                            |       "auth" : "[email protected]",       |_______ Distribution DepSpec             |          
@ugexe
ugexe / json-resource-service.pl6
Created August 31, 2017 20:31
Basic get/delete/put/post json store example using Perl 6 and Cro
#!/usr/bin/env perl6
use v6;
use Cro::HTTP::Server;
use Cro::HTTP::Router;
use Cro::HTTP::BodyParser;
# Create a new resource
# curl --verbose -H "Content-Type: application/json" -X POST -d '{ "foo" : "123" }' http://localhost:3000/resource
@ugexe
ugexe / appveyor-webhook2irc.pl6
Last active August 31, 2017 16:12
Appveyor build status updates received from a web hook and delivered to an irc channel
#!/usr/bin/env perl6
use v6;
use IRC::Client;
use Cro::HTTP::Server;
use Cro::HTTP::Router;
use Cro::HTTP::BodyParser;
# Add the following section to an appveyor.yml
#
@ugexe
ugexe / nqp.diff
Last active August 22, 2017 16:10
Why are these changes not equivalent?
$ git diff
diff --git a/src/QRegex/Cursor.nqp b/src/QRegex/Cursor.nqp
index b10804c9f..767d79f3c 100644
--- a/src/QRegex/Cursor.nqp
+++ b/src/QRegex/Cursor.nqp
@@ -87,11 +87,11 @@ role NQPMatchRole is export {
method to() { $!to < 0 ?? $!pos !! $!to }
method CURSOR() { self }
method PRECURSOR() { self."!cursor_init"(nqp::getattr($!shared, ParseShared, '$!target'), :p($!from)) }
- method Str() { $!pos >= $!from ?? nqp::substr(nqp::getattr($!shared, ParseShared, '$!target'), $!from, nqp::sub_i(self.to, $!from)) !! '' }
proto method candidates(|) {*}
multi method candidates(Str:D $name, :$auth, :$ver, :$api) {
return samewith(CompUnit::DependencySpecification.new(
short-name => $name,
auth-matcher => $auth // True,
version-matcher => $ver // True,
api-matcher => $api // True,
));
}
multi method candidates(CompUnit::DependencySpecification $spec) {
unit module Zef::Utils::Distribution;
my grammar DepSpec::Grammar {
regex TOP { ^^ <name> [':' <key> <value>]* $$ }
regex name { <-restricted +name-sep>+ }
token key { <-restricted>+ }
token value { '<' ~ '>' [<( [[ <!before \>|\\> . ]+]* % ['\\' . ] )>] }
token restricted { [':' | '<' | '>' | '(' | ')'] }
@ugexe
ugexe / DepSpec.pm6
Created June 26, 2017 04:04
perl6 -Ilib -e 'use DepSpec; my $str = "Foo::Bar:ver<1.5>:auth<[email protected]>"; my $spec = DepSpec.new($str); say $spec.spec-matcher("Foo::Bar:ver<1.5+>:auth<[email protected]>");'
my grammar DepSpec::Grammar {
regex TOP { ^^ <name> [':' <key> <value>]* $$ }
regex name { <-restricted +name-sep>+ }
token key { <-restricted>+ }
token value { '<' ~ '>' [<( [[ <!before \>|\\> . ]+]* % ['\\' . ] )>] }
token restricted { [':' | '<' | '>' | '(' | ')'] }
token name-sep { < :: > }
}