2009年7月29日水曜日

Google map apiのローカルドライブでの開発

file:///home/directory/gmap.htmlにアクセス
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>

//下のsrc属性にkeyパラメータがなくてもローカルドライブでは開発できる
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false"
type="text/javascript"></script>
<script type="text/javascript">

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}

</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>

2009年7月26日日曜日

GAE for Javaをターミナルで開発する (Antでコンパイル)

参考ページ 厳密にはfork属性を指定する意味を理解するのに参考にした。

build.xmlファイルがあるディレクトリに移動

デフォルトでは
$ ant compile

BUILD FAILED
/path/appengine-java-sdk-1.2.0/demos/guestbook/build.xml:39: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

Total time: 0 seconds

とエラーが出る。

  <target name="compile" depends="copyjars"
description="Compiles Java source and copies other source files to the WAR.">
<mkdir dir="war/WEB-INF/classes" />
<copy todir="war/WEB-INF/classes">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac
srcdir="src"
destdir="war/WEB-INF/classes"
classpathref="project.classpath"
debug="on"
fork="true" />
</target>
※太字の部分を追加fork属性を追加することでコンパイルが可能になった。開発サーバは毎回停止しなければいけないらしい。

2009年7月25日土曜日

環境変数のいろいろ

環境変数を追加する
例:
$ export ECLIPSE_PATH=/usr/eclipse
$ export PATH=$PATH:$ECLIPSE_PATH
$ source .bash_profile

環境変数を削除するにはunsetコマンドを使う
例:$ unset ECLIPSE_PATH

環境変数を表示するにはenv,printenvを使う。この2つがどう違うのかはまだ不明。

SuggestをjQueryで作ってみた

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
google.setOnLoadCallback(function(){
var arr = ["abc","abf","abo","b4","bce","日本語","日本","アメリカ","アフリカ","どいつ"];
var dft = -1:
$("#txt").keyup(function(e){
if(e.keyCode == 40){//下
if(dft == -1){
dft++;
$("p").eq(dft).css({backgroundColor: "#e8eefa"});
return;
}
else if(dft > -1){
var len = $("p").length;
if(dft == len)
return false;

$("p").eq(dft).css({backgroundColor: "white"});

dft++;
$("p").eq(dft).css({backgroundColor: "#e8eefa"});
return;
}
}
else if(e.keyCode == 38){//上
if(dft == 0){
$("p").eq(dft).css({backgroundColor: "white"});
dft = -1;
return;
}
else if(dft > 0){
$("p").eq(dft).css({backgroundColor: "white"});
dft = dft - 1;
$("p").eq(dft).css({backgroundColor: "#e8eefa"});
return;
}
}
else if(e.keyCode == 13){
var tex = $("p").eq(dft).text();
$("#txt").val(tex);
}
var a = $("#txt").val();
var c = "";
if (a != ""){
var bol = false;
jQuery.each(arr,function(){
if (this.indexOf(a) > -1 ){
c = "<p>"+this+"</p>" + c;
bol = true;
}//if
});//each
if(bol){
$("div").empty();
$("div").append(c);
dft = -1;
$("p").css({backgroundColor: "white"});
$("div").css({visibility: "visible"});
}
}//if
if(a == ""){
$("div").empty();
$("div").css({visibility: "hidden"});
}
});//keyup

$("#btn").click(function(){
alert(dft);
});

$("p").click(function(){
alert("a");
});
});

</script>

<style type="text/css">
div
{
width: 170px;
border-left: solid #c3d9ff 1px;
border-right: solid #c3d9ff 1px;
visibility: visible;
}
hr
{
color: #c3d9ff;
}

p
{
height: 12px;
padding-bottom: 2px;
padding-left: 2px;
font-size: 10px;
border-bottom: solid black 1px;
}
</style>
</head>
<body>
<input type="text" id="txt"/><input type="button" id="sbt" value=" send "/><br>
<div>
</div>
<input type="button" id="btn" value=" exe "/>
</body>
</html>


