<?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-5989192249356951690</id><updated>2024-09-05T19:31:02.887+09:00</updated><category term="python"/><category term="Django"/><category term="Facebook"/><category term="JavaScript"/><category term="Mootools"/><category term="mysql"/><category term="HandlerSocket"/><category term="Jenkins"/><category term="Selenium"/><category term="spider"/><title type='text'>Web屋さんのアレ</title><subtitle type='html'>PythonやらObjective-Cまわりのお話を書いていくよ！たまに関係ない事も書くよ！</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-2153392095902298586</id><published>2013-07-06T19:36:00.000+09:00</published><updated>2013-07-06T19:36:25.290+09:00</updated><title type='text'>ブログ移転しました。</title><content type='html'>はてなブログに移動してしまいました。&lt;br /&gt;
新しいURLはこっちだよ。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://odoku.hatenablog.com/&quot;&gt;http://odoku.hatenablog.com/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/2153392095902298586/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2013/07/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/2153392095902298586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/2153392095902298586'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2013/07/blog-post.html' title='ブログ移転しました。'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-2435528289382868139</id><published>2013-03-23T15:12:00.000+09:00</published><updated>2013-03-23T15:12:07.204+09:00</updated><title type='text'>【nginx】&quot;Address already in use&quot;って言われて動かない【ubuntu】</title><content type='html'>Ubuntu12.04にNginxを入れる時にいっつも忘れるのでメモ。&lt;br&gt;
80番ポートが使われてるよって怒られる場合は/etc/nginx/sites-available/defaultを以下の様に変更。

&lt;code&gt;&lt;pre&gt;listen [::]:80 default_server;&lt;/pre&gt;&lt;/code&gt;

↓

&lt;code&gt;&lt;pre&gt;listen [::]:80 ipv6only=on default_server;&lt;/pre&gt;&lt;/code&gt;

コレで動くはず。</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/2435528289382868139/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2013/03/nginxaddress-already-in-useubuntu.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/2435528289382868139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/2435528289382868139'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2013/03/nginxaddress-already-in-useubuntu.html' title='【nginx】&quot;Address already in use&quot;って言われて動かない【ubuntu】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-7500856766743909268</id><published>2013-02-24T16:15:00.000+09:00</published><updated>2013-02-24T18:39:12.427+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【python】isk-daemonのインストール【画像検索】</title><content type='html'>&lt;p&gt;
公式を見ると「easy-installでインスコ出来るお」って書いてあったんだけど何故か出来なかった。。&lt;br&gt;
仕方ないのでgithubに上がってるソースからインスコしてみたけどコレも動かず。&lt;br&gt;
イラッとしたので&lt;a href-&quot;https://pypi.python.org/pypi/isk-daemon/0.9.3&quot;&gt;pypiからソースを直接ダウンロード&lt;/a&gt;して入れてみたら動いたよ。
&lt;/p&gt;

&lt;p&gt;
でもsite-packagesの直下にcoreとかuiとかいうディレクトリが出来るんだけど、ちょっと無作法じゃないですかねコレ。&lt;br&gt;
気持ち悪い。
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/7500856766743909268/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2013/02/pythonisk-daemon.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7500856766743909268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7500856766743909268'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2013/02/pythonisk-daemon.html' title='【python】isk-daemonのインストール【画像検索】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-7576337754124908676</id><published>2012-07-30T11:29:00.002+09:00</published><updated>2012-07-30T11:29:43.698+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【python】dateをdatetimeに変換する方法【Tips】</title><content type='html'>検索してもパッと出てこないので書いておきます。
あんまり使う機会ないかもだけど。。

&lt;pre class=&quot;brush: python&quot;&gt;
from datetime import date, time, datetime

# 今日の日付
today = date.today()

# dateをdatetimeに変換
# time()は&quot;00:00:00&quot;の事
today = datetime.combine(today, time())
&lt;/pre&gt;

リファレンスにちゃんと書いてありますね。
&lt;a href=&quot;http://www.python.jp/doc/nightly/library/datetime.html&quot;&gt;http://www.python.jp/doc/nightly/library/datetime.html&lt;/a&gt;

&lt;br&gt;
&lt;br&gt;
変換ってか結合って感じだけども。。</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/7576337754124908676/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/07/pythondatedatetimetips.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7576337754124908676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7576337754124908676'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/07/pythondatedatetimetips.html' title='【python】dateをdatetimeに変換する方法【Tips】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-5580483648359174901</id><published>2012-04-25T16:29:00.000+09:00</published><updated>2012-04-25T17:10:29.721+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HandlerSocket"/><category scheme="http://www.blogger.com/atom/ns#" term="mysql"/><title type='text'>【MySQL】libhsclient_la-config.o: No such file or directory【HandlerSocket】</title><content type='html'>&lt;p&gt;
ubuntu10.04にMySQL HandlerSocket Pluginをインストールしようと思ったら下記の様なエラーが出た。&lt;br&gt;
&lt;br&gt;
&quot;libhsclient_la-config.o: No such file or directory&quot;&lt;br&gt;
&lt;br&gt;
調べてもさっぱり情報ないしどうしようーって思ってたら、make時にlibhsclientのディレクトリで生成されてるオブジェクトファイルの名前が何故か違ってたので、リネームしてmakeしなおしてやったらインストール出来ました。
&lt;/p&gt;

