<?xml version="1.0" encoding="UTF-8"?>




<rss version="2.0"> <channel> <title>Evernote Openbook: Programming Notes</title>
<link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes</link>
<description>Notes from ishikawa_takanori&#039;s  Evernote Openbook: Programming Notes</description> 

  
  <lastBuildDate>Thu, 24 Sep 2009 09:14:21 GMT</lastBuildDate>
 
  
  <item> <title>ISO C forbids conversion of object pointer to function&gt;pointer type</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#55f9f86c-5ccd-40cb-95c5-043914e69a6f</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">GCC: -ansi -pedantic で &quot;ISO C forbids conversion of object pointer to function&gt;pointer type&quot;<div><br clear="none"/></div><div>GCC options</div><div><a href="http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/C-Dialect-Options.html#C-Dialect-Options" shape="rect">http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/C-Dialect-Options.html#C-Dialect-Options</a><br clear="none"/></div><div><br clear="none"/></div><div>C Programming - function * = void *</div><div><a href="http://www.velocityreviews.com/forums/t443213-function--void-.html" shape="rect">http://www.velocityreviews.com/forums/t443213-function--void-.html</a><br clear="none"/></div><div><br clear="none"/></div><div>Generic Function Pointers In C And Void *</div><div><a href="http://www.safercode.com/blog/2008/11/25/generic-function-pointers-in-c-and-void.html" shape="rect">http://www.safercode.com/blog/2008/11/25/generic-function-pointers-in-c-and-void.html</a><br clear="none"/></div><div><br clear="none"/></div><div>ISO C++ forbids casting between pointer-to-function and pointer-to-object</div><div><a href="https://trac.osgeo.org/qgis/ticket/234" shape="rect">https://trac.osgeo.org/qgis/ticket/234</a><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Thu, 24 Sep 2009 09:14:21 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#55f9f86c-5ccd-40cb-95c5-043914e69a6f</guid> 
  
  </item>

  
  <item> <title>Mac OS X 10.5.7 で Sphinx を使おうとしてハマる</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#cb8da34e-71f9-44ba-bbaa-fbb2e75963a2</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote"><div>#344 (Jinja2 easy_install failing) - Jinja   Trac</div><a href="http://dev.pocoo.org/projects/jinja/ticket/344" shape="rect">http://dev.pocoo.org/projects/jinja/ticket/344</a><ul><li>C コードのコンパイルが問題？</li><li>--without-speedups<br clear="none"/></li></ul>マニュアルでインストール：<div><br clear="none"/></div><div><b>Jinja2 2.1.1</b><div><a href="http://pypi.python.org/pypi/Jinja2" shape="rect">http://pypi.python.org/pypi/Jinja2</a></div><div><br clear="none"/></div><div></div><div>% curl -LO http://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.1.1.tar.gz</div><div>% tar xvzf Jinja2-2.1.1.tar.gz</div><div>% cd Jinja2-2.1.1</div><div>% sudo python setup.py install</div><div></div><div><br clear="none"/></div><div><b>Sphinx 0.6.2</b></div><div><a href="http://pypi.python.org/pypi/Sphinx/0.6.2" shape="rect">http://pypi.python.org/pypi/Sphinx/0.6.2</a>                                 </div><div></div><div><br clear="none"/></div><div>% curl -LO http://pypi.python.org/packages/source/S/Sphinx/Sphinx-0.6.2.tar.gz</div><div>% tar xvzf Sphinx-0.6.2.tar.gz </div><div>% cd Sphinx-0.6.2</div><div>% sudo python setup.py install</div><div></div></div><div><br clear="none"/></div><div>Sphinx 0.6.2 では sphinx.builder が deprecated になったらしい</div><div><br clear="none"/></div><div>Running Sphinx v0.6.2<div>/Users/ishikawa/Developer/Workspace/Modipyd/modipyd/docs/ja/source/../../sphinxext/__init__.py:1: DeprecationWarning: The sphinx.builder module is deprecated; please import builders from the respective sphinx.builders submodules.</div><div><br clear="none"/></div><div>モジュール名を適切に直す</div><div><br clear="none"/></div><div>-from sphinx.builder import StandaloneHTMLBuilder<div>+from sphinx.builders.html import StandaloneHTMLBuilder</div><div></div></div></div><div><br clear="none"/></div><div><br clear="none"/></div><div>今度は日本語を含むドキュメントを変換しようとすると：<br clear="none"/></div><div><br clear="none"/></div><div><b>Exception occurred:<br clear="none"/></b></div><div><div><div><b>  File &quot;/Library/Python/2.5/site-packages/Sphinx-0.6.2-py2.5.egg/sphinx/themes/basic/layout.html&quot;, line 19, in block &quot;rootrellink&quot;</b></div><div><b>    &lt;li&gt;&lt;a href=&quot;{{ pathto(master_doc) }}&quot;&gt;{{ shorttitle|e }}&lt;/a&gt;{{ reldelim1 }}&lt;/li&gt;</b></div><div><b>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 8: ordinal not in range(128)</b></div><div>The full traceback has been saved in /var/folders/Xg/XgsbIugsGWiYSnTBrMoebU+++TI/-Tmp-/sphinx-err-cfE9NN.log, if you want to report the issue to the author.</div><div>Please also report this if it was a user error, so that a better error message can be provided next time.</div><div>Send reports to sphinx-dev@googlegroups.com. Thanks!</div><div><br clear="none"/></div><div>朝になって思いついた。conf に書いてた日本語テキストを unicode string に修正したら直った。</div><div>Jinja2 が unicode 対応したことが問題の原因だと思われる。</div></div></div></div>
    
    ]]></description> <pubDate>Sun, 26 Jul 2009 22:02:13 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#cb8da34e-71f9-44ba-bbaa-fbb2e75963a2</guid> 
  
  </item>

  
  <item> <title>Jetty 6.1.17 の依存パッケージ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#809be457-8913-4a33-ac00-a36d9d716f51</link>
  <description><![CDATA[
    
    
    
        
        <div style="background-color:#ffffff;" class="ennote"><div><b>% find jetty-6.1.17/modules/jetty -name *.java | xargs grep -hE '^import\b' | grep -vE -e 'org\.mortbay\.' -e 'javax?\.' | awk '{ print $2 }' | sort | uniq<br clear="none"/></b>junit.framework.AssertionFailedError;<br clear="none"/>junit.framework.TestCase;<br clear="none"/>junit.framework.TestSuite;<br clear="none"/>org.xml.sax.Attributes;<br clear="none"/>org.xml.sax.ContentHandler;<br clear="none"/>org.xml.sax.helpers.DefaultHandler;<br clear="none"/>org.xml.sax.InputSource;<br clear="none"/>org.xml.sax.SAXException;<br clear="none"/>org.xml.sax.SAXParseException;<br clear="none"/>org.xml.sax.XMLReader;<br clear="none"/><br clear="none"/><b>% find jetty-6.1.17/modules/util -name *.java | xargs grep -hE '^import\b' | grep -vE -e 'org\.mortbay\.' -e 'javax?\.' | awk '{ print $2 }' | sort | uniq<br clear="none"/></b>junit.framework.Test;<br clear="none"/>junit.framework.TestCase;<br clear="none"/>junit.framework.TestSuite;<br clear="none"/>junit.textui.TestRunner;<br clear="none"/><br clear="none"/><b>% find jetty-6.1.17 -name *.java | xargs grep -hE '^import\b' | grep -vE -e 'org\.mortbay\.' -e 'javax?\.' | awk '{ print $2 }' | sort | uniq<br clear="none"/></b>bsh.EvalError;<br clear="none"/>bsh.Interpreter;<br clear="none"/>com.acme.Derived;<br clear="none"/>com.gigaspaces.annotation.pojo.SpaceId;<br clear="none"/>com.gigaspaces.annotation.pojo.SpaceProperty;<br clear="none"/>com.gigaspaces.annotation.pojo.SpaceProperty.IndexType;<br clear="none"/>com.gigaspaces.annotation.pojo.SpaceRouting;<br clear="none"/>com.google.gwt.user.client.rpc.AsyncCallback;<br clear="none"/>com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;<br clear="none"/>com.google.gwt.user.client.rpc.RemoteService;<br clear="none"/>com.google.gwt.user.client.rpc.SerializationException;<br clear="none"/>com.google.gwt.user.server.rpc.OpenRemoteServiceServlet;<br clear="none"/>com.google.gwt.user.server.rpc.UnexpectedException;<br clear="none"/>com.j_spaces.core.client.Query;<br clear="none"/>com.j_spaces.core.client.SQLQuery;<br clear="none"/>com.sun.grizzly.Context;<br clear="none"/>com.sun.grizzly.Controller;<br clear="none"/>com.sun.grizzly.Controller.Protocol;<br clear="none"/>com.sun.grizzly.DefaultPipeline;<br clear="none"/>com.sun.grizzly.DefaultProtocolChain;<br clear="none"/>com.sun.grizzly.DefaultProtocolChainInstanceHandler;<br clear="none"/>com.sun.grizzly.DefaultSelectionKeyHandler;<br clear="none"/>com.sun.grizzly.filter.ReadFilter;<br clear="none"/>com.sun.grizzly.Pipeline;<br clear="none"/>com.sun.grizzly.ProtocolChain;<br clear="none"/>com.sun.grizzly.ProtocolFilter;<br clear="none"/>com.sun.grizzly.SelectorHandler;<br clear="none"/>com.sun.grizzly.TCPSelectorHandler;<br clear="none"/>com.sun.grizzly.util.OutputWriter;<br clear="none"/>com.sun.grizzly.util.SelectorFactory;<br clear="none"/>com.sun.grizzly.util.WorkerThread;<br clear="none"/>com.sun.net.httpserver.Authenticator;<br clear="none"/>com.sun.net.httpserver.Authenticator...</div></div>
    
    ]]></description> <pubDate>Sun, 26 Jul 2009 10:42:42 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#809be457-8913-4a33-ac00-a36d9d716f51</guid> 
  
  </item>

  
  <item> <title>jetty.xml</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#8613f4a2-ee07-4d1a-8f03-911ddb8e9011</link>
  <description><![CDATA[
    
    
    
        
        <div style="background-color:#ffffff;" class="ennote">
<div>Jetty 6.1.17 - jetty.xml</div>
<div> </div>
<div>1. ThreadPool (<a href="http://www.mortbay.org/jetty/jetty-6/apidocs/org/mortbay/thread/QueuedThreadPool.html" shape="rect">org.mortbay.thread.QueuedThreadPool</a>)</div>
<div> </div>
<div>QueuedThreadPool は再利用できるスレッドがない場合、要求（ジョブ）をキューに保存する。</div>
<div> </div>
<div>minThreads</div>
<div> </div>
<div>最小スレッド数。初期値は 2。</div>
<div> </div>
<div>maxThreads</div>
<div> </div>
<div>最大スレッド数。初期値は 250。</div>
<div> </div>
<div>spawnOrShrinkAt</div>
<div> </div>
<div>キューに待機しているジョブの個数が、この設定値を超えたら新しいスレッドを生成する。また、アイドル状態で待機しているスレッドは maxIdleTimeMS が経過したあと、待機中のスレッド数がこの設定値を超えていた場合に破棄される。初期値は 0。</div>
<div> </div>
<div>lowThreads</div>
<div> </div>
<div>キューに待機しているジョブの個数が、この設定値を超えたら、<a href="http://www.mortbay.org/jetty/jetty-6/apidocs/org/mortbay/thread/QueuedThreadPool.html#isLowOnThreads()" shape="rect">QueuedThreadPool#isLowOnThreads</a> が true を返すようになる。具体的には</div>
<div><a href="http://www.mortbay.org/jetty/jetty-6/apidocs/org/mortbay/jetty/AbstractConnector.html#getLowResourceMaxIdleTime()" shape="rect">org.mortbay.jetty.AbstractConnector.getLowResourceMaxIdleTime()</a> を使用するかどうかの判定に使われている。初期値は 0 なので、ひとつでも待機中のジョブがあると true になる。</div>
<div> </div>
<div>maxIdleTimeMs</div>
<div> </div>
<div>ジョブをおえたスレッドが次のジョブが来るまでに待機する最大の時間 (ms) 。初期値は 60000。</div>
<div> </div>
<div>maxStopTimeMs</div>
<div> </div>
<div>0 以上の値が指定された場合、スレッド・プールの終了時に実行中のジョブが完了するまでの待機時間が maxStopTimeMS までに制限される。初期値は 0。</div>
<div> </div>
<div>2. Connector (<a href="http://www.mortbay.org/jetty/jetty-6/apidocs/org/mortbay/jetty/nio/SelectChannelConnector.html" shape="rect">org.mortbay.jetty.nio.SelectChannelConnector</a>)</div>
<div> </div>
<div><a href="http://docs.codehaus.org/display/JETTY/Configuring+Connectors" shape="rect">http://docs.codehaus.org/display/JETTY/Configuring+Connectors</a></div>
<div> </div>
<div>maxIdleTime</div>
<div> </div>
<div>接続の最大待機時間。次のリクエストが来るまで待機する場合や、書き込み、読み込みにも適用される。初期値は 30000</div>
<div> </div>
<div>lowResourcesConnections</div>
<div> </div>
<div>処理中の接続数がこの設定値を超えたら low resources 状態だと判定される。ただし、0 の場合は無効。初期値は 0</div>
<div> </div>
<div>lowResourcesMaxIdleTime</div>
<div> </div>
<div>low resources 状態で使われる maxIdleTime。初期値は 0</div>
<div> </div>
<div>lowResourceMaxIdleTime</div>
<div> </div>
<div>非推奨。SelectChannelConnector では使われていない。</div>
<div> </div>
<div>acceptors</div>
<div> </div>
<div>接続確立に使われるスレッド数。実際のスレッドは ThreadPool から確保される。初期値は 1</div>
<div> </div>
<div>acceptQueueSize</div>
<div> </div>
<div><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)" shape="rect">java.net.ServerSocket.ServerSocket(int, int)</a> に渡す backlog 引数。初期値は 0 だが、0 の場合はデフォルトが使われるので、実質的には 50 になる。</div>
</div>
    
    ]]></description> <pubDate>Fri, 15 May 2009 02:33:02 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#8613f4a2-ee07-4d1a-8f03-911ddb8e9011</guid> 
  
  </item>

  
  <item> <title>Ubuntu メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#d21f458c-46c9-4a75-ab01-594dccb20c0d</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">
