memo.xight.org - 2006-03

2006-03-29 Wed

あずきフォント・うずらフォント

- Reference
あずきフォント
http://key.milkcafe.to/azuki/font/azuki.html
うずらフォント
http://key.milkcafe.to/azuki/font/uzura.html
- via
窓の杜 - JIS第一水準漢字まで備えるかわいい太字の手書き風フォント「うずらフォント」
http://www.forest.impress.co.jp/article/2006/03/28/uzurafont.html
窓の杜 - フォント
http://www.forest.impress.co.jp/lib/offc/print/font/

2006-03-24 Fri

血液サラサラの謎

- Summary

現在の血液サラサラ・ドロドロ検査では赤血球が形を変える能力を観察しているだけ


- Reference
Wikipedia - 血液サラサラ

All About - 家庭の医学 - 血液サラサラ? 血液ドロドロ?
http://allabout.co.jp/health/familymedicine/closeup/CU20040810A/index.htm

- via
スラッシュドット ジャパン - 「魚のような脂肪」を持つ豚
http://slashdot.jp/science/article.pl?sid=06/03/30/2116235

2006-03-23 Thu

rsync の使い方

#!/bin/sh
 
RSYNC=/usr/bin/rsync
LOCAL_PATH=/path/to/target/
 
REMOTE_USER=username
REMOTE_HOST=example.com
REMOTE_PATH=/path/to/backup/
 
$RSYNC -avz -e ssh $LOCAL_PATH $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH

2006-03-16 Thu

エラー Allowed memory size of XXXXXXX bytes exhausted

- Summary
/var/log/apache/error.logに以下のメッセージを発見.

Allowed memory size of 8388608 bytes exhausted (tried to allocate 133 bytes)



- 原因
PHP の メモリリミットを超えたメモリを扱おうとした.

- 対策
/etc/php4/apache/php.ini
memory_limit の値を増やす.

memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)



;memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)
memory_limit = 16M



- 反省
富豪的プログラミングをやりすぎ,このエラーに遭遇.
memory_limitの値を増やしてもいたちごっこな気がするので,ロジックを再考してみる.

- Reference
trustBee - パソコンQ&A : Re:compose.php3 のエラー
http://www.trustbee.com/bbs/?i=bee&a=7&t=421&m=2178

シーケンスと採番テーブルと欠番探索

・シーケンス

アプリケーションで採番について考えなくて済む.絶対に重複しない.
データを追加するまで、与えられる番号が分からない.欠番が起こる.

・採番テーブル
データを追加する前に与えられる番号が分かる.
管理が大変.バグの要因になりがち.設計者の手腕にかかっている.

・欠番探索
データを追加する前に与えられる番号が分かる.絶対に重複しない.欠番が起こらない.
データ件数が多いと採番に時間がかかる (100万件くらいは余裕らしい)

- Reference
@IT - Database Expert - シーケンスと採番テーブルの選択
http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=15927&forum=26&5

2006-03-15 Wed

JavaScript で指定の HTML 要素を動的に角丸デザインにする方法

- Source

Rounded("div#nifty","#377CB1","#9BD1FA"); // この1行だけで要素を角丸にすることが可能


<div id="nifty"><p>test</p></div>


- Reference
Nifty Corners
http://pro.html.it/esempio/nifty/
- via
phpspot開発日誌 - Javascriptで指定のHTML要素を動的に角丸デザインにする方法
http://phpspot.org/blog/archives/2006/03/javascripthtml.html

target="_blank" を使わないで新しいウィンドウでリンクを開く方法

- Summary
target="_blank" を使わないで新しいウィンドウでリンクを開くための手法.
Behaviour.js を利用すればより簡単,かつHTMLを汚さずに実装可能.
Sample

- Source

var myrules = {
	'.popup' : function(el){
		var href = el.getAttribute('href');
		if (href){
			el.onclick    = function(){ window.open(href); return false;}
			el.onkeypress = function(){ window.open(href); return false;}
		}
	}
};
Behaviour.register(myrules);


<script type="text/javascript" src="behaviour.js"></script>
 
<a href="index.html">Normal</a>
<a class="popup" href="index.html">Pop up</a>


- Reference
Behaviour : Using CSS selectors to apply Javascript behaviours
http://bennolan.com/behaviour/

- via
cl.pocari.org - 2006-03-14
http://cl.pocari.org/2006-03-14-5.html

2006-03-13 Mon
2006-03-12 Sun

Firefox 検索プラグインに MySQL Reference を追加する

- mysql.src

