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
months = [ 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] | |
def is_leap_year(year): | |
if (year % 4): | |
return 0 | |
elif (year % 100): | |
return 1 | |
elif (year % 400): | |
return 0 | |
else: |
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
BEGIN { | |
unshift @INC, sub { | |
die if $_[1] eq 'XML/LibXML.pm'; | |
return undef; | |
} | |
} | |
use XML::LibXML; |
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
--- a/lib/Werewolf/BBS/Controller/Chatter.pm | |
+++ b/lib/Werewolf/BBS/Controller/Chatter.pm | |
@@ -177,8 +177,17 @@ sub view | |
my $village = $c->stash->{village}; | |
my $chatter_api = $self->api('Chatter'); | |
- my $chat = $chatter_api->find( $chat_id ); | |
- if (! $chat || $chat->village_id ne $village->id) { | |
+ | |
+ my $chat; |
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
--- a/lib/Plack/Test.pm | |
+++ b/lib/Plack/Test.pm | |
@@ -116,7 +116,7 @@ my @TEST = ( | |
}, | |
diff --git a/lib/Plack/Test.pm b/lib/Plack/Test.pm | |
index fa9637d..40c4174 100644 | |
--- a/lib/Plack/Test.pm | |
+++ b/lib/Plack/Test.pm | |
@@ -116,7 +116,7 @@ my @TEST = ( | |
}, |
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
package Encodable; | |
use Moose::Role; | |
has encoder => ( | |
is => 'rw', | |
isa => 'CodeRef' | |
); | |
sub encode { | |
my $self = shift; |
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
package Acme::Morse; | |
use Moose::Role; | |
requires 'print_output'; | |
sub encode { | |
my ($self, $thing) = @_; | |
my $morse = ....; # 変換 | |
$self->print_output($morse); |
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 strict; | |
use KiokuDB; | |
use KiokuDB::Class; | |
print "Class::MOP -> ", $Class::MOP::VERSION, "\n"; | |
print "Moose -> ", $Moose::VERSION, "\n"; | |
print "KiokuDB -> ", $KiokuDB::VERSION, "\n"; | |
my $meta = Moose::Meta::Class->initialize('KiokuDB::Class'); | |
$meta->get_method_list(); |
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
# Extermely hackish way to realize case-sensitvie sort | |
# (without having to load a plugin) | |
# note, list.sort("foo") is not supported. | |
sub _build_template { | |
my $code = sub { | |
my ($list, @fields) = @_; | |
return $list unless @$list > 1; # no need to sort 1 item lists | |
return [ |
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
/* | |
* requires tokyodystopia, libapreq2 | |
* TODO: make it possible to configure from httpd.conf | |
* remove all the hardcoded gunk | |
* test properly | |
* Yes, I looked at tdserver.c. Thanks to Kawai-san | |
*/ | |
#include "httpd.h" | |
#include "http_config.h" |
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
// ==UserScript== | |
// @name NoRadioTube | |
// @namespace http://mt.endeworks.jp/d-6/ | |
// @description Silences RadioYoutube. RY is cool, but it gets annoying | |
// when your timeline is full of those tweets. | |
// @include http://twitter.com/* | |
// ==/UserScript== | |
function xpath(query, ctxt) { | |
if (ctxt == null) { | |
ctxt = document; |