<div>bash のカスタマイズ</div>
<div> </div>
<div>ユーザがログインすると、すべてのユーザ共通の設定として /etc/profile が読み込まれ、次にユーザ固有の設定として ~/.bash_profile が読み込まれる。~/.bash_profile がなければ ~/.bash_login が読み込まれ、それもない場合は、~/.profile が読み込まれる。</div>
<div> </div>
<div>.bashrc は、プロセスとしてbashを起動したときに読み込まれる。bashrc にはエイリアスのようなシェルの基本的な動作の設定を書いておき、.bash_profile にはログイン時にのみ行いたい処理を書いておけばよいわけだ。</div>
<ol><li>エイリアスは .bash_aliases に書き、.bashrc から読み込む</li><li>l, ll, la はデフォルトの .bashrc でコメントアウトされているが、そちらは使わず .bash_aliases に書く</li><li>環境変数は .bash_profile (.profile) に書いて、export</li></ol><div>~/.bash_aliases</div>
<div> </div>
<div>alias l=&quot;ls -l --show-control-char&quot;<br clear="none"/>
alias la=&quot;ls -la --show-control-char&quot;</div>
<div><br clear="none"/></div>
<div>~/.profile</div>
<div> </div>
<div>LANG=C<br clear="none"/>
LC_ALL=C<br clear="none"/>
PS1=&quot;[\h:\w]\n% &quot;</div>
<div>export LANG LC_ALL PS1</div>
<div> </div>
<div>ホスト側から SSH ログインしたときに、プロンプトにホスト名が出ていた方が便利なので \h も指定</div>
<div> </div>
<div>GRUB</div>
<div> </div>
<div>設定ファイル：/boot/grub/menu.lst</div>
<div> </div>
<div>% sudo vi /boot/grub/menu.lst</div>
<div># Pretty colours<br clear="none"/>color cyan/blue white/blue</div>
<div>...</div>
<div>## e.g. defoptions=vga=791 resume=/dev/hda5<br clear="none"/>
# defoptions=quiet splash</div>
<div><br clear="none"/>
vga=791 は 1024x768 16bit という意味（実際には 1024*768 では大きすぎるのでデフォルトのままにしてある）</div>
<div> </div>
<div>% sudo update-grub</div>
<div> </div>
<div>OpenSSH</div><div><br clear="none"/></div>
<div>Mac のターミナルから SSH ログインして使うつもりなので、SSH サーバのセットアップを行う。Ubuntu は最小構成だが、SSH クライアントはインストールされている：<br clear="none"/>
<br clear="none"/>
% which ssh<br clear="none"/>
/usr/bin/ssh<br clear="none"/><br clear="none"/>
なので、ここではサーバのみをインストールする：</div>
<div>% sudo apt-get install openssh-server<br clear="none"/><br clear="none"/>
インストールすると自動で起動される：</div>
<div><br clear="none"/>
% which sshd<br clear="none"/>
/usr/sbin/sshd<br clear="none"/>
% ps aux | grep sshd | grep -v grep<br clear="none"/>
root ... /usr/sbin/sshd</div>
<div><br clear="none"/>
また、/etc/init.d/ssh も配置してくれる。</div>
<div> </div>
<div>公開鍵方式</div>
<div> </div>
<div>このままだとパスワード認証になっているので、パスワード認証は無効にして、公開鍵方式のみにしたい。まずは、公開鍵をリモートに転送：<br clear="none"/>
<br clear="none"/>
% cat ~/.ssh/id_rsa.pub | ssh -p 12345 -l hogehgoe localhost 'mkdir -p .ssh; cat &gt;&gt;$HOME/.ssh/authorized_keys'</div>
<div> </div>
<div>OpenSSH サーバの設定</div>
<div> </div>
<div>/etc/ssh/sshd_config にて設定を変更する。</div>
<div> </div>
<div>% sudo vi /etc/ssh/sshd_config</div>
<div> </div>
<div>ログイン猶予時間は短めにする（デフォルトでは 60 秒）：<br clear="none"/>
<br clear="none"/>
LoginGraceTime 15<br clear="none"/>
<br clear="none"/>
root で直接ログインできないようにする：<br clear="none"/>
<br clear="none"/>
PermitRootLogin no<br clear="none"/>
<br clear="none"/>
パスワード認証の無効化：<br clear="none"/>
<br clear="none"/>
PasswordAuthentication no<br clear="none"/>
PermitEmptyPasswords no<br clear="none"/>
<br clear="none"/>
以降は Ubuntu 8.10 の OpenSSH_5.1p1 では変更の必要がなかった<br clear="none"/>rhostでの接続の無効化：<br clear="none"/>
<br clear="none"/>
RhostsRSAAuthentication no<br clear="none"/>
<br clear="none"/>
チャレンジレスポンス認証を無効化：<br clear="none"/>
<br clear="none"/>
ChallengeResponseAuthentication no<br clear="none"/>
<br clear="none"/>
ログを残す：<br clear="none"/>
<br clear="none"/>
SyslogFacility AUTH<br clear="none"/>
LogLevel INFO<br clear="none"/>
<br clear="none"/>
変更を保存して、サーバを再起動する：</div>
<div> </div>
<div>% sudo /etc/init.d/ssh restart<br clear="none"/><br clear="none"/>
ssh-agent</div>
<div> </div>
<div>Mac OS X 側：<a href="http://www.wand.net.nz/~smr26/wordpress/2007/10/28/mac-os-x-leopard-built-in-ssh-agent" shape="rect">Leopard には ssh-agent が組み込まれている</a>ので、鍵を追加しておこう：</div>
<div> </div>
<div>% ssh-add<br clear="none"/>
Enter passphrase for /.ssh/id_rsa:<br clear="none"/>
Identi...</div></div>
    
    ]]></description> <pubDate>Mon, 11 May 2009 14:38:26 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#d21f458c-46c9-4a75-ab01-594dccb20c0d</guid> 
  
  </item>

  
  <item> <title>Lift</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#7913caae-a678-45b1-9428-1285f7c8c9f6</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Scala web framework<div><br clear="none"/></div><div><b>Starting with Lift</b></div><div><a href="http://liftweb.net/docs/getting_started/mod_master.html" shape="rect">http://liftweb.net/docs/getting_started/mod_master.html</a></div><div><b><br clear="none"/></b></div><div><b>Getting scala syntax hightlighting to work in vim<br clear="none"/></b></div><div><a href="http://lorenzod8n.wordpress.com/2008/01/11/getting-scala-syntax-hightlighting-to-work-in-vim/" shape="rect">http://lorenzod8n.wordpress.com/2008/01/11/getting-scala-syntax-hightlighting-to-work-in-vim/</a><br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div><div>% mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-blank -DarchetypeVersion=1.0 -DremoteRepositories=http://scala-tools.org/repo-releases -DgroupId=demo.helloworld -DartifactId=helloworld -Dversion=1.0-SNAPSHOT<br clear="none"/></div><div>% cd helloworld/<br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Sun, 26 Apr 2009 08:13:19 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#7913caae-a678-45b1-9428-1285f7c8c9f6</guid> 
  
  </item>

  
  <item> <title>GAE, Java, Scala</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#66f05082-0345-47f2-9da4-1b48d5587bda</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">GAE (Google AppEngine) + Java で Scala 試したい。<div><br clear="none"/></div><div><b>Google AppEngine</b></div><div><a href="http://code.google.com/appengine/" shape="rect">http://code.google.com/appengine/</a><br clear="none"/></div><div><br clear="none"/></div><div><b>GAE Java Overview</b></div><div><a href="http://code.google.com/appengine/docs/java/overview.html" shape="rect">http://code.google.com/appengine/docs/java/overview.html</a><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Sat, 25 Apr 2009 17:01:49 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#66f05082-0345-47f2-9da4-1b48d5587bda</guid> 
  
  </item>

  
  <item> <title>vim メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#1f61e5ec-1b56-4446-b724-733989df8bcc</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">
