2009年12月30日水曜日

Google Chrome Beta版でflash playerを使う

参考ページ

$ sudo mkdir /opt/google/chrome/plugins
でフォルダを作成

adobe flash playerからtar.gz形式でダウンロード

$ tar xvzf install_flash_player_*_linux.tar.gz
で解凍する。できたlibflashplayer.soを先ほど作成したpluginsに移動。

$ sudo mv libflashplayer.so /opt/google/chrome/plugins
で再起動してyahooにでも行って確認する。

2009年12月24日木曜日

Amazonアソシエイトプログラムに申し込んでみた。



サイドバーに入れようとしたけど、XMLが不適切だと拒否される。なんでなんだろうね

2009年12月13日日曜日

name属性の動的な追加に関して(Javascript)

textareaタグにname属性を動的に追加してformタグ内に埋め込んでいき、submitで送信したかった。

最初はうまく行っていたのに、スタイルをつけ始めたらなぜか動かなくなった。

調べるとformタグをdivタグで囲んでいたためだった。

出来なかった例
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>SAMPLE</title>
</head>
  <body>
    <div style="background-color: orange;">
      <form action="/xxx" method="get">
        <textarea name="xxx"></textarea>
    </div>
      
      </form>
  </body>
</html>
こうすると出来た
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>SAMPLE</title>
</head>
  <body>
    
    <form action="/xxx" method="get">
      <div style="background-color: orange;">
        <textarea name="xxx"></textarea>
      </div>
      
    </form>
  </body>
</html>

2009年11月28日土曜日

Google Closure Toolsについて

参考ページ(Getting Started with the Closure Library)
closure-library - Revision 9: /trunk/closure/goog/demos

スクリプトをheadタグ内に書くとエラーが出る。

エラーが出る場合
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Google Closure Tools Sample</title>
  <script src="closure-library-read-only/closure/goog/base.js"></script>
  <script type="text/javascript">
    //ライブラリの読み込み
    goog.require("goog.events");
    goog.require('goog.dom');
    
    //イベントリスナーの追加
    goog.events.listen(document.getElementById("btn"), "click", sayHi);                   
    
    function sayHi() {
      var newHeader = goog.dom.createDom('h1', {'style': 'background-color:#EEE'},
        'Hello world!');
      goog.dom.appendChild(document.body, newHeader);
    }
  </script>
  </head>
  <body>
    <input type="button" id="btn" value="push" />
  </body>
</html>

エラーなしに実行できる場合
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <title>Google Closure Tools Sample</title>
<script src="closure-library-read-only/closure/goog/base.js"></script>
<script type="text/javascript">
  //ライブラリの読み込み
  goog.require("goog.events");
  goog.require('goog.dom');
</script>
</head>
<body>
  <input type="button" id="btn" value="push" />
</body>
<script>
  //イベントリスナーの追加
  goog.events.listen(document.getElementById("btn"), "click", sayHi);                   

  function sayHi() {
    var newHeader = goog.dom.createDom('h1', {'style': 'background-color:#EEE'},
      'Hello world!');
    goog.dom.appendChild(document.body, newHeader);
  }
</script>
</html>

2009年11月24日火曜日

Google app engine(python)で同名のパラメータを受け取り、配列として処理する。

参考ページ

main.py
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class Sender(webapp.RequestHandler):
  def get(self):
    self.response.out.write(
    """
    <html>
      <body>
        <form action="/receive" method="get">
          <input type="checkbox" name="ch" value="checkbox1">
          <input type="checkbox" name="ch" value="check2">
          <input type="checkbox" name="ch" value="ch3">
          
          <input type="submit" value="push" />
        </form>
      </body>
    </html>
    """
    )
class Receiver(webapp.RequestHandler):
  def get(self):
    arr = self.request.GET.getall("ch")
    for s in arr:
      self.response.out.write(s)
    
