Skip to content

Instantly share code, notes, and snippets.

View JJ's full-sized avatar
🏠
Working from home

Juan Julián Merelo Guervós JJ

🏠
Working from home
View GitHub Profile
@JJ
JJ / letter.elm
Created December 2, 2017 08:45
Letter to santa in Markdown
import Html
import Markdown
letter : Html msg
letter =
Markdown.toHtml [class "content"] """
# Letter to Santa
I've been *real* **good** so I want this for Christmas
1. A Death Star.
2. A green unicorn.
@JJ
JJ / address.p6
Last active November 23, 2022 10:41
Extract heading from a markdown-marked letter
use Text::Markdown;
sub MAIN( Str $letter-to-santa = 'letters/dear-santa.md' ) {
my $letter = Text::Markdown::Document.new($letter-to-santa.IO.slurp());
say so $letter.items.grep( { $^þ ~~ Text::Markdown::Heading } );
}
@JJ
JJ / sections.p6
Created December 2, 2017 08:48
Finds the "good" in a series of sections
use Text::Markdown;
sub MAIN( Str $letter-to-santa = 'letters/dear-santa-sections.md' ) {
my $letter = Text::Markdown::Document.new($letter-to-santa.IO.slurp());
my $flip = False;
my @paragraphs = $letter.items.grep( { $flip = ($^þ ~~ Text::Markdown::Heading and $^þ.level == 2)?? !$flip !! $flip } );
say so any @paragraphs.map( {$^þ.Str ~~ /good/ } );
}
@JJ
JJ / list.p6
Last active November 23, 2022 10:45
Find items in a markdown list
use Text::Markdown;
use JSON::Tiny;
sub MAIN( Str $letter-to-santa = 'letters/dear-santa-list.md' ) {
my $letter = Text::Markdown::Document.new($letter-to-santa.IO.slurp());
my $flip = False;
my $list = $letter.items
.grep( { $flip = ( $flip
or so ($^þ ~~ Text::Markdown::Heading
and $^þ.level == 2
@JJ
JJ / is-product.p6
Last active November 23, 2022 10:46
Check whether an item in a list is a product
use JSON::Tiny;
use Wikidata::API;
sub MAIN( Str $toy-list = 'list.json' ) {
my $toys = from-json $toy-list.IO.slurp();
say $toys.grep( { is-product( $^þ) } );
}
sub is-product( Str $item ) {
@JJ
JJ / failing-c-channels.p6
Last active March 22, 2018 17:02
(Failing) concurrent channels in perl6
my Channel $c .= new;
my Channel $c2 = $c.Supply.batch( elems => 2).Channel;
my $count = 0;
$c.send($_) for ^40;
my $work = start react whenever $c -> $item {
$c.send( $item );
say "This is $item";
}
@JJ
JJ / get-tags-pod-perl6.sh
Created April 12, 2018 16:39
Extract the tags from the perl6/doc POD6
# git clone perl6/doc, cd doc
git grep "=begin pod" | perl6 -e 'say slurp().split("\n").grep( /tag/ ).map( * ~~ / \<(.+)\> / ).map( *.values.[0] ).join("\n")'
# (「convert」 「convert」 「convert」 「convert」 「convert」 「self」 「tutorial」 「self」 「tutorial」 「perl6」 「self」 「perl6」 「perl6」 「perl6」 「perl6」 「index」 「perl6」 「list」 「tutorial」 「perl6」 「convert」 「perl6」 「perl6」 「perl6」 「perl6」 「perl6」 「tutorial」 「perl6」 「perl6」 「perl6」 「perl6」 「perl6」 「perl6」 「tutorial」 「perl6」 「perl6」 「index」 「perl6」 「convert」 「perl6」 「perl6」 「perl6」 「perl6」 「pod6」 「perl6」 「tutorial」 「index」 「perl6」 「perl6」 「index」 「tutorial」 「perl6」)
@JJ
JJ / compilingmath-statx.md
Created November 1, 2018 12:23
Compilation test for Mathx::Stat

Created this test file

use v6;
use Test;
use-ok 'Mathx::Stat::Probability';

Run with

perl6 -Ilib t/use.t
@JJ
JJ / santa.md
Created December 1, 2018 08:40
Advent Calendar Article (for formatting)

Like 6 Perls in a Pod: document everything

Christmas season was approaching, and Santa was in a gloomy mood. His inbox was full with letters from boys and girls coming from all over.

But.

Were they letter to Santa? Was the kid properly identified by signature, so that you sent the gifts to the proper person and not someone else who might

@JJ
JJ / all.kids
Last active March 18, 2019 08:52 — forked from daotoad/all.kids
Getting to Know Perl6 From the Command Line: An Article for the 2018 Perl6 Advent Calendar
1234,Bobby Smith
1235,Rosa Felix
1236,Ramesh Patil
1245,Virginia Ryder
1356,Snively Witherspoon
1358,Burnedette Down
1366,Evelyn Tent