Skip to content

Instantly share code, notes, and snippets.

@pmurias
pmurias / main.p6
Created October 14, 2018 18:19
99 Bottles of Beer
for 99...1 -> $bottles {
sing $bottles, :wall;
sing $bottles;
say "Take one down, pass it around";
sing $bottles - 1, :wall;
say "";
}
#| Prints a verse about a certain number of beers, possibly on a wall.
sub sing(
@pmurias
pmurias / index.html
Created October 17, 2018 14:17
A P6 DOM clock
Time: <span id="clockDisplay"></span>
@pmurias
pmurias / test_precompiled.p6
Created January 2, 2019 16:56
A script to run tests under precompilation
my $precompiled_tests = 't/precompiled'.IO;
mkdir($precompiled_tests);
for @*ARGS.map(*.IO) -> $file {
my $name-part = $file.relative($file.parent.parent).IO;
my $module = $file.basename.IO.extension('', :parts(0..*));
if ($module ~~ /^\d/) {
$module = 'module_' ~ $module.Str;
@pmurias
pmurias / gist:292b3ac5b672d9e690d823aca1ecc767
Created January 11, 2019 10:28
Ruby style dsls and ast tree correspondence.
Q::Block.new(Q::Statement::Expr.new(Q::Postfix::Call.new(
Q::Identifier.new("say"),
Q::Literal::Str.new("OH HAI")
)));
block {
expr {
call {
identifier "say";
str "OH HAI";
@pmurias
pmurias / gist:d868e9c9d5421d741bbd3d110b5ff55f
Created January 15, 2019 19:04
async/await stacks sometimes work
async function bottom() {
console.log('in bottom');
const stack = new Error().stack;
console.log('stack:', '<<<' + stack + '>>>');
console.log(typeof stack);
console.trace('stack trace');
}
async function middle() {
await bottom();
@pmurias
pmurias / bug.js
Created April 6, 2019 14:28
chrome bug?
const array = [0,1,2,3,4,5,6];
array.shift();
array.shift();
array.shift();
array[3] = '_set_';
array[10] = '_set_';
console.log('atpos', array.map(x => x.toString()).join(','));
@pmurias
pmurias / chalk.p6
Created June 20, 2019 13:28
Example of using a node.js module in rakudo.js
use lib 'nodejs#' ~ $*PROGRAM.parent.add('node_modules').absolute;
use chalk:from<node.js>;
say("Hello {chalk.blue("Blue")} World");
@pmurias
pmurias / index.html
Created September 23, 2019 10:57
Spaceship drawing demo
<html>
<head>
<script defer src="spaceship.p6"></script>
</head>
<body style='background-color: blue'>
<canvas id='spaceship' height='500' width='500' style='border: 1px pink;'></canvas>
</body>
</html>
# Dependencies
Install node 10.16.0 or 12.3.1 from https://nodejs.org
# Getting started with node.js rakudo.js
The easiest way is to install the rakudo package from npm
```bash
mkdir tutorial-project # Create a fresh project directory

Dependencies

Install node 10.16.0 or 12.3.1 from https://nodejs.org

Getting started with node.js rakudo.js

The easiest way is to install the rakudo package from npm

mkdir tutorial-project # Create a fresh project directory