Skip to content

Instantly share code, notes, and snippets.

@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" : "me@cpan.org",       |_______ 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<foo@bar.net>"; my $spec = DepSpec.new($str); say $spec.spec-matcher("Foo::Bar:ver<1.5+>:auth<foo@bar.net>");'
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 { < :: > }
}
@ugexe
ugexe / identity-spec-parser.pl6
Last active June 25, 2017 04:10
perl6 identity spec parsing grammar
use v6.c;
use Test;
grammar DepSpec::Grammar {
regex TOP { ^^ <name> [':' <key> <value>]* $$ }
regex name { <-restricted +name-sep>+ }
token key { <-restricted>+ }
@ugexe
ugexe / gist:4e4fa970df086ec789dada1164609633
Created May 22, 2017 04:31
perl6 -Ilib bin/zef -v --/test install Inline::Perl5
$ perl6 -Ilib bin/zef -v --/test install Inline::Perl5
===> Searching for: Inline::Perl5
===> Found: Inline::Perl5:ver('0.26'):auth('github:niner') [via Zef::Repository::Ecosystems<cpan>]
===> Searching for missing dependencies: LibraryMake, File::Temp
===> Found dependencies: File::Temp [via Zef::Repository::Ecosystems<p6c>]
===> Found dependencies: LibraryMake:ver('1.0.0'):auth('github:retupmoca') [via Zef::Repository::LocalCache]
===> Searching for missing dependencies: Shell::Command, File::Directory::Tree
===> Found dependencies: Shell::Command, File::Directory::Tree:auth('labster') [via Zef::Repository::Ecosystems<p6c>]
===> Searching for missing dependencies: File::Which, File::Find
===> Found dependencies: File::Find:ver('0.1'), File::Which [via Zef::Repository::Ecosystems<p6c>]