<div><a href="http://ja.wikipedia.org/wiki/Vi" shape="rect">vi</a> か <a href="http://ja.wikipedia.org/wiki/Emacs" shape="rect">Emacs</a> くらい使えないと、プログラマとして認めてもらえないらしい。</div>
<div>年末という節目でもあるし、いい機会だ。サーバ作業でも多用する vi/vim を習得しよう。</div>
<div> </div>
<div>     現在の習熟度：サーバ上で設定ファイルを編集するときのために基本的なコマンド（移動、編集、削除、検索／置換など）が使える程度</div>
<div>     目標設定：年明けまでに C++ や Python のコードが不自由なく書けるくらいにはなりたい。</div>
<div> </div>
<div>Vim のインストール</div>
<div> </div>
<div>Ubuntu を最小構成でインストールしたせいかもしれないけど、デフォルトでインストールされている vim は <a href="http://packages.debian.org/ja/etch/vim-tiny" shape="rect">vim-tiny</a> というパッケージで、これはパッケージサイズを小さく保つために色々と便利な機能のみならずドキュメント（ヘルプ）も含まれていない。</div>
<div> </div>
<div>% which vi<br clear="none"/>
/usr/bin/vi<br clear="none"/>
% l /usr/bin/vi<br clear="none"/>
lrwxrwxrwx 1 root root 20 Dec 16 18:45 /usr/bin/vi -&gt; /etc/alternatives/vi<br clear="none"/>
% l /etc/alternatives/vi<br clear="none"/>
lrwxrwxrwx 1 root root 17 Dec 16 18:45 /etc/alternatives/vi -&gt; /usr/bin/vim.tiny</div>
<div> </div>
<div>dpkg でも確認：</div>
<div> </div>
<div>% dpkg -l | grep vim<br clear="none"/>
ii vim-common 1:7.1.314-3ubuntu3 Vi IMproved - Common files<br clear="none"/>
ii vim-tiny 1:7.1.314-3ubuntu3 Vi IMproved - enhanced vi editor - compact</div>
<div> </div>
<div>見事に vim-tiny のみ。どうせなのでフルセットの vim をインストールしておこう：</div>
<div> </div>
<div>% sudo apt-get install vim</div>
<div>...</div>
<div>% l /etc/alternatives/vim<br clear="none"/>
lrwxrwxrwx 1 root root 18 Dec 24 22:34 /etc/alternatives/vim -&gt; /usr/bin/vim.basic</div>
<div> </div>
<div>めでたく、vim.basic になった。</div>
<div> </div>
<div>環境変数</div>
<ul><li>$VIM .vimrc などの設定ファイルのディレクトリ</li><li>$VIMRUNTIME ヘルプファイルや構文強調表示の定義ファイルのような、Vimが使用するさまざまな支援ファイルの置き場所</li></ul>
<div>いくつかの探索ルールはあるものの、:version コマンドで確認する限り、Ubuntu でのデフォルトは /usr/share/vim/vimcurrent/ である</div>
<div> </div>
<div>コードハイライト</div>
<div> </div>
<div>:syntax enable でコードハイライトが有効になる。</div>
<div> </div>
<div>色が気に入らない</div>
<div> </div>
<div>:colorscheme でスキンのように変更することが可能。選択可能なテーマは</div>
<div> </div>
<div>% ls /usr/share/vim/vimcurrent/colors/ | grep \.vim$<br clear="none"/>
...</div>
<div> </div>
<div>常に有効にする</div>
<div> </div>
<div>vimrc に syntax enable を追加：</div>
<div> </div>
<div> </div>
<div>自動インデント</div>
<ul><li>autoindent 前の行のインデントをコピー</li><li>smartindent 言語ごとのインデントルールに従う。autoindent 必要</li><li>cindent smartindent より厳密に</li></ul>
<div> </div>
<div>vimrc</div>
<div><br clear="none"/></div>
<div>set encoding=utf-8<br clear="none"/>
set autoindent<br clear="none"/>
set cindent<br clear="none"/><br clear="none"/>
set tabstop=2<br clear="none"/>
set shiftwidth=2<br clear="none"/>
set softtabstop=2<br clear="none"/>
set expandtab<br clear="none"/>
autocmd FileType make setlocal noexpandtab
</div>
<div><br clear="none"/></div><div>set backupdir=$HOME/.vim/backup</div><div>let &amp;directory=&amp;backupdir</div><div><br clear="none"/></div>
<div>set hlsearch<br clear="none"/>
set smartcase<br clear="none"/>
set incsearch<br clear="none"/>
set grepprg=ack\ --noenv\ --nogroup</div>
<div> </div>
<div>if &amp;term == &quot;xterm-256color&quot;<br clear="none"/>  set t_Co=256
<br clear="none"/>&quot; set t_AB=^[[48;5;%dm <br clear="none"/>&quot; set t_AF=^[[38;5;%dm <br clear="none"/>
endif</div>
<div><br clear="none"/>
if &amp;t_Co &gt; 1<br clear="none"/>  syntax enable
<br clear="none"/>  colorscheme railscasts <br clear="none"/>
endif</div>
<div> </div>
<div>独自の colorscheme</div>
<div> </div>
<div>~/.vim/colors/myscheme,vim</div>
<div>元々のファイルは Mac では /usr/share/vim/ にあった</div>
<div> </div>
<div>colorscheme:</div>
<div><a href="http://www.vim.org/scripts/script.php?script_id=2175" shape="rect">railscasts.vim</a></div>
<div> </div>
<div> </div>
<div>Mac の Terminal.app で CTRL-H が...</div></div>
    
    ]]></description> <pubDate>Sun, 12 Apr 2009 10:29:04 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#1f61e5ec-1b56-4446-b724-733989df8bcc</guid> 
  
  </item>

  
  <item> <title>Mac OS X: Spotlight</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#31790913-3876-4766-a0d0-59628d060c16</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote"><div>コマンドラインから Spotlight を操作する<br clear="none"/></div><div><br clear="none"/></div><div><b>検索</b></div><div><br clear="none"/></div>% mdfind -onlyin ~/Pictures image<br clear="none"/><div><br clear="none"/></div><div><b>索引作成</b></div><div><br clear="none"/></div><div>% mdimport -p .<br clear="none"/>Total processing time spent in importer plug-ins: 0.114901 seconds for 3 files<br clear="none"/>Top 3 most expensive files for importer plug-ins:<br clear="none"/>1  /Users/ishikawa/Pictures/Elements/20081211: 0.060532 seconds<br clear="none"/>2  /Users/ishikawa/Pictures/Elements/20081211/20081211_0202.JPG: 0.052955 seconds</div><div>...<br clear="none"/></div><div><br clear="none"/></div><div>-p オプションを指定すると、検索に追加されたエントリ毎のパフォーマンス情報が表示される。</div><div><br clear="none"/></div><div><br clear="none"/></div><div><b>索引再構築</b></div><div><br clear="none"/></div><div>ボリューム単位で索引を再構築する場合は mdutil を使う</div><ul><li><a href="http://journal.mycom.co.jp/column/osx/133/index.html" shape="rect">【コラム】OS X ハッキング! (133) 虎飼い日記 その1 - 噂のSpotlightをTerminalで使う | パソコン | マイコミジャーナル</a><br clear="none"/></li><li><a href="http://journal.mycom.co.jp/column/osx/134/index.html" shape="rect">【コラム】OS X ハッキング! (134) 虎飼い日記 その2 - 噂のSpotlightを手なずける | パソコン | マイコミジャーナル</a><a href="http://developer.apple.com/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple_ref/doc/uid/TP40001849" shape="rect"></a></li><li><a href="http://developer.apple.com/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple_ref/doc/uid/TP40001849" shape="rect">Spotlight Query Programming Guide: Query Expression Syntax </a><a href="http://www.oreillynet.com/pub/a/mac/2006/01/04/mdfind.html" shape="rect">The Power of mdfind | O'Reilly Media</a></li><li><a href="http://www.oreillynet.com/pub/a/mac/2006/01/04/mdfind.html" shape="rect">The Power of mdfind | O'Reilly Media</a><br clear="none"/></li></ul></div>
    
    ]]></description> <pubDate>Sun, 12 Apr 2009 02:01:29 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#31790913-3876-4766-a0d0-59628d060c16</guid> 
  
  </item>

  
  <item> <title>vim で効率よくコーディングするための方法</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#f0804e26-0fe6-4b59-b111-3a50f0093681</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">
