<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>zaru blog</title>
	<atom:link href="http://zaru.tofu-kun.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://zaru.tofu-kun.org</link>
	<description>Web系のこととかー。</description>
	<lastBuildDate>Fri, 18 Nov 2011 02:28:49 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/feed/" />
		<item>
		<title>TitaniumStudioでのコミットログが文字化けするのを修正する</title>
		<link>http://zaru.tofu-kun.org/2011/11/18/titaniumstudio%e3%81%a7%e3%81%ae%e3%82%b3%e3%83%9f%e3%83%83%e3%83%88%e3%83%ad%e3%82%b0%e3%81%8c%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%81%99%e3%82%8b%e3%81%ae%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%99/</link>
		<comments>http://zaru.tofu-kun.org/2011/11/18/titaniumstudio%e3%81%a7%e3%81%ae%e3%82%b3%e3%83%9f%e3%83%83%e3%83%88%e3%83%ad%e3%82%b0%e3%81%8c%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%81%99%e3%82%8b%e3%81%ae%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%99/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 02:28:49 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[プログラミング_Titanium]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=408</guid>
		<description><![CDATA[TitaniumStudio上で、gitコミットを行うとコミットログが文字化けして困っていたら、Eclipseベースだったのを思い出して、Eclipseと同じように設定すれば、文字コードがUTF-8で統一されて文字化けせずいけます。 /Applications/Titanium Studio/TitaniumStudio.app/Contents/MacOS/TitaniumStudio.ini -Dfile.encoding=utf-8 TitaniumStudio.appの「パッケージの内容を表示」を選択すれば、中の設定ファイルを見ることができます。]]></description>
			<content:encoded><![CDATA[<p>TitaniumStudio上で、gitコミットを行うとコミットログが文字化けして困っていたら、Eclipseベースだったのを思い出して、Eclipseと同じように設定すれば、文字コードがUTF-8で統一されて文字化けせずいけます。</p>
<h4>/Applications/Titanium Studio/TitaniumStudio.app/Contents/MacOS/TitaniumStudio.ini</h4>
<pre class="brush: bash; title: ;">
-Dfile.encoding=utf-8
</pre>
<p>TitaniumStudio.appの「パッケージの内容を表示」を選択すれば、中の設定ファイルを見ることができます。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=408&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/11/18/titaniumstudio%e3%81%a7%e3%81%ae%e3%82%b3%e3%83%9f%e3%83%83%e3%83%88%e3%83%ad%e3%82%b0%e3%81%8c%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%81%99%e3%82%8b%e3%81%ae%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/11/18/titaniumstudio%e3%81%a7%e3%81%ae%e3%82%b3%e3%83%9f%e3%83%83%e3%83%88%e3%83%ad%e3%82%b0%e3%81%8c%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%81%99%e3%82%8b%e3%81%ae%e3%82%92%e4%bf%ae%e6%ad%a3%e3%81%99/" />
	</item>
		<item>
		<title>iTunesConnectからアプリダウンロード数レポートを自動取得する方法</title>
		<link>http://zaru.tofu-kun.org/2011/11/08/itunesconnect%e3%81%8b%e3%82%89%e3%82%a2%e3%83%97%e3%83%aa%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e5%8f%96/</link>
		<comments>http://zaru.tofu-kun.org/2011/11/08/itunesconnect%e3%81%8b%e3%82%89%e3%82%a2%e3%83%97%e3%83%aa%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e5%8f%96/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 00:26:28 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[iPhoneアプリ開発]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=402</guid>
		<description><![CDATA[iTunesConnectからアプリダウンロード数レポートを取得する方法 iPhoneアプリのダウンロード数などは、iTunesConnect内のSales and Trendsからレポートを参照・ダウンロードできます。が、データを保持してくれる期間も短い上に、フィルタ機能が貧弱という、なんか使いにくいもの。 そこで、ダウンロードできるタブ区切りデータを毎日自動取得してみようというわけです。 最初は、PerlのMechanizeとか使って自動ログイン後、データを取得しようとしていたんですが、どうにも上手く行かず彷徨っていたら、普通にApple謹製の自動取得プログラムがありました。 iTunes Connect Sales and Trends Guide この中の Auto-Ingest Instructions という項目で説明があります。 JAVAプログラム http://www.apple.com/itunesnews/docs/Autoingestion.class.zip 使い方は、ガイドにある通り java Autoingestion &#60;username&#62; &#60;password&#62; &#60;vendorid&#62; &#60;report_type&#62; &#60;date_type&#62; &#60;report_subtype&#62; &#60;date_yyyymmdd&#62; です。 名前 値 備考 username iTunesConnectユーザID password iTunesConnectパスワード vendorid 8####### Sales and Trendsの右上にある8から始まる数字 report_type Sales 現在はこれだけ？ date_type Daily or Weekly 日別レポートか、週別レポートか。毎日ダウンロードするなら日別 report_subtype Summary or Opt-In 通常はSummary date [...]]]></description>
			<content:encoded><![CDATA[<h3>iTunesConnectからアプリダウンロード数レポートを取得する方法</h3>
<p>iPhoneアプリのダウンロード数などは、iTunesConnect内のSales and Trendsからレポートを参照・ダウンロードできます。が、データを保持してくれる期間も短い上に、フィルタ機能が貧弱という、なんか使いにくいもの。</p>
<p>そこで、ダウンロードできるタブ区切りデータを毎日自動取得してみようというわけです。</p>
<p>最初は、PerlのMechanizeとか使って自動ログイン後、データを取得しようとしていたんですが、どうにも上手く行かず彷徨っていたら、普通にApple謹製の自動取得プログラムがありました。</p>
<p><a href="http://www.apple.com/itunesnews/docs/AppStoreReportingInstructions.pdf" target="_blank">iTunes Connect Sales and Trends Guide</a></p>
<p>この中の Auto-Ingest Instructions という項目で説明があります。</p>
<h4>JAVAプログラム</h4>
<p><a href="http://www.apple.com/itunesnews/docs/Autoingestion.class.zip">http://www.apple.com/itunesnews/docs/Autoingestion.class.zip</a></p>
<p>使い方は、ガイドにある通り</p>
<pre class="brush: plain; title: ;">
java Autoingestion &lt;username&gt; &lt;password&gt; &lt;vendorid&gt; &lt;report_type&gt; &lt;date_type&gt; &lt;report_subtype&gt; &lt;date_yyyymmdd&gt;
</pre>
<p>です。</p>
<table>
<tr>
<th>名前</th>
<th>値</th>
<th>備考</th>
</tr>
<tr>
<td>username</td>
<td>iTunesConnectユーザID</td>
<td></td>
</tr>
<tr>
<td>password</td>
<td>iTunesConnectパスワード</td>
<td></td>
</tr>
<tr>
<td>vendorid</td>
<td>8#######</td>
<td>Sales and Trendsの右上にある8から始まる数字</td>
</tr>
<tr>
<td>report_type</td>
<td>Sales</td>
<td>現在はこれだけ？</td>
</tr>
<tr>
<td>date_type</td>
<td>Daily or Weekly</td>
<td>日別レポートか、週別レポートか。毎日ダウンロードするなら日別</td>
</tr>
<tr>
<td>report_subtype</td>
<td>Summary or Opt-In</td>
<td>通常はSummary</td>
</tr>
<tr>
<td>date</td>
<td>YYYYMMDD</td>
<td>指定をしないと最新の日付。</td>
</tr>
</table>
<p>これで</p>
<pre class="brush: plain; title: ;">
java Autoingestion hoge@example.com password 8100000 Sales Daily Summary 20111106
</pre>
<p>とすれば自動的にgzipなレポートが保存されます。</p>
<h3>レポートファイルをPHPで毎日自動取得</h3>
<p>あとはshとかperlとかでプログラムをcronで動かせば良いんですが、今回はPHPでやってみます。</p>
<pre class="brush: php; title: ;">
&lt;?php
$date = date('Ymd', strtotime('-2 day'));
$command = 'java -cp &quot;/home/zaru/itunes_report&quot; Autoingestion hoge@example.com password 8100000 Sales Daily Summary ' . $date;
exec($command,$result);
exec('gunzip ' . $result['0']);
$filename = str_replace('.gz','',$result['0']);
</pre>
<p>これで、$filenameにレポートテキストファイルが格納されます。</p>
<p>はまったのは、javaのパス指定の仕方。-cp &#8220;プログラムの置いてあるパス&#8221; と指定しないとエラーになります。後は、タブ区切りのデータから必要なものを抜き出してDBに入れるなりなんなりしてください。</p>
<h3>2011-11-09 追記：上記PHPプログラムだと、cronで正常に取得できません</h3>
<p>普通にコマンドラインで実行すると、正常に取得できるんですが、<strong>cronで実行すると環境変数の問題で正常にjavaを動かせません</strong>でした。なので、素直にshで実行するものを作りました。</p>
<h4>get.sh</h4>
<pre class="brush: bash; title: ;">
#!/bin/bash

#環境変数をセット
export PATH=/usr/kerberos/bin:/usr/java/default/bin:/usr/local/bin:/bin:/usr/bin:/home/zaru/bin
export JAVA_HOME=/usr/java/default

DIR=/home/zaru/itunes_report
GETDAY=`date +%Y%m%d -d '2 days ago'`

cd $DIR
RESULT=`java -cp &quot;$DIR&quot; Autoingestion hoge@example.com password 8100000 Sales Daily Summary $GETDAY`
arr=(`echo $RESULT`)
gunzip $DIR/${arr[0]}
php -f $DIR/import.php ${arr[0]/.gz/}
</pre>
<h4>import.php</h4>
<pre class="brush: php; title: ;">
&lt;?php
$dir = '/home/zaru/itunes_report';
if(file_exists($dir . $argv['1'])){
    echo $argv['1'] . &quot;¥n&quot;;
    $data = file($dir . $argv['1']);
    //ごにょごにょ
}
</pre>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=402&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/11/08/itunesconnect%e3%81%8b%e3%82%89%e3%82%a2%e3%83%97%e3%83%aa%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e5%8f%96/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/11/08/itunesconnect%e3%81%8b%e3%82%89%e3%82%a2%e3%83%97%e3%83%aa%e3%83%80%e3%82%a6%e3%83%b3%e3%83%ad%e3%83%bc%e3%83%89%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e5%8f%96/" />
	</item>
		<item>
		<title>TitaniumMobileで日本語アプリ名を使う方法</title>
		<link>http://zaru.tofu-kun.org/2011/11/04/titaniummobile%e3%81%a7%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a2%e3%83%97%e3%83%aa%e5%90%8d%e3%82%92%e4%bd%bf%e3%81%86%e6%96%b9%e6%b3%95/</link>
		<comments>http://zaru.tofu-kun.org/2011/11/04/titaniummobile%e3%81%a7%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a2%e3%83%97%e3%83%aa%e5%90%8d%e3%82%92%e4%bd%bf%e3%81%86%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 03:52:49 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[プログラミング_Titanium]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=399</guid>
		<description><![CDATA[TitaniumMobileで日本語アプリ名を使う方法 日本語のアプリ名を付けるにはどうすれば良いんだろうか？と思って色々と検索して試してみると、なんとか成功。 /Resources/iphone/InfoPlist.strings というファイルを作成し、そこに CFBundleDisplayName = &#34;ロケプラ&#34;; これでOK。 XCodeでごにょごにょしたけど、ビルドで失敗したけど、この方法ならいけた。]]></description>
			<content:encoded><![CDATA[<h3>TitaniumMobileで日本語アプリ名を使う方法</h3>
<p>日本語のアプリ名を付けるにはどうすれば良いんだろうか？と思って色々と検索して試してみると、なんとか成功。</p>
<p>/Resources/iphone/InfoPlist.strings</p>
<p>というファイルを作成し、そこに</p>
<pre class="brush: plain; title: ;">
CFBundleDisplayName = &quot;ロケプラ&quot;;
</pre>
<p>これでOK。</p>
<p>XCodeでごにょごにょしたけど、ビルドで失敗したけど、この方法ならいけた。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=399&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/11/04/titaniummobile%e3%81%a7%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a2%e3%83%97%e3%83%aa%e5%90%8d%e3%82%92%e4%bd%bf%e3%81%86%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/11/04/titaniummobile%e3%81%a7%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a2%e3%83%97%e3%83%aa%e5%90%8d%e3%82%92%e4%bd%bf%e3%81%86%e6%96%b9%e6%b3%95/" />
	</item>
		<item>
		<title>iPhoneでバーコードをスキャンしたい！Titanium MobileでZBarを使う方法</title>
		<link>http://zaru.tofu-kun.org/2011/08/11/iphone%e3%81%a7%e3%83%90%e3%83%bc%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e3%82%b9%e3%82%ad%e3%83%a3%e3%83%b3%e3%81%97%e3%81%9f%e3%81%84%ef%bc%81titanium-mobile%e3%81%a7zbar%e3%82%92%e4%bd%bf%e3%81%86/</link>
		<comments>http://zaru.tofu-kun.org/2011/08/11/iphone%e3%81%a7%e3%83%90%e3%83%bc%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e3%82%b9%e3%82%ad%e3%83%a3%e3%83%b3%e3%81%97%e3%81%9f%e3%81%84%ef%bc%81titanium-mobile%e3%81%a7zbar%e3%82%92%e4%bd%bf%e3%81%86/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 11:16:34 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[プログラミング_Titanium]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=391</guid>
		<description><![CDATA[ZBarSDKの準備 バーコードをスキャンするライブラリはいくつかありますが、わりと高速で使いやすいZBarを使うことにします。ネイティブアプリの場合は、このSDKをそのまま突っ込んでやれば良いんですが、Titanium Mobileの場合は tibar というモジュールを使用します。 tibar １：tibarここから、iPhone版のtibarをダウンロードします。 ２：解凍したモジュールを /Library/Application Support/Titanium/module に配置します。 ３： /Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/iphone/Titanium.xcodeproj をXCodeで立ち上げます。 ４：下記ライブラリをリンク。Bulde PhasesからLink Binary With Librariesから追加。 QuartzCore.framework libiconv.dylib AVFoundation.framework CoreMedia.framework CoreVideo.framework ５：XCodeを閉じる。 Titanium Studioでアプリを作る 準備が整ったので、Titanium Studioでプロジェクトを作成します。 まずは、tiapp.xmlを編集して、モジュールを追加します。versionの所はダウンロードしてきたtibarに合わせてください。 tiapp.xml &#60;modules&#62; &#60;module version=&#34;0.4.2&#34;&#62;tibar&#60;/module&#62; &#60;/modules&#62; app.js tibarの公式サイトにもサンプルがありますが、バーコード解析がカメラじゃなくて、カメラロールの設定になっているので、ここではカメラで自動的に認識するようにしてみます。 var win = Titanium.UI.createWindow({ title:'TiBar Test App', backgroundColor:'#fff' }); var TiBar = require('tibar'); var label = Titanium.UI.createLabel({ [...]]]></description>
			<content:encoded><![CDATA[<h3>ZBarSDKの準備</h3>
<p>バーコードをスキャンするライブラリはいくつかありますが、わりと高速で使いやすいZBarを使うことにします。ネイティブアプリの場合は、このSDKをそのまま突っ込んでやれば良いんですが、Titanium Mobileの場合は tibar というモジュールを使用します。</p>
<ul>
<li><a href="http://code.google.com/p/tibar/" target="_blank">tibar</a></li>
</ul>
<p>１：<a href="http://code.google.com/p/tibar/" target="_blank">tibar</a>ここから、iPhone版のtibarをダウンロードします。</p>
<p>２：解凍したモジュールを /Library/Application Support/Titanium/module に配置します。</p>
<p>３： /Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/iphone/Titanium.xcodeproj をXCodeで立ち上げます。</p>
<p>４：下記ライブラリをリンク。Bulde PhasesからLink Binary With Librariesから追加。</p>
<ul>
<li>QuartzCore.framework</li>
<li>libiconv.dylib</li>
<li>AVFoundation.framework</li>
<li>CoreMedia.framework</li>
<li>CoreVideo.framework</li>
</ul>
<p><a href="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/Titanium-Titanium.xcodeproj.jpg"><img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/Titanium-Titanium.xcodeproj-300x227.jpg" alt="" title="Titanium - Titanium.xcodeproj" width="300" height="227" class="alignnone size-medium wp-image-392" /></a></p>
<p>５：XCodeを閉じる。</p>
<h3>Titanium Studioでアプリを作る</h3>
<p>準備が整ったので、Titanium Studioでプロジェクトを作成します。</p>
<p>まずは、tiapp.xmlを編集して、モジュールを追加します。versionの所はダウンロードしてきたtibarに合わせてください。</p>
<h4>tiapp.xml</h4>
<pre class="brush: plain; title: ;">
&lt;modules&gt;
         &lt;module version=&quot;0.4.2&quot;&gt;tibar&lt;/module&gt;
&lt;/modules&gt;
</pre>
<h4>app.js</h4>
<p>tibarの公式サイトにもサンプルがありますが、バーコード解析がカメラじゃなくて、カメラロールの設定になっているので、ここではカメラで自動的に認識するようにしてみます。</p>
<pre class="brush: jscript; title: ;">
var win = Titanium.UI.createWindow({
    title:'TiBar Test App',
    backgroundColor:'#fff'
});

var TiBar = require('tibar');
var label = Titanium.UI.createLabel({
    text:'TiBar App',
    textAlign:'center',
    width:'auto'
});

var button = Ti.UI.createButton({
    title: &quot;Scan barcode&quot;,
    height:50,
    width:250,
    bottom:20
});
button.addEventListener('click', function(){
    TiBar.scan({
        configure: {
            classType: &quot;ZBarReaderViewController&quot;,
            sourceType: &quot;Camera&quot;,
            cameraMode: &quot;Default&quot;, // Default, Sampling, Sequence
            config:{
                &quot;showsCameraControls&quot;:true, // (VC)
                &quot;showsZBarControls&quot;:true,
                &quot;tracksSymbols&quot;:true, // the tracking rectangle that highlights barcodes
                &quot;enableCache&quot;:true,
                &quot;showsHelpOnFail&quot;:true,
                &quot;takesPicture&quot;:false
            },
        },

        success:function(data){
            Ti.API.info('TiBar success callback!');
            if(data &amp;&amp; data.barcode){
                Ti.UI.createAlertDialog({
                    title: &quot;Scan result&quot;,
                    message: &quot;Barcode: &quot; + data.barcode + &quot; Symbology:&quot; + data.symbology
                }).show();
            }
        },
        cancel:function(){
            Ti.API.info('TiBar cancel callback!');
        },
        error:function(){
            Ti.API.info('TiBar error callback!');
        }
    });
});
win.add(label);
win.add(button);

win.open();
</pre>
<p>これで、完成です。非常に簡単。</p>
<p>他の設定については公式サイトを参照してください。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=391&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/08/11/iphone%e3%81%a7%e3%83%90%e3%83%bc%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e3%82%b9%e3%82%ad%e3%83%a3%e3%83%b3%e3%81%97%e3%81%9f%e3%81%84%ef%bc%81titanium-mobile%e3%81%a7zbar%e3%82%92%e4%bd%bf%e3%81%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/08/11/iphone%e3%81%a7%e3%83%90%e3%83%bc%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e3%82%b9%e3%82%ad%e3%83%a3%e3%83%b3%e3%81%97%e3%81%9f%e3%81%84%ef%bc%81titanium-mobile%e3%81%a7zbar%e3%82%92%e4%bd%bf%e3%81%86/" />
	</item>
		<item>
		<title>Titanium StudioでiPhone実機転送をする方法</title>
		<link>http://zaru.tofu-kun.org/2011/08/09/taitanium-studio%e3%81%a7iphone%e5%ae%9f%e6%a9%9f%e8%bb%a2%e9%80%81%e3%82%92%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/</link>
		<comments>http://zaru.tofu-kun.org/2011/08/09/taitanium-studio%e3%81%a7iphone%e5%ae%9f%e6%a9%9f%e8%bb%a2%e9%80%81%e3%82%92%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 12:31:25 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[プログラミング_Titanium]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=378</guid>
		<description><![CDATA[最近、スマートフォンアプリの開発を始めたzaruです。 Xcodeでのネイティブアプリを開発していたんですが、諸事情によりWebベースで作ることになりました。色々試した結果、Titaniumでやるのが一番良さげ！というわけで、最近リリースされたTitanium Studioで開発を開始しました。 （TitaniumはWebベース…といっても良いのかな？PhoneGapとかは、Webベースと言えるが…） 開発自体は、まぁ良いんですが…いざiPhone実機にインストールをしようとするとエラーになってGoogleさんをさまよう日々。なんとかかんとか転送ができるようになったので、忘れてないようにメモをしておきます。 Titanium Studioプロジェクトの設定 tiapp.xmlの編集（TiApp Editor） Provisioning ProfilesのAppIDが、例えば「A1B2C3D4E5.zarutofukun」だった場合、自動的に付与された「A1B2C3D4E5」を除いた「zarutofukun」をTitaniumStudioのプロジェクト内にある Application ID に設定する。 僕は、ここでそのまま「A1B2C3D4E5.zarutofukun」を入力してしまい、下記のようなエラーを出してはまってました。 [ERROR] [BEROR]Code Sign error: Provisioning profile 'hogehoge' specifies the Application Identifier 'hogepiyo' which doesn't match the current setting 'A1B2C3D4E5.zarutofukun' [ERROR] [ERROR] Error: Traceback (most recent call last): File &#34;/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/builder.py&#34;, line 1305, in main execute_xcode(&#34;iphoneos%s&#34; % iphone_version,args,False) File &#34;/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/builder.py&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>最近、スマートフォンアプリの開発を始めたzaruです。</p>
<p>Xcodeでのネイティブアプリを開発していたんですが、諸事情によりWebベースで作ることになりました。色々試した結果、Titaniumでやるのが一番良さげ！というわけで、最近リリースされたTitanium Studioで開発を開始しました。<br />
（TitaniumはWebベース…といっても良いのかな？PhoneGapとかは、Webベースと言えるが…）</p>
<p>開発自体は、まぁ良いんですが…いざiPhone実機にインストールをしようとするとエラーになってGoogleさんをさまよう日々。なんとかかんとか転送ができるようになったので、忘れてないようにメモをしておきます。</p>
<h3>Titanium Studioプロジェクトの設定</h3>
<h4>tiapp.xmlの編集（TiApp Editor）</h4>
<p>Provisioning ProfilesのAppIDが、例えば「A1B2C3D4E5.zarutofukun」だった場合、自動的に付与された「A1B2C3D4E5」を除いた「zarutofukun」をTitaniumStudioのプロジェクト内にある Application ID に設定する。</p>
<p><img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/Web-TestProject_tiapp.xml-Titanium-Studio-_Users_zaru_Documents_Titanium-Studio-Workspace-1-300x246.jpg" alt="" title="Web - TestProject_tiapp.xml - Titanium Studio - _Users_zaru_Documents_Titanium Studio Workspace-1" width="300" height="246" class="alignnone size-medium wp-image-379" /></p>
<p>僕は、ここでそのまま「A1B2C3D4E5.zarutofukun」を入力してしまい、下記のようなエラーを出してはまってました。</p>
<pre class="brush: plain; title: ;">
[ERROR] [BEROR]Code Sign error: Provisioning profile 'hogehoge' specifies the Application Identifier 'hogepiyo' which doesn't match the current setting 'A1B2C3D4E5.zarutofukun'
[ERROR]
[ERROR] Error: Traceback (most recent call last):
  File &quot;/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/builder.py&quot;, line 1305, in main
    execute_xcode(&quot;iphoneos%s&quot; % iphone_version,args,False)
  File &quot;/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/builder.py&quot;, line 1066, in execute_xcode
    output = run.run(args,False,False,o)
  File &quot;/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/run.py&quot;, line 39, in run
    sys.exit(rc)
SystemExit: 65
</pre>
<h3>Provisioning Profilesの登録</h3>
<p>続いて、Provisioning Profilesを登録します。</p>
<p>メニューから「iOS Device」を選択します。（非力なMacだとけっこう時間掛かる…）</p>
<p><img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/スクリーンショット-2011-08-09-20.52.53.png" alt="" title="スクリーンショット 2011-08-09 20.52.53" width="296" height="260" class="alignnone size-full wp-image-381" /></p>
<p>ここでUpload Development Provisioning Profileとあるので、Uploadを選択し、iOS Provisioning PortalからダウンロードしたProvisioning Profileを選択する。</p>
<p><img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/TitaniumStudio-300x297.jpg" alt="" title="TitaniumStudio" width="300" height="297" class="alignnone size-medium wp-image-382" /></p>
<p>これで「Finish」をクリックすればビルド＆転送が開始！</p>
<p>Titanium Studioでの実機転送にはiTunesが使われるみたいで、自動的にiTunesが立ち上がりアプリの登録が行われます。Xcodeとは違い一発で転送！というわけにはいかないみたいですね。iPhoneと開発Macが母艦な関係だったら、iTunesで同期すればいいんですが、個人iPhone・会社Macな環境だと困る！というわけで、iTunesを使わずにアプリの転送をします。</p>
<h3>アプリをiTunes使わずに転送</h3>
<p>XcodeのOrganizerを立ち上げます。</p>
<p><img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/08/Organizer-Devices-1-300x210.jpg" alt="" title="Organizer - Devices-1" width="300" height="210" class="alignnone size-medium wp-image-383" /></p>
<p>Deviceの中にあるApplicationsを開くと、アプリの登録ができるので、Addをクリックして、先程TitaniumStudioでビルドしたバイナリファイルを追加します。<br />
すると、接続しているiPhoneに自動的に転送が開始されます！</p>
<h3>余談：ビルド時のエラー</h3>
<p>ビルド・インストールは成功したが、ログに妙なエラーが…。</p>
<h4>最初出ていたエラー</h4>
<pre class="brush: plain; title: ;">
2011-08-09 20:29:37.213 osascript[27370:f07] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
     /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition &quot;/Library/ScriptingAdditions/Adobe Unit Types.osax&quot; declares no loadable handlers.
/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/itunes_sync.scpt: execution error: Can’t make name of 3 into type Unicode text. (-1700)
</pre>
<p><a href="http://kb2.adobe.com/cps/516/cpsid_51615.html">http://kb2.adobe.com/cps/516/cpsid_51615.html</a><br />
ここからファイルをダウンロードして差し替えたら、メッセージが変わった。</p>
<h4>次のエラー</h4>
<pre class="brush: plain; title: ;">
/Library/Application Support/Titanium/mobilesdk/osx/1.7.2/iphone/itunes_sync.scpt: execution error: Can’t make name of 3 into type Unicode text.
</pre>
<p><a href="http://developer.appcelerator.com/question/122993/error-while-moving-app-to-ios-device">http://developer.appcelerator.com/question/122993/error-while-moving-app-to-ios-device</a><br />
同じ症状の人が…。</p>
<h4>解決方法…</h4>
<p>解決方法というか…単純にiTunesをアップデートしたら解決しました…。OSはLionにしたけど、iTunesは放置してたんですよね。会社のMacだし、特に使うことがないので。</p>
<p>まぁ、今後はiTunesもちゃんとアップデートしましょう…と。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=378&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/08/09/taitanium-studio%e3%81%a7iphone%e5%ae%9f%e6%a9%9f%e8%bb%a2%e9%80%81%e3%82%92%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/08/09/taitanium-studio%e3%81%a7iphone%e5%ae%9f%e6%a9%9f%e8%bb%a2%e9%80%81%e3%82%92%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/" />
	</item>
		<item>
		<title>iPhoneなどでリンクをタップ時に出るグレーの影を消す方法</title>
		<link>http://zaru.tofu-kun.org/2011/07/15/iphone%e3%81%aa%e3%81%a9%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%af%e3%82%92%e3%82%bf%e3%83%83%e3%83%97%e6%99%82%e3%81%ab%e5%87%ba%e3%82%8b%e3%82%b0%e3%83%ac%e3%83%bc%e3%81%ae%e5%bd%b1%e3%82%92%e6%b6%88/</link>
		<comments>http://zaru.tofu-kun.org/2011/07/15/iphone%e3%81%aa%e3%81%a9%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%af%e3%82%92%e3%82%bf%e3%83%83%e3%83%97%e6%99%82%e3%81%ab%e5%87%ba%e3%82%8b%e3%82%b0%e3%83%ac%e3%83%bc%e3%81%ae%e5%bd%b1%e3%82%92%e6%b6%88/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 10:10:32 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[技術その他]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=374</guid>
		<description><![CDATA[友人から、スマフォサイトでリンクをタップすると、グレーの影がでるんだけど、消せない？と連絡がきたので、ちょっと調べてみた。どうやら、Googleなんかはそういうのが出ず、タップ時に背景色が変わったりしているらしい。 調べていくと、そのものズバリなCSSがあった。 -webkit-tap-highlight-color: rgba(0, 0, 0, 0); これで、タップ時にもなんの反応もしないリンクの出来上がり。]]></description>
			<content:encoded><![CDATA[<p>友人から、スマフォサイトでリンクをタップすると、グレーの影がでるんだけど、消せない？と連絡がきたので、ちょっと調べてみた。どうやら、Googleなんかはそういうのが出ず、タップ時に背景色が変わったりしているらしい。</p>
<p>調べていくと、そのものズバリなCSSがあった。</p>
<pre class="brush: css; title: ;">
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
</pre>
<p>これで、タップ時にもなんの反応もしないリンクの出来上がり。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=374&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/07/15/iphone%e3%81%aa%e3%81%a9%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%af%e3%82%92%e3%82%bf%e3%83%83%e3%83%97%e6%99%82%e3%81%ab%e5%87%ba%e3%82%8b%e3%82%b0%e3%83%ac%e3%83%bc%e3%81%ae%e5%bd%b1%e3%82%92%e6%b6%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/07/15/iphone%e3%81%aa%e3%81%a9%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%af%e3%82%92%e3%82%bf%e3%83%83%e3%83%97%e6%99%82%e3%81%ab%e5%87%ba%e3%82%8b%e3%82%b0%e3%83%ac%e3%83%bc%e3%81%ae%e5%bd%b1%e3%82%92%e6%b6%88/" />
	</item>
		<item>
		<title>改良 : PHPでのページング処理のサンプル。</title>
		<link>http://zaru.tofu-kun.org/2011/06/28/%e6%94%b9%e8%89%af-php%e3%81%a7%e3%81%ae%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%b3%e3%82%b0%e5%87%a6%e7%90%86%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%80%82/</link>
		<comments>http://zaru.tofu-kun.org/2011/06/28/%e6%94%b9%e8%89%af-php%e3%81%a7%e3%81%ae%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%b3%e3%82%b0%e5%87%a6%e7%90%86%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%80%82/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 06:08:20 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[プログラミング_PHP]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=357</guid>
		<description><![CDATA[ページング…？ PHPでのページング処理のサンプル。「とりあえず9JP」で、紹介されていたPHPのページング処理を見たら、対象のログファイルを全て読み込んで、そこから必要なデータを出力していたので、軽いファイルの時はまだしも、ちょっとファイルサイズが大きくなったら厳しいと思ったので、片手間に改良してみました。 改良版 PHPでのページング処理のサンプル。で作られたソースを極力変えずに、必要な部分のみ改修してあります。ちょっとエラーもあったので、合わせて修正してあります。 ソース class TekitouPager { private $dataArr = array(); private $pageNum = null; private $maxPageNum = null; function __construct($dataFile, $maxRecodeNum,$pageNum = '') { $start = $pageNum * $maxRecodeNum; $end = $start + $maxRecodeNum; $file = new SplFileObject($dataFile); for($i=$start;$i&#60;$end;$i++){ $file-&#62;seek($i); $this-&#62;dataArr[] = $file-&#62;current(); } //ページ数を計算 $count = 0; foreach ($file as $line) { [...]]]></description>
			<content:encoded><![CDATA[<h3>ページング…？</h3>
<p><a href="http://9jp.info/archives/11154" target="_blank">PHPでのページング処理のサンプル。「とりあえず9JP」</a>で、紹介されていたPHPのページング処理を見たら、対象のログファイルを全て読み込んで、そこから必要なデータを出力していたので、軽いファイルの時はまだしも、ちょっとファイルサイズが大きくなったら厳しいと思ったので、片手間に改良してみました。</p>
<h3>改良版</h3>
<p><a href="http://9jp.info/archives/11154" target="_blank">PHPでのページング処理のサンプル。</a>で作られたソースを極力変えずに、必要な部分のみ改修してあります。ちょっとエラーもあったので、合わせて修正してあります。</p>
<h4>ソース</h4>
<pre class="brush: php; title: ;">
class TekitouPager {

    private $dataArr = array();
    private $pageNum = null;
    private $maxPageNum = null;

    function __construct($dataFile, $maxRecodeNum,$pageNum = '') {
        $start = $pageNum * $maxRecodeNum;
        $end = $start + $maxRecodeNum;
        $file = new SplFileObject($dataFile);
        for($i=$start;$i&lt;$end;$i++){
            $file-&gt;seek($i);
            $this-&gt;dataArr[] = $file-&gt;current();
        }
        //ページ数を計算
        $count = 0;
        foreach ($file as $line) {
            $count++;
        }
        $this-&gt;maxPageNum = ceil($count / $maxRecodeNum);
        $this-&gt;pageNum = intval($pageNum);
    }

    function getPageData() {
        //指定されたページの配列を返す
        return $this-&gt;dataArr;
    }

    function getNaviLink() {
        $naviLink = '';
        for ($i = 0; $i &lt; $this-&gt;maxPageNum ; $i++) {
            //現在のページと一致する場合、太字等の強調
            if ($i != $this-&gt;pageNum) {
                $naviLink .= sprintf('&lt;a href=&quot;%s?page=%d&quot;&gt;%d&lt;/a&gt;&amp;nbsp;', $_SERVER['SCRIPT_NAME'], $i, $i);
            }
            else {
                $naviLink .= sprintf('&lt;b&gt;&lt;a href=&quot;%s?page=%d&quot;&gt;%d&lt;/a&gt;&lt;/b&gt;&amp;nbsp;', $_SERVER['SCRIPT_NAME'], $i, $i);
            }
        }
        return $naviLink;
    }

    function getNextLink() {
        //次のページが存在する場合、次のページへのリンク
        if ($this-&gt;maxPageNum &gt; $this-&gt;pageNum + 1) {
            return sprintf('&lt;a href=&quot;%s?page=%d&quot;&gt;Next&lt;/a&gt;&amp;nbsp;', $_SERVER['SCRIPT_NAME'], $this-&gt;pageNum + 1);
        }

    }

    function getPrevLink() {
        //現在のページが0では無い場合、前のページへのリンク
        if ($this-&gt;pageNum != 0) {
            return sprintf('&lt;a href=&quot;%s?page=%d&quot;&gt;Prev&lt;/a&gt;&amp;nbsp;', $_SERVER['SCRIPT_NAME'], $this-&gt;pageNum - 1);
        }
    }

}

if(isset($_GET['page'])){
    $page = $_GET['page'];
}else{
    $page = 0;
}
$pager = new TekitouPager('data.dat', 5,$page);
var_dump($pager-&gt;getPageData());
echo $pager-&gt;getPrevLink() . $pager-&gt;getNaviLink() . $pager-&gt;getNextLink();
</pre>
<h4>2011/06/28 23:15 追記</h4>
<p style="color:#ff0000;">とりあえず9JPの@buffbuffratさんから、次ページリンクの処理がこのままだとできないと指摘をいただいたため、慌てて修正しました。ありがとうございます。</p>
<p>変更箇所は、ファイルが何行あるのか調べるという部分です。</p>
<pre class="brush: php; title: ;">
$file = new SplFileObject($dataFile);
//ページ数を計算
$count = 0;
foreach ($file as $line) {
    $count++;
}
</pre>
<p>こんな感じです。</p>
<h4>なにを変えたか</h4>
<p>ページング自体のロジックは変更していません。ファイルを読み込む方法を変更してあります。元のソースは file() で全てを読み込み、配列に格納していましたが1000行も超えてくるとメモリ消費も馬鹿になりません。</p>
<p>そこで、SplFileObjectを使って、ファイルポインタを移動して、必要な行のみを取得しています。これであれば、メモリも最低限でいけます。</p>
<p>さすがに数万とかになってくるとポインタ移動だけで、けっこうな負荷になりますが、それでも全部読み込むよりはましだと思います。</p>
<h4>実際にパフォーマンスを測ってみた</h4>
<p>abで簡単にパフォーマンスを測ってみました。</p>
<table>
<tr>
<th></th>
<th>file()</th>
<th>SplFileObject</th>
</tr>
<tr>
<th>20行</th>
<td>1733 [#/sec]</td>
<td>1653 [#/sec]</td>
</tr>
<tr>
<th>500行</th>
<td>1180 [#/sec]</td>
<td>1292 [#/sec]</td>
</tr>
<tr>
<th>1,000行</th>
<td>844 [#/sec]</td>
<td>1246 [#/sec]</td>
</tr>
<tr>
<th>20,000行</th>
<td>40 [#/sec]</td>
<td>490 [#/sec]</td>
</tr>
</table>
<p>ファイルサイズが大きくなるにつれてパフォーマンスの差も出てきますね。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=357&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/06/28/%e6%94%b9%e8%89%af-php%e3%81%a7%e3%81%ae%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%b3%e3%82%b0%e5%87%a6%e7%90%86%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/06/28/%e6%94%b9%e8%89%af-php%e3%81%a7%e3%81%ae%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%b3%e3%82%b0%e5%87%a6%e7%90%86%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%80%82/" />
	</item>
		<item>
		<title>WindowsXPで、タスクトレイが正常に表示されない・スタートアップが立ち上がらないのを直す</title>
		<link>http://zaru.tofu-kun.org/2011/05/12/windowsxp%e3%81%a7%e3%80%81%e3%82%bf%e3%82%b9%e3%82%af%e3%83%88%e3%83%ac%e3%82%a4%e3%81%8c%e6%ad%a3%e5%b8%b8%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%95%e3%82%8c%e3%81%aa%e3%81%84%e3%83%bb%e3%82%b9%e3%82%bf/</link>
		<comments>http://zaru.tofu-kun.org/2011/05/12/windowsxp%e3%81%a7%e3%80%81%e3%82%bf%e3%82%b9%e3%82%af%e3%83%88%e3%83%ac%e3%82%a4%e3%81%8c%e6%ad%a3%e5%b8%b8%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%95%e3%82%8c%e3%81%aa%e3%81%84%e3%83%bb%e3%82%b9%e3%82%bf/#comments</comments>
		<pubDate>Thu, 12 May 2011 01:21:14 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[技術その他]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=350</guid>
		<description><![CDATA[WindowsXPをメインに使うのが久しぶりなのもあって、色々と戸惑いながら作業をしているzaruです。こんにちは。メインで使っているので、色々なツールを入れてはスタートアップに登録して、起動時に自動的に立ち上がるようにしています。SkypeやらEvernoteやらDropboxやらTortoise関係などなど。 で、いつの日かほぼすべてのサービスが立ち上がらなくなってしまいました。正確に言うと、起動時にタスクトレイにアイコンが一瞬出るんですが、すぐ落ちて消えてしまうという感じです。 なんでだろう…。と思いつつも、主導で立ち上げていたりしていたんですが、さすがに面倒になってきたので重い腰を上げて検索してみると「タスクトレイ登録時に、起動4秒以上かかると消えてしまう」のが仕様らしいです。知らなかった。 解決方法 肝心の解決方法としては、「ネットワーク接続」→「詳細設定」→「オプション ネットワーク コンポーネント」を選択。 出てきたダイアログから「ネットワークサービス」を選択して、右下の「詳細」ボタンをクリック。 その中に「UPnPユーザーインターフェース」というのがあるので、これのチェックを外して「OK」をクリックし、「次へ」で完了です。 あとは再起動して、確認。 なぜこれで解決するのかは分かりませんが、とりあえず僕の場合は無事スタートアップが正常に動き、解消しました。]]></description>
			<content:encoded><![CDATA[<p>WindowsXPをメインに使うのが久しぶりなのもあって、色々と戸惑いながら作業をしているzaruです。こんにちは。メインで使っているので、色々なツールを入れてはスタートアップに登録して、起動時に自動的に立ち上がるようにしています。SkypeやらEvernoteやらDropboxやらTortoise関係などなど。</p>
<p>で、いつの日かほぼすべてのサービスが立ち上がらなくなってしまいました。正確に言うと、起動時にタスクトレイにアイコンが一瞬出るんですが、すぐ落ちて消えてしまうという感じです。</p>
<p>なんでだろう…。と思いつつも、主導で立ち上げていたりしていたんですが、さすがに面倒になってきたので重い腰を上げて検索してみると「タスクトレイ登録時に、起動4秒以上かかると消えてしまう」のが仕様らしいです。知らなかった。</p>
<h3>解決方法</h3>
<p>肝心の解決方法としては、「ネットワーク接続」→「詳細設定」→「オプション ネットワーク コンポーネント」を選択。<br />
<img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/05/WS000003-300x225.jpg" alt="" title="WS000003" width="300" height="225" class="alignnone size-medium wp-image-351" /></p>
<p>出てきたダイアログから「ネットワークサービス」を選択して、右下の「詳細」ボタンをクリック。<br />
<img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/05/WS000001-300x183.jpg" alt="" title="WS000001" width="300" height="183" class="alignnone size-medium wp-image-352" /></p>
<p>その中に「UPnPユーザーインターフェース」というのがあるので、これのチェックを外して「OK」をクリックし、「次へ」で完了です。<br />
<img src="http://zaru.tofu-kun.org/wp-content/uploads/2011/05/WS000002-300x181.jpg" alt="" title="WS000002" width="300" height="181" class="alignnone size-medium wp-image-353" /></p>
<p>あとは再起動して、確認。</p>
<p>なぜこれで解決するのかは分かりませんが、とりあえず僕の場合は無事スタートアップが正常に動き、解消しました。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=350&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/05/12/windowsxp%e3%81%a7%e3%80%81%e3%82%bf%e3%82%b9%e3%82%af%e3%83%88%e3%83%ac%e3%82%a4%e3%81%8c%e6%ad%a3%e5%b8%b8%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%95%e3%82%8c%e3%81%aa%e3%81%84%e3%83%bb%e3%82%b9%e3%82%bf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/05/12/windowsxp%e3%81%a7%e3%80%81%e3%82%bf%e3%82%b9%e3%82%af%e3%83%88%e3%83%ac%e3%82%a4%e3%81%8c%e6%ad%a3%e5%b8%b8%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%95%e3%82%8c%e3%81%aa%e3%81%84%e3%83%bb%e3%82%b9%e3%82%bf/" />
	</item>
		<item>
		<title>Postfixでメール転送する（バーチャルドメイン版＋通常版）</title>
		<link>http://zaru.tofu-kun.org/2011/05/11/postfix%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e8%bb%a2%e9%80%81%e3%81%99%e3%82%8b%ef%bc%88%e3%83%90%e3%83%bc%e3%83%81%e3%83%a3%e3%83%ab%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e7%89%88%ef%bc%8b%e9%80%9a/</link>
		<comments>http://zaru.tofu-kun.org/2011/05/11/postfix%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e8%bb%a2%e9%80%81%e3%81%99%e3%82%8b%ef%bc%88%e3%83%90%e3%83%bc%e3%83%81%e3%83%a3%e3%83%ab%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e7%89%88%ef%bc%8b%e9%80%9a/#comments</comments>
		<pubDate>Wed, 11 May 2011 02:24:22 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[サーバ_Linux_Windows]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=347</guid>
		<description><![CDATA[Postfixで、メール転送をするには普通は2つの方法があります。/etc/aliases を利用するのと、~/.forward を利用する方法です。ただし、これはどちらも実ユーザが存在する場合のみに有効で、複数のドメインでバーチャルドメイン運用している場合は、そもそもユーザが存在しないので、これではできません。 メール転送ドメイン /etc/postfix/main.cf virtual_alias_domains = example.com, example.net virtual_alias_maps = hash:/etc/postfix/virtual バーチャルドメインで使用するドメインを記載します。 /etc/postfix/virtual example.com anything info@example.com aaa@example.co.jp example.net anything info@example.net aaa@example.co.jp bbb@example.co.jp 転送元メールアドレスの後に、転送先メールアドレスを記載していきます。複数の転送先を設定できます。 設定を反映させる #/usr/sbin/postmap /etc/postfix/virtual #/etc/rc.d/init.d/postfix restart 転送設定ファイルを反映させた後、postfixを再起動させてください。これで転送が出来ていると思います。 /etc/aliases を利用する方法 一応、普通のメール転送設定も。 /etc/aliases info:aaa@example.co.jp sales:aaa@example.co.jp,bbb@example.co.jp /etc/aliases に転送元メールアカウントの後に、転送先メールアドレスをカンマ区切りで記載していきます。 #postalias /etc/aliases #newaliases これで反映されます。なお、エイリアスファイルは、/etc/postfix/main.cf に alias_maps という項目で設定されています（通常は /etc/aliases のはず）。 ~/.forward aaa@example.co.jp bbb@example.co.jp と、転送元アカウントのホームディレクトリに .forward ファイルを作成して、転送先のメールアドレスを改行、もしくはカンマ区切りで記載していきます。 また、転送元にメールを残す場合はには \info [...]]]></description>
			<content:encoded><![CDATA[<p>Postfixで、メール転送をするには普通は2つの方法があります。/etc/aliases を利用するのと、~/.forward を利用する方法です。ただし、これはどちらも実ユーザが存在する場合のみに有効で、複数のドメインでバーチャルドメイン運用している場合は、そもそもユーザが存在しないので、これではできません。</p>
<h3>メール転送ドメイン</h3>
<h4>/etc/postfix/main.cf</h4>
<pre class="brush: bash; title: ;">virtual_alias_domains = example.com, example.net
virtual_alias_maps = hash:/etc/postfix/virtual
</pre>
<p>バーチャルドメインで使用するドメインを記載します。</p>
<h4>/etc/postfix/virtual</h4>
<pre class="brush: bash; title: ;">example.com anything
info@example.com aaa@example.co.jp

example.net anything
info@example.net aaa@example.co.jp bbb@example.co.jp
</pre>
<p>転送元メールアドレスの後に、転送先メールアドレスを記載していきます。複数の転送先を設定できます。</p>
<h4>設定を反映させる</h4>
<pre class="brush: bash; title: ;">#/usr/sbin/postmap /etc/postfix/virtual
#/etc/rc.d/init.d/postfix restart
</pre>
<p>転送設定ファイルを反映させた後、postfixを再起動させてください。これで転送が出来ていると思います。</p>
<h3>/etc/aliases を利用する方法</h3>
<p>一応、普通のメール転送設定も。</p>
<h4>/etc/aliases</h4>
<pre class="brush: bash; title: ;">info:aaa@example.co.jp
sales:aaa@example.co.jp,bbb@example.co.jp
</pre>
<p>/etc/aliases に転送元メールアカウントの後に、転送先メールアドレスをカンマ区切りで記載していきます。</p>
<pre class="brush: bash; title: ;">#postalias /etc/aliases
#newaliases
</pre>
<p>これで反映されます。なお、エイリアスファイルは、/etc/postfix/main.cf に alias_maps という項目で設定されています（通常は /etc/aliases のはず）。</p>
<h4>~/.forward</h4>
<pre class="brush: bash; title: ;">aaa@example.co.jp
bbb@example.co.jp
</pre>
<p>と、転送元アカウントのホームディレクトリに .forward ファイルを作成して、転送先のメールアドレスを改行、もしくはカンマ区切りで記載していきます。<br />
また、転送元にメールを残す場合はには</p>
<pre class="brush: bash; title: ;">\info
aaa@example.co.jp
bbb@example.co.jp
</pre>
<p>と、バックスラッシュ＋アカウント名を先頭に記載します。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=347&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/05/11/postfix%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e8%bb%a2%e9%80%81%e3%81%99%e3%82%8b%ef%bc%88%e3%83%90%e3%83%bc%e3%83%81%e3%83%a3%e3%83%ab%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e7%89%88%ef%bc%8b%e9%80%9a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/05/11/postfix%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e8%bb%a2%e9%80%81%e3%81%99%e3%82%8b%ef%bc%88%e3%83%90%e3%83%bc%e3%83%81%e3%83%a3%e3%83%ab%e3%83%89%e3%83%a1%e3%82%a4%e3%83%b3%e7%89%88%ef%bc%8b%e9%80%9a/" />
	</item>
		<item>
		<title>CakePHPで、MySQLとPostgreSQL両方を使いつつ、さらに違う文字コードに対応する方法</title>
		<link>http://zaru.tofu-kun.org/2011/04/28/cakephp%e3%81%a7%e3%80%81mysql%e3%81%a8postgresql%e4%b8%a1%e6%96%b9%e3%82%92%e4%bd%bf%e3%81%84%e3%81%a4%e3%81%a4%e3%80%81%e3%81%95%e3%82%89%e3%81%ab%e9%81%95%e3%81%86%e6%96%87%e5%ad%97%e3%82%b3/</link>
		<comments>http://zaru.tofu-kun.org/2011/04/28/cakephp%e3%81%a7%e3%80%81mysql%e3%81%a8postgresql%e4%b8%a1%e6%96%b9%e3%82%92%e4%bd%bf%e3%81%84%e3%81%a4%e3%81%a4%e3%80%81%e3%81%95%e3%82%89%e3%81%ab%e9%81%95%e3%81%86%e6%96%87%e5%ad%97%e3%82%b3/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 06:42:58 +0000</pubDate>
		<dc:creator>zaru</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[プログラミング_PHP]]></category>

		<guid isPermaLink="false">http://zaru.tofu-kun.org/?p=343</guid>
		<description><![CDATA[めったにないタイプですが、つい先日すでに存在しているデータベースを使用して新しいサイトを立ち上げるという案件がありました。しかもMySQLはUTF-8だけど、PostgreSQLはEUC-JP…。おぉう。というわけで、CakePHPでサクっと両方のデータベースに対応してみました。 モデルの作成 config/database.php class DATABASE_CONFIG { //MySQL_DB var $default = array( 'driver' =&#62; 'mysql', 'persistent' =&#62; false, 'host' =&#62; 'localhost', 'login' =&#62; 'id', 'password' =&#62; 'pass', 'database' =&#62; 'name', 'prefix' =&#62; '', ); //PostgreSQL_DB var $pg = array( 'driver' =&#62; 'postgres', 'persistent' =&#62; false, 'host' =&#62; '192.168.0.100', 'login' =&#62; 'id', 'password' =&#62; 'pass', 'database' =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>めったにないタイプですが、つい先日すでに存在しているデータベースを使用して新しいサイトを立ち上げるという案件がありました。しかもMySQLはUTF-8だけど、PostgreSQLはEUC-JP…。おぉう。というわけで、CakePHPでサクっと両方のデータベースに対応してみました。</p>
<h3>モデルの作成</h3>
<h4>config/database.php</h4>
<pre class="brush: php; title: ;">
class DATABASE_CONFIG {

 //MySQL_DB
 var $default = array(
  'driver' =&gt; 'mysql',
  'persistent' =&gt; false,
  'host' =&gt; 'localhost',
  'login' =&gt; 'id',
  'password' =&gt; 'pass',
  'database' =&gt; 'name',
  'prefix' =&gt; '',
 );

 //PostgreSQL_DB
 var $pg = array(
  'driver' =&gt; 'postgres',
  'persistent' =&gt; false,
  'host' =&gt; '192.168.0.100',
  'login' =&gt; 'id',
  'password' =&gt; 'pass',
  'database' =&gt; 'name',
  'encoding' =&gt; 'EUC_JP',
  'prefix' =&gt; '',
  'port' =&gt; 5432,
 );
}
</pre>
<h4>app_model.php</h4>
<pre class="brush: php; title: ;">
//PostgreSQL用（EUC）
class PgAppModel extends Model {

 function beforeFind($queryData) {
  // クエリパラメータの配列を、DB文字コードに変換
  array_walk_recursive($queryData, array($this, 'encodeToDbEncoding'));
  return $queryData;
 }

 function afterFind($results, $primary = false) {
  // 取得結果の配列を、内部文字コードに変換
  array_walk_recursive($results, array($this, 'decodeFromDbEncoding'));
  return $results;
 }

 function beforeSave($options = array()) {
  // saveするデータの配列を、DB文字コードに変換
  array_walk_recursive($this-&gt;data, array($this, 'encodeToDbEncoding'));
  return true;
 }

 function query() {
  // Model::queryは可変の引数をとるので同じようオーバーライドにする
  $params = func_get_args();
  array_walk_recursive($params, array($this, 'encodeToDbEncoding'));
  $results = call_user_func_array(array('Model', 'query'), $params);
  if (is_array($results)) {
   $results = $this-&gt;afterFind($results);
  }
  return $results;
 }

 function encodeToDbEncoding(&amp;$value, $key) {
  if (is_string($value)) {
   $value = mb_convert_encoding($value, 'EUC-JP', Configure::read('App.encoding'));
  }
 }

 function decodeFromDbEncoding(&amp;$value, $key) {
  if (is_string($value)) {
   //機種依存文字をEUC-JP -&gt; UTF-8にすると文字化けするので、一旦 sjis-win に変換する
   //$value = mb_convert_encoding(mb_convert_encoding($value, 'sjis-win','EUC-JP'),Configure::read('App.encoding'), 'sjis-win');
   //でも、一部の機種依存のみの対応で大丈夫そうなので、 eucJP-win にする
   $value = mb_convert_encoding($value,Configure::read('App.encoding'), 'eucJP-win');
  }
 }
}

//MySQL用（UTF-8）
class AppModel extends Model {
}
</pre>
<p>ちょっと気をつけたいのは、EUC-JPからUTF-8に変換する際に、機種依存文字（「①」「㈱」「Ⅰ」など）が文字化けしてしまいます。いったん、sjis-winに変換してからUTF-8に変換をすれば文字化けをすることがありません。よく使われる文字の対応だけであれば、eucJP-winからUTF-8への変換でいけるようです。</p>
<h4>各モデル</h4>
<pre class="brush: php; title: ;">
/**
 * PostgreSQLを利用するモデル
 */
class Hoge extends PgAppModel{

 var $name = 'Hoge';
 var $useDbConfig = 'pg'; //PostgreSQLのデータベース情報に対応
 var $useTable = 'hoge'; //CakePHPの命名規則に従ってない場合、ここで指定
 var $primaryKey = 'cid'; //プライマリーキーも同様

}

/**
 * MySQLを利用するモデル
 */
class Fuga extends AppModel{

 var $name = 'Fuga';

}
</pre>
<h3>トランザクション</h3>
<p>違うデータベースを使用していた場合でも、トランザクションはできます。</p>
<pre class="brush: php; title: ;">
//それぞれのモデルをロード
App::import('Model','MyModel');
App::import('Model','PgModel');
$my = new MyModel;
$pg = new PgModel;

//MySQLトランザクション
$dataSourceMy = $my-&gt;getDataSource();
$dataSourceMy-&gt;begin($my);

//PostgreSQLトランザクション
$dataSourcePg = $pg-&gt;getDataSource();
$dataSourcePg-&gt;begin($pg);

//結果格納用
$return = array();

//登録処理
$return[] = $my-&gt;save($data);
$return[] = $pg-&gt;save($data);

//ロールバック・コミット
if(in_array(false,$return,true)) {
	$dataSourceMy-&gt;rollback($my);
	$dataSourcePg-&gt;rollback($pg);

	return false;
} else {
	$dataSourceMy-&gt;commit($my);
	$dataSourcePg-&gt;commit($pg);

	return true;
}
</pre>
<p>もっとスマートな方法があるのかもしれないですが、とりあえずこれで複数データベースに対応ができます。</p>
<img src="http://zaru.tofu-kun.org/?ak_action=api_record_view&id=343&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://zaru.tofu-kun.org/2011/04/28/cakephp%e3%81%a7%e3%80%81mysql%e3%81%a8postgresql%e4%b8%a1%e6%96%b9%e3%82%92%e4%bd%bf%e3%81%84%e3%81%a4%e3%81%a4%e3%80%81%e3%81%95%e3%82%89%e3%81%ab%e9%81%95%e3%81%86%e6%96%87%e5%ad%97%e3%82%b3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://zaru.tofu-kun.org/2011/04/28/cakephp%e3%81%a7%e3%80%81mysql%e3%81%a8postgresql%e4%b8%a1%e6%96%b9%e3%82%92%e4%bd%bf%e3%81%84%e3%81%a4%e3%81%a4%e3%80%81%e3%81%95%e3%82%89%e3%81%ab%e9%81%95%e3%81%86%e6%96%87%e5%ad%97%e3%82%b3/" />
	</item>
	</channel>
</rss>