application = webapp.WSGIApplication([
  ("/receive", Receiver),
  ("/", Sender)
], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

2009年11月22日日曜日

PDFをGoogle Docsで開く、Chromiumの拡張機能を作る。

参考ページ

ChromiumでPDFをどうやって開くか分からなかったので、作ったんですがAdobe Readerより軽くていい。Linux版のAdobe Readerは重すぎてやってられない。

manifest.json
{
  "name": "OpenPDF",
  "version": "0.1",
   "content_scripts": [ {
      "js": [ "background.js" ],
      "matches": [ "http://*/*", "https://*/*" ]
   } ],
  "description": "Open PDF by Google Docs",
  "background_page": "background.html",
  "permissions": ["tabs", "http://*/*", "https://*/*" ]
}
background.js
var op = {//OpenPdf
 init: function()
 {
   var anchors = document.getElementsByTagName("a");
   for(var i = 0;i < anchors.length;i++){
     if(anchors[i].href.indexOf(".pdf")!=-1 || anchors[i].href.indexOf(".PDF")!=-1){
       var link = 'http://docs.google.com/viewer?url='+anchors[i].href;
       anchors[i].href = link;
     }
   }
 }
}
op.init();//Entry Point
background.html
<html>
<head>

</head>
<body>
background
</body>
</html>

Google app engine(python)でアップローダーを作る。

参考ページ

全体的に参考ページを真似した。読んでて感動した。すごいお方もいるんだなぁ…

解決できなかったこと:
日本語のファイル名ではエラーが出る。
# -*- coding : utf-8 -*-

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

class FileStore(db.Model):
  #ほとんど使ってません。
  name = db.StringProperty()
  
  body = db.BlobProperty()
  
  mime = db.StringProperty()
  
  size = db.IntegerProperty()
  
  time = db.DateTimeProperty(auto_now_add=True)
  
  download_count = db.IntegerProperty()

class RenderMainPage(webapp.RequestHandler):
  def get(self):
    user = users.get_current_user()
    if user:
      self.response.out.write(
      """
      <html>
        <body>
          <div style="border-bottom: 1px dotted gray;">
            <nobr>
              <b>%(nickname)s</b>
              <a href='%(logout_url)s'>logout</a>
              <a href='/alldelete'>All Delete</a>
            </nobr>
          </div>
          <br>
          <div style="background-color: #ece8e3;border: 1px dotted #82c78e;padding: 3px;">
            <h4>upload</h4>
              <form action='/upload' method='post' enctype='multipart/form-data'>
                password: <input type='text' name="admin_pass" /><br>
                <input type='file' name="file" />
                <input type="submit" value="upload" />
              </form>
          </div>
          <br>
          <div style="background-color: #efebe7;padding: 3px;">
            <h3 style="text-align: center;">download</h3>
          <br>
      """ %{"nickname": user.nickname(),
            "logout_url": users.create_logout_url("/")})
    
      files = db.GqlQuery("SELECT * FROM FileStore"+
                          " ORDER BY time DESC")
      if not files:
        self.response.out.write("not upload file")
        return
      else:
        for file_data in files:
          if file_data.name:
            self.response.out.write(
            """
              <a href='/download?key=%(key)s'>%(name)s</a><br>
            """ %{"key": str(file_data.key()),
                  "name": file_data.name
                  })
      self.response.out.write(
      """
         </div>
        </body>
      </html>
      """)
    else:
      self.response.out.write(
      """
      <html>
        <body>
          <a href='%s'>Sign In</a>
        </body>
      </html>
      """ % users.create_login_url("/"))

class Uploader(webapp.RequestHandler):
  def post(self):
    if self.request.get("admin_pass") == "xxxxxxxx":#自分以外アップロードできません。
      file_data = self.request.get("file")
      upf = self.request.body_file.vars["file"]# omit upload file
      _file = FileStore()
      
      _file.name = upf.filename
      _file.body = db.Blob(file_data)
      _file.mime = upf.headers["content-type"]
      _file.size = len(_file.body)
      _file.download_count = 0
      _file.put()
      
      self.redirect("../")
    else:
      self.redirect("../")
      
class Downloader(webapp.RequestHandler):#知識がない分、ここが一番参考になった。
  def get(self):
    _file = FileStore.get(self.request.get("key"))
    #アップローダを作るとき重要となる部分.
    self.response.headers["Content-Type"] = "application/octet-stream"#このContent-Typeが必要。
    content_disposition = 'attachment; filename="%s"' % str(_file.name)
    self.response.headers["Content-Disposition"] = content_disposition #これも必須
      
    self.response.out.write(_file.body) #バイナリの書き出し

class AllDelete(webapp.RequestHandler):#テストを手っ取り早くするためもの。データストアを全削除する。
  def get(self):
    file_list = db.GqlQuery("SELECT * FROM FileStore")
    for _file in file_list:
      _file.delete()
      
    self.redirect("../")  
    
application = webapp.WSGIApplication([
  ("/", RenderMainPage),
  ("/upload", Uploader),
  ("/download", Downloader),
  ("/alldelete", AllDelete)
], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

2009年11月21日土曜日

Google App Engine(python)でUserAgentを取得する方法

参考ページ

webobのRequestオブジェクトに関して調べた。

サンプルコード
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class Receiver(webapp.RequestHandler):
  def get(self):
    self.response.out.write(
    """
    <html>
      <body>
        <b>%s</b>
      </body>
    </html>
    """ % self.request.user_agent)
    
    
application = webapp.WSGIApplication([
  ("/", Receiver)
], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

http://localhost:8080/にアクセスすると表示される

ChromeOSを試す

ビルドしようとしたら"mbr.image"が作成されず、OSが起動できないというエラーで挫折した。

TechCrunchでBitTorrentでVirtualBox用のvmdkファイルを配布しているという記事を見つけたので、それをダウンロードしてVirtualBox OSEで試した。

感想としては、起動の早い「ウェブブラウザ」だった。

確かにウェブアプリケーションで多くのことをまかなうというのは効率的かもしれないけど、もっとクライアント側のアプリケーションを強化しないと、さすがに自由度が低すぎるんじゃないだろうかと思った。

追記:
ビルドの参考にしたサイト

ビルド中に各項目でかかった大まかな時間。
 6:30 gclient sync開始
 6:55 終了
 6:58 ./make_local_repo.sh開始
 7:30 終了
 7:31 ./make_chroot.sh開始
 7:40 終了
 7:50 ./build_platform_packages.sh開始
 7:57 終了
 7:59./build_kernal.sh開始
 8:31 終了
 8:33 ./build_image.sh開始
 8:37 終了

unzipで文字化けが起こらないように解凍する

$ unzip -hでヘルプを参照

1回ためして起こらなかっただけなので、絶対というわけではないが
$ unzip -O sjis ****.zip
で、オプションなしでは文字化けを起こしたファイルを起こさず解凍できた。

2009年11月20日金曜日

Chrome OSの初プレビューを動画で見る

Google OS Fast Boot
Demonstration Google Chrome OS
Video demo of Google Chrome OS, Taken At Mountain View Debut

「Google OS Fast Boot」 はChrome OSの起動が従来のOSと比較してどう違うかを説明している。終盤にちょっとだけ実際の起動場面を見ることができる。

「Demonstration Google Chrome OS」 は実際にChrome OSを動かしつつ説明している。「Video demo of Google Chrome OS, Taken At Mountain View Debut」 は起動している場面と前フリで開発者がいろいろ話している場面を見れる。

英語なので雰囲気でしか分からない。

2009年11月17日火曜日

google app engine(python)のfavicon.icoについて

参考ページ


- url: /favicon.ico
  static_files: favicon.png
  upload: favicon.ico


拡張子を.icoに設定する必要はない。

ubuntu 9.10でgoogle app engine(python)の開発を行う。

python2.5のインストール
$ sudo apt-get install python2.5

テスト:
ディレクトリに移動
$ cd google_appengine/demos

サーバー起動:
$ python2.5 ../dev_appserver.py guestbook/

たぶん動く。

google-app-engine-samplesのサンプルを参考にできる。

2009年11月15日日曜日

HTML, CSSに関する学んだことは一つにまとめようと思う。

タイトルの横にあるやつを作る(HTML)
IT戦記さんのCSSをWebInspectorで解析した。
div{
border-left: 0.4em solid #F90;
padding-top: 15px;
/* padding-topで大きさを調節 */
}
h3{
}
<body>
<div>
<h3>参考ページ</h3>
</div>
</body>


個人的に好きなボーダーのCSS
reference page(WebInspector)
border-color: #BABABA;
border-style: dotted;
border-width: 2px 0px;

コマンドに関して

参考ページ

下位ディレクトリもまとめて作成する
$ mkdir -p ***
下位ディレクトリもまとめて削除する
$ rmdir -p ***

2009年11月6日金曜日

ubuntu 9.10でマウスでワークスペースを切り替える

参考ページ1
参考ページ2

$ sudo apt-get install compizconfig-settings-manager


[システム] → [設定] → [CompizConfig設定マネージャ]

[ビューボートスイッチャー] → [デスクトップ上でのビューポート切り替え]
  次へ移動 Button4
前へ移動 Button5
に設定する。

2009年11月4日水曜日

Ubuntu 9.10にChromiumをインストールする

/etc/apt/sources.listに追記
$ echo "deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main" >> /etc/apt/sources.list
$ echo "deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main" >> /etc/apt/sources.list

ubuntu 9.10以降ならこんな感じでやってもいいらしい。
#after ubuntu 9.10
$ sudo add-apt-repository ppa:chromium-daily

アップデート
$ sudo apt-get update

chromium, WebInspectorのインストールと日本語化を同時にやる
$ sudo apt-get install chromium-browser chromium-browser-l10n chromium-browser-inspector

Ubuntu Netbook Remix(UNR) 9.10の無線LAN使用について

参考ページ

インストールしただけではなぜか無線LANのドライバが入っておらず、インストールもできなかった。

参考ページを参考にして
$ sudo apt-get install bcmwl-kernel-source (元々、インストールされていなかったので)

[システム] → [ハードウェア・ドライバ]で 「STA」の方を選択して有功にして再起動

なぜか、プロキシで接続にしておかないと無線LANがつながらないので
[システム] → [ネットワークのプロキシ] で 「マニュアルでプロキシの設定を行う」をクリック

ディスプレイ上のアイコンをクリックしてアクセスポイントを選択してつなげる

追記:我が家にルータがやってきてからプロキシにしておかなくてもつながるようになった。

2009年10月20日火曜日

2009年10月13日火曜日

Androidをターミナルで開発する(アプリケーションの開発)

参考サイト(英語)

ソースを書き直して動かそうとすると「INSTALL_FAILED_ALREADY_EXISTS」という警告が出る。
$ant reinstall
とすると正常にインストールが完了する。

ChromeOSのソースコードが公開されたという記事を見つけた。

参考サイト:SEO-LPO.net

/buildbot/snapshots/chromium-rel-linux-chromeosにある最新のディレクトリからchrome-linux.zipを試しにダウンロードしてみる。

サイズは139MB。解凍して543MB。かなりデカい。

解凍したディレクトリをのぞくとgoogle-chrome, chromium-browserとそれほど変わりない構成。

chromeの実行ファイルが532MBもある。これを実行すると少しかっこいいgoogle chromeブラウザが起動する。

オプションにはOSっぽいメニューが追加されている。(タッチパッドの感度とか)

今渡こそ偽者じゃありませんように。

2009年10月12日月曜日

Androidをターミナルで開発する(HelloWorldのインストール)

付属のドキュメントを参考に試した。

androidのツールをインストールしておいた方が効率いいのでインストールをする
$ gedit ~/.bashrc
最終行に下記を追加
export ANDROID_HOME=~/xxx/android-sdk-_x86-/tools
export PATH=$PATH:$ANDROID_HOME

前に作ったディレクトリに移動

適当にjavaファイルを作成
HelloWorld.java
package com.example.myapp;

import android.app.Activity;
import android.os.Bundle;

public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}


HelloWorld.javaをsrcディレクトリにパッケージに従って配置。

antを使ってビルドする
$ ant debug
※環境変数$JAVA_HOMEを適切に設定しておかない警告が出る。
追記:ant installと入力するとインストールを自動でしてくれる。

成功したら
$ emulator -avd MyFirstApp
でエミュレータを起動。

別にターミナル起動、作業しているディレクトリに移動。
$ adb install bin/MyFirstApp-debug.apk
を実行。

エミュレータ内のAndroidのタブをクリックしてアプリケーションの一覧を表示。一覧の中にMyFirstAppという項目があること確認。クリックして実行し、文字列が出てこれば成功。

もし、一覧に無かったり、クリックしても実行されない場合、エミュレータを再起動。

Androidを端末で開発する

ダウンロードしたSDKに入っていたドキュメントを参考に試した。

解凍してできたディレクトリ直下のtools/ディレクトリに移動

プロジェクトの作成
$./android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid

AVD(アンドロイド仮想デバイス)の作成
$./android create avd --name MyAndroidApp --target 1

エミュレータの起動
$./emulator -avd MyAndroidApp

トラブルを恐れずに気長に待つ

2009年10月11日日曜日

ChromiumでlocalStorageを動かす方法ChromiumではlocalStorageがどうにも動かない

参考ページ
端末からの起動オプションに「--enable-local-storage」をつける
$ chromium-browser --enable-local-storage
  window.addEventListener("click", function(){
localStorage.key1 = "value1";
alert(localStorage["key1"]);
}, true);


原文:In the current dev release there is no support for events nor for quotas. Event support should land by 9/30, with quotas landing by 10/9. The goal is to remove the flag by mid October on dev channel, and include this feature in the 4.0 launch.
和訳:9/23/2009現在、開発版ではevent,quotasはサポートしていない。eventは9/30,quotasは10/9頃にサポートされ、10月中旬には起動フラグがなくなる。(ここから確信が無い)これらの変更はversion4.0以降にも含まれる。

もうちょっと待つとデフォルトでlocalStorage使えるようになる(予定)ということだろうか。

FirefoxのlocalStorage的なやつで気分転換する。
参考ページ
最新版を使っていれば本物のlocalStorageを使えるみたいだがFirefox3.5でないのでこちらで我慢する。
var ls = {
init: function(){
window.addEventListener("load", function(){
globalStorage['localhost'].visits =
parseInt( globalStorage['localhost'].visits || 0 ) + 1;
alert(globalStorage['localhost'].visits);
}, true);
}
}

ls.init();

Chromiumが悪いのかWebkitが悪いのかどちらなんだろうか?

2009年10月8日木曜日

for文を使用してaddEventListenerを割り当てる(javascript)

参考ページ
    var handlers = document.getElementsByTagName("a");
for(var i = 0;i < handlers.length;i++){
handlers[i].addEventListener("click", function(event){
foo(event.target);//クリックしたelementをfoo関数に渡す
}, true);
}

どうやらこれで動いているんだけど、本当にこれで正しいのかはまだ分からない。

2009年10月1日木曜日

Chromiumの拡張機能(Backround Pagesの最小構成)

Chromiumのサイト(Extensionsのところ)
技術評論社のGoogleChrome拡張機能に関する連載
AutoPagerize For Chromeのページ
Chromiumのサイト(Extensionsのサンプルのところ)の「Subscribe in Feed Reader」のソースコード

manifest.json
{
"name": "My First Extension",
"version": "1.0",
"content_scripts": [ {
"js": [ "jquery-1.3.2.js", "background.js" ],//ちなみにjqueryも使うことが出来る。
"matches": [ "http://*/*", "https://*/*" ]
} ],
"description": "The first extension that I made.",
"background_page": "background.html",
"run_at": "document-start"//これは無くてもいい
}
background.js
window.addEventListener("click", callFunc);

function callFunc(){
chrome.extension.connect().postMessage();
}
background.html
<html>
<head>
<script>
chrome.extension.onConnect.addListener(function(port){
window.open("helloworld.html");
});
</script>
</head>
<body>
background
</body>
</html>
helloworld.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<title>TEMPLATE</title>
</head>
<body>
<h1>HELLO WORLD!!</h1>
</body>
</html>

2009年9月30日水曜日

chromiumの(中途半端な)日本語化とDevloperToolsの導入

参考ページ

日本語化
$sudo apt-get install chromium-browser-l10n
 ※文字フォントがおかしくなるため、インストール後手動で設定する必要があった。また、日本語化しきれていない部分が随所にある。

Developer Toolsのインストール
$sudo apt-get install chromium-browser-inspector
 ※FirefoxでいうところのFirebugみたいなもの。比較対象がないため、良いのか悪いのか分からない。

2009年9月28日月曜日

Chrome OSをUSBメモリにインストールする

LiveCDを起動し、インストールを始める。USBメモリはあらかじめアンマウントしておく。

インストールの作業はUbuntuに似ており、Ubuntuをインストールしたことがあるなら難なく行える。ただし、どんな不具合があるか分からないのでHDDは外しておいた方が無難な感じ。

時間を計測していないが、インストール作業自体は30~40分くらい。

使ってみた印象としては、まだまだ使い物にはならないという感じ。期待して使うとかなりガッカリする。っていうかこれホントにChrome OSなのかな?何か騙されている気がする。


参考ページによるとFakeだそうです。確信は無いけど、そっちの方が確率高い気がする。

Google Chrome OS Betaがダウンロード可能になったので試してみる。

参考ページ

手順は大まかに
 1.isoイメージのダウンロード
 2.LiveCDの作成
 3.HDDを抜いておく
 4.LiveCDの起動
 5.USB(4GB)にインストール
で順調に進んでくれればいいなと思っている。特に工程の5が。

2009年9月25日金曜日

boost c++のインストール(UNRでの場合)

boost c++のダウンロード

解凍してディレクトリに入る

$ ./bootstrap.sh --prefix=/usr/ --with-libraries=all
$ sudo ./bjam install

/usr/includeにboostというディレクトリが作成され、/usr/libにlibboost_regex.aのようなboost関係の静的ライブラリが作られる。

環境変数に
 CPLUS_INCLUDE_PATH=/usr/include
 LD_LIBRARY_PATH=/usr/lib
を追加

2009年9月10日木曜日

Chromiumの拡張機能について

参考ページ

9月10日。どうやら拡張機能のAPIの準備が整ったようだ。ただし、冒頭にこんな文がある。

原文:This tutorial requires Windows. You can try it on Linux and OS X, and it might work, but the extensions support is less stable on those platforms. We're working hard to bring them up to speed.

訳:このチュートリアルはWindows向けです。Linux,Macでは、もしかしたら何とかできるかもしれませんが、基本まだ無理です。できるようになるように頑張ってます。

頑張ってください。期待して待ってます。

2009年9月9日水曜日

GAE/Jでのformについて

  <form action="/write" method="post" enctype="multipart/form-data">
<input type="text" name="userid" />
<input type="submit" value="push" />
</form>

enctypeでスラッシュを使うとなぜかrequest.getParameter("○○○");でデータの取得が出来ない。
  <form action="/write" method="post" enctype="multipart-form-data">
<input type="text" name="userid" />
<input type="submit" value="push" />
</form>

enctypeでハイフンを使うとrequest.getParameter("○○○");でデータの取得ができる。

何でなんだろうか?

2009年8月23日日曜日

GAE/Jでアップロードした画像をデータストアに保存し、imgタグに出力する

upload.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>TEMPLATE</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
アップロードするファイル : <input type="file" name="imgfile" /><br>
<input type="submit" value="upload" />
</form>
<img src="/indication" alt="imgfile" />
</body>
</html>
UploadTest.javaにアップロードしたファイルをPostリクエストで送信
package org.test;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import java.util.logging.Logger;

import javax.jdo.PersistenceManager;
import org.test.DataStImg;
import org.test.PMF;

public class UploadTest extends HttpServlet {
private static final Logger log =
Logger.getLogger(UploadTest.class.getName());

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

PersistenceManager pm = PMF.get().getPersistenceManager();
final int size = 50000;
try{
ServletFileUpload upload = new ServletFileUpload();
upload.setSizeMax(size);//50KBの制限

FileItemIterator iterator = upload.getItemIterator(req);
while (iterator.hasNext()) {
FileItemStream item = iterator.next();
InputStream stream = item.openStream();

if(item.isFormField()){
log.warning("Got a form field: " + item.getFieldName());
} else {
log.warning("Got an uploaded file: " + item.getFieldName() +
", name = " + item.getName());
//ここからが大変だった。
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
int i = 0;
byte[] buffer = new byte[1024];
while( (len = stream.read(buffer, 0, buffer.length)) != -1){
out.write(buffer, 0, len);

}
byte[] b = out.toByteArray();

//直す気力ないけどファイル名を取得して
//contentに入れればファイル名をキーに画像を呼び出せる。
String content = "content";
DataStImg ds = new DataStImg(content, b);
pm.makePersistent(ds);
pm.close();

resp.sendRedirect("/html/upload.html");
}
}
}
catch(Exception ex){
throw new ServletException(ex);
}
}
}
package org.test;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DataStImg {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;

@Persistent
private Blob blob;

@Persistent
private String content;

public DataStImg(String content, byte[] buffer) {
blob = new Blob(buffer);
this.content = content;
System.out.println("In DataStImg");
}

public Long getId() {
return id;
}

public byte[] getImg() {
return blob.getBytes();
}

public String getContent() {
return content;
}

public void setImg(byte[] buffer) {

this.blob = blob;
}

public void setContent(String content) {
this.content = content;
}

}
Google app engineのFAQのところにあったコードを参考に作成。DataStImg.javaに画像データを保存し、再びupload.htmlにリダイレクト。imgタグsrc属性にservletを呼び出すためのURLを指定しておく。IndicationImg.javaにGETリクエストが送信される。
package org.test;

import java.util.List;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.jdo.PersistenceManager;
import org.test.DataStImg;
import org.test.PMF;

public class IndicationImg extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
resp.setContentType("image/png");
PersistenceManager pm = PMF.get().getPersistenceManager();

try {
String query = "select from " + DataStImg.class.getName();
List dss = (List) pm.newQuery(query).execute();
if (dss.isEmpty()) {
resp.sendRedirect("/html/upload.html");
} else {
for (DataStImg ds : dss) {
byte[] b = ds.getImg();
BufferedInputStream in = new BufferedInputStream(
new ByteArrayInputStream(b));

ServletOutputStream out = resp.getOutputStream();
int len;
while( (len = in.read(b, 0, b.length)) != -1) {
out.write(b, 0, len);
}

out.close();
in.close();
//まずは何番目の画像とか細かいこと考えず、
//とにかく最初に入れた画像を表示する
break;
}
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
pm.close();
}
}
}
これで画像が表示される。

