OpenIDでテキストを共有できます
- 新規作成
- OpenIDで認証してエントリーを新規作成します
- 共有
- エントリーにはOpenIDで閲覧と編集に制限かけることができます
- 変更履歴
- 編集履歴もあるので、コラボレーションにも活用できます
新着エントリー
使用目的がわからないAA
/^`''-.., // /`〉゙'., // / / ;;::| // / / ;;:::/ ヤ,\/ / ;;::/ ミ 乗せてやんよ! ヤ, V/ ;;::/ ミ バリバリ ,... -—————ヤ, //7::/ __ ,,..-''"(´・ω・`) ヤ,/_;;:::/ヽ、\皿#,,\ ,,.. - ''"゙゙;>ー—---——;=''''"゛゛⌒ヽ, ̄ィ7 /〉 ''´ ̄`i ,,. '" ,,. '" / / ヽェソ 乃▲ /,r'⌒!' マジックテープ式!? ∠二フ/___,___/∠二フ/ r'⌒ヽヽ_/´ // ∩ i lヽ,,lヽ 〔`゙`ー—————————'''''"゙´ ノ/ ∩ |  ̄__!/ノ ∪ノ ( ) 〉同〉—— [二二] ———j同>=:;つ_ノ ∪ノ/ ̄ `ー—''´ と i  ̄ ̄ー— ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ `ー—''´ しーJ
Tokyo Tyrantのstatsの結果がもっと充実するといいな
■memcached 1.4.0
% telnet localhost 11212 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. stats STAT pid 21811 STAT uptime 12 STAT time 1254207824 STAT version 1.4.0 STAT pointer_size 64 STAT rusage_user 0.000000 STAT rusage_system 0.000999 STAT curr_connections 10 STAT total_connections 11 STAT connection_structures 11 STAT cmd_get 0 STAT cmd_set 0 STAT cmd_flush 0 STAT get_hits 0 STAT get_misses 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT bytes_read 7 STAT bytes_written 0 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 5 STAT conn_yields 0 STAT bytes 0 STAT curr_items 0 STAT total_items 0 STAT evictions 0 END
■Tokyo Tyrant 1.1.29
% telnet localhost 11212 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. stats STAT pid 21823 STAT uptime 20 STAT time 1254207872 STAT version 1.1.29 STAT rusage_user 0.002999 STAT rusage_system 0.020996 STAT curr_items 0 STAT bytes 525376 END
うちではmemcachedのstatsの結果を利用して、get/setの数やhit率なんかをグラフ化している。
Tokyo Tyrantでも同じようなことができたらいいなぁと思った。
WWW::Curl で POST
http://cpansearch.perl.org/src/SZBALINT/WWW-Curl-4.09/Curl.xs
/* not working yet...
case CURLOPT_HTTPPOST:
if (sv_derived_from(value, "WWW::Curl::Form")) {
WWW__Curl__form wrapper;
IV tmp = SvIV((SV*)SvRV(value));
wrapper = INT2PTR(WWW__Curl__form,tmp);
RETVAL = curl_easy_setopt(self->curl, option, wrapper->post);
} else
croak("value is not of type WWW::Curl::Form");
break;
*/
と書いてあるので CURLOPT_HTTPPOST は使えない。構造体 curl_httppost をまだ Perl でラップしていないから?
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPPOST
で http://cpansearch.perl.org/src/SZBALINT/WWW-Curl-4.09/t/new/06http-post.t をみたらできた。
use strict; use warnings; use WWW::Curl::Easy; sub create_read_callback { my ($data) = @_; my $offset = 0; return sub { my ($size, undef) = @_; if ($offset > length $data) { return ''; } my $result = substr($data, $offset, $size); $offset += $size; return $result; }; } sub curl_set_post { my ($curl, $data) = @_; $curl->setopt(CURLOPT_CUSTOMREQUEST, 'POST'); $curl->setopt(CURLOPT_READFUNCTION, create_read_callback($data)); $curl->setopt(CURLOPT_INFILESIZE, length $data); $curl->setopt(CURLOPT_UPLOAD, 1); } my $uri = shift or die; my $curl = WWW::Curl::Easy->new; $curl->setopt(CURLOPT_URL, $uri); curl_set_post($curl, "hello"); $curl->perform;
レビューされた
レビュー通らなかった。
- CURLOPT_UPLOAD が Expect: 100-continue リクエストヘッダをつけ、そこでサーバーが 100 Continue を返さないとダメな時がある? (条件おいつめきれず)
- そもそも CURLOPT_POST を使う方が素直
というわけで curl_set_post を書き直し。
sub curl_set_post { my ($curl, $data) = @_; $curl->setopt(CURLOPT_POST, 1); $curl->setopt(CURLOPT_POSTFIELDS, $data); }
CURLOPT_POST は Content-Type: を application/x-www-form-urlencoded に指定してくるので、ほかを指定したい場合
$curl->setopt(CURLOPT_HTTPHEADER, ['Content-Type: text/plain']);
とする。CURLOPT_HTTPHEADER と curl がなかで指定するものとで重複した場合は CURLOPT_HTTPHEADER が勝つ。
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPHEADER
bench2
use Benchmark; use LWP::UserAgent; use WWW::Curl::Easy; my $count = 2000; my $curl2 = WWW::Curl::Easy->new; $curl2->setopt(CURLOPT_URL, 'http://localhost:8080/'); my $curl3 = WWW::Curl::Easy->new; $curl3->setopt(CURLOPT_URL, 'http://localhost:8080/'); timethese( $count , { 'curl' => sub { open(my $content_fh, '>', ¥my $content); open(my $header_fh, '>', ¥my $header); my $curl = WWW::Curl::Easy->new(); $curl->setopt( CURLOPT_WRITEDATA, $content_fh); $curl->setopt( CURLOPT_WRITEHEADER, $header_fh); $curl->setopt( CURLOPT_URL, 'http://localhost:8080/' ); $curl->perform(); }, 'curl2' => sub { open my $content_fh, '>', ¥my $content; open(my $header_fh, '>', ¥my $header); $curl2->setopt( CURLOPT_WRITEDATA, $content_fh); $curl2->setopt( CURLOPT_WRITEHEADER, $header_fh); $curl2->perform; }, 'curl3' => sub { open my $content_fh, '>', ¥my $content; $curl3->setopt( CURLOPT_WRITEDATA, $content_fh); $curl3->perform; }, 'lwp' => sub { my $ua = LWP::UserAgent->new; my $res = $ua->get('http://localhost:8080/'); }, 'lwp-nohead' => sub { my $ua = LWP::UserAgent->new( parse_head => 0 ); my $res = $ua->get('http://localhost:8080/'); } }); __END__ Benchmark: timing 2000 iterations of curl, curl2, curl3, lwp, lwp-nohead... curl: 30 wallclock secs ( 0.39 usr + 0.57 sys = 0.96 CPU) @ 2083.33/s (n=2000) curl2: 32 wallclock secs ( 0.24 usr + 0.38 sys = 0.62 CPU) @ 3225.81/s (n=2000) curl3: 33 wallclock secs ( 0.21 usr + 0.38 sys = 0.59 CPU) @ 3389.83/s (n=2000) lwp: 4 wallclock secs ( 2.74 usr + 0.36 sys = 3.10 CPU) @ 645.16/s (n=2000) lwp-nohead: 4 wallclock secs ( 2.50 usr + 0.36 sys = 2.86 CPU) @ 699.30/s (n=2000)
bench
use Benchmark; use LWP::UserAgent; use WWW::Curl::Easy; my $count = 2000; my $curl2 = WWW::Curl::Easy->new; $curl2->setopt(CURLOPT_URL, 'http://localhost:8080/'); timethese( $count , { 'curl' => sub { open(my $content_fh, '>', \my $content); open(my $header_fh, '>', \my $header); my $curl = WWW::Curl::Easy->new(); $curl->setopt( CURLOPT_WRITEDATA, $content_fh); $curl->setopt( CURLOPT_WRITEHEADER, $header_fh); $curl->setopt( CURLOPT_URL, 'http://localhost:8080/' ); $curl->perform(); }, 'curl2' => sub { open my $content_fh, '>', \my $content; open(my $header_fh, '>', \my $header); $curl2->setopt( CURLOPT_WRITEDATA, $content_fh); $curl2->setopt( CURLOPT_WRITEHEADER, $header_fh); $curl2->perform; }, 'lwp' => sub { my $ua = LWP::UserAgent->new; my $res = $ua->get('http://localhost:8080/'); } }); __END__ curl: 31 wallclock secs ( 0.38 usr + 0.56 sys = 0.94 CPU) @ 2127.66/s (n=2000) curl2: 30 wallclock secs ( 0.23 usr + 0.37 sys = 0.60 CPU) @ 3333.33/s (n=2000) lwp: 4 wallclock secs ( 2.64 usr + 0.34 sys = 2.98 CPU) @ 671.14/s (n=2000)
emacs 23依存部分
;;; http://d.hatena.ne.jp/kazu-yamamoto/20090122/1232589385 (if (= emacs-major-version 23) (progn (set-input-method "MacOSX") (setq ns-command-modifier (quote meta)) (setq ns-alternate-modifier (quote super)) (setq my-font "-*-*-medium-r-normal--14-*-*-*-*-*-fontset-hiramaru") (setq fixed-width-use-QuickDraw-for-ascii t) (setq mac-allow-anti-aliasing t) (set-default-font my-font) (add-to-list 'default-frame-alist `(font . ,my-font)) (set-fontset-font (frame-parameter nil 'font) 'japanese-jisx0208 '("Hiragino Maru Gothic Pro" . "iso10646-1")) (setq face-font-rescale-alist '(("^-apple-hiragino.*" . 1.2) (".*osaka-bold.*" . 1.2) (".*osaka-medium.*" . 1.2) (".*courier-bold-.*-mac-roman" . 1.0) (".*monaco cy-bold-.*-mac-cyrillic" . 0.9) (".*monaco-bold-.*-mac-roman" . 0.9) ("-cdac$" . 1.3)))))
$@ issue on DT::TZ
perl -e 'use DateTime::TimeZone; eval { DateTime::TimeZone->new(name => "America/Miyagawa"); }; warn $@'
unless ( $real_class->can('instance') )
{
local $@;
eval "require $real_class";
if ($@)
{
my $regex = join '.', split /::/, $real_class;
$regex .= '\\.pm';
if ( $@ =~ /^Can't locate $regex/i )
{
die "The timezone '$p{name}' could not be loaded, or is an invalid name.\n";
}
else
{
die $@;
}
}
}
WTF?
Socket::unpack_sockaddr_un doesn't works on OSX
Socket::unpack_sockaddr_un is a minor method for a lot of case.
bug
Perl's embedded function accept() always returns sizeof(sockaddr).
accept() should return sizeof(sockaddr_un) bytes string for UNIX Domain Socket.
Solution
finding...