# Mozilla search plugin for MySQL Reference
# by Yoshiki SATO <xight.org+memo@gmail.com>.
# http://xight.org/misc/firefox/searchplugins/
# This file is released into the public domain.
#
# Version: 0.0.1 (2006-03-12)
# Country: JP
# Language: ja

<search
	version="0.0.1"
	name="MySQL Reference"
	description="MySQL Reference"
	sourceTextEncoding="0"
	method="get"
	action="http://dev.mysql.com/doc/mysql/search.php"
	queryCharset="UTF-8"
	searchForm="http://dev.mysql.com/doc/mysql/search.php"
>

<input name="q" user>
<input name="lang" value="ja">

<interpret
	browserResultType="result"
	charset="EUC-JP"
	language="ja"
	resultListStart="<div id='results'></div>"
	resultListEnd="<hr/>"
	resultItemStart="<li style='padding-bottom: 1em'>"
	resultItemEnd="</li>"
>

</search>

<browser
	alsomatch="http://dev.mysql.com/doc/mysql/search.php"
	update="http://xight.org/misc/firefox/searchplugins/mysql.src"
	updateIcon="http://xight.org/misc/firefox/searchplugins/mysql.png"
	updateCheckDays="100"
>



- Reference
xight.org - misc - firefox
http://xight.org/misc/firefox/

2006-03-11 Sat

spyc - PHPでYAMLを扱えるライブラリ

- 用途
オプションファイルを YAML で記述.
オプションファイルの編集に PHP を利用.

- YAML から 配列に

include('spyc.php');
 
$array = Spyc::YAMLLoad('yamlfile.yml');
print_r($array);


- 配列 から YAML に
include('spyc.php');
 
$array[] = 'Sequence item';
$array['The Key'] = 'Mapped value';
$array[] = array('A sequence','of a sequence');
$array[] = array('first' => 'A sequence','second' => 'of mapped values');
$array['Mapped'] = array('A sequence','which is mapped');
$array['A Note'] = 'What if your text is too long?';
$array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block.  Kinda like this.';
$array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.';
$array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!";
 
$yaml = Spyc::YAMLDump($array,4,60);
print_r($yaml);


- Reference
SourceForge - spyc: a simple php yaml class
http://spyc.sourceforge.net/

cl.pocari.org - 人間にとって読みやすいデータ直列化フォーマット YAML Ain't Markup Language
http://cl.pocari.org/2005-10-20-1.html
NamingSense::TokuLog! - YAMLでヴァリデーションの条件を書く
http://d.hatena.ne.jp/tokuhirom/20060310/1142007501

- via
phpspot開発日誌 - PHP用YAMLクラス : spyc
http://phpspot.org/blog/archives/2006/02/phpyaml_spyc.html

2006-03-10 Fri
2006-03-09 Thu

起床術 - 布団から抜け出すための4つのテクニック

- 布団から足だけを出す.
足が冷えるにしたがって意識もはっきりする.

- カーテンを開けておく.
寝ている状態で光を浴びるとステロイド (ホルモン) が分泌され、眠りが浅くなるという研究結果がある.

- テレビやラジオをつける.
起きたい時間の30分程度前から音が流れるようにする.

- ガバッと起きる.

- Reference
早起き生活 - 起床術 - 布団から抜け出すためのテクニック
http://www.hayaoki-seikatsu.com/documents/articles/kisyoujutsu01.html

- via
オレンジニュース - 2006-03-07
http://secure.ddo.jp/~kaku/tdiary/20060307.html#p11

BASE64

- Summary
バイナリデータの6bitを0〜63までの数値とみなす.

アルファベットの大文字 26 文字
アルファベットの小文字 26 文字
数字 10 文字
記号(+,/) 2 文字

3byte が常に 4byte に変換されるので,
データサイズは常に33%程度増加する.

- Reference
Wikipedia - Base64

@IT:Insider's Computer Dictionary [Base64]
http://www.atmarkit.co.jp/icd/root/21/5784921.html

2006-03-08 Wed
2006-03-06 Mon

 GD::Barcode::QRcode で各ページにQRコードの画像を付加

- Summary
[2006-03-05-1]を応用し,Refererを用いてQRコード生成.

- インストール

# aptitude install libexpat-dev libgd2-dev
# cpan install GD
# cpan install GD::Barcode::QRcode


- qr.cgi

#!/usr/bin/perl
use strict;
use GD::Barcode::QRcode;
 
my $str         = $ENV{'HTTP_REFERER'};
my $header      = qq(Content-Type: image/png\n\n);
my $qr          = GD::Barcode::QRcode->new($str,{ ECC => 'L', Version => 2, ModuleSize =>2,})->plot->png;
print $header,$qr;
exit;