2009年8月22日土曜日

GAE/Jでのファイルアップロードについて

参考ページ(参考にしたソースコード)
参考ページ(使用できるフレームワークについての情報)
参考ページ(Apache Commons FileUploadについて)から1.2.1.tar.gzをダウンロードし、解凍。
できたフォルダから/commons-fileupload-1.2.1/lib/commons-fileupload-1.2.1.jarを/google/appengine/mydirectory/war/WEB-INF/lib/にコピー。
UploadTest.java
package org.test;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import java.util.logging.Logger;


public class UploadTest extends HttpServlet {
private static final Logger log =
Logger.getLogger(UploadTest.class.getName());

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try{
ServletFileUpload upload = new ServletFileUpload();
resp.setContentType("image/png");

FileItemIterator iterator = upload.getItemIterator(req);
while (iterator.hasNext()) {
FileItemStream item = iterator.next();
InputStream stream = item.openStream();

if(item.isFormField()){
log.warning("Got a form field: " + item.getFieldName());
} else {
log.warning("Got an uploaded file: " + item.getFieldName() +
", name = " + item.getName());
int len;
byte[] buffer = new byte[8192];
while((len = stream.read(buffer, 0, buffer.length)) != -1){
resp.getOutputStream().write(buffer, 0, len);
}
}
}
}
catch(Exception ex){
throw new ServletException(ex);
}
}
}
upload.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Upload</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
アップロードするファイル : <input type="file" name="imgfile" /><br>
<input type="submit" value="upload" />
</form>
</body>
</html>

