Skip to content

Instantly share code, notes, and snippets.

View cognominal's full-sized avatar

Stéphane Payrard cognominal

View GitHub Profile
@cognominal
cognominal / foo.pl
Created June 10, 2011 01:33
>{$len} does not use the $len value previously set in the regex
#! /usr/bin/perl
use feature ':5.10';
use re 'eval';
my $len;
say $];
">>" =~ m/ >{2} /x;
say $&;
$len = 0;
@cognominal
cognominal / foo.pl
Created June 10, 2011 10:39
I want to use >{$len} to match the number of closing '>' to the number of opening '>'; does not work
#! /usr/bin/perl
use feature ':5.10';
use re 'eval';
my $len;
say $];
">>" =~ m/ >{2} /x;
say $&;
$len = 0;
@cognominal
cognominal / gitprompt.pl
Created July 22, 2011 13:50
A small script to get information on the current git repos #perl
#! /usr/bin/env perl
=pod
=head1 NAME
gitprompt -- output info about git status, current repo, current branch name for use in a shell prompt
=head1 DESCRIPTION
Make sure gitprompt is executable and accessible from you PATH.
With the bash shell, add the following line in your C<~/.profile>
@cognominal
cognominal / mp.pl
Created August 1, 2011 20:20
A utility for matching, classifying and counting lines #perl
#! /usr/bin/env perl
use feature ':5.10';
use strict;
use autodie;
use List::Util qw( max );
=pod
=head1 NAME
@cognominal
cognominal / gist:1129884
Last active March 26, 2021 14:54
raku 2015 #prez
This post talks about using node.js to improve the ergonomy of a web
page : the raku compiler feature matrix. It quickly presents the
the raku project current state, then move to the specifics of my
small project written in coffeescript and to be run on node.js. I
briefly discuss some of coffeescript merits. Thx to the use of the
jsdom library pulled from the npn archive network, my project can use
jquery to exploit a web page DOM API outside of a web browser.
raku, the next generation Perl environment, currently has two
competing experimental implementations : rakudo and niecza.
@cognominal
cognominal / octolia.svg
Created August 8, 2011 06:50
camelia transmogrified in an octocat
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cognominal
cognominal / test.html
Created August 15, 2011 00:40
problem with visual feeback on editable elements
<!DOCTYPE html>
<!--
I want to edit an editable element if I click on it.
Elements of class "editing" are editable as per the css.
Clicking an element of class code makes it editable.
Typing escape makes the englobing element editable.
Everything works fine except that the blue box indicating
the editable area does not appear until I move the caret with
@cognominal
cognominal / parse-tree.pm
Created August 21, 2011 10:01
Matches the output of --target=ast #raku
BEGIN { @*INC.push('/Users/stephanepayrard/git/grammar-debugger/lib/') }
# use Grammar::Tracer;
grammar ParseTree {
sub t { say "ok" }
rule TOP { ^ '"parse"' "=>" <scalrule> }
rule rule { [ \< <nm> \> | \[ $<nr>=\d+ { say "===$<nr>" }\] ] "=>" [ <scalrule> | <aryrule> | <parseref> ] }
rule scalrule { PMC "'Regex;Match'" '=>' <string> \@ \d+ [ \{ <rule>+ \} <O>? ]? }
@cognominal
cognominal / bug.p6
Created November 25, 2011 13:04
problematic braced lexical within a double quoted string :
my $data = a => ( b => 'c');
# unexpected different outputs
say test $data;
say test1 $data;
sub test($p) {
my $s = '';
$s ~= "$p.key() => (" ~ test($p.value) ~ ")" if $p ~~ Pair;
$s ~= $p if $p ~~ Str;
@cognominal
cognominal / gist:1596551
Created January 11, 2012 20:16
controlling backtrace with env var RAKUDO_BACKTRACE
--- a/src/core/Exception.pm
+++ b/src/core/Exception.pm
@@ -69,10 +69,15 @@ do {
$err.print: $e.gist;
$err.print: "\n";
}
- elsif is_runtime($ex.backtrace) {
+ elsif %*ENV<RAKUDO_BACKTRACE> | is_runtime($ex.backtrace) {
$err.print: $e;
$err.print: "\n";