&lt;pre class=&quot;brush: python&quot;&gt;
sudo apt-get install libtool
sudo apt-get install autoconf
sudo apt-get install g++

cd ~/HandlerSocket-Plugin-for-MySQL

./autogen.sh
./configure --with-mysql-source=/home/odoku/opt/src/mysql5.5.14 --with-mysql-bindir=/home/odoku/opt/mysql/5.5.14/bin --with-mysql-plugindir=/home/odoku/opt/mysql/5.5.14/lib/plugin
make

# ここでエラーが出るんです。。

cd libhsclient
mv config.o libhsclient_la-config.o
mv escape.o libhsclient_la-escape.o
mv fatal.o libhsclient_la-fatal.o
mv hstcpcli.o libhsclient_la-hstcpcli.o
mv socket.o libhsclient_la-socket.o
mv string_util.o libhsclient_la-string_util.o

cd ..
sudo make install
&lt;/pre&gt;

&lt;p&gt;
はたしてこんな無理やりな対処方法でいいのかどうか。。
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/5580483648359174901/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/04/mysqllibhsclientla-configo-no-such-file.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/5580483648359174901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/5580483648359174901'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/04/mysqllibhsclientla-configo-no-such-file.html' title='【MySQL】libhsclient_la-config.o: No such file or directory【HandlerSocket】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-6412900870868828026</id><published>2012-04-24T18:15:00.000+09:00</published><updated>2012-04-24T18:20:18.294+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mysql"/><category scheme="http://www.blogger.com/atom/ns#" term="spider"/><title type='text'>【MySQL】SpiderをSandboxで動かす【Sandbox】</title><content type='html'>&lt;p&gt;
SpiderってかMysql Sandboxの話ですけども。。&lt;br /&gt;
サンプル通りにやっても動かなかったのでメモ。&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;
インストール方法は調べれば沢山出てくるので割愛。&lt;br /&gt;
つっても1行書くだけだけども。。&lt;br /&gt;
ここらへんを参考に。&lt;br /&gt;
&lt;a href=&quot;http://d.hatena.ne.jp/ZIGOROu/20090607/1244367464&quot;&gt;http://d.hatena.ne.jp/ZIGOROu/20090607/1244367464&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
で、make_sandboxすると&lt;br /&gt;
&lt;br /&gt;
&quot;You must enter a full path to the tarball. Relative paths are not supported.&quot;&lt;br /&gt;
&lt;br /&gt;
とか&lt;br /&gt;
&lt;br /&gt;
&quot;Not a tarball&quot;&lt;br /&gt;
&lt;br /&gt;
とか訳の判らん事(わかるけどｗ)を仰るので困った。&lt;br /&gt;
ので、解凍してからやってやると上手くいきました。&lt;br /&gt;
以下、手順&lt;br /&gt;
&lt;br /&gt;
Spiderはコチラからダウンロードしてね。&lt;br /&gt;
&lt;a href=&quot;https://launchpad.net/spiderformysql&quot;&gt;https://launchpad.net/spiderformysql&lt;/a&gt;
&lt;/p&gt;

&lt;pre class=&quot;brush: python&quot;&gt;
export SANDBOX_BINARY=$HOME/opt/mysql
export SANDBOX_HOME=$HOME/opt/sandboxes

mkdir ~/opt/mysql
cd ~/opt/mysql

wget http://spiderformysql.com/downloads/spider-2.26/mysql-5.5.14-spider-2.26-vp-0.15-hs-1.0-linux-i686-glibc23.tgz
tar zxvf mysql-5.5.14-spider-2.26-vp-0.15-hs-1.0-linux-i686-glibc23.tgz
mv mysql-5.5.14-spider-2.26-vp-0.15-hs-1.0-linux-i686-glibc23.tgz 5.5.14

make_sandbox $SANDBOX_BINARY/5.5.14
&lt;/pre&gt;

&lt;p&gt;
なんかディレクトリをバージョン名にしなきゃいけないとか決まりごとがある様です。&lt;br /&gt;
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/6412900870868828026/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/04/mysqlspidersandboxsandbox.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/6412900870868828026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/6412900870868828026'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/04/mysqlspidersandboxsandbox.html' title='【MySQL】SpiderをSandboxで動かす【Sandbox】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-7101026760533988900</id><published>2012-04-16T18:59:00.000+09:00</published><updated>2012-04-25T16:47:52.953+09:00</updated><title type='text'>【KVS】ubuntuにKyoto Tycoonをインストールする【memcached】</title><content type='html'>&lt;h3&gt;コンパイル環境を入れる&lt;/h3&gt;
&lt;pre&gt;sudo apt-get install build-essential&lt;/pre&gt;



&lt;h3&gt;必要なライブラリを入れる&lt;/h3&gt;
&lt;pre&gt;sudo apt-get install zlib1g&lt;/pre&gt;



&lt;h3&gt;パッケージをダウンロード&lt;/h3&gt;
&lt;p&gt;# 最新版はコチラで確認してね &lt;a href=&quot;http://fallabs.com/&quot;&gt;http://fallabs.com/&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;
wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.74.tar.gz
wget http://fallabs.com/kyototycoon/pkg/kyototycoon-0.9.55.tar.gz
&lt;/pre&gt;



