<?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>@blog.justoneplanet.info</title>
	<atom:link href="http://blog.justoneplanet.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justoneplanet.info</link>
	<description>JavaScript、PHP、MySQLを使ったり</description>
	<lastBuildDate>Thu, 02 Sep 2010 17:30:45 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MySQLサーバーをインストールして初期設定をする</title>
		<link>http://blog.justoneplanet.info/2010/08/29/mysql%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e5%88%9d%e6%9c%9f%e8%a8%ad%e5%ae%9a%e3%82%92%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/29/mysql%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e5%88%9d%e6%9c%9f%e8%a8%ad%e5%ae%9a%e3%82%92%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 09:46:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2957</guid>
		<description><![CDATA[■インストール

yum install mysql-server

PHPから使う場合は以下のようにphp-mysqlもインストールする。

yum install php-mysql

MySQLにアクセスする。

 [...]]]></description>
			<content:encoded><![CDATA[<h3>■インストール</h3>
<pre class="brush: bash;">
yum install mysql-server
</pre>
<p>PHPから使う場合は以下のようにphp-mysqlもインストールする。</p>
<pre class="brush: bash;">
yum install php-mysql
</pre>
<p>MySQLにアクセスする。</p>
<pre class="brush: bash;">
mysql -u root
</pre>
<h3>■パスワード</h3>
<p>アクセスできるのは良いんだがパスワードが設定されてないのはイカン。（･ε･)</p>
<pre class="brush: bash;">
SET PASSWORD FOR root@localhost=PASSWORD('fugafuga');
</pre>
<h3>■データベース</h3>
<p>ちょっとデータベースを作ってみる。</p>
<pre class="brush: sql;">
CREATE DATABASE `sample`;
</pre>
<h3>■テーブル</h3>
<p>ちょっとテーブルを作ってみる。</p>
<pre class="brush: sql;">
USE `sample`;
CREATE TABLE  `sample`.`tbl1` (
    `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
    `name` VARCHAR( 255 ) NOT NULL ,
    PRIMARY KEY (  `id` )
) ENGINE = MYISAM ;
</pre>
<h3>■文字コード</h3>
<p>ネットで探してもなかなか適切な文献が見当たらない。凄く深いので結論だけまとめておく。</p>
<section class="kakomi">
<p>ちょっとPHPからデータを入れてみる。</p>
<pre class="brush: php;">
$dbh = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $dbh);
$query = &quot;INSERT INTO `tbl1`(`name`) VALUES('山田');&quot;;
$result = mysql_query($query);
</pre>
<p>phpMyAdminで見てみると以下のように文字化けする。</p>
<p><a href="/wp-content/uploads/2010/08/capture.png" rel="lightbox[2957]"><img src="/wp-content/uploads/2010/08/capture.png" alt="capture" title="capture" width="199" height="100" /></a></p>
<p>MySQLのデフォルト文字コードはlatin1になっている為だ。アプリケーション側で表示するときは特に文字化けすることはないかもしれないが、管理上は非常に面倒なのでデフォルト文字コードをutf-8にする事を強く勧める。</p>
</section>
<h4>my.cnf（my.ini）</h4>
<p>以下のようにする。</p>
<pre class="brush: bash;">
[mysqld]
default-character-set=utf8
[client]
default-character-set=utf8
</pre>
<p>但しMySQLクライアントのコンパイルオプションによっては全然文字化けしまくる。従ってプログラム側での修正も必要だ。</p>
<h4>PHP</h4>
<h5>mysql_connectを使う</h5>
<p>mysql_connectを使用している場合は5.2.3以上が必須で、以下のようにクライアント側の文字コードを設定する。</p>
<pre class="brush: php;">
$dbh = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_set_charset('utf8', $dbh);
</pre>
<h5>PDOを使う</h5>
<p>PDOを使用している場合は以下のように、MySQLの設定ファイルを読み込み、ATTR_EMULATE_PREPARESをfalseにしてサーバーサイドPrepared Statementを使うようにする。</p>
<pre class="brush: php;">
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
$dbh = new PDO(
    $dsn,
    DB_USER,
    DB_PASS,
    array(
        PDO::MYSQL_ATTR_READ_DEFAULT_FILE =&gt; '/etc/my.cnf'
    )
);
$dbh-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
</pre>
<p>但し、MySQL＜5.1の場合はクエリキャッシュが聞かないので注意が必要だ。現時点ではPDOでクライアント側の文字コードを指定する方法は無い。</p>
<h5>誤り</h5>
<ul>
<li>「SET NAMES utf8」クエリを発行する。</li>
<li>「skip-character-set-client-handshake」をmy.cnfに記述する。</li>
</ul>
<h5>参考</h5>
<ul>
<li><a href="http://rhiz.jp/id/171.html">PHPとSET NAMES問題のまとめ</a></li>
<li><a href="http://rhiz.jp/id/174.html">PHPでmysqlを適切に扱う方法</a></li>
<li><a href="http://blog.everqueue.com/chiba/2009/08/27/291/">mysqlでskip-character-set-client-handshakeはもう使わないほうがいいと思われ</a></li>
<li><a href="http://blog.ohgaki.net/set_namesa_mcb_asc">SET NAMESは禁止</a></li>
</ul>
<p>「PHP5.2.3以前」かつ「PDOを使用できない」かつ「再コンパイルできない」とき文字コードの問題を完全に解決するのは不可能とのこと。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/29/mysql%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e5%88%9d%e6%9c%9f%e8%a8%ad%e5%ae%9a%e3%82%92%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSにおけるパッケージインストールまとめ</title>
		<link>http://blog.justoneplanet.info/2010/08/29/centos%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%be%e3%81%a8%e3%82%81/</link>
		<comments>http://blog.justoneplanet.info/2010/08/29/centos%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%be%e3%81%a8%e3%82%81/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 07:59:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2955</guid>
		<description><![CDATA[■ソースからインストール
ソースパッケージをダウンロードしてコンパイル・ビルド。（gcc・・・）
【メリット】

環境に依存したどうこうに関係なくインストールできる。

インストールするときにインストールするマシン自身が [...]]]></description>
			<content:encoded><![CDATA[<h3>■ソースからインストール</h3>
<p>ソースパッケージをダウンロードしてコンパイル・ビルド。（gcc・・・）</p>
<h4>【メリット】</h4>
<ul>
<li>環境に依存したどうこうに関係なくインストールできる。</li>
</ul>
<p>インストールするときにインストールするマシン自身が自分でビルドする為。</p>
<h4>【デメリット】</h4>
<ul>
<li>「依存関係」の考慮が必要で面倒</li>
<li>必要な他プログラムなどあれば別途自分でインストールする等</li>
</ul>
<h3>■RPMでインストール</h3>
<p>あらかじめ別のマシンでコンパイルしたものをそのままコピーする。</p>
<h4>【メリット】</h4>
<ul>
<li>自分でコンパイルしないだけ簡単</li>
</ul>
<h4>【デメリット】</h4>
<ul>
<li>コンパイルしたマシンと環境が異なる場合は使えない</li>
<li>コンパイルしたマシンで指定したオプションに限定され、必要なオプションが指定できない</li>
<li>パッケージはあらゆる人が公開してるから、探したりダウンロードしたり記録したり、などが面倒</li>
</ul>
<h3>■yumでインストール</h3>
<p>パッケージ群を公開しているリポジトリからRPMを探し、ダウンロードして、インストールしてくれるツール</p>
<h4>【デメリット】</h4>
<ul>
<li>依存関係や付属プログラムや、そもそもそれらの有無なども、すべて他人が決めたもの</li>
<li>たくさんのリポジトリを参照するようにyumに追加設定すると依存関係のトラブルが起きたりする</li>
</ul>
<h4>【ポイント】</h4>
<p>リポジトリは信頼できるところにしておいたほうが良い。</p>
<ul>
<li>～redhat.com</li>
<li>有名どころとか</li>
<li>各ディストリビューションのベンダーなど・・・</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/29/centos%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%be%e3%81%a8%e3%82%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows XPでPHPとimageMagickを使用する</title>
		<link>http://blog.justoneplanet.info/2010/08/29/windows-xp%e3%81%a7php%e3%81%a8imagemagick%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/29/windows-xp%e3%81%a7php%e3%81%a8imagemagick%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 07:48:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2950</guid>
		<description><![CDATA[■ImageMagick
以下のサイトからWindows版をダウンロードしてインストールする。
http://www.imagemagick.org/script/binary-releases.php?ImageMag [...]]]></description>
			<content:encoded><![CDATA[<h3>■ImageMagick</h3>
<p>以下のサイトからWindows版をダウンロードしてインストールする。</p>
<p><a href="http://www.imagemagick.org/script/binary-releases.php?ImageMagick=pjjjn3udinf3ldej2osq7k8nj1#windows">http://www.imagemagick.org/script/binary-releases.php?ImageMagick=pjjjn3udinf3ldej2osq7k8nj1#windows</a></p>
<p>Program Files配下などのスペースを含むパスにインストールせず、cドライブ直下が望ましいらしい。</p>
<h4>環境変数</h4>
<p>設定＞コントロールパネル＞システム＞詳細設定＞環境変数＞システム環境変数</p>
<p>変数名はMAGICK_HOMEとし値はインストールしたパスを入力する。</p>
<h3>■Microsoft Visual C++ 2005 SP1</h3>
<p>以下のサイトからインストール</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&#038;displaylang=ja">http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&#038;displaylang=ja</a></p>
<h3>■php_imagick</h3>
<p>以下のサイトからインストールする。</p>
<p><a href="http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/">http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/</a></p>
<p>リンクが切れている場合は<a href="/wp-content/uploads/2010/08/php_imagick.dll">ここ</a>。</p>
<p>上手くいかない場合は以下のサイトのdllを使用した方が良いかもしれない。</p>
<p><a href="http://valokuva.org/?page_id=50">http://valokuva.org/?page_id=50</a></p>
<pre class="brush: bash;">
extension_dir = &quot;C:\xampp\php\ext&quot;
</pre>
<p>php.iniが上述のような場合は「C:\xampp\php\ext」にファイルを配置する。</p>
<h3>php.ini</h3>
<p>以下の設定を追加(パスは環境に合わせて変更してください)</p>
<pre class="brush: bash;">
extension=php_imagick.dll
</pre>
<p>Windowsを再起動すると使用可能になる。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/29/windows-xp%e3%81%a7php%e3%81%a8imagemagick%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>svnで以前のリビジョンに戻す</title>
		<link>http://blog.justoneplanet.info/2010/08/29/svn%e3%81%a7%e4%bb%a5%e5%89%8d%e3%81%ae%e3%83%aa%e3%83%93%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ab%e6%88%bb%e3%81%99/</link>
		<comments>http://blog.justoneplanet.info/2010/08/29/svn%e3%81%a7%e4%bb%a5%e5%89%8d%e3%81%ae%e3%83%aa%e3%83%93%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ab%e6%88%bb%e3%81%99/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 07:04:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2948</guid>
		<description><![CDATA[以下を同階層で実行。

svn merge -r 100:99 sample.txt

これでリビジョン100から99に戻る。
]]></description>
			<content:encoded><![CDATA[<p>以下を同階層で実行。</p>
<pre class="brush: bash;">
svn merge -r 100:99 sample.txt
</pre>
<p>これでリビジョン100から99に戻る。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/29/svn%e3%81%a7%e4%bb%a5%e5%89%8d%e3%81%ae%e3%83%aa%e3%83%93%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ab%e6%88%bb%e3%81%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでアプリを作ってみる</title>
		<link>http://blog.justoneplanet.info/2010/08/24/android%e3%81%a7%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/24/android%e3%81%a7%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:07:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2941</guid>
		<description><![CDATA[今回のアプリはandroid marketで公開した「prime?」という名のアプリの全てのソースコードである。 ■AndroidManifest.xml 今回はActivityを2つ使用するので、以下のようにactivity要素を加えないとアプリから使用できない。 &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;manifest xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34; package=&#34;info.justoneplanet.android.primenumber&#34; android:versionCode=&#34;2&#34; android:versionName=&#34;0.2&#34;&#62; &#60;application android:icon=&#34;@drawable/icon&#34; android:label=&#34;@string/app_name&#34;&#62; &#60;activity android:name=&#34;.PrimeNumberActivity&#34; android:label=&#34;@string/app_name&#34;&#62; &#60;intent-filter&#62; &#60;action android:name=&#34;android.intent.action.MAIN&#34; /&#62; &#60;category android:name=&#34;android.intent.category.LAUNCHER&#34; /&#62; &#60;/intent-filter&#62; &#60;/activity&#62; &#60;activity android:name=&#34;.PrimeNumberListActivity&#34; android:label=&#34;@string/app_name_list&#34;&#62; &#60;/activity&#62; &#60;/application&#62; &#60;uses-sdk android:minSdkVersion=&#34;3&#34; /&#62; &#60;/manifest&#62; ■アクティビティ1 /src/info/justoneplanet/android/primenumber/PrimeNumberActivity.java まず、初めに表示されるActivityを実装する。 package info.justoneplanet.android.primenumber; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; [...]]]></description>
			<content:encoded><![CDATA[<p>今回のアプリはandroid marketで公開した「prime?」という名のアプリの全てのソースコードである。</p>
<h3>■AndroidManifest.xml</h3>
<p>今回はActivityを2つ使用するので、以下のようにactivity要素を加えないとアプリから使用できない。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;info.justoneplanet.android.primenumber&quot;
      android:versionCode=&quot;2&quot;
      android:versionName=&quot;0.2&quot;&gt;
    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.PrimeNumberActivity&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name=&quot;.PrimeNumberListActivity&quot;
                  android:label=&quot;@string/app_name_list&quot;&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
    &lt;uses-sdk android:minSdkVersion=&quot;3&quot; /&gt;
&lt;/manifest&gt;
</pre>
<h3>■アクティビティ1</h3>
<h4>/src/info/justoneplanet/android/primenumber/PrimeNumberActivity.java</h4>
<p>まず、初めに表示されるActivityを実装する。</p>
<pre class="brush: java;">
package info.justoneplanet.android.primenumber;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class PrimeNumberActivity extends Activity {
    private static final int MENU1_ID = Menu.FIRST;
    private static final int MENU2_ID = Menu.FIRST + 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);// こいつでレイアウトのxmlを指定！

        Button validate = (Button) findViewById(R.id.button_validate);
        validate.setOnClickListener(// これがイベントだ！なんかコード量多し。
            new View.OnClickListener() {
                public void onClick(View v) {
                    TextView textView = (TextView) findViewById(R.id.result);
                    EditText editText = (EditText) findViewById(R.id.number);
                    Integer number = Integer.valueOf(editText.getText().toString());
                    int num = _isPrime(number, textView);
                    if(num == 0){
                        textView.setText(&quot;Prime!!&quot;);
                    }
                    else if(num &lt; 0){
                        textView.setText(&quot;Not Prime!!&quot;);
                    }
                    else{
                        String str = Integer.toString(num);
                        textView.setText(&quot;Not Prime!! It will be divided by '&quot; + str + &quot;'&quot;);
                    }
                }
            }
        );
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        // メニューを押したとき
        boolean result = super.onCreateOptionsMenu(menu);
        menu.add(0, MENU1_ID, Menu.NONE, R.string.menu2);
        return result;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        // メニューが選択されたとき
        switch(item.getItemId()){
        case MENU1_ID:
            //Log.e(&quot;tag&quot;, &quot;start&quot;);
            startActivity(new Intent(this, PrimeNumberListActivity.class));
            finish();
            return true;
        }
        return false;
    }

    /**
     *_isPrime
     * @param number
     * @return
     */
    private int _isPrime(Integer number, TextView textView)
    {
        if(number &lt; 2){
            return -1;
        }
        for(int i = 2; i &lt; number / 2 + 1; i++){
            textView.setText(Integer.toString(i));
            if(number % i == 0){
                return i;
            }
        }
        return 0;
    }
}
</pre>
<h4>/res/layout/main.xml</h4>
<p>上述のActivityのレイアウトを定義する。ボタンが上にあると押しにくいので下に配置した。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
&lt;TextView
    android:id=&quot;@+id/result&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:text=&quot;@string/msg_title_input&quot;
    android:textSize=&quot;16dip&quot;
    /&gt;
    &lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;fill_parent&quot;
        android:gravity=&quot;bottom&quot;
        &gt;
    &lt;EditText
        android:id=&quot;@+id/number&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:paddingBottom=&quot;10dip&quot;
        android:inputType=&quot;number&quot;
        android:textSize=&quot;26dip&quot;
        android:maxLength=&quot;7&quot;
        /&gt;
    &lt;Button
        android:id=&quot;@+id/button_validate&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/button_validate&quot;
        /&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</pre>
<h3>■/src/info/justoneplanet/android/primenumber/PrimeNumberListActivity.java</h3>
<p>まず、次のActivityを実装する。せっかくだからListActivityを継承する。</p>
<pre class="brush: java;">
package info.justoneplanet.android.primenumber;

import java.util.ArrayList;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Layout;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class PrimeNumberListActivity extends ListActivity {
    private static final int MENU1_ID = Menu.FIRST;
    private static final int MENU2_ID = Menu.FIRST + 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);

        // 配列を生成
        ArrayList&lt;String&gt; numbers = new ArrayList&lt;String&gt;();
        for(int i = 0; i &lt; 100; i++){
            numbers.add(Integer.toString(i));
        }
        // 生成した配列をリストの各要素にassign
        setListAdapter(new ArrayAdapter&lt;String&gt;(
            getApplicationContext(),
            R.layout.list_row,
            numbers
        ));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        boolean result = super.onCreateOptionsMenu(menu);
        menu.add(0, MENU1_ID, Menu.NONE, R.string.menu1);
        return result;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        switch(item.getItemId()){
        case MENU1_ID:
            startActivity(new Intent(this, PrimeNumberActivity.class));
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {
        // リストがクリックされたとき
        super.onListItemClick(l, v, position, id);
        TextView textView = (TextView) findViewById(R.id.result);
        Integer strItem = Integer.valueOf((String) getListAdapter().getItem(position));
        int num = _isPrime(strItem, textView);
        if(num == 0){
            textView.setText(&quot;Prime!!&quot;);
        }
        else if(num &lt; 0){
            textView.setText(&quot;Not Prime!!&quot;);
        }
        else{
            String str = Integer.toString(num);
            textView.setText(&quot;Not Prime!! It will be divided by '&quot; + str + &quot;'&quot;);
        }
    }

    /**
     *_isPrime
     * @param number
     * @return
     */
    private int _isPrime(Integer number, TextView textView)
    {
        if(number &lt; 2){
            return -1;
        }
        for(int i = 2; i &lt; number / 2 + 1; i++){
            textView.setText(Integer.toString(i));
            if(number % i == 0){
                return i;
            }
        }
        return 0;
    }
}
</pre>
<p>まぁ、ツッコミどころは沢山あるがとりあえず。</p>
<h4>/res/layout/list.xml</h4>
<p>上述のActivityのレイアウトを定義する。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
&lt;TextView
    android:id=&quot;@+id/result&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:text=&quot;@string/msg_title_select&quot;
    android:textSize=&quot;16dip&quot;
    /&gt;
&lt;ListView
    android:id=&quot;@id/android:list&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    /&gt;
&lt;TextView
    android:id=&quot;@+id/android:empty&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:text=&quot;@string/msg_title_select&quot;
    android:textSize=&quot;20dip&quot;
    /&gt;
    &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
       android:id=&quot;@+id/buttons&quot;
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        &gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</pre>
<h4>/res/layout/list_row.xml</h4>
<p>ListActivityを使用した場合はリストの行のレイアウトを定義する必要がある。文字が小さいとリストが選択しにくいので大きめサイズだ~</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;TextView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:gravity=&quot;center&quot;
    android:textSize=&quot;24dip&quot;
    android:text=&quot;@string/msg_title_select&quot;
    /&gt;
</pre>
<h3>■/res/values/strings.xml</h3>
<p>多言語対応できるように文字は以下のファイルに記述するべきだ。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;
    &lt;string name=&quot;app_name&quot;&gt;prime number&lt;/string&gt;
    &lt;string name=&quot;app_name_list&quot;&gt;prime number list&lt;/string&gt;
    &lt;string name=&quot;msg_title_input&quot;&gt;Input a number!&lt;/string&gt;
    &lt;string name=&quot;msg_title_select&quot;&gt;Select a number!&lt;/string&gt;
    &lt;string name=&quot;button_validate&quot;&gt;Validate&lt;/string&gt;
    &lt;string name=&quot;result_prime&quot;&gt;Prime!&lt;/string&gt;
    &lt;string name=&quot;result_notprime&quot;&gt;Not Prime!&lt;/string&gt;
    &lt;string name=&quot;menu1&quot;&gt;Input&lt;/string&gt;
    &lt;string name=&quot;menu2&quot;&gt;List&lt;/string&gt;
&lt;/resources&gt;
</pre>
<p>今回はコードにも書いちゃってるけど気にしない♪</p>
<h3>■/res/layout/main.xml</h3>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
&lt;TextView
    android:id=&quot;@+id/result&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:text=&quot;@string/msg_title_input&quot;
    android:textSize=&quot;16dip&quot;
    /&gt;
    &lt;LinearLayout
        android:orientation=&quot;vertical&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;fill_parent&quot;
        android:gravity=&quot;bottom&quot;
        &gt;
    &lt;EditText
        android:id=&quot;@+id/number&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:paddingBottom=&quot;10dip&quot;
        android:inputType=&quot;number&quot;
        android:textSize=&quot;26dip&quot;
        android:maxLength=&quot;7&quot;
        /&gt;
    &lt;Button
        android:id=&quot;@+id/button_validate&quot;
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/button_validate&quot;
        /&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</pre>
<p>Activityは画面だ★</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/24/android%e3%81%a7%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSにSubversionをインストールする</title>
		<link>http://blog.justoneplanet.info/2010/08/22/centos%e3%81%absubversion%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/22/centos%e3%81%absubversion%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 11:31:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2939</guid>
		<description><![CDATA[■インストール
yumでサクッとインストールだ！

yum install subversion

■リポジトリの作成
以下のようにするとhogeディレクトリが生成される。

mkdir -p /home/svn/rep [...]]]></description>
			<content:encoded><![CDATA[<h3>■インストール</h3>
<p>yumでサクッとインストールだ！</p>
<pre class="brush: bash;">
yum install subversion
</pre>
<h3>■リポジトリの作成</h3>
<p>以下のようにするとhogeディレクトリが生成される。</p>
<pre class="brush: bash;">
mkdir -p /home/svn/repos/
cd /home/svn/repos/
mkdir hoge
svnadmin create hoge
</pre>
<p>adminユーザでコミットするなら以下のようにしておく。。。</p>
<pre class="brush: bash;">
chown -R admin:admin hoge
chmod -R 0700 hoge
</pre>
<p>複数ユーザがコミットするときはグループとかで管理しないとなー</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/22/centos%e3%81%absubversion%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでActivityを複数使う</title>
		<link>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7activity%e3%82%92%e8%a4%87%e6%95%b0%e4%bd%bf%e3%81%86/</link>
		<comments>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7activity%e3%82%92%e8%a4%87%e6%95%b0%e4%bd%bf%e3%81%86/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 06:39:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2936</guid>
		<description><![CDATA[ActivityはAndroidManifest.xmlに登録しないと使えない。 &#60;activity android:name=&#34;.PrimeNumberActivity&#34; android:label=&#34;@string/app_name&#34;&#62; &#60;intent-filter&#62; &#60;action android:name=&#34;android.intent.action.MAIN&#34; /&#62; &#60;category android:name=&#34;android.intent.category.LAUNCHER&#34; /&#62; &#60;/intent-filter&#62; &#60;/activity&#62; &#60;activity android:name=&#34;.PrimeNumberListActivity&#34; android:label=&#34;@string/app_name_list&#34;&#62; &#60;/activity&#62;]]></description>
			<content:encoded><![CDATA[<p>ActivityはAndroidManifest.xmlに登録しないと使えない。</p>
<pre class="brush: xml;">
&lt;activity android:name=&quot;.PrimeNumberActivity&quot;
          android:label=&quot;@string/app_name&quot;&gt;
    &lt;intent-filter&gt;
        &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
        &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
    &lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;activity android:name=&quot;.PrimeNumberListActivity&quot;
          android:label=&quot;@string/app_name_list&quot;&gt;
&lt;/activity&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7activity%e3%82%92%e8%a4%87%e6%95%b0%e4%bd%bf%e3%81%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでListActivityを使う</title>
		<link>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7listactivity%e3%82%92%e4%bd%bf%e3%81%86/</link>
		<comments>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7listactivity%e3%82%92%e4%bd%bf%e3%81%86/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 06:36:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2934</guid>
		<description><![CDATA[以下のようにidにはandroid:を付加しないとエラーになる。

&#60;ListView
    android:id=&#34;@id/android:list&#34;
    android:layout_ [...]]]></description>
			<content:encoded><![CDATA[<p>以下のようにidにはandroid:を付加しないとエラーになる。</p>
<pre class="brush: xml;">
&lt;ListView
    android:id=&quot;@id/android:list&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    /&gt;
&lt;TextView
    android:id=&quot;@+id/android:empty&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    /&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/22/android%e3%81%a7listactivity%e3%82%92%e4%bd%bf%e3%81%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidアプリケーションを配布する</title>
		<link>http://blog.justoneplanet.info/2010/08/22/android%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e9%85%8d%e5%b8%83%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/22/android%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e9%85%8d%e5%b8%83%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 06:18:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2929</guid>
		<description><![CDATA[android marketでアプリケーションを配布するには署名などの作業が必要となる。
■自己署名の証明書作成
以下のようにkeytoolを使用する。

C:\Program Files\Java\jdk[versio [...]]]></description>
			<content:encoded><![CDATA[<p>android marketでアプリケーションを配布するには署名などの作業が必要となる。</p>
<h3>■自己署名の証明書作成</h3>
<p>以下のようにkeytoolを使用する。</p>
<pre class="brush: bash;">
C:\Program Files\Java\jdk[version]\bin&gt;keytool -genkey -keystore hoge.keystore -
alias hoge -validity 1000
</pre>
<p>以下のように任意のパスワードの入力を求められる。</p>
<pre class="brush: bash;">
キーストアのパスワードを入力してください:
新規パスワードを再入力してください:
</pre>
<p>正しく自分の名前を入力しよう。</p>
<pre class="brush: bash;">
姓名を入力してください。
  [Unknown]:  Taro Hoge
</pre>
<p>組織単位名の入力だ。</p>
<pre class="brush: bash;">
組織単位名を入力してください。
  [Unknown]:  personal
</pre>
<p>組織名の入力だ。</p>
<pre class="brush: bash;">
組織名を入力してください。
  [Unknown]:  personal
</pre>
<p>都市名の入力だ。</p>
<pre class="brush: bash;">
都市名または地域名を入力してください。
  [Unknown]:  Kawasaki
</pre>
<p>県名の入力だ。</p>
<pre class="brush: bash;">
州名または地方名を入力してください。
  [Unknown]:  Kanagawa
</pre>
<p>国名の入力だ。</p>
<pre class="brush: bash;">
この単位に該当する 2 文字の国番号を入力してください。
  [Unknown]:  jp
</pre>
<p>最後に確認。</p>
<pre class="brush: bash;">
CN=Taro Hoge, OU=personal, O=personal, L=Kawasaki, ST=Kanagawa, C=jp で
よろしいですか?
  [no]:  yes
</pre>
<p>以上で証明書が作成される。</p>
<h3>■アプリケーションパッケージへの署名</h3>
<p>以下のようにjarsignerを使用する。</p>
<pre class="brush: bash;">
cd C:\Program Files\Java\jdk[version]\bin
jarsigner -verbose -keystore hoge.keystore C:\[eclipse-work-space-path]\workspace\PrimeNumber\bin\PrimeNumber.apk hoge
</pre>
<h3>■apkファイルの最適化</h3>
<p>以下のコマンドでapkファイルを最適化できる。</p>
<pre class="brush: bash;">
cd C:\android-sdk-windows\tools\
zipalign -v 4 C:\[eclipse-work-space-path]\workspace\PrimeNumber\bin\PrimeNumber.apk C:\[eclipse-work-space-path]\workspace\PrimeNumber\bin\output.apk
</pre>
<p>アップロードするのは新しく生成されたoutput.apkである。</p>
<h3>■アップロード</h3>
<p>以下から行う。ユーザアカウントの開設は有料（$25）である。</p>
<p><a href="http://market.android.com/publish/Home">http://market.android.com/publish/Home</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/22/android%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e9%85%8d%e5%b8%83%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>contentEditableをJavaScriptで変更する際に気をつける事</title>
		<link>http://blog.justoneplanet.info/2010/08/21/contenteditable%e3%82%92javascript%e3%81%a7%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%b0%97%e3%82%92%e3%81%a4%e3%81%91%e3%82%8b%e4%ba%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/21/contenteditable%e3%82%92javascript%e3%81%a7%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%b0%97%e3%82%92%e3%81%a4%e3%81%91%e3%82%8b%e4%ba%8b/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 17:53:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2927</guid>
		<description><![CDATA[■結論
以下のように書けばブラウザに関係なく変更が可能である。

document.getElementById('editor').contentEditable = true;//firefox, chrome, o [...]]]></description>
			<content:encoded><![CDATA[<h3>■結論</h3>
<p>以下のように書けばブラウザに関係なく変更が可能である。</p>
<pre class="brush: jscript;">
document.getElementById('editor').contentEditable = true;//firefox, chrome, opera, safari, IE...OK
</pre>
<p>jQueryだと以下のようになる。</p>
<pre class="brush: jscript;">
$('div#editor').attr('contentEditable', true);//firefox, chrome, opera, safari, IE...OK
</pre>
<h3>■失敗例</h3>
<p>以下のように書くとIEでは動作しなくなる。</p>
<pre class="brush: jscript;">
$('div#editor').attr('contenteditable', true);//firefox, chrome, opera, safari...OK
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/21/contenteditable%e3%82%92javascript%e3%81%a7%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%b0%97%e3%82%92%e3%81%a4%e3%81%91%e3%82%8b%e4%ba%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Androidを久々に開発してみる</title>
		<link>http://blog.justoneplanet.info/2010/08/19/android%e3%82%92%e4%b9%85%e3%80%85%e3%81%ab%e9%96%8b%e7%99%ba%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2010/08/19/android%e3%82%92%e4%b9%85%e3%80%85%e3%81%ab%e9%96%8b%e7%99%ba%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 17:09:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2924</guid>
		<description><![CDATA[■エラー
以下の様なエラーが出る。

Error generating final archive: Debug certificate expired on 10/01/01 01:23! [application]  [...]]]></description>
			<content:encoded><![CDATA[<h3>■エラー</h3>
<p>以下の様なエラーが出る。</p>
<pre class="brush: bash;">
Error generating final archive: Debug certificate expired on 10/01/01 01:23! [application]  不明 Android Packaging Problem
</pre>
<p>デバッグ用の署名に使うkeystoreの期限切れらしい。めんどい。</p>
<h3>■対策</h3>
<p>以下のコマンドをコマンドプロンプトから入力。</p>
<pre class="brush: bash;">
C:\Program Files\Java\jdk[version]\bin\keytool -genkey -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android -dname &quot;CN=Android Debug, O=Android,C=US&quot;
</pre>
<ol>
<li>同ディレクトリにdebug.keystoreが生成されたので、それを「（vista）C:\Users\[user]\.android」「（xp）C:\Documents and Settings\[user]\.android」に移動。</li>
<li>eclipse＞プロジェクト＞クリーン</li>
</ol>
<p>以上。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/19/android%e3%82%92%e4%b9%85%e3%80%85%e3%81%ab%e9%96%8b%e7%99%ba%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPとGDでテキスト量に合わせたサイズの画像を生成する</title>
		<link>http://blog.justoneplanet.info/2010/08/19/php%e3%81%a8gd%e3%81%a7%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e9%87%8f%e3%81%ab%e5%90%88%e3%82%8f%e3%81%9b%e3%81%9f%e3%82%b5%e3%82%a4%e3%82%ba%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e7%94%9f%e6%88%90/</link>
		<comments>http://blog.justoneplanet.info/2010/08/19/php%e3%81%a8gd%e3%81%a7%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e9%87%8f%e3%81%ab%e5%90%88%e3%82%8f%e3%81%9b%e3%81%9f%e3%82%b5%e3%82%a4%e3%82%ba%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e7%94%9f%e6%88%90/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 16:04:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=2917</guid>
		<description><![CDATA[GDは意外にもやってくれる！
■ソースコード
以下のように、imagettfbbox関数によってテキストボックスのサイズが取得可能である。

&#60;?php
$text     = 'Open the door!';/ [...]]]></description>
			<content:encoded><![CDATA[<p>GDは意外にもやってくれる！</p>
<h3>■ソースコード</h3>
<p>以下のように、imagettfbbox関数によってテキストボックスのサイズが取得可能である。</p>
<pre class="brush: php;">
&lt;?php
$text     = 'Open the door!';// string
$fontSize = 30;
$font     = '/usr/share/fonts/bitstream-vera/ACaslonPro-Bold.otf';// path

$box    = imagettfbbox($fontSize, 0, $font, $text);
$img    = imagecreatetruecolor($box[2] - $box[6] + 10, $box[3] - $box[7] + 10);
$color  = imagecolorallocatealpha($img, 210, 0, 0, 255);
$backgroundColor = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagealphablending($img, true);
imagesavealpha($img, true);

imagefill($img, 0, 0, $backgroundColor);
imagettftext($img, 30, 0, 0, $box[3] - $box[7], $color, $font, $text);

header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?&gt;
</pre>
<h3>■画像</h3>
<p>こんな感じのができる！</p>
<p><a href="/wp-content/uploads/2010/08/font.png" rel="lightbox[2917]"><img src="/wp-content/uploads/2010/08/font.png" alt="font" title="font" width="263" height="51" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2010/08/19/php%e3%81%a8gd%e3%81%a7%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e9%87%8f%e3%81%ab%e5%90%88%e3%82%8f%e3%81%9b%e3%81%9f%e3%82%b5%e3%82%a4%e3%82%ba%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e7%94%9f%e6%88%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
