<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3323734665683622157</id><updated>2024-09-23T07:50:33.473+09:00</updated><category term="技術習得"/><category term="読書"/><category term="キャリア"/><category term="作業ログ"/><category term="Top Coder"/><category term="人"/><category term="大学"/><category term="昔のブログ"/><category term="社会勉強"/><category term="起業"/><category term="Life Hack"/><category term="企業研究"/><category term="日常"/><category term="自己分析"/><title type='text'>ありぺい日記</title><subtitle type='html'>へっぽこプログラマの日記</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.aripei.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>39</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-5187858926856878822</id><published>2014-02-20T06:54:00.002+09:00</published><updated>2014-02-20T06:54:58.151+09:00</updated><title type='text'>タイトル変更とドメイン設定しました</title><content type='html'>ブログタイトルを「ありんこ日記」から「ありぺい日記」に変更しました。また、aripei.comを取得したので、ブログをサブドメインのblog.aripei.comにして運用する事にしました。こうなると他のアカウントとかも@aripeiにしたくなるところだが、だいたいすでに取られてる…。</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/5187858926856878822/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/5187858926856878822' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5187858926856878822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5187858926856878822'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2014/02/blog-post.html' title='タイトル変更とドメイン設定しました'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-1400516264018230879</id><published>2014-02-17T11:34:00.001+09:00</published><updated>2014-02-18T01:26:39.134+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Top Coder"/><title type='text'>Top Coder SRM 609 Level3 おさらい</title><content type='html'>今週末もTop Coderに参戦したが、例のごとく最終問題のみ解けなかったので復習した。&lt;br /&gt;
&lt;br /&gt;
今回はGumiとIaとMayuというボーカロイドが音楽アルバムを作りますという若干Geekyなお題でした。以下のような入力値が与えられた時に、すべての曲が必ず一名以上に歌われるようなアルバムのパターンは何種類あるかという問題です（一つの曲を複数人で歌うのはOK）。&lt;br /&gt;
&lt;br /&gt;
入力値(すべて1から50までの整数)&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;S: 全曲数&lt;/li&gt;
&lt;li&gt;gumi: Gumiが歌う曲数&lt;/li&gt;
&lt;li&gt;ia: Iaが歌う曲数&lt;/li&gt;
&lt;li&gt;mayu: Mayuが歌う曲数&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
出力値&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Int: アルバムのパターン数&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
例えば(3,1,1,1)だと3C1 * 2C1 * 1C1で6パターンとなります。&lt;br /&gt;
&lt;br /&gt;
各曲に対して、各一名ずつ歌う場合（3パターン）、各二名ずつ歌う場合（3パターン）、三人全員が歌う場合（1パターン）の合計7パターンあります。なので7のS乗回試行して条件を満たすものをカウントすればよいのですが、Sが50の場合には1.798465e+42回ほど試行する事になるので残念ながら僕が死ぬまでには計算が終わらなそうです。&lt;br /&gt;
&lt;br /&gt;
この手の問題はどうやら以下の二種類の方法で解けるようです。&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;場合分けをして数学的に解く&lt;/li&gt;
&lt;li&gt;動的計画法で解く&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
前者は場合分けを行ってCombinationを駆使して解く方法、後者は分割統治法とメモ化と呼ばれる手法を使って問題を細分化して同じパターンの部分をキャッシュしながら解く方法です。勿論、数学的に解けた方がエレガントではあるのですが、Top Coderでは動的計画法は必須知識らしく、他の多くの問題に応用可能なようなので今回はこちらで解いてみました。&lt;br /&gt;
&lt;br /&gt;
まずは各項が以下の漸化式で求められるという事に気づく必要があります。こちらは前述の通り各曲に対して7パターン存在するということからも分かると思います。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;f(s, g, i, m) = f(s-1, g-1, i, m) + f(s-1, g, i-1, m) &amp;nbsp;+ f(s-1, g, i, m-1) &amp;nbsp;+ f(s-1, g,-1 i-1, m) &amp;nbsp;+ f(s-1, g-1, i, m-1) + &amp;nbsp;+ f(s-1, g, i-1, m-1) &amp;nbsp;+ f(s-1, g-1, i-1, m-1)&lt;/li&gt;
&lt;li&gt;f(0,0,0,0) = 1&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
後は、各入力値は正の値であるとか、g+i+m &amp;gt; sであるとかの確認をして、この漸化式を満たして、s/g/i/mのパターンをキャッシュしてあげるようなプログラムを実装すればよいです。&lt;br /&gt;
&lt;br /&gt;
できあがりは以下のようなコードになりました。でも、やっぱこのレベルの問題を30分で完璧に解くのはまだまだ無理だなぁ。あ、ちなみに1000000007で割ってるのは問題文に数値がでかすぎるのでこの値の剰余をとるようにって書いてあったから。&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;
import java.util.*;

public class VocaloidsAndSongs {

    long cache[][][][];
    final long MOD = 1000000007L;

    public int count(int S, int gumi, int ia, int mayu) {

        cache = new long[S + 1][gumi + 1][ia + 1][mayu + 1];

        for (int s = 0; s &amp;lt;= S; s++) {
            for (int g = 0; g &amp;lt;= gumi; g++) {
                for (int i = 0; i &amp;lt;= ia; i++) {
                    for (int m = 0; m &amp;lt;= mayu; m++) {
                        cache[s][g][i][m] = -1L;
                    }
                }
            }
        }
        return (int) dp(S, gumi, ia, mayu);
    }

    private long dp(int s, int g, int i, int m) {

        if (s &amp;gt; (g + i + m)) {
            return 0;
        }

        if (s == 0) {
            if (g == 0 &amp;amp;&amp;amp; i == 0 &amp;amp;&amp;amp; m == 0) {
                return 1L;
            } else {
                return 0L;
            }
        }

        if (g &amp;lt; 0 || i &amp;lt; 0 || m &amp;lt; 0) {
            return 0L;
        }

        if (cache[s][g][i][m] == -1L) {
            cache[s][g][i][m] = dp(s - 1, g - 1, i, m) +
                    dp(s - 1, g, i - 1, m) +
                    dp(s - 1, g, i, m - 1) +
                    dp(s - 1, g - 1, i - 1, m) +
                    dp(s - 1, g - 1, i, m - 1) +
                    dp(s - 1, g, i - 1, m - 1) +
                    dp(s - 1, g - 1, i - 1, m - 1);

        }

        return cache[s][g][i][m] % MOD;
    }

}
&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/1400516264018230879/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/1400516264018230879' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/1400516264018230879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/1400516264018230879'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2014/02/srm-609-level3.html' title='Top Coder SRM 609 Level3 おさらい'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-7103944930810496326</id><published>2014-02-09T07:33:00.000+09:00</published><updated>2014-02-18T01:27:03.373+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Top Coder"/><title type='text'>Top Coder SRM 608 Level3 おさらい</title><content type='html'>昨日、Top Coder SRMに二回目の参加をしてみたのですが、Level 3が解けなくて悔しかったので復習してみた。&lt;br /&gt;
&lt;br /&gt;
問題は要約するとN個のノードからなる有効グラフが渡された時にステップ数Lからなる経路の数が多項式P(L)で表されるか判別するプログラムを書くというのが問題です。本番では英語だし若干複雑なので理解するのに若干時間がかかりましたが…。&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
入力値は個々のエッジを表すYとNの文字の羅列が以下のようにStringのArrayとして渡される。配列長と文字数はグラフの頂点の数と同じです。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;String[] graph = new String[]{&quot;NYN&quot;,&quot;NNY&quot;,&quot;YNN&quot;};&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
また、出力は多項式解が存在する場合には&quot;Bounded&quot;、存在しない場合には&quot;Unbounded&quot;をリターンするだけです。&lt;br /&gt;
&lt;br /&gt;
この問題は本番時にはコード以前にそもそもどういうアルゴリズムにすれば解けるのかが思いつきませんでした。終了後に以下のようにホワイトボードを使って精査したらやっとひらめいた。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF1E8Pbyxb7GEnCGd8yT1VEHJVLfOx4wpXuZbjwgjqCOZ3mA-DsIDLYqUhP85b4RbP_22QTU3Hekz7h80qs5EVh7y6Yu9smaGZ9S0Wlh6Jau-H_nKasmeeVSQIHQhv9SjxaL97srmd5z8/s1600/IMG_20140208_170503.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF1E8Pbyxb7GEnCGd8yT1VEHJVLfOx4wpXuZbjwgjqCOZ3mA-DsIDLYqUhP85b4RbP_22QTU3Hekz7h80qs5EVh7y6Yu9smaGZ9S0Wlh6Jau-H_nKasmeeVSQIHQhv9SjxaL97srmd5z8/s640/IMG_20140208_170503.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NPがNon Polynomial(多項式解なし)でPがPolynomial(多項式解あり)を表しています。どうやら循環して自分に戻ってくるような経路を二つ以上もつノードがある場合に多項式解がなくなるようです。赤のラインで循環を示しているのですが、このラインが一つのノードから2つ以上出ている場合に多項式解がなくなります。例えば循環経路がM、自分に戻ってくるまでにNステップかかると経路数の計算は「Mの(L / N)乗」になるはずです。という訳でMが1の場合には多項式解、Mが2以上の時には多項式では解けないはず。&lt;br /&gt;
&lt;br /&gt;
ルールさえ分かってしまえばコードはこんな感じで簡単に書けました。単純に一つ一つのノードをイテレートして循環が2つ以上ないか確認するだけです。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
import java.util.*;

public class BigOEasy {
    static final String UNBOUNDED = &quot;Unbounded&quot;;
    static final String BOUNDED = &quot;Bounded&quot;;

