<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Memorandum</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/" />
    <link rel="self" type="application/atom+xml" href="http://www.pistolfly.jp/weblog/atom.xml" />
    <id>tag:www.pistolfly.jp,2008-02-03:/weblog//1</id>
    <updated>2012-05-17T07:05:55Z</updated>
    <subtitle>個人的な技術メモ。</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 5.12</generator>

<entry>
    <title>[.net] システムのログオフやシャットダウンを検出して処理を行う</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/05/post-145.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1441</id>

    <published>2012-05-17T06:27:55Z</published>
    <updated>2012-05-17T07:05:55Z</updated>

    <summary> SystemEvents.SessionEnding イベント (Micros...</summary>
    <content type="html"><![CDATA[<p>
<a href="http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.sessionending.aspx" target="_blank">SystemEvents.SessionEnding イベント (Microsoft.Win32)</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term=".net" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="http://msdn.microsoft.com/ja-jp/library/microsoft.win32.systemevents.sessionending.aspx" target="_blank">SystemEvents.SessionEnding イベント (Microsoft.Win32)</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[.net] log4netでログ出力先パス、ファイル名の取得、設定</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/05/log4net.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1440</id>

    <published>2012-05-17T04:31:19Z</published>
    <updated>2012-05-17T04:36:08Z</updated>

    <summary> log4net.Repository.ILoggerRepository[] ...</summary>
    <content type="html"><![CDATA[<pre class="prettyprint">
log4net.Repository.ILoggerRepository[] repositories = log4net.LogManager.GetAllRepositories();
foreach (log4net.Repository.ILoggerRepository repository in repositories)
{
    foreach (log4net.Appender.IAppender appender in repository.GetAppenders())
    {
        log4net.Appender.FileAppender fileAppender = appender as log4net.Appender.FileAppender;
        if (fileAppender != null)
        {
            appender.File = "log.log"; //出力先ファイルを設定
            appender.ActivateOptions();
        }
    }
}
</pre>

<p>
※ 上記のようにコードでFileを設定する場合も、依然としてXMLの設定にはFileの指定は必要だった。
</p>

<p>
<br />
<a href="http://dobon.net/vb/bbs/log3-36/22030.html" target="_blank">log4netで設定したログ出力先パス、ファイル名の取得: DOBON.NETプログラミング掲示板過去ログ</a>
</p>

<p>
<a href="http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=30980&forum=7" target="_blank">log4netでのログ出力について － Insider.NET － ＠IT</a>)
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term=".net" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<pre class="prettyprint">
log4net.Repository.ILoggerRepository[] repositories = log4net.LogManager.GetAllRepositories();
foreach (log4net.Repository.ILoggerRepository repository in repositories)
{
    foreach (log4net.Appender.IAppender appender in repository.GetAppenders())
    {
        log4net.Appender.FileAppender fileAppender = appender as log4net.Appender.FileAppender;
        if (fileAppender != null)
        {
            appender.File = "log.log"; //出力先ファイルを設定
            appender.ActivateOptions();
        }
    }
}
</pre>

<p>
※ 上記のようにコードでFileを設定する場合も、依然としてXMLの設定にはFileの指定は必要だった。
</p>

<p>
<br />
<a href="http://dobon.net/vb/bbs/log3-36/22030.html" target="_blank">log4netで設定したログ出力先パス、ファイル名の取得: DOBON.NETプログラミング掲示板過去ログ</a>
</p>

<p>
<a href="http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=30980&forum=7" target="_blank">log4netでのログ出力について － Insider.NET － ＠IT</a>)
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[c] C言語のマクロの #、 ##</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/05/c-3.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1438</id>

    <published>2012-05-13T01:53:02Z</published>
    <updated>2012-05-13T01:54:59Z</updated>

    <summary> # は、引数を文字列に変換する。  ## は二つの識別子を連結させる。  C ...</summary>
    <content type="html"><![CDATA[<p>
# は、引数を文字列に変換する。 <br />
## は二つの識別子を連結させる。 
</p>

<p>
<a href="http://uyota.asablo.jp/blog/2007/03/18/1311411" target="_blank">C 言語 マクロ講座 # ## 編: uyota 匠の一手</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="c" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
# は、引数を文字列に変換する。 <br />
## は二つの識別子を連結させる。 
</p>

<p>
<a href="http://uyota.asablo.jp/blog/2007/03/18/1311411" target="_blank">C 言語 マクロ講座 # ## 編: uyota 匠の一手</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[mysql] MySQLのいろいろな限界について</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/05/-mysql-1.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1433</id>

    <published>2012-05-03T06:35:42Z</published>
    <updated>2012-05-08T09:50:00Z</updated>

    <summary> 漢(オトコ)のコンピュータ道: 限界までMySQLを使い尽くす!! SQL文の...</summary>
    <content type="html"><![CDATA[<p>
<a href="http://nippondanji.blogspot.jp/2009/05/mysql.html" target="_blank">漢(オトコ)のコンピュータ道: 限界までMySQLを使い尽くす!!</a>
</p>

<p>
SQL文の最大長、データベースの個数、データベースあたりのテーブル数等、MySQLのいろいろな限界について。
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="mysql" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="http://nippondanji.blogspot.jp/2009/05/mysql.html" target="_blank">漢(オトコ)のコンピュータ道: 限界までMySQLを使い尽くす!!</a>
</p>

<p>
SQL文の最大長、データベースの個数、データベースあたりのテーブル数等、MySQLのいろいろな限界について。
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[windows] Windowsでスタンバイを抑止する方法</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/04/windows-3.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1430</id>

    <published>2012-04-28T04:02:54Z</published>
    <updated>2012-05-08T09:36:52Z</updated>

    <summary> Windowsでスタンバイを抑止する方法 - notes plastiques...</summary>
    <content type="html"><![CDATA[<p>
<a href="http://d.hatena.ne.jp/aont/20100121/1264089608" target="_blank">Windowsでスタンバイを抑止する方法 - notes plastiques</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term=".net" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="windows" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="http://d.hatena.ne.jp/aont/20100121/1264089608" target="_blank">Windowsでスタンバイを抑止する方法 - notes plastiques</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[ruby] 1.9.2、1.9.3で動作するruby-debug19のfork「debugger」</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/04/192193ruby-debug19fork-debugge.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1419</id>

    <published>2012-04-04T11:29:54Z</published>
    <updated>2012-04-04T11:37:21Z</updated>

    <summary> cldwalker/debugger · GitHub ...</summary>
    <content type="html"><![CDATA[<p>
<a href="https://github.com/cldwalker/debugger" target="_blank">cldwalker/debugger · GitHub</a><br />

</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="ruby" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="ruby on rails" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="https://github.com/cldwalker/debugger" target="_blank">cldwalker/debugger · GitHub</a><br />

</p>]]>
        
    </content>
</entry>

<entry>
    <title>[ruby] Mac OS X Lion RVMのRuby1.9.3でSegmentation fault</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/03/rvmruby193segmentation-fault.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1410</id>

    <published>2012-03-04T07:22:55Z</published>
    <updated>2012-03-14T08:02:55Z</updated>

    <summary> RVMでMac OS X LionにRuby1.9.3をインストール後、bun...</summary>
    <content type="html"><![CDATA[<p>
RVMでMac OS X LionにRuby1.9.3をインストール後、bundleしたらSegmentation faultが発生。
</p>

<pre class="command-line">
$ bundle
Fetching source index for https://rubygems.org/
/Users/pistolfly/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]
...
</pre>

<h3>解決方法</h3>

<pre class="command-line">
$ rvm pkg install openssl
$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
</pre>

<p>
<br />
<a href="http://somethingnew2.com/blog/archives/2012/02/ruby_193_rails_321_segmentation_fault.php" target="_blank">Ruby 1.9.3 + Rails 3.2.1 で segmentation fault -> 解決 - さとうようぞうのblog</a>
</p>

<p>
<a href="http://beginrescueend.com/packages/openssl/" target="_blank">RVM: Ruby Version Manager - 'rvm pkg install openssl'</a><br />

</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="mac" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="ruby" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
RVMでMac OS X LionにRuby1.9.3をインストール後、bundleしたらSegmentation faultが発生。
</p>

<pre class="command-line">
$ bundle
Fetching source index for https://rubygems.org/
/Users/pistolfly/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]
...
</pre>

<h3>解決方法</h3>

<pre class="command-line">
$ rvm pkg install openssl
$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
</pre>

<p>
<br />
<a href="http://somethingnew2.com/blog/archives/2012/02/ruby_193_rails_321_segmentation_fault.php" target="_blank">Ruby 1.9.3 + Rails 3.2.1 で segmentation fault -> 解決 - さとうようぞうのblog</a>
</p>

<p>
<a href="http://beginrescueend.com/packages/openssl/" target="_blank">RVM: Ruby Version Manager - 'rvm pkg install openssl'</a><br />

</p>]]>
        
    </content>
</entry>

<entry>
    <title>[linux] Xenの仮想サーバでclockを設定</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/02/xenclock.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1407</id>

    <published>2012-02-23T10:42:17Z</published>
    <updated>2012-03-18T03:16:07Z</updated>

    <summary> Xenの仮想サーバで時刻がずれていた。 ntpdで設定されるようにしているが、...</summary>
    <content type="html"><![CDATA[<p>
Xenの仮想サーバで時刻がずれていた。<br />
ntpdで設定されるようにしているが、ずれたまま。<br />
DomUの時刻は、Dom0からのみ更新できるというXenの仕様によるものらしい。
</p>

<p>
<a href="http://ken-etsu-tech.blogspot.com/2007/05/xendomuntp.html" target="_blank">検閲Tech: XenのDomUでNTPを使う</a>
</p>

<p>
ということは、Dom0の時刻がずれているのか。
</p>

<p>
DomUでNTPを使って時刻が設定できるようにした。
</p>

<pre class="command-line">
# echo 1 > /proc/sys/xen/independent_wallclock
</pre>

/etc/sysctl.conf
<pre class="prettyprint">
xen.independent_wallclock = 1
</pre>

<pre class="command-line">$ sudo yum install ntpd
$ sudo /sbin/chkconfig ntpd on
$ sudo /etc/init.d/ntpd start
$ sudo /usr/sbin/ntpdate &lt;ntpサーバ&gt;</pre>

<h3>ただし注意！</h3>
時刻が戻るとdovecotがダウンした。dovecotの仕様らしい。
dovecotのリスタートが必要だった。


/var/log/maillog
<pre class="command-line">
Feb 23 19:40:48 mail dovecot: Time just moved backwards by 105 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards
</pre>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="linux" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
Xenの仮想サーバで時刻がずれていた。<br />
ntpdで設定されるようにしているが、ずれたまま。<br />
DomUの時刻は、Dom0からのみ更新できるというXenの仕様によるものらしい。
</p>

<p>
<a href="http://ken-etsu-tech.blogspot.com/2007/05/xendomuntp.html" target="_blank">検閲Tech: XenのDomUでNTPを使う</a>
</p>

<p>
ということは、Dom0の時刻がずれているのか。
</p>

<p>
DomUでNTPを使って時刻が設定できるようにした。
</p>

<pre class="command-line">
# echo 1 > /proc/sys/xen/independent_wallclock
</pre>

/etc/sysctl.conf
<pre class="prettyprint">
xen.independent_wallclock = 1
</pre>

<pre class="command-line">$ sudo yum install ntpd
$ sudo /sbin/chkconfig ntpd on
$ sudo /etc/init.d/ntpd start
$ sudo /usr/sbin/ntpdate &lt;ntpサーバ&gt;</pre>

<h3>ただし注意！</h3>
時刻が戻るとdovecotがダウンした。dovecotの仕様らしい。
dovecotのリスタートが必要だった。


/var/log/maillog
<pre class="command-line">
Feb 23 19:40:48 mail dovecot: Time just moved backwards by 105 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards
</pre>]]>
        
    </content>
</entry>

<entry>
    <title>[c] GDBでint型配列の参照</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/02/gdbint.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1405</id>

    <published>2012-02-06T07:41:21Z</published>
    <updated>2012-02-17T05:27:42Z</updated>

    <summary> 配列はprintコマンド(p)で参照できるが、配列を引数で受け取った場合などポ...</summary>
    <content type="html"><![CDATA[<p>
配列はprintコマンド(p)で参照できるが、配列を引数で受け取った場合などポインタになっている場合は、@演算子を用いるとうまく表示できる。<br />
@演算子は、左項をアドレスとみなし、左項の型のデータを右項の数だけ配列のように表示する。
</p>

<pre class="command-line">
(gdb) l
34
35	void func(int v[], int len)
36	{
(gdb) p v[0] @ len
$1 = {4470, 5197, 2482, 1016, 4154, 9986, 8313, 6873, 8517, 5857, 9019, 8002, 349, 9817, 365, 1018, 2269, 9759, 7092, 8674, 4902, 3890, 9746, 7668, 792, 3842, 4053, 6422, 630, 4880, 9996, 7164, 8392, 8469, 2959, 8380, 6533, 1795, 4296, 9964, 8259, 7474, 72, 2948, 3681, 501, 3994, 508, 9544, 941, 8054, 2186, 7418, 8684, 3224, 7322, 3822, 5022, 3085, 8341, 2296, 4073, 1034, 9839, 7067, 1197, 739, 7028, 2809, 6610, 8633, 483, 3017, 9634, 4758, 8101, 7604, 4018, 2174, 5014, 6600, 3754, 2854, 4798, 3921, 2124, 9889, 1147, 2409, 6105, 224, 6973, 5937, 2953, 8614, 9101, 3399, 8431, 2226, 3548}
</pre>

<p>
<br />
<a href="http://idocsq.net/page/198" target="_blank">[GDB] int型配列の参照 - printコマンドの場合 | idocsq.net</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="c" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
配列はprintコマンド(p)で参照できるが、配列を引数で受け取った場合などポインタになっている場合は、@演算子を用いるとうまく表示できる。<br />
@演算子は、左項をアドレスとみなし、左項の型のデータを右項の数だけ配列のように表示する。
</p>

<pre class="command-line">
(gdb) l
34
35	void func(int v[], int len)
36	{
(gdb) p v[0] @ len
$1 = {4470, 5197, 2482, 1016, 4154, 9986, 8313, 6873, 8517, 5857, 9019, 8002, 349, 9817, 365, 1018, 2269, 9759, 7092, 8674, 4902, 3890, 9746, 7668, 792, 3842, 4053, 6422, 630, 4880, 9996, 7164, 8392, 8469, 2959, 8380, 6533, 1795, 4296, 9964, 8259, 7474, 72, 2948, 3681, 501, 3994, 508, 9544, 941, 8054, 2186, 7418, 8684, 3224, 7322, 3822, 5022, 3085, 8341, 2296, 4073, 1034, 9839, 7067, 1197, 739, 7028, 2809, 6610, 8633, 483, 3017, 9634, 4758, 8101, 7604, 4018, 2174, 5014, 6600, 3754, 2854, 4798, 3921, 2124, 9889, 1147, 2409, 6105, 224, 6973, 5937, 2953, 8614, 9101, 3399, 8431, 2226, 3548}
</pre>

<p>
<br />
<a href="http://idocsq.net/page/198" target="_blank">[GDB] int型配列の参照 - printコマンドの場合 | idocsq.net</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[ruby on rails] Change PATH environment with Rails and Capistrano</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/change-path-environment-with-r.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1403</id>

    <published>2012-01-31T07:28:51Z</published>
    <updated>2012-01-31T12:03:08Z</updated>

    <summary>Capfileに load &apos;deploy/assets&apos; を追加すると、デプロ...</summary>
    <content type="html"><![CDATA[Capfileに
<pre class="prettyprint">
load 'deploy/assets'
</pre>
を追加すると、デプロイ時にassets:precompileを実行できるが、assets:precompile実行時に、
<pre class="command-line">
/usr/bin/env:
ruby
: そのようなファイルやディレクトリはありません
</pre>
というエラーになってしまった。
ssh経由でのshellの実行時にPATHが通っていないのが原因と思われる。

<h3>解決方法</h3>

<p>
CapistranoでPATH等の環境変数を設定するには、:default_environmentを使う。
</p>

<pre class="prettyprint">	
set :default_environment, {
  'PATH' => "/opt/ruby-enterprise-1.8.7-2011.03/bin:$PATH"
}
</pre>

<p>
<br />
<a href="http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/" target="_blank">Change PATH environment with Rails and Capistrano - pastbedti.me</a><br />
<a href="http://stackoverflow.com/questions/1978797/how-do-i-configure-capistrano-to-use-my-rvm-version-of-ruby" target="_blank">How do I configure capistrano to use my rvm version of Ruby - Stack Overflow</a>
</p>


プリコンパイルする場合、config/environments/production.rbで、
<pre class="prettyprint">
config.assets.compile = false
</pre>
にするが、assetsにapplication.js, application.css以外のjs、cssを使う場合は、以下のようにconfig.assets.precompileに追加する必要がある。追加しないと、smart_phone.css isn't precompiled のようなエラーになる。

<p>

</p>

config/environments/production.rb
<pre class="prettyprint">
config.assets.compile = false
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( smart_phone.css web_app_theme.css )
</pre>
]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="ruby on rails" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[Capfileに
<pre class="prettyprint">
load 'deploy/assets'
</pre>
を追加すると、デプロイ時にassets:precompileを実行できるが、assets:precompile実行時に、
<pre class="command-line">
/usr/bin/env:
ruby
: そのようなファイルやディレクトリはありません
</pre>
というエラーになってしまった。
ssh経由でのshellの実行時にPATHが通っていないのが原因と思われる。

<h3>解決方法</h3>

<p>
CapistranoでPATH等の環境変数を設定するには、:default_environmentを使う。
</p>

<pre class="prettyprint">	
set :default_environment, {
  'PATH' => "/opt/ruby-enterprise-1.8.7-2011.03/bin:$PATH"
}
</pre>

<p>
<br />
<a href="http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/" target="_blank">Change PATH environment with Rails and Capistrano - pastbedti.me</a><br />
<a href="http://stackoverflow.com/questions/1978797/how-do-i-configure-capistrano-to-use-my-rvm-version-of-ruby" target="_blank">How do I configure capistrano to use my rvm version of Ruby - Stack Overflow</a>
</p>


プリコンパイルする場合、config/environments/production.rbで、
<pre class="prettyprint">
config.assets.compile = false
</pre>
にするが、assetsにapplication.js, application.css以外のjs、cssを使う場合は、以下のようにconfig.assets.precompileに追加する必要がある。追加しないと、smart_phone.css isn't precompiled のようなエラーになる。

<p>

</p>

config/environments/production.rb
<pre class="prettyprint">
config.assets.compile = false
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( smart_phone.css web_app_theme.css )
</pre>
]]>
        
    </content>
</entry>

<entry>
    <title>[mac] Mac OS X Lion の cron で tput: No value for $TERM and no -T specified</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/mac-os-x-cron-tput-no-value-fo.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1397</id>

    <published>2012-01-26T05:12:06Z</published>
    <updated>2012-02-12T05:08:31Z</updated>

    <summary> 以下のようにTERMを設定したら解消。 $ crontab -e TERM=x...</summary>
    <content type="html"><![CDATA[<p>
以下のようにTERMを設定したら解消。
</p>

<pre class="command-line">
$ crontab -e
</pre>

<pre>
TERM=xterm
</pre>
]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="mac" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
以下のようにTERMを設定したら解消。
</p>

<pre class="command-line">
$ crontab -e
</pre>

<pre>
TERM=xterm
</pre>
]]>
        
    </content>
</entry>

<entry>
    <title>[ruby on rails] Rack Middleware</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/rack-middleware.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1394</id>

    <published>2012-01-24T05:00:52Z</published>
    <updated>2012-01-30T03:41:47Z</updated>

    <summary> #151 Rack Middleware - RailsCasts ...</summary>
    <content type="html"><![CDATA[<p>
<a href="http://railscasts.com/episodes/151-rack-middleware?view=asciicast" target="_blank">#151 Rack Middleware - RailsCasts</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="ruby on rails" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="http://railscasts.com/episodes/151-rack-middleware?view=asciicast" target="_blank">#151 Rack Middleware - RailsCasts</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[apache] mod_proxyでバックエンドのサーバがダウンすると復旧しても 503 Service Temporarily Unavailable</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/mod-proxyservice-temporarily-u.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1389</id>

    <published>2012-01-18T06:58:31Z</published>
    <updated>2012-01-18T11:34:54Z</updated>

    <summary> mod_proxyでバックエンドのサーバがいったんダウンすると、復旧しても一定...</summary>
    <content type="html"><![CDATA[<p>
mod_proxyでバックエンドのサーバがいったんダウンすると、復旧しても一定時間（デフォルトでは60秒）は 503 Service Temporarily Unavailable になってしまう。
</p>

<p>
リトライするまでの時間は、ProxyPassディレクティブ の retry パラメータで指定することができる。<br />
（ProxyPass ディレクティブのスキームが balancer:// で始まる場合は、対応する &lt;Proxy&gt; セクション中の BalancerMember ディレクティブに retry パラメータを指定できる。）
</p>

<pre class="prettyprint">
ProxyPass / http://localhost:3000/ retry=5
ProxyPassReverse / http://localhost:3000/
</pre>

<pre class="prettyprint">ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
&lt;Proxy balancer://mycluster/&gt;
  BalancerMember http://localhost:9001 loadfactor=10 retry=5
  BalancerMember http://localhost:9002 loadfactor=10 retry=5
  BalancerMember http://localhost:9003 loadfactor=10 retry=5
&lt;/Proxy&gt;</pre>

<p>
<a href="http://httpd.apache.org/docs/2.1/ja/mod/mod_proxy.html" target="_blank">mod_proxy - Apache HTTP サーバ</a><br />
<a href="http://d.hatena.ne.jp/dayflower/20080215/1202974375" target="_blank">ProxyPass には retry=?? を指定しておく - daily dayflower</a><br />
<a href="http://d.hatena.ne.jp/yotena/20080216/1203130259" target="_blank">BalancerMemberにはretry=??を指定しておく - cys b</a><br />

</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="apache" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
mod_proxyでバックエンドのサーバがいったんダウンすると、復旧しても一定時間（デフォルトでは60秒）は 503 Service Temporarily Unavailable になってしまう。
</p>

<p>
リトライするまでの時間は、ProxyPassディレクティブ の retry パラメータで指定することができる。<br />
（ProxyPass ディレクティブのスキームが balancer:// で始まる場合は、対応する &lt;Proxy&gt; セクション中の BalancerMember ディレクティブに retry パラメータを指定できる。）
</p>

<pre class="prettyprint">
ProxyPass / http://localhost:3000/ retry=5
ProxyPassReverse / http://localhost:3000/
</pre>

<pre class="prettyprint">ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
&lt;Proxy balancer://mycluster/&gt;
  BalancerMember http://localhost:9001 loadfactor=10 retry=5
  BalancerMember http://localhost:9002 loadfactor=10 retry=5
  BalancerMember http://localhost:9003 loadfactor=10 retry=5
&lt;/Proxy&gt;</pre>

<p>
<a href="http://httpd.apache.org/docs/2.1/ja/mod/mod_proxy.html" target="_blank">mod_proxy - Apache HTTP サーバ</a><br />
<a href="http://d.hatena.ne.jp/dayflower/20080215/1202974375" target="_blank">ProxyPass には retry=?? を指定しておく - daily dayflower</a><br />
<a href="http://d.hatena.ne.jp/yotena/20080216/1203130259" target="_blank">BalancerMemberにはretry=??を指定しておく - cys b</a><br />

</p>]]>
        
    </content>
</entry>

<entry>
    <title>[ruby on rails] Phusion Passenger &amp; running multiple Ruby versions</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/phusion-passenger-running-mult.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1384</id>

    <published>2012-01-14T06:08:51Z</published>
    <updated>2012-01-14T09:42:35Z</updated>

    <summary> Phusion Passenger &amp; running multiple Ru...</summary>
    <content type="html"><![CDATA[<p>
<a href="http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/" target="_blank">Phusion Passenger & running multiple Ruby versions - Phusion Corporate Blog</a>
</p>]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="ruby on rails" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<p>
<a href="http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/" target="_blank">Phusion Passenger & running multiple Ruby versions - Phusion Corporate Blog</a>
</p>]]>
        
    </content>
</entry>

<entry>
    <title>[ruby] CentOSにRVMをマルチユーザ用にインストール</title>
    <link rel="alternate" type="text/html" href="http://www.pistolfly.jp/weblog/2012/01/centosrvm.html" />
    <id>tag:www.pistolfly.jp,2012:/weblog//1.1383</id>

    <published>2012-01-14T03:27:00Z</published>
    <updated>2012-01-29T07:01:36Z</updated>

    <summary>マルチユーザ用にRVMをインストール マルチユーザ用にRVMをインストールするに...</summary>
    <content type="html"><![CDATA[<h3>マルチユーザ用にRVMをインストール</h3>

<p>
マルチユーザ用にRVMをインストールするには、sudo でインストールする。
</p>

<p>
<a href="https://rvm.beginrescueend.com/rvm/install/" target="_blank">RVM: Ruby Version Manager - Installing RVM</a>
</p>

<pre class="command-line">
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Downloading RVM from wayneeseguin branch stable

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Could not download 'https://github.com/wayneeseguin/rvm/tarball/stable'.
  Make sure your certificates are up to date as described above.
  To continue in insecure mode run 'echo insecure >> ~/.curlrc'.
</pre>

<p>
curlのSSL証明書の検証でエラーになった。<br />
CA証明書が古いらしい。<br />
新しいCA証明書を取得する。
</p>

<h3>CA証明書のアップデート</h3>

<pre class="command-line">
$ sudo mv /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak # バックアップ
$ sudo curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
</pre>

<p>
<a href="http://d.hatena.ne.jp/kanonji/20111208/1323323155" target="_blank">curlでまたSSLのエラーが出たので対処 - kanonjiの日記</a><br />
<a href="http://curl.haxx.se/docs/sslcerts.html" target="_blank">cURL - Details on Server SSL Certificates</a><br />
<a href="http://curl.haxx.se/docs/caextract.html" target="_blank">cURL - Extract CA Certs from Mozilla</a>
</p>

<p>
再度sudoでRVMをインストール。
</p>

<pre class="command-line">
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  796k  100  796k    0     0   170k      0  0:00:04  0:00:04 --:--:--  340k

Installing RVM to /usr/local/rvm/
installing - /usr/local/rvm/man/man1/rvm.1 -
installing - /usr/local/rvm/man/man1/rvm.1.gz -
    Creating RVM system user group 'rvm'

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.beginrescueend.com/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /usr/local/rvm/ is complete.

# XXXXXXXXX,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
</pre>

<p>
sudoでマルチユーザ用にインストールすると、RVMは /usr/local/rvm にインストールされる。
</p>

<h3>sudoを使うのは、RVM自体のインストール時のみ。</h3>

<p>
以降の操作は、sudoを使わない。rvm installやgem install など、/usr/local/rvm 下に書き込む操作は、rvmグループに所属しているユーザで行う。（/usr/local/rvmのグループがrvmになっている。）
</p>

<p>
<a href="https://rvm.beginrescueend.com/support/troubleshooting/#sudo" target="_blank">RVM: Ruby Version Manager - Troubleshooting RVM</a><br />
<a href="http://dragonstar.asablo.jp/blog/2011/10/05/6133307" target="_blank">RVM をマルチユーザー用にセットアップする: ひ日記</a>
</p>

<p>
ユーザのグループにrvmを追加。
</p>

<pre class="command-line"># usermod -a -G rvm &lt;ユーザ名&gt;</pre>

<p>
ユーザをrvmグループに追加したら、いったんログアウトしてから、rubyやgemをインストール。<br />
sudo しない。
</p>

<pre class="command-line">
$ rvm install 1.9.3
$ rvm use 1.9.3
$ gem install rails
</pre>

<p>
RVMのアップデートも、sudoを使わず、rvmsudoを使う。
</p>

<pre class="command-line">
$ rvmsudo rvm get latest
</pre>
]]></content>
    <author>
        <name>pistolfly</name>
        <uri>http://www.pistolfly.jp/</uri>
    </author>
    
        <category term="ruby" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="ja" xml:base="http://www.pistolfly.jp/weblog/">
        <![CDATA[<h3>マルチユーザ用にRVMをインストール</h3>

<p>
マルチユーザ用にRVMをインストールするには、sudo でインストールする。
</p>

<p>
<a href="https://rvm.beginrescueend.com/rvm/install/" target="_blank">RVM: Ruby Version Manager - Installing RVM</a>
</p>

<pre class="command-line">
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Downloading RVM from wayneeseguin branch stable

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Could not download 'https://github.com/wayneeseguin/rvm/tarball/stable'.
  Make sure your certificates are up to date as described above.
  To continue in insecure mode run 'echo insecure >> ~/.curlrc'.
</pre>

<p>
curlのSSL証明書の検証でエラーになった。<br />
CA証明書が古いらしい。<br />
新しいCA証明書を取得する。
</p>

<h3>CA証明書のアップデート</h3>

<pre class="command-line">
$ sudo mv /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak # バックアップ
$ sudo curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
</pre>

<p>
<a href="http://d.hatena.ne.jp/kanonji/20111208/1323323155" target="_blank">curlでまたSSLのエラーが出たので対処 - kanonjiの日記</a><br />
<a href="http://curl.haxx.se/docs/sslcerts.html" target="_blank">cURL - Details on Server SSL Certificates</a><br />
<a href="http://curl.haxx.se/docs/caextract.html" target="_blank">cURL - Extract CA Certs from Mozilla</a>
</p>

<p>
再度sudoでRVMをインストール。
</p>

<pre class="command-line">
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  796k  100  796k    0     0   170k      0  0:00:04  0:00:04 --:--:--  340k

Installing RVM to /usr/local/rvm/
installing - /usr/local/rvm/man/man1/rvm.1 -
installing - /usr/local/rvm/man/man1/rvm.1.gz -
    Creating RVM system user group 'rvm'

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.beginrescueend.com/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /usr/local/rvm/ is complete.

# XXXXXXXXX,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
</pre>

<p>
sudoでマルチユーザ用にインストールすると、RVMは /usr/local/rvm にインストールされる。
</p>

<h3>sudoを使うのは、RVM自体のインストール時のみ。</h3>

<p>
以降の操作は、sudoを使わない。rvm installやgem install など、/usr/local/rvm 下に書き込む操作は、rvmグループに所属しているユーザで行う。（/usr/local/rvmのグループがrvmになっている。）
</p>

<p>
<a href="https://rvm.beginrescueend.com/support/troubleshooting/#sudo" target="_blank">RVM: Ruby Version Manager - Troubleshooting RVM</a><br />
<a href="http://dragonstar.asablo.jp/blog/2011/10/05/6133307" target="_blank">RVM をマルチユーザー用にセットアップする: ひ日記</a>
</p>

<p>
ユーザのグループにrvmを追加。
</p>

<pre class="command-line"># usermod -a -G rvm &lt;ユーザ名&gt;</pre>

<p>
ユーザをrvmグループに追加したら、いったんログアウトしてから、rubyやgemをインストール。<br />
sudo しない。
</p>

<pre class="command-line">
$ rvm install 1.9.3
$ rvm use 1.9.3
$ gem install rails
</pre>

<p>
RVMのアップデートも、sudoを使わず、rvmsudoを使う。
</p>

<pre class="command-line">
$ rvmsudo rvm get latest
</pre>
]]>
        
    </content>
</entry>

</feed>