&lt;h3&gt;Kyoto Cabinetのインストール&lt;/h3&gt;
&lt;pre&gt;
tar xvfz kyotocabinet-1.2.74.tar.gz
cd kyotocabinet-1.2.74
./configure
make
sudo make install
&lt;/pre&gt;



&lt;h3&gt;Kyoto Tycoonのインストール&lt;/h3&gt;
&lt;pre&gt;
tar xvfz kyototycoon-0.9.55.tar.gz
cd kyototycoon-0.9.55.tar.gz
./configure
make
sudo make install
&lt;/pre&gt;



&lt;h3&gt;/usr/local/libをシステムに認識させる&lt;/h3&gt;
&lt;pre&gt;sudo vi /etc/ld.so.conf.d/lib.conf&lt;/pre&gt;
&lt;pre class=&quot;brush: python&quot;&gt;
/usr/local/lib &amp;lt;--追加
&lt;/pre&gt;
&lt;p&gt;変更した設定を反映します&lt;/p&gt;
&lt;pre&gt;sudo ldconfig&lt;/pre&gt;



&lt;h3&gt;サーバーが起動すれば完了&lt;/h3&gt;
&lt;pre&gt;ktserver&lt;/pre&gt;

&lt;p&gt;memcachedプロトコルを有効（2010ポートで起動）にする場合は以下のオプションをつけてサーバーを起動&lt;/p&gt;
&lt;pre&gt;
ktserver -plsv /usr/local/libexec/ktplugservmemc.so -plex &#39;port=2010&#39;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/7101026760533988900/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/04/kvsubuntutokyo-tycoonmemcached.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7101026760533988900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7101026760533988900'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/04/kvsubuntutokyo-tycoonmemcached.html' title='【KVS】ubuntuにKyoto Tycoonをインストールする【memcached】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-4159530245553266961</id><published>2012-03-05T11:03:00.001+09:00</published><updated>2012-03-05T11:03:22.982+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【easy_install】モジュールのインストールでよくコケるアナタへ【pip】</title><content type='html'>&lt;p&gt;前に書いたエントリーと重複する内容なんですけれども。&lt;/p&gt;

&lt;p&gt;
    mac os10.6でpip installをすると、よく&lt;br&gt;
    &quot;error: command &#39;gcc-4.2&#39; failed with exit status 1&quot;&lt;br&gt;
    こんなエラーで落ちる事があるんですけれども、これを回避する方法は以下の様にすれば良いようです。&lt;br&gt;
&lt;/p&gt;

&lt;pre&gt;sudo env ARCHFLAGS=&quot;-arch i386 -arch x86_64&quot; pip install パッケージ名&lt;/pre&gt;

&lt;p&gt;
    で、毎回こんなの打ってるの面倒なので、.bashrcにでも書いといて下さい。&lt;br&gt;
    pipを置き換える場合はこんな感じ。
&lt;/p&gt;

&lt;pre&gt;alias pip=&#39;sudo env ARCHFLAGS=&quot;-arch i386 -arch x86_64&quot; pip&#39;&lt;/pre&gt;

&lt;p&gt;確かRubyでも似たような事で詰まった気がしたので、ARCHFLAGSだけ書いといたほうがいいかもね。&lt;/p&gt;

&lt;pre&gt;export ARCHFLAGS=&#39;-arch i386 -arch x86_64 -arch ppc&#39;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/4159530245553266961/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/03/easyinstallpip.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/4159530245553266961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/4159530245553266961'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/03/easyinstallpip.html' title='【easy_install】モジュールのインストールでよくコケるアナタへ【pip】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-4358843046040288440</id><published>2012-01-24T16:29:00.000+09:00</published><updated>2012-01-24T16:29:10.333+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook"/><title type='text'>【Facebook】Facebookアプリが持つアクセストークンを取得【アプリ】</title><content type='html'>&lt;p&gt;
FacebookはOAuth2.0に対応しているのでユーザーとアプリが紐づいたアクセストークンというものを発行してくれるのですが、どうやらアプリ自体が持つアクセストークンってのも在るようです。&lt;br&gt;
以下のURLにアクセスすると取得出来るみたいです。&lt;br&gt;
[APP_ID]と[APP_SECRET]は各自適宣変更して下さいね。
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&amp;client_secret=[APP_SECRET]&amp;grant_type=client_credentials&quot; target=&quot;_blank&quot;&gt;https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&amp;client_secret=[APP_SECRET]&amp;grant_type=client_credentials&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Request Dialogを使ってアプリへの招待を送った際に発行される、リクエストオブジェクトを取得する時なんかに使用出来ます。
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/4358843046040288440/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/01/facebookfacebook.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/4358843046040288440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/4358843046040288440'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/01/facebookfacebook.html' title='【Facebook】Facebookアプリが持つアクセストークンを取得【アプリ】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-108731316609905589</id><published>2012-01-24T12:01:00.001+09:00</published><updated>2012-01-24T16:29:28.382+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook"/><title type='text'>【Facebook】Facebookアプリでlocalhostを指定する為のアレ【アプリ】</title><content type='html'>&lt;p&gt;
Facebookアプリを作る機会があったので色々と調べていたのですが、OAuth認証のコールバックにはlocalhostを指定出来ないみたいでちょっと困った。&lt;br&gt;
ので、hostsを書き換えて無理やりやりましょうって事でやってみたら上手く行きました。
&lt;/p&gt;

