Skip to content

Instantly share code, notes, and snippets.

View tadzik's full-sized avatar
🐴

Tadeusz Sośnierz tadzik

🐴
View GitHub Profile
@tadzik
tadzik / bj.pl
Created September 28, 2010 13:44
my @s=<♠ ♣ ♥ ♦>;my @r=2..10,<j q k a>;my %v=j=>10,:q(10),k=>10,a=>1|11;my @d=map {[$^a,$^b]},(@s X @r);@d.=pick(*);my @p=[],[];sub a(@c is rw){@c.unshift(@d.shift)};sub b(@c){my $v=@c.map({%v{.[1]}||.[1]}).reduce(*+*);$($v.grep({$_ <21}))||$v[0]};for @p {a($_);a($_);say '-'x 33;loop {if b($_)>21 {say $_~' is over 21';last};say b($_);say ~$_;last if prompt('(h) hit (s) sit? ')~~'s';a($_)}};say 'Winner: ',[max]@p.grep({b($_)<=21})
What is:
– multis (types aswell)
– testing
– metaops
– hyperops
– regexes
– signatures
– new oop
– modules
– junctions
┌─[tadzik@yavin4]─[~]
└─[%]─> perl6
> role something {}; our multi trait_mod:<is>(something $trait, $block, $arg) { .WHAT.say for $trait, $block, $arg }
trait_mod:<is>
> sub foo ($a) is something('foobar') { say "I has $a" }
No applicable candidates found to dispatch to for 'trait_mod:<is>'. Available candidates are:
:(something $trait, Any $block, Any $arg)
:(Mu $child, Role $r)
:(Routine $r, Any :default($default)!)
:(Code $block, Any $arg?, Any :export($export)!)
┌─[tadzik@yavin4]─[~/src/perl6]
└─[%]─> cat myapp.pl
#module PerlApp {
our %commands;
# our sub add_command ($name, $sub) {
# 'almost there'.say;
# %commands{$name} = $sub; # crashes here
# 'got it'.say;
# }
From 675ab134208942518240031cad38716961b6ae2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= <tadzikes@gmail.com>
Date: Sun, 7 Nov 2010 13:01:59 +0000
Subject: [PATCH] Simplified Range.pick a bit
---
src/core/Range.pm | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/core/Range.pm b/src/core/Range.pm
@tadzik
tadzik / gist:672490
Created November 11, 2010 13:21
schema.sqlite for DancerJukebox
CREATE TABLE `queue` (
`id` integer NOT NULL primary key autoincrement,
`path` text,
`playlist_id` int(11) default NULL,
`played` datetime default NULL,
`queued` datetime default NULL
);
From 241a419edf0eb045b9770bb2cc44e7bad11c60b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= <tadzikes@gmail.com>
Date: Thu, 11 Nov 2010 16:01:06 +0000
Subject: [PATCH 2/2] Added myself to CREDITS
---
CREDITS | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/CREDITS b/CREDITS
diff --git a/src/cheats/process.pm b/src/cheats/process.pm
index b97a7b8..d0526c6 100644
--- a/src/cheats/process.pm
+++ b/src/cheats/process.pm
@@ -10,10 +10,7 @@ package PROCESS {
our $OUT = IO.new(:PIO(pir::getstdout__P));
our $ERR = IO.new(:PIO(pir::getstderr__P));
- our $PERL = {
- name => 'rakudo',
grammar Mysite {
token TOP {
<main> |
<about> |
<contact> |
<cookie> |
<api> |
<e404>
}
token main { ^ '/' $ }
use HTTP::Server::Simple::PSGI;
grammar Mysite {
token TOP { <main> | <about> | <contact> | <api> | <e404> }
token main { ^ '/' $ }
token about { ^ '/about' $ }
token contact { ^ '/about/contact' $ }
token api { ^ '/api/' $<type>=[ \S ]* $ }
token e404 { }
}