2009年8月11日火曜日

chromiumをUSBブートのlxubuntuで使用してみて

Firefoxと比較して圧倒的に起動・動作共に早い。ただし、かなり不安定ではある。特にGoogleのサービスを使用しようとログインを試みると高頻度で落ちる。異常な終了をした場合、前のセッションを復元する機能があるため大きな問題になることはなかった。

少なくとも、USBブートをしている限りはFirefoxより圧倒的にパフォーマンスは良い。セキュリティに関する部分は間情報が少なく未知数で、情報が出揃ってくるまでは危ないサイトにはいかないようにすべき。

拡張機能は現段階では使用不能?

2009年8月10日月曜日

GAE/Jの間違いやすい?部分

参考ページ
参考ページ2
ここで詰まるのは少数派かもしれないがHttpURLConnectionクラスでリクエストを行うと日本語が文字化けを起こす。具体的にはPostRequest.java からのリクエストです→PostRequest.java???????????となってしまう。私は
package org.test;

import java.net.*;
import java.io.*;
import javax.servlet.http.*;

public class PostRequest extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();

URL url = new URL("http://localhost:8080/html/index.html");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("GET");

OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.close();

if(connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
resp.setContentType("text/html;charset=UTF-8");
String line;
while( (line = reader.readLine()) != null ) {
out.println(line);
}
reader.close();
} else {
resp.setContentType("text/html;charset=UTF-8");
out.println("error");
}
}
}
のように書いていたが太字の部分をPrintWriter out = resp.getWriter();の上に書かなければならない。
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
//以下ほとんど同文


/html/index.html
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>PostRequest.javaからのリクエスト</title>

</head>
<body>
<p>PostRequest.java からのリクエストです</p>
</body>
</html>

2009年8月4日火曜日

Protocol Buffersについて勉強をする

参考ページ
JavaでProtocolBuffersを扱うにはソースコードからビルドする必要がある。基本的な手順は参考ページに書いてあるが細かいところでトラブルが起き、意外と手間がかかる。

作業ディレクトリについて
「ソースコードのルートディレクトリ/java」に移動と書いてあるがどれがそれなのか分かりにくい。ソースコードのルートディレクトリってどれ?ってことになる。
protobuf-*/javaディレクトリで作業を行う必要がある。

Java用ランタイムライブラリをビルドするときの注意点
OpenJDKではビルドエラーが発生してしまうため、環境変数JAVA_HOMEを適切なものにするために~/.bash_profileを

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.14/jre
export PAHT=$PATH:$JAVA_HOME
と編集し、
$ source ~/.bash_profile

とコマンドを実行

2009年8月3日月曜日

Protocol Buffersについて勉強

参考ページ
主にJavaについて参考にさせていただきました。あと、付属のサンプルも。

現時点で正直あんまり理解できていないがサンプルなどから推測するにあるデータがどのような構成になっているかを表現しているんじゃないかと思う。

//多分、違うのだろうから正解が分かったらちゃんと削除するようにしてください。

2009年8月1日土曜日

GAE for Javaをターミナルで開発する(AntによるJDOの初期設定について)

参考ページ
これによるとJDOを使用するのにantを用いる必要がある。
build.xmlファイルに
  <target name="datanucleusenhance" depends="compile"
description="Performs JDO enhancement on compiled data classes.">
<enhance_war war="war" />
</target>
を追加する必要があるがnew_project_templateからコピーし、作成したプロジェクトではこれだけではいけない。
$ ant datanucleusenhance
 
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Buildfile: build.xml

compile:

datanucleusenhance:

BUILD FAILED
/home/something/gcode/appengine-java-sdk-1.2.0/demos/New_Project/build.xml:83: The following error occurred while executing this line:
/home/something/gcode/appengine-java-sdk-1.2.0/config/user/ant-macros.xml:94: /home/something/gcode/appengine-java-sdk-1.2.0/demos/New_Project/war/WEB-INF/classes not found.

Total time: 0 seconds
というエラーが出る
そのため
  <target name="datanucleusenhance" depends="compile"
description="Performs JDO enhancement on compiled data classes.">
<enhance_war war="${war.dir}" />
</target>
と太字の部分を変更する必要がある。

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

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

2009年6月20日土曜日

bashにおける戻り値の利用方法

#!/bin/bash
VAR1=`ls`
echo ${VAR1}
echo "\n"
VAR2=$(ls)
echo ${VAR2}

SMTPによるファイル送信をbashで行う

参考ページ
Thunderbirdを起動→メニューの[表示]→メッセージのソースでメールのソースコードも参考にした。

$ sh smtp_attachment.sh test.jpg

#!/bin/bash
FILENAME=$1
ENCODE_RESULT=`base64 ${FILENAME}`

(
sleep 1s
echo "EHLO wakaranai.doshiyomonai.ne.jp"
sleep 1s
echo "MAIL FROM: tasukete@muryoku.ocn.ne.jp"
sleep 1s
echo "RCPT TO: tanomuseikoshite@gmail.com"
sleep 1s
echo "DATA"
sleep 1s
echo "MIME-Version: 1.0"
sleep 1s
echo "From:tasukete@muryoku.ocn.ne.jp"
sleep 1s
echo "To:tanomuseikoshite@gmail.com"
sleep 1s
echo "Subject:TEST bash source code read"
sleep 1s
echo "Content-Type: image/jpeg;"
sleep 1s
echo ' name=\"test.jpg\"'
sleep 1s
echo "Content-Transfer-Encoding: base64"
sleep 1s
echo "Content-Disposition: attachment;"
sleep 1s
echo ' filename=\"test.jpg\"'
sleep 1s
echo "${ENCODE_RESULT}"
sleep 1s
echo "."
sleep 1s
echo "QUIT"
) | telnet wakaranai.doshiyomonai.ne.jp 25

かなり小さいことで気づくまで時間がかかったが「name」と「filename」の前に半角でホワイトスペースを入れないと正常にファイル名が表示されない。
結果:

2009年6月16日火曜日

bashのfunctionについて

