<?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>Churadesign</title>
	<atom:link href="http://www.churadesign.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.churadesign.com</link>
	<description>system &#38; web design</description>
	<lastBuildDate>Sun, 24 May 2009 13:38:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhoneアプリ開発</title>
		<link>http://www.churadesign.com/2009/02/03/iphone%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba/</link>
		<comments>http://www.churadesign.com/2009/02/03/iphone%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 12:43:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[iPhoneSDK]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=115</guid>
		<description><![CDATA[iPhoneアプリ開発でこんなことやりたいのだけど、どうやるんだっけ？ってのがちょくちょくでてきます。逆引きのリファレンス逆引きiPhoneSDK &#8211; WIKIが参考になります。
]]></description>
			<content:encoded><![CDATA[<p>iPhoneアプリ開発でこんなことやりたいのだけど、どうやるんだっけ？ってのがちょくちょくでてきます。逆引きのリファレンス<a href="http://www.iphonesdk-wiki.com">逆引きiPhoneSDK &#8211; WIKI</a>が参考になります。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2009/02/03/iphone%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>「ビジュアライジング・データ」 日本の郵便番号をマッピング</title>
		<link>http://www.churadesign.com/2009/01/10/%e3%80%8c%e3%83%93%e3%82%b8%e3%83%a5%e3%82%a2%e3%83%a9%e3%82%a4%e3%82%b8%e3%83%b3%e3%82%b0%e3%83%bb%e3%83%87%e3%83%bc%e3%82%bf%e3%80%8d-%e6%97%a5%e6%9c%ac%e3%81%ae%e9%83%b5%e4%be%bf%e7%95%aa%e5%8f%b7/</link>
		<comments>http://www.churadesign.com/2009/01/10/%e3%80%8c%e3%83%93%e3%82%b8%e3%83%a5%e3%82%a2%e3%83%a9%e3%82%a4%e3%82%b8%e3%83%b3%e3%82%b0%e3%83%bb%e3%83%87%e3%83%bc%e3%82%bf%e3%80%8d-%e6%97%a5%e6%9c%ac%e3%81%ae%e9%83%b5%e4%be%bf%e7%95%aa%e5%8f%b7/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 08:53:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[visualizing]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=97</guid>
		<description><![CDATA[&#8220;ビジュアライジング・データ ―Processingによる情報視覚化手法&#8221; にアメリカの郵便番号の緯度経度を平面上にマッピングし、キーボードからの郵便番号入力にしたがって、入力した郵便番号に部分一致するポイントをインタラクティブに表示するサンプルが載っています。
例えば、「2」と入力すると、郵便番号が「2」から始まるエリアがハイライトされ、それ以外が暗くなります。続けて「1」と入力すると「21」と続くエリアが絞り込まれてハイライトされます。
ズーム機能をオンにすると、一致したエリアになめらかにズームし、郵便番号の緯度経度といった無機質なデータをとても美しく表示してくれます。
本書はProcessingによるデータ表示の手法だけでなく、オンライン上にあるデータを取得し、解析し、不要なデータを削除するフィルタリングの手法についても書かれており、自分で応用してさまざまなデータを視覚化していくことができるようになるでしょう。
このサンプルを参考に日本の郵便番号で試してみることにしました。アメリカの郵便番号は5桁ですが、日本は7桁なのでより精緻なマップを得ることができることを期待しています。
郵便番号から緯度経度データ取得
郵便番号は郵政局のwebサイトからダウンロードできますが、残念なことに緯度経度情報が含まれていません。GoogleMapsAPIのGeocordingを使って地名から緯度経度情報を取得する簡単なスクリプトをRubyでつくりました。
データ量が多いので、同じIPからリクエスト続けていると5000件程度でGoogleMapsから拒否されるようになるので、自動的にプロキシを変更するように、データ取得をどこからでもレジュームできるように作っておくとよいでしょう。
郵便番号リストは住所に（その他）と入っていたり（１丁目〜１０丁目）、（ビル名何階）と書いてあったり表記がばらばらなので、Geocordingに投げて緯度経度が戻ってこないものは今回は無視することにしました。マッピングに必要なデータは十分な得られました。
Processingプログラム修正
本書のサンプルが外部データを取得して表示するようにつくられているため、ほとんどそのままで利用できます。アメリカの郵便番号が5桁なので、日本の郵便番号7桁に合うようにいくつか修正します。
実行
日本が浮かび上がりました。人口の密な地域はポイントもたくさんありますし、郵便番号の緯度経度だけから山脈がなんとなくわかったりとおもしろいです。9からはじまる郵便番号は沖縄と北陸、南東北まとめて割り振られたりします。
いくつかGeocordingが突飛な緯度経度を返しているようで、7からはじまる郵便番号がぽつっと関東にあったりするので、はずれ値をフィルタリングする処理を追加する必要がありそうです。
もうひとつの問題はデバイスフォントをつかって日本語が表示できない。。vlwというフォントファイルを日本語含めて作成することはできるようなのですが、フォントも配布となるとサイズが大きくなってしまうので。
データビジュアライジング
この本とても勉強になります。いろいろと刺激されてなにか作りたくなります。おすすめです！

&#8220;ビジュアライジング・データ ―Processingによる情報視覚化手法&#8221; 
追記:
・いくつか外れ値がある
・日本語表示できない。
と問題がありますが、アプレットをアップしましたのでぜひお試しください。フォーカスがあたっている状態で郵便番号を入力すると、一致したエリアがハイライトされます。ズームモードに入るには右下の「ZOOM」をクリックします。
]]></description>
			<content:encoded><![CDATA[<div id="attachment_99" class="wp-caption alignright" style="width: 330px"><a href="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data1.png"><img class="size-thumbnail wp-image-99" title="ビジュアライジング・データ サンプルアメリカ" src="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data1-320x201.png" alt="ビジュアライジング・データ サンプルアメリカ" width="320" height="201" /></a><p class="wp-caption-text">ビジュアライジング・データ サンプルアメリカ</p></div>
<p><a href="http://www.amazon.co.jp/%E3%83%93%E3%82%B8%E3%83%A5%E3%82%A2%E3%83%A9%E3%82%A4%E3%82%B8%E3%83%B3%E3%82%B0%E3%83%BB%E3%83%87%E3%83%BC%E3%82%BF-%E2%80%95Processing%E3%81%AB%E3%82%88%E3%82%8B%E6%83%85%E5%A0%B1%E8%A6%96%E8%A6%9A%E5%8C%96%E6%89%8B%E6%B3%95-Ben-Fry/dp/4873113784%3FSubscriptionId%3D0PZ7TM66EXQCXFVTMTR2%26tag%3Dc9radyn-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4873113784">&#8220;ビジュアライジング・データ ―Processingによる情報視覚化手法&#8221; </a>にアメリカの郵便番号の緯度経度を平面上にマッピングし、キーボードからの郵便番号入力にしたがって、入力した郵便番号に部分一致するポイントをインタラクティブに表示するサンプルが載っています。</p>
<p>例えば、「2」と入力すると、郵便番号が「2」から始まるエリアがハイライトされ、それ以外が暗くなります。続けて「1」と入力すると「21」と続くエリアが絞り込まれてハイライトされます。</p>
<p>ズーム機能をオンにすると、一致したエリアになめらかにズームし、郵便番号の緯度経度といった無機質なデータをとても美しく表示してくれます。</p>
<p>本書はProcessingによるデータ表示の手法だけでなく、オンライン上にあるデータを取得し、解析し、不要なデータを削除するフィルタリングの手法についても書かれており、自分で応用してさまざまなデータを視覚化していくことができるようになるでしょう。</p>
<p>このサンプルを参考に日本の郵便番号で試してみることにしました。アメリカの郵便番号は5桁ですが、日本は7桁なのでより精緻なマップを得ることができることを期待しています。</p>
<h3>郵便番号から緯度経度データ取得</h3>
<p>郵便番号は郵政局のwebサイトからダウンロードできますが、残念なことに緯度経度情報が含まれていません。GoogleMapsAPIのGeocordingを使って地名から緯度経度情報を取得する簡単なスクリプトをRubyでつくりました。</p>
<p>データ量が多いので、同じIPからリクエスト続けていると5000件程度でGoogleMapsから拒否されるようになるので、自動的にプロキシを変更するように、データ取得をどこからでもレジュームできるように作っておくとよいでしょう。</p>
<p>郵便番号リストは住所に（その他）と入っていたり（１丁目〜１０丁目）、（ビル名何階）と書いてあったり表記がばらばらなので、Geocordingに投げて緯度経度が戻ってこないものは今回は無視することにしました。マッピングに必要なデータは十分な得られました。</p>
<h3>Processingプログラム修正</h3>
<p>本書のサンプルが外部データを取得して表示するようにつくられているため、ほとんどそのままで利用できます。アメリカの郵便番号が5桁なので、日本の郵便番号7桁に合うようにいくつか修正します。</p>
<h3>実行</h3>
<p>日本が浮かび上がりました。人口の密な地域はポイントもたくさんありますし、郵便番号の緯度経度だけから山脈がなんとなくわかったりとおもしろいです。9からはじまる郵便番号は沖縄と北陸、南東北まとめて割り振られたりします。</p>
<p>いくつかGeocordingが突飛な緯度経度を返しているようで、7からはじまる郵便番号がぽつっと関東にあったりするので、はずれ値をフィルタリングする処理を追加する必要がありそうです。<br />
もうひとつの問題はデバイスフォントをつかって日本語が表示できない。。vlwというフォントファイルを日本語含めて作成することはできるようなのですが、フォントも配布となるとサイズが大きくなってしまうので。</p>
<div id="attachment_104" class="wp-caption alignleft" style="width: 321px"><a href="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data2.png"><img class="size-thumbnail wp-image-104" title="ビジュアライジング・データ 日本1" src="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data2-311x320.png" alt="ビジュアライジング・データ 日本1" width="311" height="320" /></a><p class="wp-caption-text">ビジュアライジング・データ 日本1</p></div>
<div id="attachment_105" class="wp-caption alignleft" style="width: 330px"><a href="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data3.png"><img class="size-thumbnail wp-image-105" title="ビジュアライジング・データ 日本2" src="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data3-320x307.png" alt="ビジュアライジング・データ 日本2" width="320" height="307" /></a><p class="wp-caption-text">ビジュアライジング・データ 日本2</p></div>
<div id="attachment_106" class="wp-caption alignnone" style="width: 319px"><a href="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data4.png"><img class="size-thumbnail wp-image-106" title="ビジュアライジング・データ 日本3" src="http://www.churadesign.com/wp-content/uploads/2009/01/visualizing-data4-309x320.png" alt="ビジュアライジング・データ 日本3" width="309" height="320" /></a><p class="wp-caption-text">ビジュアライジング・データ 日本3</p></div>
<h3>データビジュアライジング</h3>
<p>この本とても勉強になります。いろいろと刺激されてなにか作りたくなります。おすすめです！<br />
<a href="http://www.amazon.co.jp/%E3%83%93%E3%82%B8%E3%83%A5%E3%82%A2%E3%83%A9%E3%82%A4%E3%82%B8%E3%83%B3%E3%82%B0%E3%83%BB%E3%83%87%E3%83%BC%E3%82%BF-%E2%80%95Processing%E3%81%AB%E3%82%88%E3%82%8B%E6%83%85%E5%A0%B1%E8%A6%96%E8%A6%9A%E5%8C%96%E6%89%8B%E6%B3%95-Ben-Fry/dp/4873113784%3FSubscriptionId%3D0PZ7TM66EXQCXFVTMTR2%26tag%3Dc9radyn-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4873113784"><img src="http://ecx.images-amazon.com/images/I/41DdCRhKTAL._SL160_.jpg" alt="" width="124" height="160" /></a><br />
<a href="http://www.amazon.co.jp/%E3%83%93%E3%82%B8%E3%83%A5%E3%82%A2%E3%83%A9%E3%82%A4%E3%82%B8%E3%83%B3%E3%82%B0%E3%83%BB%E3%83%87%E3%83%BC%E3%82%BF-%E2%80%95Processing%E3%81%AB%E3%82%88%E3%82%8B%E6%83%85%E5%A0%B1%E8%A6%96%E8%A6%9A%E5%8C%96%E6%89%8B%E6%B3%95-Ben-Fry/dp/4873113784%3FSubscriptionId%3D0PZ7TM66EXQCXFVTMTR2%26tag%3Dc9radyn-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4873113784">&#8220;ビジュアライジング・データ ―Processingによる情報視覚化手法&#8221; </a></p>
<p>追記:</p>
<p>・いくつか外れ値がある</p>
<p>・日本語表示できない。</p>
<p>と問題がありますが、<a href="http://churadesign.com/applets/visualizing_data_zips/">アプレットをアップ</a>しましたのでぜひお試しください。フォーカスがあたっている状態で郵便番号を入力すると、一致したエリアがハイライトされます。ズームモードに入るには右下の「ZOOM」をクリックします。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2009/01/10/%e3%80%8c%e3%83%93%e3%82%b8%e3%83%a5%e3%82%a2%e3%83%a9%e3%82%a4%e3%82%b8%e3%83%b3%e3%82%b0%e3%83%bb%e3%83%87%e3%83%bc%e3%82%bf%e3%80%8d-%e6%97%a5%e6%9c%ac%e3%81%ae%e9%83%b5%e4%be%bf%e7%95%aa%e5%8f%b7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GAEOアプリをDashcodeでiPhone/iPodTouch対応</title>
		<link>http://www.churadesign.com/2008/12/19/gaeo%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92dashcode%e3%81%a7iphoneipodtouch%e5%af%be%e5%bf%9c/</link>
		<comments>http://www.churadesign.com/2008/12/19/gaeo%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92dashcode%e3%81%a7iphoneipodtouch%e5%af%be%e5%bf%9c/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 14:42:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[GAEO]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPodTouch]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=93</guid>
		<description><![CDATA[

Dashcodeすばらしい。iPhone/iPodTouch向けのWEBサイトを簡単に作ることができます。GUIでパーツを配置するだけでデザインの編集ができます。
デバッガ機能も充実していて、ブレークポイント、スタックトレースなど豊富なデバック機能を活用することができます。
今回はGoogleAppEngineOil(GAEO)で作成していたアプリケーションのフロントにiPhone/iPodTouch用のテンプレートを作成しました。
GAEOではBaseControllerに_is_iphoneというフラグを持っているため、今回はiPhone/iPodTouchからのアクセスは/touchというアドレスにリダイレクトします。if self._is_iphone: self.redirect(&#8221;/touch&#8221;)
TouchControllerのindexテンプレートにDashcodeで作成したindex.htmlを設定します。
app.yamlでDashcodeで生成したjsやcss、画像などを正しく読めるように設定します。
iPhone/iPodTouchでデータを取得するには、Dashcodeでmain.jsからXMLHttpRequestを通してデータを取得するようになるため、GAEOからはテキスト/JSON形式でデータを返すようにしました。


def get_hello_data(self):

self.render(text=Hellodata.getTestData())

]]></description>
			<content:encoded><![CDATA[<p><strong><br />
</strong></p>
<p><img class="alignleft size-thumbnail wp-image-95" title="dashcode2" src="http://www.churadesign.com/wp-content/uploads/2008/12/dashcode2-263x320.png" alt="dashcode2" width="263" height="320" />Dashcodeすばらしい。iPhone/iPodTouch向けのWEBサイトを簡単に作ることができます。GUIでパーツを配置するだけでデザインの編集ができます。</p>
<p>デバッガ機能も充実していて、ブレークポイント、スタックトレースなど豊富なデバック機能を活用することができます。</p>
<p>今回はGoogleAppEngineOil(GAEO)で作成していたアプリケーションのフロントにiPhone/iPodTouch用のテンプレートを作成しました。</p>
<p>GAEOではBaseControllerに<strong>_is_iphone</strong>というフラグを持っているため、今回はiPhone/iPodTouchからのアクセスは/touchというアドレスにリダイレクトします。<strong>if self._is_iphone: self.redirect(&#8221;/touch&#8221;)</strong></p>
<p>TouchControllerのindexテンプレートにDashcodeで作成したindex.htmlを設定します。</p>
<p><strong>app.yaml</strong>でDashcodeで生成したjsやcss、画像などを正しく読めるように設定します。</p>
<p>iPhone/iPodTouchでデータを取得するには、Dashcodeで<strong>main.js</strong>から<strong>XMLHttpRequest</strong>を通してデータを取得するようになるため、GAEOからはテキスト/JSON形式でデータを返すようにしました。</p>
<pre class="brush: php">

def get_hello_data(self):

self.render(text=Hellodata.getTestData())
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/12/19/gaeo%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92dashcode%e3%81%a7iphoneipodtouch%e5%af%be%e5%bf%9c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSXにLaTeX環境(Emacs+YaTex+LaTex+TeXShop)を構築してPDFプレビューする</title>
		<link>http://www.churadesign.com/2008/12/10/osx%e3%81%ablatex%e7%92%b0%e5%a2%83emacsyatexlatextexshop%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6pdf%e3%83%97%e3%83%ac%e3%83%93%e3%83%a5%e3%83%bc%e3%81%99%e3%82%8b/</link>
		<comments>http://www.churadesign.com/2008/12/10/osx%e3%81%ablatex%e7%92%b0%e5%a2%83emacsyatexlatextexshop%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6pdf%e3%83%97%e3%83%ac%e3%83%93%e3%83%a5%e3%83%bc%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 04:03:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[TeX]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=86</guid>
		<description><![CDATA[めんどうなことはせずにとにかくTeX環境をOSX上に構築したい人向けです。OSX10.5(Leopald)にMacPort環境を構築していて既に、CarbonEmacsを使っている前提で書いています。
もしも、以前にteTeXやpTeXなどをインストールしようとしていた場合はすべてアンインストールしておいてください。残っているとインストール途中にエラーが発生します。
インストール
portも最新になるようにsudo port selfupgradeしておきます。
pTexをインストールします。かなり時間がかかります。

sudo port install pTeX +hiragino +otf +utf8 +motif +macosx

TeXShopをダウンロードしdmgをバインドし、アプリケーションにコピーしてインストールします。
TexShopを起動して、環境設定を開きます。
「設定プロファイル」からTexShop標準を選択し標準のプロファイルをロードします。
「エンコーディング」をUTF-8に変更します。
「プレビュー」タブの「外部エディタ」「プレビューの自動更新」にチェックを入れます。
「内部設定」タブの「パス設定」(pdf)、Distiller(Ghostscript)両方を/opt/local/binに変更します。
「TeX + dvips + distiller」の「TeXプログラム」を~/Library/TeXShop/bin/ptex2pdf-utf8に変更します。
下の「LaTexプログラム」を~/Library/TeXShop/bin/platex2pdf-utf8にします。
「タイプセット」タブを開いて「ディフォルトのスクリプト」を「TeX + Ghostscript」に変更します。
ターミナルを開いて

$ cp ~/Library/TeXShop/bin/ptex2pdf-euc ~/Library/TeXShop/bin/ptex2pdf-utf8
$ cp ~/Library/TeXShop/bin/platex2pdf-euc ~/Library/TeXShop/bin/platex2pdf-utf8

と入力します。
TexShopを再起動します。
TexShopで動作確認
TeXShopが起動したら、テキスト入力画面に

\documentclass[12pt]{jarticle}
\begin{document}

\title{タイトル}
\author{テスト}
\date{\today}
\maketitle

ハローLaTeX

\end{document}

と入力し、保存します。上部にある「タイプセット」をクリックすると、TeXがコンパイルされPDFが表示されます。
Emacs+YaTeX設定
Emacsを起動し、「Help」-「Carbon Emacs Package」-「Net-Install」-「YaTeX」を選択し、YaTeXをインストールします。
~/.emacs.elに次の行を追加します。


;;Tex
(setq auto-mode-alist
(cons (cons &#34;\\.tex$&#34; &#039;yatex-mode) auto-mode-alist))
(autoload &#039;yatex-mode &#34;yatex&#34; &#34;Yet Another LaTeX mode&#34; t)
(setq tex-command &#34;~/Library/TeXShop/bin/platex2pdf-utf8&#34; dvi2-command &#34;open -a TexShop&#34;)

emacsを起動し、hellotex.texファイルを作成します。
先ほどと同じように

\documentclass[12pt]{jarticle}
\begin{document}

\title{タイトル}
\author{テスト}
\date{\today}
\maketitle

ハローLaTeX

\end{document}

と入力し保存します。
C-t jでコンパイルした後、C-t pでプレビューができることを確認してください。
YaTexには様々な便利な機能がありますので「YaTeX World」の野鳥入門を一通り試してみるとよいでしょう。
texファイルの変更後はC-t jでコンパイルし、プレビュー画面に移動することで自動更新してくれますが、バックグラウンドで再読み込みしたい場合はSKIMがよさそうです。
SKIMをダウンロードして、インストール。「Preference」の「Sync」タブの「Check for file changes」にチェックを入れ、「PDF-TeX Sync support」の「Preset:」から「Emacs」を選択します。
~/.emacs.elのdvi2-command &#8220;open -a TexShop&#8221;をdvi2-command [...]]]></description>
			<content:encoded><![CDATA[<p>めんどうなことはせずにとにかくTeX環境をOSX上に構築したい人向けです。OSX10.5(Leopald)にMacPort環境を構築していて既に、CarbonEmacsを使っている前提で書いています。</p>
<p>もしも、以前にteTeXやpTeXなどをインストールしようとしていた場合はすべてアンインストールしておいてください。残っているとインストール途中にエラーが発生します。</p>
<h3>インストール</h3>
<p>portも最新になるように<strong>sudo port selfupgrade</strong>しておきます。</p>
<p>pTexをインストールします。かなり時間がかかります。</p>
<pre class="brush: php">
sudo port install pTeX +hiragino +otf +utf8 +motif +macosx
</pre>
<p><a href="http://www.uoregon.edu/~koch/texshop/texshop.html">TeXShopをダウンロード</a>しdmgをバインドし、アプリケーションにコピーしてインストールします。</p>
<p>TexShopを起動して、環境設定を開きます。</p>
<p>「設定プロファイル」からTexShop標準を選択し標準のプロファイルをロードします。</p>
<p>「エンコーディング」をUTF-8に変更します。</p>
<p>「プレビュー」タブの「外部エディタ」「プレビューの自動更新」にチェックを入れます。</p>
<p>「内部設定」タブの「パス設定」(pdf)、Distiller(Ghostscript)両方を<strong>/opt/local/bin</strong>に変更します。</p>
<p>「TeX + dvips + distiller」の「TeXプログラム」を<strong>~/Library/TeXShop/bin/ptex2pdf-utf8</strong>に変更します。</p>
<p>下の「LaTexプログラム」を<strong>~/Library/TeXShop/bin/platex2pdf-utf8</strong>にします。</p>
<p>「タイプセット」タブを開いて「ディフォルトのスクリプト」を「TeX + Ghostscript」に変更します。</p>
<p>ターミナルを開いて</p>
<pre class="brush: php">
$ cp ~/Library/TeXShop/bin/ptex2pdf-euc ~/Library/TeXShop/bin/ptex2pdf-utf8
$ cp ~/Library/TeXShop/bin/platex2pdf-euc ~/Library/TeXShop/bin/platex2pdf-utf8
</pre>
<p>と入力します。</p>
<p>TexShopを再起動します。</p>
<h3>TexShopで動作確認</h3>
<p>TeXShopが起動したら、テキスト入力画面に</p>
<pre class="brush: php">
\documentclass[12pt]{jarticle}
\begin{document}

\title{タイトル}
\author{テスト}
\date{\today}
\maketitle

ハローLaTeX

\end{document}
</pre>
<p>と入力し、保存します。上部にある「タイプセット」をクリックすると、TeXがコンパイルされPDFが表示されます。</p>
<h3>Emacs+YaTeX設定</h3>
<p>Emacsを起動し、「Help」-「Carbon Emacs Package」-「Net-Install」-「YaTeX」を選択し、YaTeXをインストールします。</p>
<p><strong>~/.emacs.el</strong>に次の行を追加します。</p>
<pre class="brush: php">

;;Tex
(setq auto-mode-alist
(cons (cons &quot;\\.tex$&quot; &#039;yatex-mode) auto-mode-alist))
(autoload &#039;yatex-mode &quot;yatex&quot; &quot;Yet Another LaTeX mode&quot; t)
(setq tex-command &quot;~/Library/TeXShop/bin/platex2pdf-utf8&quot; dvi2-command &quot;open -a TexShop&quot;)
</pre>
<p>emacsを起動し、<strong>hellotex.tex</strong>ファイルを作成します。</p>
<p>先ほどと同じように</p>
<pre class="brush: php">
\documentclass[12pt]{jarticle}
\begin{document}

\title{タイトル}
\author{テスト}
\date{\today}
\maketitle

ハローLaTeX

\end{document}
</pre>
<p>と入力し保存します。</p>
<p><strong>C-t j</strong>でコンパイルした後、<strong>C-t p</strong>でプレビューができることを確認してください。</p>
<p>YaTexには様々な便利な機能がありますので<a href="http://www.nk.rim.or.jp/~naru/yatex/">「YaTeX World」の野鳥入門</a>を一通り試してみるとよいでしょう。</p>
<p>texファイルの変更後は<strong>C-t j</strong>でコンパイルし、プレビュー画面に移動することで自動更新してくれますが、バックグラウンドで再読み込みしたい場合は<a href="http://skim-app.sourceforge.net/">SKIM</a>がよさそうです。</p>
<p><a href="http://skim-app.sourceforge.net/">SKIMをダウンロード</a>して、インストール。「Preference」の「Sync」タブの「Check for file changes」にチェックを入れ、「PDF-TeX Sync support」の「Preset:」から「Emacs」を選択します。</p>
<p><strong>~/.emacs.el</strong>の<strong>dvi2-command &#8220;open -a TexShop&#8221;</strong>を<strong>dvi2-command &#8220;open -a Skim&#8221;</strong>に変更します。</p>
<p>これで<strong>C-t j</strong>するだけでバックグラウンドでPDFを更新してくれるようになります。</p>
<p>※追記</p>
<h3>OMakeをつかって自動コンパイル</h3>
<p>OMakeを使うことで、texファイルが更新される度に自動的にコンパイルさせることができます。</p>
<p>OMakeをインストール</p>
<pre class="brush: php">

sudo port install omake
</pre>
<p>texファイルを作成しているディレクトリに移動して、omake設定します。</p>
<pre class="brush: php">
omake --install
</pre>
<p>OMakefile と OMakerootが出来上がるので、OMakefileを次のように編集します。ここではbook1.texというファイル名の場合の設定です。</p>
<pre class="brush: php">
LATEX = platex
DVIPDFM = dvipdfmx
DVIPDFMFLAGS = -p a4

LaTeXDocument(book1, book1)

.DEFAULT: book1.pdf book1.dvi
</pre>
<p>ここまでできれば、</p>
<pre class="brush: php">
omake -P --verbose
</pre>
<p>を実行します。あとはEmacsなどで変更中のtexファイルを保存するだけで、自動的にコンパイルされます。上のSKIMを使っている場合は保存するだけで、PDFが更新されます。</p>
<h3>参考</h3>
<ul>
<li><a href="Beginning OS X: http://osx.miko.org/index.php/Beginning_OS_X_10.4/%E3%82%A2%E3%83%97%E3%83%AA%E5%B0%8E%E5%85%A5%E7%B7%A8">Beginning OS X: http://osx.miko.org/index.php/Beginning_OS_X_10.4/%E3%82%A2%E3%83%97%E3%83%AA%E5%B0%8E%E5%85%A5%E7%B7%A8</a></li>
<li><a href="http://d.hatena.ne.jp/hayamiz/20081208/1228727272">OMake つかって LaTeX コンパイルしたら簡単すぎて身長が5cm伸びた: http://d.hatena.ne.jp/hayamiz/20081208/1228727272</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/12/10/osx%e3%81%ablatex%e7%92%b0%e5%a2%83emacsyatexlatextexshop%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6pdf%e3%83%97%e3%83%ac%e3%83%93%e3%83%a5%e3%83%bc%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoogleAppEngineOil 0.1安定板 0.2アップデート</title>
		<link>http://www.churadesign.com/2008/09/27/googleappengineoil%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88/</link>
		<comments>http://www.churadesign.com/2008/09/27/googleappengineoil%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 01:58:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[GAE]]></category>
		<category><![CDATA[GAEO]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=78</guid>
		<description><![CDATA[ようやくベータが外れ、GoogleAppEngineOil(GAEO)のバージョン0.1の安定板リリースされています。
更に進行中の0.2には次のような機能が追加されています。
1. respond_toサポート
ルーティングルールに r.connect(&#8217;:controller/:action/:id.:format&#8217;)と書くことで、次のようにrespond_toメソッドを利用できます。

self.respond_to(
html=lambda: self.render(&#039;&#38;amp;amp;amp;amp;lt;h1&#38;amp;amp;amp;amp;gt;Hello World&#38;amp;amp;amp;amp;lt;/h1&#38;amp;amp;amp;amp;gt;&#039;),
js=lambda: self.render(script=&#039;alert(&#34;hello, world&#34;)&#039;)
)

http://www.example.com/foo/bar.htmlの場合は&#60;h1&#62;Hello World&#60;/h1&#62;の行をhttp://example.com/foo/bar.jsの場合はjavascriptの行を実行させることができます。
2. XHRリクエスト判別
GAEOはX-Requested-WithをつかってXMLHttpRequestオブジェクトによってリクエストされたか調べます。
self._is_xhrでTRUE/FALSEを判別できます。
3. renderメソッドにscriptタイプ追加
self.render(script=&#8221;alert(&#8217;!'&#8221;)のようにして、text/javascriptデータを送信できます。
4. RESTメソッド
self._request_methodを使用して&#8217;get&#8217;, &#8216;put&#8217;, &#8216;head&#8217;などのリクエストメソッドを判別できます。
Railsにできるだけ近づこうとしているのでしょうか。今後ともGAEO楽しみです。
]]></description>
			<content:encoded><![CDATA[<p>ようやくベータが外れ、GoogleAppEngineOil(GAEO)のバージョン0.1の安定板リリースされています。</p>
<p>更に進行中の0.2には次のような機能が追加されています。</p>
<h3>1. respond_toサポート</h3>
<p>ルーティングルールに r.connect(&#8217;:controller/:action/:id.:format&#8217;)と書くことで、次のようにrespond_toメソッドを利用できます。</p>
<pre class="brush: php">
self.respond_to(
html=lambda: self.render(&#039;&amp;amp;amp;amp;amp;lt;h1&amp;amp;amp;amp;amp;gt;Hello World&amp;amp;amp;amp;amp;lt;/h1&amp;amp;amp;amp;amp;gt;&#039;),
js=lambda: self.render(script=&#039;alert(&quot;hello, world&quot;)&#039;)
)
</pre>
<p>http://www.example.com/foo/bar.htmlの場合は&lt;h1&gt;Hello World&lt;/h1&gt;の行をhttp://example.com/foo/bar.jsの場合はjavascriptの行を実行させることができます。</p>
<h3>2. XHRリクエスト判別</h3>
<p>GAEOはX-Requested-WithをつかってXMLHttpRequestオブジェクトによってリクエストされたか調べます。</p>
<p>self._is_xhrでTRUE/FALSEを判別できます。</p>
<h3>3. renderメソッドにscriptタイプ追加</h3>
<p>self.render(script=&#8221;alert(&#8217;!'&#8221;)のようにして、text/javascriptデータを送信できます。</p>
<h3>4. RESTメソッド</h3>
<p>self._request_methodを使用して&#8217;get&#8217;, &#8216;put&#8217;, &#8216;head&#8217;などのリクエストメソッドを判別できます。</p>
<p>Railsにできるだけ近づこうとしているのでしょうか。今後ともGAEO楽しみです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/09/27/googleappengineoil%e3%82%a2%e3%83%83%e3%83%97%e3%83%87%e3%83%bc%e3%83%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google App Engineで予約管理アプリケーションを作ってみた</title>
		<link>http://www.churadesign.com/2008/09/15/google-app-engine%e3%81%a7%e4%ba%88%e7%b4%84%e7%ae%a1%e7%90%86%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f/</link>
		<comments>http://www.churadesign.com/2008/09/15/google-app-engine%e3%81%a7%e4%ba%88%e7%b4%84%e7%ae%a1%e7%90%86%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 04:54:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[GAE]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=69</guid>
		<description><![CDATA[GoogleAppEngine(GAE)とGoogleAppEngineOil(GAEO)がだいたいわかったところで、簡単な顧客&#38;予約管理アプリケーションを作ってみました。
RubyonRailsになれていると、ちょっとしたことに詰まったりしてしまいます。RoRとGAEOの対応表なんかがあればよいな。
リレーションモデルではないとされているGAEのデータストレージもGAEOのBaseModel.belongs_to()を使うことで、RoRっぽく簡単にリレーションを利用できました。
最後にjQueryをつかって使いやすいUIにしてみました。
GoogleAppEngineかなり使えます。
]]></description>
			<content:encoded><![CDATA[<p>GoogleAppEngine(GAE)とGoogleAppEngineOil(GAEO)がだいたいわかったところで、簡単な顧客&amp;予約管理アプリケーションを作ってみました。</p>
<p>RubyonRailsになれていると、ちょっとしたことに詰まったりしてしまいます。RoRとGAEOの対応表なんかがあればよいな。<br />
リレーションモデルではないとされているGAEのデータストレージもGAEOの<strong>BaseModel.belongs_to()</strong>を使うことで、RoRっぽく簡単にリレーションを利用できました。</p>
<p>最後にjQueryをつかって使いやすいUIにしてみました。</p>
<p>GoogleAppEngineかなり使えます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/09/15/google-app-engine%e3%81%a7%e4%ba%88%e7%b4%84%e7%ae%a1%e7%90%86%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google App Engine Oil入門1</title>
		<link>http://www.churadesign.com/2008/09/02/googleappengineoil%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab/</link>
		<comments>http://www.churadesign.com/2008/09/02/googleappengineoil%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 07:44:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[GAE]]></category>
		<category><![CDATA[GAEO]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=60</guid>
		<description><![CDATA[GoogleAppEngineを使い始めたらぜひGoogleAppEigineOilを導入してみましょう。
このオイルはGoogleAppEngineをより簡単に利用するためのMVCフレームワークを提供してくれるため、より少ない設定、コーディングでアプリケーションを作成できるようになります。
Google App Engine Oilのサイトにチュートリアル基本編が用意されているので、それに従ってすすめてみます。
Google App Engine Oilインストール
まずはGoogle App Engine Oilのサイトからgaeo-trunk-rxx.zipファイルをダウンロードし、適当なディレクトリに配置します。私は ~/sdk/gaeoに配置しました。
実行権限を付加します。

chmod +x ~/sdk/gaeo/bin/*

環境変数設定
~/.bashrcを開いて次のようにパスを設定します。

export GAEO_HOME=&#039;/home/ericsk/sdk/gaeo&#039;  # put your installation directory here.
export PATH=&#039;${GAEO_HOME}/bin:${PATH}&#039;

ターミナルを開いて変更を反映します。

source ~/.bashrc

gaeo.pyとタイプして、実行してみましょう。次のように表示されたら正常にインストールできています。エラーが発生した場合は、Pythonのバージョンが2.5以上か確認してみてください。

Usage: /home/ericsk/sdk/gaeo/bin/gaeo.py &#38;amp;amp;amp;amp;amp;amp;amp;amp;lt;project name&#38;amp;amp;amp;amp;amp;amp;amp;amp;gt;

ハローワールド
新しいアプリケーションを早速作成してみましょう。ワーキングディレクトリに移動し、gaeo.py helloとタイプします。

&#38;amp;amp;amp;amp;amp;amp;amp;amp;gt;gaeo.py hello

The &#38;amp;amp;amp;amp;amp;amp;amp;amp;quot;hello&#38;amp;amp;amp;amp;amp;amp;amp;amp;quot; project has been created.

これだけで基本的なアプリケーションが準備されています。
自動生成されたファイル
app.yaml, favicon.ico, main.py
app.yamlとmain.pyがApp Engineアプリケーションのメインファイルとなります。app.yamlとmain.pyを編集してアプリケーションの設定を変更することができます。 favicon.icoは〜のファイルです。ブラウザによって最初にfavicon.icoを取得しようとするので、エラーにログが残るのを防ぐために作成されています。
application/
アプリケーションコード(コントローラー、モデル、テンプレート)がこのディレクトリに配置されます。
assets/
app.yaml内で、画像、スタイルシート、Javascriptファイルのような静的なファイルをそれぞれ、assets/img、assets/css、and assets/js
ディレクトリに配置すると設定しています。foo.pngをassets/imgディレクトリに配置したら、http:///img/foo.pngでアクセスすることができます。スタイルシートやJavascriptファイルも同様です。
gaeo/
Google App Engine Oil(GAEO)のコアライブラリです。新しいGAEOがリリースされれば、このディレクトリを新しいものに置き換えるだけでアップデートすることができます。SVNをつかって常に最新版を利用することもできます。
最新のGAEOライブラリはhttp://google-app-engine-oil.googlecode.com/svn/trunk/gaeo にあります。
GoogleAppEngineLuncherでこのhelloアプリケーションを指定して実行します。
http://localhost:8080/ にアクセスし、正しく動作している事が確認できます。
初期画面に表示されているファイルは/application/template/welcome/index.htmlに置かれています。
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.churadesign.com/2008/08/31/osx%E3%81%A7googleappengine%E3%82%92%E3%81%AF%E3%81%98%E3%82%81%E3%82%8B/">GoogleAppEngineを使い始めたら</a>ぜひ<a href="http://code.google.com/p/google-app-engine-oil/">GoogleAppEigineOil</a>を導入してみましょう。</p>
<p>このオイルはGoogleAppEngineをより簡単に利用するためのMVCフレームワークを提供してくれるため、より少ない設定、コーディングでアプリケーションを作成できるようになります。</p>
<p>Google App Engine Oilのサイトに<a href="http://code.google.com/docreader/#p=google-app-engine-oil-doc&amp;s=google-app-engine-oil-doc&amp;t=GettingStartedBasics">チュートリアル基本編</a>が用意されているので、それに従ってすすめてみます。</p>
<h2>Google App Engine Oilインストール</h2>
<p>まずは<a href="http://code.google.com/p/google-app-engine-oil/">Google App Engine Oil</a>のサイトから<strong>gaeo-trunk-rxx.zip</strong>ファイルをダウンロードし、適当なディレクトリに配置します。私は <strong>~/sdk/gaeo</strong>に配置しました。</p>
<p>実行権限を付加します。</p>
<pre class="brush: php">
chmod +x ~/sdk/gaeo/bin/*
</pre>
<h3>環境変数設定</h3>
<p><strong>~/.bashrc</strong>を開いて次のようにパスを設定します。</p>
<pre class="brush: php">
export GAEO_HOME=&#039;/home/ericsk/sdk/gaeo&#039;  # put your installation directory here.
export PATH=&#039;${GAEO_HOME}/bin:${PATH}&#039;
</pre>
<p>ターミナルを開いて変更を反映します。</p>
<pre class="brush: php">
source ~/.bashrc
</pre>
<p><strong>gaeo.py</strong>とタイプして、実行してみましょう。次のように表示されたら正常にインストールできています。エラーが発生した場合は、Pythonのバージョンが2.5以上か確認してみてください。</p>
<pre class="brush: php">
Usage: /home/ericsk/sdk/gaeo/bin/gaeo.py &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;project name&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;
</pre>
<h2>ハローワールド</h2>
<p>新しいアプリケーションを早速作成してみましょう。ワーキングディレクトリに移動し、gaeo.py helloとタイプします。</p>
<pre class="brush: php">
&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;gaeo.py hello

The &amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;hello&amp;amp;amp;amp;amp;amp;amp;amp;amp;quot; project has been created.
</pre>
<p>これだけで基本的なアプリケーションが準備されています。</p>
<h3>自動生成されたファイル</h3>
<p>app.yaml, favicon.ico, main.py</p>
<p>app.yamlとmain.pyがApp Engineアプリケーションのメインファイルとなります。<strong>app.yaml</strong>と<strong>main.py</strong>を編集してアプリケーションの設定を変更することができます。 favicon.icoは〜のファイルです。ブラウザによって最初にfavicon.icoを取得しようとするので、エラーにログが残るのを防ぐために作成されています。</p>
<p>application/</p>
<p>アプリケーションコード(コントローラー、モデル、テンプレート)がこのディレクトリに配置されます。</p>
<p>assets/</p>
<p>app.yaml内で、画像、スタイルシート、Javascriptファイルのような静的なファイルをそれぞれ、assets/img、assets/css、and assets/js<br />
ディレクトリに配置すると設定しています。foo.pngをassets/imgディレクトリに配置したら、http:///img/foo.pngでアクセスすることができます。スタイルシートやJavascriptファイルも同様です。</p>
<p>gaeo/</p>
<p>Google App Engine Oil(GAEO)のコアライブラリです。新しいGAEOがリリースされれば、このディレクトリを新しいものに置き換えるだけでアップデートすることができます。SVNをつかって常に最新版を利用することもできます。<br />
最新のGAEOライブラリはhttp://google-app-engine-oil.googlecode.com/svn/trunk/gaeo にあります。</p>
<p>GoogleAppEngineLuncherでこのhelloアプリケーションを指定して実行します。</p>
<p>http://localhost:8080/ にアクセスし、正しく動作している事が確認できます。</p>
<p>初期画面に表示されているファイルは<strong>/application/template/welcome/index.html</strong>に置かれています。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/09/02/googleappengineoil%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSXでGoogle App Engineをはじめる</title>
		<link>http://www.churadesign.com/2008/08/31/osx%e3%81%a7googleappengine%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%82%8b/</link>
		<comments>http://www.churadesign.com/2008/08/31/osx%e3%81%a7googleappengine%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%82%8b/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 04:47:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[GAE]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/?p=55</guid>
		<description><![CDATA[GoogleAppEngineとはGoogle社拡張性に飛んだサーバーを利用してアプリケーションを配置することのできるサービスで、非常に簡単にwebアプリケーションを数百万規模のユーザーへ提供することができます。
現在はPythonを使ってアプリケーションを開発することができます。
早速OSXに開発環境を用意してみます。
開発環境
OSX LeopardであればPython2.5が標準でインストールされてます。
ターミナルを立ち上げ

python

と入力。

Python 2.5.1 (r251:54863, Mar  7 2008, 03:19:34)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type &#38;quot;help&#38;quot;, &#38;quot;copyright&#38;quot;, &#38;quot;credits&#38;quot; or &#38;quot;license&#38;quot; for more information.

と表示されればOK。GoogleAppEngineにはPython2.5以上が必要ですので、2.4以下であればpythonのウェブサイトから最新版をダウンロードしてインストールしてください。
GoogleAppEngineのインストール
http://code.google.com/intl/ja/appengine/downloads.html
GoogleAppEngineサイトからOSX版をダウンロードし、dmgを開いてGoogleAppEngineLuncherをApplicationsフォルダに移動します。GUIのランチャーを起動して簡単に、ローカルサーバーの起動、停止、appspotに配置できるようになっています。
本家のチュートリアルがわかりやすいので、これに従って進みましょう。
helloworldディレクトリは ~/appengine/helloworldとしました。
GoogleAppEngineLuncherの＋アイコンをクリックして、作成したディレクトリを指定します。RunボタンとStopボタンでローカルサーバーを起動してアプリケーションをテストすることができます。
ローカルでテストが終われば、Deployボタンを押すだけでアプリケーションをインターネット上に公開することができます。
公開されているAPIの中でしかプログラムを作成できませんが、ユーザー管理、データ管理、画像編集、メール送信など基本的なAPIは用意されており、これほど簡単にGoogleのサーバーインフラを利用できるのはとても魅力的です。
]]></description>
			<content:encoded><![CDATA[<p>GoogleAppEngineとはGoogle社拡張性に飛んだサーバーを利用してアプリケーションを配置することのできるサービスで、非常に簡単にwebアプリケーションを数百万規模のユーザーへ提供することができます。</p>
<p>現在はPythonを使ってアプリケーションを開発することができます。</p>
<p>早速OSXに開発環境を用意してみます。</p>
<h2>開発環境</h2>
<p>OSX LeopardであればPython2.5が標準でインストールされてます。</p>
<p>ターミナルを立ち上げ</p>
<pre class="brush: php">
python
</pre>
<p>と入力。</p>
<pre class="brush: php">
Python 2.5.1 (r251:54863, Mar  7 2008, 03:19:34)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
</pre>
<p>と表示されればOK。GoogleAppEngineにはPython2.5以上が必要ですので、2.4以下であればpythonのウェブサイトから<a href="http://www.python.jp/Zope/download/pythoncore">最新版をダウンロード</a>してインストールしてください。</p>
<h2>GoogleAppEngineのインストール</h2>
<p>http://code.google.com/intl/ja/appengine/downloads.html</p>
<p><a href="http://code.google.com/intl/ja/appengine/downloads.html">GoogleAppEngineサイト</a>からOSX版をダウンロードし、dmgを開いて<strong>GoogleAppEngineLuncher</strong>をApplicationsフォルダに移動します。GUIのランチャーを起動して簡単に、ローカルサーバーの起動、停止、appspotに配置できるようになっています。</p>
<p><a href="http://code.google.com/intl/ja/appengine/downloads.html">本家のチュートリアル</a>がわかりやすいので、これに従って進みましょう。</p>
<p>helloworldディレクトリは ~/appengine/helloworldとしました。</p>
<p>GoogleAppEngineLuncherの＋アイコンをクリックして、作成したディレクトリを指定します。RunボタンとStopボタンでローカルサーバーを起動してアプリケーションをテストすることができます。</p>
<p>ローカルでテストが終われば、Deployボタンを押すだけでアプリケーションをインターネット上に公開することができます。</p>
<p>公開されているAPIの中でしかプログラムを作成できませんが、ユーザー管理、データ管理、画像編集、メール送信など基本的なAPIは用意されており、これほど簡単にGoogleのサーバーインフラを利用できるのはとても魅力的です。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/08/31/osx%e3%81%a7googleappengine%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>あなたのコードに使うべき21のRubyトリック</title>
		<link>http://www.churadesign.com/2008/06/03/%e3%81%82%e3%81%aa%e3%81%9f%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e4%bd%bf%e3%81%86%e3%81%b9%e3%81%8d21%e3%81%aeruby%e3%83%88%e3%83%aa%e3%83%83%e3%82%af/</link>
		<comments>http://www.churadesign.com/2008/06/03/%e3%81%82%e3%81%aa%e3%81%9f%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e4%bd%bf%e3%81%86%e3%81%b9%e3%81%8d21%e3%81%aeruby%e3%83%88%e3%83%aa%e3%83%83%e3%82%af/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 23:17:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/2008/06/03/%e3%81%82%e3%81%aa%e3%81%9f%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e4%bd%bf%e3%81%86%e3%81%b9%e3%81%8d21%e3%81%aeruby%e3%83%88%e3%83%aa%e3%83%83%e3%82%af/</guid>
		<description><![CDATA[rubyinside.comに 21 Ruby Tricks You Should Be Using In Your Own Codeという記事が掲載されていました。
よりRubyコードをシンプルに読みやすくするために覚えておいて損はないですね。
勉強になりましたので抄訳しました。
1 &#8211; 正規表現にマッチした文字を抜き出す簡単な方法
文字列から正規表現にマッチした文字を抜き出す場合、通常はmatchもソッドを使いますが、次のようなショートカット方法もあります。

email = "Fred Bloggs &#60;fred@bloggs.com&#62;"email.match(/&#60;(.*?)&#62;/)[1]            # =&#62; “fred@bloggs.com”email[/&#60;(.*?)&#62;/, 1]                  # =&#62; “fred@bloggs.com”email.match(/(x)/)[1]   [...]]]></description>
			<content:encoded><![CDATA[<p>rubyinside.comに <a href="http://www.rubyinside.com/21-ruby-tricks-902.html">21 Ruby Tricks You Should Be Using In Your Own Code</a>という記事が掲載されていました。</p>
<p>よりRubyコードをシンプルに読みやすくするために覚えておいて損はないですね。</p>
<p>勉強になりましたので抄訳しました。</p>
<h2>1 &#8211; 正規表現にマッチした文字を抜き出す簡単な方法</h2>
<p>文字列から正規表現にマッチした文字を抜き出す場合、通常はmatchもソッドを使いますが、次のようなショートカット方法もあります。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">email</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Fred Bloggs &lt;fred@bloggs.com&gt;</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="ident" style="color: #000044;">email</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">match</span><span class="punct" style="color: #444477; font-weight: bold;">(/</span><span class="regex" style="color: #BB6666; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFEEFF; background-position: initial initial;">&lt;(.*?)&gt;</span><span class="punct" style="color: #444477; font-weight: bold;">/)[</span><span class="number" style="color: #FF9999;">1</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>            <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “fred@bloggs.com”</span><span class="ident" style="color: #000044;">email</span><span class="punct" style="color: #444477; font-weight: bold;">[/</span><span class="regex" style="color: #BB6666; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFEEFF; background-position: initial initial;">&lt;(.*?)&gt;</span><span class="punct" style="color: #444477; font-weight: bold;">/,</span> <span class="number" style="color: #FF9999;">1</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                  <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “fred@bloggs.com”</span><span class="ident" style="color: #000044;">email</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">match</span><span class="punct" style="color: #444477; font-weight: bold;">(/</span><span class="regex" style="color: #BB6666; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFEEFF; background-position: initial initial;">(x)</span><span class="punct" style="color: #444477; font-weight: bold;">/)[</span><span class="number" style="color: #FF9999;">1</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                <span class="comment" style="color: #000055; font-style: italic;"># =&gt; NoMethodError [:(]</span><span class="ident" style="color: #000044;">email</span><span class="punct" style="color: #444477; font-weight: bold;">[/</span><span class="regex" style="color: #BB6666; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFEEFF; background-position: initial initial;">(x)</span><span class="punct" style="color: #444477; font-weight: bold;">/,</span> <span class="number" style="color: #FF9999;">1</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                      <span class="comment" style="color: #000055; font-style: italic;"># =&gt; nil</span><span class="ident" style="color: #000044;">email</span><span class="punct" style="color: #444477; font-weight: bold;">[/</span><span class="regex" style="color: #BB6666; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFEEFF; background-position: initial initial;">([bcd]).*?([fgh])</span><span class="punct" style="color: #444477; font-weight: bold;">/,</span> <span class="number" style="color: #FF9999;">2</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>        <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “g”</span></span>
</pre>
<p></p>
<h2>2 &#8211; Array#joinのショートカット</h2>
<p>配列に数値を渡し、要素を複製するArray#*メソッドはよく知られていますが、Array#*に文字を渡すことで、文字列を結合させる方法はあまり知られていないようです。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">this is a test</span><span class="punct" style="color: #444477; font-weight: bold;">}</span> <span class="punct" style="color: #444477; font-weight: bold;">*</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">, </span><span class="punct" style="color: #444477; font-weight: bold;">"</span>                 <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “this, is, a, test”</span><span class="ident" style="color: #000044;">h</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="symbol" style="color: #009999;">:name</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Fred</span><span class="punct" style="color: #444477; font-weight: bold;">“,</span> <span class="symbol" style="color: #009999;">:age</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="number" style="color: #FF9999;">77</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="ident" style="color: #000044;">h</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">map</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">i</span><span class="punct" style="color: #444477; font-weight: bold;">|</span> <span class="ident" style="color: #000044;">i</span> <span class="punct" style="color: #444477; font-weight: bold;">*</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">=</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span> <span class="punct" style="color: #444477; font-weight: bold;">*</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;"><span class="escape" style="color: #227777;">\n</span></span><span class="punct" style="color: #444477; font-weight: bold;">"</span>              <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “age=77\nname=Fred”</span></span>
</pre>
<p></p>
<h2>3- 小数の簡単なフォーマット方法</h2>
<p>価格の表示に小数点のフォーマットをそろえるにはsprintfの代わりに次の方法を使うことができます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">oney</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="number" style="color: #FF9999;">9.5</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">%.2f</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="ident" style="color: #000044;">money</span>                       <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “9.50″</span></span>
</pre>
<p></p>
<h2>4 &#8211; テキストを囲む簡単な方法</h2>
<p>#3のフォーマットテクニックと同様に文字列を他の文字列の中に差し込むことができます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">[%s]</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">same old drag</span><span class="punct" style="color: #444477; font-weight: bold;">"</span>             <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “[same old drag]”</span></span>
</pre>
<p>配列をつかうこともできます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">p hello p</span><span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">&lt;%s&gt;%s&lt;/%s&gt;</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="ident" style="color: #000044;">x</span>                    <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “&lt;p&gt;hello&lt;/p&gt;"</span></span>
</pre>
<p></p>
<h2>5 &#8211; ファイルツリーを削除</h2>
<p>簡単にShellを使ってはいけません。Rubyは使いやすい<a href="http://www.noobkit.com/show/ruby/ruby/standard-library/fileutils.html">ファイルユーティリティライブラリ</a>を持っています。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">require</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">fileutils</span><span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="constant" style="color: #0077FF;">FileUtils</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">rm_r</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">somedir</span><span class="punct" style="color: #444477; font-weight: bold;">'</span></span>
</pre>
<p>このメソッドを使う時は十分ご注意を！</p>
<h2>6 &#8211; Enum要素を爆破</h2>
<p>*はArrayやHashのようなEnum要素を*爆破*することができます。なんの事をいっているかは次の例をみてください。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">a</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">a b</span><span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="ident" style="color: #000044;">b</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">c d</span><span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="ident" style="color: #000044;">a</span> <span class="punct" style="color: #444477; font-weight: bold;">+</span> <span class="ident" style="color: #000044;">b</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                              <span class="comment" style="color: #000055; font-style: italic;"># =&gt; [[”a”, “b”, “c”, “d”]]</span><span class="punct" style="color: #444477; font-weight: bold;">[*</span><span class="ident" style="color: #000044;">a</span> <span class="punct" style="color: #444477; font-weight: bold;">+</span> <span class="ident" style="color: #000044;">b</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                             <span class="comment" style="color: #000055; font-style: italic;"># =&gt; [”a”, “b”, “c”, “d”]</span></span>
</pre>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">a</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="symbol" style="color: #009999;">:name</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Fred</span><span class="punct" style="color: #444477; font-weight: bold;">“,</span> <span class="symbol" style="color: #009999;">:age</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="number" style="color: #FF9999;">93</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="ident" style="color: #000044;">a</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                                  <span class="comment" style="color: #000055; font-style: italic;"># =&gt; [{:name =&gt; “Fred”, :age =&gt;93}]</span><span class="punct" style="color: #444477; font-weight: bold;">[*</span><span class="ident" style="color: #000044;">a</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                                 <span class="comment" style="color: #000055; font-style: italic;"># =&gt; [[:name, “Fred”], [:age, 93]]</span></span>
</pre>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">a</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">a b c d e f g h</span><span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="ident" style="color: #000044;">b</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="number" style="color: #FF9999;">0</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="number" style="color: #FF9999;">5</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="number" style="color: #FF9999;">6</span><span class="punct" style="color: #444477; font-weight: bold;">]</span><span class="ident" style="color: #000044;">a</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">values_at</span><span class="punct" style="color: #444477; font-weight: bold;">(*</span><span class="ident" style="color: #000044;">b</span><span class="punct" style="color: #444477; font-weight: bold;">).</span><span class="ident" style="color: #000044;">inspect</span>              <span class="comment" style="color: #000055; font-style: italic;"># =&gt; [”a”, “f”, “g”]</span></span>
</pre>
<p></p>
<h2>7 &#8211; ローカル値の定義をやめる</h2>
<p>空のHashやArray でローカル値の定義する代わりに、次のように定義と同時に使うことができます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">z</span> <span class="punct" style="color: #444477; font-weight: bold;">||=</span> <span class="punct" style="color: #444477; font-weight: bold;">[])</span> <span class="punct" style="color: #444477; font-weight: bold;">&lt;&lt;</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">test</span><span class="punct" style="color: #444477; font-weight: bold;">'</span></span>
</pre>
<p></p>
<h2>8 &#8211; ハッシュキーに文字やシンボルじゃないものをつかう</h2>
<p>シンボルや文字列以外のものをハッシュキーに使っているのをみることはほとんどありませんが、つかうことができ、時に使いやすいでしょう（次の例はあまりよい例ではないですが）。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">does</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="ident" style="color: #000044;">is</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="constant" style="color: #0077FF;">true</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Yes</span><span class="punct" style="color: #444477; font-weight: bold;">',</span> <span class="constant" style="color: #0077FF;">false</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">No</span><span class="punct" style="color: #444477; font-weight: bold;">'</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="ident" style="color: #000044;">does</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="number" style="color: #FF9999;">10</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">50</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                       <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “No”</span><span class="ident" style="color: #000044;">is</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="number" style="color: #FF9999;">10</span> <span class="punct" style="color: #444477; font-weight: bold;">&gt;</span> <span class="number" style="color: #FF9999;">5</span><span class="punct" style="color: #444477; font-weight: bold;">]</span>                           <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “Yes”</span></span>
</pre>
<p></p>
<h2>9 &#8211; &#8216;and&#8217; と&#8217;or&#8217;を使って一行に処理をまとめる</h2>
<p>より自信のあるRuby開発者がコードを短くして、ifやunlessなど短い複数行を省くためのトリックです。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">queue</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">[]</span><span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">hello x world</span><span class="punct" style="color: #444477; font-weight: bold;">}.</span><span class="ident" style="color: #000044;">each</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">do</span> <span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">word</span><span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">queue</span> <span class="punct" style="color: #444477; font-weight: bold;">&lt;&lt;</span> <span class="ident" style="color: #000044;">word</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">and</span> <span class="ident" style="color: #000044;">puts</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Added to queue</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">unless</span> <span class="ident" style="color: #000044;">word</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">length</span> <span class="punct" style="color: #444477; font-weight: bold;">&lt; </span> <span class="number" style="color: #FF9999;">2</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span><span class="ident" style="color: #000044;">puts</span> <span class="ident" style="color: #000044;">queue</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">inspect</span><span class="comment" style="color: #000055; font-style: italic;"># Output:</span><span class="comment" style="color: #000055; font-style: italic;">#   Added to queue</span><span class="comment" style="color: #000055; font-style: italic;">#   Added to queue</span><span class="comment" style="color: #000055; font-style: italic;">#   [”hello”, “world”]</span></span>
</pre>
<p></p>
<h2>10 &#8211; requireされた時ではなく直接実行されていた場合に何かを行う</h2>
<p>このパターンは上級Ruby開発者にはよく使われています。ライブラリとしてや、コマンドラインからディレクトリの下から呼ばれているのではなく、直接rubyコードが呼ばれている場合のみ処理を行います。</p>
<pre style="background-color: #F1F1F3; color: rgb(17, 17, 34); padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">if</span> <span class="constant" style="color: #0077FF;">__FILE__</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="global" style="color: #77FFBB;">$0</span>
  <span class="comment" style="color: #000055; font-style: italic;"># Do something.. run tests, call a method, etc. We're direct.</span>
<span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<h2>11 &#8211; 複数データの簡単割り当て</h2>
<p>複数データの割当はRuby開発者が早期に学ぶことですが、簡単な割にほとんど使われていないのには驚きです。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">a</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">b</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">c</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">d</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="number" style="color: #FF9999;">1</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="number" style="color: #FF9999;">2</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="number" style="color: #FF9999;">3</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="number" style="color: #FF9999;">4</span></span>
</pre>
<p>要素数の指定がないメソッドの引数として配列を*でバンドルするのは特に役立ちます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">my_method</span><span class="punct" style="color: #444477; font-weight: bold;">(*</span><span class="ident" style="color: #000044;">args</span><span class="punct" style="color: #444477; font-weight: bold;">)</span><span class="ident" style="color: #000044;">a</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">b</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">c</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">d</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="ident" style="color: #000044;">args</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p>つぎのような賢い使い方も</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">initialize</span><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">args</span><span class="punct" style="color: #444477; font-weight: bold;">)</span><span class="ident" style="color: #000044;">args</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">keys</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">each</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">name</span><span class="punct" style="color: #444477; font-weight: bold;">|</span> <span class="ident" style="color: #000044;">instance_variable_set</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">@</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">+</span> <span class="ident" style="color: #000044;">name</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">to_s</span><span class="punct" style="color: #444477; font-weight: bold;">,</span> <span class="ident" style="color: #000044;">args</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="ident" style="color: #000044;">name</span><span class="punct" style="color: #444477; font-weight: bold;">]</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p></p>
<h2>12 &#8211; 数値の比較に複数の比較ではなくrangeインスタンスを使う</h2>
<p>もう<span style="font-style: italic;">i</span><span style="font-style: italic;">f x &gt; 1000 &amp;&amp; x &lt; 2000</span> を使わないで次のコードをつかいましょう。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">year</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="number" style="color: #FF9999;">1972</span><span class="ident" style="color: #000044;">puts</span>  <span class="keyword" style="color: #AA0000; font-weight: bold;">case</span> <span class="ident" style="color: #000044;">year</span><span class="keyword" style="color: #AA0000; font-weight: bold;">when</span> <span class="number" style="color: #FF9999;">1970</span><span class="punct" style="color: #444477; font-weight: bold;">..</span><span class="number" style="color: #FF9999;">1979</span><span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Seventies</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="keyword" style="color: #AA0000; font-weight: bold;">when</span> <span class="number" style="color: #FF9999;">1980</span><span class="punct" style="color: #444477; font-weight: bold;">..</span><span class="number" style="color: #FF9999;">1989</span><span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Eighties</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="keyword" style="color: #AA0000; font-weight: bold;">when</span> <span class="number" style="color: #FF9999;">1990</span><span class="punct" style="color: #444477; font-weight: bold;">..</span><span class="number" style="color: #FF9999;">1999</span><span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">Nineties</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p></p>
<h2>13 &#8211; 配列をつかって重複したコードをカット</h2>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="punct" style="color: #444477; font-weight: bold;">%w{</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">rubygems daemons eventmachine</span><span class="punct" style="color: #444477; font-weight: bold;">}.</span><span class="ident" style="color: #000044;">each</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">x</span><span class="punct" style="color: #444477; font-weight: bold;">|</span> <span class="ident" style="color: #000044;">require</span> <span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span></span>
</pre>
<p></p>
<h2>14 &#8211; 比較演算子</h2>
<p>比較演算子もまた、Ruby開発者が早期に学ぶトリックですが、ほとんどみることがありません。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">puts</span> <span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">10</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">x is ten</span><span class="punct" style="color: #444477; font-weight: bold;">"</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">x is not ten</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="comment" style="color: #000055; font-style: italic;"># Or.. an assignment based on the results of a ternary operation:</span><span class="constant" style="color: #0077FF;">LOG</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">sev_threshold</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="constant" style="color: #0077FF;">ENVIRONMENT</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="symbol" style="color: #009999;">:development</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="constant" style="color: #0077FF;">Logger</span><span class="punct" style="color: #444477; font-weight: bold;">::</span><span class="constant" style="color: #0077FF;">DEBUG</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="constant" style="color: #0077FF;">Logger</span><span class="punct" style="color: #444477; font-weight: bold;">::</span><span class="constant" style="color: #0077FF;">INFO</span></span>
</pre>
<p></p>
<h2>15 &#8211; ネストされた比較演算子</h2>
<p>トラブルを引き起こすでしょうが、比較演算子はネストすることができます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">qty</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="number" style="color: #FF9999;">1</span><span class="ident" style="color: #000044;">qty</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">0</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">none</span><span class="punct" style="color: #444477; font-weight: bold;">'</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="ident" style="color: #000044;">qty</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">1</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">one</span><span class="punct" style="color: #444477; font-weight: bold;">'</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">many</span><span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="comment" style="color: #000055; font-style: italic;"># Just to illustrate, in case of confusion:</span><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">qty</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">0</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">none</span><span class="punct" style="color: #444477; font-weight: bold;">'</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">qty</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">1</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">one</span><span class="punct" style="color: #444477; font-weight: bold;">'</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="punct" style="color: #444477; font-weight: bold;">'</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">many</span><span class="punct" style="color: #444477; font-weight: bold;">'))</span></span>
</pre>
<p></p>
<h2>16 &#8211; Rubyの論理式を簡素に</h2>
<p>よくつぎのようなメソッドパターンをみますが、</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">is_odd</span><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">x</span><span class="punct" style="color: #444477; font-weight: bold;">)</span><span class="comment" style="color: #000055; font-style: italic;"># Wayyyy too long..</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  if</span> <span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="number" style="color: #FF9999;">2</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">0</span><span class="keyword" style="color: #AA0000; font-weight: bold;">    return</span> <span class="constant" style="color: #0077FF;">false</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  else</span><span class="keyword" style="color: #AA0000; font-weight: bold;">    return</span> <span class="constant" style="color: #0077FF;">true</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  end</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p>おそらく次のように比較演算子を使って、よい短くできるのでは？</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">is_odd</span><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">x</span><span class="punct" style="color: #444477; font-weight: bold;">)</span><span class="comment" style="color: #000055; font-style: italic;"># Don't EVER put false and true in a ternary operator!!</span><span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="number" style="color: #FF9999;">2</span> <span class="punct" style="color: #444477; font-weight: bold;">==</span> <span class="number" style="color: #FF9999;">0</span> <span class="punct" style="color: #444477; font-weight: bold;">?</span> <span class="constant" style="color: #0077FF;">false</span> <span class="punct" style="color: #444477; font-weight: bold;">:</span> <span class="constant" style="color: #0077FF;">true</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p>確かに。このパターンはよく見ますが、もう一歩すすめてください。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">is_odd</span><span class="punct" style="color: #444477; font-weight: bold;">(</span><span class="ident" style="color: #000044;">x</span><span class="punct" style="color: #444477; font-weight: bold;">)</span><span class="comment" style="color: #000055; font-style: italic;"># Use the logical results provided to you by Ruby already..</span><span class="ident" style="color: #000044;">x</span> <span class="punct" style="color: #444477; font-weight: bold;">%</span> <span class="number" style="color: #FF9999;">2</span> <span class="punct" style="color: #444477; font-weight: bold;">!=</span> <span class="number" style="color: #FF9999;">0</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p></p>
<h2>17　-　例外のバックトレースのすべてをみる</h2>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">do_division_by_zero</span><span class="punct" style="color: #444477; font-weight: bold;">;</span> <span class="number" style="color: #FF9999;">5</span> <span class="punct" style="color: #444477; font-weight: bold;">/</span> <span class="number" style="color: #FF9999;">0</span><span class="punct" style="color: #444477; font-weight: bold;">;</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">end</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  begin</span><span class="ident" style="color: #000044;">    do_division_by_zero</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  rescue</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="ident" style="color: #000044;">exception</span><span class="ident" style="color: #000044;">    puts</span> <span class="ident" style="color: #000044;">exception</span><span class="punct" style="color: #444477; font-weight: bold;">.</span><span class="ident" style="color: #000044;">backtrace</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p></p>
<h2>18 &#8211; 配列とシングルオブジェクト両方で繰り返し処理</h2>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="comment" style="color: #000055; font-style: italic;"># [*items] はシングルオブジェクトを配列に置き換えます。</span><span class="punct" style="color: #444477; font-weight: bold;">[*</span><span class="ident" style="color: #000044;">items</span><span class="punct" style="color: #444477; font-weight: bold;">].</span><span class="ident" style="color: #000044;">each</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">do</span> <span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="ident" style="color: #000044;">item</span><span class="punct" style="color: #444477; font-weight: bold;">|</span><span class="comment" style="color: #000055; font-style: italic;"># …</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<p></p>
<h2>19 &#8211; Rescueブロックはbeginでくくる必要はない</h2>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">x</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  begin</span><span class="comment" style="color: #000055; font-style: italic;">    # …</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  rescue</span><span class="comment" style="color: #000055; font-style: italic;">    # …</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  end</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span></span>
</pre>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span class="keyword" style="color: #AA0000; font-weight: bold;">def </span><span class="method" style="color: #007777;">x</span><span class="comment" style="color: #000055; font-style: italic;">  # …</span><span class="keyword" style="color: #AA0000; font-weight: bold;">  rescue</span><span class="comment" style="color: #000055; font-style: italic;">    # …</span><span class="keyword" style="color: #AA0000; font-weight: bold;">end</span>
</pre>
<p></p>
<h2>20 &#8211; ブロックコメント</h2>
<p>これは古いRuby学校のコードでよくみますが、あまりつかわれていないようです。ポンドマークのついた巨大な行よりも見やすいのでは？</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">puts</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">x</span><span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="comment" style="color: #000055; font-style: italic;">=beginthis is a block commentYou can put anything you like here!puts “y”=end</span><span class="ident" style="color: #000044;">puts</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">z</span><span class="punct" style="color: #444477; font-weight: bold;">"</span></span>
</pre>
<p></p>
<h2>21 &#8211; rescueの救出</h2>
<p>一行でrescueを使う事で例外が発生した場合に値を返すことができます。</p>
<pre style="background-color: #F1F1F3; color: #111122; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 13px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; width: 97%; overflow-x: auto; overflow-y: hidden; margin-top: 12px;">
<span style="color: #333333; font-family: 'Lucida Grande'; font-size: 13px; line-height: 21px;"><span class="ident" style="color: #000044;">h</span> <span class="punct" style="color: #444477; font-weight: bold;">=</span> <span class="punct" style="color: #444477; font-weight: bold;">{</span> <span class="symbol" style="color: #009999;">:age</span> <span class="punct" style="color: #444477; font-weight: bold;">=&gt;</span> <span class="number" style="color: #FF9999;">10</span> <span class="punct" style="color: #444477; font-weight: bold;">}</span><span class="ident" style="color: #000044;">h</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="symbol" style="color: #009999;">:name</span><span class="punct" style="color: #444477; font-weight: bold;">].</span><span class="ident" style="color: #000044;">downcase</span>                         <span class="comment" style="color: #000055; font-style: italic;"># ERROR</span><span class="ident" style="color: #000044;">h</span><span class="punct" style="color: #444477; font-weight: bold;">[</span><span class="symbol" style="color: #009999;">:name</span><span class="punct" style="color: #444477; font-weight: bold;">].</span><span class="ident" style="color: #000044;">downcase</span> <span class="keyword" style="color: #AA0000; font-weight: bold;">rescue</span> <span class="punct" style="color: #444477; font-weight: bold;">"</span><span class="string" style="color: #994444; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #FFFFEE; background-position: initial initial;">No name</span><span class="punct" style="color: #444477; font-weight: bold;">"</span>        <span class="comment" style="color: #000055; font-style: italic;"># =&gt; “No name”</span></span>
</pre>
<p><a href="http://www.rubyinside.com/21-ruby-tricks-902.html">原文</a>のコメント欄にも他のTipsや意見等が投稿されていました。</p>
<h2>おまけ1 &#8211; 6と11を組み合わせるとこんな風にかけます。特にArray#splitと一緒に使うと特に便利です。</h2>
<p style="font-weight: normal; line-height: 1.5em; text-transform: none; margin-top: 10px; margin-right: 5px; margin-bottom: 10px; margin-left: 0px;"><span style="color: #333333; font-family: 'Lucida Grande'; font-weight: bold;">&gt; a, b, *c = 1, 2, 3, 4, 5, 6<br />
a =&gt; 1<br />
b =&gt; 2<br />
c =&gt; [3, 4, 5, 6]</span></p>
<h2>おまけ2 &#8211; 最初から12個のフォボナッチ数を求める</h2>
<p style="font-weight: normal; line-height: 1.5em; text-transform: none; margin-top: 10px; margin-right: 5px; margin-bottom: 10px; margin-left: 0px;"><span style="color: #333333; font-family: 'Lucida Grande'; font-weight: bold;"><span style="line-height: 17px;">10.times { (fib ||= [1, 1]) &lt;&lt; fib[-1] + fib[-2] }</span><br /></span></p>
<p>他にもRubyコードのTipsがあれば知りたいです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/06/03/%e3%81%82%e3%81%aa%e3%81%9f%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e4%bd%bf%e3%81%86%e3%81%b9%e3%81%8d21%e3%81%aeruby%e3%83%88%e3%83%aa%e3%83%83%e3%82%af/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduinoコンテスト2008</title>
		<link>http://www.churadesign.com/2008/06/02/arduino%e3%82%b3%e3%83%b3%e3%83%86%e3%82%b9%e3%83%882008/</link>
		<comments>http://www.churadesign.com/2008/06/02/arduino%e3%82%b3%e3%83%b3%e3%83%86%e3%82%b9%e3%83%882008/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 04:17:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article (記事)]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.churadesign.com/2008/06/02/arduino%e3%82%b3%e3%83%b3%e3%83%86%e3%82%b9%e3%83%882008/</guid>
		<description><![CDATA[Arduinoをつかった各種ハードウェアのコンテスト結果優勝者の映像が公開されています。
Arduinoを使ったドアのロックシステムやGPSと連動した方向指示機、ロボットなどおもしろいソリューションが公開されています。
]]></description>
			<content:encoded><![CDATA[<p>Arduinoをつかった各種ハードウェアのコンテスト結果優勝者の<a href="http://www.libelium.com/tienda/catalog/contest.php">映像が公開</a>されています。</p>
<p>Arduinoを使ったドアのロックシステムやGPSと連動した方向指示機、ロボットなどおもしろいソリューションが公開されています。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.churadesign.com/2008/06/02/arduino%e3%82%b3%e3%83%b3%e3%83%86%e3%82%b9%e3%83%882008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