    boolean[][] edges;
    public String isBounded(String[] graph) {

        // edges as boolean 2d array
        edges = new boolean[graph.length][graph.length];
        for (int i = 0; i &amp;lt; graph.length; i++) {
            for (int j = 0; j &amp;lt; graph[i].length(); j++) {
                edges[i][j] = (graph[i].charAt(j) == &#39;Y&#39;);
            }
        }

        // each vertex
        for (int currentVertex = 0; currentVertex &amp;lt; edges.length; currentVertex++) {
            int num_of_circle = 0;

            // each edge
            for (int nextVertex = 0; nextVertex &amp;lt; edges[currentVertex].length; nextVertex++) {
                // check if circular
                if (edges[currentVertex][nextVertex]) {
                    if(checkCircular(currentVertex, nextVertex, new boolean[edges.length])){
                        num_of_circle++;
                    }
                }

                // unbounded if more than one circulars
                if(num_of_circle &amp;gt; 1){
                    return UNBOUNDED;
                }
            }
        }
        return BOUNDED;
    }

    private boolean checkCircular(int startVertex, int currentVertex, boolean visited[]) {
        visited[currentVertex] = true;
        for(int nextVertex = 0; nextVertex &amp;lt; edges.length; nextVertex++){
            if(edges[currentVertex][nextVertex]){
                if(startVertex == nextVertex){
                    return true;
                }else if(visited[nextVertex]){
                    continue;
                }else{
                    if(checkCircular(startVertex, nextVertex, visited)){
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
ただ、Level 1で10分、Level 2で20分程度は消費すると考えるとLevel 3に費やせる時間は30分程度しかありません。ちょっと本番でこのレベルの問題がでたらかなりラッキーじゃないと時間内に解ける気がしませんね。今のところは確実にLevel 1とLevel 2を片付けることを目標とするか。忘れかけたJavaをググりながら書いているので、この辺りのTipsが身に付けば早く解けるようになってもう少しスコアがあがるはず。</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/7103944930810496326/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/7103944930810496326' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7103944930810496326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7103944930810496326'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2014/02/top-coder-srm-608-level3.html' title='Top Coder SRM 608 Level3 おさらい'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF1E8Pbyxb7GEnCGd8yT1VEHJVLfOx4wpXuZbjwgjqCOZ3mA-DsIDLYqUhP85b4RbP_22QTU3Hekz7h80qs5EVh7y6Yu9smaGZ9S0Wlh6Jau-H_nKasmeeVSQIHQhv9SjxaL97srmd5z8/s72-c/IMG_20140208_170503.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-4679138787826841049</id><published>2014-01-27T12:10:00.003+09:00</published><updated>2014-01-27T12:47:01.723+09:00</updated><title type='text'>Pythonでデータ分析ごっこ事始めしてみる</title><content type='html'>弊社(&lt;a href=&quot;http://camenergydatalab.com/&quot;&gt;Cambridge Energy Data Lab&lt;/a&gt;)ではデータサイエンス系の開発言語をPythonに統一しておりまして、社員達がNumPy、SciPy、pandasなどなどを目下勉強中です。&lt;br /&gt;
&lt;br /&gt;
データサイエンティストも&lt;a href=&quot;https://www.facebook.com/notes/cambridge-energy-data-lab/data-scientist-intern-paid/334848266654299&quot;&gt;積極採用中&lt;/a&gt;なのですが、応募者全員に以下のデータ解析タスクをGitHubから提出するという課題を課しています。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/camenergydatalab/EnergyDataSimulationChallenge&quot;&gt;Cambridge Energy Data Lab: EnergyDataSimulationChallenge&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
既に15フォークされていて、質の良いPull Requestも多く来ていて嬉しい限りです。Cambridge大学の学生もどんどん応募してきてくれています。皆さんもお暇な時に是非 :)&lt;br /&gt;
&lt;br /&gt;
これが採用に非常に有効で、まずランダムにCVを送りまくっている応募者や、最低限のスキルの身に付いていない応募者のフィルタリングが非常に効率的に行えます。基本的にはこのプログラミングタスクの提出をしていない応募者のCVは一切確認しません。また、どの言語が得意なのか、どんなライブラリの扱いに慣れているか、どのように考えて分析を進めているのかなどなど、やはりコードを見ると非常に効率よく応募者のスキルを知る事ができます。&lt;br /&gt;
&lt;br /&gt;
とか偉そうな事を言っておいて、実は僕はWeb Applicationの開発に集中しないといけないという言い訳があり、自分ではデータ解析部分に殆ど触れておらずデータサイエンティストに任せっきりにしていました。しかしながら採用活動をバンバンしている手前、それじゃいかんなと反省して、週末にちょっと時間をみつけて自分でもPythonでデータ解析をしてみました。&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
環境設定&lt;/h2&gt;
まずは&lt;a href=&quot;https://www.enthought.com/products/canopy/&quot;&gt;Canopy&lt;/a&gt;をインストールしました。こちらはPythonでのデータ解析に利用されるライブラリ群（NumPy、SciPy、Matplotlib、pandasなどなど）に加えて&lt;a href=&quot;http://ipython.org/&quot;&gt;IPython&lt;/a&gt;が搭載された統合環境です。これをインストールするだけで必要なツールが一気に揃うので、Macを使っている方には非常にお薦めです。&lt;br /&gt;
&lt;br /&gt;
分析結果は&lt;a href=&quot;http://ipython.org/notebook.html&quot;&gt;IPython Notebook&lt;/a&gt;にまとめると便利です。Web上でInteractiveにコードの実行が出来、かつDescriptionなども加えられて自分の分析がNotebookとしてまとめられるので分析結果の公開が非常にやり易いです。&lt;br /&gt;
&lt;br /&gt;
以下のように実行すると、Plotに必要なライブラリが読み込まれ、かつ結果のグラフ等の出力がHTMLに出力されて便利です。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ipython notebook --pylab inline
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
UIはこんな感じ。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGxkX6eM3cSeq_nS8TBArlp_jC7jhvx-KP3M3lJXZRWQV7H920qws93H3-5vMyuVh0cy-XvsGHbcFS3SMjjpuLO0HeIoSrNX4GX5xi0JMd_cpBpl33Xf8T5KJmUrLIhRrhnMZ2D6kGIQc/s1600/Screen+Shot+2014-01-26+at+11.34.01+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGxkX6eM3cSeq_nS8TBArlp_jC7jhvx-KP3M3lJXZRWQV7H920qws93H3-5vMyuVh0cy-XvsGHbcFS3SMjjpuLO0HeIoSrNX4GX5xi0JMd_cpBpl33Xf8T5KJmUrLIhRrhnMZ2D6kGIQc/s1600/Screen+Shot+2014-01-26+at+11.34.01+PM.png&quot; height=&quot;488&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;
チャレンジ&lt;/h2&gt;
覚えないと行けない事は非常に多いのですが、とりあえずは&lt;a href=&quot;http://pandas.pydata.org/&quot;&gt;pandas&lt;/a&gt;の&lt;a href=&quot;http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.html&quot;&gt;DataFrame&lt;/a&gt;としてデータを取り込んで、&lt;a href=&quot;http://matplotlib.org/&quot;&gt;Matplotlib&lt;/a&gt;で可視化するという事を目標にして、&lt;a href=&quot;https://github.com/camenergydatalab/EnergyDataSimulationChallenge#challenge-2---visualization-of-energy-consumptions&quot;&gt;Challenge 2 - Visualization of Energy Consumptions&lt;/a&gt;に取り組みました。主にデータの可視化、時系列変換、クラスタリングを行うタスクです。&lt;br /&gt;
&lt;br /&gt;
初めて触るということもありやっぱデータの扱いに慣れておらず、半日近くかけてなんとか以下の処理だけ済ませました。&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;pandasにデータ取り込み&lt;/li&gt;
&lt;li&gt;そのままPlot&lt;/li&gt;
&lt;li&gt;データのDiffをプロット&lt;/li&gt;
&lt;li&gt;時系列変換してプロット&lt;/li&gt;
&lt;li&gt;データの分類（クラスタリング）をしてプロット&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
ちなみに、Gitに載せておくと&lt;a href=&quot;http://nbviewer.ipython.org/&quot;&gt;IPython Notebook Viewer&lt;/a&gt;というサービスで公開できて便利です。僕の分析は&lt;a href=&quot;http://nbviewer.ipython.org/gist/peisan/bd776d4ef7cb352c65b4&quot;&gt;こちら&lt;/a&gt;から見られます。とりあえず最低要件だけはなんとか済ませたというレベルなので、暇を見つけてちょっとかっこ良く分析するかな。特に単純に平均から標準偏差を足して引いてしてるだけの分類がダサいので。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/4679138787826841049/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/4679138787826841049' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/4679138787826841049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/4679138787826841049'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2014/01/python.html' title='Pythonでデータ分析ごっこ事始めしてみる'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGxkX6eM3cSeq_nS8TBArlp_jC7jhvx-KP3M3lJXZRWQV7H920qws93H3-5vMyuVh0cy-XvsGHbcFS3SMjjpuLO0HeIoSrNX4GX5xi0JMd_cpBpl33Xf8T5KJmUrLIhRrhnMZ2D6kGIQc/s72-c/Screen+Shot+2014-01-26+at+11.34.01+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-2389395557990333728</id><published>2014-01-17T04:43:00.000+09:00</published><updated>2014-01-17T04:43:21.658+09:00</updated><title type='text'>HerokuからS3へアクセスするRakeを作ってみた</title><content type='html'>S3に置かれたデータファイルを取得し、それを読み込みデータを更新するというRakeタスクを作って、Herokuのスケジューラでバッチタスクとして登録してみました。このあたり（&lt;a href=&quot;https://devcenter.heroku.com/articles/s3&quot;&gt;Using AWS S3 to Store Static Assets and File Uploads&lt;/a&gt;）を参照しながら進めました。


&lt;br /&gt;
&lt;h2&gt;Rakeの設定&lt;/h2&gt;
Rakeのタスクはrailsコマンドでlib/tasks以下に生成される。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ rails generate task loader
      create  lib/tasks/loader.rake
&lt;/code&gt;&lt;/pre&gt;
とりあえずこんな感じで作って。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
namespace :loader do
  desc &quot;Load Data Files&quot;
  task :test =&amp;gt; :environment do
    puts &quot;test&quot;
  end
end
&lt;/code&gt;&lt;/pre&gt;
実行できる。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ rake loader:test
test
&lt;/code&gt;&lt;/pre&gt;

RSpecもこんな感じで書けました。generatorはないっぽいけどspec/tasks以下とかに置けばよいのでは。
&lt;pre&gt;&lt;code&gt;
require &#39;spec_helper&#39;
require &#39;rake&#39;
MyApp::Application.load_tasks

describe &#39;Rake Test&#39; do
  it &#39;run test&#39; do
    Rake::Task[&#39;test&#39;].invoke(&#39;arg&#39;)
  end
end
&lt;/code&gt;&lt;/pre&gt;


&lt;h2&gt;S3へのアクセス&lt;/h2&gt;
RubyからS3の利用はAmazonのドキュメント（&lt;a href=&quot;http://docs.aws.amazon.com/AWSRubySDK/latest/frames.html&quot;&gt;AWS SDK for Ruby&lt;/a&gt;）を見ながら設定したら思いのほか簡単にできました。

S3のアクセス情報はHerokuのConfigに突っ込んで環境変数として使います(&lt;a href=&quot;https://devcenter.heroku.com/articles/config-vars&quot;&gt;Configuration and Config Vars&lt;/a&gt;)。ローカルから走らせる場合には環境変数に設定するかRakeコマンドに引数として渡す事もできます。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ heroku config:set S3_KEY=xxx S3_SECRET=yyy S3_BUCKET=zzz
Adding config vars and restarting app... done, v21
  S3_BUCKET  =&amp;gt; zzz
  S3_KEY     =&amp;gt; xxx
  S3_SECRET  =&amp;gt; yyy
&lt;/code&gt;&lt;/pre&gt;

まぁ、以下のようにrailsのconfigに置いちゃっても良いみたいだけど。ちなみにこれは接続に失敗した時に表示されるAWSライブラリのエラーメッセージです。
&lt;pre&gt;&lt;code&gt;
= Ruby on Rails
       
In a Ruby on Rails application you may also specify your credentials in
the following ways:
       
* Via a config initializer script using any of the methods mentioned above
 (e.g. RAILS_ROOT/config/initializers/aws-sdk.rb).
       
* Via a yaml configuration file located at RAILS_ROOT/config/aws.yml.
  This file should be formated like the default RAILS_ROOT/config/database.yml
  file.
&lt;/code&gt;&lt;/pre&gt;


Rubyからのアクセスには、まず以下のGemを追加します。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
gem &quot;aws-sdk&quot;, &quot;~&amp;gt; 1.32.0&quot;
&lt;/code&gt;&lt;/pre&gt;

そうすると上で設定した環境変数を引っ張って下記のように接続からBucketの取得までできます。
&lt;pre&gt;&lt;code&gt;
AWS.config(access_key_id: ENV[&#39;S3_KEY&#39;],
           secret_access_key: ENV[&#39;S3_SECRET&#39;],
           region: &#39;us-west-2&#39;)
BUCKET = AWS::S3.new.buckets[ENV[&#39;S3_BUCKET&#39;]]
&lt;/code&gt;&lt;/pre&gt;

すると以下のように、key名のprefixでS3上のオブジェクトを取得したりデータを読み込んだりできます。オブジェクトの詳細な扱いとかは&lt;a href=&quot;http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3.html&quot;&gt;AWS::S3のクラスドキュメント&lt;/a&gt;にまとまっています。

&lt;pre&gt;&lt;code&gt;
BUCKET.objects.with_prefix(directory).each do |obj|
  puts obj.key
  puts obj.read
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;スケジューラへの追加&lt;/h2&gt;

スケジュール化されたタスクを走らせる方法としては定期的にRakeコマンドを実行する&lt;a href=&quot;https://devcenter.heroku.com/articles/scheduler&quot;&gt;Heroku Scheduler&lt;/a&gt;と&lt;a href=&quot;https://devcenter.heroku.com/articles/clock-processes-ruby&quot;&gt;Clockwork&lt;/a&gt;などのGemを利用する方法があるらしい。Heroku Schedulerはone-off dynos上で実行されるBest Effortサービスらしいが、とりあえずこっちの方が簡単そうなのでこちらで実装してみました。

&lt;a href=&quot;https://addons.heroku.com/scheduler&quot;&gt;Heroku Scheduler&lt;/a&gt;のアドオンを追加すると以下のような感じで簡単にJobの登録ができます。
&lt;br/&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09qzZZuVhigPy8mPrWj6B875rIcQOtWZkwcIHvCzQesB2bBhBNyyM2dBsVonRS-mMY4Ofa_GMU9v3gbQmfyoU8UPk28Xt5yp7y4bAt68fHqooDVKE7ImN8tE52DSnDZFU7XDjgW780qE/s1600/Screen+Shot+2014-01-15+at+6.07.46+PM.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09qzZZuVhigPy8mPrWj6B875rIcQOtWZkwcIHvCzQesB2bBhBNyyM2dBsVonRS-mMY4Ofa_GMU9v3gbQmfyoU8UPk28Xt5yp7y4bAt68fHqooDVKE7ImN8tE52DSnDZFU7XDjgW780qE/s640/Screen+Shot+2014-01-15+at+6.07.46+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;

実行後に以下のようにログを確認できます。
&lt;pre&gt;&lt;code&gt;
$ heroku logs -p scheduler
2014-01-16T18:07:59.715840+00:00 heroku[scheduler.7222]: Starting process with command `bundle exec rake test`
2014-01-16T18:08:00.376906+00:00 heroku[scheduler.7222]: State changed from starting to up
2014-01-16T18:08:04.282904+00:00 app[scheduler.7222]: Loading Files for 20140116
2014-01-16T18:08:04.719251+00:00 app[scheduler.7222]: 
2014-01-16T18:08:04.719251+00:00 app[scheduler.7222]: [AWS S3 200 0.431475 0 retries] list_objects(:bucket_name=&gt;&quot;zzz&quot;,:max_keys=&gt;1000,:prefix=&gt;&quot;pre&quot;)  
2014-01-16T18:08:05.958921+00:00 heroku[scheduler.7222]: Process exited with status 0
2014-01-16T18:08:05.980991+00:00 heroku[scheduler.7222]: State changed from up to complete
&lt;/code&gt;&lt;/pre&gt;

ところで、Herokuのログってdefaultだと1500行までしか保持してくれないんですね。アドオン導入しないとな。やっぱ&lt;a href=&quot;https://papertrailapp.com/&quot;&gt;Papertrail&lt;/a&gt;でしょうか。</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/2389395557990333728/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/2389395557990333728' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2389395557990333728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2389395557990333728'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2014/01/herokus3rake.html' title='HerokuからS3へアクセスするRakeを作ってみた'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09qzZZuVhigPy8mPrWj6B875rIcQOtWZkwcIHvCzQesB2bBhBNyyM2dBsVonRS-mMY4Ofa_GMU9v3gbQmfyoU8UPk28Xt5yp7y4bAt68fHqooDVKE7ImN8tE52DSnDZFU7XDjgW780qE/s72-c/Screen+Shot+2014-01-15+at+6.07.46+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-6595204499958973183</id><published>2013-12-10T04:49:00.000+09:00</published><updated>2013-12-10T04:49:04.200+09:00</updated><title type='text'>Rails多言語対応</title><content type='html'>今日はRailsで日本語と英語の出し分けを実装してました。さすがRails、多言語対応も安定の簡単さ。グリーみたいにアラビア語対応とかしなくていいから更に楽です。ここ(&lt;a href=&quot;http://guides.rubyonrails.org/i18n.html&quot;&gt;Rails Internationalization (I18n) API&lt;/a&gt;)を見ながらちょいちょいと設定が済みました。

基本的にはI18nというオブジェクトですべてハンドルしております。

I18n.lでlocalize、I18n.tで翻訳をします。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
2.0.0p247 :010 &amp;gt; I18n.l Time.now
 =&amp;gt; &quot;Tue, 03 Dec 2013 17:19:04 +0000&quot; 
2.0.0p247 :022 &amp;gt; I18n.t &quot;hello&quot;
 =&amp;gt; &quot;こんにちわ世界&quot; 
&lt;/code&gt;&lt;/pre&gt;
どのLocaleを利用するかはI18n.localeに格納されています。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
2.0.0p247 :026 &amp;gt; I18n.locale
 =&amp;gt; :jp 
2.0.0p247 :027 &amp;gt; I18n.default_locale
 =&amp;gt; :en 
&lt;/code&gt;&lt;/pre&gt;
言語リソースはymlで用意する。config/locales/*.ymlというファイルを作るとRailsが自動的に読み込んでくれる。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
en:
  hello: &quot;Hello world&quot;
jp:
  hello: &quot;こんにちわ世界&quot;
&lt;/code&gt;&lt;/pre&gt;

ちなみに階層化できるので、きれいにまとめましょう。
&lt;pre&gt;&lt;code&gt;
en:
  greeting:
    hi:
      world: &quot;Hi World&quot;
      ippei: &quot;Hi Ippei&quot;
&lt;/code&gt;&lt;/pre&gt;

.(ドット)でつなぎます。
&lt;pre&gt;&lt;code&gt;
2.0.0p247 :004 &gt; I18n.t(&quot;greeting&quot;)
 =&gt; {:hi=&gt;{:world=&gt;&quot;Hi World&quot;, :ippei=&gt;&quot;Hi Ippei&quot;}} 
2.0.0p247 :005 &gt; I18n.t(&quot;greeting.hi.world&quot;)
 =&gt; &quot;Hi World&quot; 
2.0.0p247 :006 &gt; I18n.t(&quot;greeting.hi.ippei&quot;)
 =&gt; &quot;Hi Ippei&quot; 
&lt;/code&gt;&lt;/pre&gt;

若干ハマったのが、なぜかjp.ymlという言語リソースファイルを追加したのに読んでくれていない。Railsがconfig/locales/から自動的にロードしてくれるのだが、残念ながらファイルを追加した時には動的に呼んでないらしい。ファイルに新しいKeyをアペンドした時は読んでくれるんだけど。たぶんこのパラメータが起動時に作られるのだと思われる。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
2.0.0p247 :001 &amp;gt; I18n.load_path
 =&amp;gt; [&quot;/Users/ippei/RubymineProjects/eneberg/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/locale/en.yml&quot;, &quot;/Users/ippei/Rubymine.....
&lt;/code&gt;&lt;/pre&gt;
また、application.rbからdefault_localeの変更やload_pathの追加をすることもできる。少なくともrails4.0.1では以下のようなComment OutされたエントリーがあるのでComment Inして任意の言語またはディレクトリを追加するだけ。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join(&#39;my&#39;, &#39;locales&#39;, &#39;*.{rb,yml}&#39;).to_s]
    # config.i18n.default_locale = :de
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
問題はI18n.localeにどうやって任意の言語を入れてあげるか。つまりどうやって言語を判別するか。 大まかに以下の方法があると思います。組み合わせて使ったりもします。&lt;a href=&quot;http://sns.gree.net/&quot;&gt;グリー&lt;/a&gt;はAccept-Languageだったはず。&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;ドメインで識別&amp;nbsp;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;jp.example.com&lt;/li&gt;
&lt;li&gt;example.jp&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Query Stringで渡す&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;example.com?locale=jp&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Pathに追加する&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;example.com/jp&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Accept-Languageを見る&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Accept-Language:en-US,en;q=0.8,ja;q=0.6&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;GeoIP&lt;/li&gt;
&lt;li&gt;ユーザ毎に設定を持たせる&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
今回はお手軽にQuery StringとAccept-Languageで実装しました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

まずはQuery Stringから。ApplicationController.rbに下記を追加してQuery Stringで渡されたパラメーターをI18n.localeに設定するようにします。
&lt;pre&gt;&lt;code&gt;
before_action :set_locale
 
def set_locale
  I18n.locale = params[:locale] || I18n.default_locale
end
&lt;/code&gt;&lt;/pre&gt;

これだけだと画面遷移時にlocaleが引き継がれないので、以下のmethodをoverrideして常にlocaleパラメータを渡すようにします。
&lt;pre&gt;&lt;code&gt;
def default_url_options(options={})
  { locale: I18n.locale }
end
&lt;/code&gt;&lt;/pre&gt;


お次はAccept-Languageの実装です。残念ながらRails自体にはAccept-LanguageをParseする機能はないようなので、&lt;a href=&quot;https://github.com/iain/http_accept_language&quot;&gt;http_accept_language&lt;/a&gt;というGemを使いました。

Gemfileに以下を追加します。

&lt;pre&gt;&lt;code&gt;gem &quot;http_accept_language&quot;, &quot;~&gt; 2.0.0&quot;&lt;/code&gt;&lt;/pre&gt;

そうするとこんな感じで準備したLocaleに対応する言語を返してくれます。
&lt;pre&gt;&lt;code&gt;http_accept_language.compatible_language_from(I18n.available_locales)&lt;/code&gt;&lt;/pre&gt;

Query Stringを優先させるので、終わってみるとApplication Controllerはこんな感じになりました。
&lt;pre&gt;&lt;code&gt;
  before_action :set_locale

  def default_url_options(options={})
    {:locale =&gt; I18n.locale}
  end

  def set_locale
    I18n.locale = extract_locale_from_params ||
        extract_locale_from_accept_language_header ||
        I18n.default_locale
  end

  private
  def extract_locale_from_params
    if params[:locale] and I18n.available_locales.index(params[:locale].to_sym)
      params[:locale]
    end
  end

  def extract_locale_from_accept_language_header
    http_accept_language.compatible_language_from(I18n.available_locales)
  end
&lt;/code&gt;&lt;/pre&gt;


後はja.ymlとen.ymlにひたすらリソースを追加して、Templateにせこせこと以下の文字を馬鹿みたいに埋め込み続けるだけの簡単なお仕事です。
&lt;pre&gt;&lt;code&gt;&lt;%= t(&#39;KEY&#39;) %&gt;&lt;/code&gt;&lt;/pre&gt;

</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/6595204499958973183/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/6595204499958973183' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/6595204499958973183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/6595204499958973183'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/12/rails.html' title='Rails多言語対応'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-119456480272547661</id><published>2013-12-01T08:47:00.003+09:00</published><updated>2013-12-13T07:33:36.691+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="作業ログ"/><title type='text'>DNSimpleでHerokuアプリのドメイン登録</title><content type='html'>&lt;br /&gt;
Herokuとの連携が簡単そうだったので&lt;a href=&quot;https://dnsimple.com/&quot;&gt;DNSimple&lt;/a&gt;というドメインサービスを利用してみたら死ぬほど簡単だったので紹介してみる。DocumentもSimpleにまとまっていて良い(&lt;a href=&quot;http://support.dnsimple.com/&quot;&gt;DNSimple Support&lt;/a&gt;)。&lt;br /&gt;HeokuのドキュメントもDNSimple推しでまとまってます（&lt;a href=&quot;https://devcenter.heroku.com/articles/ssl-endpoint&quot;&gt;SSL Endpoint&lt;/a&gt;, &lt;a href=&quot;https://devcenter.heroku.com/articles/ssl-certificate-dnsimple&quot;&gt;Purchasing an SSL Certificate from DNSimple&lt;/a&gt;）。
&lt;br /&gt;
まずはクレジットカードの登録をしてアカウントアクティベートしてみます。ドメインを追加します。フォームに打ち込むだけで取得できるかの確認や、Name Servreへの登録とかもやってくれて数分待っていれば名前が解決できるようになりました。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8cTWkLV15o08W3_C3j0EIENCdA_2Zsm1pUqRUDbUgh0tTP2zPrvhzVj0Ci6YR0uq1Nv7W1Z3nXT8bz-MOyZFmNtksYXWXxfoPF6kI76qaX-OobJboihGbrIDhYhnvICYTb9Mnnehdju0/s1600/Screen+Shot+2013-11-29+at+6.08.23+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8cTWkLV15o08W3_C3j0EIENCdA_2Zsm1pUqRUDbUgh0tTP2zPrvhzVj0Ci6YR0uq1Nv7W1Z3nXT8bz-MOyZFmNtksYXWXxfoPF6kI76qaX-OobJboihGbrIDhYhnvICYTb9Mnnehdju0/s640/Screen+Shot+2013-11-29+at+6.08.23+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;

&lt;br /&gt;
既にとられているドメインだと怒られる。
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Gh0_WS5az7hpyhaNgaEht0PIl_zPXev6oewYEOAIMN0BFA5Q7qFPivRJGXx8O3lXNRaiG9mjGuKBP5LNnKENfg5uHEpSznvdImggv9Ik0CxUZqvgIIcGmz_iusq5TJg0Ub0SMzYyn50/s1600/Screen+Shot+2013-11-29+at+7.25.32+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Gh0_WS5az7hpyhaNgaEht0PIl_zPXev6oewYEOAIMN0BFA5Q7qFPivRJGXx8O3lXNRaiG9mjGuKBP5LNnKENfg5uHEpSznvdImggv9Ik0CxUZqvgIIcGmz_iusq5TJg0Ub0SMzYyn50/s400/Screen+Shot+2013-11-29+at+7.25.32+PM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
こんな感じでダッシュボードから登録の状況やALIAS、SOA、NS等の情報が確認できます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7RpRfimVnjpTFZ0Cj5eYkGiV34bgHc5ROF2MV-8u4rCxjho_P_H4FeKcI6uKVHcd3m8csztM71fMv4OlGRzrrb_YWFHRKnUrBl1GSNL2uavLaknoIz45zhbefOoKCHa4bB_LIO75ShP0/s1600/Screen+Shot+2013-11-29+at+6.15.50+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;338&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7RpRfimVnjpTFZ0Cj5eYkGiV34bgHc5ROF2MV-8u4rCxjho_P_H4FeKcI6uKVHcd3m8csztM71fMv4OlGRzrrb_YWFHRKnUrBl1GSNL2uavLaknoIz45zhbefOoKCHa4bB_LIO75ShP0/s640/Screen+Shot+2013-11-29+at+6.15.50+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Advance Editorという画面からRecordが登録できるので、サブドメインと一緒にHerokuのアプリへのALIASレコードを作ってやります。ALIASレコードはDNSimpleが追加してたCNAMEの拡張レコードのようなもの。Aレコードがなくてもdomain名からアドレスを解決してくれるものらしい。詳しくはこちら(&lt;a href=&quot;http://support.dnsimple.com/articles/alias-record&quot;&gt;What is an ALIAS record?&lt;/a&gt;, &lt;a href=&quot;http://blog.dnsimple.com/zone-apex-naked-domain-alias-that-works/&quot;&gt;Introducing the ALIAS Record – Naked Domain Aliasing that Works!&lt;/a&gt;)。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8otX-llYLgqC88PNMKIjq_h0ItdIcjI7IDUH9Ij3HXG59MiHtS86xbaoiimMLerVuvYnsoPa2tStM_G7M6aRNOKPjHTUyW7rMk9loOvaPmNFHMm65sfYFWtvVnuO6GUcTY6UWi7Sbh78/s1600/Screen+Shot+2013-11-29+at+6.10.59+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;450&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8otX-llYLgqC88PNMKIjq_h0ItdIcjI7IDUH9Ij3HXG59MiHtS86xbaoiimMLerVuvYnsoPa2tStM_G7M6aRNOKPjHTUyW7rMk9loOvaPmNFHMm65sfYFWtvVnuO6GUcTY6UWi7Sbh78/s640/Screen+Shot+2013-11-29+at+6.10.59+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
後は、Herokuのアプリ設定で上で追加したDomainを追加してあげればOK。ここまでで、もう作ったばかりのサブドメインでアプリに接続できるようになりました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgejsvFm-6rK-5mNeukA5Rm2tD7yDsSSLS6ZMHelpaGFD2FFxHSIxPtQ6es-moUTSWtlPKE-0zVkM91aDd01DKgDQKemBRGpGtK4mYJbNF5HKoM5XvB4Jmp2CLcRhEbv8EASnhWr36g82A/s1600/Screen+Shot+2013-11-29+at+6.09.44+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgejsvFm-6rK-5mNeukA5Rm2tD7yDsSSLS6ZMHelpaGFD2FFxHSIxPtQ6es-moUTSWtlPKE-0zVkM91aDd01DKgDQKemBRGpGtK4mYJbNF5HKoM5XvB4Jmp2CLcRhEbv8EASnhWr36g82A/s640/Screen+Shot+2013-11-29+at+6.09.44+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
お次はSSLの設定。これもしっかりまとまっています(&lt;a href=&quot;http://support.dnsimple.com/articles/ssl-certificate-with-heroku&quot;&gt;Using an SSL Certificate with Heroku&lt;/a&gt;)。まずはダッシュボードからこんな感じでサブドメインを指定して証明書を購入します。これも一瞬で済みます。サブドメイン一つのみだと$20/year、ワイルドカードだと$100/yearっぽいです。

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTVpiikc5g_X2TDpq0VTCtZjT8Anudd8zk4vDpDCij0bP5Y5CWE9wC3mkSBJllLJnX-g5tAW1zz0eJ-K79ACn78yyykq4JGZFLs2GPIGTCTW_pJuwpOos9fpefwwFzmPm1HGgBaBmWETA/s1600/Screen+Shot+2013-11-29+at+7.26.56+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTVpiikc5g_X2TDpq0VTCtZjT8Anudd8zk4vDpDCij0bP5Y5CWE9wC3mkSBJllLJnX-g5tAW1zz0eJ-K79ACn78yyykq4JGZFLs2GPIGTCTW_pJuwpOos9fpefwwFzmPm1HGgBaBmWETA/s640/Screen+Shot+2013-11-29+at+7.26.56+PM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
購入すると発行期間からemailでkeyが送られてくるので、こんな感じで証明書とPrivate Keyを設定。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ heroku certs:add /tmp/server.crt /tmp/server.key /tmp/bundle.pem 
Resolving trust chain... done
Adding SSL Endpoint to .$oldapp.. done
$oldapp now served by $newapp
Certificate details:
Common Name(s): 
Expires At:.....
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
注意点としては$newapp.herokussl.comっていうアプリ名がSSL用のエンドポイントとして割り振られるので、ALIASの先をherokuapp.comから変更すること。じゃないと、証明書のドメインと一致しなくて激おこされます。こちらに書いてある通りです(&lt;a href=&quot;http://support.dnsimple.com/articles/ssl-certificate-herokuapp-error&quot;&gt;Troubleshooting SSL error for *.heroku.com or *. herokuapp.com&lt;/a&gt;)。もともと非SSLのアプリへのALIASにしてあったので、キャッシュの関係で変更後もしばらくは怒られていましたが一晩おいといたらちゃんとアップデートされてhttpsでアクセスできるようになりました。&lt;br /&gt;
&lt;br /&gt;
後は以下のようにConfigでProduction環境のみhttpsを強制するようにすれば終了。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -40,7 +40,7 @@Application.configure do
   # config.action_dispatch.x_sendfile_header = &#39;X-Accel-Redirect&#39; # for nginx
 
   # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
-  # config.force_ssl = true
+  config.force_ssl = true
&lt;/code&gt;&lt;/pre&gt;

という感じで初めての僕でも作業時間半日くらいでドメインを取得してサブドメインでSSL対応のWebアプリを公開するとこまでできてしまいました。もう一度やったら1-2時間で済みそう。ちなみにBatch Server用のAWSのドメイン登録もしたんだけど、こちらはPublic IPが割り振られているのでAレコードを追加するのみでした。</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/119456480272547661/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/119456480272547661' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/119456480272547661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/119456480272547661'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/12/dnsimpleheroku.html' title='DNSimpleでHerokuアプリのドメイン登録'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8cTWkLV15o08W3_C3j0EIENCdA_2Zsm1pUqRUDbUgh0tTP2zPrvhzVj0Ci6YR0uq1Nv7W1Z3nXT8bz-MOyZFmNtksYXWXxfoPF6kI76qaX-OobJboihGbrIDhYhnvICYTb9Mnnehdju0/s72-c/Screen+Shot+2013-11-29+at+6.08.23+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-8474096090179631369</id><published>2013-11-27T05:14:00.000+09:00</published><updated>2013-11-27T05:14:09.742+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="作業ログ"/><title type='text'>EC2とS3の設定してみた</title><content type='html'>Herokuで動作しているRuby on Railsアプリケーションで外部からのファイルを受け取るためにEC2とS3のセットアップをしてみました。HerokuはDyno単位で動作するという特性上、ファイルシステムをもっていません。だいたい皆さんS3を使っているみたいなので、以下の手順でファイルの受け渡しをしてみることにしました。&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;EC2をSFTPサーバとして外部からファイルを受け取る&lt;/li&gt;
&lt;li&gt;EC2はファイルのバリデーションをしてS3と必要なデータをSync&lt;/li&gt;
&lt;li&gt;HerokuのアプリケーションがS3からデータ取得&lt;/li&gt;
&lt;/ol&gt;
ちなみに、むかーしにEC2のインスタンスをちょっと立てて放置したことがあるくらいで、AWSはほぼ初心者です。&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Amazon S3&lt;/h2&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
とりあえずS3の設定をしてみます。このチュートリアル(&lt;a href=&quot;http://docs.aws.amazon.com/AmazonS3/latest/gsg/GetStartedWithS3.html&quot;&gt;Get Started With Amazon Simple Storage Service&lt;/a&gt;)に従って進めたらBucketを作ってAmazonのコンソールからファイルをアップロードする所まではすぐにできました。&lt;/div&gt;
&lt;br /&gt;
まずはBucketを作ります。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitPmjv5eyAaC1aSav2qm9fP7Py3mg7CRGZfU_4gJmtbs1X-4OvBSDiwRlJp8OqHBJsoPHSPm40WL9Z6-PVJOBskK2-y1vTbpD1U-epbhy693Z7I0971swKqTPGKfEmo5wQseC1IrT7biU/s1600/Screen+Shot+2013-11-19+at+5.21.07+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitPmjv5eyAaC1aSav2qm9fP7Py3mg7CRGZfU_4gJmtbs1X-4OvBSDiwRlJp8OqHBJsoPHSPm40WL9Z6-PVJOBskK2-y1vTbpD1U-epbhy693Z7I0971swKqTPGKfEmo5wQseC1IrT7biU/s640/Screen+Shot+2013-11-19+at+5.21.07+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
とりあえずRegionはHerokuに合わせてUSにしておく。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$heroku info
=== $server_name
Addons:        heroku-postgresql:dev
Git URL:       git@heroku.com:$server_name.git
Owner Email:   test@example.com
Region:        us
Repo Size:     2M
Slug Size:     36M
Stack:         cedar
Tier:          Legacy
Web URL:       http://$server_name.herokuapp.com/
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Amzon S3の&lt;a href=&quot;https://console.aws.amazon.com/s3&quot;&gt;Console&lt;/a&gt;から管理ができる。&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Amazon EC2&lt;/h2&gt;
次にFTP Server / Batch Serverとして使うEC2の設定です。これも基本的にはAmazonのチュートリアル(&lt;a href=&quot;http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html&quot;&gt;Getting Started with Amazon EC2 Linux Instances&lt;/a&gt;)通りに進めればすぐにインスタンスが立てられます。&lt;br /&gt;
&lt;br /&gt;
まずはOSを選ぶんですがAmazon Linux、Red Hat、SUSE、UbuntuからWindowsまで選択肢が多くて困る。Debianに慣れているし&lt;a href=&quot;http://cloud-images.ubuntu.com/locator/ec2/&quot;&gt;Ubuntu AMI&lt;/a&gt;にしようかとも思ったけれども、無難に&lt;a href=&quot;http://aws.amazon.com/jp/amazon-linux-ami/&quot;&gt;Amazon Linux AMI&lt;/a&gt;にした。とりあえず基本的なパッケージが安全に動けば良いし、AmazonのDocumentもAmazon Linuxを基準にしてあるみたいなので。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_yAopdf_W4Ka0HVzcHdJAzcJsBc_mx8t47KvIOcdDOEwD0F03V8-u0cNXdoRu2p4pZxUMqyMhjpba1FC2JD4unStM3q4gfo2XBr3gpHbJexz7QO-Lo1A_kKuBEnqlppTJXeSiVWgcT30/s1600/Screen+Shot+2013-11-25+at+3.36.19+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;361&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_yAopdf_W4Ka0HVzcHdJAzcJsBc_mx8t47KvIOcdDOEwD0F03V8-u0cNXdoRu2p4pZxUMqyMhjpba1FC2JD4unStM3q4gfo2XBr3gpHbJexz7QO-Lo1A_kKuBEnqlppTJXeSiVWgcT30/s640/Screen+Shot+2013-11-25+at+3.36.19+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
後はメモリやCPUやストレージサイズなどを適当に選んでいけばインスタンスが立ちます。最後にKey Pairが作れるのでそのPrivate Keyを使ってsshで接続すればすぐにLoginできます。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ ssh -i ~/.ssh/amazon_ec2.pem ec2-user@pub_dns
Last login: Mon Nov 25 10:14:54 2013 from host

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
これもAmazon EC2の&lt;a href=&quot;https://console.aws.amazon.com/ec2&quot;&gt;Console&lt;/a&gt;からInstance増やしたりVolume追加したりなどの管理ができます。&lt;br /&gt;
&lt;br /&gt;
ついでにEBS Volumeの作成とマウントもしといた。VolumeはEC2のコンソールから作るだけ。初回のみはVolumeのフォーマットが必要なので注意。でないとマウントでエラーになります。とりあえずext4にしといた。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G 1023M  6.8G  13% /
tmpfs                 298M     0  298M   0% /dev/shm

$ sudo mkfs -t ext4 /dev/xvdf 
mke2fs 1.42.3 (14-May-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
 32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

$ sudo mkdir /mnt/ebs
$ sudo mount /dev/sdf /mnt/ebs

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G 1023M  6.8G  13% /
tmpfs                 298M     0  298M   0% /dev/shm
/dev/xvdf             5.0G  138M  4.6G   3% /mnt/ebs
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
EC2からS3へのデータ転送&lt;/h2&gt;
&lt;br /&gt;
まずは例のごとくAmazonのドキュメントを見ながらCliの初期設定をします(&lt;a href=&quot;http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html&quot;&gt;Getting Set Up with the AWS Command Line Interface&lt;/a&gt;)。Access Keyの設定とかPythonライブラリのインストールとかあって若干めんどくさい。&lt;br /&gt;
&lt;br /&gt;
Pythonで書かれてるらしいんだけど、Localeの設定をしてあげないと以下のように盛大に死ぬので注意。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ aws
Traceback (most recent call last):
  File &quot;/usr/bin/aws&quot;, line 15, in
    import awscli.clidriver
  File &quot;/usr/lib/python2.6/site-packages/awscli/clidriver.py&quot;, line 29, in
    from awscli.help import ProviderHelpCommand
  File &quot;/usr/lib/python2.6/site-packages/awscli/help.py&quot;, line 20, in
    from docutils.core import publish_string
  File &quot;/usr/lib/python2.6/site-packages/docutils/core.py&quot;, line 20, in
    from docutils import frontend, io, utils, readers, writers
  File &quot;/usr/lib/python2.6/site-packages/docutils/frontend.py&quot;, line 41, in
    import docutils.utils
  File &quot;/usr/lib/python2.6/site-packages/docutils/utils/__init__.py&quot;, line 20, in
    import docutils.io
  File &quot;/usr/lib/python2.6/site-packages/docutils/io.py&quot;, line 18, in
    from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
  File &quot;/usr/lib/python2.6/site-packages/docutils/utils/error_reporting.py&quot;, line 46, in
    locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
  File &quot;/usr/lib64/python2.6/locale.py&quot;, line 478, in getdefaultlocale
    return _parse_localename(localename)
  File &quot;/usr/lib64/python2.6/locale.py&quot;, line 410, in _parse_localename
    raise ValueError, &#39;unknown locale: %s&#39; % localename
ValueError: unknown locale: UTF-8
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Credentialsのペアは&lt;a href=&quot;https://portal.aws.amazon.com/gp/aws/securityCredentials&quot;&gt;Security Credential&lt;/a&gt;の管理ページから作れる。aws configureでAccess Keyを設定すると~/.aws/configに設定ファイルが作られる。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ aws configure
AWS Access Key ID [None]: $KEY_ID
AWS Secret Access Key [None]: $SECRET_KEY
Default region name [None]: us-west-2
Default output format [None]: json
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
やっとアクセスできるようになった。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
 aws s3 ls s3://arita_test
2013-11-19 17:22:58        300 2013-11-19-17-22-57-69ED20ABB5DBF2F7
2013-11-19 17:27:56        326 2013-11-19-17-27-55-8498FB7A97E32996
2013-11-19 17:31:41        299 2013-11-19-17-31-40-81265F67425272DE
2013-11-19 17:33:08        584 2013-11-19-17-33-07-87A40B3132B18A50
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
regionの指定で少しハマったけど、US StandardではなくEC2と同じRegionでS3のBucketを作り直したら上手く行った。aws configureで指定したregionと違う場合は--regionオプションで指定してあげないと上手く行かない。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
 $ aws s3 cp test s3://arita_test/  --region us-east-1
upload: ./test to s3://arita_test/test

 $ aws s3 sync s3://arita_test/  s3
download: s3://arita_test/test to s3/test&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 style=&quot;font-family: Times; white-space: normal;&quot;&gt;
SFTP用のユーザ作成&lt;/h2&gt;
&lt;div&gt;
さすがにec2-userでファイルを送るのは問題なので、SFTP用のユーザを作成。まぁ、これは素直にUnixのアカウントを作ってsshの設定をしてあげるだけ。&lt;/div&gt;
まずはユーザを作って
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ sudo adduser arita
$ sudo passwd arita
Changing password for user arita.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
&lt;/code&gt;&lt;/pre&gt;
公開鍵を置いてPerissionの設定。
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ su arita
Password: 
$ mkdir .ssh
$ chmod 700 .ssh/
$ vim .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;
これでとりあえず、SFTPでデータを置いてS3にSyncするところまでは完成。</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/8474096090179631369/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/8474096090179631369' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/8474096090179631369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/8474096090179631369'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/11/ec2s3.html' title='EC2とS3の設定してみた'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitPmjv5eyAaC1aSav2qm9fP7Py3mg7CRGZfU_4gJmtbs1X-4OvBSDiwRlJp8OqHBJsoPHSPm40WL9Z6-PVJOBskK2-y1vTbpD1U-epbhy693Z7I0971swKqTPGKfEmo5wQseC1IrT7biU/s72-c/Screen+Shot+2013-11-19+at+5.21.07+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-3783294407724978307</id><published>2013-10-19T04:58:00.000+09:00</published><updated>2013-10-19T05:58:46.490+09:00</updated><title type='text'>Facebook 広告を試してみる</title><content type='html'>会社の求人の広告をするためにFacebook広告を利用してみました。ターゲティングの詳細さに感動したのでちょっと紹介してみます。&lt;br /&gt;
&lt;br /&gt;
まず、右上のアイコンから広告の作成ページに飛ぶ事ができます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimCQDL8XBX5XGFORSCOtZ-_2bwiJpPZ8aDhOLj5G6Af7MpnrKEkbrK9GMhhoaUTP_W06uYzyDRlWDY01HIAUq11SU7H3HdocWP4BYaNzOmCntm-mSA5EYfnCbk9p_Xs-lD5_UwmRD3CK4/s1600/Screen+Shot+2013-10-18+at+5.51.03+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimCQDL8XBX5XGFORSCOtZ-_2bwiJpPZ8aDhOLj5G6Af7MpnrKEkbrK9GMhhoaUTP_W06uYzyDRlWDY01HIAUq11SU7H3HdocWP4BYaNzOmCntm-mSA5EYfnCbk9p_Xs-lD5_UwmRD3CK4/s200/Screen+Shot+2013-10-18+at+5.51.03+PM.png&quot; width=&quot;183&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
で、Headlineや説明や画像を設定したりできるのですが、ターゲティング機能が恐ろしくすごいです。&lt;br /&gt;
&lt;br /&gt;
まずは市町村区単位での地域、年齢や性別の絞り込みは当然として、興味などでも絞り込みができます。例えば以下では東京都港区在住の30才以下でArsenalというサッカーチームに興味のある男女に絞り込んでいます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEixdhGt9aMdK0XthX4ZPoblxbKsAUNmcFMOpIGVSqfvwS0-hd7iYs6KXGM-djNIN1yWHvpxl75LEhGSN_CUfiIGCPcIL_BvtGRz5AaL0bV5CF5_a-7TH4MVVYOUCCZaJUsnHS_oy7FOg/s1600/Screen+Shot+2013-10-18+at+6.06.30+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;619&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEixdhGt9aMdK0XthX4ZPoblxbKsAUNmcFMOpIGVSqfvwS0-hd7iYs6KXGM-djNIN1yWHvpxl75LEhGSN_CUfiIGCPcIL_BvtGRz5AaL0bV5CF5_a-7TH4MVVYOUCCZaJUsnHS_oy7FOg/s640/Screen+Shot+2013-10-18+at+6.06.30+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
また、利用しているアプリや恋愛関係のステータス、言語や学歴等でも絞り込む事ができます。婚活サイトや出会い系は独身者をターゲットに、転職エージェントは出身大学をターゲットにして広告を打っているといるんでしょう。「早稲田大学出身のあなたに」とかでてきますからね。&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4o-Feunk1opoERMEW9oh7m1HSGd_t-odguHPuHKUbL6tlKKSnzwOj6akqH4d1e9lesuFfDhGswbLWj3yTaMqndpRhcpVZaO-KaYrbSczc76IebHQAwHzVjNFugd0HzN3M79hQ7qXrDIc/s1600/Screen+Shot+2013-10-18+at+6.06.39+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4o-Feunk1opoERMEW9oh7m1HSGd_t-odguHPuHKUbL6tlKKSnzwOj6akqH4d1e9lesuFfDhGswbLWj3yTaMqndpRhcpVZaO-KaYrbSczc76IebHQAwHzVjNFugd0HzN3M79hQ7qXrDIc/s640/Screen+Shot+2013-10-18+at+6.06.39+PM.png&quot; width=&quot;620&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
ちなみに、絞り込みを調整しながら、ターゲットの数が何人くらいになるのか、広告のクリック単価がいくらになるのかというのも確認する事ができます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj92rdfhdVfAZpq8OJi-6XgBaKNWA1SsoeEFLU11rc3RSLEL30qeLT02ifMHBEihAJtlMzzDFN7LCinKXtFJZStTcMeywp8osw4bHj0SqbFZpdhZx95Kxwto8m-1wnIDOG5aVfpZXFhuE/s1600/Screen+Shot+2013-10-18+at+6.13.34+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj92rdfhdVfAZpq8OJi-6XgBaKNWA1SsoeEFLU11rc3RSLEL30qeLT02ifMHBEihAJtlMzzDFN7LCinKXtFJZStTcMeywp8osw4bHj0SqbFZpdhZx95Kxwto8m-1wnIDOG5aVfpZXFhuE/s320/Screen+Shot+2013-10-18+at+6.13.34+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
後は、予算と期間を決めて広告を出すだけです。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyvcAbKn2JAArBDdGBRawF3uup0XPjKZePqG3qgBpxfpLaZ8H6y3CHIMdoMixyZHcV4aQfLgxEar3cT6TPBBqS0dZRAgCW76E1UbmXFUJtQTWbf9UE9KSlaBsIZbiX-RANCpQ6jaArDl8/s1600/Screen+Shot+2013-10-18+at+6.17.52+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;636&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyvcAbKn2JAArBDdGBRawF3uup0XPjKZePqG3qgBpxfpLaZ8H6y3CHIMdoMixyZHcV4aQfLgxEar3cT6TPBBqS0dZRAgCW76E1UbmXFUJtQTWbf9UE9KSlaBsIZbiX-RANCpQ6jaArDl8/s640/Screen+Shot+2013-10-18+at+6.17.52+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
実際に広告がはじまると以下の画面からPVやらクリック数やらの詳細情報が見られるようになります。また、広告のストップなどもすぐに行う事ができます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqnmCZDzxUnSTpemkrZpQ-0ViECFn2bP0gbZAi6E-r-qiMiYUohlZ2oxD-gGkJfGOcTPBmyHFZZ99ZEureamibXvWy2ZmgBsIR6LFLy55DBdenBV4jHOgOD9U2h9_73wSV5f7RbGgtnbY/s1600/Screen+Shot+2013-10-18+at+6.19.27+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqnmCZDzxUnSTpemkrZpQ-0ViECFn2bP0gbZAi6E-r-qiMiYUohlZ2oxD-gGkJfGOcTPBmyHFZZ99ZEureamibXvWy2ZmgBsIR6LFLy55DBdenBV4jHOgOD9U2h9_73wSV5f7RbGgtnbY/s640/Screen+Shot+2013-10-18+at+6.19.27+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ところで、広告が始まった瞬間に以下のような画面が現れて、広告のアカウントが止められてしまうという問題が発生しました。サポートに怒りのメールを投げてみたら2日ほどで対応して直してくれました。どうやらPay PalのBilling Addresと僕の現在地や広告先が違っていたのが原因だったようです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmJZmtKWZAEamfiwncEBUcx1BXoqXnwK3sk8np4-OgelP3HS8GXBDC3mzjqxXj14B3RUE6hpaxIGaFfOeO72OBEAnB7oP6QQ38jX9CxJO4vkLcWP9AMsXhpT6uOgBLLHNgn6jSbnTxJR4/s1600/Screen+Shot+2013-10-14+at+6.30.19+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;141&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmJZmtKWZAEamfiwncEBUcx1BXoqXnwK3sk8np4-OgelP3HS8GXBDC3mzjqxXj14B3RUE6hpaxIGaFfOeO72OBEAnB7oP6QQ38jX9CxJO4vkLcWP9AMsXhpT6uOgBLLHNgn6jSbnTxJR4/s400/Screen+Shot+2013-10-14+at+6.30.19+PM.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/3783294407724978307/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/3783294407724978307' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3783294407724978307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3783294407724978307'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/facebook.html' title='Facebook 広告を試してみる'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimCQDL8XBX5XGFORSCOtZ-_2bwiJpPZ8aDhOLj5G6Af7MpnrKEkbrK9GMhhoaUTP_W06uYzyDRlWDY01HIAUq11SU7H3HdocWP4BYaNzOmCntm-mSA5EYfnCbk9p_Xs-lD5_UwmRD3CK4/s72-c/Screen+Shot+2013-10-18+at+5.51.03+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-2365099510201880400</id><published>2013-10-18T03:08:00.000+09:00</published><updated>2014-01-18T07:06:29.523+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="作業ログ"/><title type='text'>Rails Operation in Heoku</title><content type='html'>Heoku上でdeployとdbのマイグレーションやseedの流し込みをしたので簡単にまとめてみる。&lt;br /&gt;
&lt;br /&gt;
基本的にはHeroku Toolbeltを利用してオペレーションをする事になり、簡単な運用方法はHeokuのサイトにまとまっています。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://devcenter.heroku.com/articles/getting-started-with-rails4&quot;&gt;Getting Started with Rails 4.x on Heroku&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
けっこーな数のコマンドがあります。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;$ heroku help
Usage: heroku COMMAND [--app APP] [command-specific-options]

Primary help topics, type &quot;heroku help TOPIC&quot; for more details:

  addons    #  manage addon resources
  apps      #  manage apps (create, destroy)
  auth      #  authentication (login, logout)
  config    #  manage app config vars
  domains   #  manage custom domains
  logs      #  display logs for an app
  ps        #  manage dynos (dynos, workers)
  releases  #  manage app releases
  run       #  run one-off commands (console, rake)
  sharing   #  manage collaborators on an app

Additional topics:

  account      #  manage heroku account options
  certs        #  manage ssl endpoints for an app
  drains       #  display syslog drains for an app
  fork         #  clone an existing app
  git          #  manage git for apps
  help         #  list commands and display help
  keys         #  manage authentication keys
  labs         #  manage optional features
  maintenance  #  manage maintenance mode for an app
  pg           #  manage heroku-postgresql databases
  pgbackups    #  manage backups of heroku postgresql databases
  plugins      #  manage plugins to the heroku gem
  regions      #  list available regions
  stack        #  manage the stack for an app
  status       #  check status of heroku platform
  update       #  update the heroku client
  version      #  display version
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Dynoのステータスの確認&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
heroku ps
=== web (1X): `bin/rails server -p $PORT -e $RAILS_ENV`
web.1: up 2013/10/17 17:38:06 (~ 1h ago)
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Rails Consoleもリモートの環境のものがこんな感じで使えてしまいます。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ heroku run rails console
Running `rails console` attached to terminal... up, run.2213
Loading production environment (Rails 4.0.0)
irb(main):001:0&amp;gt; User.all
=&amp;gt; #&amp;lt;ActiveRecord::Relation [#&amp;lt;User id: 2, email: ...&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
rakeのCommandもheroku runとタイプするだけで走ってしまう。例えばdb:migrateだったらこんな感じ。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$  heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.6382
Migrating to DeviseCreateUsers (20131014182214)
==  DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
   -&amp;gt; 0.0243s
-- add_index(:users, :email, {:unique=&amp;gt;true})
   -&amp;gt; 0.0076s
-- add_index(:users, :reset_password_token, {:unique=&amp;gt;true})
   -&amp;gt; 0.0087s
==  DeviseCreateUsers: migrated (0.0419s) =====================================

$  heroku run rake db:seed
Running `rake db:seed` attached to terminal... up, run.6750
&lt;/code&gt;&lt;/pre&gt;
ただ、rake db:migrate:resetとかのDBを書き換えちゃうようなコマンドはPermissionで怒られます。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ heroku run rake db:migrate:reset
Running `rake db:migrate:reset` attached to terminal... up, run.2597
FATAL:  permission denied for database &quot;postgres&quot;
DETAIL:  User does not have CONNECT privilege.
&lt;/code&gt;&lt;/pre&gt;
そんな時はheroku pgコマンドで対応できるっぽい。

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ heroku pg:reset DATABASE

 !    WARNING: Destructive Action
 !    This command will affect the app: $host
 !    To proceed, type &quot;$host&quot; or re-run this command with --confirm $host

&amp;gt; $host
Resetting HEROKU_POSTGRESQL_AMBER_URL (DATABASE_URL)... done
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
うーん。超簡単ですね。今後はDatabase周りの細かいオペレーションが必要になってくると思うので、この辺をみながらいじってみて勉強しとこっと。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/categories/heroku-postgres&quot;&gt;https://devcenter.heroku.com/categories/heroku-postgres&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/heroku-postgresql&quot;&gt;https://devcenter.heroku.com/articles/heroku-postgresql&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/2365099510201880400/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/2365099510201880400' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2365099510201880400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2365099510201880400'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/rails-operation-in-heoku.html' title='Rails Operation in Heoku'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-8002896337603002008</id><published>2013-10-10T19:19:00.000+09:00</published><updated>2013-11-27T01:59:28.243+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="作業ログ"/><title type='text'>RSpec with Rails4</title><content type='html'>今日は&lt;a href=&quot;https://github.com/rspec/rspec-rails&quot;&gt;rspec-rails&lt;/a&gt;を使ってRails4に&lt;a href=&quot;https://github.com/rspec/rspec&quot;&gt;RSpec&lt;/a&gt;を導入してました。ここ(&lt;a href=&quot;https://www.relishapp.com/rspec/&quot;&gt;https://www.relishapp.com/rspec/&lt;/a&gt;)にドキュメントがすごくしっかりまとまっているので、これを見ながらやってました。&lt;br /&gt;
&lt;br /&gt;
導入は相変わらず超簡単でGemfileにこんな感じで追加してbundle installした後にrails genearateで必要なファイルを生成するだけ。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;# RSpec
group :development, :test do
  gem &#39;rspec-rails&#39;, &#39;~&amp;gt; 2.0&#39;
end
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre&gt;bundle install
rails generate rspec:install
&lt;/pre&gt;
&lt;br /&gt;
モデルを作ると以下のようにTest:Unitの代わりにSpecを自動生成してくれる。&lt;br /&gt;
&lt;pre&gt;rails generate model test name:string
      invoke  active_record
      create    db/migrate/20131011100432_create_tests.rb
      create    app/models/test.rb
      invoke    rspec
      create      spec/models/test_spec.rb
&lt;/pre&gt;
&lt;br /&gt;
Specだけ作りたい時はこんな感じ。&lt;br /&gt;
&lt;pre&gt;rails generate rspec:model user
      create &amp;nbsp;spec/models/user_spec.rb
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
こんな感じで他のSpecと同じように書けます。ちゃんとRubyMineで補完もしてくれる。&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
describe User do
  before :each do
    @testee = User.create! email:&#39;hoge@hoge.com&#39;, password:&#39;testtest&#39;
  end

  it &#39;has fields&#39; do
    expect(@testee.email).to eq(&#39;hoge@hoge.com&#39;)
    expect(@testee.password).to eq(&#39;testtest&#39;)
  end
end
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
bundle exec rspecで実行はできますが、.rpecファイルか引数でformat指定するとSpecの出力もしてくれて少し幸せになれる。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;bundle exec rspec --format documentation

User
  has fields

Finished in 0.40579 seconds
1 examples, 0 failures

Randomized with seed 13270
&lt;/pre&gt;
&lt;br /&gt;
という感じで安定のお手軽さに感動しました。
</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/8002896337603002008/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/8002896337603002008' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/8002896337603002008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/8002896337603002008'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/rspec-with-rails4.html' title='RSpec with Rails4'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-2153042527989428276</id><published>2013-10-09T06:45:00.003+09:00</published><updated>2013-11-27T02:00:00.750+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="昔のブログ"/><title type='text'>Railsでモデル生成のお勉強中</title><content type='html'>今日はこの辺りRails Guide -&amp;nbsp;&lt;a href=&quot;http://guides.rubyonrails.org/getting_started.html#adding-a-second-model&quot;&gt;Getting Started with Rails#Adding a Second Model&lt;/a&gt;を参考にしてrailsでmodelの実装をしてました。あまりの簡単さにびっくりした。&lt;br /&gt;
&lt;br /&gt;
とりあえずrake generate modelでモデルの定義をするとmodel classとそのUnit Testとdbのmigration fileをわんさか作ってくれます。DBのmigration手順はここ(&lt;a href=&quot;http://edgeguides.rubyonrails.org/migrations.html&quot;&gt;Rails Guide - Active Record Migrations&lt;/a&gt;)に良くまとまっていますが、必要に応じてindexやrelationなんかを追加しつつrake commandで簡単にDBを作る事ができます。rake db:migrateでdb/migrate以下に作られたmigration&amp;nbsp;fileを元にじゃんじゃかテーブルを作ります。以下の順序で行われるっぽい。&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;db/migrate以下のファイルからテーブルを作成&lt;/li&gt;
&lt;li&gt;データベースからdb/schema.rbを作る&lt;/li&gt;
&lt;/ol&gt;
また、rake db:migrate:resetを実行するとmigration filesからテーブルを作成してseed.rbを作り直す。db:resetだとseed.rbからテーブルを作るのでmigration fileを何回変更しても変わらない。&lt;br /&gt;
少しハマった…。&lt;br /&gt;
&lt;br /&gt;
rakeのコマンドとかもまだ全く覚えていないのですが、rake --tasksで他のタスクがぞろぞろでてきてくれます。rake -Pで親タスクやその依存関係とかも出力してくれるっぽい。&lt;br /&gt;
&lt;br /&gt;
例えば上記のdb:migrate:resetは3つのタスクを組み合わせたものらしい。&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
rake db:migrate:reset
    db:drop
    db:create
    db:migrate
&lt;/pre&gt;
また、rake test:allでUnit Testの全実行をしてくれるっぽい。&lt;br /&gt;
&lt;br /&gt;
db/seed.rbに開発環境用のデータを用意できる。rake consoleから実行するのと同じように$class.new(:$field1 =&amp;gt; $value)みたいな感じで書ける。RubyのScriptなのでファイルから読み込んでLoopでオブジェクト生成とかも非常に簡単にできそう。rake db:seedだと単純にseed.rbからデータをLoadする。rake&amp;nbsp;db:setupだとスキーマごと作り直してからデータをLoadする。ちょこちょこデータファイルを変更する時は後者を使う。&lt;br /&gt;
&lt;br /&gt;
あ、後作ったModelやそのObjectはrails consoleから確認してったら超効率よくできた。こんな感じで一通りモデルを作って、DBに反映させて、テストして、開発用データの準備までが半日かからずにできちゃいました。DBとModelの定義を固定して厳しい命名規則を受け入れるだけでこれだけの恩恵をうけられるとは。明日はRSpecを導入する予定。Rails楽しいね。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/2153042527989428276/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/2153042527989428276' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2153042527989428276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2153042527989428276'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/rails.html' title='Railsでモデル生成のお勉強中'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-933367646513396488</id><published>2013-10-08T07:12:00.000+09:00</published><updated>2013-10-09T02:45:02.685+09:00</updated><title type='text'>Cambridge到着</title><content type='html'>無事にTeir1 Visaもとれてケンブリッジに引っ越しをしました。人口も十万人少々しかいない小規模な町ですが生活に必要なものはすべて揃っているし、人々も親切で治安も良い非常に住みやすい町だと思います。緑が多く綺麗ですし、食べ物も想像していたよりずっと美味しいです。短くとも2年くらいは住む事になるはずなので、とても素敵な町で安心しています。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHNjCBtnmszXeH3uuxiYbqqcv0NSK3g-bEz15iCx6Q37ayFGFD-zE6TDcPJX-K_aJsN5rkuYBFlBD-wQfqXeZh9R_BzNnG7xSdoo_LlWbSU0QVwviiLuL5QNe6NIXDrKWni0_1QE_VPts/s1600/IMG_2083.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHNjCBtnmszXeH3uuxiYbqqcv0NSK3g-bEz15iCx6Q37ayFGFD-zE6TDcPJX-K_aJsN5rkuYBFlBD-wQfqXeZh9R_BzNnG7xSdoo_LlWbSU0QVwviiLuL5QNe6NIXDrKWni0_1QE_VPts/s320/IMG_2083.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
ケンブリッジで落ち着くまでの一ヶ月間は本当にドタバタでした。転職直後で慣れない仕事を進める傍ら、大学で授業を行いつつ、もろもろの住所変更やら部屋の引き払い等の引っ越し準備を行い、数多くの送別会でお別れを言いつつ、さらに父親が心筋梗塞で倒れるという災難まで重なり毎週名古屋に帰省するという、間違いなく僕の人生で一番大変だった訳の分からない一ヶ月間でした。幸い一度は心臓が止まった父親は後遺症もなく順調に回復し、僕も無事予定通りにケンブリッジに辿り着く事ができました。と思いきや初日というか飛行機の中から体調を崩して到着日に救急病院のお世話になるという超ドタバタが続き、体力的にも精神的にも疲弊しきっている状態だったのですが、仲間の支えもあり一週間たった今では十分に落ち着いて仕事に集中する環境ができています。&lt;br /&gt;
&lt;br /&gt;
初めの週で銀行口座開設、携帯電話の契約、NHS(国民保険サービス)の登録、職場での環境設定、自転車購入などの必要最低限の生活インフラもひと通り整い、町にも少しずつ慣れてきました（まだけっこー迷うけど）。同じようなスタートアップ企業が集まるCo-Workingスペースが職場なのですが、早速他の会社の日本企業との商談を手伝ってあげたりして人間関係も非常に上手くいっています。&lt;br /&gt;
&lt;br /&gt;
食べ物も思っていたよりは遥かにまともそうです。レストランもちょっと値段は高いけど十分美味しいし、スーパーも豊富にあるので近くのコリアンショップで肉を買って焼き肉をしたり、チキンを一匹オーブンで焼いて食べてみたり、日本のカレーライスを作ってみたりなどなどして食事を楽しんでいます。また、こちらは食べ物のデリバリーがすごく盛んなので&lt;a href=&quot;http://www.just-eat.co.uk/&quot;&gt;JUSTEAT&lt;/a&gt;で調べれば数えきれないくらい多くデリバリー料理が見つかります。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG5vnAXTkphtysUBa8zfCEfT8sMQaaSyCQ1aWOM6-1SmTMKgKj8xf987lnofPQ7qx3-1-nVkF1b6uuFGtSpP9TMnOidW1XgujzEwicU-UBmHvuBtXgxt_VfHar2xRBE5jCZrkE1DCeE2c/s1600/IMG_2123.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG5vnAXTkphtysUBa8zfCEfT8sMQaaSyCQ1aWOM6-1SmTMKgKj8xf987lnofPQ7qx3-1-nVkF1b6uuFGtSpP9TMnOidW1XgujzEwicU-UBmHvuBtXgxt_VfHar2xRBE5jCZrkE1DCeE2c/s320/IMG_2123.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
父親の件もあり自分のこれからの人生や生死なんかについて一度落ち着いて考えてみたいななんて思ったりもする訳ですが、とりあえずは後悔のないように新しい仕事に全力で打ち込んでみたいと思います。街を案内できるくらいにはなっておくのでイギリスにお越しの際には是非お立ち寄りください。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/933367646513396488/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/933367646513396488' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/933367646513396488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/933367646513396488'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/cambridge.html' title='Cambridge到着'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHNjCBtnmszXeH3uuxiYbqqcv0NSK3g-bEz15iCx6Q37ayFGFD-zE6TDcPJX-K_aJsN5rkuYBFlBD-wQfqXeZh9R_BzNnG7xSdoo_LlWbSU0QVwviiLuL5QNe6NIXDrKWni0_1QE_VPts/s72-c/IMG_2083.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-7934205303725334686</id><published>2013-09-20T04:50:00.000+09:00</published><updated>2013-11-27T02:00:13.135+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="作業ログ"/><title type='text'>Ruby2.0.0 &amp; rails4 &amp; Postgres on Herokuの環境づくり</title><content type='html'>Rails4をHerokuで動かす環境を整えた覚え書き。Postgresを使った一番スタンダードな仕様（のつもり）。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ruby Mine&lt;/b&gt;&lt;br /&gt;
IntelliJに慣れつつある僕は&lt;a href=&quot;http://www.jetbrains.com/ruby/&quot;&gt;RubyMine&lt;/a&gt;を使いたい。VimのKeybinding使えるし、デバッグしやすいし、安定しているし、良い！&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjivsoysxmGRmffverwfy1IyDVqM-yzGbXTNUAtPC3rCJMH7Vv9rP45OCGD2jkstLGHucpVUt1TLnp3beF_AkQDD5CdTPWinJbrAKb6yNr6HBAwvJXauxbyI_ltyfU_h1AUcH-4UITkpg/s1600/Screen+Shot+2013-08-30+at+7.59.53+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;234&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjivsoysxmGRmffverwfy1IyDVqM-yzGbXTNUAtPC3rCJMH7Vv9rP45OCGD2jkstLGHucpVUt1TLnp3beF_AkQDD5CdTPWinJbrAKb6yNr6HBAwvJXauxbyI_ltyfU_h1AUcH-4UITkpg/s320/Screen+Shot+2013-08-30+at+7.59.53+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ruby on Rails&lt;/b&gt;&lt;br /&gt;
Homebrewとgemで適当にインストールした。超簡単なので覚え書きもしません。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;RVM&lt;/b&gt;&lt;br /&gt;
その後、RVMでバージョン使い分けようとしたら少しはまった。たぶんHomebrewのと干渉したんだと思う。&lt;br /&gt;
https://rvm.io/&lt;br /&gt;
&lt;br /&gt;
こんなエラーが出てしまった。&lt;br /&gt;
&lt;pre&gt;/Users/ippei/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do&#39;: The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.

&lt;/pre&gt;
&lt;br /&gt;
以下をしてruby2.0.0とsqlite3をインストールし直したら直った。&lt;br /&gt;
&lt;pre&gt;rvm get head
rvm --force install 2.0.0
gem install bundle
gem install sqlite3
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Postgres&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Postgresはここを見ながら設定。Macでの設定は&lt;a href=&quot;http://postgresapp.com/&quot;&gt;Postgres.app&lt;/a&gt;を使うと一瞬で済む。&lt;br /&gt;
https://devcenter.heroku.com/articles/heroku-postgresql&lt;br /&gt;
&lt;br /&gt;
と思いきや何故かSocketのI/Oの場所がpgライブラリが見に行く場所と違ってエラーになるっぽいので、無理矢理以下のlinkを作って解決。&lt;br /&gt;
&lt;br /&gt;
lrwxr-xr-x &amp;nbsp;1 root &amp;nbsp;wheel &amp;nbsp;4 Sep 10 09:14 /var/pgsql_socket -&amp;gt; /tmp&lt;br /&gt;
&lt;br /&gt;
後はPostgresにアプリケーション名でユーザを作りつつ。&lt;br /&gt;
&lt;pre&gt;$ createuser -U ippei -P $user_name
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
&lt;/pre&gt;
rakeでDBを作る。&lt;br /&gt;
#rake db:create&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;Heroku&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
とりあえず、&lt;a href=&quot;https://devcenter.heroku.com/articles/rails4-getting-started&quot;&gt;Herokuのインストラクション&lt;/a&gt;をみながら設定。すでにsqliteでひな形を作ってしまっていたので少しつまづいた。Herokuは基本Postgresぽいです。&lt;br /&gt;
&lt;br /&gt;
以下のツールベルトというのがコマンドラインツール。いろいろ便利。&lt;br /&gt;
&lt;a href=&quot;https://toolbelt.heroku.com/&quot;&gt;https://toolbelt.heroku.com/&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
上記の設定を済ませた上でHerokuのレポジトリにpushすれば動くはず。&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Reference&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://devcenter.heroku.com/articles/rails4-getting-started&quot;&gt;https://devcenter.heroku.com/articles/rails4-getting-started&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://devcenter.heroku.com/articles/heroku-postgresql&quot;&gt;https://devcenter.heroku.com/articles/heroku-postgresql&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/7934205303725334686/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/7934205303725334686' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7934205303725334686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7934205303725334686'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/10/ruby200-rails4-postgres-on-heroku.html' title='Ruby2.0.0 &amp; rails4 &amp; Postgres on Herokuの環境づくり'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjivsoysxmGRmffverwfy1IyDVqM-yzGbXTNUAtPC3rCJMH7Vv9rP45OCGD2jkstLGHucpVUt1TLnp3beF_AkQDD5CdTPWinJbrAKb6yNr6HBAwvJXauxbyI_ltyfU_h1AUcH-4UITkpg/s72-c/Screen+Shot+2013-08-30+at+7.59.53+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-4588084854524866189</id><published>2013-09-16T01:25:00.001+09:00</published><updated>2013-10-04T04:53:23.707+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><category scheme="http://www.blogger.com/atom/ns#" term="大学"/><title type='text'>非常勤講師@早稲田大学 - モバイルプログラミング</title><content type='html'>先週のJava（という名のScala）の授業に引き続き、今週はモバイルプログラミングというテーマで、Smart Phone向けのWeb Applicationを作るという授業を一週間行ってきました。今週は生徒が10名以上と多く一人一人のコードを細かく見る事ができなかったため、前回よりは講義形式に近い形で授業を進めました。本当は前回と同じようにGitHubのアカウントを作らせてpull requestで課題提出とか、作ったアプリをHerokuで公開して提出くらいまでしたかったですが、さすがに生徒数が多くそこまで手が回りませんでした。&lt;br /&gt;
&lt;br /&gt;
でも授業の出来としては上々で、生徒全員が毎日出席してくれましたし、プログラミングの経験が乏しかった生徒達も最後の課題ではjQueryとTwitter Bootstrapを使ってレスポンシブなUIを作ったり、Google Chartsでグラフを作って利までできるようになりました。やはり皆さん若くて覚えが早いからかw、僕の期待よりは遥かに早いスピートで吸収してくれました。&lt;br /&gt;
&lt;br /&gt;
今回のクラスでは「&lt;a href=&quot;http://dotinstall.com/&quot;&gt;ドットインストール&lt;/a&gt;」をかなり活用しました。動画で学べる初心者向けのプログラミングサイトです。ドットインストールの動画を見せて、僕がライブコーディングをしてみて、生徒に実際に試してもらうというステップで進めてみました。やっぱり僕が空いた時間でちょこちょこ作った雑な資料なんかを使うより、より質の高い資料を生徒に会わせて上手く作った方が上手く教えられるという事が実感できました。これまでは教科書を使って授業という形が主でしたが、今後は授業によっては「&lt;a href=&quot;https://www.coursera.org/&quot;&gt;Coursera&lt;/a&gt;」とかの外部の質の高い講義ごと利用しちゃったりした方が質の高い教育ができるんじゃないかななんて思ったりしました。そうすれば講師が個々の生徒のフォローに使える時間も増えそうですしね。&lt;br /&gt;
&lt;br /&gt;
前回と同じように授業で使ったスライドとコードはSlideShareとGitHubで公開しています。また資料や生徒の課題はWebで公開してあります。&lt;br /&gt;
&lt;br /&gt;
GitHub:&amp;nbsp;&lt;a href=&quot;https://github.com/peisan/WasedaMobileProgrammingClass&quot;&gt;https://github.com/peisan/WasedaMobileProgrammingClass&lt;/a&gt;&lt;br /&gt;
URL:&amp;nbsp;&lt;a href=&quot;http://mpwaseda.herokuapp.com/&quot;&gt;http://mpwaseda.herokuapp.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;330&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; mozallowfullscreen=&quot;&quot; scrolling=&quot;no&quot; src=&quot;http://www.slideshare.net/slideshow/embed_code/26209562&quot; style=&quot;border-width: 1px 1px 0; border: 1px solid #CCC; margin-bottom: 5px;&quot; webkitallowfullscreen=&quot;&quot; width=&quot;400&quot;&gt; &lt;/iframe&gt; </content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/4588084854524866189/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/4588084854524866189' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/4588084854524866189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/4588084854524866189'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/09/blog-post_16.html' title='非常勤講師@早稲田大学 - モバイルプログラミング'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-2881882401835992513</id><published>2013-09-07T19:35:00.001+09:00</published><updated>2013-10-04T04:53:05.035+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><category scheme="http://www.blogger.com/atom/ns#" term="大学"/><title type='text'>非常勤講師@早稲田大学 - Java Programing上級</title><content type='html'>今週は夏期集中講義の非常勤講師として早稲田大学でJavaの授業を行なってきました。Javaといいつつ実は殆どをScalaで進めてしまったのですが。「Java Programing 上級」という授業だったのですが、やはり学生さんということで経験が浅く、準備した資料をアドホックに変更しながら初心者向けの授業にしました。&lt;br /&gt;
&lt;br /&gt;
大学の先生達と同じ事をしていては面白くないので、IntelliJ、Github、Homebrewなどを導入して実際に僕がグリーで行っていた開発環境に近いような形で授業を進めてきました。最後の課題では素因数分解のプログラムを書いて貰ったりしたのですが、終了時にはPull Requestで提出してもらいました。&lt;br /&gt;
&lt;br /&gt;
開発環境のセットアップに思った以上に時間がかかったりなど反省すべき点も多々ありましたが、生徒も楽しんで積極的に授業に参加してくれましたし、何よりどんどん吸収して上達していく生徒を見ているのが僕も楽しかったです。&lt;br /&gt;
&lt;br /&gt;
ちなみに授業で使ったプログラムはgithubで公開、スライドはSlide Shareで公開しています。&lt;br /&gt;
&lt;br /&gt;
github - &lt;a href=&quot;https://github.com/peisan/WasedaAdvancedJavaClass&quot;&gt;https://github.com/peisan/WasedaAdvancedJavaClass&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;330&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; mozallowfullscreen=&quot;&quot; scrolling=&quot;no&quot; src=&quot;http://www.slideshare.net/slideshow/embed_code/25979742&quot; style=&quot;border-width: 1px 1px 0; border: 1px solid #CCC; margin-bottom: 5px;&quot; webkitallowfullscreen=&quot;&quot; width=&quot;400&quot;&gt; &lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/2881882401835992513/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/2881882401835992513' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2881882401835992513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/2881882401835992513'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/09/java-programing.html' title='非常勤講師@早稲田大学 - Java Programing上級'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-3606263399690860852</id><published>2013-09-05T23:07:00.001+09:00</published><updated>2013-10-04T04:52:44.643+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><category scheme="http://www.blogger.com/atom/ns#" term="技術習得"/><category scheme="http://www.blogger.com/atom/ns#" term="自己分析"/><title type='text'>グリーで覚えた&amp;忘れた単語リスト</title><content type='html'>GREEに入って覚えた言葉と忘れそうになった言葉をなんとなく羅列してみた。まぁ、何を学んで何を忘れていったのか何となく想像できますね。今度もう少し丁寧に整理してみようかな。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;覚えた&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;CDN&lt;/li&gt;
&lt;li&gt;LVS&lt;/li&gt;
&lt;li&gt;Web Storage&lt;/li&gt;
&lt;li&gt;App Cache&lt;/li&gt;
&lt;li&gt;CSRF&lt;/li&gt;
&lt;li&gt;SPOF&lt;/li&gt;
&lt;li&gt;UX&lt;/li&gt;
&lt;li&gt;DAU&lt;/li&gt;
&lt;li&gt;MAU&lt;/li&gt;
&lt;li&gt;UU&lt;/li&gt;
&lt;li&gt;ささる&lt;/li&gt;
&lt;li&gt;くばる&lt;/li&gt;
&lt;li&gt;デグレる&lt;/li&gt;
&lt;li&gt;上長&lt;/li&gt;
&lt;li&gt;リア充&lt;/li&gt;
&lt;li&gt;ネト充&lt;/li&gt;
&lt;li&gt;スイーツ()&lt;/li&gt;
&lt;li&gt;ボトラー&lt;/li&gt;
&lt;li&gt;懐古虫&lt;/li&gt;
&lt;li&gt;イカ娘&lt;/li&gt;
&lt;li&gt;ノ&lt;/li&gt;
&lt;li&gt;まどマギ&lt;/li&gt;
&lt;li&gt;プギャー&lt;/li&gt;
&lt;li&gt;モヒカン&lt;/li&gt;
&lt;li&gt;マサカリ&lt;/li&gt;
&lt;li&gt;ラブライブ&lt;/li&gt;
&lt;li&gt;Homebrew&lt;/li&gt;
&lt;li&gt;git-flow&lt;/li&gt;
&lt;li&gt;Coffee Script&lt;/li&gt;
&lt;li&gt;Tyepe Script&lt;/li&gt;
&lt;li&gt;Zepto&lt;/li&gt;
&lt;li&gt;node.js&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;Ethna&lt;/li&gt;
&lt;li&gt;Shading&lt;/li&gt;
&lt;li&gt;Master / Slave&lt;/li&gt;
&lt;li&gt;play framework&lt;/li&gt;
&lt;li&gt;finagle&lt;/li&gt;
&lt;li&gt;sbt&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;DDD&lt;/li&gt;
&lt;li&gt;Monad&lt;/li&gt;
&lt;li&gt;Scrum&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;忘れそう&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Bloomberg Tickers (jb/js/jl/...)&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Reconciliation&lt;/li&gt;
&lt;li&gt;Tweak&lt;/li&gt;
&lt;li&gt;PNL&lt;/li&gt;
&lt;li&gt;Delta&lt;/li&gt;
&lt;li&gt;FUTEQ&lt;/li&gt;
&lt;li&gt;PVBP&lt;/li&gt;
&lt;li&gt;Interpolation&lt;/li&gt;
&lt;li&gt;fix / float leg&lt;/li&gt;
&lt;li&gt;xccy&lt;/li&gt;
&lt;li&gt;basis swap (e.g. 3m / 6m)&lt;/li&gt;
&lt;li&gt;fixing risk&lt;/li&gt;
&lt;li&gt;LIBOR / TIBOR / EURIBOR&lt;/li&gt;
&lt;li&gt;Spring Framework&lt;/li&gt;
&lt;li&gt;RMI&lt;/li&gt;
&lt;li&gt;RMDS&lt;/li&gt;
&lt;li&gt;dbunit&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/3606263399690860852/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/3606263399690860852' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3606263399690860852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3606263399690860852'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/09/blog-post.html' title='グリーで覚えた&amp;忘れた単語リスト'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-208661164998043175</id><published>2013-08-25T23:55:00.000+09:00</published><updated>2013-10-04T04:52:23.987+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><title type='text'>卒グリー（中退かも）</title><content type='html'>今月末で1年5ヶ月働いたグリー株式会社を退職することになりました。短い期間でしたが多くの大変貴重な経験をさせていただく事ができました。もう少し残ってさらにたくさんの事を吸収したかったというのが本音ですが、新たなチャレンジのために卒業（中退かも）させていただく事になりました。&lt;br /&gt;
&lt;br /&gt;
思い起こせば入社時には、&lt;strike&gt;僕を採用してくれたはずの&lt;a href=&quot;http://d.hatena.ne.jp/naoya/&quot;&gt;伊藤直也さん&lt;/a&gt;という有名なHackerが前日に退職しており、なんとドラクエ三昧になっているらしいという噂がなんてトラブルもありつつも&lt;/strike&gt;、&lt;a href=&quot;http://solvalou.net/about&quot;&gt;オオヒダさん&lt;/a&gt;を初めとした他のメンバーがあたたかく迎え入れてくれたおかげで、投資銀行という全く異なる業界から来た僕も、すぐにチームになじむ事ができました。今は&lt;a href=&quot;http://raksul.com/&quot;&gt;ラクスル&lt;/a&gt;にいる山下雄太さん、山田あかねさんにも、当時は大変お世話になりました。&lt;br /&gt;
&lt;br /&gt;
入社当時は、大手の証券会社という全く別の業界からきた事もあり、コミュニケーション面でも、技術面でも勝手が分からずおどおどしていたのを覚えています。「IRC？LVS？CDN？DAU？SPOF？なんだそれ？」みたいな。システムのリリース時にも何百台という単位のサーバにデプロイをするのはWeb業界のない僕には初めての経験で、初めは心臓バクバクでした。大きなミスをやらかしたりもしました。そんな僕でしたが数百万DAUという巨大Webサービスが如何にして運用させているのかというノウハウも少しずつ身につけ（実はけっこー日曜大工的ですw）、後半には海外のチームとの共同プロジェクトのマネジメントや、新規プロダクトの立ち上げ業務や、非常に技術力の高いエンジニア達のマネジメントも任せてもらえるようにまでなりました。特に&lt;a href=&quot;http://j5ik2o.me/&quot;&gt;かとじゅん&lt;/a&gt;や上村君の元ドワンゴ勢と一緒に仕事するのは本当に刺激的でした。本当はかとじゅんからもっと色々吸収したかったな。&lt;br /&gt;
&lt;br /&gt;
グリーに入って一番感じた事は、技術好き、プロダクト好きの人の多さと、現場の裁量の大きさでした。やはりJPMorganという巨大な国際的大企業から、グリーという大きくなったとはいえまだベンチャー気質の残るインターネット企業への転職ですから、インパクトが大きかったのだと思います。&lt;br /&gt;
&lt;br /&gt;
本当に技術が好きで、自分の作っているプロダクトが好きで、それが世に出てサービスとして使ってもらえる事を一番の喜びにしている人たちが本当に多かったです。プロダクトとかじゃなくて、常に自分の好きな技術を押し通してみたいな人達もいたしw。JPMorganにいた時は、モチベーションは「お金を稼ぐ」という人が殆どだったと思いますが、グリーは本当に多様で、モチベーションって人によってこんなに違うんだなというのを強く感じました。&lt;br /&gt;
&lt;br /&gt;
裁量の面では、グリーでは与えられた仕事の枠をいくらでも広げたり壊したりできるというか、そもそも枠自体がすごく曖昧。&lt;strike&gt;というかテキトーすぎ！もう少しちゃんと決めろw&lt;/strike&gt;むしろ枠を勝手に広げてしまえるような人が評価されていく感じ（もちろんちゃんと会社の利益になればだけどね）。JPMorganはやはりマネジメント主導の会社で、仕事の枠が予算とか上司や関係部署の承認などによってきっちり決められており、僕は前の職場で決められた仕事をサラリーマン的にこなしていくような働き方に慣れてしまっていたので、グリーの裁量の大きさはかなり衝撃でした。 今ではその裁量の大きさが僕のモチベーションの源泉になってしまっていますが。&lt;br /&gt;
&lt;br /&gt;
あと、CTOの藤本さんにも驚かされました。CTOなのに現場レベルの仕事に自ら積極的に関わってくれている。僕も一度ヘマをした時に、付きっきりでフォローをして頂いた事がありました。マネジメントも現場のエンジニアを理解して、いかに僕らが仕事をしやすくするかを考えて進めてくれていました。憧れの存在です。 &lt;br /&gt;
&lt;br /&gt;
あ、なんかこう比べるとJPMorgan批判みたいになってしまいましたが（汗）、前職で身につけた能力があったおかげでグリーでもこれだけの事を吸収できたのだと思います。日本国内のエンジニア職であれだけグローバルな環境で働けたというのは本当にありがたい経験でした。国際感覚はかなり身につきましたし、証券業務のという複雑で専門性の高い知識、もちろんシステム開発や運用のスキルも身につきました。おかげで転職時も引く手数多でしたし:)&lt;br /&gt;
&lt;br /&gt;
そうそう、最後に、グリーで働いたせいで「リア充」という言葉もしらないくらいリア充だった僕が、たった1年ちょっとでかなりWeb系のヲタの人達に順応してきてしまいました。朝会社こないし、短パンにサンダルだし、変な言葉いっぱい覚えたし、実は最近では変なアニメとかも見るようにまで…。グリーを突き抜けてドワンゴ化してしまいました。&lt;br /&gt;
&lt;br /&gt;
それでは次のチャレンジへと進んでいきたいと思います。グリーでお世話になった方々、壮行会で暖かく追い出してくれた方々、どうも有り難うございました。おかげさまでいつも笑顔で楽しく働く事ができました。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4wmZAkMJKUEB_L3vzsgFna-dv4EoEvl9znayDoH0zzbBDeam1NVvua9WiSHQ77wUxLCIbkbIaAVys_nPRUXYwxqBOQzx8AfCPiAIjR64Ku92UjSf_MQEKGXno8odzw35QYmLXlFMD8OY/s1600/1082215_632798580078833_781107996_o.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4wmZAkMJKUEB_L3vzsgFna-dv4EoEvl9znayDoH0zzbBDeam1NVvua9WiSHQ77wUxLCIbkbIaAVys_nPRUXYwxqBOQzx8AfCPiAIjR64Ku92UjSf_MQEKGXno8odzw35QYmLXlFMD8OY/s400/1082215_632798580078833_781107996_o.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/208661164998043175/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/208661164998043175' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/208661164998043175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/208661164998043175'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2013/08/blog-post.html' title='卒グリー（中退かも）'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4wmZAkMJKUEB_L3vzsgFna-dv4EoEvl9znayDoH0zzbBDeam1NVvua9WiSHQ77wUxLCIbkbIaAVys_nPRUXYwxqBOQzx8AfCPiAIjR64Ku92UjSf_MQEKGXno8odzw35QYmLXlFMD8OY/s72-c/1082215_632798580078833_781107996_o.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-5810853569192891212</id><published>2012-04-30T22:54:00.001+09:00</published><updated>2013-08-13T00:22:27.592+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><title type='text'>JPMorganからグリーへ</title><content type='html'>新卒で入社して五年間働いたJPモルガン証券を退職して、今月からグリーでSNSの開発に携わることになりました。外資系証券会社のエンジニアからインターネット企業への転職という珍しい転職例なののですが、どのような考えで転職に至ったのか公開できる範囲でまとめました。一番の理由は、世界中の人々の生活を変えつつあるSNSの世界に関わりたかったからです。
&lt;br /&gt;
&lt;p&gt;
まず、JPモルガン証券を退職した理由ですが、従業員のレベルは本当に高く世界中からとびっきり優秀な人達が集まった素晴らしい職場でした。僕は債券システム部という部署にいたのですが、東京オフィスでさえチームメンバーのほとんどが外国人で、毎日のように世界中（ニューヨーク、ロンドン、シンガポール、香港、ムンバイなど）のメンバーと協力して業務を進めていたので国際感覚はかなり身につきましたし、証券業務のという複雑で専門性の高い知識を身に付けることもできました。勿論、システム開発や運用のスキルも身につきました。&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;
ただ、証券会社ということもありエンジニアが主役ではない点や、大手金融機関ということでコンプライアンスが厳しく社内の手続きが猥雑という点はありました。なので、ここ数年間でFacebookやTwitterを始めとする世界を変えるほどのインパクを持つ新しいWebサービスがどんどん出てきて、Facebookの「&lt;a href=&quot;http://www.wired.com/epicenter/2012/02/zuck-letter/&quot;&gt;The Hacker Way&lt;/a&gt;」に象徴されるようなエンジニアが先頭に立って自由にサービスを作り上げていくインターネット業界には強く憧れていました。
&lt;/p&gt;
&lt;p&gt;
数あるインターネット企業の中からグリーを選んだ理由は、SNSに対する興味、エンジニアを重視するカルチャー、積極的な海外展開の三点です。
&lt;/p&gt;
&lt;p&gt;
まず、SNSに対する興味ですが、僕はFacebookのヘビーユーザです。最近はSNSを利用することによって自分のコニュニケーションのスタイルが変わり、時間や場所を越えて効率的にコミュニケーションがとれるようになりました。最近では友達と連絡を取るときにはメールではなくFacebookメッセンジャーで話すことが多いですし、人と知り合うときにも携帯番号などではなくFacebookで友達申請し合うようになっています。グリーのSNSはまだFacebookほど洗練されたものではないかもしれませんが、ゲームとの連携や半匿名性のような特徴を利用してFacebookとはまた違うタイプの面白いプラットフォームになる可能性があると思ってます。
&lt;/p&gt;
&lt;p&gt;
次にエンジニアを重視するカルチャーです。転職にあたって他社ともお話をしたのですが、私が検討した会社の中ではグリーが一番エンジニア主導の会社だというイメージを持ちました。社長が自ら作って始めたSNSサービスが会社の始まりですし、創業時のキープレーヤーの多くがエンジニア出身という点が大きく影響しているからだと思います。会社によってはエンジニアは他の人のアイデアを実現するためのリソースとしての位置づけという印象をもった所もありましたので、そこは大きな魅力でした。
&lt;/p&gt;
&lt;p&gt;
最後に、積極的な海外展開ですが、グリーは世界市場をを狙える日本企業という点でもとても魅力的でした。今までは「世界展開している外資系大企業の東京支社」で働いていたので、意思決定権をもっているマネージャーがロンドンにいたりして、予算や技術的な枠組みがすべて海の向こうで決まった後に僕らがそれに合わせてプロジェクトにアサインされれローカライズするような形でした。なので、程よい規模で世界展開をすべく急激に成長している企業で働けるという点は大きな魅力でした。JPモルガンで海外のエンジニアチームと協力してプロジェクトを進める能力はかなり身についたと思うので、今度は日本から世界へという部分でその能力を活かせたら嬉しいです。
&lt;/p&gt;
&lt;p&gt;
そんな感じで４月頭に入社して丁度一ヶ月経ちますが、基本的にはイメージしていた通りの会社で順調にやってます。特に、前職がマネジメントが強い会社だったこともあってか現場主導の環境にとても心地よさを感じていますし、カルチャーの違い（全然違うよ！）なども楽しめています。その辺りを含めて、まだブログに書きたい事はいくつかありますが、今回はこの辺で。
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/5810853569192891212/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/5810853569192891212' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5810853569192891212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5810853569192891212'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/04/jpmorgan.html' title='JPMorganからグリーへ'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-6808308488877344204</id><published>2012-04-22T22:11:00.000+09:00</published><updated>2012-04-22T22:11:34.572+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="技術習得"/><title type='text'>Graph APIとGAEでお遊びアプリ</title><content type='html'>実は先月暇だったので、WebアプリケーションとKVS(Key Value Store)のお勉強をすべく、FacebookのAPIとGAE(Google App Engine) Pythonを使ってFacebookのフィードや友達、所属するグループの簡単な統計情報を表示する小さなアプリケーションを作りました。まぁしょぼいアプリですが、ここでちょろっと紹介します。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pei-fbstats.appspot.com/&quot;&gt;http://pei-fbstats.appspot.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
基本的にはfacebookのGraph APIを使って友達の性別や所属、コメントやLikeの数などを集計しているだけのアプリです。遥か昔に忘れたHTMLの書き方とか、GAEの使い方や初めて書くPythonやjQueryやKVS(結局使わなかったけど)の使い方とかを覚えながら、のべ二週間くらいかけて作りました。Feedのコメント数とかが微妙に上手く取れていないことがあるような気もしたりするので、お遊びの参考程度だと思っててきとーに使ってください。ユニットテストすら書いていないので…。気が向いたらちゃんと確認します。&lt;br /&gt;
&lt;br /&gt;
なんか問題があっても責任はとりませんがw、当初のKVSのお勉強をするという目標とは裏腹に、実はデータは全くKVSにストアしていないのでデータ集めてるとかはないです（KVSは使ってみたし勉強はちゃんとしたけどね！）。でも、毎回Graph API叩くのはさすがにパフォーマンス的にどうかと思うので、cache目的で使った方がいいだろうなぁとは思ってます。まぁでもその目的ならBigtableではなくmemcachedになるか…。でも、たぶん転職直後で忙しくて触ってる暇はもうないですが。&lt;br /&gt;
&lt;br /&gt;
以下、使ってるサービスとかライブラリの説明です。たぶんWebプログラミングに慣れてるひとからするとアホみたいな話でしょうが。僕が5-6年前に大学でやっていた頃と比べると、特にクラウドサービスとかJavascriptのライブラリの充実ぶりが半端無くて、本当に簡単にWebサービスが作れる時代になったんだなぁと実感しました。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://developers.google.com/appengine/?hl=ja&quot;&gt;GAE&lt;/a&gt;&lt;br /&gt;
サーバ借りたりとか面倒だし、勝手にスケールしてくれるし（そんなに使う人いないと思うけど）、僕みたいな怠惰な人間には最高のプラットフォームです。余談ですが、GAEではurllib2.urlopenは使えなくてgoogleの用意したurlfetchっていうライブラリを使わないといけないみたいです。socketが使えないのが理由みたい。軽くハマりました。詳しくはここで（&lt;a href=&quot;https://developers.google.com/appengine/docs/python/urlfetch/&quot;&gt;The URL Fetch Python API&lt;/a&gt;）。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://developers.facebook.com/docs/reference/api/&quot;&gt;Facebook Graph API&lt;/a&gt;&lt;br /&gt;
言わずと知れたfacebookのAPIです。リクエストの数が多い時には複数のリクエストをまとめてPOSTできる&lt;a href=&quot;http://developers.facebook.com/docs/reference/api/batch/&quot;&gt;batch機能&lt;/a&gt;とかもあったりして便利でした。けっこー、レスポンスに時間がかかったりするのでtimeoutとかpagingとかのパラメーターを上手く調整する必要があります。でかいデータにアクセスしようとすると、時間かかったりレスポンスがなかったりするのはこいつのせいです。（嘘です。ぼくが怠惰でエラーハンドリングとかcacheとかしてないせいです。）&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery&lt;/a&gt;&lt;br /&gt;
Webに慣れてる人は何を今更って感じでしょうが、奇跡のライブラリですねこれは。恥ずかしながら今回はじめて使ったのですが、非同期の処理が本当に簡単にできてしまってjavascriptの敷居を一気に下げるツールです。6-7年前に自分でオブジェクト作ってブラウザごとに分岐したりしてAjaxの処理を作っていたのが懐かしい（というか馬鹿みたい）。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pypi.python.org/pypi/simplejson/&quot;&gt;simplejson&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Graph APIはJSONでデータを返してきますし、このアプリも基本的にサーバ側はJSONでデータを返すだけで、クライアント側がサーバから返ってきたデータを可視化しています。実はJSON形式のデータって今まで使ったことなかったんですが（証券会社勤務だったのでJavaでXMLみたいな堅いメッセージングばっかり）、すごくシンプルなデータ構造ですし、このライブラリを使ったら超簡単に扱えました。pythonの配列や辞書形式のデータとJSONの文法がほとんど同じだったなのですぐに慣れました。python2.6以降ではデフォルトで含まれているみたいですが、GAEがサポートしているpython2.5に含まれていないので自分で落としてきました。&lt;a href=&quot;http://simplejson.readthedocs.org/en/latest/index.html&quot;&gt;このチュートリアル&lt;/a&gt;が分かり易かった。&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/dound/gae-sessions&quot;&gt;gae-sessions&lt;/a&gt;&lt;br /&gt;
後はwebappというGAEビルトインのフレームワークにはSession管理機能が含まれていないためgae-sessionsというセッション管理ライブラリを利用しました。たしかmemcachedを使ってるライブラリだったような。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://developers.facebook.com/docs/reference/api/batch/&quot;&gt;Google Graph Tools&lt;/a&gt;&lt;br /&gt;
グラフはGoogleのAPIを利用しました。javascriptのオブジェクトにデータ突っ込むと勝手に綺麗なグラフを作ってくれます。pie chartとbar chartしか使わなかったけど本当はもっと色々と細かいことできるみたいです。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://developers.facebook.com/tools/explorer/&quot;&gt;Graph API Explore&lt;/a&gt;&lt;br /&gt;
Graph APIで遊ぶなら必須ツールです。APIがどんなメッセージを返してくるのか簡単にチェックすることができます。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://antifavicon.com/&quot;&gt;Favicon Generator&lt;/a&gt;&lt;br /&gt;
faviconはこれでテキトーに作りました。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://git-scm.com/&quot;&gt;git&lt;/a&gt;&lt;br /&gt;
Dropboxをレポジトリにしてgitで管理しました。一度、リファクタリングしたらGitHubに乗せてみようかな。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
今後追加してもいいかなぁと思っているもの&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;キャッシュ。毎回時間かかり過ぎだから。&lt;/li&gt;
&lt;li&gt;人の名前をクにその人のFBページのリンクをつける。（Google Chart Toolsで簡単にできそう）&lt;/li&gt;
&lt;li&gt;自分と一緒にタグ付けされている人のランキング&lt;/li&gt;
&lt;li&gt;友達やグループメンバーのフィルタリングツール（友達を所属とか年齢や性別みたいな属性で絞り込むような機能。絞り込み後にメッセージ一斉送信とかできたら更に使えるかなみたいな。）&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/6808308488877344204/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/6808308488877344204' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/6808308488877344204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/6808308488877344204'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/04/graph-apigae.html' title='Graph APIとGAEでお遊びアプリ'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-1580324247123579888</id><published>2012-03-12T14:16:00.005+09:00</published><updated>2012-03-12T14:28:12.085+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="キャリア"/><category scheme="http://www.blogger.com/atom/ns#" term="昔のブログ"/><title type='text'>昔のブログ「外資系投資銀行を選んだ理由(2006年03月20日)」</title><content type='html'>最近、大学の研究室のサーバで眠っていた僕の修士課程時代のブログを見つけたので救出して読んでみました。2005年〜2007年くらいまで書いていたのですが、特に就職活動やキャリアの考えたかに関して興味をもって貰えそうなエントリーがいくつか出てきたので、基本的にはそのまま転載する形でいくつか紹介していきたいと思っています。&lt;br /&gt;
&lt;br /&gt;
僕は修士課程在籍中の2005年3月のにJPモルガン証券のシステム部門に内定して2007年の4月から新入社員として入社したのですが、以下のエントリーはその時にどうして僕が外資系投資銀行のシステム部門という特殊な職を選んだのかを説明したものです。&lt;br /&gt;
&lt;br /&gt;
6年経った今ではソフトウェアエンジニアの争奪戦が起こっており、高度な知識や技術をもったエンジニアの価値や待遇がどんどん高まっているという点では、この時の僕の考えはかなり的を得ていたと自分でも思っています。このエントリーで述べている僕のITコンサルやSIerに関する見方はちょっとステレオタイプな部分もあるかもしれませんが、今でも自分のキャリアに対する考えはこの時と殆ど変わっていません。6年前のひよっこ時代にも、それなりに物事を考えていたんだなぁと昔の自分にちょっと感心 :)&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;&lt;b&gt;2006年03月20日&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;b&gt;外資系投資銀行を選んだ理由&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;初のトラックバックです。以下のブログを読んで思うところがあったので。&lt;br /&gt;
&lt;a href=&quot;http://satoshi.blogs.com/life/2006/03/post_8.html&quot;&gt;&lt;span class=&quot;s1&quot;&gt;「Life is beautiful: ソフトウェアの仕様書は料理のレシピに似ている」&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
要約すると、日本のシステム開発は「上流→下流」とゼネコンみたいに階層化されていて、プログラムもろくに書かない上流コンサルタントの設計を下請けの下流プログラマが仕様書どおりにコーディングするという構造になっている。そんなの効率悪いし、品質のよいソフトウェアはできないよという話。&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;この問題は、就職活動をするにあたってソフトウェア・エンジニアとしてガリガリと開発ができる職種を求めていた僕が、外資系投資銀行のテクノロジー部を選んだ大きな理由の一つ。&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;日本のシステム開発は上記のような階層構造になっているため、価値の高いことをしようと思うと、ITコンサルタントという職を選ぶしかない。IBM、アクセンチュア、野村総研とかのね。こういう企業では入社しばらくはプログラマとして下働きをして、その後に&lt;b&gt;「泥臭いコーディングなんてしないコンサルタント」&lt;/b&gt;としてステップアップするらしい。その後は、マネージメントやお客さんから仕事をとってくる営業活動がメイン。技術重視では出世できない。実装を行う下請けの会社では、プログラムを書かない人達が作ったガチガチの設計書を元に、就職して初めてプログラムを書くような経験の少ない人達がコーディングを行う。「プログラマ＝初心者」という感じで、プログラマの地位は低い。階層構造の上の方からしっかりと利抜きされて仕事が回ってくるため給料も低い。&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;この階層構造の中での仕事を回避するために、少数で効率の良い開発を行っている企業をターゲットにしてみた。初めに考えたのは外資系のソフトウェアベンダーやインターネット企業。ソフトウェアベンダーとしてはマイクロソフトやオラクルが挙げられるけど、開発の拠点はアメリカで、日本の支店はそのローカライズや顧客サポート、営業が大半を占める。やっぱり一番魅力的な会社はGoogleなのだが、さすがに敷居が高すぎるし、どうしようかなぁと悩んでいたときに出会ったのが外資系投資銀行のテクノロジー部門。&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;基本丸投げの日系金融機関と違って、外資系投資銀行ではITをとても重視している。開発は少数のエンジニア達により殆ど自社で行う。エンジニアには金融工学などの数学的センスも求められるみたいで、専門性が高い。ここで頑張ればコンピューター・サイエンスと金融数学を武器にできると思って、この業界に決めた。海外のエンジニアさん達との共同開発や、成果を重視する評価精度も魅力的だった。日本の会社って若いうちは安い給料で奉公って感じだから。まぁ、エンジニアが主役となる会社ではないっていうのがネックなんだけどね。&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;採用人数はとても少なく、面接は英語ばかりだし、いきなりプログラムを書かされたりと大変だったが、運良く内定を頂くことができた。という訳で外資系投資銀行のテクノロジー部門に就職する事になった。&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/1580324247123579888/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/1580324247123579888' title='1 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/1580324247123579888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/1580324247123579888'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/03/20060320.html' title='昔のブログ「外資系投資銀行を選んだ理由(2006年03月20日)」'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-5530331221824329528</id><published>2012-02-29T12:29:00.007+09:00</published><updated>2012-02-29T13:08:18.847+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="社会勉強"/><title type='text'>旅券統計で遊んでみた</title><content type='html'>近いうちにハワイ旅行に行こうと思っているのですが、パスポートの残存期間が半年を割っているのでそろそろ更新したほうがよいかと思い調べてみると、10年券の発行には1万6千円、5年券の発行には1万1千円もかかるではないですか。仮に裏に外務省の天下り機関とかがいたらとしたらどれくらいウハウハなんだよ勝手に妄想していると、なんかムシャクシャしてきたので数字を調べてみました。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.mofa.go.jp/mofaj/toko/tokei/passport/index.html&quot;&gt;外務省の統計&lt;/a&gt;によりますと、平成23年のパスポート発行数は5年で1,543,554、10年で2,417,828の合計3,961,382だそうです。以下のように計算してみると、一年で550億円以上の収入が入っていることが分かります。あんな小さい冊子にICチップを埋め込んだ程度のものなので、作成には1000円もかからないでしょうし、事務手続きも簡単だと思うのですが…&lt;br /&gt;
&lt;br /&gt;
1,543,554 x 11,000円 + 2,417,828 x 16,000円 = 55,664,342,000円&lt;br /&gt;
&lt;br /&gt;
後、てきとーに数字を眺めていると以下の事にも気づきました。&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;若い世代のシーズナリティが強い。&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;特に19才以下は8月の夏休みと3月の春休み期間に発行が集中しており、その二ヶ月で一年の発行数の25%を超えています。&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;20才を超えると年齢と発行数が逆相関になっている。&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;面倒くさくてちゃんと調べてないけど、Wikipediaの年齢別人口のグラフを眺めたところ、20代よりは30代、40代、50代の方が人口が多そうなのに発行数が減っていっています。やっぱ若者のほうが海外旅行に行きたがるのですかね。&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;都市部の発行数が多い&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;人口に応じて発行率（発行数 / 人口）が上がる。&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;上位は東京(4.80%)、神奈川(4.22%)、千葉(3.65)&lt;/li&gt;
&lt;li&gt;下位は青森(1.21%)、秋田(1.41%)、高知(1.66%)&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;以下、縦軸を発行率、横軸を人口として各都道府県をプロットした図です。水色のラインはただの線形回帰。なんとなくイメージが掴めると思います。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKshmSyCNlmE_uAwp0-abu8vh_qIkrShk3cAkY2_SFcFleEC8adavIo7bzRfyFSkqOUgf6UYU0wMedlcOnveZ0EFoOOAKDsYr40BDQ8AolQUymWEc5s8KihucVUASG8KyWBQpyjXYPu4/s1600/passport_vs_population.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKshmSyCNlmE_uAwp0-abu8vh_qIkrShk3cAkY2_SFcFleEC8adavIo7bzRfyFSkqOUgf6UYU0wMedlcOnveZ0EFoOOAKDsYr40BDQ8AolQUymWEc5s8KihucVUASG8KyWBQpyjXYPu4/s320/passport_vs_population.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;
で、結局550億円って一体どこに行くのでしょうか？？&lt;br /&gt;
&lt;br /&gt;
参考&lt;br /&gt;
&lt;a href=&quot;http://www.mofa.go.jp/mofaj/toko/tokei/passport/index.html&quot;&gt;外務省旅券統計&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E4%BA%BA%E5%8F%A3%E7%B5%B1%E8%A8%88&quot;&gt;Wikipedia 日本の人口統計&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ja.wikipedia.org/wiki/%E9%83%BD%E9%81%93%E5%BA%9C%E7%9C%8C%E3%81%AE%E4%BA%BA%E5%8F%A3%E4%B8%80%E8%A6%A7&quot;&gt;Wikipedia 都道府県の人口一覧&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/5530331221824329528/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/5530331221824329528' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5530331221824329528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5530331221824329528'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/02/blog-post_29.html' title='旅券統計で遊んでみた'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKshmSyCNlmE_uAwp0-abu8vh_qIkrShk3cAkY2_SFcFleEC8adavIo7bzRfyFSkqOUgf6UYU0wMedlcOnveZ0EFoOOAKDsYr40BDQ8AolQUymWEc5s8KihucVUASG8KyWBQpyjXYPu4/s72-c/passport_vs_population.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-5337318494602767480</id><published>2012-02-20T23:25:00.000+09:00</published><updated>2012-02-20T23:25:13.600+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Life Hack"/><title type='text'>Sitting is Killing You</title><content type='html'>昔見つけたインフォグラフィックス。僕は昔からかなりの腰痛持ちだったのですが、これの通りに135度くらい傾けて体重をしっかり背中に預けて、足を伸ばしたりしながらプラプラしてると、腰痛が和らぐことに気づきました。お勧めはスチールケース社のリープチェア。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.medicalbillingandcoding.org/sitting-kills&quot;&gt;&lt;img src=&quot;http://images.medicalbillingandcoding.org.s3.amazonaws.com/sitting-is-killing-you.jpg&quot; alt=&quot;Sitting is Killing You&quot; width=&quot;500&quot;  border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Via: &lt;a href=&quot;http://www.medicalbillingandcoding.org&quot;&gt;Medical Billing And Coding&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/5337318494602767480/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/5337318494602767480' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5337318494602767480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/5337318494602767480'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/02/sitting-is-killing-you.html' title='Sitting is Killing You'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-3189711184613127263</id><published>2012-02-19T22:08:00.003+09:00</published><updated>2012-02-20T23:43:22.247+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="技術習得"/><category scheme="http://www.blogger.com/atom/ns#" term="読書"/><title type='text'>読書日記「仮想世界錬金術　モバイルソーシャルアプリに見る現代ディジタルコンテンツ革命」</title><content type='html'>今、破竹の勢いでビジネスが拡大しているモバイルソーシャルゲームについて勉強してみたいと思って読んでみました。僕もモバイルソーシャルゲームは「&lt;a href=&quot;http://ja.wikipedia.org/wiki/%E7%A0%B4%E5%A3%8A%E7%9A%84%E6%8A%80%E8%A1%93&quot;&gt;破壊的イノベーション&lt;/a&gt;」の典型例だと思っていて、最近はとても注目しています。グリーやDeNAの好調な業績が世間を驚かせていますが、国内のソーシャルゲーム市場は2012年度には3400億円を突破すると予想されているようです。（&lt;a href=&quot;http://www.yano.co.jp/press/press.php/000899http://www.yano.co.jp/press/press.php/000899&quot;&gt;矢野経済研究所：ソーシャルゲーム市場に関する調査結果2011&lt;/a&gt;より）また、同時に海外市場への進出も急速に進めています。本書ではソーシャルゲームビジネスがいかに拡大してきたか、ソーシャルゲームの基本原理、またそのマーケットについてを実例に基づいて説明しています。&lt;br /&gt;
&lt;br /&gt;
僕が一番面白いと感じたのは、モバイルソーシャルゲームはひたすらEnterを押し続けるような単純なゲームに見えながらも、裏側では以下のような技術やノウハウが凝縮された、かなり高度なサービスだということです。&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;限られた機能、コンテンツ、UIでいかにユーザを楽しませるか（ゲームニクス理論、エクスペクトロジー、時間の使わせ方など）&lt;/li&gt;
&lt;li&gt;どうユーザ間のコミュニケーションを楽しませるか&lt;/li&gt;
&lt;li&gt;データマイニングに基づくチューニング&lt;/li&gt;
&lt;li&gt;フレームワークを利用した少人数、短期間での開発&lt;/li&gt;
&lt;li&gt;クラウドサービスや並列処理を利用した負荷分散&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
個人的には、これからゲームビジネスはどんどんパッケージ型から課金型へビシネスモデルが変換していくと予測しています。据え置き型のゲームも初期の価格設定を低く抑えて、コンテンツやアイテムなどで課金していくのが主流になっていく気がします。正直、僕自身がモバイルソーシャルゲーム（怪盗ロワイヤルとかドリランド）をやった限りでは、システムが単調すぎてのめり込むほど面白いとは思えなかったんだけれども、おそらく今後はスマートフォン向けの新しいゲームがどんどん出てきて、もっとリッチなコンテンツを求めるユーザ層も獲得していくだろうと思っています。メインフレームがオープン系のワークステーションに置き換えていったようにね。海外進出もどんどん進められているようなので、日本のIT企業が海外の市場でどれだけ戦えるのか楽しみですね。&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm-jp.amazon.co.jp/e/cm?t=studentsblog-22&amp;amp;o=9&amp;amp;p=8&amp;amp;l=as1&amp;amp;asins=4901976907&amp;amp;ref=tf_til&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 240px; width: 120px;&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/3189711184613127263/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/3189711184613127263' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3189711184613127263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/3189711184613127263'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/02/blog-post_19.html' title='読書日記「仮想世界錬金術　モバイルソーシャルアプリに見る現代ディジタルコンテンツ革命」'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3323734665683622157.post-7198778663514058482</id><published>2012-02-08T21:13:00.001+09:00</published><updated>2012-02-20T23:28:52.638+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="読書"/><category scheme="http://www.blogger.com/atom/ns#" term="起業"/><title type='text'>読書日記「企業のファイナンス　ベンチャーにとって一番大切なこと」</title><content type='html'>ちょっと起業して一発当ててやろうと思い（嘘）、友達に薦められた、「&lt;a href=&quot;http://www.amazon.co.jp/gp/product/4534047576/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;tag=studentsblog-22&amp;linkCode=as2&amp;camp=247&amp;creative=1211&amp;creativeASIN=4534047576&quot;&gt;企業のファイナンス　ベンチャーにとって一番大切なこと&lt;/a&gt;」というベンチャー企業のファイナンスの本を呼んで見ました。磯崎哲也さんというベンチャービジネスやファイナンスについて書かれた&lt;a href=&quot;http://www.tez.com/blog/&quot;&gt;isologue&lt;/a&gt;というブログで有名な方です。&lt;br /&gt;
&lt;br /&gt;
この本は、実際に自分が起業した時のイメージを持つために書かれており、起業の流れやファイナンスの仕組み、上場やバイアウトのプロセス、実行時にに気をつけたほうが良いことなどを易しく筆者の経験を交えながら説明してあります。&lt;br /&gt;
&lt;br /&gt;
かなり幅広い事を説明しているので詳細まで紹介することはできませんが、事業計画の作り方、ストック・オプションや種類株式や投資家（VCなど）との交渉の仕方の説明まで含めた資本政策の方法、バイアウトや上場によりどうキャピタルゲインが得られるのかなどまで説明してあります。僕は証券会社に5年間ほど勤務しているので基本的なファイナンスの知識はあるのですが、上場時に何が必要になるかや、種類株式を利用して如何にすべてのステークホルダーの利益を損ねないように増資を行うかなどの説明はとても興味深かったです。&lt;br /&gt;
&lt;br /&gt;
また、日本はベンチャーの市場規模が小さく、「ベンチャーに冷たい」と言われがちですが、実際にはそうではなく足りていないのはアニマルスピリッツをもったイケてる創業者や、それをサポートする仕組みだというのが著者の意見です。&lt;br /&gt;
&lt;br /&gt;
シリコンバレーみたいに次から次へと競争力もスピードもあるスタートアップが湧いて出てくる環境と比べればライバルが少ないですし、サポートしてくれる人は資金政策さえ上手く行けば、競争の少ない分だけ上手く行く可能性が高いのかもしれませんね。&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src=&quot;http://rcm-jp.amazon.co.jp/e/cm?t=studentsblog-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=4534047576&amp;ref=qf_sp_asin_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr&quot; style=&quot;width:120px;height:240px;&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.aripei.com/feeds/7198778663514058482/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3323734665683622157/7198778663514058482' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7198778663514058482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3323734665683622157/posts/default/7198778663514058482'/><link rel='alternate' type='text/html' href='http://blog.aripei.com/2012/02/blog-post_08.html' title='読書日記「企業のファイナンス　ベンチャーにとって一番大切なこと」'/><author><name>Ippei Arita</name><uri>http://www.blogger.com/profile/15184486722739180850</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVtm6kxLXN-hzVHRZDKnq3Nc4ZXehdZ1eKn2hbVTGN2jzP1L2lmJgNp4mDZ3oPSa59eKQJokto1eJgcZXo663v_zMEhoiHA9Z5GFUWMBHjuGOWwPz8JKBXrlI06KQ/s1600/*'/></author><thr:total>0</thr:total></entry></feed>