- 各ページに以下の HTML で付加可能.
<img src="path/to/qr.cgi" width="97" height="97" alt="QRcode" />


- Reference
GD::Barcode::QRcode

nitsujiの日記 - GD::Barcode::QRcodeのバグ?の件について
http://d.hatena.ne.jp/nitsuji/20070626/1182840997

2006-03-05 Sun

GD::Barcode::QRcode を用いた QRコード生成

- Summary
http://example.com/cgi-bin/qr.cgi?q=QRコードにしたい文字列
でQRコードの画像を生成したい.

- 準備

# cpan -i GD::Barcode::QRcode


- 注意
GD::Barcode::QRcode (0.01) 40行目を変更

#$oSelf->{Version} = $rhPrm->{Version} || 1;
$oSelf->{Version} = $rhPrm->{Version};


- Source
#!/usr/bin/perl
use strict;
use CGI;
use GD::Barcode::QRcode;
 
my $q		= new CGI;
my $str		= $q->param('q');
my $header	= qq(Content-Type: image/png\n\n);
my $qr		= GD::Barcode::QRcode->new($str)->plot->png;
print $header,$qr;
exit;


- Reference
GD::Barcode::QRcode
Debian パッケージディレクトリ検索 (バイナリ) - libgd-graph-perl

どんぞこ日誌(2004-07-25)
http://donzoko.net/cgi-bin/tdiary/20040725.html

2006-03-04 Sat

Capture STAFF Light - 高機能スクリーンキャプチャ

- Summary
連続キャプチャや周期キャプチャ,Web等のスクロールキャプチャが可能な画像キャプチャソフトウェア.
Internet Explorer, Firefox での スクロールキャプチャが可能.

- Reference
femt's home page - Capture STAFF -Light-
http://hp.vector.co.jp/authors/VA017297/#capt_st
Vector - Capture STAFF - Light -
http://www.vector.co.jp/soft/win95/art/se119281.html

2006-03-03 Fri

原美術館

- Data

住所 東京都品川区北品川4-7-25 (原美術館)
開館時間 11:00 - 17:00, 水曜日は11:00 - 20:00
休館日 月曜日
電話番号 03-3445-0651
最寄駅 品川
入館料 \1000

- Summary
オラファー・エリアソン (Olafur Eliasson) の「光と影」(Your Light Shadow)を見てきた.
Amazon - Olafur Eliasson: Your Light House: Working With Light, 1991-2004: 洋書Amazon - Olafur Eliasson: 洋書Amazon - Olafur Eliasson (Contemporary Artists): 洋書Amazon - Olafur Eliasson: Photographs: 洋書Amazon - Olafur Eliasson: The Blind Pavilion: 洋書
Amazon - Dufttunnel: Ein Projekt Fur Die Autostadt in Wolfsburg/A Project for the Autostadt in Wolfsburg: 洋書Amazon - Parkett 2002 (Parkett): 洋書Amazon - Einbildung (Imagination) Perception in Art: 洋書Amazon - The Mediated Motion: 洋書



- Reference
Hara Museum
http://www.haramuseum.or.jp/
日本の博物館美術館ガイド - 原美術館
http://e-museum.jp/modules/weblinks/singlelink.php?lid=1456
YOKOHAMA2001 - Artist data sheet - Olafur Eliasson
http://www.jpf.go.jp/yt2001/cyber/artist/029_Elia/
Olafur Eliasson

2006-03-02 Thu

はてなリング - ChangeLog メモ

<script type="text/javascript"
        src="http://ring.hatena.ne.jp/showlogo?rid=changelogmemo&sid=106801&mode=image"></script>
<noscript>
<a href="http://changelogmemo.ring.hatena.ne.jp/"><img 
   src="http://ring.hatena.ne.jp/images/logo/c/changelogmemo/changelogmemo_s.jpg" /></a>
<a href="http://changelogmemo.ring.hatena.ne.jp/go?type=random&sid=106801">random</a>
<a href="http://changelogmemo.ring.hatena.ne.jp/">Hatena Ring changelogmemo</a>
</noscript>




- Reference
はてなリング - ChangeLog メモ
http://changelogmemo.ring.hatena.ne.jp/

All your base are belong to us

- Summary
ゼロウイングというゲームの翻訳英語.
略してAll Your Base, AYBABTU, AYBとも言われる.

- Reference
Wikipedia - All your base are belong to us
Wikipedia - Engrish

All your base are belong to us
http://24hour.system.to/jitb/ayb.htm

faireal.net - 2003-08-15 - "All your base are belong to us" vs. "反省しる"
http://www.faireal.net/articles/8/03/#d30815_2

