Skip to content

Instantly share code, notes, and snippets.

View awwaiid's full-sized avatar

Brock Wilcox awwaiid

View GitHub Profile
Err... see http://gist.github.com/327467 for the most up-to-date version
#!/usr/bin/perl
use strict;
use SDL;
use SDL::App;
use SDL::Game::Rect;
use SDL::Event;
use SDL::Events;
@awwaiid
awwaiid / coro_sdl.pl
Created March 10, 2010 02:59
Coro+SDL Demo
#!/usr/bin/perl
use strict;
use SDL;
use SDL::App;
use SDL::Game::Rect;
use SDL::Event;
use SDL::Events;
use Coro;
# Boiled down to it's essentials? This is how to write a twiggy-compatible
# Coro-using PSGI app.
use strict;
use EV;
use Coro::AnyEvent;
use Coro;
my $app = sub {
# Original API
my $grammar = Marpa::Grammar->new(
{ start => 'Expression',
actions => 'My_Actions',
default_action => 'first_arg',
rules => [
{ lhs => 'Expression', rhs => [qw/Term/] },
{ lhs => 'Term', rhs => [qw/Factor/] },
{ lhs => 'Factor', rhs => [qw/Number/] },
{ lhs => 'Term', rhs => [qw/Term Add Term/], action => 'do_add' },
@awwaiid
awwaiid / myboardgame.pl
Created April 25, 2011 19:46
Linux Format Perl Redone
#!/usr/bin/perl
use strict;
use Image::Magick;
# auxiliary variables
my $img_id = 0; #loop index
my @ordered_squares;
my $rotation = 180;
#Width and Height of each box, squares per side
@awwaiid
awwaiid / output.txt
Created February 13, 2012 03:05
Unit Testing Spim
$ prove -v unittest.t
unittest.t ..
ok 1 - expect_run
ok 2 - Load program
ok 3 - print $a0
ok 4 - $a0 starts out as 0
ok 5 - Stepping toward [main]
ok 6 - Initial jump to [main]
ok 7 - Stepping past [main]
ok 8 - print $a0
awwaiid@misao:~/tmp/modtest$ cat -n MyModule.pm6
1 module MyModule {
2 sub hello {
3 say "Hello!";
4 }
5 }
6
awwaiid@misao:~/tmp/modtest$ cat -n demo.p6
1 #!/usr/bin/env perl6
2
------------- [List variables] ---------------
my vars: $_ $! @parent_vars $*DISPATCHER @my_vars RETURN $¢ $x $/
caller vars: $y $_ $! $*DISPATCHER RETURN $¢ $x $/
------------- [Eval Variable] ---------------
Local $x=5
EVAL $x=5
#!/usr/bin/env perl6
# Run with: perl6 --setting=RESTRICTED webrepl.p6
use HTTP::Server::Tiny;
use URI::Encode;
use HTML::Entity;
use UUID;
sub parse-params($data) {
#!/usr/bin/env perl6
use Grammar::Tracer;
# use Grammar::Debugger;
grammar Offsides {
token TOP {
<tree>*
}