&lt;p&gt;
hostsの設定は以下のとおり。
コレを/etc/hostsのどっかに書いておいて下さい。
&lt;/p&gt;
&lt;pre class=&quot;brush: python&quot;&gt;127.0.0.1    local.examples.com&lt;/pre&gt;

&lt;p&gt;
で、Facebookアプリの設定。&lt;br&gt;
【アプリのドメイン】の所に上記で設定したドメインを追加。&lt;br&gt;
下の方にある【ウェブサイト】のところも忘れずに。
&lt;/p&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/AVvXsEgwvvNVD1PBqsggnnUed7Jdjy4RAhyphenhyphenJaIfqYaliJ70ZoaK23EzVwhG__lKMm2TcUqqGbMUHKwwLGM2xAk9Z1gpTQi3rIU0IdBkkhtPjeRYKl3TdGldBlxVJHFInulf-av14YJ9TVlgFIb9-/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.08.27%25EF%25BC%2589.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;113&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwvvNVD1PBqsggnnUed7Jdjy4RAhyphenhyphenJaIfqYaliJ70ZoaK23EzVwhG__lKMm2TcUqqGbMUHKwwLGM2xAk9Z1gpTQi3rIU0IdBkkhtPjeRYKl3TdGldBlxVJHFInulf-av14YJ9TVlgFIb9-/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.08.27%25EF%25BC%2589.png&quot; /&gt;&lt;/a&gt;
&lt;/div&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/AVvXsEg0gvAdjVVQihxTKDH_f6fjkhc4GSEFOHCfJq-Vi3hXyZWySAxxmDjmPEvzKxuH4H0_qgWT9onIQr5LzEeuGIkNg5vr8Hvdkw8hMoaIe6xJiZ9brF0R0CZAOuPzHSfKqtgPu_6B2w-yjksI/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.14.12%25EF%25BC%2589.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;63&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0gvAdjVVQihxTKDH_f6fjkhc4GSEFOHCfJq-Vi3hXyZWySAxxmDjmPEvzKxuH4H0_qgWT9onIQr5LzEeuGIkNg5vr8Hvdkw8hMoaIe6xJiZ9brF0R0CZAOuPzHSfKqtgPu_6B2w-yjksI/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.14.12%25EF%25BC%2589.png&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;
後は設定したドメインにアクセスすれば問題なく動きますよ。
&lt;/p&gt;

&lt;p&gt;
ついでにキャンバスページも同様に出来るので設定してみると幸せになれるかも。
&lt;/p&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/AVvXsEhRHu4I6TEUeLaec_a1fk4thcFctCWDJVhyphenhyphentTTYGVrzw1lPFMKwg8BVrHHl8Qr5MA1-vPOlPAGnXbKeWG-xYg5w1yHF95Y2JGq2qiNPsC6Tsmm5DlnLzHDJcuZiinFJT_882RAAy0DqePUO/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.16.29%25EF%25BC%2589.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHu4I6TEUeLaec_a1fk4thcFctCWDJVhyphenhyphentTTYGVrzw1lPFMKwg8BVrHHl8Qr5MA1-vPOlPAGnXbKeWG-xYg5w1yHF95Y2JGq2qiNPsC6Tsmm5DlnLzHDJcuZiinFJT_882RAAy0DqePUO/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.16.29%25EF%25BC%2589.png&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;
余談ですが、Djangoのテストサーバーがlocalhost:8000で動いてるんですけども、Nginx使ってリバースプロキシってやると幸せになりました。&lt;br&gt;
便利な世の中ですね。
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/108731316609905589/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/01/facebookfacebooklocalhostwo.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/108731316609905589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/108731316609905589'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/01/facebookfacebooklocalhostwo.html' title='【Facebook】Facebookアプリでlocalhostを指定する為のアレ【アプリ】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwvvNVD1PBqsggnnUed7Jdjy4RAhyphenhyphenJaIfqYaliJ70ZoaK23EzVwhG__lKMm2TcUqqGbMUHKwwLGM2xAk9Z1gpTQi3rIU0IdBkkhtPjeRYKl3TdGldBlxVJHFInulf-av14YJ9TVlgFIb9-/s72-c/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%25EF%25BC%25882012-01-24+12.08.27%25EF%25BC%2589.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-7686910054880370884</id><published>2012-01-12T18:44:00.000+09:00</published><updated>2012-01-12T18:44:11.952+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【Python】Modelクラスでclean_[field_name]メソッドを使う【Django】</title><content type='html'>&lt;p&gt;
  Djangoのforms.Formクラスにあるアレです。&lt;br&gt;
  Modelにも実装してくれればいいのに。。
&lt;/p&gt;


&lt;p&gt;
  Modelにもカスタムバリデーション用のcleanメソッドがありますけども、あすこでValidationErrorを投げるとどんな設定してもNON_FIELD_ERRORSのエラーになってしまいます。&lt;br&gt;
  こりゃー使いづらいぜーという事なのでFormクラスと似たような事が出来るようにMixinを使って実装をしてみました。&lt;br&gt;
  と言ってもDjangoのソースパクって数行追加するだけですけども。
