Skip to content

Instantly share code, notes, and snippets.

View tene's full-sized avatar

Stephen Weeks tene

  • Sunnyvale, CA
View GitHub Profile
module Demo;
sub omg is export { say "omgwtf!" }
[sweeks@kweh ~]$ perl slasho.pl
Rate without with
without 1468429/s -- -4%
with 1536098/s 5% --
#!/usr/bin/perl
use feature ':5.10';
use strict;
sub act {
my $action = shift;
no strict 'refs';
&{"Actions::$action"}();
}
sub use_skill {
my $id = gen_new_answer_id();
$answers->{$id} = sub {
my ($response) = @_;
my $skill = choose($response->{skills});
send('use_skill',$skill);
}
send('get', $id, 'skills');
}
sub use_skill {
my $id = gen_new_answer_id();
$answers->{$id} = sub {
my ($response) = @_;
my $skill = choose($response->{skills});
send('use_skill',$skill);
}
send('get', $id, 'skills');
}
Store a map, minus all the players
Load a map in preference to reading from ascii
save the map on shutdown
Store regular and scheduled events in the map itself. Pull them out and schedule them after loading.
Add some commands to modify the map, see how it works out.
--------------------------------
copy client.pl to admin.pl
abstract out common code
choose some reasonable commands
toggle between wall and open tile
use strict;
use Coro::State;
use Test::More tests => 2;
my $input;
my $main = new Coro::State;
our $tests = new Coro::State sub {
our $tests;
.sub main :main
.local int redux
.local pmc cont
redux = 0
print "calling test\n"
cont = test()
print "back from test\n"
if redux goto done
redux = 1
print "calling cont\n"
[sweeks@kweh rakudo]$ ./perl6
> multi bar (@a where [*,2,3]) { say "by jove" }
> multi bar (@a) { say "bad luck" }
> bar([1,1,1])
bad luck
> bar([1,2,3])
by jove
DATE=$(date +%F)
YESTERDAY=$(date -d yesterday +%F)
DIR=/mnt/backups/$DATE
PREVDIR=/mnt/backups/$YESTERDAY
mkdir -p $DIR
backup() {
rsync -a --link-dest=$PREVDIR$1 $1/ $DIR$1
}