<div>個人的に vim 勉強中なので、vim か shell から使える tips やツール限定。できれば、vim 単体で完結したコードリーディング環境を構築したい。</div>
<div> </div>
<div>Vim</div>
<div> </div>
<div>情報の表示</div>
<div> </div>
<div>&lt;C-G&gt; 表示中のファイル名を表示</div>
<div>g &lt;C-G&gt; カーソルの位置を行番号などで表示、&lt;S-V&gt; で行選択モードにした方がカーソル行がハイライトされてわかりやすい</div>
<div> </div>
<div>挿入モード</div>
<div> </div>
<div>&lt;C-J&gt; 改行</div>
<div>&lt;C-W&gt; 前単語削除</div>
<div>&lt;C-U&gt; 行頭まで削除</div>
<div>&lt;C-A&gt; 直前に挿入したテキストを挿入。&lt;C-@&gt; は同時に挿入モードを抜ける</div>
<div>&lt;C-Y&gt;&lt;C-E&gt; 上、または下の行から一文字コピー</div>
<div>&lt;C-O&gt; {command} 通常モードのコマンドを実行</div>
<div> </div>
<div>編集モードへ移るためのキー</div>
<div> </div>
<div>A 現在行の末尾に追加</div>
<div>O 現在行の前に行挿入</div>
<div>o 現在行の次に行挿入</div>
<div> </div>
<div>便利な削除</div>
<div> </div>
<div>di&quot;&quot;&quot; で囲まれたテキストを削除</div>
<div>da&quot;&quot; も含み、&quot;&quot; で囲まれたテキストを削除</div>
<div> </div>
<div>y ならコピー、他にも ( とか { とか</div>
<div> </div>
<div> </div>
<div>コマンドライン行の編集で便利なコマンド</div>
<div> </div>
<div>&lt;C-W&gt; 単語削除</div>
<div>&lt;C-U&gt; すべて削除</div>
<div>&lt;C-P&gt; 前の候補</div>
<div> </div>
<div>左右の移動モーション</div>
<div> </div>
<div>削除などと組み合わせると便利</div>
<div> </div>
<div>f&lt;char&gt; 右方向に &lt;char&gt; まで移動（検索対象文字含む）</div>
<div>t&lt;char&gt; 右方向に &lt;char&gt; まで移動（検索対象文字含まない）</div>
<div> </div>
<div> </div>
<div>ファイル内検索</div>
<div> </div>
<div>:h / （ヘルプ参照）</div>
<div>* カーソル位置の単語を前方検索</div>
<div># カーソル位置の単語を後方検索</div>
<div>:set hls[earch] 検索結果をハイライト。邪魔なときは :nohlsearch でハイライト消去</div>
<div>:set incsearch インクリメンタル検索</div>
<div>:set ignorecase 大文字・小文字無視</div>
<div>:set smartcase 検索語が小文字のみの場合、大文字・小文字無視</div>
<div> </div>
<div>正規表現</div>
<div> </div>
<div>vim の正規表現は独特だが、基本的に、スターを除けばバックスラッシュをつける感じで：</div>
<div> </div>
<div>\(...\) グループ化</div>
<div>\+ 1 個以上</div>
<div>\= 0 個か 1 個</div>
<div>\{n, m} 繰り返し回数指定</div>
<div>\| または</div>
<div> </div>
<div>ファイル間検索</div>
<div> </div>
<div>:vimgrep vim 独自のファイル間検索。ファイル内検索と同じように動くが遅い</div>
<div>:grep grep か類似の外部プログラムによる検索（後述の ack も指定できる）</div>
<div> </div>
<div>ack を使うために</div>
<div> </div>
<div>set grepprg=ack\ --noenv --color</div>
<div> </div>
<div>とした。詳細は :help grep と :help quickfix 参照</div>
<div> </div>
<div>行番号表示</div>
<div> </div>
<div>:set nu[mber] 各行に行番号を表示</div>
<div>:# 挿入ポイントがある行を行番号とともに表示</div>
<div> </div>
<div>ファイルブラウザ</div>
<div> </div>
<div>:new . or :Sex カレントディレクトリ表示（縦）</div>
<div>:vnew . or :Vex カレントディレクトリ表示（横）</div>
<div> </div>
<div>タブ表示</div>
<div> </div>
<div>:tabe[dit] {file} ファイルを新規タブで開く</div>
<div>:tab {cmd} vim コマンドの実行結果をタブで開く :tab help tabedit</div>
<div> </div>
<div>:tabp[revious] or &lt;C-PageUp&gt; or gT 前のタブ</div>
<div>:tabn[ext] or &lt;C-PageDown&gt; or gt 次のタブ</div>
<div>:tabs タブ一覧表示</div>
<div> </div>
<div>ウインドウ分割</div>
<div> </div>
<div>:sp 現在のファイルを分割して表示（縦）</div>
<div>:vsp 現在のファイルを分割して表示（横）</div>
<div> </div>
<div>複数ウインドウ</div>
<div> </div>
<div>:new 新規ウインドウ（縦）</div>
<div>:vnew 新規ウインドウ（横）</div>
<div>[n]&lt;C-w&gt;&lt;C-w&gt; ウインドウ切り替え</div>
<div>&lt;C-W&gt; w ウインドウ切り替え</div>
<div>&lt;C-w&gt;&lt;移動&gt; ウインドウ切り替え</div>
<div> </div>
<div>ウインドウのサイズ変更</div>
<div> </div>
<div>&lt;C-W&gt; + 高さ</div>
<div>&lt;C-W&gt; -</div>
<div>{height}&lt;C-W&gt; _</div>
<div> </div>
<div> </div>
<div>ファイルを開く</div>
<div> </div>
<div><a href="http://nanasi.jp/articles/howto/file/expand.html#" shape="rect">vimエディタから、いろいろなパターンの方法でファイルを開く — 名無しのvim使い</a></div>
<div> </div>
<div>CTRL-W gf カーソル下のファイルを新規タブで開く</div>
<div> </div>
<div>これらのコマンドの検索パスは path 変数にカンマ区切りで指定する。相対パスは ./ や ../ で始めない。カレントディレクトリは空文字、１個の . はカレントディレクトリからの相対パスという意味。e.g. :set path=.,include,/usr/include</div>
<div> </div>
<div> </div>
<div>ファイルタイプの関連づけ</div>
<div> </div>
<div>% cat ~/.vim/ftdetect/apache.vim<br clear="none"/>
au BufRead,BufNewFile *.conf            set filetype=apache</div>
<div> </div>
<div>外部ツール</div>
<div> </div>
<div><a href="http://petdance.com/ack" shape="rect">ack</a></div>
<div> </div>
<div>プログラマ向け grep ともいうべき、ソースコード検索に適した...</div></div>
    
    ]]></description> <pubDate>Wed, 08 Apr 2009 02:17:24 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#f0804e26-0fe6-4b59-b111-3a50f0093681</guid> 
  
  </item>

  
  <item> <title>演算子優先順位構文解析</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#c7128d93-6776-40e1-bb8f-ade6ed7382c9</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Operator Precedence Parsing、演算子順位解析、演算子順位法と書かれることもある。書籍「ビューティフルコード」では「９章　下向き演算子順位解析」において、再帰下降構文解析と組み合わせて紹介されている。<div><br clear="none"/><ul><li><a href="http://en.wikipedia.org/wiki/Operator-precedence_parser#" shape="rect">Operator-precedence parser - Wikipedia, the free encyclopedia</a><br clear="none"/></li><li><a href="http://llvm.org/docs/tutorial/LangImpl2.html#parserbinops" shape="rect">Kaleidoscope: Implementing a Parser and AST</a><br clear="none"/></li></ul></div></div>
    
    ]]></description> <pubDate>Mon, 23 Feb 2009 23:32:38 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#c7128d93-6776-40e1-bb8f-ade6ed7382c9</guid> 
  
  </item>

  
  <item> <title>OAuth</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#4e67e0d8-02d3-4e7d-8696-d67022114c6b</link>
  <description><![CDATA[
    
    
    
        
        <div style="background-color:#ffffff;" class="ennote">
<div> </div>
<div>ユーザー：アプリケーションの利用者</div>
<div>サービスプロバイダー：ユーザのアカウント情報や写真など、リソースを管理する側</div>
<div>コンシューマー：リソースを利用し、サービスを提供する側</div>
<div> </div>
<div>OpenSocialのOAuthまとめ</div>
<div><a href="http://devlog.agektmr.com/ja/archives/79" shape="rect">http://devlog.agektmr.com/ja/archives/79</a></div>
<div> </div>
<div>OAuthの署名方式を掘り下げる</div>
<div><a href="http://devlog.agektmr.com/ja/archives/174" shape="rect">http://devlog.agektmr.com/ja/archives/174</a></div>
<div> </div>
<div>APIアクセス権を委譲するプロトコル、OAuthを知る</div>
<div><a href="http://www.atmarkit.co.jp/fsecurity/special/106oauth/oauth02.html" shape="rect">http://www.atmarkit.co.jp/fsecurity/special/106oauth/oauth02.html</a></div>
</div>
    
    ]]></description> <pubDate>Tue, 17 Feb 2009 02:00:30 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#4e67e0d8-02d3-4e7d-8696-d67022114c6b</guid> 
  
  </item>

  
  <item> <title>C or C++</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#f71d9d44-a5d2-4116-9505-56274438da70</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote"><div><div><div><div><div>Git<br clear="none"/><br clear="none"/><a href="http://git-scm.com/" shape="rect">git</a> が C++ ではなく C で実装されているのはヘン、という ML での指摘を受けて、Linus Torvalds の<a href="http://tabesugi.net/memo/2009/1a.html#152154" shape="rect">返答（和訳）</a>：<br clear="none"/><br clear="none"/></div><div>git の ML より（日本語は適当）：</div><div><br clear="none"/></div><div><a href="http://marc.info/?l=git&amp;m=118893905220948&amp;w=2" shape="rect">ML のスレッド：最初のメッセージ：builtin-mailinfo.c で &quot;The Better String Library&quot; を使うようにしませんか？</a><br clear="none"/></div><div>→ <a href="http://marc.info/?l=git&amp;#38;m=118900612008602&amp;#38;w=2" shape="rect">もう、strbuf.c があるじゃん。依存性の問題だってあるし、やめてよ</a></div><div>→ <a href="http://marc.info/?l=git&amp;#38;m=118901462720268&amp;#38;w=2" shape="rect">コードサイズはちいさいし、そのまま含めりゃいいじゃん</a></div><div><b><br clear="none"/></b></div><div><b>Dmitry Kakurin: </b><a href="http://marc.info/?l=git&amp;#38;#38;m=118905414201544&amp;#38;#38;w=2" shape="rect"><b>なんで C++ 使わねーんだよ</b></a></div><div>→ <a href="http://marc.info/?l=git&amp;#38;m=118905503112831&amp;#38;w=2" shape="rect">あんたをイライラさせるためさ</a></div><div>→ <a href="http://marc.info/?l=git&amp;#38;m=118906997731833&amp;#38;w=2" shape="rect">もしも、Git が C++ で書かれていたなら、300 人以上いる開発者のうち 2/3 を失うことになるだろう。Git の主な開発者はカーネルの開発者でもあり、彼らは間違いなく優秀な C プログラマなんだよ</a></div><div>→→ <a href="http://marc.info/?l=git&amp;#38;m=118907134408423&amp;#38;w=2" shape="rect">（少数の例外を除いて）カーネル開発者がパッチを送ってくれてたのは最初の数週間って感じだけどね</a></div><div>→→→ <a href="http://marc.info/?l=git&amp;#38;m=118907415319270&amp;#38;w=2" shape="rect">そりゃ、そうなんだけどさ</a></div><div>→ <a href="http://marc.info/?l=git&amp;#38;m=118907238000722&amp;#38;w=2" shape="rect">C++ とは秩序なくデザインされたプログラミング言語である</a></div><div><b>→ Linus Torvalds: </b><a href="http://marc.info/?l=git&amp;#38;m=118910117324952&amp;#38;w=2" shape="rect"><b>*あんた* のほうこそ大ウソつきだ。</b></a><b><br clear="none"/></b></div><div>→→ Dmitry Kakurin: <a href="http://marc.info/?l=git&amp;#38;m=118912450130609&amp;#38;w=2" shape="rect">駄目な開発者は、どんな言語でも駄目なコードを書くもんだろ</a></div><div>→→→ <a href="http://marc.info/?l=git&amp;#38;m=118912848227121&amp;#38;w=2" shape="rect">Linus の返答</a><br clear="none"/></div><div>→→ Linus Torvalds: <a href="http://marc.info/?l=git&amp;#38;m=118912756413635&amp;#38;w=2" shape="rect">そんなに「すてきな」言語を使いたければ、C++ なんて選ぶなよ</a></div><div><br clear="none"/></div><div><br clear="none"/></div><div>GCC<br clear="none"/><br clear="none"/><a href="http://gcc.gnu.org/" shape="rect">GCC</a> を C++ で書き直そうぜプロジェクト：</div><ul><li><a href="http://www.airs.com/ian/cxx-slides.pdf" shape="rect">Write gcc in C++ (PDF)</a><br clear="none"/></li></ul>GCC の ML より（日本語は適当）：</div><div><ul><li><a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00385.html" shape="rect">gcc-in-cxx branch 作ったよ！</a><br clear="none"/></li><li><a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00554.html" shape="rect">C++ の「良い」部分だけ使うようにしよう、なんて無理じゃね？　最初はうまくいっても、すぐに「アレもコレも」ってなるぜ</a></li><li><a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00565.html" shape="rect">コーディング規約のチェック機能をコンパイラにつけて、規約に違反した場合はエラーにしてはどうでしょうか？</a></li><li><a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00571.html" shape="rect">言語の機能 X がいいとか、Y が悪いとかは問題じゃないんだ</a></li></ul></div><div><br clear="none"/></div><div>&gt; Whether we use C or C++, we need to try to ensure that interfaces are<br clear="none"/>&gt; easy to understand, that the code is reasonably modular, that the<br clear="none"/>&gt; internal documentation corresponds to the code, that it is possible<br clear="none"/>&gt; for new developers to write new passes and to fix bugs.  Those are the<br clear="none"/>&gt; important issues for us to consider.  The C++ features which are not<br clear="none"/>&gt; present in C--features which are well documented in many books and<br clear="none"/>&gt; many web sites--are not an important issue.<br clear="none"/><br clear="none"/><ul><li><a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00596.html" shape="rect">新人開発者に必要な C++ スキルってどのへん？</a><br clear="none"/></li><li>→ <a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00598.html" shape="rect">俺は &quot;Accelerated C++&quot; かなー</a><br clear="none"/></li><li>→ <a href="http://gcc.gnu.org/ml/gcc/2008-06/msg00601.html" shape="rect">Ian: STL コンテナと単一クラス継承は使いたいね</a></li></ul></div><div><br clear="none"/></div><div>C99</div><ul><li>Windows 環境ではサポートするコンパイラが限られる</li><li>C++ は C99 と互換性がない</li><li><a href="http://drizzle.org/wiki/FAQ#What_platforms_will_Drizzle_build_on.3F_Will_it_ever_run_on_Windows.3F" shape="rect">Drizzle は C99 で書かれている</a></li></ul><div><br clear="none"/></div><div><br clear="none"/></div></div></div></div></div>
    
    ]]></description> <pubDate>Sat, 31 Jan 2009 05:00:44 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#f71d9d44-a5d2-4116-9505-56274438da70</guid> 
  
  </item>

  
  <item> <title>Git メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#c1860968-3cd2-49a2-908b-8268ab7d3c3a</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">あるプロジェクトのブランチをチェックアウトし作業する場合<br clear="none"/>まずはリモートのプロジェクトを clone する<br clear="none"/>% git clone git@github.com:ishikawa/pekoe.git<br clear="none"/>Initialized empty Git repository in /home/ishikawa/pekoe/.git/<br clear="none"/>remote: Counting objects: 1966, done.<br clear="none"/>remote: Compressing objects: 100% (421/421), done.<br clear="none"/>remote: Total 1966 (delta 1359), reused 1898 (delta 1325)<br clear="none"/>Receiving objects: 100% (1966/1966), 290.62 KiB | 111 KiB/s, done.<br clear="none"/>Resolving deltas: 100% (1359/1359), done.<br clear="none"/><br clear="none"/>この時点でデフォルトのブランチ master と、すべてのリモートブランチとタグも手に入れたことになる。<br clear="none"/>% cd pekoe<br clear="none"/>[ubuntu:~/pekoe]<br clear="none"/>% git branch<br clear="none"/>* master<br clear="none"/>% git branch -r # remote<br clear="none"/>  origin/HEAD<br clear="none"/>  origin/master<br clear="none"/>  origin/pekoe-0.6<br clear="none"/><br clear="none"/><b>リモートブランチは変更できない。必ずローカルブランチを作り、リモートブランチを追跡する。</b><br clear="none"/>% git checkout --track -b pekoe-0.6 origin/pekoe-0.6<br clear="none"/>Branch pekoe-0.6 set up to track remote branch refs/remotes/origin/pekoe-0.6.<br clear="none"/>Switched to a new branch &quot;pekoe-0.6&quot;<br clear="none"/><br clear="none"/><br clear="none"/><br clear="none"/>% git clone git@github.com:ishikawa/pekoe.git<br clear="none"/>% cd pekoe<br clear="none"/>% git fetch<br clear="none"/>% git branch -r<br clear="none"/>  origin/HEAD<br clear="none"/>  origin/master<br clear="none"/>origin/pekoe-0.6% git checkout pekoe-0.6<br clear="none"/><br clear="none"/>git add の取り消し<br clear="none"/>% git rm --cached ...<br clear="none"/>error: failed to push some refs to ...<br clear="none"/><div><br clear="none"/></div><div>あるとき push しようとしたら怒られた。</div><div><br clear="none"/></div><div>% git push origin master<br clear="none"/>To git@github.com:xxxx/xxxx.git<br clear="none"/> ! [rejected]        master -&gt; master (non-fast forward)<br clear="none"/>error: failed to push some refs to 'git@github.com:xxxx/xxxx.git'<br clear="none"/></div><div><br clear="none"/></div><div>こういうときは pull してみる</div><div><br clear="none"/></div><div>% git pull origin master<br clear="none"/>...<br clear="none"/>% git push origin master<br clear="none"/></div><div><br clear="none"/></div><div><a href="http://d.hatena.ne.jp/zhesto/20080929/1222658772" shape="rect">github error: failed to push some refs - ZHlog</a><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Thu, 29 Jan 2009 14:39:19 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#c1860968-3cd2-49a2-908b-8268ab7d3c3a</guid> 
  
  </item>

  
  <item> <title>Mac OS X に VirtualBox + Ubuntu で開発環境をセットアップする</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#7d34b648-9a0e-4db0-8e4d-10c9d4f872c0</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">
