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;
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
awwaiid / 01 hive.rb
Last active December 24, 2015 06:09
Everyone adds a line, one at a time!
#!/usr/bin/env ruby
if ARGV == ['who', 'is', 'this?']
puts "THIS IS SPARTA!!!"
end
puts (words = File.read('/usr/share/dict/words')).length
good_words = words.split.select {|w| w.size > 6}
puts good_words.sample(3).join(' ')
Thread.new{ STDERR.<< ", \n A PLAY IN 3 PARTS.\n\n============ PAGE " }
puts good_words.length
puts File.read(__FILE__).split.detect{|_| _ =~ /SPARTA/}
#!/usr/bin/perl
use strict;
use IO::Handle;
STDOUT->autoflush();
STDERR->autoflush();
print "1\n";
my $is_swapped = `xmodmap -pke | grep 'keycode 10 = exclam'`;
use HOI::Match;
psub point_extract =>
"point (x _) :: r" => sub { my %args = @_; $args{x} + point_extract($args{r}) },
"nil" => sub { 0 };
point_extract(
[
{"type" => "point", "val" => [ 1, 2 ]},
{"type" => "point", "val" => [ 2, 4 ]},