13:09 (mst) thx? 13:09 (purl) please don't say "thx", if you're genuinely grateful it's worth the effort to type three extra characters and say "thanks". this is IRC, after all, not SMS or twitter IRCでは感謝の意を込めて略さずthanksってタイプしようねとのこと。
環境は以下の通り mac mini 2.66GHz 4GB RAM kyotocabinet 1.2.30 kyototycoon 0.9.18 KTをMemcachd pluginサポート起動 ktserver -plsv /usr/local/lib/ktplugservmemc.dylib -plex 'port=2010'ベンチを取ったコードはこんな感じ とりあえずsetのベンチ #!/usr/bin/env perl use strict; use warnings; use Benchmark qw(:all); use Cache::KyotoTycoon; use Cache::Memcached::Fast; my $kt = Cache::KyotoTycoon->new( host => '127.0.0.1', port => 1978 ); my $mf = Ca
QRコードを表示するだけの簡単なお仕事を大量にさばきたいって言われたので書いてみた。 use Imager::QRCode; use Plack::Request; my $qrcode = Imager::QRCode->new( size => 2, margin => 2, version => 1, level => 'M', casesensitive => 1, lightcolor => Imager::Color->new(255, 255, 255), darkcolor => Imager::Color->new(0, 0, 0), ); my $app = sub { my $req = Plack::Request->new(shift); my $url = $req->param('url') or return [400, ['Content-Type' =>
mod_perlでどのくらいメモリー使われてるかとか調べたかったのでApache2::Statusを使ってみた。 Shibuya.pmのLTにも含めようと思ったけど5分に押し込めるのは無理なのでここで公開。 テスト対象としてCGI::Applicationで package HelloWorld; use strict; use warnings; use base 'CGI::Application'; sub setup { my $self = shift; $self->start_mode('index'); $self->run_modes( ['index']); } sub index { "HelloWorld"; } 1; runスクリプトとして #!/usr/bin/perl use strict; use warnings; use lib './lib'; use
追記: id:tokuhirom先生に添削してもらった。 malloc使うべからず -> NewXX()系でアロケート、SafeFree()で解放すべし(そういえばid:hirose31さんも言ってた) newSVpvの第二引数(STRLEN)は明示的に指定すべし -> 0で自動計算は\0 終端前提 SV * getString(CFStringRef var) { char *buf; SV *sv; CFIndex len = CFStringGetLength(val); CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8); buf = Newxz(max + 1); CFStringGetCString(val, buf, max + 1, kCFStringEncodingUTF8
コードリファレンスのシリアライズとデシリアライズ use strict; use warnings; use YAML; use Data::Dumper; $Data::Dumper::Deparse = 1; { no warnings ('once'); $YAML::UseCode = 1; } my $obj = { hello => sub { print "hello\n"; }, name => "hoge", }; # serialize my $yaml = YAML::Dump($obj); warn $yaml; # deserialize my $obj2 = YAML::Load($yaml); warn Dumper $obj2; # call coderef $obj2->{hello}->(); $YAML::UseCode = 1で$YAML::Load
SQLiteの追加/更新はトランザクションを使うと高速化に効果があるというのはよく効くので実際試してみました。 use strict; use warnings; use DBI; use Benchmark qw(:all); my $count = 100; my $loop = 100; cmpthese( $count, { commit_each_insert => \&commit_each_insert, commit_bulk_insert => \&commit_bulk_insert, } ); sub commit_each_insert { unlink('test1.db'); my $dbh = DBI->connect('dbi:SQLite:dbname=test1.db'); $dbh->do( "CREATE TABLE test (id int not
Standard C++ foo-bar.cpp #include <iostream> int main () { std::cout << "Hello World"; } $ gcc -o foo-bar foo-bar.cpp -lstdc++ $ foo-bar Hello Wolrd Devel::BindPP $ perl -MDevel::BindPP -e 'use Devel::BindPP::WriteFile()'foo-bar.cpp include <iostream> #include "bindpp.h" XS(xs_hello_world) { std::cout << "Hello World"; } extern "C" { XS(boot_Foo__Bar) { pl::BootstrapCtx bc; pl::Package pkg("Foo::B
Class-Accessor-Fast-XS-0.04 - XS replacement for Class::Accessor::Fast - metacpan.org Mooseブームも一段落したところでこんなん出てたからベンチ取ってみた。 package ClassAccessor; use strict; use warnings; use base qw/Class::Accessor/; __PACKAGE__->mk_accessors(qw/foo bar/); package ClassAccessorFast; use strict; use warnings; use base qw/Class::Accessor::Fast/; __PACKAGE__->mk_accessors(qw/foo bar/); package ClassAccessorFastXS;
Catalystのstashをグローバル変数的に使うのは - Charsbar::Note ビューのテンプレート設定とかもそう。古くさいC::V::TTではstash経由でテンプレを渡しているけど、新しいC::V::Templated ベースのものはstashなんぞ通さず、$c->view(...)->template('template')のような形で直接指定できるようになっている。 これはいいですね。 jrockwayがC::M::Adaptorに続き、Viewまで汎用化してくれました。 で、C::V::Templatedとstashの関係ですが、ちらっとソースを見てみるとtemplateメソッドでテンプレートを渡すようになったけどstashを使ってないわけではないんですね。 templateメソッドの実装を見ると $self->context->stash($self->_ident
Catalystがモダンかどうかは置いておいてCatalystのコンポーネントを書く時のお作法として 大昔は ... use base qw(Catalyst::Action); use NEXT; sub execute { my $self = shift; $self->NEXT::execute( @_ ); ... ちょっと前は ... use base qw(Catalyst::Action); use Class::C3; sub execute { my $self = shift; $self->next::method( @_ ); ... モダンなのは ... use base qw(Catalyst::Action); use MRO::Compat; sub execute { my $self = shift; $self->next::method( @_ )
Ideas - O'Reilly Media modperlite PHPのようにファイルを置くだけで実行されてCGIより速くてmod_perlより簡単なapache moduleだそうです。去年からのCGI frameworkブームを補完する上でも試してみるっきゃないということで まずはソースの取得 svn co http://code.sixapart.com/svn/mod_perlite/trunk modperlite cd modperliteちなみにもうすぐgithubに移行されるようです。 コンパイルとインストールはapxsにパスを通して ./Build.PL ./Build ./Build installhttpd.confとかconf.d/modperlite.confとかに LoadModule perlite_module modules/mod_perlite.s
最近GitHubを使っているのですが、pushのたびにパスワード入力めんどうだからこのへん見てssh-agentを使ってパスワード入力を省くようにしてました。 が、keychainを使えばさらにログイン間で共有できるようになることを今さら知りました。 CentOSではrpmforgeからyumでインストールできます。 # yum install keychainで、.zshrcに /usr/bin/keychain $HOME/.ssh/id_rsa source $HOME/.keychain/$HOST-shとか書いておけば、ssh-agentが実行されていなかったら実行するし、されていたら自動的に使うようになってくれるので新しいシェルを上げるたびにssh-agentを上げて、パスワード入力して…といった作業から開放されます。
前代未聞のPerl軽量ウェブアプリケーションフレームワーク祭りの中、いかがお過ごしでしょうか? 紆余曲折があってこんなことを言ってたわりに何もしてないでぼーっとしている間に、腕に覚えのある兵達が我も我もと手を動かしてくれたので、申し訳なさ半分で懲りずにベンチマークを取ってみました。 http://d.hatena.ne.jp/tokuhirom/20081111/1226418572 NanoA というウェブアプリケーションフレームワークをかいてみた - kazuhoのメモ置き場 YappoLogs: Yacafi という軽量CGIフレームワーク書いたよ みんな基本的に軽量なフレームワークをうたっていて、開発効率よりも軽さや配布のしやすさを売りとしているので特に問題ないと思います。 比べたのは上の3つと モジュールを使わないcgi CGI.pmでヘッダ出力をするもの 軽量フレームワークの代
これもよく使うくせによく忘れるので備忘。 まずはCatalystのControllerでData::Page::Navigationをuseして MyApp::Controller::User package MyApp::Controller::User use strict; use warnings; use parent 'Catalyst::Controller'; use Data::Page::Navigation; sub index : Path : Args(0) { my ( $self, $c ) = @_; my $page = $c->req->param('page') || 1; my $rows = $c->req->param('rows') || 10; my $users = $c->model('DBIC::Users')->search( {},
下のやつをModule::Setup::Flavor::CatalystStarterとしてcodereposにコミットしました。 module-setup --init --flavor-class=CatalystStarter catalystすると~/.module-setup/flavors/catalystにflavorがインストールされます。 module-setup MyApp catalystとすればcatalyst.pl MyAppと同じことをしてくれます。 で、これの何がうれしいかというと、~/.module-setup/flavors/catalyst/以下をいじくればオレオレcatstarterが作れるってことです。 ディレクトリ構造がそのままなので視覚的にいじれるのでわかりやすい。 で、保存しておきたくなったら module-setup --pack MyCat
mysqlではデフォルトではNOT NULL制約に明示的に値を与えない場合、勝手に空文字や0といった値を勝手に入れちゃう。 例えば CREATE TABLE users ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL ); なテーブルに対して INSERT INTO users(id) VALUES(1); とかしたらエラーにならずid = 1, username = ''みたいなレコードが作られちゃう。 んで、これを許可しないようにするのが5.0.2以上でサポートされてるSTRICT_ALL_TABLESモード。知らんかったです。 SET sql_mode = 'STRICT_ALL_TABLES'; することによって ERROR 1146 (42S02): Table 'u
CPANにMoose版Catalystである5.8のdeveloper releaseが出ていたのでベンチマーク取って見ました。 なお、Catalyst::ClassDataがパッケージに含まれていなかったので、これだけリポジトリから持ってきて動かしてます。 テスト内容はcataltst.pl MyAppで出来るトップページをビルトインエンジンで起動して ab -n 1000 -c 100 http://localhost:3000/するだけ。 結果はこちら。 Catalyst 5.7014 Server Software: Server Hostname: localhost Server Port: 3000 Document Path: / Document Length: 5635 bytes Concurrency Level: 100 Time taken for tests:
最近はもっぱらこんな構成 MyApp/ |-- Changes |-- Makefile.PL |-- README |-- conf - 設定ファイルはまとめてここへ | `-- myapp.conf |-- docs - ドキュメントとかSQLとか |-- lib | |-- MyApp | | |-- Base - Base::Controllerとか基底クラス | | |-- Component - ビジネスロジッククラス | | |-- Controller | | |-- Model | | |-- Plugin - オレオレプラグイン | | |-- Schema - DBICのスキーマ | | `-- View | `-- MyApp.pm |-- root | |-- db - SQLiteを使うときはこの辺 | |-- static | | |-- scripts -
Tracって素ではローカルのsubversionリポジトリしか見れないのね。 しょうがないのでローカルにミラーすることにした。 で、どうやってミラーするかなんだけどSVKじゃなくてsvnsync使ってみた。 まずはミラー先で普通にリポジトリ作って svnadmin create /var/repos/hogehook/pre-revprop-changeを作って #!/bin/sh exit 0pre-revprop-changeに実行権限与えて chmod +x /var/repos/hoge/hooks/pre-revprop-changeミラーを初期化。 svnsync init file:///var/repos/hoge http://example.com/repos/hoge構文は svncsync init [ミラー先] [ミラー元] 同期するときは svnsync syn
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く