MediaZilla Main Page
http://bugzilla.wikimedia.org/

ITmedia News:YouTubeに謎のメンテナンス?画面
http://www.itmedia.co.jp/news/articles/0606/02/news073.html

勝手に ALPSLAB clip! for chalow - ALPSLAB clip! の chalow 用プラグイン

- Summary
以下の記述で地図が挿入できる.

{{alps_map('東京都新宿区西新宿2-8-1')}}
{{alps_map('35/41/10.574,139/41/41.787')}}
 
{{alps_map('東京都新宿区西新宿2-8-1','LN')}}


- Sample
ALPSLAB clip! - 東京都新宿区西新宿2-8-1

- オプション
サイズ指定
L 480 x 360
M 320 x 240 (デフォルト)
S 240 x 180

縮尺指定
D 詳細 最大縮尺 (デフォルト)
N 中域 (25000階層)
W 広域 (250000階層)

- Reference
勝手に ALPSLAB clips! for chalow
http://www.kunitake.org/chalow/alps-chalow_pl.txt

ALPSLAB clip!
http://www.alpslab.jp/clip.html

戯れ言 / 2006-02-28
http://www.kunitake.org/chalow/2006-02-28.html#2006-02-28-2

- via
/home/pochi/ChangeLog - 2006-03-01 - ALPSLAB clip! の Chalow 用プラグイン
http://www.pochi.cc/~sasaki/chalow/2006-03-01-1.html

読書記録ChangeLog - 2006-03-01
http://dkiroku.com/2006-03-01-14.html

- 追記 [2009-08-19-1]
embed_mapに変更。
いまさら、Google mapsの埋め込みに。

2006-03-01 Wed

mod_cache + mod_mem_cache を利用した apache2 のパフォーマンス改善とその効果

- Summary
mod_cache + mod_disk_cache を利用した apache2 のパフォーマンス改善とその効果 [2006-02-28-6] では,
mod_disk_cache の使用前後を比較し,その効果は証明されたが,以下のエラーが発生するようになった.

Directory index forbidden by rule: /path/to/public_html/foo/


今度は,mod_cache + mod_mem_cache を利用することにした.

- /etc/apache2/mods-available/mem_cache.conf
MCacheSize は kByte単位.

<IfModule mod_cache.c>
	<IfModule mod_mem_cache.c>
		CacheEnable mem /
		MCacheSize 4096
		MCacheMaxObjectCount 100
		MCacheMinObjectSize 1
		MCacheMaxObjectSize 2048
	</IfModule>
</IfModule>


- mod_cache と mod_mem_cache の有効化

# a2enmod cache
# a2enmod mem_cache
# apache2ctl configtest
# apache2ctl restart




- mod_cache + mod_mem_cache 使用後のベンチマーク (ApacheBench を利用)
mod_cache + mod_mem_cache 使用後 (HTMLへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/static
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/static
Document Length: 119 bytes

Concurrency Level: 10
Time taken for tests: 2.615437 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 43800 bytes
HTML transferred: 11900 bytes
Requests per second: 38.23 [#/sec] (mean)
Time per request: 261.544 [ms] (mean)
Time per request: 26.154 [ms] (mean, across all concurrent requests)
Transfer rate: 16.06 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 10 25 9.7 26 60
Processing: 36 224 44.5 230 304
Waiting: 26 136 65.5 136 269
Total: 62 250 44.8 259 333

Percentage of the requests served within a certain time (ms)
  50% 259
  66% 265
  75% 267
  80% 271
  90% 291
  95% 311
  98% 325
  99% 333
 100% 333 (longest request)


mod_cache + mod_mem_cache 使用後 (PHPへのアクセス)

% ab -n 100 -c 10 http://xight.org/test/dynamic
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.4502 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xight.org (be patient).....done


Server Software: Apache
Server Hostname: xight.org
Server Port: 80

Document Path: /test/dynamic
Document Length: 1011 bytes

Concurrency Level: 10
Time taken for tests: 2.532703 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 125500 bytes
HTML transferred: 101100 bytes
Requests per second: 39.48 [#/sec] (mean)
Time per request: 253.270 [ms] (mean)
Time per request: 25.327 [ms] (mean, across all concurrent requests)
Transfer rate: 48.17 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 10 24 5.9 24 38
Processing: 36 216 43.1 223 271
Waiting: 33 134 61.2 136 267
Total: 60 241 43.9 247 303

Percentage of the requests served within a certain time (ms)
  50% 247
  66% 253
  75% 263
  80% 263
  90% 279
  95% 291
  98% 295
  99% 303
 100% 303 (longest request)