Skip to content

Instantly share code, notes, and snippets.

View tene's full-sized avatar

Stephen Weeks tene

  • Sunnyvale, CA
View GitHub Profile
[sweeks@sweeks-laptop parrot]$ ./parrot /tmp/subthrow.pir
throwing parrot;Exception
in EH, caught a: Exception
message is: :(
Resuming...
back from EH
throwing LolException
in EH, caught a: LolException
message is: OHAI
Resuming...
.sub main :main
.local pmc cl, kl, meth, kli, i
cl = get_class 'Class'
kl = subclass cl, 'Klass'
kli = new kl
i = new kli
.end
@tene
tene / gist:722248
Created November 30, 2010 19:43
ignore-anon-class-name.patch
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm
index 1acdee4..9e44a7b 100644
--- a/src/Perl6/Actions.pm
+++ b/src/Perl6/Actions.pm
@@ -917,7 +917,9 @@ method package_def($/, $key?) {
if $<def_module_name> {
my $name := ~$<def_module_name>[0]<longname><name>;
if $name ne '::' {
- $/.CURSOR.add_name($name, 1);
+ if $*SCOPE ne 'anon' {
module Foo {
CATCH {
say 'b';
}
sub fooify {
die "wtf";
}
}
@tene
tene / rlp.pl
Created September 27, 2010 21:15
use v5.10.0;
use strict;
use warnings;
use Data::Dumper;
my $default = 50;
sub lol {
say STDERR "default: $default";
my ($intensity) = ("foo 123" =~ m{^foo (\d+)?$});
return {
You're tasked with enforcing the rule "If you are less than 21 years old, you are restricted to ordering non-alcoholic drinks."
You have a set of receipts which list an age and a drink order, with one or the other obscured.
Given the information you can see on the following receipts, which fields do you need to reveal to detect violations of the rule?
1 2 3 4
--------------------------------------------
age: | 19 | 23 | XX | XX |
# ### ##
### ###
### #*#
# ##* *#
# ##* *#
### #*#
### ###
# ### ##
This is looking forward; the blank spaces are the mine shafts.
@tene
tene / rlp.pl
Created September 17, 2010 06:55
use 5.010;
use strict;
use warnings;
use List::MoreUtils qw/natatime zip/;
my $rlp = [ 1, 2, [3, 4, [5, 6]]];
my $rlp1 = [ 1, 2, [3, 4, [5, 6]]];
my $rlp2 = [ 1, 2, [3, 4, [5, 9]]];
sub rcmp {
my ($l, $r, $test) = @_;
@tene
tene / B.pm
Created September 4, 2010 21:33
module A::B;
sub C is export { say "called C" };
@tene
tene / rlp.pl
Created September 3, 2010 21:53
my @clusters = <a b c d e f>;
my @backed_up = <a b d f>;
my @not = @clusters.grep(* eq none(@backed_up));
say @not.perl; # ["c", "e"]