Skip to content

Instantly share code, notes, and snippets.

Method 'initialize' not found for invocant of class ''
current instr.: 'cardinal;Class;new' pc 2010 (src/classes/Class.pir:119)
called from Sub '!new' pc 1413 (src/builtins/classes.pir:116)
called from Sub 'setup' pc 2503 (src/classes/NilClass.pir:57)
called from Sub 'cardinal;cardinal;Compiler;main' pc 83720 (src/gen_actions.pir:6477)
.sub '' :load :init :anon
# Well need this later:
.local pmc nil
nil = get_hll_global 'nil'
# First, we'll make the parrot classes.
.local pmc obj_pclass, cls_pclass, mdl_pclass
obj_pclass = newclass 'Object'
use Digest::MD5 qw(md5_hex);
my $text = $ARGV[0];
my @colors = (21,23..51,63..87,99..231,246..253);
my $colors = @colors;
my $color = $colors[int(md5_hex($text)) % $colors];
print "[38;5;" . $color . "m$text\n" . "";
def handle_random(self, target, args):
index = -1
total_weight = 0
current_time = time.time()
for ttime in self.times:
total_weight += math.log(current_time - ttime)
r = self.rnd.random() * total_weight
for n in range(len(self.quotes)):
if index == -1:
weight = math.log(current_time - self.times[n])
require 'gtk2'
dialog = Gtk::FileChooserDialog.new("Open File",
nil,
Gtk::FileChooser::ACTION_OPEN,
nil,
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
[Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
dialog.select_multiple = true
grammar Assembly {
rule TOP { ^ <statement>+ $ }
rule statement {
<operator> <operand> $$
}
rule operator {
| lda
| ldx
| ldy
}
@treed
treed / app.psgi
Created May 15, 2011 10:12 — forked from tene/.gitignore
basic psgi worker running on nginx
#!/usr/bin/perl
use strict;
use warnings;
use Dancer;
get '/' => sub {
return "Hi!";
};
get '/bye' => sub {
token ip_address { [<octet> '.'] ** 3 <octet> }
token octet {
| 25<[0..5]>
| 2<[0..4]><[0..9]>
| 1<[0..9]><[0..9]>
| <[1..9]><[0..9]>
| <[0..9]>
}
@treed
treed / gist:1075186
Created July 11, 2011 01:31
Legend of Zelda Conversation Loading Code
The code that actually loads this is executed from $882B
LDA $045F
STA $0303
INC $045F
LDY $0415 ; $0415 apparently contains the conversation to be loaded
LDA $8000,Y
STA $00
INY
LDA $8000,Y
@treed
treed / gist:1103695
Created July 25, 2011 07:20
An Idea
#!/usr/bin/perl
use Modern::Perl;
use Coro;
sub do_a_thing {
my @args = @_;
my $cb = pop @args;
async {
for my $thing (@args) {
say "Thing $thing";