<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>梨木を読む</title>
	<atom:link href="http://cyberwave.jp/nashiki/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyberwave.jp/nashiki</link>
	<description>～ ポジティブ・ライフハッカーな、梨木繁幸の脳ミソ ～</description>
	<lastBuildDate>Wed, 11 Apr 2012 02:00:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/feed/" />
		<item>
		<title>Jenkins + PhantomJS + QUnit でJavaScriptをCIする</title>
		<link>http://cyberwave.jp/nashiki/2012/04/jenkins-phantomjs-qunit-%e3%81%a7javascript%e3%82%92ci%e3%81%99%e3%82%8b/</link>
		<comments>http://cyberwave.jp/nashiki/2012/04/jenkins-phantomjs-qunit-%e3%81%a7javascript%e3%82%92ci%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 01:43:30 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Jenkins]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=549</guid>
		<description><![CDATA[

最近とあるプロジェクトで、JavaScriptを使い、お客さん先のホームページを読込、その内容に応じて広告をJavaScript内で生成する『レコメンドエンジン』の配信サービスを提供している。
その中で、JavaSc [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cyberwave.jp/nashiki/wp-content/uploads/2012/04/Jenkins_PhantomJS_QUnit.png"><img src="http://cyberwave.jp/nashiki/wp-content/uploads/2012/04/Jenkins_PhantomJS_QUnit.png" alt="Jenkins PhantomJS QUnit" title="Jenkins_PhantomJS_QUnit" width="588" height="129" class="alignnone size-full wp-image-580" /></a></p>

<p>最近とあるプロジェクトで、JavaScriptを使い、お客さん先のホームページを読込、その内容に応じて広告をJavaScript内で生成する『レコメンドエンジン』の配信サービスを提供している。
その中で、JavaScriptが複雑化してきたので、JSのxUnitの書き方と、CIサーバJenkinsに載せるようにしました。</p>

<h2>JavaScriptの単体テスト</h2>

<p>QUnitとJasmineを調べたが、ピュアなxUnitが好きなので、今回QUnitを選択した。QUnitのテスト表記は下記のようにシンプルなequal関数でサクサクかけました。<br />
書きながらソースコードのリファクタリングも進みました。やはりテストコード書くとコードの悪い所が顕著に見えるのが心地いいです。</p>

<p>１，QUnit<br />
　元々は、jQueryのテストフレームワークとしてスタートした。現在はjQueryに依存していない<br />
　公式サイト：<a href="http://docs.jquery.com/QUnit">http://docs.jquery.com/QUnit</a></p>

<p>　◯テスト表記</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">	test<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a basic test example&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	  ok<span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;this test is fine&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #003366; font-weight: bold;">var</span> value <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;hello&quot;</span><span style="color: #339933;">;</span>
	  equal<span style="color: #009900;">&#40;</span> value<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;hello&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;We expect value to be hello&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>２，Jasmine<br />
　BDD for JavaScriptのテストフレームワーク<br />
　公式サイト：<a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a></p>

<p>　◯テスト表記</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">	describe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Jasmine&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		it<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;makes testing JavaScript awesome!&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			expect<span style="color: #009900;">&#40;</span>yourCode<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toBeLotsBetter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h2>QUnitをCUIで実行する</h2>

<p>通常QUnitのテスト実行は、ブラウザを使って試験実行と試験確認を行います。JenkinsにてCIを回す事を考えると、CUIベースで試験が実行される仕組みが必要です。</p>

<p>そこで、headless Webkitの『PhantomJS』を使います。headlessとは、頭の無いということですが、Webkitでの表示機能を内部に持っているけど、実際の表示は一切しないというブラウザです。</p>

<p>&lt;</p>

<p>blockquote>
実際どんな事出来るのですが、PhantomJSのソース内のexamplesを見てみて下さい。<br />
公式サイト：<a href="http://www.phantomjs.org">http://www.phantomjs.org</a><br />
公式サンプル：&lt;a href=&#8221;https://github.com/ariya/phantomjs/tree/master/examples>https://github.com/ariya/phantomjs/tree/master/examples</a><br />
</blockquote></p>

<h2>PhantomJSのインストール</h2>

<p>下記ページを参考に、バイナリでCentOS5.5へインストールしたらエラーが出てうまく入りませんでした。<br />
<a href="http://code.google.com/p/phantomjs/wiki/Installation">http://code.google.com/p/phantomjs/wiki/Installation</a></p>

<p>ソースからコンパイルしてインストールしました。</p>

<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># atrpmsリポジトリの追加</span>
<span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>yum.repos.d<span style="color: #000000; font-weight: bold;">/</span>atrpms.repo
<span style="color: #7a0874; font-weight: bold;">&#91;</span>atrpms<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">name</span>=ATrpms manual
<span style="color: #007800;">baseurl</span>=http:<span style="color: #000000; font-weight: bold;">//</span>dl.atrpms.net<span style="color: #000000; font-weight: bold;">/</span>el5-<span style="color: #007800;">$basearch</span><span style="color: #000000; font-weight: bold;">/</span>atrpms<span style="color: #000000; font-weight: bold;">/</span>testing<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #007800;">gpgkey</span>=http:<span style="color: #000000; font-weight: bold;">//</span>ATrpms.net<span style="color: #000000; font-weight: bold;">/</span>RPM-GPG-KEY.atrpms
<span style="color: #007800;">gpgcheck</span>=<span style="color: #000000;">1</span>
&nbsp;
rpm <span style="color: #660033;">--import</span> http:<span style="color: #000000; font-weight: bold;">//</span>packages.atrpms.net<span style="color: #000000; font-weight: bold;">/</span>RPM-GPG-KEY.atrpms
yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> qt47-webkit qt47-webkit-devel qt47-devel sqlite
&nbsp;
<span style="color: #666666; font-style: italic;"># ソースからコンパイル</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">su</span> -
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>phantomjs.googlecode.com<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>phantomjs-1.5.0-source.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxfv phantomjs-1.5.0-source.tar.gz
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> phantomjs-1.5.0-source.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> phantomjs-1.5.0<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #666666; font-style: italic;"># 下記ビルドコマンドはデフォルトで4つのコンパイラが同時起動する</span>
<span style="color: #666666; font-style: italic;"># さくらVPS512だとSwapが発生したので下記オプション付きで実行</span>
<span style="color: #666666; font-style: italic;"># ./build.sh --jobs 1</span>
.<span style="color: #000000; font-weight: bold;">/</span>build.sh
&nbsp;
<span style="color: #666666; font-style: italic;"># インストール用のパッケージ作成</span>
<span style="color: #666666; font-style: italic;"># make distclean</span>
<span style="color: #666666; font-style: italic;"># yum -y install chrpath</span>
.<span style="color: #000000; font-weight: bold;">/</span>deploy<span style="color: #000000; font-weight: bold;">/</span>package-linux-dynamic.sh 
&nbsp;
<span style="color: #666666; font-style: italic;"># インストール</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxfv .<span style="color: #000000; font-weight: bold;">/</span>phantomjs-1.5.0<span style="color: #000000; font-weight: bold;">/</span>phantomjs.tar.gz 
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-f</span> .<span style="color: #000000; font-weight: bold;">/</span>phantomjs<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>phantomjs <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-f</span> .<span style="color: #000000; font-weight: bold;">/</span>phantomjs<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libQt<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib
&nbsp;
<span style="color: #666666; font-style: italic;"># 掃除</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-fr</span> .<span style="color: #000000; font-weight: bold;">/</span>phantomjs
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-fr</span> .<span style="color: #000000; font-weight: bold;">/</span>phantomjs-1.5.0</pre></td></tr></table></div>
</p>

<p>下記コマンドでVerが確認出来れば無事にインストール終了</p>

<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">phantomjs <span style="color: #660033;">-v</span>
1.5.0</pre></td></tr></table></div>
</p>

<h2>PhantomJS 内で QUnit を実行</h2>

<p>PhantomJSのexamplesの中にある「<a href="https://github.com/ariya/phantomjs/blob/master/examples/run-qunit.js">run-qunit.js</a>」を使うとCUIでQUnitを実行できます。</p>

<p>下記コマンドqunitのテストコードが実行できる。引数に相対パスでQUnitのテストコードを指定すると、テスト結果を標準出力と終了コードに返します。</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">phantomjs .<span style="color: #000000; font-weight: bold;">/</span>phantomjs-1.5.0<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>run-qunit.js .<span style="color: #000000; font-weight: bold;">/</span>qunit<span style="color: #000000; font-weight: bold;">/</span>test<span style="color: #000000; font-weight: bold;">/</span>index.html 
<span style="color: #ff0000;">'waitFor()'</span> finished <span style="color: #000000; font-weight: bold;">in</span> 1952ms.
Tests completed <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">1780</span> milliseconds.
<span style="color: #000000;">586</span> tests of <span style="color: #000000;">586</span> passed, <span style="color: #000000;">0</span> failed.</pre></td></tr></table></div>


<p>これで、Jenkinsに組み込むための準備ができました！</p>

<p>参照：<a href="http://code.google.com/p/phantomjs/wiki/TestFrameworkIntegration">http://code.google.com/p/phantomjs/wiki/TestFrameworkIntegration</a></p>

<h2>Jenkinsに組み込む</h2>

<p>Jenkinsへはプロジェクトの「設定」の「ビルド」にシェルの実行を加え下記コマンドを追加します。</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># 下記パスは適当に書き換えて下さい</span>
phantomjs .<span style="color: #000000; font-weight: bold;">/</span>public<span style="color: #000000; font-weight: bold;">/</span>javascripts<span style="color: #000000; font-weight: bold;">/</span>run-qunit.js .<span style="color: #000000; font-weight: bold;">/</span>public<span style="color: #000000; font-weight: bold;">/</span>test<span style="color: #000000; font-weight: bold;">/</span>test_common_service.html</pre></td></tr></table></div>


<p>メニューから「ビルド実行」を実行して無事にQUnitが動作しているか確認して下さい。</p>

<p>これで無事にJSをCI出来ます！</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2012/04/jenkins-phantomjs-qunit-%e3%81%a7javascript%e3%82%92ci%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2012/04/jenkins-phantomjs-qunit-%e3%81%a7javascript%e3%82%92ci%e3%81%99%e3%82%8b/" />
	</item>
		<item>
		<title>手元のテキストメモを手軽に公開するために　PHP Markdown Extraプラグイン</title>
		<link>http://cyberwave.jp/nashiki/2012/03/php-markdown-extra/</link>
		<comments>http://cyberwave.jp/nashiki/2012/03/php-markdown-extra/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 22:07:19 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[生活をハック]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=530</guid>
		<description><![CDATA[ここ数年メモはTextTreeでメモして、DropBoxで共有しています。
メモをまとめて、手軽に整形して、WordPressへ公開できないものかと考えていました。
テキストのメモからHTMLを作るのは一苦労なので、Wi [...]]]></description>
			<content:encoded><![CDATA[<p>ここ数年メモはTextTreeでメモして、DropBoxで共有しています。<br />
メモをまとめて、手軽に整形して、WordPressへ公開できないものかと考えていました。<br />
テキストのメモからHTMLを作るのは一苦労なので、Wikiで使われいてMarkDownをWordPressで使えるようにしました。</p>

<h2>PHP Markdown</h2>

<p><a href="http://michelf.com/projects/php-markdown/">http://michelf.com/projects/php-markdown/</a></p>

<h2>インストール手順</h2>

<h3>プラグインの配置</h3>

<p>下記手順はサンプルです。実際のホスト名やパスに修正をして下さい。</p>

<pre><code>ssh -lcyberwave cyberwave.sakura.ne.jp
cd ~/www/wordpress/wp-content/plugins
wget http://michelf.com/docs/projets/php-markdown-extra-1.2.5.zip
unzip php-markdown*.zip
rm php-markdown*.zip
</code></pre>

<h3>WordPressでプラグイン有効化</h3>

<ol>
<li>WordPress管理画面のメニューの「プラグイン」の「インストール済み」をクリック  </li>
<li>その中から「Markdown Extra」を探して「使用する」をクリック  </li>
<li>画面上部に「プラグインを使用開始しました。」が表示されることを確認  </li>
</ol>

<h3>ビジュアルエディタを無効化</h3>

<ol>
<li>WordPress管理画面のメニューの「ユーザー」の「あなたのプロフィール」をクリック  </li>
<li>「ビジュアルリッチエディターを使用しない」のチェックボックスをONにする  </li>
<li>「プロフィール更新」をクリック  </li>
</ol>

<h3>コメント欄でのMarkDown記法</h3>

<p>markdown.phpの4行目を下記のように変更するとコメント欄はMarkDown記法は無効になる<br />
vi PHP\ Markdown\ Extra\ 1.2.5/markdown.php</p>

<pre><code>-@define( 'MARKDOWN_WP_COMMENTS',   true );
+@define( 'MARKDOWN_WP_COMMENTS',   false );
</code></pre>

<h2>参照</h2>

<ul>
<li>WP: PHP Markdown 記法早見表（的なもの）<br />
<a href="http://bono.s206.xrea.com/2007/01/312-markdown_syntax/">http://bono.s206.xrea.com/2007/01/312-markdown_syntax/</a>  </li>
<li>WP plugin[up]: 簡易記法で記事を書く – PHP Markdown Extra をアップグレード<br />
<a href="http://bono.s206.xrea.com/2007/01/311-php_markdown111/">http://bono.s206.xrea.com/2007/01/311-php_markdown111/</a>  </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2012/03/php-markdown-extra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2012/03/php-markdown-extra/" />
	</item>
		<item>
		<title>Storage Cache Plugin for jQuery</title>
		<link>http://cyberwave.jp/nashiki/2011/12/storagecache/</link>
		<comments>http://cyberwave.jp/nashiki/2011/12/storagecache/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 03:37:44 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=512</guid>
		<description><![CDATA[

回線の細いスマフォサイトでは、極力サーバとのコネクション数を減らし、速やかにページを表示させたいものです。
そこで、HTML5でのローカルストレージを使った、画像キャッシュを行う jQuery Pluginを作りまし [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/12/logo_jquery_215x53.gif" alt="jQuery" title="logo_jquery_215x53" width="215" height="53" class="alignright size-full wp-image-518" style="background-color: #000000; padding-top: 20px; padding-right: 50px; padding-bottom: 20px; padding-left: 50px; margin-bottom: 10px; margin-left: 30px;" /></p>

<p>回線の細いスマフォサイトでは、極力サーバとのコネクション数を減らし、速やかにページを表示させたいものです。
そこで、HTML5でのローカルストレージを使った、画像キャッシュを行う jQuery Pluginを作りました。</p>

<p>サーバ側でキャッシュ有効期限を設定しても、画像１つづつにコネクションを張りトータルの接続時間がかかります。スマフォサイトだと、manifest書けばという話もあるが、これはこれで強力すぎるキャッシュ機構でもあり、サーバ側で反映した変更が即時サイトに反映されないと、運用要件として難しい事もあると思います。</p>

<p>下記スクリプトを使用すれば、manifestを使わなくても画像データを完全にオフライン化できます。</p>

<h5>使い方</h5>

<p>HTMLのHEAD部分で下記スクリプトを書く。</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery.storagecache.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>


<p>ストレージキャッシュしたい画像を下記のように書いて下さい。
但し、Ajaxのクロスドメイン制約から、他ドメインのイメージソースは使用できませんので、同サーバの画像を指定して下さい。</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>img cache_src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;./images/banner.gif&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;this is banner!&quot;</span> width<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;90&quot;</span> height<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;45&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>


<p>HTMLの呼び出しが完了した時点で、下記スクリプトを実行。</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img[cache_src]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">storagecache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<h5>ダウンロード</h5>

<p><a href="https://gist.github.com/1454448" target="_blank">こちら</a>からダウンロードして下さい。</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2011/12/storagecache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2011/12/storagecache/" />
	</item>
		<item>
		<title>Zabbixをスマートフォン対応にしよう！(iPhone、Android対応)</title>
		<link>http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/</link>
		<comments>http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 22:08:02 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Zabbix]]></category>
		<category><![CDATA[スマートフォン]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/</guid>
		<description><![CDATA[監視サービスとしてのZabbixを、スマートフォンで見れるようにするクライアントを見つけました。
いつでも、どこでも、監視状況をスマートフォンに最適化された画面で使用する事ができますよ。

iPhone、Androidの [...]]]></description>
			<content:encoded><![CDATA[<p>監視サービスとしてのZabbixを、スマートフォンで見れるようにするクライアントを見つけました。
いつでも、どこでも、監視状況をスマートフォンに最適化された画面で使用する事ができますよ。</p>

<p>iPhone、Androidのために、jQtouchを使い、ネイティブアプリっぽいUIがかっこいいです。</p>

<h5>インストールメモ</h5>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">sudo mkdir <span style="color:#006600; font-weight:bold;">/</span>etc<span style="color:#006600; font-weight:bold;">/</span>zabbix<span style="color:#006600; font-weight:bold;">/</span>mozbx
sudo chown nashiki:nashiki <span style="color:#006600; font-weight:bold;">/</span>etc<span style="color:#006600; font-weight:bold;">/</span>zabbix<span style="color:#006600; font-weight:bold;">/</span>mozbx
sudo chmod <span style="color:#006600; font-weight:bold;">+</span>x <span style="color:#006600; font-weight:bold;">/</span>etc<span style="color:#006600; font-weight:bold;">/</span>zabbix<span style="color:#006600; font-weight:bold;">/</span>mozbx
cd <span style="color:#006600; font-weight:bold;">/</span>etc<span style="color:#006600; font-weight:bold;">/</span>zabbix<span style="color:#006600; font-weight:bold;">/</span>mozbx
git clone git:<span style="color:#006600; font-weight:bold;">//</span>github.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span>mattiasgeniar<span style="color:#006600; font-weight:bold;">/</span>MoZBX.<span style="color:#9900CC;">git</span> .
<span style="color:#9900CC;">cd</span> <span style="color:#006600; font-weight:bold;">/</span>var<span style="color:#006600; font-weight:bold;">/</span>www<span style="color:#006600; font-weight:bold;">/</span>html<span style="color:#006600; font-weight:bold;">/</span>
ln <span style="color:#006600; font-weight:bold;">-</span>s <span style="color:#006600; font-weight:bold;">/</span>etc<span style="color:#006600; font-weight:bold;">/</span>zabbix<span style="color:#006600; font-weight:bold;">/</span>mozbx .<span style="color:#006600; font-weight:bold;">/</span>mozbx</pre></div></div>


<p>その後に、Zabbixへ管理者ログインして、メニューの「管理」⇒ユーザ⇒API accessに、スマフォ対応させたいアカウントを追加して保存</p>

<p>インストール後お手元のスマフォから下記URLでアクセスして下さい。

http://yourhostname.jp/mozbx</p>


<a href='http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/host/' title='host'><img width="150" height="150" src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/02/host-150x150.png" class="attachment-thumbnail" alt="" title="host" /></a>
<a href='http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/dashboard/' title='dashboard'><img width="150" height="150" src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/02/dashboard-150x150.png" class="attachment-thumbnail" alt="" title="dashboard" /></a>
<a href='http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/graph_cpuload/' title='graph_cpuload'><img width="150" height="150" src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/02/graph_cpuload-150x150.png" class="attachment-thumbnail" alt="" title="graph_cpuload" /></a>
<a href='http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/graph_network/' title='graph_network'><img width="150" height="150" src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/02/graph_network-150x150.png" class="attachment-thumbnail" alt="" title="graph_network" /></a>
<a href='http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/homescreen/' title='homescreen'><img width="150" height="150" src="http://cyberwave.jp/nashiki/wp-content/uploads/2011/02/homescreen-150x150.png" class="attachment-thumbnail" alt="" title="homescreen" /></a>


<h5>参考</h5>

<p><a href="http://www.mozbx.net/index.html" target="_blank">http://www.mozbx.net/index.html
</a><a href="https://github.com/mattiasgeniar/MoZBX" target="_blank">https://github.com/mattiasgeniar/MoZBX</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2011/02/zabbix%e3%82%92%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%97%e3%82%88%e3%81%86%ef%bc%81iphone%e3%80%81android%e5%af%be%e5%bf%9c/" />
	</item>
		<item>
		<title>Rails ＋ Sinatra ≒ Padrino で遊ぼう！</title>
		<link>http://cyberwave.jp/nashiki/2010/06/rails-%ef%bc%8b-sinatra-%e2%89%92-padrino-%e3%81%a7%e9%81%8a%e3%81%bc%e3%81%86%ef%bc%81/</link>
		<comments>http://cyberwave.jp/nashiki/2010/06/rails-%ef%bc%8b-sinatra-%e2%89%92-padrino-%e3%81%a7%e9%81%8a%e3%81%bc%e3%81%86%ef%bc%81/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 06:55:37 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[Padrino]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=462</guid>
		<description><![CDATA[Rails3の登場が待ち遠しい中、社内プロジェクトをSinatraで進めていました。
しかし、Sinatraの軽量感はいいのですが、少し大きなプロジェクトになると、app.rbが煩雑になります。
そこで、Railsみたい [...]]]></description>
			<content:encoded><![CDATA[<p>Rails3の登場が待ち遠しい中、社内プロジェクトをSinatraで進めていました。
しかし、Sinatraの軽量感はいいのですが、少し大きなプロジェクトになると、app.rbが煩雑になります。
そこで、Railsみたいなディレクトリ分けをして作っていきますが、その時やはりRailsみたいにコードの自動生成が欲しくなってきます。</p>

<h4>Padrinoを使いましょう！</h4>

<p>軽量フレームワークSinatraを使い、Railsみたいな自動コード生成が出来ます。
<a href="http://www.padrinorb.com/" target="_blank">http://www.padrinorb.com/</a></p>

<p>他に、Padrinoには下記のような機能が付いています。
<a href="http://www.padrinorb.com/" target="_blank"><img src="http://cyberwave.jp/nashiki/wp-content/uploads/2010/06/309ca37516fe1fac75867adc86ecc368-300x251.jpg" alt="Padrino公式サイト" title="Padrino公式サイト" width="300" height="251" align="right" /></a></p>

<ol>
    <li><span style="font-size: 13.3333px;">複数の有名なテストフレームワークとの連携</span></li>
    <li><span style="font-size: 13.3333px;"> </span><span style="font-size: 13.3333px;">複数の有名なテンプレートエンジンとの連携</span></li>
    <li><span style="font-size: 13.3333px;">データベースも複数対応</span></li>
    <li><span style="font-size: 13.3333px;">コードジェネレータ(</span><span style="font-size: 13.3333px;">モデル・コントローラの自動生成)</span></li>
    <li><span style="font-size: 13.3333px;">複数のアプリケーションを簡単に統合させるマウント機能</span></li>
    <li><span style="font-size: 13.3333px;">強力なルーティング機能</span></li>
    <li><span style="font-size: 13.3333px;">各種ヘルパー機能（</span><span style="font-size: 13.3333px;">タグ、アセット、フォーム、テキスト）</span></li>
    <li><span style="font-size: 13.3333px;">メーラー機能</span></li>
    <li><span style="font-size: 13.3333px;">管理画面自動生成</span></li>
    <li><span style="font-size: 13.3333px;">ログ収集機能</span></li>
    <li><span style="font-size: 13.3333px;">リローディング機能</span></li>
    <li><span style="font-size: 13.3333px;">国際化</span></li>
</ol>

<h4>Blog作成チュートリアル</h4>

<p>下記スクリーンキャストは、作者本人による説明です。
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="330" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blip.tv/play/AYHS23AC" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="330" src="http://blip.tv/play/AYHS23AC" allowfullscreen="true"></embed></object></p>

<p>下記内容は、公式チュートリアルに掲載していあるBlogの作成を行いました。</p>

<h5>Padrinoフレームワークのインストール</h5>

<p>いつもどおり、gemで一発終了です。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">gem install padrino</pre></div></div>


<h5>sample_blogプロジェクトの初期化</h5>

<p>Railsプロジェクトと同様ですが、プロジェクトで使用するディレクトリ構成、及び、設定ファイル等を自動的に作成をしてくれます。
下記内容では、テストにshoulda、ビューにhaml、sass、ORMにactiverecordを使用するという設定です。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen project sample_blog <span style="color:#006600; font-weight:bold;">-</span>t shoulda <span style="color:#006600; font-weight:bold;">-</span>e haml <span style="color:#006600; font-weight:bold;">-</span>c sass <span style="color:#006600; font-weight:bold;">-</span>s jquery <span style="color:#006600; font-weight:bold;">-</span>d activerecord <span style="color:#006600; font-weight:bold;">-</span>b
cd sample_blog</pre></div></div>


<h5>Routeの初期設定</h5>

<p>既に自動生成されている下記ファイルを書き換え、テストも兼ねて「Hello World!」を入れてみましょう。</p>

<h1>app/app.rb</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SampleBlog <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Padrino::Application</span>
  configure <span style="color:#9966CC; font-weight:bold;">do</span>
     <span style="color:#008000; font-style:italic;"># ...</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Add these routes below to the app file...</span>
  get <span style="color:#996600;">&quot;/&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#996600;">&quot;Hello World!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  get <span style="color:#ff3333; font-weight:bold;">:about</span>, <span style="color:#ff3333; font-weight:bold;">:map</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/about_us'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    render <span style="color:#ff3333; font-weight:bold;">:haml</span>, <span style="color:#996600;">&quot;%p This is a sample blog created to demonstrate the power of Padrino!&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<h5>動作確認</h5>

<p>padrinoを起動させて、WEBアプリケーションが出来ているか確認しましょう。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino start
<span style="color:#008000; font-style:italic;"># ブラウザで下記URLをアクセス</span>
<span style="color:#008000; font-style:italic;"># http://localhost:3000/</span>
<span style="color:#008000; font-style:italic;"># http://localhost:3000/about_us</span></pre></div></div>


<h5>管理画面作成</h5>

<p>次に管理画面を自動生成してみましょう！
これも、自動生成が付いているので手軽に管理画面が構築出来ます。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen admin
padrino rake ar:create
padrino rake ar:migrate</pre></div></div>


<p>下記コマンドで、管理画面へログインする初期アカウント作成を行います。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino rake seed
<span style="color:#008000; font-style:italic;"># 任意のEメールとパスワードを入力</span></pre></div></div>


<h5>動作確認</h5>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino start
<span style="color:#008000; font-style:italic;"># ブラウザで下記URLをアクセス</span>
<span style="color:#008000; font-style:italic;"># http://localhost:3000/admin/</span></pre></div></div>


<h5>モデル作成</h5>

<p>Rails同様に、モデルも自動生成出来ます。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen model post title:<span style="color:#CC0066; font-weight:bold;">string</span> body:text</pre></div></div>


<p>下記自動生成された、マイグレートファイルに「t.timestamps」を追加します。</p>

<h1>db/migrate/002_create_posts.rb</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> CreatePosts <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:posts</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:title</span>
      t.<span style="color:#9900CC;">text</span> <span style="color:#ff3333; font-weight:bold;">:body</span>
      t.<span style="color:#9900CC;">timestamps</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:posts</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<h5>マイグレート</h5>

<p>アクティブレコードでのマイグレーションを実行します。
DBはデフォルトで、sqlite3なので、プロジェクト直下のdbディレクトリ内に「development.db」が生成されます。
※sqlite3のファイル内容を確かめるには、TkSQLiteがお勧めです！
<a href="http://reddog.s35.xrea.com/wiki/TkSQLite.html" target="_blank">http://reddog.s35.xrea.com/wiki/TkSQLite.html</a></p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino rake ar:migrate</pre></div></div>


<h5>コントローラ自動生成</h5>

<p>下記コマンドでコントローラを自動生成します。
URIの規則は、Railsと同様になっています。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen controller posts get:index get:show</pre></div></div>


<p>自動生成されたpost.rbを下記のように書き換えます。
indexは、Postモデルからデータを取得して@postsに入れてViewに渡しています。
showは、URIからidを取得して、Postモデルから検索し、@postに入れてViewに渡しています。</p>

<h1>app/controllers/posts.rb</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">SampleBlog.<span style="color:#9900CC;">controllers</span> <span style="color:#ff3333; font-weight:bold;">:posts</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  get <span style="color:#ff3333; font-weight:bold;">:index</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#0066ff; font-weight:bold;">@posts</span> = Post.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:order</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">'created_at desc'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    render <span style="color:#996600;">'posts/index'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  get <span style="color:#ff3333; font-weight:bold;">:show</span>, <span style="color:#ff3333; font-weight:bold;">:with</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<span style="color:#9900CC;">find_by_id</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    render <span style="color:#996600;">'posts/show'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<h5>ビュー作成</h5>

<p>Hamlでビューを書いています。</p>

<h1>app/views/posts/index.haml</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">-</span> <span style="color:#0066ff; font-weight:bold;">@title</span> = <span style="color:#996600;">&quot;Welcome&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#posts= partial 'posts/post', :collection =&amp;gt; @posts</span></pre></div></div>


<h1>app/views/posts/_post.haml</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">.<span style="color:#9900CC;">post</span>
  .<span style="color:#9900CC;">title</span>= link_to post.<span style="color:#9900CC;">title</span>, url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:show</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; post<span style="color:#006600; font-weight:bold;">&#41;</span>
  .<span style="color:#9900CC;">date</span>= time_ago_in_words<span style="color:#006600; font-weight:bold;">&#40;</span>post.<span style="color:#9900CC;">created_at</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">' ago'</span>
  .<span style="color:#9900CC;">body</span>= simple_format<span style="color:#006600; font-weight:bold;">&#40;</span>post.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>


<h1>app/views/posts/show.haml</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">-</span> <span style="color:#0066ff; font-weight:bold;">@title</span> = <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">title</span>
<span style="color:#008000; font-style:italic;">#show</span>
  .<span style="color:#9900CC;">post</span>
    .<span style="color:#9900CC;">title</span>= <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">title</span>
    .<span style="color:#9900CC;">date</span>= time_ago_in_words<span style="color:#006600; font-weight:bold;">&#40;</span>@post.<span style="color:#9900CC;">created_at</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">' ago'</span>
    .<span style="color:#9900CC;">body</span>= simple_format<span style="color:#006600; font-weight:bold;">&#40;</span>@post.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">%</span><span style="color:#CC0066; font-weight:bold;">p</span>= link_to <span style="color:#996600;">'View all posts'</span>, url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:index</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>


<h5>管理画面にpostモデルを追加する</h5>

<p>下記魔法のコマンドで、先程生成した管理画面にpostモデルを追加できます。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen admin_page post</pre></div></div>


<h5>動作確認</h5>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino start
<span style="color:#008000; font-style:italic;"># ブラウザで下記URLをアクセス</span>
<span style="color:#008000; font-style:italic;"># http://localhost:3000/admin/</span></pre></div></div>


<h5>モデルへ新カラム追加</h5>

<p>下記コマンドで、postモデルに、acount_idカラムを追加しています。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino<span style="color:#006600; font-weight:bold;">-</span>gen migration AddAccountToPost account_id:<span style="color:#CC0066; font-weight:bold;">integer</span></pre></div></div>


<p>postモデルにバリデーションルールとacountとの関連ルールを追加</p>

<h1>app/models/post.rb</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Post <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:account</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:title</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:body</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>管理画面でのpostモデル新規作成時に、accountが管理画面へログインしているユーザになるようにする
(「@post.account = current_account」の一行)</p>

<h1>admin/controllers/posts.rb</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Admin.<span style="color:#9900CC;">controllers</span> <span style="color:#ff3333; font-weight:bold;">:posts</span> <span style="color:#9966CC; font-weight:bold;">do</span>
<span style="color:#008000; font-style:italic;"># ...</span>
  post <span style="color:#ff3333; font-weight:bold;">:create</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">account</span> = current_account
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">save</span>
      flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'Post was successfully created.'</span>
      redirect url<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:edit</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      render <span style="color:#996600;">'posts/new'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;"># ...</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<h5>ビューに「Posted by」を追加</h5>

<p>アクティブレコードのお陰で、コントローラをいじらずすんなり追加できます。</p>

<h1>app/views/posts/show.haml</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">-</span> <span style="color:#0066ff; font-weight:bold;">@title</span> = <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">title</span>
<span style="color:#008000; font-style:italic;">#show</span>
  .<span style="color:#9900CC;">post</span>
    .<span style="color:#9900CC;">title</span>= <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">title</span>
    .<span style="color:#9900CC;">date</span>= time_ago_in_words<span style="color:#006600; font-weight:bold;">&#40;</span>@post.<span style="color:#9900CC;">created_at</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">' ago'</span>
    .<span style="color:#9900CC;">body</span>= simple_format<span style="color:#006600; font-weight:bold;">&#40;</span>@post.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    .<span style="color:#9900CC;">details</span>
      .<span style="color:#9900CC;">author</span> Posted by <span style="color:#008000; font-style:italic;">#{@post.account.email}</span>
<span style="color:#006600; font-weight:bold;">%</span><span style="color:#CC0066; font-weight:bold;">p</span>= link_to <span style="color:#996600;">'View all posts'</span>, url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:index</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>


<h1>app/views/posts/_post.haml</h1>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">.<span style="color:#9900CC;">post</span>
  .<span style="color:#9900CC;">title</span>= link_to post.<span style="color:#9900CC;">title</span>, url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:show</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; post<span style="color:#006600; font-weight:bold;">&#41;</span>
  .<span style="color:#9900CC;">date</span>= time_ago_in_words<span style="color:#006600; font-weight:bold;">&#40;</span>post.<span style="color:#9900CC;">created_at</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">' ago'</span>
  .<span style="color:#9900CC;">body</span>= simple_format<span style="color:#006600; font-weight:bold;">&#40;</span>post.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  .<span style="color:#9900CC;">details</span>
    .<span style="color:#9900CC;">author</span> Posted by <span style="color:#008000; font-style:italic;">#{post.account.email}</span></pre></div></div>


<h5>CSSの配置</h5>

<p>下記パスより、CSSを2つ取得する。
<a href="http://github.com/padrino/sample_blog/tree/master/public/stylesheets/" target="_blank">http://github.com/padrino/sample_blog/tree/master/public/stylesheets/</a>
配置場所:\sample_blog\public\stylesheets</p>

<h5>動作確認</h5>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">padrino start
<span style="color:#008000; font-style:italic;"># ブラウザで下記URLをアクセス</span>
<span style="color:#008000; font-style:italic;"># http://localhost:3000/posts</span></pre></div></div>


<h5>感想</h5>

<p>sinatraの手軽さを残しつつ、Railsライクなディレクトリ構成とコード自動生成が出来ます。
また、テストフレームワーク、ビュー、モデルなどが疎結合になっており、自由に選択できるところも魅力だと感じました。</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2010/06/rails-%ef%bc%8b-sinatra-%e2%89%92-padrino-%e3%81%a7%e9%81%8a%e3%81%bc%e3%81%86%ef%bc%81/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2010/06/rails-%ef%bc%8b-sinatra-%e2%89%92-padrino-%e3%81%a7%e9%81%8a%e3%81%bc%e3%81%86%ef%bc%81/" />
	</item>
		<item>
		<title>pikで簡単、複数のRuby環境構築！</title>
		<link>http://cyberwave.jp/nashiki/2010/05/windows%e3%81%ab%e3%81%a6%e3%80%81%e8%a4%87%e6%95%b0%e3%81%aeruby%e7%92%b0%e5%a2%83%e3%82%92%e5%85%b1%e5%ad%98%e3%81%95%e3%81%9b%e3%82%88%e3%81%86%ef%bc%81/</link>
		<comments>http://cyberwave.jp/nashiki/2010/05/windows%e3%81%ab%e3%81%a6%e3%80%81%e8%a4%87%e6%95%b0%e3%81%aeruby%e7%92%b0%e5%a2%83%e3%82%92%e5%85%b1%e5%ad%98%e3%81%95%e3%81%9b%e3%82%88%e3%81%86%ef%bc%81/#comments</comments>
		<pubDate>Fri, 28 May 2010 19:50:53 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[pik]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=411</guid>
		<description><![CDATA[そろそろ、Ruby1.9も試したいが、環境をスグには変えられないと思いませんか？
pikは、Windows内で複数のRuby環境を管理できるツールです。
いつも通りGemでインストール出来て、Ruby環境の追加、一覧、変 [...]]]></description>
			<content:encoded><![CDATA[<p>そろそろ、Ruby1.9も試したいが、環境をスグには変えられないと思いませんか？
pikは、Windows内で複数のRuby環境を管理できるツールです。
いつも通りGemでインストール出来て、Ruby環境の追加、一覧、変更が出来ます。</p>

<h4>pikのインストール</h4>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">gem install pik
mkdir <span style="color:#996600;">&quot;C:<span style="color:#000099;">\P</span>rogram Files<span style="color:#000099;">\p</span>ik&quot;</span>
<span style="color:#008000; font-style:italic;"># PATHに&quot;C:\Program Files\pik&quot;を追加</span>
pik_install <span style="color:#996600;">&quot;C:<span style="color:#000099;">\P</span>rogram Files<span style="color:#000099;">\p</span>ik&quot;</span></pre></div></div>


<h4>初期設定</h4>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># 既存環境の追加</span>
pik add
This version has already been added.
<span style="color:#008000; font-style:italic;"># 新しい環境の追加</span>
pik add C:\ruby<span style="color:#006600; font-weight:bold;">-</span>1.9.1<span style="color:#006600; font-weight:bold;">-</span>p376<span style="color:#006600; font-weight:bold;">-</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32\bin
<span style="color:#006600; font-weight:bold;">**</span> Adding:  <span style="color:#006666;">191</span>: ruby 1.9.1p376 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span><span style="color:#006600; font-weight:bold;">-</span>07 revision <span style="color:#006666;">26041</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
 Located at:  C:\ruby<span style="color:#006600; font-weight:bold;">-</span>1.9.1<span style="color:#006600; font-weight:bold;">-</span>p376<span style="color:#006600; font-weight:bold;">-</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32\bin</pre></div></div>


<h4>環境一覧</h4>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">pik list
<span style="color:#006666;">187</span>: ruby 1.8.7 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span>06<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span> patchlevel <span style="color:#006666;">174</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">*</span>
<span style="color:#006666;">191</span>: ruby 1.9.1p376 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span><span style="color:#006600; font-weight:bold;">-</span>07 revision <span style="color:#006666;">26041</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006666;">191</span>: ruby 1.9.1p378 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2010</span><span style="color:#006600; font-weight:bold;">-</span>01<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">10</span> revision <span style="color:#006666;">26273</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mingw32<span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>


<h4>環境チャンジ</h4>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">pik sw <span style="color:#006666;">191</span>      <span style="color:#008000; font-style:italic;"># Verのみ指定</span>
pik sw <span style="color:#006666;">191</span> p378 <span style="color:#008000; font-style:italic;"># Verとpまで指定</span></pre></div></div>


<h4>使ってみた感想</h4>

<p>まずインストールと初期設定がすごく簡単でした。
環境周りだからちょっと面倒かなと思いましたが、すごく簡単。
手軽に、Rubyの実行環境をチェンジ出来る感覚は新鮮です！
Gem環境も完全に分離されているので、影響が無いです。
ぜひ、皆さんも試してみて下さい。</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Ruby環境一覧を確認</span>
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;pik list
<span style="color:#006666;">187</span>: ruby 1.8.7 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span>06<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span> patchlevel <span style="color:#006666;">174</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">*</span>
<span style="color:#006666;">191</span>: ruby 1.9.1p376 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span><span style="color:#006600; font-weight:bold;">-</span>07 revision <span style="color:#006666;">26041</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006666;">191</span>: ruby 1.9.1p378 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2010</span><span style="color:#006600; font-weight:bold;">-</span>01<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">10</span> revision <span style="color:#006666;">26273</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mingw32<span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 現状のRubyVerを確認</span>
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;ruby <span style="color:#006600; font-weight:bold;">-</span>v
ruby 1.8.7 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span>06<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span> patchlevel <span style="color:#006666;">174</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Ver1.9.1に変更</span>
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;pik sw <span style="color:#006666;">191</span> p376
&nbsp;
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;ruby <span style="color:#006600; font-weight:bold;">-</span>v
ruby 1.9.1p376 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span><span style="color:#006600; font-weight:bold;">-</span>07 revision <span style="color:#006666;">26041</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#008000; font-style:italic;"># ↑無事に変更されています。</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 再度Ver1.8.7に戻す</span>
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;pik sw <span style="color:#006666;">187</span>
&nbsp;
C:\WINDOWS<span style="color:#006600; font-weight:bold;">&amp;</span>gt;ruby <span style="color:#006600; font-weight:bold;">-</span>v
ruby 1.8.7 <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span>06<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">12</span> patchlevel <span style="color:#006666;">174</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>i386<span style="color:#006600; font-weight:bold;">-</span>mswin32<span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#008000; font-style:italic;"># ↑こちらも無事に変更されています。</span></pre></div></div>


<h3>参照</h3>

<h3><span style="font-weight: normal; font-size: 13px;"><span style="font-size: medium;"><span><strong> </strong></span></span><a href="http://github.com/vertiginous/pik" target="_blank">http://github.com/vertiginous/pik</a></span></h3>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2010/05/windows%e3%81%ab%e3%81%a6%e3%80%81%e8%a4%87%e6%95%b0%e3%81%aeruby%e7%92%b0%e5%a2%83%e3%82%92%e5%85%b1%e5%ad%98%e3%81%95%e3%81%9b%e3%82%88%e3%81%86%ef%bc%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2010/05/windows%e3%81%ab%e3%81%a6%e3%80%81%e8%a4%87%e6%95%b0%e3%81%aeruby%e7%92%b0%e5%a2%83%e3%82%92%e5%85%b1%e5%ad%98%e3%81%95%e3%81%9b%e3%82%88%e3%81%86%ef%bc%81/" />
	</item>
		<item>
		<title>夏が楽しみ！地味渋Etnicaが超カッコいい！</title>
		<link>http://cyberwave.jp/nashiki/2010/02/%e5%9c%b0%e5%91%b3%e6%b8%8b%e3%80%81etnica%e3%81%8c%e3%82%ab%e3%83%83%e3%82%b3%e3%81%84%e3%81%84%ef%bc%81/</link>
		<comments>http://cyberwave.jp/nashiki/2010/02/%e5%9c%b0%e5%91%b3%e6%b8%8b%e3%80%81etnica%e3%81%8c%e3%82%ab%e3%83%83%e3%82%b3%e3%81%84%e3%81%84%ef%bc%81/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 14:39:11 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[音の世界]]></category>
		<category><![CDATA[トランス]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=405</guid>
		<description><![CDATA[Twitterポストだけでは物足りず、Blogへアーカイブ。
このVは、かっこえ~~。
思い起こせば2002年現地に居ました。。

Etnicaは、とにかくクール。
渋くて重いベースラインが、ゆっくりとテンションを上げて [...]]]></description>
			<content:encoded><![CDATA[<p>Twitterポストだけでは物足りず、Blogへアーカイブ。
このVは、かっこえ~~。
思い起こせば2002年現地に居ました。。</p>

<p>Etnicaは、とにかくクール。
渋くて重いベースラインが、ゆっくりとテンションを上げてくれる。
上がった後の渋いブレイク。。
下記Vの、<span style="color: #ff0000;">5分01秒</span>のところがカッコいいです。 ^^
とにかく地味渋！！</p>

<p>これからシーズンですね。
野外が楽しみです！
おもいッきり踊りたいですね。</p>

<p>いっぱい遊びましょ！
Enjoy your life!</p>

<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/vT_Svu2KI5o&#038;hl=ja_JP&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/vT_Svu2KI5o&#038;hl=ja_JP&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2010/02/%e5%9c%b0%e5%91%b3%e6%b8%8b%e3%80%81etnica%e3%81%8c%e3%82%ab%e3%83%83%e3%82%b3%e3%81%84%e3%81%84%ef%bc%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2010/02/%e5%9c%b0%e5%91%b3%e6%b8%8b%e3%80%81etnica%e3%81%8c%e3%82%ab%e3%83%83%e3%82%b3%e3%81%84%e3%81%84%ef%bc%81/" />
	</item>
		<item>
		<title>エンジニア・ライフ イズ ビューティフル！</title>
		<link>http://cyberwave.jp/nashiki/2009/11/%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%8b%e3%82%a2%e3%83%bb%e3%83%a9%e3%82%a4%e3%83%95-%e3%82%a4%e3%82%ba-%e3%83%93%e3%83%a5%e3%83%bc%e3%83%86%e3%82%a3%e3%83%95%e3%83%ab%ef%bc%81/</link>
		<comments>http://cyberwave.jp/nashiki/2009/11/%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%8b%e3%82%a2%e3%83%bb%e3%83%a9%e3%82%a4%e3%83%95-%e3%82%a4%e3%82%ba-%e3%83%93%e3%83%a5%e3%83%bc%e3%83%86%e3%82%a3%e3%83%95%e3%83%ab%ef%bc%81/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 12:54:46 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[日記]]></category>
		<category><![CDATA[エンジニアライフ]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=392</guid>
		<description><![CDATA[Blog投稿久しぶり！
最近は、めっきりツイットしてました！

今日は、ドリーセさん＠渋谷の事務所会議室をお借りして、LTを行っておりました！！
僕の発表は、『エンジニアの人生』について、梨木が思っている事を話しました。 [...]]]></description>
			<content:encoded><![CDATA[<p>Blog投稿久しぶり！
最近は、めっきり<a href="https://twitter.com/nashiki" target="_blank">ツイット</a>してました！</p>

<p>今日は、<a href="http://www.drice.jp/" target="_blank">ドリーセ</a>さん＠渋谷の事務所会議室をお借りして、LTを行っておりました！！
僕の発表は、『エンジニアの人生』について、梨木が思っている事を話しました。</p>

<p><span style="background-color: #ffffff;">資料をslideshareに(初)アップしましたので、皆さん、ご覧頂けたらと思います。。。
一部、Twitterで「今は、ユーストリームで流せ」的なご意見をいただきました！
次回、トライするぜい。</span></p>

<p><span style="background-color: #ffffff;">ではでは、スライドは以下の通りです！！
（本当は、PPTでアニメが付いているのですが。。ま、slideshareなのでご勘弁。。）</span></p>

<p><span style="background-color: #ffffff;">沢山のエンジニアさんにお会いできてハッピーでした。。。
このポストを読んでいただいたエンジニアの皆様が、少しでも「エンジニア・ライフ イズ ビューティフル」を感じて頂いたら幸いです。</span></p>

<p>梨木繁幸</p>

<div style="width:425px;text-align:left" id="__ss_2499028"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/nashiki/ss-2499028" title="エンジニア・ライフ・イズ・ビューティフル">エンジニア・ライフ・イズ・ビューティフル</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=random-091114071717-phpapp01&#038;stripped_title=ss-2499028" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=random-091114071717-phpapp01&#038;stripped_title=ss-2499028" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/nashiki">梨木 繁幸</a>.</div></div>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2009/11/%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%8b%e3%82%a2%e3%83%bb%e3%83%a9%e3%82%a4%e3%83%95-%e3%82%a4%e3%82%ba-%e3%83%93%e3%83%a5%e3%83%bc%e3%83%86%e3%82%a3%e3%83%95%e3%83%ab%ef%bc%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2009/11/%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%8b%e3%82%a2%e3%83%bb%e3%83%a9%e3%82%a4%e3%83%95-%e3%82%a4%e3%82%ba-%e3%83%93%e3%83%a5%e3%83%bc%e3%83%86%e3%82%a3%e3%83%95%e3%83%ab%ef%bc%81/" />
	</item>
		<item>
		<title>マーカレス拡張現実PTAMってすごい!!</title>
		<link>http://cyberwave.jp/nashiki/2009/09/%e3%83%9e%e3%83%bc%e3%82%ab%e3%83%ac%e3%82%b9%e6%8b%a1%e5%bc%b5%e7%8f%be%e5%ae%9fptam%e3%81%a3%e3%81%a6%e3%81%99%e3%81%94%e3%81%84/</link>
		<comments>http://cyberwave.jp/nashiki/2009/09/%e3%83%9e%e3%83%bc%e3%82%ab%e3%83%ac%e3%82%b9%e6%8b%a1%e5%bc%b5%e7%8f%be%e5%ae%9fptam%e3%81%a3%e3%81%a6%e3%81%99%e3%81%94%e3%81%84/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:17:55 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[生活をハック]]></category>
		<category><![CDATA[AR]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[PTAM]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=385</guid>
		<description><![CDATA[久しぶりに興奮しました！
すげーすげー。
これはやばいと思ったのでポスト。
タイトルにある『マーカレス拡張現実PTAM！』

なんて表現したらいいのかわからないので動画を載せます。

今までの拡張現実。

ワシントン大学 [...]]]></description>
			<content:encoded><![CDATA[<p>久しぶりに興奮しました！
すげーすげー。
これはやばいと思ったのでポスト。
タイトルにある『マーカレス拡張現実PTAM！』</p>

<p>なんて表現したらいいのかわからないので動画を載せます。</p>

<h2>今までの拡張現実。</h2>

<p>ワシントン大学HIT研究室が作ったARToolKitとしてライブラリがありこのライブラリからいろんなアプリを作って遊んでいます。
PCのカメラが読み込んだ画像の中からマーカーを認識し、そのマーカーから空間(X,Y,Z,VX,VY,VZ)を認識し、その空間に何かオブジェクトを簡単に配置できるライブラリです。
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/5M-oAmBDcZk&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/5M-oAmBDcZk&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>このARToolKitは、空間をソフトが識別するための白黒の記号(マーカー)が必要です。</p>

<h2>マーカレス拡張現実PTAM</h2>

<p>しかし、マーカレス拡張現実はこれがいらない！
オックスフォード大学のアクティブビジョングループの<a href="http://www.robots.ox.ac.uk/~gk/" target="_blank">ジョージクレイン</a>さんがマーカレス拡張現実作ってます！
これがすごい。
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Y9HMn6bd-v8&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Y9HMn6bd-v8&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<h3>このビデオ下記秒数をチェックしてください！</h3>

<ul>
    <li><span style="color: #ff0000;">16秒目：電車外に見える野球グラウンドに巨大キャラクター！</span></li>
    <li><span style="color: #ff0000;">1分目：京都日本庭園にダースベーダーが現れ敵と戦う！</span></li>
    <li><span style="color: #ff0000;">2分目：京都の鹿と遊んだあと、鳥居を見たら空間認識し、ドットが現れる！</span></li>
    <li><span style="color: #ff0000;">2分50秒目：京都の池が歪む！</span></li>
</ul>

<p>ヤバ過ぎます。
これって、文字通り『現実が拡張』されてる感じ。
フィーチャーしすぎだし、 他の人が見てる現実から離脱してる感じもありますよね。
スカラ株式会社の<a href="http://www.scalar.co.jp/detail.php?id=t4-n" target="_blank">T4-N</a>なんかのデバイスと組み合わせたいです。</p>

<h3>美術館入り口にいきなり恐竜２頭がお出迎え！</h3>

<p>しかも画像の特徴点から場所の認識が可能で他の動画サンプルでは美術館に入ってiPhoneをかざすといろんなものがARで飛び出るようなものも作っています。
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Wn9yUZm1fqY&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Wn9yUZm1fqY&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>これは基礎技術なのでこの技術から応用して生活に活かさないといけないですよね。</p>

<p>この技術自体は画像のみを使って空間を認識しているので、これにGPSや地磁気センサーを加えると更に精度を高めた現時点の認識が可能です。
ソースコードも<a href="http://www.robots.ox.ac.uk/~gk/PTAM/" target="_self">公開</a>されているので何か作りたいですね！！</p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2009/09/%e3%83%9e%e3%83%bc%e3%82%ab%e3%83%ac%e3%82%b9%e6%8b%a1%e5%bc%b5%e7%8f%be%e5%ae%9fptam%e3%81%a3%e3%81%a6%e3%81%99%e3%81%94%e3%81%84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2009/09/%e3%83%9e%e3%83%bc%e3%82%ab%e3%83%ac%e3%82%b9%e6%8b%a1%e5%bc%b5%e7%8f%be%e5%ae%9fptam%e3%81%a3%e3%81%a6%e3%81%99%e3%81%94%e3%81%84/" />
	</item>
		<item>
		<title>TwitterからMixiエコーへ自動転送サービスα版開始しました!</title>
		<link>http://cyberwave.jp/nashiki/2009/09/twitter%e3%81%8b%e3%82%89mixi%e3%82%a8%e3%82%b3%e3%83%bc%e3%81%b8%e8%87%aa%e5%8b%95%e8%bb%a2%e9%80%81%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%ce%b1%e7%89%88%e9%96%8b%e5%a7%8b%e3%81%97%e3%81%be%e3%81%97/</link>
		<comments>http://cyberwave.jp/nashiki/2009/09/twitter%e3%81%8b%e3%82%89mixi%e3%82%a8%e3%82%b3%e3%83%bc%e3%81%b8%e8%87%aa%e5%8b%95%e8%bb%a2%e9%80%81%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%ce%b1%e7%89%88%e9%96%8b%e5%a7%8b%e3%81%97%e3%81%be%e3%81%97/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 22:26:49 +0000</pubDate>
		<dc:creator>nashiki</dc:creator>
				<category><![CDATA[プロジェクト]]></category>
		<category><![CDATA[楽しいコーディング]]></category>
		<category><![CDATA[mixi]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://cyberwave.jp/nashiki/?p=380</guid>
		<description><![CDATA[先週から正式に『Twitter2Mixi』のWEBサービスを開始しました。以前作ったスクリプトを、ご要望の多かったWEBサービス版にしました。
少しでもTwitterの楽しさが広がればと思いTwitterのつぶやきを自動 [...]]]></description>
			<content:encoded><![CDATA[<p>先週から正式に『Twitter2Mixi』のWEBサービスを開始しました。以前作った<a href="http://cyberwave.jp/nashiki/2009/04/twitter%E3%81%97%E3%81%9F%E3%82%89%E3%80%81%E8%87%AA%E5%8B%95%E3%81%A7mixi%E3%82%A8%E3%82%B3%E3%83%BC%E4%BD%9C%E3%81%A3%E3%81%9F%E3%82%88%E3%80%80%E3%80%8Etwitter2mixirb%E3%80%8F/" target="_self">スクリプト</a>を、ご要望の多かったWEBサービス版にしました。
少しでもTwitterの楽しさが広がればと思いTwitterのつぶやきを自動でMixiエコーに転送します。</p>

<p>まだ、Mixiエコーの利用者が少ないですがこのサービスを気に増えてもらえればうれしいかなと思ってます！</p>

<p><a href="http://twitter2mixi.cyberwave.jp/">http://twitter2mixi.cyberwave.jp/</a></p>

<p><a href="http://cyberwave.jp/nashiki/wp-content/uploads/2009/09/CAP000016.JPG"><img class="alignnone size-medium wp-image-381" title="twitter2mixi" src="http://cyberwave.jp/nashiki/wp-content/uploads/2009/09/CAP000016-300x282.jpg" alt="twitter2mixi" width="300" height="282" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cyberwave.jp/nashiki/2009/09/twitter%e3%81%8b%e3%82%89mixi%e3%82%a8%e3%82%b3%e3%83%bc%e3%81%b8%e8%87%aa%e5%8b%95%e8%bb%a2%e9%80%81%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%ce%b1%e7%89%88%e9%96%8b%e5%a7%8b%e3%81%97%e3%81%be%e3%81%97/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://cyberwave.jp/nashiki/2009/09/twitter%e3%81%8b%e3%82%89mixi%e3%82%a8%e3%82%b3%e3%83%bc%e3%81%b8%e8%87%aa%e5%8b%95%e8%bb%a2%e9%80%81%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%ce%b1%e7%89%88%e9%96%8b%e5%a7%8b%e3%81%97%e3%81%be%e3%81%97/" />
	</item>
	</channel>
</rss>

