<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LabMemo</title>
	<atom:link href="http://ebisuisland.com/labmemo/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://ebisuisland.com/labmemo</link>
	<description></description>
	<lastBuildDate>Thu, 14 May 2009 00:32:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>悩ましいtarget=&#8221;_blank&#8221;問題に対するシンプルな解</title>
		<link>http://ebisuisland.com/labmemo/?p=65</link>
		<comments>http://ebisuisland.com/labmemo/?p=65#comments</comments>
		<pubDate>Thu, 14 May 2009 00:31:03 +0000</pubDate>
		<dc:creator>Ethan Goodspeed</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://ebisuisland.com/labmemo/?p=65</guid>
		<description><![CDATA[XHTML 1.0 Strictではanchorタグにtarget=&#8221;_blank&#8221;属性を設けて、新規ウインドウでリンク先を開くことが認められていない。
私自身、いまだにtransitionalを [...]]]></description>
			<content:encoded><![CDATA[<p>XHTML 1.0 Strictではanchorタグにtarget=&#8221;_blank&#8221;属性を設けて、新規ウインドウでリンク先を開くことが認められていない。</p>
<p>私自身、いまだにtransitionalを主流にしているのであまり深くは考えてきていなかったのだが、先日、知人から「どうすれば最もシンプルに解決できるのか?」という質問を受けた。</p>
<p>Javascriptを使って新規ウインドウで開くのは手法として当然のことだが、ここで「シンプルに…」と言われて、<a href="http://www.catswhocode.com/blog/" target="_blank">catswhocode.com</a>の<a href="http://www.catswhocode.com/blog/8-awesome-jquery-tips-and-tricks" target="_blank">8 awesome JQuery tips and tricks</a>という記事を思い出し、ちょっと手を加えてみた。</p>
<p>手筈は極めて簡単で、anchorタグにrel属性で特定の名前を与えておいて、jQueryを使ってその名前を持つものだけ新規ウインドウで開くというやり方（<a href="/extlink_sampl/index.html" target="_blank">一応これがデモページ</a>）。jQueryをロードした後、以下のスクリプトを実行させるだけで済む。</p>
<blockquote><p>
&lt;script type=&#8221;text/javascript&#8221;&gt;// &lt;![CDATA[<br />
&nbsp;&nbsp;$(document).ready(function(){<br />
&nbsp;&nbsp;//-----------<br />
&nbsp;&nbsp;&nbsp;&nbsp;$("a[rel^='extlink']&#8220;).click(function(){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.target = &#8220;_blank&#8221;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;});<br />
&nbsp;&nbsp;//&#8212;&#8212;&#8212;&#8211;<br />
&nbsp;&nbsp;});<br />
// ]]&gt;&lt;/script&gt;
</p></blockquote>
<p>ソースにあるとおり、ここではanchorタグのrel属性にextlinkで始まる値を持つものだけを対象にしている。</p>
<p>至ってシンプル。もちろんW3Cの<a href="http://validator.w3.org/check?uri=referer">Markup Validation</a>もキチンと通る。<a href="/extlink_sampl/index.html" target="_blank">デモページ</a>ではcssにも細工を持たせ、外部リンクを明示的に示すアイコンも表示できるようにしてあるので、興味があれば参照してほしい。</p>
]]></content:encoded>
			<wfw:commentRss>http://ebisuisland.com/labmemo/?feed=rss2&amp;p=65</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leopardで、ローカルへMT4をインストール</title>
		<link>http://ebisuisland.com/labmemo/?p=60</link>
		<comments>http://ebisuisland.com/labmemo/?p=60#comments</comments>
		<pubDate>Wed, 06 May 2009 05:39:26 +0000</pubDate>
		<dc:creator>Ethan Goodspeed</dc:creator>
				<category><![CDATA[Leopard]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[MT4]]></category>

		<guid isPermaLink="false">http://ebisuisland.com/labmemo/?p=60</guid>
		<description><![CDATA[取引先の方から「LeopardでローカルへMT4をインストールしたいのだけれども…」という問い合わせがあったので、解答前に自らの環境で手順を確認。このエントリはそのメモ。
Xcodeはインストールしていることを想定してい [...]]]></description>
			<content:encoded><![CDATA[<p>取引先の方から「LeopardでローカルへMT4をインストールしたいのだけれども…」という問い合わせがあったので、解答前に自らの環境で手順を確認。このエントリはそのメモ。<br />
Xcodeはインストールしていることを想定しているので、新たにインストールしたのは以下の4つ：</p>
<ul>
<li> MAMP </li>
<li> DBI</li>
<li>DBD-SQLite</li>
<li> MT </li>
</ul>
<p>MAMPはイメージをマウントして、アプリケーションフォルダへドラッグでインストール完了。インストール後にMAMP.appをダブルクリックすればサーバが自動起動し、ブラウザの新規ウインドウが開いてテストページが表示される。ポートは8888番。動作を確認後に終了。</p>
<p>DBIはtarボールを展開後そのディレクトリへ下りて「perl Makefile.PL」でmakeファイルを構成。構成後、「make」そしてその後「make test」。test.pl doneとメッセージが出て問題なくテストが完了したら「sudo make install」でインストール。当然管理者パスワードは必要。</p>
<p>DBD-SQLite-1.25もDBIと同様の手順。</p>
<p>続いてMT4のインストール。展開したディレクトリ名をmt4に変え、MAMPのディレクトリ直下のcgi-binディレクトリへ移動（/Application/MAMP/cgi-bin/mt4/）。そのmt4ディレクトリ内にあるmt-staticディレクトリを、MAMPのディレクトリ直下のhtdocsディレクトリへ移動（mt-static）。</p>
<p>これらを移動した後、MAMPを起動し、ウィザードを使ってMT4を構成（http://localhost:8888/cgi-bin/mt4/mt-wizard.cgi）。Static web pathは「http://localhost:8888/mt-static」に、Static file pathは「/Applications/MAMP/htdocs/mt-static」に設定。</p>
<p>DBの設定画面ではパスを「/Applications/MAMP/db/sqlite/mt.db」に設定。</p>
<p>以上で完了。デフォルトのブログ名のまま構成していればhttp://localhost:8888/my_first_blog/でページを確認できる。後は煮るなり、焼くなり。</p>
<p>P.S.<br />
久しくMTを触っていなかったのだが、取り立てて戸惑うところはなかった。個人的な意見を述べさせてもらえば、こうやってローカルへインストールする方がかえって面倒に思える。公開を前提しているサーバであればすでにインストール済みであろうものが一切、もしくは中途半端に入っている分だけ手間だ。今どきのレンタルサーバなら月額500円程で御膳立ての整った環境をほぼ即座に借りられるのだから、そちらの利用をおすすめしたい。</p>
<p>「テンプレートやテーマの開発にどうしてもローカルで…」というニーズであれば理解できなくもないが、安易に入れてもHDDの肥やしを増やしてしまうだけだと思う。</p>
]]></content:encoded>
			<wfw:commentRss>http://ebisuisland.com/labmemo/?feed=rss2&amp;p=60</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leopardでテスト環境用にPostgreSQLをインストール</title>
		<link>http://ebisuisland.com/labmemo/?p=48</link>
		<comments>http://ebisuisland.com/labmemo/?p=48#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:54:01 +0000</pubDate>
		<dc:creator>Ethan Goodspeed</dc:creator>
				<category><![CDATA[Leopard]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://ebisuisland.com/labmemo/?p=48</guid>
		<description><![CDATA[5年くらいまえ、メインマシンがまだThinkPadだった頃、PowerBookにPostgreSQLをインストールする時はADCの資料を参考にFinkの手を借りるお手軽な方法を選んだ。今ならさしずめMac Portsと言 [...]]]></description>
			<content:encoded><![CDATA[<p>5年くらいまえ、メインマシンがまだThinkPadだった頃、PowerBookに<a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a>をインストールする時は<a href="http://developer.apple.com/" target="_blank">ADC</a>の資料を参考にFinkの手を借りるお手軽な方法を選んだ。今ならさしずめMac Portsと言うところだろう。</p>
<p>当時、自分にとってのPowerBookは、Vista後を考えた上でメイン環境をOS Xへ移行することを見据えたウオーミングアップ期間であり、配付システムでアップデートを続けても特に気にならないくらいにディスクの空き容量は潤沢にあった。環境がおかしくなってもすべてクリーン・インストールしなおせば良いというお気楽な考えもあたまの中にあった。</p>
<p>しかし、いま使っているMacBook Proはメインマシン。使いもしないソースをわざわざローカルに置いておきたいはずもない。だから今回、PostgreSQLをインストールする際にもMac Portsを使おうといういう考えははなからなかった。クリアにしておきたかったポイントは以下のとおり：</p>
<ol>
<li>最新のソースからのインストール</li>
<li>「postgres」ユーザを利用せず、現在自分が利用しているユーザでPostgreSQLを動かす</li>
<li>上記も踏まえ<a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/dscl.1.html" target="_blank">dsclコマンド</a>での操作も行わない</li>
</ul>
<p>上述のポイントはオーバーラップする部分がある。バイナリで配付されているPostgreSQLでは「postgres」ユーザが作成されてしまう。またユーザが作成されてしまうのでdsclコマンドでユーザ環境の初期操作も必要になる。しかもユーザが増えると、起動時にGUIログインでの画面が現れるという悪循環が生まれる。</p>
<p>そもそも今回PostgreSQLをローカルへ放り込むことになった理由はデータベースで遊ぶためではなく、<a href="http://www.djangoproject.com/" target="_blank">Django</a>での開発を行うためなので、このような渾沌がメインマシンに持ち込まれることは精神的にもよくない。</p>
<p>これらの理由も踏まえて、いろいろと調べることから始めた。この3年ばかりは翻訳仕事がメインになっていたこともあり、正直いって状況把握をかなり怠っていたからだ。</p>
<p>まずは把握すべくは初期の共有メモリの値。これへの対応はPostgreSQL 8.2.13 Documentationの<a href="http://www.postgresql.org/docs/8.2/interactive/kernel-resources.html" target="_blank">16.4. Managing Kernel Resources</a>と<a href="http://earthcode.com/blog/2008/01/postgresql_on_leopard_gotchas.html" target="_blank">Andre Lewis氏のブログエントリ</a>を参考にした。</p>
<blockquote><p>
In OS X 10.3.9 and later, instead of editing /etc/rc you may create a file named /etc/sysctl.conf, containing variable assignments such as</p>
<p>kern.sysv.shmmax=4194304<br />
kern.sysv.shmmin=1<br />
kern.sysv.shmmni=32<br />
kern.sysv.shmseg=8<br />
kern.sysv.shmall=1024<br />
This method is better than editing /etc/rc because your changes will be preserved across system updates. Note that all five shared-memory parameters must be set in /etc/sysctl.conf, else the values will be ignored.</p>
<p>Beware that recent releases of OS X ignore attempts to set SHMMAX to a value that isn&#8217;t an exact multiple of 4096.</p>
<p>SHMALL is measured in 4 kB pages on this platform.
</p></blockquote>
<p>実際に割当てた値は以下のとおり：</p>
<blockquote><p>
%  cat /etc/sysctl.conf<br />
kern.sysv.shmmax=167772160<br />
kern.sysv.shmmin=1<br />
kern.sysv.shmmni=32<br />
kern.sysv.shmseg=8<br />
kern.sysv.shmall=65536
</p></blockquote>
<p>sysctl.confを作成した後、マシンを再起動し割当てを有効にして、PostgreSQLをインストール。インストールの方法はなんら悩むようなものではなく、ダウンロードしてきたソースを展開後、素直に./configure、make 、make installの順番で進めていくだけだ。</p>
<p>「postgres」ユーザの問題はPostgreSQLインストール後のdata/ディレクトリの所有権を自分に変更することで対応している。</p>
<blockquote><p>
# chown -R egg /usr/local/pgsql/data
</p></blockquote>
<p>環境変数に実行パスとaliasを追加（私はtcshを使っているので、必要に合わせて読み替ええてほしい）。</p>
<blockquote><p>
% cat ./.cshrc<br />
set path=($path /usr/local/bin /opt/local/bin /opt/local/sbin ~/bin /usr/local/pgsql/bin)<br />
&#8230;中略&#8230;<br />
alias pgrun &#8216;/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start&#8217;<br />
alias pgstop &#8216;/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop&#8217;
</p></blockquote>
<p>サーバ機ではないので、起動時にPostgreSQLが立ち上がる必要はないためaliasを使ってパラメータ込みで任意に起動／停止できるようにしてある。</p>
<p>続いてデータベースのイニシャライズ。</p>
<blockquote><p>
% initdb -D /usr/local/pgsql/data<br />
The files belonging to this database system will be owned by user &#8220;****&#8221;.<br />
This user must also own the server process.</p>
<p>The database cluster will be initialized with locales<br />
  COLLATE:  ja_JP<br />
  CTYPE:    ja_JP.UTF-8<br />
  MESSAGES: ja_JP<br />
  MONETARY: ja_JP<br />
  NUMERIC:  ja_JP<br />
  TIME:     ja_JP<br />
The default database encoding has accordingly been set to UTF8.<br />
initdb: could not find suitable text search configuration for locale ja_JP.UTF-8<br />
The default text search configuration will be set to &#8220;simple&#8221;.</p>
<p>fixing permissions on existing directory /usr/local/pgsql/data &#8230; ok<br />
creating subdirectories &#8230; ok<br />
selecting default max_connections &#8230; 100<br />
selecting default shared_buffers/max_fsm_pages &#8230; 32MB/204800<br />
creating configuration files &#8230; ok<br />
creating template1 database in /usr/local/pgsql/data/base/1 &#8230; ok<br />
initializing pg_authid &#8230; ok<br />
initializing dependencies &#8230; ok<br />
creating system views &#8230; ok<br />
loading system objects&#8217; descriptions &#8230; ok<br />
creating conversions &#8230; ok<br />
creating dictionaries &#8230; ok<br />
setting privileges on built-in objects &#8230; ok<br />
creating information schema &#8230; ok<br />
vacuuming database template1 &#8230; ok<br />
copying template1 to template0 &#8230; ok<br />
copying template1 to postgres &#8230; ok</p>
<p>WARNING: enabling &#8220;trust&#8221; authentication for local connections<br />
You can change this by editing pg_hba.conf or using the -A option the<br />
next time you run initdb.</p>
<p>Success. You can now start the database server using:</p>
<p>    postgres -D /usr/local/pgsql/data<br />
or<br />
    pg_ctl -D /usr/local/pgsql/data -l logfile start</p>
<p>====================================================<br />
% postmaster -D /usr/local/pgsql/data<br />
LOG:  database system was shut down at 2009-04-12 00:15:49 JST<br />
LOG:  database system is ready to accept connections<br />
LOG:  autovacuum launcher started<br />
====================================================</p>
<p>% pg_ctl -D /usr/local/pgsql/data stop<br />
waiting for server to shut down&#8230;. done<br />
server stopped
</p></blockquote>
<p>さて、これでお膳立ては全部そろった。後はpsycopg2を放り込んで、Djangoと連携させるだけだ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ebisuisland.com/labmemo/?feed=rss2&amp;p=48</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YQLとgetJSON()の組みあわせが素敵すぎる件について</title>
		<link>http://ebisuisland.com/labmemo/?p=11</link>
		<comments>http://ebisuisland.com/labmemo/?p=11#comments</comments>
		<pubDate>Fri, 10 Apr 2009 13:45:21 +0000</pubDate>
		<dc:creator>Ethan Goodspeed</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[getJSON]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[YQL]]></category>

		<guid isPermaLink="false">http://ebisuisland.com/labmemo/?p=11</guid>
		<description><![CDATA[CSVやRSSなど、どこかのデータソースを上手に利用してマッシュアップをしたいと考えているなら、YQLとgetJSON()の組みあわせが、なんとも素敵すぎるくらいにシンプルに物事を解決してくれる。
XMLをそのまま力技で [...]]]></description>
			<content:encoded><![CDATA[<p>CSVやRSSなど、どこかのデータソースを上手に利用してマッシュアップをしたいと考えているなら、YQLとgetJSON()の組みあわせが、なんとも素敵すぎるくらいにシンプルに物事を解決してくれる。</p>
<p>XMLをそのまま力技でparseしても良いのだろうけど。しかし実際には必要ないデータをクライアント側へ送って帯域を無駄にしてしまうのはやはりエレガントではない。どこかでJSONに畳み込んで非同期でクライアント側へ投げるのが、最低限の今どきのお作法なのだろうと思う。ならば自らのサーバサイドでLLを使ってXMLからJSONへポロリと吐き出そう、と、短絡的に考えてしまうのも悪くないが、なんだか3年前に戻ったようなDéjà vuを覚えなくもないし、せっかくだからもうひとひねりしてみたいと思うのが人情というものだろう。</p>
<p>すこし前に、IBMのdeveloperWorks Japanに<a href="http://www.ibm.com/developerworks/jp/web/library/wa-aj-jsonp2/" target="_blank">JSONP、jQuery、Yahoo! Query Language を使ってREST クエリを使ってマッシュアップを作成する</a>と言うエントリが掲載されていた。それを思い出し、参考にして<a href="http://developer.yahoo.com/yql/" target="_blank">YQL（Yahoo! Query Language）</a>を使ってJSONP(JSON with Padding)を生成し、クロスドメインなgetJSON()で遊んでみた。</p>
<p>このブログのトップページの中間カラムにある「Top news@sfgate.com」の内容は、ページがロードされた時点での最新のsfgate.comのトップニュース内容のRSSをYQL側で取り込み、ヘッドラインと記事へのURLという必要な情報だけをもったJSONPへ畳み込んでjQueryのgetJSON()で読み込んでエレメントの追加したもの。</p>
<p>コードは以下のとおり：</p>
<blockquote><p>
<code>var yqlUrl4="http://query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.sfgate.com%2Frss%2Ffeeds%2Fnews.xml%22&#038;format=json&#038;callback=?"; </p>
<p>jQuery.getJSON(yqlUrl4, function(data){<br />
    jQuery.each(data.query.results.item, function(index, item){<br />
        $("＜a href='" + item.link + "' target=\"_blank\"/＞")<br />
            .html(item.title) .appendTo($('#sfgate'))<br />
            .wrap('＜li/＞');<br />
    });<br />
});<br />
</code>
</p></blockquote>
<p>コード中にもあるように、getJSONで得た値を各々「sfgate」という識別子を持つエレメント（ここではul）に追加している。文字列へのタグの修飾（ここではliとa）も見てのとおり。YQLが生成するRESTクエリはけっして美しいとは言えないが、YQLの書きやすさと柔軟さを考えれば、差し引きしてもじゅうぶんにおつりがくる。このRESTクエリの生成に必要なYQLは以下のとおり。</p>
<blockquote><p>
select title, link from rss where url=&#8221;http://www.sfgate.com/rss/feeds/news.xml&#8221;
</p></blockquote>
<p>YQLとgetJSON()の組みあわせれは、マッシュアップのアイデアを形にするために必要な時間を大幅に短縮できる。ちょと素敵すぎるくらいに自分好みだ。</p>
<p>P.S.<br />
ちなみにjQueryのドキュメントの例にあるとおり、Flickrのようにデータフォーマット変換用APIオプションが用意されている場合はYQLを通す必要はない。便利になった反面、このあたりのチェックを怠ると「気が利いて、間が抜けてる」状態に陥りかねない。</p>
]]></content:encoded>
			<wfw:commentRss>http://ebisuisland.com/labmemo/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
