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

<channel>
	<title>せつないぶろぐ</title>
	<atom:link href="http://blog.setunai.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.setunai.net</link>
	<description>ソフトウェア開発、アジャイルなどについてＳＥ兼ＰＧが思った事を書いてます。たまにプログラムも</description>
	<lastBuildDate>Thu, 05 Apr 2012 12:06:25 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>TypeError: sequence item 0: expected string, int found</title>
		<link>http://blog.setunai.net/20120405/typeerror-sequence-item-0-expected-string-int-found/</link>
		<comments>http://blog.setunai.net/20120405/typeerror-sequence-item-0-expected-string-int-found/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 11:54:35 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=773</guid>
		<description><![CDATA[Pythonで配列に数値が入っている時にjoinするとエラーになるってお話。 Python触り始めて半年くらいになるけど、まだたまにやっちゃうので記事にすることにした。 これで忘れないだろう。 配列を/区切りの文字列に変 [...]]]></description>
			<content:encoded><![CDATA[<p>Pythonで配列に数値が入っている時にjoinするとエラーになるってお話。<br />
Python触り始めて半年くらいになるけど、まだたまにやっちゃうので記事にすることにした。<br />
これで忘れないだろう。</p>
<p>配列を/区切りの文字列に変換</p>
<pre class="prettyprint lang-py">
arr = [1, 2, 3, 4, 5]
print '/'.join(arr)
</pre>
<pre class="console">
TypeError: sequence item 0: expected string, int found
</pre>
<p>中身が数値なのでエラーになる。</p>
<p>ちなみにPythonに馴染みがない人の為に言っておくがjoinは文字列のメソッドです。</p>
<p>１度数値を文字列に変換する</p>
<pre class="prettyprint lang-py">
arr = [1, 2, 3, 4, 5]
arr = [str(i) for i in arr]
print '/'.join(arr)
</pre>
<pre class="console">
1/2/3/4/5
</pre>
<p>これでok。もうちょっとシンプルなやり方はないのかな？知ってる人いたら教えて下さい。</p>
<p>ちなみにrubyでは</p>
<pre class="prettyprint lang-rb">
arr = [1, 2, 3, 4, 5]
print arr.join('/')
</pre>
<pre class="console">
1/2/3/4/5
</pre>
<p>エラーにはならない。</p>
<p>そしてPHP</p>
<pre class="prettyprint lang-php">
$arr = array(1, 2, 3, 4, 5);
print join('/', $arr);
</pre>
<pre class="console">
1/2/3/4/5
</pre>
<p>こちらもエラーにならない。</p>
<p>思想の違いなんだろうな。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120405/typeerror-sequence-item-0-expected-string-int-found/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VirtualBoxでゲストOSを直接起動する方法</title>
		<link>http://blog.setunai.net/20120329/virtualbox%e3%81%a7%e3%82%b2%e3%82%b9%e3%83%88os%e3%82%92%e7%9b%b4%e6%8e%a5%e8%b5%b7%e5%8b%95%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/</link>
		<comments>http://blog.setunai.net/20120329/virtualbox%e3%81%a7%e3%82%b2%e3%82%b9%e3%83%88os%e3%82%92%e7%9b%b4%e6%8e%a5%e8%b5%b7%e5%8b%95%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 14:02:17 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=769</guid>
		<description><![CDATA[VirtualBoxを利用してるんですがVirtualBoxマネージャーからゲストOSをいちいち起動するのと手間なので調べてみた。 ホスト：Win7 ゲスト：Ubuntu 10.04 結果、-startvmオプションに自 [...]]]></description>
			<content:encoded><![CDATA[<p>VirtualBoxを利用してるんですがVirtualBoxマネージャーからゲストOSをいちいち起動するのと手間なので調べてみた。</p>
<p>ホスト：Win7<br />
ゲスト：Ubuntu 10.04</p>
<p>結果、-startvmオプションに自分で付けたゲストOSの名前を付ければok。</p>
<blockquote><p>
&quot;C:\Program Files\Oracle\VirtualBox\VirtualBox.exe&quot; -startvm ubuntu10
</p></blockquote>
<p>ubuntu10と書いてあるところがゲストOSの名前。<br />
コピペする時はは自分の環境に合わせてパスを変更して下さい。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120329/virtualbox%e3%81%a7%e3%82%b2%e3%82%b9%e3%83%88os%e3%82%92%e7%9b%b4%e6%8e%a5%e8%b5%b7%e5%8b%95%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScriptの実行順序について</title>
		<link>http://blog.setunai.net/20120317/javascript%e3%81%ae%e5%ae%9f%e8%a1%8c%e9%a0%86%e5%ba%8f%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/</link>
		<comments>http://blog.setunai.net/20120317/javascript%e3%81%ae%e5%ae%9f%e8%a1%8c%e9%a0%86%e5%ba%8f%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 05:55:43 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=763</guid>
		<description><![CDATA[createElement(&#8220;script&#8221;)で生成したjavascriptは実行順序が保証されませんよって話。 まあ知ってる人は知ってると思うのですが、知らない人はやってしまうかもしれないのでと [...]]]></description>
			<content:encoded><![CDATA[<p>createElement(&#8220;script&#8221;)で生成したjavascriptは実行順序が保証されませんよって話。<br />
まあ知ってる人は知ってると思うのですが、知らない人はやってしまうかもしれないのでとりあえず書いときます。</p>
<h3>scriptタグでの記述</h3>
<p>scriptタグでJavaScriptの読み込みを記述している場合に記述かれた順序で実行されます。<br />
<a href="http://labs.setunai.net/jsload/test1.html">http://labs.setunai.net/jsload/test1.html</a></p>
<p>test1.html</p>
<pre class="prettyprint">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    var _arr = [];
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;a.js.php&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;b.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;headタグにて読込&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>a.js.php</p>
<pre class="prettyprint lang-js">
&lt;?php
sleep(3);
?&gt;
_arr.push('a');
</pre>
<p>b.js</p>
<pre class="prettyprint lang-js">
_arr.push('b');
</pre>
<p>a.js.phpは3秒だけ遅延してjsのコードを出力します。</p>
<p>画面が表示されたら_arrの中を確認します。<br />
chromeならデベロッパーツールのConsole、FirefoxならFirebug、IEなら開発者ツールのスクリプト＞コンソールで中身が確認できます。</p>
<p><a href="http://blog.setunai.net/wp-content/uploads/2012/03/jsload_test1.png"><img src="http://blog.setunai.net/wp-content/uploads/2012/03/jsload_test1.png" alt="" title="jsload_test1" width="315" height="198" class="alignnone size-full wp-image-764" /></a></p>
<p>a.js.phpの3秒遅延もちゃんと待ってくれて、記述された通りに実行され["a", "b"]となります。<br />
ちなみに読み込み自体はb.jsの方が先に終わってます。実行がまだなだけです。</p>
<h3>createElement(&#8220;script&#8221;)での記述</h3>
<p>createElement(&#8220;script&#8221;)での場合には読み込まが完了した順序で実行されます。<br />
<a href="http://labs.setunai.net/jsload/test2.html">http://labs.setunai.net/jsload/test2.html</a></p>
<p>test2.html</p>
<pre class="prettyprint">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    var _arr = [];

    var s_a = document.createElement(&quot;script&quot;);
    s_a.src = &quot;a.js.php&quot;;
    document.getElementsByTagName(&quot;head&quot;)[0].appendChild(s_a);

    var s_b = document.createElement(&quot;script&quot;);
    s_b.src = &quot;b.js&quot;;
    document.getElementsByTagName(&quot;head&quot;)[0].appendChild(s_b);
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;jsで動的読込&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>a.js.phpとb.jsは同じ物を利用しています。</p>
<p>結果はこちら<br />
<a href="http://blog.setunai.net/wp-content/uploads/2012/03/jsload_test2.png"><img src="http://blog.setunai.net/wp-content/uploads/2012/03/jsload_test2.png" alt="" title="jsload_test2" width="252" height="197" class="alignnone size-full wp-image-765" /></a></p>
<p>a.js.phpは先に読み込み処理が発生しますが3秒待ってしまうので後から読み込み処理が発生したb.jsの方が先に読み込みを完了します。<br />
ですので上記の通り["b", "a"]となります。</p>
<p>各ブラウザで確認しましたが、どれも同じ結果となりました。<br />
知らなかった人は気をつけましょう。</p>
<p>※検証ブラウザ<br />
chrome 17.0.963.79<br />
Firefox 11.0<br />
IE 8.0</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120317/javascript%e3%81%ae%e5%ae%9f%e8%a1%8c%e9%a0%86%e5%ba%8f%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQueryでformの値をajax向け配列に変換</title>
		<link>http://blog.setunai.net/20120305/jquery%e3%81%a7form%e3%81%ae%e5%80%a4%e3%82%92ajax%e5%90%91%e3%81%91%e9%85%8d%e5%88%97%e3%81%ab%e5%a4%89%e6%8f%9b/</link>
		<comments>http://blog.setunai.net/20120305/jquery%e3%81%a7form%e3%81%ae%e5%80%a4%e3%82%92ajax%e5%90%91%e3%81%91%e9%85%8d%e5%88%97%e3%81%ab%e5%a4%89%e6%8f%9b/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 14:13:24 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=745</guid>
		<description><![CDATA[jQuery.getJSONやjQuery.postを利用するのですが引数のdata部分を作成するのがどうもやぼったい。 そう思いつつも、そこまで問題でもないのでデータ部分の配列を自力で作って利用していたのですが、今日リ [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery.getJSONやjQuery.postを利用するのですが引数のdata部分を作成するのがどうもやぼったい。<br />
そう思いつつも、そこまで問題でもないのでデータ部分の配列を自力で作って利用していたのですが、今日リファレンスを眺めていたら見つけました。</p>
<p>今更感もありますが、私と同じく知らない人はどうぞ。<br />
<a href="http://api.jquery.com/serializeArray/">.serializeArray() &#8211; jQuery API</a></p>
<p>form内のelementをajax向け配列に変換してくれます。（たぶんform内じゃなくてもいいと思う）</p>
<pre class="prettyprint lang-html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;serializeArray/jquery test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id=&quot;test_form&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;namae&quot; style=&quot;width:100px;&quot; value=&quot;123&quot;&gt;&lt;br&gt;
&lt;input type=&quot;radio&quot; name=&quot;blood&quot; value=&quot;b_a&quot;&gt;A
&lt;input type=&quot;radio&quot; name=&quot;blood&quot; value=&quot;b_b&quot;&gt;B
&lt;input type=&quot;radio&quot; name=&quot;blood&quot; value=&quot;b_ab&quot; checked&gt;AB
&lt;input type=&quot;radio&quot; name=&quot;blood&quot; value=&quot;b_o&quot;&gt;O&lt;br&gt;
&lt;input type=&quot;hidden&quot; name=&quot;key&quot; value=&quot;hoge&quot;&gt;
&lt;input type=&quot;button&quot; id=&quot;run&quot; value=&quot;test&quot;&gt;
&lt;/form&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
(function ($) {

$('#run').click(function (){
    var arr = $('#test_form :input');
    console.log(arr.serializeArray());
    console.log(arr.serialize());
});

})(jQuery);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>結果</p>
<pre class="console">
[ Object { name="namae", value="123" }, Object { name="blood", value="b_ab" }, Object { name="key", value="hoge" } ]
namae=123&#038;blood=b_ab&#038;key=hoge
</pre>
<p><a href="http://api.jquery.com/serialize/">.serialize() &#8211; jQuery API</a>も見つけたので試してみました。</p>
<p>.serializeArray()の結果をそのままjQuery.getJSONで利用できるのでとても便利ですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120305/jquery%e3%81%a7form%e3%81%ae%e5%80%a4%e3%82%92ajax%e5%90%91%e3%81%91%e9%85%8d%e5%88%97%e3%81%ab%e5%a4%89%e6%8f%9b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>クロスドメインへのアクセスが回避できるXMLHttpRequest2</title>
		<link>http://blog.setunai.net/20120229/%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%b8%e3%81%ae%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%8c%e5%9b%9e%e9%81%bf%e3%81%a7%e3%81%8d%e3%82%8bxmlhttprequest2/</link>
		<comments>http://blog.setunai.net/20120229/%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%b8%e3%81%ae%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%8c%e5%9b%9e%e9%81%bf%e3%81%a7%e3%81%8d%e3%82%8bxmlhttprequest2/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 15:13:26 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=743</guid>
		<description><![CDATA[最近クロスドメインの記事を書きました。 jQueryでクロスドメインのjson取得(JSONP) が、もっと良い手がありました。 HTTP access control &#8211; MDN 404 Blog Not  [...]]]></description>
			<content:encoded><![CDATA[<p>最近クロスドメインの記事を書きました。<br />
<a href="http://blog.setunai.net/20120226/jquery%E3%81%A7%E3%82%AF%E3%83%AD%E3%82%B9%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3%E3%81%AEjson%E5%8F%96%E5%BE%97jsonp/">jQueryでクロスドメインのjson取得(JSONP)</a></p>
<p>が、もっと良い手がありました。</p>
<p><a href="https://developer.mozilla.org/En/HTTP_Access_Control">HTTP access control &#8211; MDN</a><br />
<a href="http://blog.livedoor.jp/dankogai/archives/51502865.html">404 Blog Not Found:Ajax &#8211; Goodbye, JSONP.  Hello, Access-Control-Allow-Origin</a></p>
<p>小飼弾さんの記事を見ると2年前ですね。知らなかった。</p>
<p>XMLHttpRequest2(XHR2)ではサーバー側がAccess-Control-Allow-Originヘッダーを設定していればクロスドメインの制限を回避できるようです。</p>
<pre class="prettyprint lang-html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;XHR2/jquery test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type=&quot;text&quot; id=&quot;zip&quot; style=&quot;width:100px;&quot; value=&quot;2210824&quot;&gt;
&lt;input type=&quot;button&quot; id=&quot;run&quot; value=&quot;test&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
(function ($) {

var api = 'http://api.aoikujira.com/zip/json/';

$('#run').click(function (){
    var zip = $('#zip').val();
    var url = api + zip;
    $.getJSON(url).then(
        function (json){
            alert(json.address);
        },
        function (){
            alert('error dayo');
        }
    );
});

})(jQuery);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>これで自分で提供するAPIならクロスドメインも気にしなくてよさそうです。<br />
各apiはcallbackを用意するよりAccess-Control-Allow-Originヘッダーを指定した方が助かりますね。</p>
<p>これでめでたしめでたしと思ったらブラウザ毎に挙動の違いがあるみたいです。<br />
<a href="http://hisasann.com/housetect/2010/11/xmlhttprequest_level2.html">XMLHttpRequest level2に対応しているブラウザまとめ at HouseTect, JavaScriptな情報をあなたに</a><br />
IE7が未対応なのは痛い。実サービスだと厳しいかもしれません。</p>
<p>一応自分のブラウザでも試してみました。<br />
○ chrome 17.0.963.56<br />
○ Firefox 10.0.2<br />
× IE 8.0.7601.17514<br />
あ、IE8でもダメだ。途中で変わったのか、私のIEだけなのかはわからないところ。う～</p>
<p>利用API<br />
<a href="http://api.aoikujira.com/zip/">クジラ　郵便番号　API</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120229/%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%b8%e3%81%ae%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%8c%e5%9b%9e%e9%81%bf%e3%81%a7%e3%81%8d%e3%82%8bxmlhttprequest2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flaskのログインデコレータ</title>
		<link>http://blog.setunai.net/20120227/flask%e3%81%ae%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%87%e3%82%b3%e3%83%ac%e3%83%bc%e3%82%bf/</link>
		<comments>http://blog.setunai.net/20120227/flask%e3%81%ae%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%87%e3%82%b3%e3%83%ac%e3%83%bc%e3%82%bf/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 14:56:05 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=740</guid>
		<description><![CDATA[最近Pythonのデコレータが理解できて、ログイン後のページ表示に使えるんじゃないかと思いついた。 Flaskを利用しているので、そこらへんを中心にググってみたらやはりありました。 pocooチームによるLogin Re [...]]]></description>
			<content:encoded><![CDATA[<p>最近Pythonのデコレータが理解できて、ログイン後のページ表示に使えるんじゃないかと思いついた。<br />
Flaskを利用しているので、そこらへんを中心にググってみたらやはりありました。</p>
<p>pocooチームによるLogin Required Decoratorの実装<br />
<a href="http://flask.pocoo.org/docs/patterns/viewdecorators/#login-required-decorator">Login Required Decorator</a></p>
<p>とりあえず上記を元に実際に組んでみます。</p>
<pre class="prettyprint lang-py">
from functools import wraps

from flask import Flask
app = Flask(__name__)

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if not is_login():
            return 'dame dayo!'
        return f(*args, **kwargs)
    return decorated_function

def is_login():
    return False

@app.route('/')
def root_page():
    return 'public!!'

@app.route('/mypage')
@login_required
def my_page():
    return 'private!!'

if __name__ == '__main__':
    app.run(host='192.168.56.10')
</pre>
<p>/にアクセス</p>
<blockquote><p>
public!!
</p></blockquote>
<p>/mypageにアクセス</p>
<blockquote><p>
dame dayo!
</p></blockquote>
<p>これで目的達成。<br />
functools.wrap()なんて初めて使った。<br />
今度はここらへんを調べてみよう。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120227/flask%e3%81%ae%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%87%e3%82%b3%e3%83%ac%e3%83%bc%e3%82%bf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQueryでクロスドメインのjson取得(JSONP)</title>
		<link>http://blog.setunai.net/20120226/jquery%e3%81%a7%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%aejson%e5%8f%96%e5%be%97jsonp/</link>
		<comments>http://blog.setunai.net/20120226/jquery%e3%81%a7%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%aejson%e5%8f%96%e5%be%97jsonp/#comments</comments>
		<pubDate>Sun, 26 Feb 2012 03:34:19 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=732</guid>
		<description><![CDATA[JSONP とは｜傲慢SE日記 ～30歳からの挑戦～ 上記記事を読んでいてjQueryでできそうな気がしたので調べてみました。 やっぱり対応していてテスト。 github:gist 簡単ですね。jquery内部でscri [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ameblo.jp/syou007/entry-11173719736.html">JSONP とは｜傲慢SE日記 ～30歳からの挑戦～</a><br />
上記記事を読んでいてjQueryでできそうな気がしたので調べてみました。<br />
やっぱり対応していてテスト。</p>
<p><script src="https://gist.github.com/1912532.js?file=gistfile1.html"></script><br />
<a href="https://gist.github.com/1912532">github:gist</a></p>
<p>簡単ですね。jquery内部でscriptタグを発行していると思いますが、自分で管理しなくていいので楽です。</p>
<p>関係ないけどgistも便利。でもブログ内にソースコードが残らないのでちょっと微妙だなー。</p>
<p>参考<br />
<a href="http://d.hatena.ne.jp/kanonji/20100427/1272372721">jQuery.getJSON()で別ドメインのJSONPなデータを読み込む時の注意 &#8211; kanonjiの日記</a></p>
<p>利用したAPI<br />
<a href="http://d.hatena.ne.jp/keyword/%a4%cf%a4%c6%a4%ca%a5%d6%a5%c3%a5%af%a5%de%a1%bc%a5%af%b7%ef%bf%f4%bc%e8%c6%c0API">はてなブックマーク件数取得API</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120226/jquery%e3%81%a7%e3%82%af%e3%83%ad%e3%82%b9%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e3%81%aejson%e5%8f%96%e5%be%97jsonp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLAlchemyのSAWarningメッセージ</title>
		<link>http://blog.setunai.net/20120221/sqlalchemy%e3%81%aesawarning%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8/</link>
		<comments>http://blog.setunai.net/20120221/sqlalchemy%e3%81%aesawarning%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 14:48:26 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=723</guid>
		<description><![CDATA[ログを眺めていたらSAWarningってメッセージが頻繁に出ていて何かと思ったら SQLAlchemyのメッセージでした。ちなみにSQLAlchemyはPythonで利用できるO/Rマッパーです。 メッセージを読むと配列 [...]]]></description>
			<content:encoded><![CDATA[<p>ログを眺めていたらSAWarningってメッセージが頻繁に出ていて何かと思ったら<br />
SQLAlchemyのメッセージでした。ちなみにSQLAlchemyはPythonで利用できるO/Rマッパーです。</p>
<p>メッセージを読むと配列が空だよとのことなので原因はわかりました。</p>
<pre class="console">
site-packages/sqlalchemy/sql/expression.py:1794: SAWarning: The IN-predicate on "users.id" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.  Consider alternative strategies for improved performance.
  return self._in_impl(operators.in_op, operators.notin_op, other)
</pre>
<p>例外は吐かずにパフォーマンスを気にしてるのがちょっと不思議な感じ。<br />
試しにどんなSQL文が出力されているか見てみます。</p>
<p>■usersテーブル<br />
(id, name, age)</p>
<p>■空ではない配列</p>
<pre class="code">
arr = [10, 20, 5]
tmp = User.query.filter(User.id.in_(arr)).all()
</pre>
<p>生成されたSQL文</p>
<pre class="console">
SELECT users.id AS users_id, users.name AS users_name, users.age AS users_age
FROM users
WHERE users.id IN (10, 20, 5)
</pre>
<p>■空の配列</p>
<pre class="code">
arr = []
tmp = User.query.filter(User.id.in_(arr)).all()
</pre>
<p>生成されたSQL文</p>
<pre class="console">
SELECT users.id AS users_id, users.name AS users_name, users.age AS users_age
FROM users
WHERE users.id != users.id
</pre>
<p>空の配列で生成されたSQLは条件に否定演算子が使われていますね。<br />
これは遅くなりそうです。</p>
<p>空の配列がきた場合に、正常な戻り値を目指して、この方法をとったんでしょうね。<br />
なのでin句に配列を渡す場合にはemptyチェックをお勧めします。</p>
<p>バージョン<br />
SQLAlchemy==0.7.2</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120221/sqlalchemy%e3%81%aesawarning%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pythonのバージョンを切り替えることができるpythonbrewをインストール</title>
		<link>http://blog.setunai.net/20120218/python%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b%e3%81%93%e3%81%a8%e3%81%8c%e3%81%a7%e3%81%8d%e3%82%8bpythonbrew%e3%82%92%e3%82%a4/</link>
		<comments>http://blog.setunai.net/20120218/python%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b%e3%81%93%e3%81%a8%e3%81%8c%e3%81%a7%e3%81%8d%e3%82%8bpythonbrew%e3%82%92%e3%82%a4/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 03:33:28 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[プログラム＆技術系]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=719</guid>
		<description><![CDATA[タイトルそのままですがpython利用しようかと手持ちの環境を調べたら バージョンが2.4.3（CentOS release 5.7） これは古過ぎなので最新版を入れたい。でもpythonはyumなどが利用してるので普通 [...]]]></description>
			<content:encoded><![CDATA[<p>タイトルそのままですがpython利用しようかと手持ちの環境を調べたら<br />
バージョンが2.4.3（CentOS release 5.7）</p>
<p>これは古過ぎなので最新版を入れたい。でもpythonはyumなどが利用してるので普通に入れ替えちゃうといろいろ影響がある。<br />
なので既存の環境を壊さないでなんとかならないかと探していたら見つけました。</p>
<p>pythonbrew<br />
<a href="https://github.com/utahta/pythonbrew" title="utahta/pythonbrew">https://github.com/utahta/pythonbrew</a></p>
<p>これでpythonのバージョンを簡単に切り替えて利用できそうです。</p>
<h3>pythonbrewのインストール</h3>
<p>githubにある通りにインストール</p>
<pre class="console">
$ curl -kL http://xrl.us/pythonbrewinstall | bash
</pre>
<p>~/.bashrcに下記を追加<br />
[[ -s $HOME/.pythonbrew/etc/bashrc ]] &#038;&#038; source $HOME/.pythonbrew/etc/bashrc</p>
<pre class="console">
$ pythonbrew version
1.1
</pre>
<p>で完了。</p>
<h3>python 2.7.2のインストール</h3>
<pre class="console">
$ pythonbrew install --force 2.7.2
Downloading Python-2.7.2.tgz as /home/[hoge]/.pythonbrew/dists/Python-2.7.2.tgz
######################################################################## 100.0%
Extracting Python-2.7.2.tgz into /home/[hoge]/.pythonbrew/build/Python-2.7.2

This could take a while. You can run the following command on another shell to track the status:
  tail -f /home/[hoge]/.pythonbrew/log/build.log

Installing Python-2.7.2 into /home/[hoge]/.pythonbrew/pythons/Python-2.7.2
Downloading distribute_setup.py as /home/[hoge]/.pythonbrew/dists/distribute_setup.py
######################################################################## 100.0%
Installing distribute into /home/[hoge]/.pythonbrew/pythons/Python-2.7.2
Installing pip into /home/[hoge]/.pythonbrew/pythons/Python-2.7.2

Installed Python-2.7.2 successfully. Run the following command to switch to Python-2.7.2.
  pythonbrew switch 2.7.2
</pre>
<p>すごく時間がかかるのでメッセージの通り、tailでbuild.logを参照した方が安心できます。<br />
別に時間が短くなる訳ではないですけど。</p>
<p>インストールできたので確認してみます。</p>
<pre class="console">
$ python -V
Python 2.4.3
$ pythonbrew switch 2.7.2
Switched to Python-2.7.2
$ python -V
Python 2.7.2
</pre>
<p>簡単ですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120218/python%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b%e3%81%93%e3%81%a8%e3%81%8c%e3%81%a7%e3%81%8d%e3%82%8bpythonbrew%e3%82%92%e3%82%a4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>デブサミ（Developers Summit）2012 感想</title>
		<link>http://blog.setunai.net/20120217/%e3%83%87%e3%83%96%e3%82%b5%e3%83%9f%ef%bc%88developers-summit%ef%bc%892012-%e6%84%9f%e6%83%b3/</link>
		<comments>http://blog.setunai.net/20120217/%e3%83%87%e3%83%96%e3%82%b5%e3%83%9f%ef%bc%88developers-summit%ef%bc%892012-%e6%84%9f%e6%83%b3/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 13:35:52 +0000</pubDate>
		<dc:creator>t</dc:creator>
				<category><![CDATA[日記]]></category>

		<guid isPermaLink="false">http://blog.setunai.net/?p=716</guid>
		<description><![CDATA[今回で10回目となるデブサミ。申込時には知らなくて開会の挨拶で知りました。 ブログを検索してみると2005年が最初の参加です。存在自体は2004年から知ってた様です。 当時デマルコが来日するとの事で、申し込もうとしたら既 [...]]]></description>
			<content:encoded><![CDATA[<p>今回で10回目となるデブサミ。申込時には知らなくて開会の挨拶で知りました。</p>
<p>ブログを検索してみると2005年が最初の参加です。存在自体は2004年から知ってた様です。<br />
当時デマルコが来日するとの事で、申し込もうとしたら既に満席。<br />
で、代わりにJaSST&#8217;04の方に申し込んだらなんとか参加できて感動したのを覚えています。</p>
<p>その後、2005年にダイレクトメールが来てデブサミ初参加となりました。<br />
2005年からなので7回参加ですね。<br />
この頃どんなセッションに参加したブログ読んでみたんですけど全然わからないｗ<br />
セッション名も書いてないし、ブログ移行したときに記事が消えてる部分もあるみたい。残念です。<br />
ペアプロのライブを見たって事は書かれてるんですけどね。</p>
<p>この頃書いたブログを読んでるとチームビルディングとアジャイルについていろいろ書かれているのできっとそれ関係のセッションに参加したのでしょう。</p>
<p>それから7年。私的には転職2回行なってSIer業界からWeb業界に来てました。<br />
これもデブサミを含めたカンファレンス系イベントに参加して、いろいろな人に熱意を貰った結果だと思います。</p>
<p>こういった無料で質の高いカンファレンスが継続されて、いろいろな人に影響与えてくれるといいなと思います。</p>
<p>あ、今回の感想じゃないな。まあいいや。</p>
<p>今回も楽しめましたし、刺激をたくさん頂きました。<br />
スタッフならび公演者の方々、ありがとうございました。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.setunai.net/20120217/%e3%83%87%e3%83%96%e3%82%b5%e3%83%9f%ef%bc%88developers-summit%ef%bc%892012-%e6%84%9f%e6%83%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.448 seconds -->
<!-- Cached page served by WP-Cache -->

