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
// before html | |
// <html lang="ja"> | |
// <span data-text-ja="タイムライン">Timeline</span> | |
// | |
// var localizer = new Localizer(); | |
// localizer.localize(); | |
// | |
// after html | |
// <span data-text-ja="タイムライン">タイムライン</span> |
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
// https://github.com/tokuhirom/Amon/blob/master/lib/Amon2/Plugin/Web/CSRFDefender.pm | |
function ajax(option) { | |
this.token_name = 'csrf_token'; // 実際は別のところでsetupしておく | |
if ("data" in option && "type" in option && option.type.toLowerCase() == 'post') { | |
if (!this.token) { | |
this.token = $('input[name=' + this.token_name + ']:first').val(); | |
} | |
option.data[this.token_name] = this.token; | |
} | |
return $.ajax(option); |
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
var lis = []; | |
this.parts.tasks.find('> li').each(function(i, ele) { | |
lis.push($(ele)); | |
}); | |
lis = lis.sort(function(a, b) { | |
return b.data('updated') - a.data('updated'); | |
}); | |
for (var i = 0; i < lis.length; i++) { | |
lis[i].appendTo(this.parts.tasks); | |
} |
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 MIME::Parser::Delux; | |
use strict; | |
use Encode; | |
use Encode::Alias; | |
use Encode::Guess qw/euc-jp shiftjis 7bit-jis/; | |
use File::Temp qw/ :seekable /; | |
use MIME::Parser; | |
use MIME::WordDecoder; | |
use MIME::Words qw(:all); |
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
function delayHover(element, over, out, delay) { | |
var timer; | |
$(element).hover(function(){ | |
if (timer) { | |
clearTimeout(timer); | |
timer = null; | |
} else { | |
over.apply(this, arguments); | |
} | |
}, function(){ |
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
How to Build One Page Apps | |
実サービス(9月下旬完成予定)を例にOne Page Appsの作り方を紹介します。 | |
One Page Apps(Single Page Application)とは1枚のHTMLで構成されたWebアプリケーションでTweetDech等が有名です。 | |
一日中開いたままでもバックグラウンドで同期が走り、必要に応じて通知やDOMの再構成が行われ、オフライン中の操作はスタックされ、通信回復後に再同期が行われる様なクライアントアプリケーションに非常に近い実装が必要になります。 | |
実用的なアプリケーションにする為には標準のUIだけでは力不足ですし、開発効率を保つ為には肥大化しがちなJsコードをうまく整頓するコツも必要です。 |
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
function initElements(context) { | |
$('*[data-init]', context).each(function(){ | |
var ele = $(this); | |
var methods = ele.data('init').split(','); | |
for (var i = 0, max_i = methods.length; i < max_i; i++) { | |
app.exec(['initElement', methods[i]], [this]); | |
} | |
}); | |
} | |
function initElementClick(element) { |
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
# 500 | |
test_psgi | |
app => builder { | |
enable "StackTrace", no_print_errors => 1; # no warning in make test. | |
MyApp->handler | |
}, | |
client => sub { | |
my $cb = shift; | |
my $req = HTTP::Request->new( GET => 'http://localhost/foo/error' ); | |
$req->header('Accept' => 'text/html'); # get stack trace message |
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
my $zip; | |
open my $fh, "<:encoding(cp932)", $ken; | |
while (my $row = $csv->getline($fh)) { | |
next if $zip->{$row->[2]}; | |
$zip->{$row->[2]}++; | |
$model->insert( 'minotaur_zip', { | |
zip => $row->[2], | |
pref => substr($row->[0], 0, 2), | |
address1 => $row->[7], | |
address2 => $row->[8] |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Crypt::CBC; | |
use Crypt::Blowfish; | |
my $key = shift; | |
my $val = shift; |