<div>Mac OS X Leopard (10.5.6) 上に <a href="http://www.virtualbox.org/" shape="rect">VirtualBox</a> をインストールし、ゲスト OS として <a href="http://www.ubuntu.com/" shape="rect">Ubuntu</a> をインストールする。コマンドラインでの開発環境として使うことを念頭に置き、デスクトップ環境は整えない。</div>
<div> </div>
<div>VIrtualBox</div>
<ol><li><a href="http://www.virtualbox.org/wiki/Downloads" shape="rect">ダウンロードページ</a>より 2.0.6 の Mac OS X 向けバイナリの .dmg をダウンロードする</li><li>ディスクイメージをマウントし、VirtualBox.mpkg でインストールする</li><li>/Applications にインストールされた VirtualBox.app を起動</li><li>初回起動時は登録フォームが表示されるので登録する</li></ol>
<div>仮想マシンの作成</div>
<div> </div>
<div>「新規仮想マシン作成ウィザード」で新しい仮想マシンを作成する：</div>
<ol><li>OS タイプは「Ubuntu」</li><li>メインメモリのサイズは 256 MB</li><li>仮想ハードディスクで「新規...」→「新規仮想ディスク作成ウィザード」</li><li>可変サイズのイメージ（4 GB）を作成。~/Library/VirtualBox/VDI/Ubuntu.vdi(20KB) が出来た。</li></ol>
<div>Ubuntu のインストール</div>
<div> </div>
<div><a href="http://www.ubuntu.com/getubuntu/download" shape="rect">ダウンロードページ</a>から Ubuntu 8.10 の Server Edition (i386) をダウンロードし、<a href="https://help.ubuntu.com/community/UbuntuHashes" shape="rect">MD5 チェックサム</a>を検証する。</div>
<div> </div>
<div>% test `md5 -q ~/Downloads/ubuntu-8.10-server-i386.iso` == a2ec9975a91e1228c8292ed9799dc302 &amp;&amp; echo OK<br clear="none"/>
OK</div>
<div> </div>
<div>ダウンロードした ISO イメージファイルを VirtualBox で使うには、まず、仮想ディスクマネージャに登録する必要がある：</div>
<ol><li>「ファイル」メニューから「仮想ディスクマネージャ」を起動</li><li>「CD/DVD イメージ」にダウンロードした ISO イメージファイルを追加</li><li>先ほど作成した仮想マシンの設定で、ストレージに「CD/DVD-ROM」＞「ISO イメージファイル」で登録したファイルを選択</li></ol>
<div>Ubuntu</div>
<div> </div>
<div>仮想マシンを起動して Ubuntu のインストールを開始する：</div>
<ul><li>基本的にデフォルト設定</li><li>言語は English</li><li>&quot;Select and Install Software&quot; では無選択のまま Continue</li></ul>
<div>&quot;This kernel requires the following features not present on the CPI: pae&quot; で起動しない：</div>
<div>VirtualBox で仮想マシンの「一般」＞「高度」＞「PAE/NX を有効にする」にチェックを入れて再起動（PAE - Physical Address Extension = <a href="http://ja.wikipedia.org/wiki/%E7%89%A9%E7%90%86%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9%E6%8B%A1%E5%BC%B5" shape="rect">物理アドレス拡張</a>）。</div>
<div> </div>
<div>The VirtualBox Guest Additions</div>
<div> </div>
<div>ゲスト拡張（Guest Additions）はデバイスドライバとシステムアプリケーションで構成され、仮想マシンに組み込むことで、ゲスト OS の機能をより使いやすいものにする。VirtualBox がサポートするすべてのゲスト OS に対するゲスト拡張は、一枚の CD-ROM イメージファイル VBoxGuestAdditions.iso で提供されている。仮想マシンにゲスト拡張を組み込むには、この CD-ROM イメージファイルを仮想 CD-ROM としてマウントし、ゲスト拡張をインストールする。</div>
<div> </div>
<div>dkms</div>
<div> </div>
<div>カーネルモジュールをビルドできるようにゲスト OS 側に <a href="http://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support" shape="rect">Dynamic Kernel Module Support (DKMS)</a> とカーネルのヘッダファイルを導入する。</div>
<div> </div>
<div>% sudo apt-get install dkms linux-headers-2.6.27-7-server</div>
<div> </div>
<div>VBoxGuestAdditions.iso</div>
<div> </div>
<div>VBoxGuestAdditions.iso は /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso にあるのだが、Ubuntu の実行中にメニューから「デバイス」＞「Guest Additions のインストール」を実行すると、VBoxGuestAdditions.iso がマウント可能な状態になる。</div>
<div>そして、マウントする：</div>
<div> </div>
<div>% sudo mount -r /dev/cdrom /media/cdrom0/</div>
<div> </div>
<div>マウントされたディレクトリに移動し、インストールスクリプトを実行</div>
<div> </div>
<div>% cd /media/cdrom0/<br clear="none"/>
% sudo sh ./VBoxLinuxAdditions-x86.run kernel-module vfs-module control timesync</div>
<div> </div>
<div>X11 拡張はいらないので、必要なモジュールを個別に...</div></div>
    
    ]]></description> <pubDate>Wed, 28 Jan 2009 14:54:27 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#7d34b648-9a0e-4db0-8e4d-10c9d4f872c0</guid> 
  
  </item>

  
  <item> <title>Subversion 復習</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#5f8645b6-b4ec-45c6-a713-3799ea7ea51f</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">
