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

<channel>
	<title>Vantage Point of Queens &#187; Tech</title>
	<atom:link href="http://blog.nydd.org/topic/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nydd.org</link>
	<description>Art, Hack and Rock'n Roll</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:59:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wordpress Plugin for Meetup Everywhere</title>
		<link>http://blog.nydd.org/2010/06/wordpress-plugin-for-meetup-everywhere/</link>
		<comments>http://blog.nydd.org/2010/06/wordpress-plugin-for-meetup-everywhere/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:43:10 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=321</guid>
		<description><![CDATA[				This allows you to control Meetup Everywhere from your Wordpress site!
				Please be noted that this is still very experimental.
				Go to Github: beatak / Meetup-Everywhere-WordPress-plugin
				Requirement
				
				WordPress 2.9 and after?
				
				Version 0.1
				Todos
				
				Clean up widget&#8217;s visual (it should look similar to the official widget?)
				Organize config pages
				Reflect changes on config page to Meetup Everywhere
				
]]></description>
			<content:encoded><![CDATA[				<p>This allows you to control Meetup Everywhere from your Wordpress site!</p>
				<p>Please be noted that this is still very experimental.</p>
				<p><strong>Go to Github: <a href="http://github.com/beatak/Meetup-Everywhere-WordPress-plugin">beatak / Meetup-Everywhere-WordPress-plugin</a></strong></p>
				<p><strong>Requirement</strong></p>
				<ul>
				<li>WordPress 2.9 and after?</li>
				</ul>
				<p><strong>Version 0.1</strong><br />
				<em>Todos</em></p>
				<ul>
				<li>Clean up widget&#8217;s visual (it should look similar to the official widget?)</li>
				<li>Organize config pages</li>
				<li>Reflect changes on config page to Meetup Everywhere</li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2010/06/wordpress-plugin-for-meetup-everywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gitosis をインストール</title>
		<link>http://blog.nydd.org/2010/01/gitosis%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/</link>
		<comments>http://blog.nydd.org/2010/01/gitosis%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 06:00:33 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=306</guid>
		<description><![CDATA[				仕事場では昨年から git を使っています。svn と比べていろんな利点があるとは思いますが、スピードが僕には捨てがたいです。というわけで自分用の git サーバーを立てたいのですが、管理を全て、というのはちょっと面倒くさいし… そこで gitosis という管理ツール群を見つけました。
				日本語で書かれたものとして openbooth さんの gitosis &#8211; Git リポジトリ群の管理とアクセス制御 vol.1が非常によく纏まっています。僕は Install (Set Up) Git and Gitosis on Ubuntu を参考にしました。
				解説は上に上げたページを参考にしてもらうとして僕が少しハマったところを解説します。
				
				sudo python setup.py install は gitosis-init, gitosis-run-hook, gitosis-serve を /usr/bin 以下にセットアップする
				gitosis-init は実行したユーザのホームディレクトリに repositories ディレクトリなどを勝手に作ってくれる
				sudo chmod u+x /var/git/repositories/gitosis-admin.git/hooks/post-update は絶対にする。逆に他の hooks script は +x である必要はない
				クライアント側でする最初のタスクは、git 開発の手順通り、git clone ssh://GIT_USER_NAME@YOUR.HOST.NAME/gitosis-admin.git git clone の url がわからなかったらマニュアル参照: [...]]]></description>
			<content:encoded><![CDATA[				<p>仕事場では昨年から git を使っています。svn と比べていろんな利点があるとは思いますが、スピードが僕には捨てがたいです。というわけで自分用の git サーバーを立てたいのですが、管理を全て、というのはちょっと面倒くさいし… そこで gitosis という管理ツール群を見つけました。</p>
				<p>日本語で書かれたものとして openbooth さんの gitosis &#8211; <a href="http://openbooth.org/archives/65.html">Git リポジトリ群の管理とアクセス制御 vol.1</a>が非常によく纏まっています。僕は <a href="http://blog.agdunn.net/?p=277">Install (Set Up) Git and Gitosis on Ubuntu</a> を参考にしました。</p>
				<p>解説は上に上げたページを参考にしてもらうとして僕が少しハマったところを解説します。</p>
				<ul>
				<li><code class="prettyprint">sudo python setup.py install</code> は <code class="prettyprint">gitosis-init, gitosis-run-hook, gitosis-serve</code> を /usr/bin 以下にセットアップする</li>
				<li><code class="prettyprint">gitosis-init</code> は実行したユーザのホームディレクトリに repositories ディレクトリなどを勝手に作ってくれる</li>
				<li><code class="prettyprint">sudo chmod u+x /var/git/repositories/gitosis-admin.git/hooks/post-update</code> は絶対にする。逆に他の hooks script は +x である必要はない</li>
				<li>クライアント側でする最初のタスクは、git 開発の手順通り、<code class="prettyprint">git clone ssh://GIT_USER_NAME@YOUR.HOST.NAME/gitosis-admin.git</code> git clone の url がわからなかったらマニュアル参照: <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">git-clone(1)</a> 僕は ssh に 22 を使っていないので、<code class="prettyprint">git clone ssh://GIT_USER_NAME@YOUR.HOST.NAME:PORT_NUM/gitosis-admin.git</code> のようになりました。</li>
				<li>gitosis.conf を編集して、新しいレポジトリを作る時、writable にするのを忘れない。そして keyfiles に ユーザの ssh public key を追加するのを忘れない。</li>
				<li>一番最初に 新しい repository を追加する前に、僕のように ssh:22 で無い人は、client 側の ssh_config に、
				<pre><code class="prettyprint">Host YOUR.HOST.NAME
Port PORT
IdentityFile ~/.ssh/id_rsa
Protocol 2</code></pre>
				<p>を追加しておく必要あり。そうしないと <code>git remote add origin GIT_USER_NAME@YOUR.HOST.NAME:PROJECT_NAME.git</code> が実行できない</li>
				</ul>
				<p>あと、エラーがでて git push が成功しなくても、サーバにログインして fix しちゃダメだよね。このツールはサーバに git を使って git を管理できるってのが売りだし。おそらく次回は commit hook の設定の仕方かな？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2010/01/gitosis%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update SSL Certificate</title>
		<link>http://blog.nydd.org/2010/01/update-ssl-certificate/</link>
		<comments>http://blog.nydd.org/2010/01/update-ssl-certificate/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 04:45:33 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=302</guid>
		<description><![CDATA[				あけましておめでとうございます。本年もどうぞよろしく。2009 年のまとめもせずに、本題に入ります。
				僕は別のサイトで、CAcert.org を利用して、いわゆるオレオレ証明書ではない、https 通信を実現しています。利用者に root 証明書のインストールを要求するので、本質的にオレオレと変わりない、という批判は受け入れます。が、これ以降 CAcert がどう化けるかわかりませんし、証明書作成のプロセスの勉強にもなります。
				なお本記事の多くは以下のページに依りました。
				CACert.orgで無料のSSLサーバを動かすメモ [FreeBSD](fkimura.com)
				今回は更新なので、domain の登録は済んでいるものとします。Domain の登録に必要なのは、メールアドレスだけです。
				作業手順
				
				サーバ秘密鍵作成の作成 openssl genrsa -rand /var/log/messages -des3 -out /path/to/example.key 1024 54002 semi-random bytes loadedパスワードは後で使うことは、あまり、ない。
				証明書申請データの作成 openssl req -new -key /path/to/example.key -out /usr/local/etc/apache2/ssl.key/example.jp.csrここで唯一のハマりどころはCommon Name [CN] が、登録済みの domain と一致する必要がある、ということ。
				証明書申請データを提出する
				(1)で作成したキーのパスフレーズを解除する
				今回作成した 4 ファイルの permission を全て 600 にする
				httpd.conf をアップデート
				
				fkimura.com に書いてあるそのままなんですが、あまりやらない作業はなんとなくやりたくない、という心理障壁になります。blog に書いておけば、また半年後やる時に、思い返せるでしょう。
				というわけで本年もどうぞよろしく。
]]></description>
			<content:encoded><![CDATA[				<p>あけましておめでとうございます。本年もどうぞよろしく。2009 年のまとめもせずに、本題に入ります。</p>
				<p>僕は別のサイトで、<a href="https://www.cacert.org/">CAcert.org</a> を利用して、いわゆるオレオレ証明書ではない、https 通信を実現しています。利用者に root 証明書のインストールを要求するので、本質的にオレオレと変わりない、という批判は受け入れます。が、これ以降 CAcert がどう化けるかわかりませんし、証明書作成のプロセスの勉強にもなります。</p>
				<p>なお本記事の多くは以下のページに依りました。</p>
				<p><a href="http://freebsd.fkimura.com/cacert-a0.html">CACert.orgで無料のSSLサーバを動かすメモ [FreeBSD](fkimura.com)</a></p>
				<p>今回は更新なので、domain の登録は済んでいるものとします。Domain の登録に必要なのは、メールアドレスだけです。</p>
				<h4>作業手順</h4>
				<ol>
				<li>サーバ秘密鍵作成の作成 <br /><code>openssl genrsa -rand /var/log/messages -des3 -out /path/to/example.key 1024 54002 semi-random bytes loaded</code><br />パスワードは後で使うことは、あまり、ない。</li>
				<li>証明書申請データの作成 <br /><code>openssl req -new -key /path/to/example.key -out /usr/local/etc/apache2/ssl.key/example.jp.csr</code><br />ここで唯一のハマりどころはCommon Name [CN] が、登録済みの domain と一致する必要がある、ということ。</li>
				<li>証明書申請データを提出する</li>
				<li>(1)で作成したキーのパスフレーズを解除する</li>
				<li>今回作成した 4 ファイルの permission を全て 600 にする</li>
				<li>httpd.conf をアップデート</li>
				</ol>
				<p>fkimura.com に書いてあるそのままなんですが、あまりやらない作業はなんとなくやりたくない、という心理障壁になります。blog に書いておけば、また半年後やる時に、思い返せるでしょう。</p>
				<p>というわけで本年もどうぞよろしく。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2010/01/update-ssl-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs Again (9): some tips and not to be purist.</title>
		<link>http://blog.nydd.org/2009/10/emacs-again-9-some-tips-and-not-to-be-purist/</link>
		<comments>http://blog.nydd.org/2009/10/emacs-again-9-some-tips-and-not-to-be-purist/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 03:26:56 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=296</guid>
		<description><![CDATA[				I got some reactions about Emacs via Twitter/Facebook.
				
				Gary B at work told me about this command.
				
(global-set-key "\C-x\C-m" 'execute-extended-command)

				It sets up another key stroke (C-x C-m) for &#8220;execute-extended-command&#8220;, which you can do with M-x as default.  I was also originally thinking that &#8220;execute-extended-command&#8221; is such a frequent command and why Emacs doesn&#8217;t assign with Control [...]]]></description>
			<content:encoded><![CDATA[				<p>I got some reactions <a href="http://blog.nydd.org/2009/10/10/emacs-again-8-recent-commands/">about Emacs</a> via Twitter/Facebook.</p>
				<hr />
				<p><a href="http://www.facebook.com/that.gary">Gary B</a> at work told me about this command.</p>
				<pre class="prettyprint"><code>
(global-set-key "\C-x\C-m" 'execute-extended-command)
</code></pre>
				<p>It sets up another key stroke (<code>C-x C-m</code>) for &#8220;<code>execute-extended-command</code>&#8220;, which you can do with <code>M-x</code> as default.  I was also originally thinking that &#8220;<code>execute-extended-command</code>&#8221; is such a frequent command and why Emacs doesn&#8217;t assign with Control key instead of Meta.  As Gary told me &#8220;it&#8217;ll grow on you.&#8221;  For me personally at this moment, I have no problems with doing <code>M-x</code>, but we&#8217;ll see.  At least now I know how to do it. <img src='http://blog.nydd.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
				<hr />
				<p><a href="http://twitter.com/swh">Steph</a> told me 3 things at one message.</p>
				<pre class="prettyprint"><code>M-x occur</code></pre>
<p>is absolute useful.  My initial reaction was, &#8220;Hmm, it looks similar to tag jump?&#8221;  But I was wrong.  Because it takes regex, it can do a lot more flexible, and more over it&#8217;s on the fly.  Neat!</p>
<pre class="prettyprint"><code>M-x align-regexp</code></pre>
				<p>I haven&#8217;t used it yet but looks nice.  And I found this page: <a href=" http://www.emacswiki.org/emacs/AlignCommands">Emacs wiki &#8212; Align commands</a> comes with tons of other useful tricks for aligning.</p>
				<pre class="prettyprint"><code>Also % for finding the matching brace.</code></pre>
<p>I found <code>M-C-f</code> (forward) and <code>M-C-b</code> (backward) in order to do that.  How do I do with % sign?</p>
<hr />
<p>Before I used Emacs on my dev box only very once in a while and I couldn&#8217;t like for various reasons.  One of the biggest glitch was, lots of my config wasn&#8217;t simply working.  So, I setup .emacs.el and .emacs.d on my linux dev box today.  It was not still working, then I realize &#8220;Hmm, maybe I can update Emacs.&#8221;  Gentoo default was 21.  22 was installed, but not defaultly used.  And latest is 23.  Why not?  Boon, here you go.  Emacs 23 works perfectly fine now.</p>
<p>As I explained before (<a href="http://blog.nydd.org/2009/03/02/emacs-again-1-config/">Emacs Again (1): config</a>), I setup all Emacs related config files on Dropbox.  I know you can setup Dropbox on Linux but since all dev at work can log into my dev box, I don&#8217;t wanna do that.  So what I did was setup rsync script on both my work mac and my linux box.</p>
<pre class="prettyprint"><code>
#!/bin/sh                                                                                

rsync --progress -a --rsh='ssh -p22' $HOME/Dropbox/Config/emacs/ takashi@my.devbox.local:emacs/ --exclude 'auto-save-list' --exclude '.DS_Store' --exclude 'tramp'
</code></pre>
				<p>then I run this command everyday.  Yay.</p>
				<hr />
				<p>One last thing is about permission issue.  I believe I talked about this with <a href="http://readystate4.com/">Mauvis</a> before (and I don&#8217;t remember what he does, sorry!).</p>
				<p>If you start to use Emacs, then you wanna do every text editing in Emacs.  But what if you wanna edit something that requires root permission.  You can do <code>sudo emacs /something/important</code>  Yeah, you can do it but&#8230; It&#8217;s not efficient at all.</p>
				<p>One other way I found was using <a href="http://www.emacswiki.org/emacs/TrampMode">tramp</a>.  But I don&#8217;t like the idea because it implicitly requires that you can login as root via ssh on your localhost.  I think it&#8217;s definitely a nice hack but I don&#8217;t like the solution.  And I talked to Gary about it, and he said &#8220;<strong>then I use vi.</strong>&#8221;  <em>Touché</em>, Gary.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/10/emacs-again-9-some-tips-and-not-to-be-purist/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Emacs Again (8): Recent Commands</title>
		<link>http://blog.nydd.org/2009/10/emacs-again-8-recent-commands/</link>
		<comments>http://blog.nydd.org/2009/10/emacs-again-8-recent-commands/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 00:12:20 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=293</guid>
		<description><![CDATA[				I know some of them appeared before, but I re-find them again and again.  That&#8217;s how you learn it, right?
				
				
				
				Key Stroke
				Command Name
				Action
				
				
				
				
				M-;
				comment-dwim
				comment or uncomment the selected region
				
				
				M-g g
				goto-line
				Interestingly M-g g and  M-g M-g are the same goto-line.  Very self explainatory.
				
				
				C-M-\
				indent-region
				self explainatory. Without argument, Emacs will automatically find suitable indent. If you do [...]]]></description>
			<content:encoded><![CDATA[				<p>I know some of them appeared before, but I re-find them again and again.  That&#8217;s how you learn it, right?</p>
				<table>
				<thead>
				<tr>
				<th><code>Key Stroke</code></th>
				<th><code>Command Name</code></th>
				<th>Action</th>
				</tr>
				</thead>
				<tbody>
				<tr>
				<td><code>M-;</code></td>
				<td><code>comment-dwim</code></td>
				<td>comment or uncomment the selected region</td>
				</tr>
				<tr>
				<td><code>M-g g</code></td>
				<td><code>goto-line</code></td>
				<td>Interestingly <code>M-g g</code> and  <code>M-g M-g</code> are the same goto-line.  Very self explainatory.</td>
				</tr>
				<tr>
				<td><code>C-M-\</code></td>
				<td><code>indent-region</code></td>
				<td>self explainatory. Without argument, Emacs will automatically find suitable indent. If you do throw argument like <code>C-u 10 C-M-\</code> then it adds 10 spaces (or tab. depends on your mode) in the beginning of the selected region.</td>
				</tr>
				<tr>
				<td><code>C-j</code></td>
				<td><code>eval-print-last-sexp</code></td>
				<td>You can only do this in &#8220;Lisp-Interaction&#8221; mode? Evaluate expression on.  You can use it as temporary command.  As usual, it display the last return value.</td>
				</tr>
				<tr>
				<td><code>C-x 3</code></td>
				<td><code>split-window-horizontally</code></td>
				<td>Split current window into two windows side by side.  Vertical split is <code>C-x 2</code>.  If you want to get windows back into 1 window do <code>C-x 0</code> or <code>C-x 1</code>.  <code>1</code> brings you to absolutely 1 window and 0 make split windows back to 1 (it makes difference when you have multiple sprits).  If you want to switch between windows, do <code>C-x o</code>.</td>
				</tr>
				<tr>
				<td><code>C-_</code></td>
				<td><code>undo</code></td>
				<td>Undo and redo, smartly executed.  It says _(underscore) but you basically can do as -(minus sign).  Maybe because I use US-ASCII layouted keyboard.  Those two characters are assigned on the same key, so I don&#8217;t have to hold Shift key in order to type _(underscore).</td>
				</tr>
				<tr>
				<td><code>C-g C-_</code></td>
				<td><code>cancel undo</code></td>
				<td>Explicitly you can redo by doing this.</td>
				</tr>
				</tbody>
				</table>
				<h4>Change Split Ratio</h4>
				<p>So I was wondering if I can change the window split ratio, when I do C-x 2 or C-x 3.  I asked it on IRC, and somebody immediately answer me.  It&#8217;s simple, as Emacs way.  You pass the argument.</p>
				<pre><code>
C-u 20 C-x 3
</code></pre>
				<p>So this will make left side 20 cursor width and split window vertically.</p>
				<h4>Community channel</h4>
				<p>Related to the preceding section, you can ask question on IRC.  And also there is a twitter account <a href="http://twitter.com/learnemacs">@learnemacs</a>, and he (or she) can answer your question if you tweet something.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/10/emacs-again-8-recent-commands/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript code review 000</title>
		<link>http://blog.nydd.org/2009/08/javascript-code-review-000/</link>
		<comments>http://blog.nydd.org/2009/08/javascript-code-review-000/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 03:44:27 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=280</guid>
		<description><![CDATA[				今日は指向を変えて、JavaScript の code review をしてみたいと思います。DOM の操作をする以下のような DOM ノードとスクリプトがあるとします。
				&#60;div class="description expandTo_500 canToggle"&#62;...&#60;/div&#62;
&#60;script type="text/javascript"&#62;
var someFunction = function (elm) {
  var classes = elm.className.split(' ');
  for( var i in classes )
    if( /^expandTo_[0-9]*/.test( classes[i] ) )
      var lim_char = Number( classes[i].split('_')[1] );
  ...
};
&#60;/script&#62;
				ぱっと見て、何をするかまぁだいたいわかると思うんですが、この someFunction が実行されると、引数として受け取った element を、その [...]]]></description>
			<content:encoded><![CDATA[				<p>今日は指向を変えて、JavaScript の code review をしてみたいと思います。DOM の操作をする以下のような DOM ノードとスクリプトがあるとします。</p>
				<pre><code class="prettyprint">&lt;div class="description expandTo_500 canToggle"&gt;...&lt;/div&gt;
&lt;script type="text/javascript"&gt;
var someFunction = function (elm) {
  var classes = elm.className.split(' ');
  for( var i in classes )
    if( /^expandTo_[0-9]*/.test( classes[i] ) )
      var lim_char = Number( classes[i].split('_')[1] );
  ...
};
&lt;/script&gt;</code></pre>
				<p>ぱっと見て、何をするかまぁだいたいわかると思うんですが、この someFunction が実行されると、引数として受け取った element を、その class にある一定の数字を解析して、それによって何かの処理をしたい、ということだと思います。</p>
				<p>問題としたいのは以下の 4点あります。</p>
				<ul>
				<li>curly braces の欠如</li>
				<li>array の 列挙</li>
				<li>Number Objectの使用</li>
				<li>正規表現を有効につかっていない</li>
				</ul>
				<p>では順番に見ていきましょう。</p>
				<h4>curly braces の欠如</h4>
				<p><a href="http://www.flickr.com/photos/beatak/3328026346/" title="JavaScript: The Good Parts by Douglas Crockford by beatak, on Flickr" style="display: block; float:left; margin: 0 7px 7px 0;"><img src="http://farm4.static.flickr.com/3377/3328026346_6f640b60a4_m.jpg" width="240" height="201" alt="JavaScript: The Good Parts by Douglas Crockford" /></a>文法がそれを許している限り、これは好みの問題だ、という見方もあるんですが、<a href="http://www.crockford.com/javascript/">Douglas Crockford</a> によれば &#8220;Style isn&#8217;t subjective&#8221; だそうです。僕もそう思います。Curly braces はいかなる状況でも、省略すべきではないです。</p>
				<h4 style="clear:both;">array の 列挙</h4>
				<p>array 型の内容を列挙する時、JavaScript では、２つの方法があります。</p>
				<pre><code class="prettyprint">var arr1 = [0, 1, 2, 3, 4];
for (var i = 0, len = arr1.length; i &lt; len; ++i) {
  console.log(arr1[i]);
}

var arr2 = [0, 1, 2, 3, 4];
for (var j in arr2) {
  console.log(arr2[j]);
}</code></pre>
				<p> 上記の二つの for ループは、基本的に同じことを目的としてしていますし、多くの場合は同じ結果をもたらすと思いますが、後者は違う結果をもたらす可能性があります。for の中で使用される in 演算子はもともと object のプロパティを列挙する為にあって、array の列挙の為ではありません。例えば <code class="prettyprint">Array.prototype.foo = '99';</code> という文がアプリケーションのどこかにあると、それだけで違う結果をもたらします。Crockford氏の <a href="http://www.jslint.com/">jslint</a> を使うと、for (&#8230;in&#8230;) は object の列挙の時ですら、 hasOwnProperty を一緒に用いないと、警告が出ます。</p>
				<h4>Number Object の使用</h4>
				<p>number型、boolean型、string型、には、wrapper クラスが存在するのですが、これを使う十分な理由、というのは僕には考えられません。前にも一度書きましたが、ポインタの比較をしたい時（というのがもしあれば、ですが）に、確かにこれらを使うことはできますが…ここでしているようなことの為なら parseInt で十分でしょう。</p>
				<h4>正規表現を有効につかっていない</h4>
				<p>さて最後に、文字列から数字を取り出すのに、split を使うのはもったいないです。せっかく正規表現で確認しているわけですから、一緒に切り出し作業もしてもらいましょう。</p>
				<p>というわけで、書き直したコードを以下に。</p>
				<pre><code class="prettyprint">
var someFunction = function (elm) {
  var classes = elm.className.split(' ');
  var matches;
  var regex = /expandTo_(\d+)/;
  for (var i = 0, len = classes.length; i &lt; len; ++i) {
    matches = classes[i].match(regex)
    if (matches) {
      var lim_char = parseInt(matches[1]);
    }
  ...
};</code></pre>
				<p>正規表現の一節以外は、ほとんど Douglas Crockford の受け売りになってしまいました。この本を読むと、Crockford氏の JavaScript に対する考え方を理解できると思います。（そして Java のような JavaScript を書くことになると思いますが…まぁそれはまた別の機会に。）</p>
				<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=grfdesign-22&#038;o=9&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=1X69VDGQCMF7Z30FM082&#038;asins=4873113911" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/08/javascript-code-review-000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meetup.Tweener 000: 簡単なアニメーション</title>
		<link>http://blog.nydd.org/2009/08/meetup-tweener-000-%e7%b0%a1%e5%8d%98%e3%81%aa%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3/</link>
		<comments>http://blog.nydd.org/2009/08/meetup-tweener-000-%e7%b0%a1%e5%8d%98%e3%81%aa%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 05:15:54 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[meetup.tweener]]></category>
		<category><![CDATA[japanese]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=275</guid>
		<description><![CDATA[				
				まずは非常に簡単なアニメーションをやってみましょう。Wireframe の Cube をクリックしてみてください。ジャンプ先のページでも見られますが、このアニメーションは以下のコードで実現されています。
				Meetup.Tweener.isUsing = 'jQuery'; // The Magic spell of using Tweener with jQuery
$(function(){ // jQuery way of DOM Ready
  var cube = document.getElementById('cube');
  $(cube).click(function(){
    Meetup.Tweener.addTween(
      cube,  // 1st arg: the target element
      {'left': '100%'} // 2nd arg: [...]]]></description>
			<content:encoded><![CDATA[				<p><a href="http://archive.nydd.org/meetup.tweener/helloworld/000/" title="Hello world to Meetup.Tweener: Easy animation by beatak, on Flickr"><img src="http://farm3.static.flickr.com/2438/3850768445_d2b5149de0.jpg" width="500" height="386" alt="Hello world to Meetup.Tweener: Easy animation" /></a></p>
				<p>まずは非常に簡単なアニメーションをやってみましょう。Wireframe の Cube をクリックしてみてください。ジャンプ先のページでも見られますが、このアニメーションは以下のコードで実現されています。</p>
				<pre><code class="prettyprint">Meetup.Tweener.isUsing = 'jQuery'; // The Magic spell of using Tweener with jQuery
$(function(){ // jQuery way of DOM Ready
  var cube = document.getElementById('cube');
  $(cube).click(function(){
    Meetup.Tweener.addTween(
      cube,  // 1st arg: the target element
      {'left': '100%'} // 2nd arg: animation property
    );
  });
});</code></pre>
				<p>ご覧の通り、Meetup.Tweener は AS3 Tweener と全く同じ、Tweener.addTween というメソッドの呼び出しで始まります。詳しい内容は次回以降お楽しみに、ということで。</p>
				<p><a href="http://www.flickr.com/photos/beatak/3850768445/" title="Hello world to Meetup.Tweener: Easy animation by beatak, on Flickr">Flickr: Hello world to Meetup.Tweener: Easy animation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/08/meetup-tweener-000-%e7%b0%a1%e5%8d%98%e3%81%aa%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World to Meetup.Tweener</title>
		<link>http://blog.nydd.org/2009/08/hello-world-to-meetup-tweener-ja/</link>
		<comments>http://blog.nydd.org/2009/08/hello-world-to-meetup-tweener-ja/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 05:04:38 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[meetup.tweener]]></category>
		<category><![CDATA[japanese]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=271</guid>
		<description><![CDATA[				今更、Hello World, という感じでもないんですが、Meetup.Tweener の解説記事を書いていこうと思います。
				Meetup.Tweener は僕が Open Source として開発している JavaScript のライブラリで、HTML + JavaScript の環境で非常に簡単にアニメーションを作ることができます。もし Flash での開発経験があれば、Tweener という Library は絶対聞いたことがあると思うのですが、Original の Tweener と API 互換性を持たせつつ、JavaScript 用に最適化をしています。
				今やどのメジャー JavaScript ライブラリもアニメーション機能があるというのになんでいまさらアニメーションライブラリ？と思われるかもしれません。Meetup.Tweener の利点は
				
				依存性は低く、（理論上では）どのメジャーライブラリとも共存できる
				長い間 Flash で培われた API
				Meetup での実用実績
				
				(1) に関して、今のところ対応しているのは jQuery と MochiKit だけなんですが、Prototype.js, MooTools, YUI, Dojo には対応する準備があります。(2) に関して、HTML5 が台頭してくるにあたって、多くの Flash 製作者が JavaScript に流れてくることが予想されます（楽観的）。彼らにとってなれしたしんできた syntax が使えるのはとても大きな資産になることでしょう。また、アニメーションをメジャーライブラリに頼らないことで、突然のコードベース変更にも強いでしょう。
				このライブラリは Google Adplanner によれば 6M の Unique Visitor [...]]]></description>
			<content:encoded><![CDATA[				<p>今更、Hello World, という感じでもないんですが、<a href="http://github.com/beatak/meetup.tweener/">Meetup.Tweener</a> の解説記事を書いていこうと思います。</p>
				<p>Meetup.Tweener は僕が Open Source として開発している JavaScript のライブラリで、HTML + JavaScript の環境で非常に簡単にアニメーションを作ることができます。もし Flash での開発経験があれば、<a href="http://code.google.com/p/tweener/">Tweener</a> という Library は絶対聞いたことがあると思うのですが、Original の Tweener と API 互換性を持たせつつ、JavaScript 用に最適化をしています。</p>
				<p>今やどのメジャー JavaScript ライブラリもアニメーション機能があるというのになんでいまさらアニメーションライブラリ？と思われるかもしれません。Meetup.Tweener の利点は</p>
				<ol>
				<li>依存性は低く、（理論上では）どのメジャーライブラリとも共存できる</li>
				<li>長い間 Flash で培われた API</li>
				<li>Meetup での実用実績</li>
				</ol>
				<p>(1) に関して、今のところ対応しているのは jQuery と MochiKit だけなんですが、Prototype.js, MooTools, YUI, Dojo には対応する準備があります。(2) に関して、HTML5 が台頭してくるにあたって、多くの Flash 製作者が JavaScript に流れてくることが予想されます（楽観的）。彼らにとってなれしたしんできた syntax が使えるのはとても大きな資産になることでしょう。また、アニメーションをメジャーライブラリに頼らないことで、突然のコードベース変更にも強いでしょう。</p>
				<p>このライブラリは <a href="https://www.google.com/adplanner/planning/site_profile#siteDetails?identifier=meetup.com&#038;lp=true">Google Adplanner によれば 6M の Unique Visitor をほこる Meetup.com</a> で運用の実績があります。実地で使われているものですから、問題があれば対処は素早く行われます。</p>
				<p>開発は <a href="http://github.com/beatak/meetup.tweener/">Github 上の meetup.tweener</a> レポジトリにて行われていて、<a href="http://beatak.github.com/meetup.tweener/">ドキュメントも Github 上</a>にあります。</p>
				<p>開発にあたって、Yuichi Tateno (id:secondlife) さんの <a href="http://hotchpotch.github.com/javascripts/JSTweener.js">JSTweener</a> を参考にさせていただきました。ありがとうございます。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/08/hello-world-to-meetup-tweener-ja/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>090823: learn</title>
		<link>http://blog.nydd.org/2009/08/090823-learn/</link>
		<comments>http://blog.nydd.org/2009/08/090823-learn/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 03:39:16 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[japanese]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=266</guid>
		<description><![CDATA[				diretory の比較 on Unix
				Wordpress をアップデート。いつも忘れてしまう diretory の比較。普段は Changes.app などという Mac OS X の GUI アプリを使ってしまって、いっこうに覚えなかった…
				How To Compare Directories in Unix
				$ diff --recursive --brief /tmp/dir1 /tmp/dir2
Files /tmp/dir1/dir11/file12 and /tmp/dir2/dir11/file12 differ
Files /tmp/dir1/file1 and /tmp/dir2/file1 differ
Only in /tmp/dir1: file2
Only in /tmp/dir2: file3
				これを応用すると、例えば dir1 にだけ存在するファイルは
				$ diff --recursive --brief /tmp/dir1 /tmp/dir2 &#124; grep '^Only \/tmp\/dir1'
とすればよいですね。
emacs で major mode を変える
例えば .html [...]]]></description>
			<content:encoded><![CDATA[				<h4>diretory の比較 on Unix</h4>
				<p>Wordpress をアップデート。いつも忘れてしまう diretory の比較。普段は <a href="http://connectedflow.com/changes/">Changes.app</a> などという Mac OS X の GUI アプリを使ってしまって、いっこうに覚えなかった…</p>
				<p><a href="http://www.unixtutorial.org/2008/06/how-to-compare-directories-in-unix/">How To Compare Directories in Unix</a></p>
				<pre><code class="prettyprint">$ diff --recursive --brief /tmp/dir1 /tmp/dir2
Files /tmp/dir1/dir11/file12 and /tmp/dir2/dir11/file12 differ
Files /tmp/dir1/file1 and /tmp/dir2/file1 differ
Only in /tmp/dir1: file2
Only in /tmp/dir2: file3</code></pre>
				<p>これを応用すると、例えば dir1 にだけ存在するファイルは</p>
				<pre><code class="prettyprint">$ diff --recursive --brief /tmp/dir1 /tmp/dir2 | grep '^Only \/tmp\/dir1'</code></pre>
<p>とすればよいですね。</p>
<h4>emacs で major mode を変える</h4>
<p>例えば .html なファイルを emacs で開くとほぼおそらく HTML mode で開かれると思います。でも実は内部の JavaScript を編集したいし、js2-mode (JavaScript-IDE) で編集したい。凄い基本ですがしばらく emacs を触ってないで忘れてしまっていました。</p>
<pre><code class="prettyprint">M-x js2-mode</code></pre>
				<p>でした。</p>
				<hr />
				<p>またこれから emacs 勉強記録をつけていきたいと思います。今日はどうやってコピーするのか忘れてましたが (M-w Copy / C-w Cut / C-y Paste) それさえわかれば、それなりに使えrて結構びっくりした。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/08/090823-learn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pseudo 3D by canvas2D</title>
		<link>http://blog.nydd.org/2009/08/pseudo-3d-by-canvas2d/</link>
		<comments>http://blog.nydd.org/2009/08/pseudo-3d-by-canvas2d/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 02:25:51 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[english]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=258</guid>
		<description><![CDATA[				Today, I had a Hack-a-thon day at my work.  Basically, no meeting, just do whatever you wanna do.  It should be related to the work, but it doesn&#8217;t have to (am I right?).  So I have been thinking that I wanted work on something 3D by using canvas and my Meetup.Tweener.  [...]]]></description>
			<content:encoded><![CDATA[				<p>Today, I had a Hack-a-thon day at my work.  Basically, no meeting, just do whatever you wanna do.  It should be related to the work, but it doesn&#8217;t have to (am I right?).  So I have been thinking that I wanted work on something 3D by using canvas and my <a href="http://github.com/beatak/meetup.tweener/">Meetup.Tweener</a>.  I read lots of articles (which I have done before as well..), and gosh, I forgot so much about matrix transformation.  But anyway, let me show you what I did.  It&#8217;s only half done but it&#8217;s still sort of interesting how much you can do with canvas.</p>
				<p><a href="http://archive.nydd.org/2009/aug/3d_by_canvas2d/">Fliping picture</a></p>
				<p>Click on picture, it will flip around.</p>
				<p>This is even worse than CSS transformation because it only works for x-axis scaling as opposed to, CSS transformation, you can do 3d, at least more 3D-ish, flipping animation.  BUT ANYWAY, this just fire on my heart to learn 3D again. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2009/08/pseudo-3d-by-canvas2d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
