This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Dancer; | |
get '/' => sub { | |
return "Hi!"; | |
}; | |
get '/bye' => sub { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Assembly { | |
rule TOP { ^ <statement>+ $ } | |
rule statement { | |
<operator> <operand> $$ | |
} | |
rule operator { | |
| lda | |
| ldx | |
| ldy | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" . "[0m"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[22:48] [inara:/Users/treed/code/cardinal]% ./cardinal t/08-class.t | |
Method 'iterator' not found for invocant of class 'String' | |
current instr.: 'parrot;POST;Compiler;pir_children' pc 9663 (src/POST/Compiler.pir:70) | |
called from Sub 'parrot;POST;Compiler;pir_children' pc 9663 (src/POST/Compiler.pir:70) | |
... call repeated 4 times | |
called from Sub 'parrot;POST;Compiler;pir' pc 9945 (src/POST/Compiler.pir:212) | |
called from Sub 'parrot;POST;Compiler;pir_children' pc 9663 (src/POST/Compiler.pir:70) | |
... call repeated 2 times | |
called from Sub 'parrot;POST;Compiler;pir' pc 9945 (src/POST/Compiler.pir:212) | |
called from Sub 'parrot;POST;Compiler;pir_children' pc 9663 (src/POST/Compiler.pir:70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The usual class setup stuff is combined with that of Object and Module. | |
# Look in src/builtins/classes.pir | |
.namespace ['Class';'meta'] | |
.sub 'new' :method | |
.param pmc superclass :optional | |
.param int super_flag :opt_flag | |
if super_flag goto have_super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.namespace ['CardinalException'] | |
.sub 'onload' :anon :init :load | |
.local pmc excproto, core_type, hll_type, interp | |
excproto = newclass 'CardinalException' | |
$P0 = get_class 'CardinalObject' | |
addparent excproto, $P0 | |
$P0 = get_class ['parrot';'Exception'] |