<div>最近は git ばかりで Subversion を使っていないので、<a href="http://subversion.bluegate.org/" shape="rect">Subversion によるバージョン管理</a>で復習する</div>
<div> </div>
<div>apt で subversion をインストール</div>
<div> </div>
<div>% sudo aptitude install subversion</div>
<div> </div>
<div>ローカルにリポジトリを作成</div>
<div> </div>
<div>% svnadmin create ~/svnrepos</div>
<div>% ls ~/svnrepos<br clear="none"/>README.txt conf db format hooks locks</div>
<div> </div>
<div>以下の hello ディレクトリをバージョン管理する</div>
<div> </div>
<div>% pwd<br clear="none"/>/home/ishikawa/hello<br clear="none"/>% ls<br clear="none"/>Makefile hello.c</div>
<div> </div>
<div>まずは定番のディレクトリ構造を作成し、import する：</div>
<div> </div>
<div>% mkdir -p tmp/trunk tmp/branches tmp/tags</div>
<div>% cd tmp/</div>
<div>% svn import . file:///home/ishikawa/svnrepos/hello -m &quot;initial import&quot;<br clear="none"/>Adding trunk<br clear="none"/>
Adding branches<br clear="none"/>
Adding tags<br clear="none"/>
<br clear="none"/>
Committed revision 1.</div>
<div> </div>
<div>一次ディレクトリを削除し、さきほど import したディレクトリ構造の trunk をバージョン管理したいディレクトリにチェックアウトする：</div>
<div> </div>
<div>% cd ..; rm -rf tmp</div>
<div>% svn co file:///home/ishikawa/svnrepos/hello/trunk .<br clear="none"/>Checked out revision 1.</div>
<div> </div>
<div>バージョン管理情報を確認してみる：</div>
<div> </div>
<div>% svn info<br clear="none"/>Path: .<br clear="none"/>
URL: file:///home/ishikawa/svnrepos/hello/trunk<br clear="none"/>
Repository Root: file:///home/ishikawa/svnrepos</div>
<div>...</div>
<div>% svn status</div>
<div>? hello.c<br clear="none"/>
? Makefile</div>
<div> </div>
<div>では、最初のコミット：</div>
<div> </div>
<div>% svn add *<br clear="none"/>A Makefile<br clear="none"/>
A hello.c<br clear="none"/>
% svn commit -m &quot;initial commit&quot;<br clear="none"/>Adding Makefile<br clear="none"/>
Adding hello.c<br clear="none"/>
Transmitting file data ..<br clear="none"/>
Committed revision 2.</div>
<div> </div>
<div>まあ、このへんは問題ない</div>
<div> </div>
<div>無視するファイル</div>
<div> </div>
<div>Makefile は all: hello としているので、make すると hello という実行ファイルができる。</div>
<div> </div>
<div>% make<br clear="none"/>cc hello.c -o hello<br clear="none"/>
% ls<br clear="none"/>Makefile hello hello.c</div>
<div> </div>
<div>hello はコミットしたくないので、無視するよう <a href="http://subversion.bluegate.org/doc/book.html#svn.advanced.props.special.ignore" shape="rect">svn:ignore</a> という<a href="http://subversion.bluegate.org/doc/book.html#svn.advanced.props.special" shape="rect">特殊な属性</a>をディレクトリにつけておく：</div>
<div> </div>
<div>% svn propset svn:ignore &quot;hello&quot; .<br clear="none"/>property 'svn:ignore' set on '.'</div>
<div>% svn status<br clear="none"/>M .<br clear="none"/>
M hello.c<br clear="none"/>
M Makefile</div>
<div> </div>
<div>コミット</div>
<div> </div>
<div>% svn commit -m &quot;Added files&quot;<br clear="none"/> Sending .<br clear="none"/>
Sending Makefile<br clear="none"/>
Sending hello.c<br clear="none"/>
Transmitting file data ..<br clear="none"/>
Committed revision 3.</div>
<div> </div>
<div>複数人での開発</div>
<div> </div>
<div>複数人での開発をシミュレートするために、ホスト側でもチェックアウトしてみる：</div>
<div> </div>
<div>% svn co svn+ssh://vbox-ubuntu/home/ishikawa/svnrepos/hello/trunk hello<br clear="none"/>A hello/hello.c<br clear="none"/>
A hello/Makefile<br clear="none"/>
U hello</div>
<div>% cd hello</div>
<div> </div>
<div>更新 (U) や追加 (A) はわかりやすいので、変更が衝突せずにマージ (G) される、というのをシミュレートしてみる。</div>
<div>ホスト側とゲスト側で hello.c を変更し、ゲスト側で commit、そのあと、ホスト側で update する：</div>
<div> </div>
<div>% svn up<br clear="none"/>G hello.c<br clear="none"/>
Updated to revision 4.</div>
<div> </div>
<div>G は merGed の G らしい</div>
<div> </div>
<div> </div>
<div>svn diff の出力を色つきで</div>
<div> </div>
<div>svn diff foo.c | vim -R - とか colordiff とか</div>
<div>svn cat の出力とローカルのファイルを、vimdiff プログラムで比較するとか</div>
</div>
    
    ]]></description> <pubDate>Wed, 28 Jan 2009 05:39:15 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#5f8645b6-b4ec-45c6-a713-3799ea7ea51f</guid> 
  
  </item>

  
  <item> <title>Perl のお勉強メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#4e177acf-fab2-41f7-9b8b-2d535711c650</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Perl の学習<ul><li><a shape="rect" href="http://d.hatena.ne.jp/antipop/20060505/1146822604" target="_blank">Perl の学習コストを大幅に軽減するスゴイ方法 - antipop</a><br clear="none"/></li><li><a shape="rect" href="http://dann.g.hatena.ne.jp/dann/20080703/p2" target="_blank">Perl「言語」初心者がモダンなPerlを高速に学ぶ方法 - dann@webdev - dann's portal</a><br clear="none"/></li></ul><div><br clear="none"/></div><div>自分なりにまとめてみると：<ol><li>既存プロダクトのコードを読みつつ、Perl っぽいコードや頻出するライブラリを学ぶ</li><li>分からないところは perldoc コマンド、または<a shape="rect" href="http://perldoc.perl.org/" target="_blank">オンライン版</a>で調べつつ、</li><li>自分が作りたいものを作る</li></ol>という学習方法がよさそうだ。というか、これってたぶん、他の言語でもそう。特に、他のプログラミング言語の経験があるのなら、マニュアルを一から読むよりは、上記のようにトップダウンで学んでいく方が上達が早いし、継続できた気がする。もっとも、はじめて関数型言語を使う、とかパラダイムが異なるものはマニュアルなりから入るほうがいいだろうけど。</div><div><br clear="none"/></div><div><br clear="none"/></div><div>学習の方針<br clear="none"/>上に書いたとおりなんだけど、問題は何のコードを参考に、何をつくるか：<ul><li><a href="http://www.catalystframework.org/" shape="rect">Catalyst</a> や <a href="http://search.cpan.org/~drolsky/Moose-0.63/lib/Moose.pm" shape="rect">Moose</a> は他モジュールへの依存も規模もでかくて大変そう</li><li><a href="http://mojolicious.org/" shape="rect">Mojo</a> は依存もすくないし、なんか最先端っぽいのでよさげ</li><li>でも、依存がすくないということは、逆にライブラリの使い方を学ぶのには適してなさそう</li><li>ちょうど、ライフログ的なアプリが欲しかったので、それをつくってみることに決定</li><li>Mojo ベースでつくって、<a href="http://plagger.org/trac/wiki/WikiStartJa" shape="rect">Plagger</a> も読んでみようかな...</li><li>う、、それ以前に vim でのコードリーディングを、もっと効率的にできるようにならなにと。。</li><li>Plagger のプレゼン資料読んでるけど面白そう</li></ul>参考ページとか：<br clear="none"/><a shape="rect" href="http://d.hatena.ne.jp/charsbar/20081105/1225820041" target="_blank">Mojoを使ってみた - Charsbar::Note</a><br clear="none"/><a shape="rect" href="http://e8y.net/blog/2006/07/25/p126.html" target="_blank">Elementary, ... Googleで「はらへ</a><a shape="rect" href="http://e8y.net/blog/2006/07/25/p126.html" target="_blank">った」と検索するとピザが届くようにするまで</a><br clear="none"/><a href="http://plagger.org/trac/wiki/PlaggerPresentations" shape="rect">PlaggerPresentations - Plagger - Trac</a><br clear="none"/><br clear="none"/>Perl の対話環境<br clear="none"/><br clear="none"/></div><div>Ruby における irb のような REPL がないと、ちょっとした動作確認が面倒。</div><div><ul><li>perlsh というものがあるらしい（参考：<a shape="rect" href="http://d.hatena.ne.jp/secondlife/20060111/1136975310" target="_blank">perl でインタラクティブなシェルを実現する perlsh - 川o・-・）＜2nd life</a>）<br clear="none"/></li><li>しかし、インストールが面倒くさそう。cpan コマンドではインストールされない、とか<br clear="none"/></li><li>pirl というものもあるらしい（参考：<a shape="rect" href="http://jijixi.azito.com/cgi-bin/diary/index.rb?date=20080327#p04" target="_blank">jijixi's diary - Perl の対話環境 , perlsh (CPAN) , .perlshrc , pirl</a>）</li></ul></div><div><b>Devel::REPL / re.pl を使ってみる</b></div><div><b><br clear="none"/></b><a shape="rect" href="http://search.cpan.org/dist/Devel-REPL/lib/Devel/REPL.pm" target="_blank">Devel::REPL</a> - re.pl というコマンドがついてくる。CPAN で入れるのがよさげ</div><div><ul><li>グローバル変数（というかどうかさえ知らないけど）使えない？<br clear="none"/></li><li>my してやる→あー、これは use strict になってるのかな<br clear="none"/></li><li>コメントを書くと、スタックトレース吐いて死亡</li></ul><div><br clear="none"/></div><div>Plagger</div><div><br clear="none"/></div><div>Plagger 本体を svn co する</div><div><br clear="none"/></div><div>% svn co http://svn.bulknews.net/repos/plagger/trunk/plagger plagger<br clear="none"/></div><div><br clear="none"/></div><div>cpan で依存モジュールのみをインストール</div><div><br clear="none"/></div><div>cpan&gt; test Plagger</div><div><br clear="none"/></div><div>XML::LibXML がインストールできない。libxml2 が必要。</div><div><br clear="none"/></div><div>% sudo ln -s /usr/lib/libxml2.so.2 /usr/lib/libxml2.so<br clear="none"/></div><div><br clear="none"/></div><div>ん、ヘッダがない</div><div><br clear="none"/></div><div>% sudo aptitude install libxml2-dev<br clear="none"/></div><div><br clear="none"/></div><div>今度はテストが通らんし。</div><div>なんか、XML::LibXML::Common がうまくいってなかった</div><div><br clear="none"/></div><div>cpan&gt; force get XML::LibXML::Common</div><div>cpan&gt; install XML::LibXML::Common</div><div><br clear="none"/></div><div>XML::LibXML はインストールできた。</div><div><br clear="none"/></div><div>今度は XML::Liberal ... どうにも test が通らないので force install</div><div><br clear="none"/></div><div>% ./plagger --version<br clear="none"/>Plagger version 0.7.17<br clear="none"/></div><div><br clear="none"/></div><div>Plagger を試す</div><div><br clear="none"/></div><div>ライブラリの検索パスさえ通っていれば、特にインストールしなくても使えるみたいなので、しばらくはこのままで遊んでみよう。</div><div><br clear="none"/></div><div>MOJO_ROOT=$HOME/Mojo/mojo<br clear="none"/>PLAGGER_ROOT=$HOME/Plagger/plagger<br clear="none"/>PATH=$PATH:$MOJO_ROOT/bin:$PLAGGER_ROOT<br clear="none"/>PERL5LIB=$MOJO_ROOT/lib:$PLAGGER_ROOT/lib:$PERL5LIB<br clear="none"/>export PATH PERL5LIB<br clear="none"/></div><div><br clear="none"/></div><div>まずは examples/atode.yml をいじって試す（参考：<a href="http://d.hatena.ne.jp/keisukefukuda/20070116" shape="rect">[Plagger] del.icio.usをGMailに送る - Text::Easyhacking</a>）。</div><div><br clear="none"/></div><div><br clear="none"/></div><div>Ubuntu 8.10 に Net::SMTP::TLS をイ...</div></div></div>
    
    ]]></description> <pubDate>Wed, 14 Jan 2009 14:43:05 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#4e177acf-fab2-41f7-9b8b-2d535711c650</guid> 
  
  </item>

  
  <item> <title>Mojo と Mojolicious の日記</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#6bd80488-a713-47ea-999a-bac37c59d576</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Mojo, Mojolicious<br clear="none"/><div><br clear="none"/></div><div><b><a shape="rect" href="http://mojolicious.org/" target="_blank">Mojo</a></b> の開発版を git clone する：<br clear="none"/></div><div><br clear="none"/></div><div>% mkdir -p Mojo; cd Mojo<br clear="none"/></div><div>% <b>git clone git://github.com/kraih/mojo.git mojo</b></div>Initialized empty Git repository in /home/ishikawa/Mojo/mojo/.git/<br clear="none"/>remote: Counting objects: 2403, done.<br clear="none"/>remote: Compressing objects: 100% (2212/2212), done.<br clear="none"/>remote: Total 2403 (delta 1694), reused 209 (delta 116)<br clear="none"/>Receiving objects: 100% (2403/2403), 530.91 KiB | 277 KiB/s, done.<br clear="none"/>Resolving deltas: 100% (1694/1694), done.<br clear="none"/><br clear="none"/>最新のコミットを確認：<div><br clear="none"/>% cd mojo/<br clear="none"/>% git show <br clear="none"/><b>commit ca87975ef061383b793a92fbd18b3ee5c5b86251</b><br clear="none"/>Author: Sebastian Riedel &lt;sri@labs.kraih.com&gt;<br clear="none"/>Date: Tue Dec 16 18:32:11 2008 +0100<br clear="none"/><br clear="none"/>試しに、いきなりコマンドを実行してみる；<br clear="none"/><br clear="none"/></div><div>% perl ./bin/mojo<br clear="none"/>Welcome to the Mojo Framework!<br clear="none"/><br clear="none"/>HINT: In case you don't know what you are doing here try the manual!<br clear="none"/>perldoc Mojo::Manual<br clear="none"/>perldoc Mojo::Manual::GettingStarted<br clear="none"/><br clear="none"/>This is the interactive script interface, the syntax is very simple.<br clear="none"/>mojo &lt;script&gt;&lt;options&gt;<br clear="none"/><br clear="none"/>おぉ、動いた。<br clear="none"/><br clear="none"/></div><div>perldoc の検索パス</div><div><br clear="none"/></div><div>ん、、perldoc Mojo::Manual しても、ちゃんとマニュアルが表示されるな。いや、もちろん、表示されるのは嬉しいんだけど、これってどうやってマニュアルの場所を特定してるんだろう。lib ディレクトリを特別扱いするとか、カレントディレクトリ以下を探索する、とか？<br clear="none"/><br clear="none"/></div><div>perldoc -l Mojo とすると lib/Mojo.pm が出力されるので、perldoc が lib 以下を探索してるのは間違いなさそう。man perldoc しても環境変数みるよ、とかしか書いてないな。perldoc に -v オプションつけると、どこを検索してるかが表示される：</div><div><br clear="none"/></div><div><b>% perldoc -lv Mojo<br clear="none"/></b>...</div><div>Looking for Mojo in /usr/bin . <b>lib</b> /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 </div><div>...</div><div>lib/Mojo.pm<br clear="none"/></div><div><br clear="none"/></div><div>やはり、lib を検索対象に含めてるようだ。</div><div><br clear="none"/></div><div>% perl -le 'print foreach @INC;'<br clear="none"/>/etc/perl<br clear="none"/>/usr/local/lib/perl/5.10.0<br clear="none"/>/usr/local/share/perl/5.10.0<br clear="none"/>/usr/lib/perl5<br clear="none"/>/usr/share/perl5<br clear="none"/>/usr/lib/perl/5.10<br clear="none"/>/usr/share/perl/5.10<br clear="none"/>/usr/local/lib/site_perl<br clear="none"/>.<br clear="none"/></div><div><br clear="none"/></div><div>@INC には含まれていないところをみると、perldoc の挙動なのかな。Pod::Perldoc のソースを読んでみるか：</div><div><br clear="none"/></div><div>% vi `perldoc -lm Pod::Perldoc`<br clear="none"/> 428     $self-&gt;maybe_diddle_INC();<br clear="none"/>...<br clear="none"/> 454 sub maybe_diddle_INC {<br clear="none"/>1455   my $self = shift;<br clear="none"/>1456 <br clear="none"/>1457   # Does this look like a module or extension directory?<br clear="none"/>1458 <br clear="none"/>1459   if (-f &quot;Makefile.PL&quot;) {<br clear="none"/>1460 <br clear="none"/><b>1461     # Add &quot;.&quot; and &quot;lib&quot; to @INC (if they exist)<br clear="none"/>1462     eval q{ use lib qw(. lib); 1; } or die;<br clear="none"/></b></div><div><br clear="none"/></div><div>maybe_diddle_INC 関数の中で追加してるっぽい。納得。<br clear="none"/></div><div><br clear="none"/></div><div>Mojo と Mojolicious を使用可能にする</div><div><br clear="none"/></div><div>通常は Makefile.PL でインストールするようだが、今回はインストールせずに clone したディレクトリそのままで...</div></div>
    
    ]]></description> <pubDate>Mon, 05 Jan 2009 09:12:45 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#6bd80488-a713-47ea-999a-bac37c59d576</guid> 
  
  </item>

  
  <item> <title>CPAN メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#a5bcf544-f245-4433-bd00-0ab170c3b368</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote"><div>設定の変更</div><div><br clear="none"/></div><div>cpan&gt; o conf &lt;name&gt; &lt;param&gt;</div><div>cpan&gt; o conf commit</div><div><br clear="none"/></div><div>o commit しなければ、そのセッション中だけ有効。あるモジュールでだけ設定を変更したい場合などは o commit しない。</div><div><br clear="none"/></div><div>[Y/n] で自動的に Y を選ぶ設定<br clear="none"/><br clear="none"/>cpan&gt; o conf prerequisites_policy follow<br clear="none"/>cpan&gt; o conf commit</div><div><br clear="none"/></div><div>CPAN 自体のアップデート</div><div><br clear="none"/></div><div>cpan&gt; install Bundle::CPAN</div><div>cpan&gt; reload cpan</div><div><br clear="none"/></div><div>手動でインデックス更新とキャッシュのスキャン</div><div><br clear="none"/></div><div>perl -MCPAN -e 'CPAN::Index-&gt;force_reload; my $c = CPAN::CacheMgr-&gt;new; $c-&gt;{SCAN} = q/atstart/; $c-&gt;scan_cache'</div><br clear="none"/><div><div>表示テキストの色づけ</div><div><br clear="none"/></div><div>参考：<a href="http://d.hatena.ne.jp/ymorimo/20070222/1172170190" shape="rect">CPAN shellでテキスト色づけ - ymorimoの日記</a></div><div><br clear="none"/></div><div>cpan[5]&gt; o conf colorize_output 1                                                                          <br clear="none"/></div><div>cpan[6]&gt; o conf colorize_print 'bold cyan on_black'                                                        <br clear="none"/></div><div>cpan[7]&gt; o conf colorize_warn 'bold yellow on_black' </div><div><br clear="none"/></div><div>依存パッケージのみをインストール</div><div><br clear="none"/></div><div>cpan&gt; test ...</div><div><br clear="none"/></div><div>該当モジュールを test すると、結果的に依存モジュールがインストールされる</div><div><br clear="none"/></div></div></div>
    
    ]]></description> <pubDate>Fri, 02 Jan 2009 11:18:04 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#a5bcf544-f245-4433-bd00-0ab170c3b368</guid> 
  
  </item>

  
  <item> <title>make, autoconf, automake</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#ceb67740-b371-424c-918d-99f52bfca4f6</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Autoconf<div><br clear="none"/><b>文字列のクォート</b><br clear="none"/></div><div><br clear="none"/></div><div>m4 のクォートは '`' と ''' だが、 これらはシェルスクリプトで頻繁に使われるため、autoconf はクォート文字を '[' と ']' に変更している。もしも、スクリプト中で '[' と ']' を使いたい場合は、@&lt;:@ と @:&gt;@ を使う（参考：<a shape="rect" href="http://www.ensta.fr/~diam/dev/online/autoconf/autobook/autobook_197.html" target="_blank">Autoconf, Automake, and Libtool: Quoting</a>）。ちなみに $ 記号を書く場合は @S|@ とする（参考：<a shape="rect" href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs" target="_blank">8.1.6 Quadrigraphs</a>）</div><div><br clear="none"/><b>AC_INIT で '$' を使いたい</b><br clear="none"/></div><div><br clear="none"/></div><div>当初、configure.ac のリテラルで '$' を使うために、autoconf の特殊文字を使って；<br clear="none"/><br clear="none"/>  AC_INIT([A @S|@1 Gesture Recognizer], [0.1], [bugs@...])<br clear="none"/><br clear="none"/>としていたのだが、これだと生成された configure を --help オプション指定で実行すると、$1 が変数展開されてしまう。<br clear="none"/><br clear="none"/></div><div>そこで、バックスラッシュでエスケープしてみる：<br clear="none"/><br clear="none"/>  AC_INIT([A \@S|@1 Gesture Recognizer], [0.1], [bugs@...])<br clear="none"/><br clear="none"/>そうすると、今度は config.h で：<br clear="none"/><br clear="none"/>  /* Define to the full name and version of this package. */<br clear="none"/>  #define PACKAGE_STRING &quot;A <b>\$1</b> Gesture Recognizer 0.1&quot;<br clear="none"/><br clear="none"/>こうなってしまい、\$ は不正なエスケープシーケンスとなってしまう。<br clear="none"/><br clear="none"/><b>Makefile.in での変数展開</b><br clear="none"/><br clear="none"/>configure スクリプトで Makefile.in から Makefile を生成するとき、Makefile.in に書かれた @...@ 形式の変数は展開される。automake を使っている場合、Makefile.in は Makefile.am から生成されるので、これらの変数を Makefile.am に書く（<a shape="rect" href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Makefile-Substitutions" target="_blank">4.8 Substitutions in Makefiles | Autoconf</a>）。<br clear="none"/><b><br clear="none"/></b></div><div><b>コミットしないファイル一覧 (.gitignore)</b><br clear="none"/><br clear="none"/></div><div>autoscan.log<br clear="none"/>Makefile<br clear="none"/>autom4te.cache<br clear="none"/>config.log<br clear="none"/>config.status<br clear="none"/>config.h<br clear="none"/>stamp-h1<br clear="none"/>.deps<br clear="none"/><br clear="none"/>Automake<br clear="none"/><br clear="none"/>% autoscan<br clear="none"/>% ls<br clear="none"/><b>autoscan.log  configure.scan</b>  hello.c<br clear="none"/><br clear="none"/>% touch <b>NEWS ChangeLog README AUTHORS</b><br clear="none"/>% aclocal% autoconf <br clear="none"/>% automake -a -c<br clear="none"/><br clear="none"/>% ./configure <br clear="none"/>% make<br clear="none"/>% ./hello <br clear="none"/>Hello, World!<br clear="none"/>% ls<br clear="none"/><b>AUTHORS    INSTALL      </b><b>Makefile.in</b><b>  aclocal.m4      config.log     </b><b>configure.ac</b><b>  install-sh<br clear="none"/>COPYING    Makefile     NEWS         autom4te.cache  config.status  depcomp       missing<br clear="none"/>ChangeLog  </b><b>Makefile.am</b><b>  README       autoscan.log    configure      hello.c<br clear="none"/></b><br clear="none"/>これら、autoconf や automake の実行は autoreconf 一発でいい：<br clear="none"/>% autoreconf --install<br clear="none"/><br clear="none"/>AM_INIT_AUTOMAKE<br clear="none"/><br clear="none"/>AM_INIT_AUTOMAKE にオプションを渡せる<ul><li>foreign NEWS README など必要なくする</li><li>nostdinc デフォルトの -I をなくす</li></ul><br clear="none"/>参考情報<div><div><ul><li><a shape="rect" href="http://enbug.org/HackingWithGnu/GnuMake" target="_blank">HackingWithGnu/GnuMake - enbug.org</a><br clear="none"/></li><li><a shape="rect" href="http://enbug.org/HackingWithGnu/GnuAutomake" target="_blank">HackingWithGnu/GnuAutomake - enbug.org</a><br clear="none"/></li><li><a shape="rect" href="http://sources.redhat.com/automake/automake.html" target="_blank">automake</a></li></ul><br clear="none"/></div></div></div></div>
    
    ]]></description> <pubDate>Sat, 27 Dec 2008 09:22:49 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#ceb67740-b371-424c-918d-99f52bfca4f6</guid> 
  
  </item>

  
  <item> <title>AppleScript メモ</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#761e9e5a-3a85-4635-9c7d-d4aff98faf3b</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">アプリケーションが起動しているかどうか確認<br clear="none"/>tell application &quot;System Events&quot;<br clear="none"/>  exists application process &quot;Evernote&quot;<br clear="none"/>end tell<br clear="none"/><br clear="none"/>指定回数ループ<br clear="none"/>repeat x times<br clear="none"/>  ...<br clear="none"/>end repeat<br clear="none"/><br clear="none"/>System Events: 左移動、右移動<br clear="none"/>keystroke (ASCII character 28) -- &lt;-<br clear="none"/>keystroke (ASCII character 29) -- -&gt;<br clear="none"/><br clear="none"/>System Events: keystroke で複数のモディファイアを指定する<br clear="none"/>keystroke (ASCII character 28) using {shift down, option down}<br clear="none"/><br clear="none"/>参考情報<ul><li><a href="http://www.apple.com/applescript/" shape="rect">AppleScript: The Language of Automation</a></li></ul><br clear="none"/></div>
    
    ]]></description> <pubDate>Mon, 15 Dec 2008 14:00:05 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#761e9e5a-3a85-4635-9c7d-d4aff98faf3b</guid> 
  
  </item>

  
  <item> <title>Google Native Client</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#b8e70be3-3324-4dcb-9537-e62703f5d0ba</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">Google からリリースされた研究プロジェクト。Web ブラウザ上でネイティブコードを実行するためのプロダクト：<ul><li>Native Client はブラウザ用プラグインによるランタイムとGCC ベースのコンパイラで構成されている</li><li>ネイティブコードと同等の速度をもつ Web アプリケーションを開発可能</li><li>現時点での対応ブラウザは Firefox, Safari, Opera, and Google Chrome (Mac, Linux, Windows) x86 CPU</li><li>ARM や PPC も対応予定</li><li>セキュリティや移植性について：コードのディスアセンブルによりインストラクションレベルで制御？</li></ul>Native Client (NaCl)<div><br clear="none"/></div><div>Native Client は予期しない副作用を防ぐための、制限された実行環境と安全なコードを実行するためのランタイムで構成されている。</div><ul><li>OS, ブラウザ間でポータブルな x86 バイナリのサンドボックス</li><li>高いパフォーマンスを追求するための、スレッドや SSE インストラクション、コンパイラの独自拡張、アセンブラのサポート</li><li>新しいコンパイラや言語に対応するためのオープンなデザイン</li><li>オーバーヘッドを減らし、よりシンプルにするために x86 セグメント機構を活用</li></ul><div>参考情報<br clear="none"/></div><div><div><ul><li><a href="http://code.google.com/p/nativeclient/" shape="rect">nativeclient - Google Code</a><br clear="none"/></li><li><a href="http://nativeclient.googlecode.com/svn/trunk/nacl/googleclient/native_client/documentation/nacl_paper.pdf" shape="rect">Native Client: A Sandbox for Portable, Untrusted x86 Native Code</a> [PDF]<br clear="none"/></li><li><a href="http://google-code-updates.blogspot.com/2008/12/native-client-technology-for-running.html" shape="rect">Google Code Blog: Native Client: A Technology for Running Native Code on the Web</a><br clear="none"/></li><li><a href="http://blog.deadbeaf.org/2008/12/09/google-native-client/" shape="rect">mootoh.log - Native Client</a><br clear="none"/></li><li><a href="http://d.hatena.ne.jp/amachang/20081209/1228804423" shape="rect">ブラウザで X86 のマシン語を動かす！ Google 謹製 Native Client をさっそく試してみる - IT戦記</a><br clear="none"/></li><li><a href="http://d.hatena.ne.jp/yaneurao/20081211#p1" shape="rect">Native Clientの仕組みはどうなっているのか？ - やねうらお−よっちゃんイカはしばらく買わずにiPhoneだけに注力する男</a><br clear="none"/></li><li><a href="http://steps.dodgson.org/?date=20081214" shape="rect">最近読んだ VM の本 | steps to phantasien(2008-12-14)</a><br clear="none"/></li></ul></div></div></div>
    
    ]]></description> <pubDate>Mon, 15 Dec 2008 10:54:25 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#b8e70be3-3324-4dcb-9537-e62703f5d0ba</guid> 
  
  </item>

  
  <item> <title>GCC の警告・エラーのオプション設定</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#97652250-d0af-4d73-b4d4-319eded65cea</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">GCC の警告オプションでよく使うもの<br clear="none"/><ul><li>-Wall 一般的な警告オプション<br clear="none"/></li><li>-Wextra gcc 4 より古いバージョンでは -W だった。-Wall 以外の警告</li><li>-Werror 警告をエラーにする</li></ul><div>-Wunused について</div><div><br clear="none"/></div><div>-Wunused は -W が有効な場合、-Wunused-parameter も有効になる。-Wunused は -Wall によっても暗黙的に有効になるため、-W と -Wall を両方指定すると、-Wunused-parameter が有効になる。このとき、もし、-Werror も有効になっていると、関数の引数で使われていないとコンパイルエラーになってしまい都合が悪い。たとえば、テスト駆動開発では関数の中身を空にしておくことがあるが、上記の場合は、これがエラーになってしまう。</div><div><br clear="none"/></div><div>Xcode (Mac OS X Leopard) 付属の Apple gcc 4.0.1 の場合、-Wno-unused-parameter を指定することで「未使用の関数引数」警告自体をなくすことはできる。しかし、できれば、「未使用の関数引数」も警告のまま残し、他の警告はエラー扱いしたい。</div><div><br clear="none"/></div><div>  % gcc -Iinclude -O0 -std=c++98 -pedantic -Wall -Wextra -Werror <b>-Wno-unused-parameter</b> -c -o src/utils.o src/utils.cpp<br clear="none"/></div><div><br clear="none"/></div><div><b>-Werror=</b></div><div><br clear="none"/></div><div><a href="http://gcc.gnu.org/gcc-4.2/" shape="rect">gcc 4.2</a> からは <a href="http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Warning-Options.html#index-Werror_003d-325" shape="rect">-Werror= および -Wno-error= というオプション</a>が追加され、エラー扱いにする警告を個別に指定できるようになった。このオプションを使えば、-Wunused-parameter は警告のまま、その他の警告をエラーに出来るだろう。Mac OS X Leopard では gcc 4.2.1 は gcc-4.2 という名前でインストールされている。</div><div><br clear="none"/></div><div>  % gcc-4.2 -Iinclude -O0 -std=c++98 -pedantic -Wall -Wextra -Werror <b>-Wno-error=unused-parameter</b> -c -o src/utils.o src/utils.cpp<br clear="none"/>  src/utils.cpp:108: warning: unused parameter 'start'<br clear="none"/>  src/utils.cpp:108: warning: unused parameter 'end'<br clear="none"/>  src/utils.cpp:108: warning: unused parameter 'positiveOnly'<br clear="none"/></div><div><br clear="none"/></div><div>しかし、Mac の場合、gcc 4.2.1 がデフォルトでない以上、このオプションを使っていいのか悩むところ。</div><div><br clear="none"/></div><div><b>環境変数の利用</b></div><div><br clear="none"/></div><div>Makefile には直接書かずに、環境変数で指定する、という手もある：</div><div><br clear="none"/></div><div>  % CXX=gcc-4.2 CPPFLAGS=-Wno-error=unused-parameter make<br clear="none"/></div><div><br clear="none"/></div><div>オンラインマニュアル</div><ul><li><a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html#Warning-Options" shape="rect">GCC 4.3.2 の警告オプション</a><br clear="none"/></li><li><a href="http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Warning-Options.html" shape="rect">Apple GCC 4.0.1 の警告オプション</a><br clear="none"/></li></ul><div><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Fri, 12 Dec 2008 09:19:33 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#97652250-d0af-4d73-b4d4-319eded65cea</guid> 
  
  </item>

  
  <item> <title>LLVM 2.4 インストール</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#2040b8c0-766c-441b-9a34-ed94c7857585</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">遅まきながら、<a href="http://llvm.org/releases/2.4/docs/ReleaseNotes.html" shape="rect">LLVM 2.4</a> を Mac OS X Leopard にインストールする。<div><br clear="none"/></div><div>ソースコードをダウンロードして解凍</div><div><br clear="none"/></div><div>  % curl -LO http://llvm.org/releases/2.4/llvm-2.4.tar.gz<br clear="none"/></div><div>  % tar xvzf llvm-2.4.tar.gz <br clear="none"/></div><div>  % cd llvm-2.4<br clear="none"/></div><div><br clear="none"/></div><div>コンパイル、インストール</div><div><br clear="none"/></div><div>  % ./configure --prefix=/Users/ishikawa/Developer/Workspace/Pekoe/llvm<br clear="none"/></div><div>  % gmake -k -j2 2&gt;&amp;1 | tee make.log</div><div><br clear="none"/></div><div>特に、書き残すまでもなかったかな...<br clear="none"/></div><div><br clear="none"/></div><div>既存のプログラムがコンパイル通らない</div><div><br clear="none"/></div><div>LLVM 2.4 にすると、コンパイルできなくなった。こんなエラー：</div><div><br clear="none"/></div><div>g++  -g -O2 -I./include -Wall -W -Wwrite-strings -Wno-unused -Wpointer-arith -Wstrict-aliasing=2 -Winit-self -ansi -std=c++98 `llvm-config --cxxflags core jit native`  -c -o src/generator.o src/generator.cc<br clear="none"/>src/generator.cc:67: error: ISO C++ forbids declaration of 'IRBuilder' with no type<br clear="none"/></div><div><br clear="none"/></div><div>llvm::IRBuilder が変更された？ <a href="http://llvm.org/releases/2.4/docs/ReleaseNotes.html" shape="rect">Release Note</a> を読む。これかな？</div><div><br clear="none"/></div><div><i>The</i><i> </i><i>IRBuilder</i><i> </i><i>class is now parameterized by a class responsible for constant folding.</i><br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div><div><br clear="none"/></div></div>
    
    ]]></description> <pubDate>Thu, 11 Dec 2008 10:26:34 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#2040b8c0-766c-441b-9a34-ed94c7857585</guid> 
  
  </item>

  
  <item> <title>Adobe Alchemy</title> <link>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#27bc6623-12c4-4f51-9a22-90499f2c13c5</link>
  <description><![CDATA[
    
    
    
        
        <div class="ennote">以前から話題にのぼっていた <a href="http://labs.adobe.com/" shape="rect">Adobe Labs</a> の研究プロジェクト、<a href="http://labs.adobe.com/technologies/alchemy/" shape="rect">Alchemy</a>（コードネーム）。<div><br clear="none"/></div><div>ActionScript VM 上で動作するプログラムを C/C++ コードで記述できるようになる。これはつまり、既存の C/C++ プログラムが Flash Player や <a href="http://www.adobe.com/jp/products/air/" shape="rect">AIR</a> 上で動作することを意味している。また、C/C++ プログラムのコンパイルには <a href="http://llvm.org/" shape="rect">LLVM</a> を利用しており、そこで生成された中間コードが <b>ActionScript 3.0 のソースコードに変換</b>される（そのままバイトコードには変換しない）。その後、生成された ActionScript コードが Alchemy 特製の ActionScript コンパイラで ActionScript Byte Code  (ABC) にコンパイルされるようだ。</div><ul><li>既存の C/C++ ライブラリの再利用に。特に OS 非依存なもの（例：オーディオ／ビデオ、XML パース、暗号処理、シミュレーション）<br clear="none"/></li><li>C/C++ コードは ActionScript 3.0 の SWF または SWC にコンパイルされる</li><li>C/C++ と ActionScript 間のブリッジ。SWF/SWC のセキュリティ制限やサンドボックスは通常の SWF/SWC と同様</li><li>CPU バウンドなプログラムなら Alchemy でコンパイルすると 10 倍ほども速くなるかもしれない。これは、LLVM による最適化の恩恵と、ByteArray に関する最適化された命令が理由（ActionScript コンパイラではまだ使われていない）</li><li>C/C++ コードから &quot;AS3.h&quot; の API を使うことで、Flash Player にアクセス可能</li></ul><div>インストール</div><ol><li><a href="http://www.adobe.com/jp/products/flashplayer/" shape="rect">Flash Player 10</a> が必要</li><li><a href="http://labs.adobe.com/downloads/alchemy.html" shape="rect">ダウンロードページ</a>から Alchemy ツールキットを落とす（思ったより軽い）</li><li>あとは、<a href="http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Getting_Started" shape="rect">Alchemy:Documentation:Getting Started - Adobe Labs</a> を参考に進めてみる<br clear="none"/></li><li><a href="http://www.adobe.com/products/flex/flexdownloads/#sdk" shape="rect">Flex SDK 3.2</a> をダウンロードする</li></ol>$FLEX_HOME/bin を PATH に追加する<br clear="none"/><div><br clear="none"/></div><div>  % adt -version<br clear="none"/>  adt version &quot;1.5.0.7220&quot;<br clear="none"/></div><div><br clear="none"/></div><div>Alchemy のディレクトリに移動し、config プログラムを実行する</div><div><br clear="none"/></div><div>  % cd Developer/System/Flash/alchemy-darwin-v0.4a/<br clear="none"/>  % ./config<br clear="none"/></div><div><br clear="none"/></div><div>config プログラムで生成された alchemy-setup をシェルの起動時に読み込むようにする：</div><div><br clear="none"/></div><div>  source /Users/ishikawa/Developer/System/Flash/alchemy-darwin-v0.4a/alchemy-setup<br clear="none"/></div><div><br clear="none"/></div><div>また、alchemy-setup は PATH を<b>変更する前に読み込</b>むらしい。</div><div>そして、次に、${ALCHEMY_HOME}/achacks を PATH に追加する。最終的に以下のようになる：</div><div><br clear="none"/></div><div>  # Flash, Flex, Alchemy ...<br clear="none"/>  source /Users/ishikawa/Developer/System/Flash/alchemy-darwin-v0.4a/alchemy-setup<br clear="none"/>  PATH=${PATH}:/Users/ishikawa/Developer/System/Flash/flex_sdk_3/bin<br clear="none"/>  PATH=${PATH}:${ALCHEMY_HOME}/achacks<br clear="none"/></div><div>  ...</div><div>  export PATH</div><div><br clear="none"/></div><div>サンプルを試す</div><div><br clear="none"/></div><div>では、同梱されているサンプルを試してみよう：</div><div><br clear="none"/></div><div>  % cd $ALCHEMY_HOME/samples/stringecho<br clear="none"/>  % which gcc<br clear="none"/>  /usr/bin/gcc<br clear="none"/>  % alc-on; which gcc<br clear="none"/>  /Users/ishikawa/Developer/System/Flash/alchemy-darwin-v0.4a/achacks/gcc<br clear="none"/></div><div><br clear="none"/></div><div>まず、alc-on を実行すると、gcc が Alchemy 独自のものに切り替わるのが分かると思う。</div><div>そして、samples/stringecho にあるファイルは以下の通り：</div><div><br clear="none"/></div>- as3/<div>  - EchoTest.as</div><div>- readme.txt</div><div>- stringecho.c<br clear="none"/><br clear="none"/><div>ここで、Alchemy 独自の gcc で stringecho.c をコンパイルする</div><div><br clear="none"/></div><div>  % gcc stringecho.c -O3 -Wall -swc -o stringecho.swc<br clear="none"/>  WARNING: While resolving call to function 'main' arguments were dropped!<br clear="none"/>  ...<br clear="none"/>  464.achacks.swf, 362566 bytes ...</div></div></div>
    
    ]]></description> <pubDate>Thu, 11 Dec 2008 09:19:12 GMT</pubDate> <guid>http://www.evernote.com/pub/ishikawa_takanori/ProgrammingNotes#27bc6623-12c4-4f51-9a22-90499f2c13c5</guid> 
  
  </item>
 </channel> </rss>