<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2japanesefull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:xhtml="http://www.w3.org/1999/xhtml" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>おれせか</title>
	
	<link>http://ichi.fool.jp/blog</link>
	<description>なんかそれっぽいのをうにうに。</description>
	<pubDate>Fri, 02 Dec 2011 08:47:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>ja</language>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ichi" /><feedburner:info uri="ichi" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>rails3のvalidationコンテキスト指定はsaveでね。</title>
		<link>http://ichi.fool.jp/blog/?p=1724</link>
		<comments>http://ichi.fool.jp/blog/?p=1724#comments</comments>
		<pubDate>Fri, 02 Dec 2011 08:47:52 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[rails3]]></category>

		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1724</guid>
		<description><![CDATA[kennyjのブログ(仮): rails3.0の頃からvalidationにコンテキストを指定できる様になってた
↑の記事を読んで、おおこりゃいいやと思いつつ使ってみた時に気づいたことメモ。

@hoge.update_ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://kennyj-jp.blogspot.com/2011/09/rails30validation.html" target="_blank" class="external">kennyjのブログ(仮): rails3.0の頃からvalidationにコンテキストを指定できる様になってた</a></p>
<p>↑の記事を読んで、おおこりゃいいやと思いつつ使ってみた時に気づいたことメモ。</p>
<div class="pre code">
<pre class="code"><span style="color:#0066ff; font-weight:bold;">@hoge</span>.<span style="color:#9900CC;">update_attributes</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;">:hoge</span><span style="color:#006600; font-weight:bold;">&#93;</span>, context: <span style="color:#ff3333; font-weight:bold;">:foo</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre>
</div>
<p>何も考えずにupdate_attributesにも:contextオプション指定できるかなー？と思ってやってみた。<br />
→ :updateコンテキスト（デフォ）扱いされる。</p>
<div class="pre code">
<pre class="code"><span style="color:#0066ff; font-weight:bold;">@hoge</span>.<span style="color:#9900CC;">attributes</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:hoge</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#0066ff; font-weight:bold;">@hoge</span>.<span style="color:#9900CC;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span>context: <span style="color:#ff3333; font-weight:bold;">:foo</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre>
</div>
<p>attributes= してからsaveしてみた。<br />
→ やったー。:fooコンテキスト扱いされたよー。</p>
<p>railsのdocumentちろっと見てみたらupdate_attributesの引数は1個しかないみたいなんで当たり前っちゃ当たり前なんですが、なんかrailsだとこのくらいサクっといけてしまうんじゃなかろうかて気がしたのでやってみたというね。</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1724</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1724" />
	</item>
		<item>
		<title>メモ： rakなんかで「invalid byte sequence in UTF-8」言われたら。</title>
		<link>http://ichi.fool.jp/blog/?p=1720</link>
		<comments>http://ichi.fool.jp/blog/?p=1720#comments</comments>
		<pubDate>Fri, 21 Oct 2011 10:00:14 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[shell]]></category>

		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1720</guid>
		<description><![CDATA[
rakなんかしたときに「invalid byte sequence in UTF-8」みたいなこと言われたら、たぶんファイルがutfじゃないんでしょうよ、ということでとりあえず適当にutfに変換するとかなんとか。

j [...]]]></description>
			<content:encoded><![CDATA[
<p><a href="http://rak.rubyforge.org/" target="_blank" class="external">rak</a>なんかしたときに「invalid byte sequence in UTF-8」みたいなこと言われたら、たぶんファイルがutfじゃないんでしょうよ、ということでとりあえず適当にutfに変換するとかなんとか。</p>
<ul>
<li>jsファイルまとめて変換の場合（mac os x）
<div class="pre code">
<pre class="code" type="bash">find . -type f -name \*.js -print0 | xargs -0 nkf -w --overwrite
</pre>
</div>
</li>
</ul>
<p>-print0 とか -0 忘れないように。<br />
<a href="http://d.hatena.ne.jp/kanonji/20091119/1258616974" target="_blank" class="external">Macでfindとxargsをパイプで繋いで使うなら -print0 と -0 を必ず使うメモ - kanonjiの日記</a></p>
<p>ほんとはまとめて変換しないでちゃんと対象ファイルしっかり選んで変換したほうがきっといいよ！</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1720</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1720" />
	</item>
		<item>
		<title>titaniumとcoffeeと</title>
		<link>http://ichi.fool.jp/blog/?p=1701</link>
		<comments>http://ichi.fool.jp/blog/?p=1701#comments</comments>
		<pubDate>Fri, 30 Sep 2011 06:56:17 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[rake]]></category>

		<category><![CDATA[shell]]></category>

		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1701</guid>
		<description><![CDATA[
最近お仕事でtitaniumでのiphoneアプリ開発などちょいちょいしております。
で、最初はフツーにjavascriptをガリガリ書いてたのですが、coffeescriptなるものの噂を聞いたので使ってみるとこりゃ [...]]]></description>
			<content:encoded><![CDATA[
<p>最近お仕事で<a href="http://www.appcelerator.com/products/titanium-mobile-application-development/" target="_blank" class="external">titanium</a>でのiphoneアプリ開発などちょいちょいしております。</p>
<p>で、最初はフツーにjavascriptをガリガリ書いてたのですが、<a href="http://jashkenas.github.com/coffee-script/" target="_blank" class="external">coffeescript</a>なるものの噂を聞いたので使ってみるとこりゃいいやということに。</p>
<h3 class="contentsTitle">で、こっから本題。</h3>
<p>で、coffeescriptってjsにコンパイルしなきゃいけないんですが毎度叩くのもなんだかなーて感じだったので<a href="https://github.com/mynyml/watchr" target="_blank" class="external">watchr</a>ていうgemがあったのでこいつをインストール。</p>
<ul>
<li>coffee_compile.watchr
<div class="pre code">
<pre class="code">coffee_files = <span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span>^<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span>\.<span style="color:#9900CC;">coffee</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">&#125;</span>

watch<span style="color:#006600; font-weight:bold;">&#40;</span>coffee_files<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; cmd = <span style="color:#996600;">&quot;coffee --bare --compile .&quot;</span>
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;$#{cmd}&quot;</span>
&nbsp; <span style="color:#996600;">`#{cmd}`</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</li>
</ul>
<p>で、下記で実行。</p>
<div class="pre">
<pre class="code">watchr -d coffee_compile.watchr
</pre>
</div>
<p>しかし、追加ファイル感知してくれないとか、ファイル削除のイベントがなぜか止まらないとかあったので、結局使わなくなったり。</p>
<h3 class="contentsTitle">というわけで、毎度コンパイル叩くことにしたんだけど、</h3>
<p>ちょっとは楽しようということでRakefile書いた</p>
<ul>
<li>Rakefile
<div class="pre code">
<pre class="code">task <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;coffee:compile&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>

<span style="color:#9966CC; font-weight:bold;">def</span> show_and_cmd<span style="color:#006600; font-weight:bold;">&#40;</span>title, cmd = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp; cmd = title <span style="color:#9966CC; font-weight:bold;">if</span> cmd.<span style="color:#0000FF; font-weight:bold;">nil</span>?
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>===== <span style="color:#008000; font-style:italic;">#{title} =====}</span>
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>$<span style="color:#008000; font-style:italic;">#{cmd}}</span>
&nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> cmd
<span style="color:#9966CC; font-weight:bold;">end</span>

namespace <span style="color:#ff3333; font-weight:bold;">:coffee</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; desc <span style="color:#996600;">&quot;Compile coffee scripts&quot;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:compile</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'compile coffee'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>coffee <span style="color:#006600; font-weight:bold;">--</span>bare <span style="color:#006600; font-weight:bold;">--</span>compile .<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>

&nbsp; desc <span style="color:#996600;">&quot;Watch coffee scripts&quot;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:watch</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; watchr_file = <span style="color:#996600;">'coffee_compile.watchr'</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'watching files'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>watchr <span style="color:#006600; font-weight:bold;">-</span>l <span style="color:#008000; font-style:italic;">#{watchr_file}}</span>
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">''</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'watch coffee'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>watchr <span style="color:#006600; font-weight:bold;">-</span>d <span style="color:#008000; font-style:italic;">#{watchr_file}}</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</li>
</ul>
<p>これで、</p>
<div class="pre">
<pre class="code">rake #または rake coffee:compile
</pre>
</div>
<p>でコンパイルできるぜー。ひゃっほい。</p>
<p>いちおう念のため、watchrのほうも</p>
<div class="pre">
<pre class="code">rake coffee:watch
</pre>
</div>
<p>でいけるようにしてたり。</p>
<h3 class="contentsTitle">あと、titaniumのほうも</h3>
<p>titaniumって普段はbuildやシミュレータの起動をtitanium developerてアプリを立ち上げといて、その中にあるボタンをぽちっとなするわけなんですが、毎度これ起動しとくのヤダナーと思ってたんですよ。</p>
<p>と思ってたら、なんかコマンドラインで叩けるらしいじゃないですか。<br />
<a href="http://d.hatena.ne.jp/kaz_konno/20110304/1299252675" target="_blank" class="external">コマンドラインでTitanium Mobileを操作する - kaz_konno’ blog: walkthisway</a></p>
<p>やったー！</p>
<p>というわけでRakefile修正。</p>
<div class="pre code">
<pre class="code">task <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'coffee:compile'</span>, <span style="color:#996600;">'titanium:run'</span><span style="color:#006600; font-weight:bold;">&#93;</span>

<span style="color:#9966CC; font-weight:bold;">def</span> show_and_cmd<span style="color:#006600; font-weight:bold;">&#40;</span>title, cmd = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp; cmd = title <span style="color:#9966CC; font-weight:bold;">if</span> cmd.<span style="color:#0000FF; font-weight:bold;">nil</span>?
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>===== <span style="color:#008000; font-style:italic;">#{title} =====}</span>
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>$<span style="color:#008000; font-style:italic;">#{cmd}}</span>
&nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> cmd
<span style="color:#9966CC; font-weight:bold;">end</span>

namespace <span style="color:#ff3333; font-weight:bold;">:titanium</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; desc <span style="color:#996600;">&quot;build &amp; run on iphone simulator&quot;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:run</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'build &amp; run'</span>, <span style="color:#996600;">'/Library/Application<span style="color:#000099;">\ </span>Support/Titanium/mobilesdk/osx/1.7.X/iphone/builder.py run ./'</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>

namespace <span style="color:#ff3333; font-weight:bold;">:coffee</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; desc <span style="color:#996600;">&quot;Compile coffee scripts&quot;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:compile</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'compile coffee'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>coffee <span style="color:#006600; font-weight:bold;">--</span>bare <span style="color:#006600; font-weight:bold;">--</span>compile .<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp; desc <span style="color:#996600;">&quot;Watch coffee scripts&quot;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:watch</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; watchr_file = <span style="color:#996600;">'coffee_compile.watchr'</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'watching files'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>watchr <span style="color:#006600; font-weight:bold;">-</span>l <span style="color:#008000; font-style:italic;">#{watchr_file}}</span>
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">''</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'watch coffee'</span>, <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>watchr <span style="color:#006600; font-weight:bold;">-</span>d <span style="color:#008000; font-style:italic;">#{watchr_file}}</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>

namespace <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; desc <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#123;</span>Show <span style="color:#996600;">&quot;git diff -- *.coffee&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:diff</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp; &nbsp; show_and_cmd <span style="color:#996600;">'git diff *.coffee'</span>, <span style="color:#996600;">'git diff -- <span style="color:#000099;">\*</span>.coffee'</span>
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
<p>「rake」で以下まとめて出来るようになったよー。</p>
<ol>
<li>coffeescriptのコンパイル</li>
<li>titaniumのビルド</li>
<li>iphone simulatorの起動</li>
</ol>
<p>やったー！</p>
<p><span style="color:brown">#ちなみにRakefieの最後に書いてあるrake git:diffはcoffeeファイルの差分だけ見たくてよく使うコマンドだったのでついでに追加しといた。</span></p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1701</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1701" />
	</item>
		<item>
		<title>【私的連絡】携帯復活したお</title>
		<link>http://ichi.fool.jp/blog/?p=1698</link>
		<comments>http://ichi.fool.jp/blog/?p=1698#comments</comments>
		<pubDate>Tue, 21 Jun 2011 10:26:59 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[雑記]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1698</guid>
		<description><![CDATA[無くしたのは結局まだ見つかんないんだけどね(´・ω・｀)
新たにまたIS03購入して使うことにしました。
電話番号やメアドは変わってません。
そして同期してなかったデータとかがだいぶすっとんでしまったので、今年に入って電 [...]]]></description>
			<content:encoded><![CDATA[<p>無くしたのは結局まだ見つかんないんだけどね(´・ω・｀)</p>
<p>新たにまたIS03購入して使うことにしました。<br />
電話番号やメアドは変わってません。</p>
<p>そして同期してなかったデータとかがだいぶすっとんでしまったので、今年に入って電話番号やらメアドを変更した方のデータがおそらく無くなってるかと。</p>
<p>というわけで、今年になって電話番号/メアド変えた方は再度ご連絡頂けるとありがたく。</p>
<p>よろしくおねがいしますー。</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1698</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1698" />
	</item>
		<item>
		<title>【私的連絡】携帯落とした。</title>
		<link>http://ichi.fool.jp/blog/?p=1696</link>
		<comments>http://ichi.fool.jp/blog/?p=1696#comments</comments>
		<pubDate>Tue, 14 Jun 2011 15:35:51 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[雑記]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1696</guid>
		<description><![CDATA[
この日曜日に携帯落としてしまいました(・´∀｀・)
未だに見つかっておりません。
というわけで、しばらくの間（今週末くらいまでかなー？）見つかることを祈りながら携帯ナシ生活しようと思います。
てなわけで、見つかるか新し [...]]]></description>
			<content:encoded><![CDATA[
<p>この日曜日に携帯落としてしまいました(・´∀｀・)<br />
未だに見つかっておりません。</p>
<p>というわけで、しばらくの間（今週末くらいまでかなー？）見つかることを祈りながら携帯ナシ生活しようと思います。</p>
<p>てなわけで、見つかるか新しい携帯にするまでの間は</p>
<ul>
<li>skype (id:ichi1s)</li>
<li>twitter (<a href="http://twitter.com/ichi_s" title="@:ichi_s" target="_blank" class="external">@:ichi_s</a>)</li>
<li>gmail</li>
</ul>
<p>のいずれかに連絡してもらえればと思いまする。</p>
<p>あと、もしも日曜からこれまでの間にメールや電話等してくれた方がいれば上記いずれかに再度連絡してみてもらえるとありがたいですー。</p>
<p>よろしくでーす。</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1696</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1696" />
	</item>
		<item>
		<title>mac 上書きコピー</title>
		<link>http://ichi.fool.jp/blog/?p=1694</link>
		<comments>http://ichi.fool.jp/blog/?p=1694#comments</comments>
		<pubDate>Thu, 24 Mar 2011 09:41:40 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[shell]]></category>

		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1694</guid>
		<description><![CDATA[置き換えじゃなくて上書きしたいときね。
毎回忘れて毎回ググって毎回あーこうだったこうだったてなるのでメモっとく。

cp -Rf hoge fuga


-Rオプションね。
]]></description>
			<content:encoded><![CDATA[<p>置き換えじゃなくて上書きしたいときね。</p>
<p>毎回忘れて毎回ググって毎回あーこうだったこうだったてなるのでメモっとく。</p>
<div class="pre code">
<pre class="code" type="bash">cp -Rf hoge fuga
</pre>
</div>
<p>-Rオプションね。</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1694</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1694" />
	</item>
		<item>
		<title>rails3 + jqueryで DELETEやらPOSTのリンクががが。</title>
		<link>http://ichi.fool.jp/blog/?p=1690</link>
		<comments>http://ichi.fool.jp/blog/?p=1690#comments</comments>
		<pubDate>Thu, 17 Feb 2011 07:18:47 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1690</guid>
		<description><![CDATA[rails3いじいじ中。

&#60;%= link_to 'ログアウト', user_session_path&#40;@current_user&#41;, :method =&#62; :delete %&#62;

み [...]]]></description>
			<content:encoded><![CDATA[<p>rails3いじいじ中。</p>
<div class="pre code">
<pre class="code"><span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to <span style="color:#996600;">'ログアウト'</span>, user_session_path<span style="color:#006600; font-weight:bold;">&#40;</span>@current_user<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:delete</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre>
</div>
<p>みたいなリンククリックすると『No Route matches』言われちゃう。</p>
<p>サーバーログのほうには、</p>
<div class="pre">
<pre class="code">Started GET "/user_sessions/1" for 127.0.0.1 at 2011-02-17 14:32:19 +0900

ActionController::RoutingError (No route matches "/user_sessions/1"):
</pre>
</div>
<p>みたく出てて、DELETEでもPOSTでもなくGETになっておられる、と。</p>
<p>あるぇー？ってことで色々試してみたけどよーわからん。<br />
というわけで<a href="http://twitter.com/masarakki" title="@:masarakki" target="_blank" class="external">@:masarakki</a>に相談してみたら、<strong>「DELETEとかのリンク処理してるjsおかしいんじゃね？」</strong>ということに。</p>
<h3 class="contentsTitle">おお。jsといえば、思い当たるフシがあるよ！ と。</h3>
<p><a href="http://d.hatena.ne.jp/parrot_studio/20101222/1293005513" target="_blank" class="external">3分でRails3+rspec+jquery+mysql開発環境を準備する - どっかのBlogの前置きのような</a></p>
<p>ここにあるようにrails3+jqueryでつくりはじめたんだけど</p>
<div class="pre">
<pre class="code">rails g jquery:install
</pre>
</div>
<p>でエラーでちゃってた。</p>
<div class="pre">
<pre class="code">      remove  public/javascripts/controls.js
      remove  public/javascripts/dragdrop.js
      remove  public/javascripts/effects.js
      remove  public/javascripts/prototype.js
    fetching  jQuery (1.5)
   identical  public/javascripts/jquery.js
   identical  public/javascripts/jquery.min.js
    fetching  jQuery UJS adapter (github HEAD)
/Users/ichi/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677: [BUG] Segmentation fault
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]

-- control frame ----------
c:0040 p:---- s:0195 b:0195 l:000194 d:000194 CFUNC  :connect
c:0039 p:0440 s:0192 b:0192 l:000608 d:000608 METHOD /Users/ichi/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677
c:0038 p:0011 s:0185 b:0185 l:000184 d:000184 METHOD /Users/ichi/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637
c:0037 p:0048 s:0182 b:0182 l:000181 d:000181 METHOD /Users/ichi/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626
c:0036 p:0646 s:0179 b:0179 l:000178 d:000178 METHOD /Users/ichi/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/open-uri.rb:306

〜以下略〜
</pre>
</div>
<p>前述のブログにはｷﾆｼﾅｲ！て書いてたから気にせずそのままいじってたんだけど、どうも本来ならあるはずのrails.jsとか入ってない状態のままになってたらしい。</p>
<h3 class="contentsTitle">というわけで教えてぐぐる先生した結果</h3>
<p><a href="https://github.com/rails/jquery-ujs" target="_blank" class="external">https://github.com/rails/jquery-ujs</a><br />
ここのREADMEの『Manual installation』にあるようにrails.jsをつっこんで、config/application.rbに</p>
<div class="pre code">
<pre class="code">config.<span style="color:#9900CC;">action_view</span>.<span style="color:#9900CC;">javascript_expansions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:defaults</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>jquery rails<span style="color:#006600; font-weight:bold;">&#41;</span></pre>
</div>
<p>てしたら、<strong>イケタ！！</strong></p>
<h3 class="contentsTitle">ちなみに</h3>
<p>相談した<a href="http://twitter.com/masarakki" title="@:masarakki" target="_blank" class="external">@:masarakki</a>によると、これmac特有の問題じゃなイカ？ とのこと。<br />
rubyのMLでちょうど同じような報告があったらしい。</p>
<p>フェー。</p>
<p>とりあえず、<a href="http://twitter.com/masarakki" title="@:masarakki" target="_blank" class="external">@:masarakki</a>△としておこう。</p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1690</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1690" />
	</item>
		<item>
		<title>行番号つけるだけ</title>
		<link>http://ichi.fool.jp/blog/?p=1687</link>
		<comments>http://ichi.fool.jp/blog/?p=1687#comments</comments>
		<pubDate>Wed, 16 Feb 2011 07:43:11 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[shell]]></category>

		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1687</guid>
		<description><![CDATA[macのterminalでワンライナー
対象の文をコピって

pbpaste &#124; ruby -ne 'puts &#34;#{$..to_s}\t#{$_}&#34;' &#124; pbcopy


rubyのオプションの- [...]]]></description>
			<content:encoded><![CDATA[<p>macのterminalでワンライナー</p>
<p>対象の文をコピって</p>
<div class="pre code">
<pre class="code" type="bash">pbpaste | ruby -ne 'puts &quot;#{$..to_s}\t#{$_}&quot;' | pbcopy
</pre>
</div>
<p>rubyのオプションの-pと-nの差忘れないようにめも from:<a href="http://www.ruby-lang.org/ja/man/html/Ruby_A4CEB5AFC6B0.html#a.a5.b3.a5.de.a5.f3.a5.c9.a5.e9.a5.a4.a5.f3.a5.aa.a5.d7.a5.b7.a5.e7.a5.f3" target="_blank" class="external">Rubyの起動</a></p>
<blockquote><p class="modPuki_quotation"><strong>-n</strong><br />
このフラグがセットされるとプログラム全体が sed -nやawk のように</p>
<blockquote><p class="modPuki_quotation">while gets<br />
&#8230;<br />
end</p>
</blockquote>
<p class="modPuki_quotation">で囲まれているように動作します.</p>
</blockquote>
<blockquote><p class="modPuki_quotation"><strong>-p</strong><br />
-nフラグとほぼ同じですが, 各ループの最後に変数 $_ の値を出力するようになります。<br />
例:</p>
<blockquote><p class="modPuki_quotation">% echo matz | ruby -p -e &#8216;$_.tr! &quot;a-z&quot;, &quot;A-Z&quot;&#8217;<br />
MATZ</p>
</blockquote>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1687</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1687" />
	</item>
		<item>
		<title>macで全角カナ←→半角カナの変換</title>
		<link>http://ichi.fool.jp/blog/?p=1678</link>
		<comments>http://ichi.fool.jp/blog/?p=1678#comments</comments>
		<pubDate>Thu, 06 Jan 2011 06:06:17 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[shell]]></category>

		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1678</guid>
		<description><![CDATA[Terminalでnkf使うとはやいね。
半角カナを全角カナへ

echo 'ｳﾝｺ' &#124; nkf -W


出力結果

ウンコ


全角カナを半角カナへ
Z4オプションで変換できるみたい。

echo 'ウンコ' &#124;  [...]]]></description>
			<content:encoded><![CDATA[<p>Terminalでnkf使うとはやいね。</p>
<h3 class="contentsTitle">半角カナを全角カナへ</h3>
<div class="pre code">
<pre class="code" type="ｂash">echo 'ｳﾝｺ' | nkf -W
</pre>
</div>
<p><span style="color:brown">出力結果</span></p>
<div class="pre">
<pre>ウンコ
</pre>
</div>
<h3 class="contentsTitle">全角カナを半角カナへ</h3>
<p>Z4オプションで変換できるみたい。</p>
<div class="pre code">
<pre class="code" type="ｂash">echo 'ウンコ' | nkf -W -Z4
</pre>
</div>
<p><span style="color:brown">出力結果</span></p>
<div class="pre">
<pre>ｳﾝｺ
</pre>
</div>
<h3 class="contentsTitle">ちょこっと変換したいだけなのにechoとかめんどくさいです＞＜</h3>
<p>macだとコピーとペーストのコマンドがそれぞれ『pbcopy』と『pbpaste』なので、<br />
変換したい文字列をコピーして、</p>
<div class="pre code">
<pre class="code" type="bash">pbpaste | nkf -W | pbcopy
</pre>
</div>
<p>そして、おもむろに貼りつけ。</p>
<p><strong>やったー！ できたよー！</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1678</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1678" />
	</item>
		<item>
		<title>paginate</title>
		<link>http://ichi.fool.jp/blog/?p=1675</link>
		<comments>http://ichi.fool.jp/blog/?p=1675#comments</comments>
		<pubDate>Mon, 06 Sep 2010 07:34:44 +0000</pubDate>
		<dc:creator>ichi</dc:creator>
		
		<category><![CDATA[cakephp]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ichi.fool.jp/blog/?p=1675</guid>
		<description><![CDATA[ここの存在すら忘れてた。
たまにmemoがわりに使ってこう。

/name/action/1?type=f


みたいに適当にgetでパラメータ渡してるとこでのページング。
よく忘れるので書いとく。
そのままだとページ送 [...]]]></description>
			<content:encoded><![CDATA[<p>ここの存在すら忘れてた。<br />
たまにmemoがわりに使ってこう。</p>
<div class="pre">
<pre>/name/action/1?type=f
</pre>
</div>
<p>みたいに適当にgetでパラメータ渡してるとこでのページング。</p>
<p>よく忘れるので書いとく。</p>
<p>そのままだとページ送りしたらパラメータ消えるので<br />
controller側で</p>
<div class="pre code">
<pre class="code"><code><span style="color: #000000"><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">passedArgs</span><span style="color: #007700">[</span><span style="color: #DD0000">'type'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'f'</span><span style="color: #007700">; </span><span style="color: #0000BB"></span></span></code></pre>
</div>
<p>みたいにして、view側では</p>
<div class="pre code">
<pre class="code"><code><span style="color: #000000"><span style="color: #0000BB"></span><span style="color: #007700">if(isset(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">passedArgs</span><span style="color: #007700">)) </span><span style="color: #0000BB">$paginator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">options</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'url' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">passedArgs</span><span style="color: #007700">)); </span><span style="color: #0000BB"></span></span></code></pre>
</div>
<p>てかんじのも忘れずに。</p>
<p><span style="color:brown">＃ひさびさすぎてここに書く記法わすれとるし。</span></p>
]]></content:encoded>
			<wfw:commentRss>http://ichi.fool.jp/blog/?feed=rss2&amp;p=1675</wfw:commentRss>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ichi.fool.jp/blog/?p=1675" />
	</item>
	</channel>
</rss>

