Hatena::ブログ(Diary)

muddy brown thang このページをアンテナに追加 RSSフィード Twitter

2012-02-09

やったーmod_vimできたよー

Vim scriptはウェブアプリケーション記述言語やったんやー

Plack とかよくわかんないのでさくっと Apache で使えるようにしてみました。

mod_vim

httpd.conf はこんな感じ

LoadModule vim_module mod_vim.so
DocumentRoot .

Listen 8080

PidFile /tmp/pid
LockFile /tmp/lock
ErrorLog /tmp/error_log

VimDisplay :0
VimVersion 7.2
VimEncoding UTF-8

<Location />
    SetHandler vim
    VimExpr vimplack#handle(@@)
</Location>

ビルド方法は、まあ README に書いておけよって感じですが

make top_builddir=/usr/share/apache2/build

みたいにしてください、apr-json が別途必要です。

mattnさんのサンプルはこんな感じに動いています。

f:id:moriyoshi:20120209193608p:image

% ab -n 500 -c 20 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        Apache/2.2.20
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        348 bytes

Concurrency Level:      20
Time taken for tests:   0.587 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      246500 bytes
HTML transferred:       174000 bytes
Requests per second:    851.90 [#/sec] (mean)
Time per request:       23.477 [ms] (mean)
Time per request:       1.174 [ms] (mean, across all concurrent requests)
Transfer rate:          410.14 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   22  14.0     20     229
Processing:     0    1   3.4      0      31
Waiting:        0    1   3.4      0      31
Total:          4   23  14.1     21     248

Percentage of the requests served within a certain time (ms)
  50%     21
  66%     22
  75%     23
  80%     25
  90%     28
  95%     32
  98%     52
  99%     98
 100%    248 (longest request)

Enjoy!

2012-01-07

JavaScriptで任意のテキストをバイト列からラスタ画像化する、またはその逆

id:monjudohid:nishiohirokazu と話してて作ったんだけどとりあえず使い道なかったので共有します。

テキストをレンダリングして画像にするという話ではなく、

  1. テキストを UTF-8 に変換する
  2. UTF-8 化されたバイト列であるテキストをラスタ画像 (ImageData) にする
  3. 画像を PNG 形式にする

ということをする話です。

f:id:moriyoshi:20120107194512p:image

デモサイト:

http://moriyoshi.github.com/textimgenc/

ソースはこちら:

http://github.com/moriyoshi/textimgenc/

2011-12-18

PHP Apocalypse (と1981忘年会で) 発表してきました

HPHPは約束の地なのか<object id="__sse10625933" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=hphp-111217170534-phpapp02&stripped_title=hphp&userName=moriyoshi" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent"/><embed name="__sse10625933" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=hphp-111217170534-phpapp02&stripped_title=hphp&userName=moriyoshi" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="425" height="355"></embed></object>

HipHop for PHP (HPHP) についてのスライドです。

前も同じ事があったけども、なぜか貼れない...。

2011-10-15

Python Developers Fest 2011.10 で発表しました

最近ネタの切れが悪いと言われます…。

Package documentation より:

This package is a port of a great Perl module called Acme::AKB48 which was created by Hideo Kimura. Although I don’t have the slightest interest in AKB48, I happened to be under the impression that Python world (almost) totally lacks “Acme” essence and feel like it being worth the first Acme to be ported.

http://github.com/moriyoshi/pyakb48

http://pypi.python.org/pypi/pyakb48