Skip to content

Instantly share code, notes, and snippets.

grammar Confusion {
token TOP { ^ <element> $ }
rule element { <name> <list> }
rule list { '(' ~ ')' [ <name> ]+ % ',' }
rule name { \w+ }
}
class Build {
method element ($/) { }
# method list ($/) { }
subset HTML of Str;
subset HEAD of Str;
subset BODY of Str;
sub body( --> BODY ) { '<body></body>' }
sub head( --> HEAD ) { '<head></head>' }
subset HTML-nodes of Cool where HEAD|BODY;
# sub html(HTML-nodes @nodes, :$lang?, :$xml-lang?, :$dir? where * eq 'ltr'
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>... <title>Untitled</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <style type="text/css"> body { margin-left: 4em; margin-right: 4em; } div.pod-content { padding-left: 20em; } div.marginale { float: right; margin-right: -4em; width: 18em; font-size: 66%; text-align: left; } h1.title { font-size: 200%; } h1 { font-size: 160%; } h2 { font-size: 140%; } h3 { font-size: 120%; } h4 { font-size: 100%; } h5 { font-size: 100%; } h6 { font-size: 100%; } h7 { font-size: 100%; } pre { padding-left: 2em; } ul.toc { list-style-type: none; padding-left: 0; margin-left: 0 } ul.toc ul { list-style-type: none; } ul.toc ul { margin-left: 0; padding-left: 1em; } ul.toc li { margin-left: 0; padding-left: 0em; } ul.toc li.toc-level-1 { padding-left: 1em; } ul.toc li.toc-level-
use v6;
use lib '.';
use the-lib;
use v6;
role ConcatGuard[::T-right] {
has T-right $.attr is rw;
method left-type () is nodal { self.WHAT }
method right-type () is nodal { T-right }
method convert () {...} # --> T-right
method new (T-right) {...}
# our proto sub infix:<~>(|) {*}
# our multi sub infix:<~>(T-left \l, T-right \r) {
@gfldex
gfldex / Lib.pm
Last active January 13, 2016 12:30
use v6;
role ConcatGuard[::T-right] {
has T-right $.attr is rw;
method left-type () is nodal { self.WHAT }
method right-type () is nodal { T-right }
method convert () {...} # --> T-right
method new (T-right) {...}
}
#!/usr/bin/env perl6
use v6;
# Return a string of $length bytes where each bit is 1 50% of the time
multi sub random-bytes(Int $length) returns array[uint8] {
array[uint8].new((0x00..0xff).roll($length))
# same thing and way faster
}
# Return a string of $length bytes where each bit is 1 with probability $prob
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html lang="en" ng-app="moarProfApp" ng-controller="NavigationController">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MoarVM Profiler Results</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<style>
@gfldex
gfldex / hibbified-249.p6
Created January 14, 2016 14:16
0.424330944646612s/generation
#!/usr/bin/env perl6
use v6;
# Return a string of $length bytes where each bit is 1 50% of the time
multi sub random-bytes(Int $length) returns array[uint8] {
array[uint8].new((0x00..0xff).roll($length))
# same thing and way faster
}
# Return a string of $length bytes where each bit is 1 with probability $prob
use v6;
# Let's prefix &say with the line number it's called from
module BaseLib {
role BaseRole[::T] is export {
has T $.attr is rw;
}