関数を用いてコードを読みやすくする。
uncompress_dir() {
case $1 in
*.tar.bz2)
tar lxvf $1 -C $2
;;
*.tar.gz)
tar zvxf $1 -C $2
;;
*.tar)
tar xvf $1 -C $2
;;
*.zip)
unzip $1 -d $2
;;
*)
echo "未対応のファイル形式です"
;;
esac
}

uncompress_dir ${archivename} ${uncompdir}
「function<空白>関数名<空白>{ ・・・ }」にしないとエラーが出る。

2009年6月14日日曜日

bashの複数行のコメントアウト

: << '#COMMENT_OUT'

#コメントアウトしたいソースコード

#COMMENT_OUT

2009年6月13日土曜日

google ajax apiの呼び出し

<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
google.setOnLoadCallback(function(){
//ソースコードを書く
});
</script>

Protocol Buffersのコンパイル

ubuntu9.04ではレポジトリにProtocol Buffersのコンパイラが入っている
$ sudo apt-get install protobuf-compiler

でインストール
$ protoc --cpp_out=examples/ examples/addressbook.proto

でコンパイル

圧縮ファイルをディレクトリを指定して解凍する

tar lxvf archive_filename -C directory_name
で出来る

2009年6月7日日曜日

bashのfor文について

#!/bin/bash
#ファイル・ディレクトリ名を配列に入れる
ARRAY=$(ls)

# @を入れると配列に入っている要素をすべて処理する
for ELEMENT in ${ARRAY[@]};
do
echo "${ELEMENT}"
done


追記:配列を使うには権限を変更する必要があるようだ。
chmod u+x filename
uは所有者
xは実行

2009年5月30日土曜日

bashで正規表現

参考ページ

#!/bin/bash
V_OPTION=$1

if expr "$V_OPTION" : [0-9] > /dev/null
then
echo "数字です"
else
echo "数字ではないです"
fi


$ sh reg_bash.sh 1

数字です

$ sh reg_bash.sh a

数字ではないです

bashはすごいなぁ…

2009年5月29日金曜日

ターミナルからメールを送る

送信側のメールアドレス: wakaranai@pcnomaede.ocn.ne.jp
送信メールサーバ(SMTP): vcpcnomaede.ocn.ne.jp
受信側のメールアドレス: To_google_mail@gmail.com


$ telnet vcpcnomaede.ocn.ne.jp 25
Trying <数字.X4>...
Connected to vcpcnomaede.ocn.ne.jp.
Escape character is '^]'.
220 vcpcnomaede.ocn.ne.jp ESMTP Postfix

$ HELO vcpcnomaede.ocn.ne.jp
250 vcpcnomaede.ocn.ne.jp

$ MAIL FROM: wakaranai@pcnomaede.ocn.ne.jp
250 Ok

$ RCPT TO: To_google_mail@gmail.com
250 Ok
DATA
354 End data with .
From: wakaranai@pcnomaede.ocn.ne.jp
Subject: test
Hello World.
.
250 <数字> Ok: queued as <16進数?>


…こんな面倒くさい作業を簡単にしてくれてありがとうメーラー!!

2009年5月23日土曜日

chmodによるパーミッションの変更

参考サイト
・読み込み権限はlsコマンドなどファイル名を表示する権限
・書き込み権限はcp・mv・rmコマンドなどファイルを操作する権限
・実行権限はcdコマンドなどディレクトリへの移動を許可する権限

各パーミッションは数字で表現される
読み込み→4
書き込み→2
実行  →1

ex)
読み込み&書き込み&実行の権限をディレクトリに許可
$ sudo chmod 7 -R ディレクトリ名
読み込み&書き込み&実行の権限をファイルに許可
$ sudo chmod 7 ファイル名

読み込み&書き込みの権限を許可
$ sudo chmod 6 ファイル名

書き込みの権限を許可
$ sudo chmod 2 ファイル名

読み込み&書き込み&実行の権限を不許可
$ sudo chmod 0 ファイル名

2009年5月22日金曜日

Bespinを使ってみた

今のところまだ十分に把握出来ていないが、基本的に右クリックは無意味っぽい。あとダブルクリックでプロジェクトやファイルを開いたりするっぽい。所々何とも言えない妙な動きをする。

ページ最下部にあるターミナルとキーボードショートカットで操作するらしい。
コマンドヘルプを見る
help(使い方の勉強はこれを使うべき)

プロジェクトの作成コマンド
createproject 作成したいプロジェクト名

ファイルの作成コマンド
newfile ファイル名 ファイルを入れたいプロジェクト名
○ newfile test.html myfirstproject
× newfile test.html test.js myfirstproject

ファイルを作成すると最初に2文字空白が入っているのは何なんだろう?何か意味があるのだろうか?

デフォルトではオートインデントは入らないらしい。
ターミナルで
$ set autoindent on
と打ち込めばオートインデントになる。

コピー・カットアンドペースト
Windowsのショートカットと同じです。
[Ctrl]+[X] カット
[Ctrl]+[C] コピー
[Ctrl]+[V] ペースト
ただし、他のページにあるサンプルコードを貼り付けて実行ということはできないらしい。(現時点で方法を発見できていないだけかもしれないが)

2009年5月21日木曜日

「jetpack」を試してみる

IT戦記さん
本家のサイト

IT戦記さんのサイトを参考にすれば問題なし。(いつもお世話になってます)

準備
・本家サイト「Get Started! Install the Jetpack Prototype & API」からJetPackアドオンをインストールする。

Jetpackをインストールするには
・HTMLファイル
・JavaScriptファイル
の2つが必要

インストール用HTMLファイルのサンプル(install.html)

<!DOCTYPE html>
<html>
<head>
<link rel="jetpack" href="test.js"/>
<title>Install Jetpack Addon</title>
</head>
<body>
<h1>Install Jetpack!!!</h1>
</body>
</html>


インストールするJavascriptファイルのサンプル(test.js)

jetpack.statusBar.append({
html: "Boom!!!!!"
});


適当なフォルダを作成し、上記の2つのファイルを配置。

Firefoxで
file:///ファイルを配置したディレクトリまでのパス/install.html
にアクセス

インストール作業が始まる。

簡単に終わる。(30秒もかからないぐらい)


インストールできた。

アドオンのアンインストール方法
 about:jetpackとURLを入力しアクセス
 
 Install Featuresをクリック
 
 アンインストールしたいアドオンのuninstallをクリック

 完了

2009年5月17日日曜日

ubuntu シェルスクリプトの配列について

シェルスクリプトでは配列は

array = (A B C)

と表現する