&lt;/p&gt;

&lt;pre class=&quot;brush: python&quot;&gt;#-*-coding=utf8-*-

from django.core.exceptions import ValidationError

class CleanFieldModelMixin(object):
  &quot;&quot;&quot;clean_[field_name]メソッドが使えるようになります。&quot;&quot;&quot;
  
  def clean_fields(self, exclude=None):
    if exclude is None: exclude = []

    errors = {}
    for f in self._meta.fields:
      if f.name in exclude: continue

      raw_value = getattr(self, f.attname)
      if f.blank and raw_value in validators.EMPTY_VALUES: continue
      
      try:
        setattr(self, f.attname, f.clean(raw_value, self))
        if hasattr(self, &#39;clean_%s&#39; % f.name):
          value = getattr(self, &#39;clean_%s&#39; % f.name)()
          setattr(self, f.attname, value)
      except ValidationError, e:
        errors[f.name] = e.messages

    if errors:
      raise ValidationError(errors)
&lt;/pre&gt;

&lt;p&gt;んで、実際の使い方はこんな感じ&lt;/p&gt;

&lt;pre class=&quot;brush: python&quot;&gt;#-*-coding=utf8-*-

from django.db import models
from django.core.exceptions import ValidationError
from utils.models import CleanFieldModelMixin # 適当にして下さいな。

# MixinクラスはModelクラスより先に書いてくださいね！
class User(CleanFieldModelMixin, models.Model):
  name = models.CharField(&#39;name&#39;, max_length=60)
  
  def clean_name(self):
    count = User.objects.filter(name=self.name).count()
    if count &gt; 0:
      raise ValidationError(&#39;%s is already exists.&#39; % self.name)
&lt;/pre&gt;

&lt;p&gt;
  これで動く。&lt;br&gt;
  多分動く。。  
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/7686910054880370884/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2012/01/pythonmodelcleanfieldnamedjango.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7686910054880370884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/7686910054880370884'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2012/01/pythonmodelcleanfieldnamedjango.html' title='【Python】Modelクラスでclean_[field_name]メソッドを使う【Django】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-8949724311810079204</id><published>2011-12-21T16:55:00.001+09:00</published><updated>2011-12-21T16:55:19.925+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【python】str(u&quot;unicode文字列&quot;)をUTF-8にする方法【エンコーディング】</title><content type='html'>unicode文字列をstr()で変換する場合、デフォルトだとasciiで変換しようとするので困る。&lt;br /&gt;
これをUTF-8に変更するには、Pythonのデフォルトエンコーディングを指定してやれば良いみたい。&lt;br /&gt;
&lt;br /&gt;
以下の内容を、&quot;site-packages&quot;配下に&quot;sitecustomize.py&quot;という名前で保存。&lt;br /&gt;
&lt;br /&gt;
Mac OS 10.7だと&quot;/Library/Python/2.6/site-packages/sitecustomize.py&quot;な感じ。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: python&quot;&gt;import sys
sys.setdefaultencoding(&quot;utf-8&quot;)
&lt;/pre&gt;
&lt;br /&gt;
これでおｋ</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/8949724311810079204/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/12/pythonstruunicodeutf-8.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8949724311810079204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8949724311810079204'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/12/pythonstruunicodeutf-8.html' title='【python】str(u&quot;unicode文字列&quot;)をUTF-8にする方法【エンコーディング】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-3606624860726659117</id><published>2011-11-21T15:31:00.001+09:00</published><updated>2011-11-21T15:41:20.165+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【python】Snow leopardにcythonをpipでインストール【mac osx】</title><content type='html'>やろうと思ったらコケました。。&lt;br /&gt;
&lt;br /&gt;
以下のようやったらイケましたよ。&lt;br /&gt;
easy_installの場合も多分一緒。&lt;br /&gt;
&lt;br /&gt;

&lt;pre&gt;
% sudo su -
% env ARCHFLAGS=&quot;-arch i386 -arch x86_64&quot; pip install cython
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/3606624860726659117/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/11/pythonsnow-leopardcythonpipmac-osx.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/3606624860726659117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/3606624860726659117'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/11/pythonsnow-leopardcythonpipmac-osx.html' title='【python】Snow leopardにcythonをpipでインストール【mac osx】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-6384906384473045452</id><published>2011-11-14T18:57:00.001+09:00</published><updated>2011-11-21T15:46:21.896+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Django"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="Mootools"/><title type='text'>【Django】DynamicにFormsetを生成するJavaScriptのライブラリを作ったよ【Mootools】</title><content type='html'>&lt;br /&gt;
DjangoのFormsetを動的に増やしたり削除したり並び替えたりしたかったんです。。&lt;br /&gt;
&lt;br /&gt;
調べたとろこjQueryにしかそういうライブラリがなかったので、Mootools好きな私と致しましては居ても立ってもいられず、こうしてライブラリを作成した次第でありますです。&lt;br /&gt;
&lt;br /&gt;
って事で、内容に関する説明は面倒なのでしませんｗ&lt;br /&gt;
みんな頑張っていじくって使い方模索してね！&lt;br /&gt;
気が向いたらドキュメント書きますー。&lt;br /&gt;
&lt;br /&gt;
[Django Dynamic Formset with Mootools]&lt;br /&gt;
&lt;a href=&quot;https://bitbucket.org/odoku/django-dynamic-formset-with-mootools/&quot;&gt;https://bitbucket.org/odoku/django-dynamic-formset-with-mootools/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
あ、一応動くと思うけど例に漏れずあんまりテストしてないのでお気をつけを。。&lt;br /&gt;
&lt;br /&gt;
[ScreenShots]&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/AVvXsEh8KI7CpE8oryX_di6FORuCzvbHFPv87ievpdfKT0f_gHqUDRr6B8sOKHhGDX27LcbowG0oWi0l6iAuPSvebMQaLzS599Cxq_a8AvKyPbYZdxcXXkxbeLyxq_GPLOYepQYkAA9Jvvmkysku/s1600/ddfsbm001.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;195&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8KI7CpE8oryX_di6FORuCzvbHFPv87ievpdfKT0f_gHqUDRr6B8sOKHhGDX27LcbowG0oWi0l6iAuPSvebMQaLzS599Cxq_a8AvKyPbYZdxcXXkxbeLyxq_GPLOYepQYkAA9Jvvmkysku/s320/ddfsbm001.png&quot; width=&quot;320&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;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVnlRnk87GDb9sW_9ujLZaskwvKZEU5W9rsxar6Jqv4VzQk5y0rnWTkaFYy5oSS2pisb7OW1P1D0qStyQRdtfP27G3nERJxxhdRNgzz5NQz5KoZs9x4zYwdeuK8T2woe0fnH8tO3O_uMT2/s1600/ddfsbm002.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;286&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVnlRnk87GDb9sW_9ujLZaskwvKZEU5W9rsxar6Jqv4VzQk5y0rnWTkaFYy5oSS2pisb7OW1P1D0qStyQRdtfP27G3nERJxxhdRNgzz5NQz5KoZs9x4zYwdeuK8T2woe0fnH8tO3O_uMT2/s320/ddfsbm002.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/6384906384473045452/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/11/djangoformsetjavascriptmootools.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/6384906384473045452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/6384906384473045452'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/11/djangoformsetjavascriptmootools.html' title='【Django】DynamicにFormsetを生成するJavaScriptのライブラリを作ったよ【Mootools】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8KI7CpE8oryX_di6FORuCzvbHFPv87ievpdfKT0f_gHqUDRr6B8sOKHhGDX27LcbowG0oWi0l6iAuPSvebMQaLzS599Cxq_a8AvKyPbYZdxcXXkxbeLyxq_GPLOYepQYkAA9Jvvmkysku/s72-c/ddfsbm001.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-800299766024946328</id><published>2011-11-10T12:05:00.001+09:00</published><updated>2011-11-21T15:40:35.067+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="Mootools"/><title type='text'>【JavaScript】時間と秒の相互変換【Mootools】</title><content type='html'>Mootools大好きっ子(jQuery大嫌いっ子)の僕だよ！&lt;br /&gt;
&lt;br /&gt;
JSってなんか時間まわりの使い勝手がイマイチな気がするのです。&lt;br /&gt;
PHPが使いやすいってだけなのかもしれませんけども。。&lt;br /&gt;
&lt;br /&gt;
という訳でお題の通り「時間と秒の相互変換」を行う関数を書きました。&lt;br /&gt;
普通に関数書くのじゃつまらないので、StringクラスとNumberクラスに盛り込んでみましたとさ。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;Number.implement({
    secToTime: function(hour) {
        if (arguments.length == 0) hour = true;
        
        var sec = this.toFloat();
        
        if (hour) {
            var hours = (&quot;0&quot; + Math.floor(sec / 3600).toString()).slice(-2);
            var minutes = (&quot;0&quot; + Math.floor(sec % 3600 / 60).toString()).slice(-2);
            var seconds = (&quot;0&quot; + Math.floor(sec % 60).toString()).slice(-2);
            return hours + &#39;:&#39; + minutes + &#39;:&#39; + seconds;
        } else {
            var minutes = (&quot;0&quot; + Math.floor(sec / 60).toString()).slice(-2);
            var seconds = (&quot;0&quot; + Math.floor(sec % 60).toString()).slice(-2);
            return minutes + &#39;:&#39; + seconds;
        }
    }
})

String.implement({
    timeToSec: function() {
        var regexp = /^(?:(?:(\d+):)?(\d+):)?(\d+)$/;
        var timeString = this.toString();
        var matches = timeString.match(regexp);
        if (matches == null) return false;
        
        var sec = 0;
        if (matches[1]) sec += matches[1].toInt() * 3600;
        if (matches[2]) sec += matches[2].toInt() * 60;
        sec += matches[3].toInt();
        
        return sec;
    },
    secToTime: function(hour) {
        if (arguments.length == 0) hour = true;
        var sec = this.toInt();
        return sec.secToTime(hour);
    }
})

var sec1 =       &#39;60&#39;.timeToSec();
var sec2 =    &#39;30:00&#39;.timeToSec();
var sec3 = &#39;01:00:00&#39;.timeToSec();

console.log(sec1); // 60
console.log(sec2); // 1800
console.log(sec3); // 3600

var time1 = sec1.secToTime();
var time2 = sec2.secToTime();
var time3 = sec3.secToTime();

console.log(time1); // 00:01:00
console.log(time2); // 00:30:00
console.log(time3); // 01:00:00

time1 = sec1.secToTime(false);
time2 = sec2.secToTime(false);
time3 = sec3.secToTime(false);

console.log(time1); // 01:00
console.log(time2); // 30:00
console.log(time3); // 60:00
&lt;/pre&gt;&lt;br /&gt;
あんまりテストしてないけど、多分大丈夫◎</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/800299766024946328/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/11/javascript-mootools.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/800299766024946328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/800299766024946328'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/11/javascript-mootools.html' title='【JavaScript】時間と秒の相互変換【Mootools】'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-3636565880822578073</id><published>2011-08-11T17:38:00.000+09:00</published><updated>2011-08-11T17:39:16.309+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【Python】プロパティに対して動的にアクセスする方法</title><content type='html'>&lt;br /&gt;
&lt;p&gt;まだまだPythonはぺーぺー極まり無いのでメモメモ。。&lt;/p&gt;&lt;p&gt;    お代の通り、インスタンス変数等に文字列を使って動的に値を取得する方法で御座います。&lt;br /&gt;
    getattrっていう関数を使うらしいよ。&lt;br /&gt;
&lt;/p&gt;&lt;blockquote&gt;getattr (object, name[, default])&lt;br /&gt;
&lt;br /&gt;
指定された object の属性を返します。name は文字列で なくてはなりません。文字列がオブジェクトの属性名の一つであった 場合、戻り値はその属性の値になります。例えば、 getattr(x, &#39;foobar&#39;) は x.foobar と等価です。 指定された属性が存在しない場合、default が与えられている 場合にはしれが返されます。そうでない場合には AttributeError が送出されます。&lt;br /&gt;
&lt;/blockquote&gt;&lt;p&gt;サンプルソース&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;class Hoge:
    piyo = 10

instance = Hoge()
print getattr(instance, &#39;piyo&#39;)
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;ちなみに、逆に値をセットする場合はsetattrってのを使うそうです。&lt;/p&gt;&lt;blockquote&gt;setattr (object, name, value)&lt;br /&gt;
&lt;br /&gt;
getattr() と対をなす関数です。引数はそれぞれオブジェクト、 文字列、そして任意の値です。文字列はすでに存在する属性の名前でも、 新たな属性の名前でもかまいません。この関数は指定した値を指定した属性に 関連付けますが、指定したオブジェクトにおいて可能な場合に限ります。 例えば、setattr(x, &#39;foobar&#39;, 123) は x.foobar = 123 と等価です。&lt;br /&gt;
&lt;/blockquote&gt;&lt;p&gt;サンプルソース&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;class Hoge:
    piyo = 10

instance = Hoge()
setattr(instance, &#39;piyo&#39;, 200000)

print instance.piyo
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/3636565880822578073/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/08/python.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/3636565880822578073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/3636565880822578073'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/08/python.html' title='【Python】プロパティに対して動的にアクセスする方法'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-8583932850578791930</id><published>2011-08-10T18:01:00.005+09:00</published><updated>2011-08-11T17:39:03.641+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>【Python】datetimeでタイムゾーンをUTCに変換する方法</title><content type='html'>&lt;p&gt;なんか毎回調べてる気がするので覚え書きとして残しておく。。&lt;/p&gt;&lt;p&gt;	タイムゾーンの変換を行うときにはpython-dateutilを使うと便利だとの事。&lt;br /&gt;
ダウンロードとリファレンスは以下の所です。&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;	&lt;a href=&quot;http://niemeyer.net/python-dateutil&quot; target=&quot;_blank&quot;&gt;python-dateutil - Labi&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;	あ、pipとかeasy_installでも入るみたい&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;sudo pip install python-dateutil&lt;/pre&gt;&lt;p&gt;	サンプルソースを載せておきますねー。&lt;br /&gt;
&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;#!/usr/bin/python
# -*- coding: utf-8 -*-

import datetime
import dateutil.tz

# 日本時間 2011年08月10日 16時00分00秒 を指定
date = datetime.datetime(2011, 8, 10, 16, 0, 0, 0, dateutil.tz.gettz(&#39;Asia/Tokyo&#39;))
print date

# UTC表記に変換
date = date.astimezone(dateutil.tz.tzutc())
print date
&lt;/pre&gt;&lt;p&gt;これでばっちり。&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/8583932850578791930/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/08/pythondatetimeutc.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8583932850578791930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8583932850578791930'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/08/pythondatetimeutc.html' title='【Python】datetimeでタイムゾーンをUTCに変換する方法'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5989192249356951690.post-8563926495359328335</id><published>2011-08-10T11:05:00.002+09:00</published><updated>2011-08-11T11:51:45.516+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium"/><title type='text'>Jenkins + Selenium + Django でテスト自動化のための環境構築</title><content type='html'>&lt;br /&gt;
&lt;p&gt;Jenkins + Seleniumを使ってリポジトリにコードをプッシュした際に、テストもやっちまいましょうよーってお誘いが来たので手順メモとして書いておく。&lt;/p&gt;&lt;h3&gt;環境&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;ubuntu10.04&lt;/li&gt;
&lt;li&gt;python2.6&lt;/li&gt;
&lt;li&gt;django1.3&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;必要なモノ&lt;/h3&gt;&lt;h4&gt;サーバー&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;selenium-server-standalone.jar&lt;/li&gt;
&lt;li&gt;jenkins.jar&lt;/li&gt;
&lt;/ul&gt;&lt;h4&gt;アプリケーション&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;Xvfb（仮想フレームバッファ）&lt;/li&gt;
&lt;li&gt;Firefox&lt;/li&gt;
&lt;/ul&gt;&lt;h4&gt;Pythonライブラリ&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;selenium&lt;/li&gt;
&lt;li&gt;unittest-xml-reporting&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;手順&lt;/h3&gt;&lt;h4&gt;1, Ubuntu Serverにて、FireFoxを仮想フレームバッファで動かす&lt;/h4&gt;&lt;p&gt;	GUI環境のある場所でやる人はやらなくても良い部分。&lt;br /&gt;
	Xvfbという仮想フレームバッファを使ってCUIでもFirefoxを動かせるようにしようぜってものだと思う。&lt;br /&gt;
&lt;/p&gt;&lt;h5&gt;インストール&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;sudo apt-get install xvfb
sudo apt-get install firefox	
&lt;/pre&gt;&lt;h5&gt;環境変数の指定&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;export DISPLAY=:1.0&lt;/pre&gt;&lt;h5&gt;起動&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;Xvfb :1 -screen 0 1024x768x24 &gt; /dev/null &amp;&lt;/pre&gt;&lt;br /&gt;
&lt;h4&gt;2, Selenium Serverを動かす&lt;/h4&gt;&lt;h5&gt;ダウンロード&lt;/h5&gt;&lt;p&gt;&lt;a href=&quot;http://seleniumhq.org/download/&quot; target=&quot;_blank&quot;&gt;http://seleniumhq.org/download/&lt;/a&gt;&lt;/p&gt;&lt;h5&gt;起動&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;java -jar selenium-server-standalone.jar &gt; /tmp/selenium.log 2&gt;&amp;1 &amp;&lt;/pre&gt;&lt;br /&gt;
&lt;h4&gt;3, djangoに必要なライブラリを入れる&lt;/h4&gt;&lt;p&gt;seleniumを使ったテストの書き方は多分説明してるサイトが沢山あるので割愛。。&lt;/p&gt;&lt;h5&gt;インストール&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;sudo pip install selenium
sudo pip install unittest-xml-reporting
&lt;/pre&gt;&lt;h5&gt;settings.py の編集&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;# 追加
TEST_RUNNER = &#39;xmlrunner.extra.djangotestrunner.XMLTestRunner&#39;
TEST_OUTPUT_VERBOSE = True
TEST_OUTPUT_DESCRIPTIONS = True
TEST_OUTPUT_DIR = &#39;xmlrunner&#39;
&lt;/pre&gt;&lt;br /&gt;
&lt;h4&gt;4, Jenkins を動かす&lt;/h4&gt;&lt;h5&gt;ダウンロード&lt;/h5&gt;&lt;p&gt;&lt;a href=&quot;http://jenkins-ci.org/&quot; target=&quot;_blank&quot;&gt;http://jenkins-ci.org/&lt;/a&gt;&lt;/p&gt;&lt;h5&gt;起動&lt;/h5&gt;&lt;pre class=&quot;brush: python&quot;&gt;java -jar jenkins.jar&lt;/pre&gt;&lt;h5&gt;プラグインの導入&lt;/h5&gt;&lt;p&gt;TOP &gt; Jenkinsの管理 &gt; プラグインの管理 &gt; 利用可能 &gt; Jenkins Mercurial pluginにチェック &gt; インストール&lt;/p&gt;&lt;h5&gt;設定&lt;/h5&gt;&lt;p&gt;	新規ジョブ作成&lt;br /&gt;
	フリースタイルプロジェクトのビルド&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;	ソースコード管理システム &gt; Mercurial&lt;br /&gt;
	リポジトリブラウザ &gt; Bitbucket&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;ビルドトリガ &gt; 定期的に実行（1時間毎に実行する様に設定）&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;* */1 * * *&lt;/pre&gt;&lt;p&gt;ビルド手順の追加 &gt; シェルの実行&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;python manage.py test&lt;/pre&gt;&lt;p&gt;ビルド後の処理 &gt; JUnitテスト結果の集計にチェック&lt;/p&gt;&lt;pre class=&quot;brush: python&quot;&gt;xmlrunner/*.xml&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;	これで多分動くはず。。&lt;br /&gt;
	思い出しながら書いたので間違ってる箇所もあるかも知れないので、飽くまで参考程度に。。&lt;br /&gt;
	あとはBitbucketにpushしたらビルドが走る様にすれば完璧ですなー。&lt;br /&gt;
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://odokuchang.blogspot.com/feeds/8563926495359328335/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://odokuchang.blogspot.com/2011/08/jenkins-selenium-django.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8563926495359328335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5989192249356951690/posts/default/8563926495359328335'/><link rel='alternate' type='text/html' href='http://odokuchang.blogspot.com/2011/08/jenkins-selenium-django.html' title='Jenkins + Selenium + Django でテスト自動化のための環境構築'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09331728859750901713</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>