googleのサジェストではタイマーを使うことで確定前の文字も取得できるようにしているらしい。機会があれば同じようなのを作ってみたい。

2009年7月24日金曜日

google app engine(GAE)のデータストアについて

from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app

class DS(db.Model):
mozi = db.StringProperty()
suuji = db.IntegerProperty()

class main(webapp.RequestHandler):
def get(self):
#保存方法
ds = DS()
ds.IDE = 'last'
ds.suuji = 3
ds.put()

#読み出し方法
grts = db.GqlQuery('SELECT * FROM DS')
for grt in grts:
self.response.out.write(grt.mozi)
self.response.out.write(grt.suuji)


application = webapp.WSGIApplication([('/',main)],debug=True)

def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()

2009年7月6日月曜日

ubuntu パッケージの検索

参考ページ
$ apt-cache search [検索キーワード]

キーワードを「firefox」にしたときの検索結果:
epiphany-gecko - Intuitive GNOME web browser - Gecko version
latex-xft-fonts - Xft-compatible versions of some LaTeX fonts
mozvoikko - Finnish spell-checker extension for Firefox
openoffice.org - full-featured office productivity suite
totem-mozilla - Totem Mozilla plugin
ubufox - Ubuntu Firefox specific configuration defaults and apt support
abrowser-3.1 - dummy upgrade package for firefox-3.1 -> firefox-3.5
abrowser-3.1-branding - dummy upgrade package for firefox-3.1 -> firefox-3.5
abrowser-3.5 - meta package for the unbranded abrowser
abrowser-3.5-branding - package that ships the abrowser branding
adblock-plus - advertisement blocking extension for web browsers
all-in-one-sidebar - A sidebar extension for Mozilla Firefox
amule-gnome-support - ed2k links handling support for GNOME web browsers
aptlinex - Web browser addon to install Debian packages with a click
bleachbit - delete unnecessary files from the system
fennec - Mobile version of the Firefox browser from Mozilla
firefox-3.1 - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-branding - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-dbg - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-dev - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-gnome-support - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.5 - safe and easy web browser from Mozilla
firefox-3.5-branding - Package that ships the firefox branding
firefox-3.5-dbg - firefox-3.5 debug symbols
firefox-3.5-dev - Development files for Mozilla Firefox
firefox-3.5-gnome-support - Support for Gnome in Mozilla Firefox

firefox-greasemonkey - firefox extension that enables customization of webpages with user scripts

7月6日現在アップデートこそ行われていないがインストール可能なパッケージとしてFirefox3.5が既に存在している事が分かる。

2009年7月5日日曜日

ubuntuでapache

参考ページ
$ sudo apt-get install apache2

Webブラウザでhttp://localhost/にアクセス
$ sudo apt-get install php5 libapache2-mod-php5

インストールできているか確認する
sudo /etc/init.d/apache2 restart

PHPファイルの新規作成テスト
sudo gedit /var/www/testphp.php


PHPファイルを作成する場合 /var/www/ディレクトリ下に配置する。

ubuntuでmysql

参考ページ

・終了の仕方
mysql> exit

・SQL文の中途キャンセル \c
・SQL文の最後には「;」を入れる必要がある。
・SQL文は小文字でもOK
・$ mysql --helpでヘルプ表示

参考ページ
・MySQLの起動と停止
//起動
$ sudo /etc/init.d/mysql start
//停止
$ sudo /etc/init.d/mysql stop
その他のオプション内容
restart再起動
statusサーバーの状態を確認する
condrestartサーバが動作している確認後に、再起動

ubuntuにmysqlをインストール

$sudo apt-get install mysql-server
$mysql -u root -p
$Enter pass [パスワードを入力]

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.0.75-0ubuntu10.2 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

2009年7月3日金曜日

bash 半角空白文字を含んだ文を1つの引数として実行する

gedit abc def

二つの新規ファイルを開く

gedit "abc def"

or
gedit abc\ def

一つの新規ファイルを開く