しかし、syntax error near unexpected token `(' というエラーが出る。

参考ページ

このページによると文字コードに問題がある場合があるらしい。

シェルスクリプトの保存時にEUC-JPを指定。

問題は解決した。

ただし、今度は日本語が文字化けを起こすようになった。

#! /bin/bash
a=(A あ )
echo ${a[0]}
echo ${a[1]}

$ sh splt.sh
A
��
また、解決策を探さなければなぁ

追記:ターミナルの文字コードをEUC-JPに変更すれば文字化けしなくなる。

HelloWorldをインストール

このページを参考にHelloWorldをインストールしてみる。

インストールしたのはこんなコード

#include <iostream>

using namespace std;

int main(){
cout << "HelloWorld!!!" << endl;

return 0;
}


HelloWorld.ccでファイルを保存。

$ g++ -o HelloWorld HelloWorld.cc
コンパイル。

HelloWorldという実行ファイルを作成。

$ gedit ~/.bash_profile
開いたファイルの最後に
export $HELLO_HOME=/usr/local/etc
export PATH=$PATH:$HELLO_HOME
を追加
****************************************************
 一般に言う「パスを通す」と言う表現はPATHという環境変数に新たな環境変数を追加する作業を指すと考えられる。コロンによって変数は区切られているらしい。
PATH=$PATH:$HELLO_HOME
とは環境変数PATHに$HELL_HOME(つまりは/usr/local/etc)を追加しているということらしい。
****************************************************

$ source ~/.bash_profile
を実行

$ sudo cp ./cppdir/HelloWorld /usr/local/etc/
//確認
$ ls /usr/local/etc
HelloWorld

//実行
$ HelloWorld
HelloWorld!!!

2009年5月16日土曜日

スパムブログ判定される

記念と後学のためにスパムブログとは何かを調べた。

参考サイト

スパムブログとは自動的に大量生産することで検索にひっかかりやすくすることを目的としている。検索ランキング上位に表示されればアフィリエイトとかでガッポガッポと言う考え方らしい。

かなりの数のスパムブログが世界には存在しているらしい。

隠しテキストなどを使うことで検索にひっかかりやすくしている物もあるらしい。

多分これが一番の問題だろうが抜本的な対策が今のところ存在していない。

           ・
           ・
           ・
 まぁ、大量生産されていそうなぐらい適当なブログだけど、スパムってのはなぁ…
大体アフィリエイトしてないんだけど。なんらかの商品をすすめてもいないんだけど。

 今回、少し調べてみて気づいたけど割と頻繁にスパムブログらしき物にお目にかかっているということだ。しかも、検索結果をいたずらに冗長的なものにしている。
 検索結果を冗長的にしていると言う意味ではこのブログがスパムブログと誤認されたのもうなずける。内容は個人的な備忘録だし、書いてある内容は私以外の誰にとっても価値のないものだろう。
 誤認されることは釈然としないが住みやすいネット社会には必要不可欠な活動の副作用だと考えるべきかもしれない。

2009年5月14日木曜日

GAE for Javaをターミナルで開発

Eclipseを使ってみたが何となくもっさりしていて使いづらい。やはり、テキストエディタ+ターミナルがいい。

$ cd /appengine-java-sdk-1.2.0/

$ ./bin/dev_appserver.sh demos/guestbook/war

ブラウザでhttp://localhost:8080/にアクセス

google app engine for javaとjsp

プロジェクト内のwarフォルダ直下にguestbook.jspを配置。

プロジェクトを実行。

http://localhost:8080/guestbook.jspにアクセス

ログインしたら?と聞いてくる画面が出れば成功。

*****************************************************
web.xmlのwelcome-fileタグの中をguestbook.jspに変更すれば
http://localost:8080/でアクセスしても自動的にリダイレクトされる。

サンプル↓
<servlet>
<servlet-name>guestbook1</servlet-name>
<servlet-class>guestbook.Guestbook1Servlet</servlet-class>
</servlet>
<servlet>
<servlet-name>guestbook2</servlet-name>
<servlet-class>guestbook.Guestbook2Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>guestbook1</servlet-name>
<url-pattern>/guestbook1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>guestbook2</servlet-name>
<url-pattern>/guestbook2</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>guestbook.jsp</welcome-file>
</welcome-file-list>

Google app engine for JavaとEclipseの初期設定

Google app engine for JavaをEclipseで作り始めた。

[ウィンドウ]→[設定]→[Java]→[インストール済みのJRE]と進む。

[検索]ボタンをクリック。

検索フォルダに/usr/libを指定。

検索結果のjava-6-openjdkにチェック。

OKボタンをクリック。

これで初期設定は完了。

※java-6-openjdkを指定したが現段階では問題は出ていないが、java-6-sun-1.6.0.13を使用すればもっとも確実なのかもしれない。

2009年5月12日火曜日

GWT(google web toolkit)1.6.4 linux版

antのインストール
1.Apache Antダウンロードページからapache-ant-1.7.1-bin.tar.gzをダウンロード

2./usr/local/srcにantをインストールする
   /usr/local/srcにダウンロードしたファイルを移動
    $sudo cp パス/apache-ant-1.7.1-bin.tar.gz /usr/local/src
    $sudo tar zvxf apache-ant...
 $mv apache-ant... ant
   環境変数の追加
    $echo 'export ANT_HOME=/usr/local/ant' >> ~/.bash_profile
    $echo 'export PATH=$PATH:$ANT_HOME/bin' >> ~/.bash_profile
    $source ~/.bash_profile
   最終確認

    $ant -version
バージョンが正しく出れば成功

GWTのインストール
1.GWTダウンロードページからGWTをダウンロード

2.GWTを適当なフォルダに解凍

3.$ cd 適当なフォルダ/gwt-linux-1.6.4/samples/Mail

4.$ant hosted
ここで場合によってはエラーが出る場合
$ sudo apt-get install libstdc++5

2009年5月11日月曜日

ubuntu9.04でpython2.5を使う(トラブル)

今のところのトラブル
 ・[アプリケーション]→[追加と削除]が起動しなくなる。
 ・何らかのインストールをする度にエラーが出て精神的にまいる。ただし、これといった不具合はない。

ubuntu9.04でpython2.5を使う

GoogleAppEngineではpython2.5が必要要件としてあげられている。このためubuntu9.04にデフォルトでインストールされているpython2.6では(頭のいい人は何らかの手段で出来るかもしれないが)テストサーバを使用できない。

このサイトを参考にpython2.5に戻してみた。

$ sudo update-alternatives --config python

pythonのalternativesがありませんと出力されるので

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.5 10
$ sudo update-alternatives --install /usr/bin/pytyon python /usr/bin/python2.6 20
と実行。

再び
$ sudo update-alternatives --config python
と実行。

うまくいけば
`python' を提供する 2 個の alternatives があります。

選択肢 alternative
-----------------------------------------------
* 1 /usr/bin/python2.5
+ 2 /usr/bin/python2.6

デフォルト[*] のままにするには Enter、さもなければ選択肢の番号のキーを押してください:
と出るらしいのだが、私は

python を提供するプログラムが 1 つしかありません (/usr/bin/python2.6)。
設定は行いません。
と出力される。

めげることなく
$ sudo apt-get install python2.5
と実行

インストール途中にエラーが出たが
$python -V
と実行すると
Python 2.5.4
と表示される。

GoogleAppEngineも正常に動作している。

一応今のところトラブルはない。

2009年5月10日日曜日

Eclipse3.4の日本語化

EclipseダウンロードページからEclipse Classic 3.4.2をダウンロードする

ダウンロードしたファイルを適当な場所に展開

日本語化パックダウンロードページからNLpackja-eclipse-SDK-3.4.1-blancofw.zipをダウンロード

ダウンロードした圧縮ファイルを解凍

eclipseファルダが作成されるので中にあるplugin・featureフォルダを先ほどダウロード作成したフォルダにコピー、マージする。

確認のためEclipseを起動

2009年5月9日土曜日

Eclipseの日本語化

eclipseのインストール
 $sudo apt-get install eclipse

このページからNLpack1-eclipse-SDK-3.2-gtk.zipをダウンロード

ダウンロードしたファイルを解凍

カレントディレクトリはそのまま

