Skip to content

Instantly share code, notes, and snippets.

View moritz's full-sized avatar

Moritz Lenz moritz

View GitHub Profile
@moritz
moritz / gist:864305
Created March 10, 2011 15:46
niecza spectest failures
t/spec/integration/no-indirect-new.t .......................... Unhandled exception: System.IndexOutOfRangeException: Array index is out of range.
Server stack trace:
at Niecza.CLRBackend.LexSimple..ctor (System.Object[] l) [0x00000] in <filename unknown>:0
at Niecza.CLRBackend.StaticSub..ctor (Niecza.CLRBackend.Unit unit, System.Object[] s) [0x00000] in <filename unknown>:0
at Niecza.CLRBackend.Unit..ctor (System.Object[] from) [0x00000] in <filename unknown>:0
at Niecza.CLRBackend.CLRBackend.LoadDepUnit (System.String name) [0x00000] in <filename unknown>:0
at Niecza.CLRBackend.CLRBackend.RunMain (System.String dir, System.String contents, System.String[] argv) [0x00000] in <filename unknown>:0
at Niecza.CLRBackend.DownCallAcceptor.Call (System.AppDomain up, System.String[] args) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Runtime.Remoting.RemotingServices:InternalExecute (System.Reflection.MethodBase,object,object[],object[]&)
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render('index');
};
app->start unless caller;
@moritz
moritz / shell 1
Created March 19, 2011 19:24
myappl.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
die "foo";
$self->render('index');
};
@moritz
moritz / gist:878489
Created March 20, 2011 17:49
Perl 6 error messages (don't believe the classification yet)
Syntax
obsolete
* <STDIN> $*IN.lines
* <> lines() to read input,\n or ('') to represent the null string,\n or () to represent Nil
* do...$s repeat...$s
C-style "for (;;)" loop "loop (;;)"
foreach for
Perl 5's $all construct a smartmatch like \$! ~~ $inside
...
Whitespace required after keyword
use v6;
sub transformed_field(@field) {
my %transform = ('*' => '*', '.' => 0);
my @t = @field.map: { [ .map: { %transform{$_}} ] };
for @t.keys X @t[0].keys -> $x, $y {
next unless @t[$x][$y] eq '*';
for ($x - 1 max 0) .. ($x + 1 min @t.end)
X ($y - 1 max 0) .. ($y + 1 min @t[0].end) -> $xa, $ya {
@t[$xa][$ya]++ if @t[$xa][$ya] ne '*';
@moritz
moritz / iso-639-2-lang-codes.pl
Created March 26, 2011 21:27
Cute Mojo::UserAgent example
use 5.012;
use Mojo::UserAgent;
use warnings;
binmode STDOUT, ':encoding(UTF-8)';
my $ua = Mojo::UserAgent->new();
my $r = $ua->get('http://www.loc.gov/standards/iso639-2/php/code_list.php');
for my $row ($r->res->dom('tr')->each) {
my ($three, $two, $english_name, $french_name) =
map $_->text, $row->find('td')->each;
$ cat server.pl
my $s = IO::Socket::INET.new(:localhost('::1'), :localport(1024), :listen);
say "Server running";
while my $client = $s.accept {
print $client.recv();
$client.close;
}
$ ./perl6 server.pl
Server running
@moritz
moritz / gist:922155
Created April 15, 2011 18:04
backtrace
# Failed test 'call a parrot sub'
# at t/src/extend.t line 339.
# Exited with error code: [SIGNAL 11]
# Received:
# src/embed.c:430: failed assertion '!"Bad idea"'
# Backtrace - Obtained 6 stack frames (max trace depth is 32).
# /home/moritz/p6/rakudo/parrot/blib/lib/libparrot.so.3.2.0(+0x19581f) [0x7fefb8eb481f]
# /home/moritz/p6/rakudo/parrot/blib/lib/libparrot.so.3.2.0(Parrot_confess+0x8b) [0x7fefb8eb47eb]
# /home/moritz/p6/rakudo/parrot/blib/lib/libparrot.so.3.2.0(+0x18ad5e) [0x7fefb8ea9d5e]
@moritz
moritz / gist:989813
Created May 24, 2011 21:47
rakudo/nom build failure
/home/moritz/perl5/perls/perl-5.14.0/bin/perl5.14.0 build/merge_pm.pl src/CORE.setting/traits.pm src/CORE.setting/stubs.pm src/CORE.setting/natives.pm src/CORE.setting/Mu.pm src/CORE.setting/Any.pm src/CORE.setting/Cool.pm src/CORE.setting/Int.pm src/CORE.setting/Num.pm src/CORE.setting/Str.pm src/CORE.setting/Block.pm src/CORE.setting/Code.pm src/CORE.setting/Method.pm src/CORE.setting/Parameter.pm src/CORE.setting/Routine.pm src/CORE.setting/Signature.pm src/CORE.setting/Sub.pm src/CORE.setting/you_are_here.pm > src/gen/CORE.setting
./perl6 --setting=NULL --target=pir --output=src/gen/CORE.setting.pir src/gen/CORE.setting
# Importing Mu
# Importing Any
# Importing Cool
# Importing Attribute
# Importing Signature
# Importing Parameter
# Importing Code
# Importing Block
@moritz
moritz / gist:1000178
Created May 31, 2011 08:44
running Configure.pl in a clean nqp checkout
$ perl Configure.pl
Use of uninitialized value $rev in pattern match (m//) at tools/lib/NQP/Config.pm line 11.
Use of uninitialized value $rev in concatenation (.) or string at tools/lib/NQP/Config.pm line 11.
Unrecognized revision specifier ''