下記のコマンドを実行
 $ sudo cp -R eclipse/plugins/* /usr/lib/eclipse/plugins/
 $ sudo cp -R eclipse/features/* /usr/lib/eclipse/features/

確認のためEclipseを起動

HTMLのrelative

<style type="text/css">
#test_div{
width: 100px;
height: 100px;
border: solid #000000 2px;
}
#test_div2{
width: 100px;
height: 100px;
border: solid #eaefaa 2px;
position: relative;
left: 100px;
top: -2px;
}
</style>
<div id="test_div">
<div id="test_div2">

</div>
</div>

2009年5月7日木曜日

GTKポートって何?

最近、WebKitの勉強していると時々GTK+portという記述を見るがなんとなく読み流していたが調べてみることにした。

IT用語辞典によれば。

本来のプラットフォーム以外で動作するように改造されたものを ○○○向けポートというらしい。また、改造する作業をporting(ポーティング)というらしい。

WebKitGtk-GNOME Live!の序文
原文:WebKit/GTK+ is the new GTK+ port of the WebKit.
訳:WebKit/GTK+はWebKitの新しいGTK+ポートです。

っていうことはGTK+ポートって言うのはWebKitをGTK+上で動作するように改造したものってこと?

自分で書いていて訳が分からなくなってきた。読解力がねぇ…

2009年5月5日火曜日

コマンドインタプリタを作ってみた。

Google V8についているshellを参考に作成。


using namespace std;

int RunMain(int argc, char* argv[]){
static const int bufsize = 256;
while(true){
char buffer[bufsize];
//↓インタプリタ感を出すやつ
printf(">");
char* str = fgets(buffer, bufsize, stdin);
//終了させるにはquitと打つ
if(strcmp(str, "quit")){
exit(0);
}
printf("%s",buffer);
}
return 0;
}

int main(int argc,char* argv[]){
int result = RunMain(argc, argv);

return 0;
}

C/C++をほとんど触ったことがなかったから、よく分からないがおそらく、pythonのインタプリタもこんな感じで動いているんだろう。

2009年5月4日月曜日

よくこれだけ忘れられると思った。

int main(int argc, char* argv){

return 0;
}
これがC/C++の基本だけど。
int argc, char* argvってなんだっけ?ってさっき思った。


#include
int main(int argc, char* argv[]){

std::cout << argv[0] << std::endl;
std::cout << argc << std::endl;
return 0;
}
実行
$./test ABC
出力結果
$./test
2

忘れてたけど0個目の引数は実行ファイル名になるんだね。

…記憶力がまずいことになってる気がしてきた。

2009年5月3日日曜日

WebkitでWebブラウザを作ってみた

GTKLauncherのコードを参考に作成。

コード:

#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include <iostream>


static WebKitWebView* web_view;

static GtkWidget* create_browser()
{
GtkWidget* scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(web_view));

return scrolled_window;
}

static void destroy_cb(GtkWidget* widget, gpointer data)
{
gtk_main_quit();
}
static GtkWidget* create_window()
{
GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
gtk_widget_set_name (window, "GtkLauncher");
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);

return window;
}



int main(int argc, char* argv[]){
//テスト出力
std::cout<< "START PROCESS" << std::endl;
//↓スタート
gtk_init(&argc, &argv);

GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), create_browser(), TRUE, TRUE, 0);

GtkWidget* _main_window;
_main_window = create_window();
gtk_container_add(GTK_CONTAINER(_main_window),vbox);

webkit_web_view_open(web_view, "http://www.google.com/");

//↓おまじない**********************
gtk_widget_grab_focus(GTK_WIDGET(web_view));
gtk_widget_show_all(_main_window);
gtk_main();
//**********************************
return 0;
}

コンパイルする:

$ g++ -o brow brow.cc `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs webkit-1.0`

なんせこんなことしたの今回が初めてだからよく分からないが
error while loading shared libraries: libwebkit-1.0.so.1: cannot open shared object file: No such file or directory
こんなエラーが出た。

調べてみるとライブラリが認識されていないために起きるエラーらしい。そこで
$lfconfig
$sudo ldconfig
を実行

再コンパイルしてみるとエラーは出なくなった。
出来たのはこんな感じ↓


…Javascriptも動くブラウザをこうも簡単に作れるのはすごい。感動した。

2009年5月1日金曜日

GTK+のコンパイル

前やったときはこんなに面倒くさいオプションいらなかった気がするんだけど。
g++ -o hello_world hello_world.cpp `pkg-config --cflags --libs gtk+-2.0`

追記:
  ubuntu 9.04(netbook remix)では同じ方法ではコンパイルが通らなかった。pkg-config自体は既にインストールされていたため
$ pkg-config --list-all
でめぼしいものを探したところ「gtk+」という項目を発見。ということで
  $ g++ -o sample_gtk.cc -o sample_gtk `pkg-config --cflags --libs gtk+`
と実行してみるとコンパイルに成功した。ubuntu8.10からの変更? pkg-configの仕様が変わった?
 後、これの前に
  $ sudo apt-get install libgtkmm*-devlibgtk2.0-dev
を実行。
さらに追記:
  コンパイルが通らなかったのはlibgtk2.0-devをインストールしてなかったからでした。

pkg-configはコンパイルオプションを自動生成してくれるスグレモノ。

バッククォートで囲んでいるのはシェルではバッククォートで囲んだ部分の実行結果を変数として格納できるから。
つまりこのコマンドを実行すると
pkg-config --cflags --libs gtk+-2.0
のコマンドの実行結果

-D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

を「g++ -o hello_world hello_world.cpp」の後に付加してコンパイルを実行しているということ。

・・・これ書くぐらいなら楽なもんだなぁ。

VirtualBoxで印刷する

ubuntuを使い始めて半年が過ぎたが素晴らしい使い心地でWindowsに戻る気も起きることなく今日まで唯一不満でならなかったのがプリンタがまったく使えなかったことだ。

そのうち対応するだろうと軽く考えていたがそうもなりそうにないので自分で何とかするしかないようだ。

結論から言うと使うことが出来た。

環境:
OS(ホスト) ubuntu8.10
OS(ゲスト) Windows vista
RAM  1.36GB
USB-HDD  60GB
プリンタ lexmark x2550

※lexmark x2550について少し説明しておく。このプリンタのドライバは付属のCD-ROMに入っており、インターネットからもダウンロードは可能。ただしインストール時はプリンタのUSBをPCが認識している状態でないとドライバのインストールもすることは出来ない。

そこでVirtualBoxを使う。

ubuntuのリポジトリにVirtualBoxのオープンソースエディションがあるがこれを使うとUSBを使えない。困ったことだ。

1.Ubuntu8.10("Intrepid Ibex")のi386をダウンロード。公式サイトのダウンロードページ

2.GDebi Packageインストーラでダウンロードしたdebファイルをインストール

3.sudo VirtualBox
と端末で入力

4.アプリケーションが起動

5.新規というボタンをクリック。

6.ウィザードに沿っていけばインストール準備完了

7.設定ダイアログでCDのマウントを有効にする

8.CD/DVDドライブにWindowsVistaのDVD-ROMを挿入

9.起動というボタンをクリック

10.インストール作業が始まる。(私の場合インストールには1時間程度かかった)

今日はここまで。
 

2009年4月26日日曜日

Webkitにv8を組み込もうと頑張ってみる

 ビルドはできたんだけどさあどうしようってなったとき、これといって計画はない。そこで何となく組み込みにチャレンジすることにした。

Chromiumにv8の組み込みについて何か情報ないかと探すとこんな文章が

We use the WebKit open-source project to lay out web pages. This code is pulled from Apple and stored in the /third_party/WebKit directory. WebKit consists primarily of "WebCore" which represents the core layout functionality, and "JavaScriptCore" which runs JavaScript. We only run JavaScriptCore for testing purposes, normally we replace it with our high performance V8 engine. We do not actually use the layer that Apple calls "WebKit," which is the embedding API between WebCore and OS X applications such as Safari. We normally refer to the code from Apple generically as "WebKit" for convenience.

まあ、要はWebkit使ってHTMLのレンダリングはしてますよ。元々Webkitに入ってるWebCoreってのを使って。でもJavascriptは我がV8を使ってますよ。元々Webkitに入ってるJavaScriptCoreはテストぐらいにしか使いませんね。
 厳密にいえば、我々は「Webkit」ってものは使ってはいないんですよ。Webkitっていうのはさっき言ったWebCoreっていうレンダリングエンジンとsafariのようなアプリケーションのAPIを組み込んだものなんで。便宜上、Webkitって読んでいるだけなんですよ。

・・・へぇ。

ubuntu 9.04をクリーンインストール

 クリーンインストールしたらflash playerまた入れなきゃならないんだけど。なんせ半年に一回のことなんで忘れちゃって微妙に面倒

1.Adobeのサイトからflash playerのtar.gzファイルをダウンロード
2.ファイルを解凍

tar xvzf ファイル名.tar.gz

3.解凍してできたディレクトリ install_flash_player_*_linuxに入る

cd install_flash_player_*_linux

4.インストール

./flashplayer-installer
//******************
Enterキーを押す
//******************

5.Webブラウザをシャットダウン
6. ホームディレクトリの./mozillaにインストールしますよ。いいですか?と聞かれるので
y を選択。
7.(ここら辺は何書いてあったかあんまり読んでないけど) 他アプリケーションにイントー ルする?って聞かれるのでお好きなように。今回は n を選んだ。

2009年4月21日火曜日

WebKitのビルドに成功

最新版のソースでは無理だったがWebKit-r39474ではすんなり成功した。

所要時間は40分ぐらい。


./autogen
make

これだけで簡単にビルドはできる。

2009年4月20日月曜日

Googleのコネ?

なぜかこのブログが検索にかかってしまっている。誰も見てないだろうに。Googleのサービス利用してるだけにひいきしてもらってるのだろうか。

何にしても検索かかるのに適当な内容だと申し訳ないので今後はもう少し頑張ってブログ作ることにします。

v8 和訳

『v8 和訳』でググるとこのサイトがトップに表示されて見苦しい。

素晴らしい和訳が
V8ドキュメント日本語訳(ゆとり)
で読むことができます。

トップに検索されてごめんなさい。

悪気はなかったんです。

2009年4月19日日曜日

WebKitビルド少し前進

constructor@constructor-laptop:~$ cd WebKit-r42583/
constructor@constructor-laptop:~/WebKit-r42583$ ./autogen.sh
/usr/share/aclocal/gtk--.m4:10: warning: underquoted definition of AM_PATH_GTKMM
/usr/share/aclocal/gtk--.m4:10: run info '(automake)Extending aclocal'
/usr/share/aclocal/gtk--.m4:10: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
configure.ac:14: installing `autotools/config.guess'
configure.ac:14: installing `autotools/config.sub'
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for native Win32... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking if supports -fvisibility=hidden -fvisibility-inlines-hidden... yes
checking for pkg-config... /usr/bin/pkg-config
checking for perl... /usr/bin/perl
checking for bison... /usr/bin/bison
checking for mv... /bin/mv
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for a BSD-compatible install... /usr/bin/install -c
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for ANSI C header files... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for bash... /bin/bash
checking if dolt supports this host... yes, replacing libtool
checking for flex... /usr/bin/flex
checking for gawk... (cached) mawk
checking for gperf... /usr/bin/gperf
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for jpeg_destroy_decompress in -ljpeg... yes
checking for jpeglib... yes
checking for libpng12... yes
checking the target windowing system... x11
checking for Hildon UI extensions... no
checking for GLIB... yes
checking for glib-genmarshal... /usr/bin/glib-genmarshal
checking for glib-mkenums... /usr/bin/glib-mkenums
checking which Unicode backend to use... icu
checking for icu-config... /usr/bin/icu-config
checking for LIBXML... yes
checking for PANGO... yes
checking for CAIRO... yes
checking for GTK... yes
checking for XT... yes
checking whether to do a debug build... no
checking whether to enable optimized builds... yes
checking whether to enable Dashboard support... yes
checking whether to enable support for 3D Transforms... no
checking whether to enable HTML5 Channel Messaging support... no
checking whether to enable HTML5 offline web applications support... yes
checking whether to enable HTML5 client-side session and persistent storage support... yes
checking whether to enable HTML5 client-side database storage support... yes
checking whether to enable icon database support... yes
checking whether to enable HTML5 video support... yes
checking whether to enable XPath support... yes
checking whether to enable XSLT support... yes
checking whether to enable geolocation support... no
checking whether to enable gnomekeyring support... no
checking whether to enable SVG support... yes
checking whether to enable WML support... no
checking whether to enable Web Workers support... yes
checking whether to enable support for SVG animation... yes
checking whether to enable support for SVG filters... no
checking whether to enable support for SVG fonts... yes
checking whether to enable support for SVG foreign objects... yes
checking whether to enable SVG as Image support... yes
checking whether to enable support for SVG use element... yes
checking whether to enable code coverage support... no
checking whether to enable optimized memory allocator... yes
checking whether to enable JIT compilation... yes
checking the font backend to use... freetype
checking for LIBSOUP... configure: error: Package requirements (libsoup-2.4 >= 2.25.91) were not met:

Requested 'libsoup-2.4 >= 2.25.91' but version of libsoup is 2.24.1

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBSOUP_CFLAGS
and LIBSOUP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.








constructor@constructor-laptop:~$ cd WebKit-r42583/
constructor@constructor-laptop:~/WebKit-r42583$ ./autogen.sh
/usr/share/aclocal/gtk--.m4:10: warning: underquoted definition of AM_PATH_GTKMM
/usr/share/aclocal/gtk--.m4:10: run info '(automake)Extending aclocal'
/usr/share/aclocal/gtk--.m4:10: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
configure.ac:14: installing `autotools/config.guess'
configure.ac:14: installing `autotools/config.sub'
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for native Win32... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking if supports -fvisibility=hidden -fvisibility-inlines-hidden... yes
checking for pkg-config... /usr/bin/pkg-config
checking for perl... /usr/bin/perl
checking for bison... /usr/bin/bison
checking for mv... /bin/mv
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for a BSD-compatible install... /usr/bin/install -c
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for ANSI C header files... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for bash... /bin/bash
checking if dolt supports this host... yes, replacing libtool
checking for flex... /usr/bin/flex
checking for gawk... (cached) mawk
checking for gperf... /usr/bin/gperf
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for jpeg_destroy_decompress in -ljpeg... yes
checking for jpeglib... yes
checking for libpng12... yes
checking the target windowing system... x11
checking for Hildon UI extensions... no
checking for GLIB... yes
checking for glib-genmarshal... /usr/bin/glib-genmarshal
checking for glib-mkenums... /usr/bin/glib-mkenums
checking which Unicode backend to use... icu
checking for icu-config... /usr/bin/icu-config
checking for LIBXML... yes
checking for PANGO... yes
checking for CAIRO... yes
checking for GTK... yes
checking for XT... yes
checking whether to do a debug build... no
checking whether to enable optimized builds... yes
checking whether to enable Dashboard support... yes
checking whether to enable support for 3D Transforms... no
checking whether to enable HTML5 Channel Messaging support... no
checking whether to enable HTML5 offline web applications support... yes
checking whether to enable HTML5 client-side session and persistent storage support... yes
checking whether to enable HTML5 client-side database storage support... yes
checking whether to enable icon database support... yes
checking whether to enable HTML5 video support... yes
checking whether to enable XPath support... yes
checking whether to enable XSLT support... yes
checking whether to enable geolocation support... no
checking whether to enable gnomekeyring support... no
checking whether to enable SVG support... yes
checking whether to enable WML support... no
checking whether to enable Web Workers support... yes
checking whether to enable support for SVG animation... yes
checking whether to enable support for SVG filters... no
checking whether to enable support for SVG fonts... yes
checking whether to enable support for SVG foreign objects... yes
checking whether to enable SVG as Image support... yes
checking whether to enable support for SVG use element... yes
checking whether to enable code coverage support... no
checking whether to enable optimized memory allocator... yes
checking whether to enable JIT compilation... yes
checking the font backend to use... freetype
checking for LIBSOUP... configure: error: Package requirements (libsoup >= 2.25.91) were not met:

No package 'libsoup' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBSOUP_CFLAGS
and LIBSOUP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

constructor@constructor-laptop:~/WebKit-r42583$ ./autogen.sh
/usr/share/aclocal/gtk--.m4:10: warning: underquoted definition of AM_PATH_GTKMM
/usr/share/aclocal/gtk--.m4:10: run info '(automake)Extending aclocal'
/usr/share/aclocal/gtk--.m4:10: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
configure.ac:14: installing `autotools/config.guess'
configure.ac:14: installing `autotools/config.sub'
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for native Win32... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking if supports -fvisibility=hidden -fvisibility-inlines-hidden... yes
checking for pkg-config... /usr/bin/pkg-config
checking for perl... /usr/bin/perl
checking for bison... /usr/bin/bison
checking for mv... /bin/mv
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for a BSD-compatible install... /usr/bin/install -c
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for ANSI C header files... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for bash... /bin/bash
checking if dolt supports this host... yes, replacing libtool
checking for flex... /usr/bin/flex
checking for gawk... (cached) mawk
checking for gperf... /usr/bin/gperf
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for jpeg_destroy_decompress in -ljpeg... yes
checking for jpeglib... yes
checking for libpng12... yes
checking the target windowing system... x11
checking for Hildon UI extensions... no
checking for GLIB... yes
checking for glib-genmarshal... /usr/bin/glib-genmarshal
checking for glib-mkenums... /usr/bin/glib-mkenums
checking which Unicode backend to use... icu
checking for icu-config... /usr/bin/icu-config
checking for LIBXML... yes
checking for PANGO... yes
checking for CAIRO... yes
checking for GTK... yes
checking for XT... yes
checking whether to do a debug build... no
checking whether to enable optimized builds... yes
checking whether to enable Dashboard support... yes
checking whether to enable support for 3D Transforms... no
checking whether to enable HTML5 Channel Messaging support... no
checking whether to enable HTML5 offline web applications support... yes
checking whether to enable HTML5 client-side session and persistent storage support... yes
checking whether to enable HTML5 client-side database storage support... yes
checking whether to enable icon database support... yes
checking whether to enable HTML5 video support... yes
checking whether to enable XPath support... yes
checking whether to enable XSLT support... yes
checking whether to enable geolocation support... no
checking whether to enable gnomekeyring support... no
checking whether to enable SVG support... yes
checking whether to enable WML support... no
checking whether to enable Web Workers support... yes
checking whether to enable support for SVG animation... yes
checking whether to enable support for SVG filters... no
checking whether to enable support for SVG fonts... yes
checking whether to enable support for SVG foreign objects... yes
checking whether to enable SVG as Image support... yes
checking whether to enable support for SVG use element... yes
checking whether to enable code coverage support... no
checking whether to enable optimized memory allocator... yes
checking whether to enable JIT compilation... yes
checking the font backend to use... freetype
checking for FREETYPE... yes
checking for SQLITE3... yes
checking for LIBXSLT... yes
checking for GSTREAMER... configure: error: Package requirements (gstreamer-0.10 >= 0.10
gstreamer-base-0.10,
gstreamer-plugins-base-0.10) were not met:

No package 'gstreamer-0.10' found
No package 'gstreamer-base-0.10' found
No package 'gstreamer-plugins-base-0.10' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GSTREAMER_CFLAGS
and GSTREAMER_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.