2010年12月20日月曜日

android handler 非同期処理

http://www.adamrocker.com/blog/261/what-is-the-handler-in-android.html

http://labs.techfirm.co.jp/android/cho/1079

2010年11月25日木曜日

android memory leak

1.adb shellにて出力先の書き込み権限をつける
chmod 777 /data/misc

2.ソースに下記出力用の処理追加する
try {
long outputString = System.currentTimeMillis();
Debug.dumpHprofData("/data/misc/" + Long.toString(outputString) + ".hprof");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

3.android実機の/data/misc/配下には.hprofファイルが生成されるんで、
androidツールキットtools配下のhprof-convを利用してhprofのフォーマット
を変換する
./hprof-conv input.hprof output.hprof

4. output.hprofをeclipseのMemory Analysis perspective(eclipseのMATプラグイン)
からfile->open heap dump..
から開くとメモリリーク解析結果が表示される

2010年10月17日日曜日

use web camera in ubuntu 10.10

try guvcview -d /dev/videoX change X to 0 1 2 and test


original page is this one:
https://help.ubuntu.com/community/UVC

2010年10月8日金曜日

複数ファイルに処理をかけるシェル

すべてのファイルの最後一行にend of lineを追加するシェル

#!/bin/sh

FILES=`find . -name '*.txt'`

for file in ${FILES}; do
echo -n $file: replacing...
cp -p $file $file.bak
echo "end of file" >> $file
echo done
done

2010年8月2日月曜日

linux ファイル名 rename

次の様なmp3ファイルに対し、以下の2つの変更をしたい。

Brian Kelly - Cool Blue (www-briankelly-com).mp3
Doug Wisler - Serenity Shores (www-dougwisler-com).mp3

(例7) 「 ( url )」を削除する。

$ rename 's/ \(\S*\)//' *.mp3

(例8) 演奏者のファーストネームをイニシャル化する。

$ rename 's/^?[a-z]* /\. /' *.mp3

元ネタ
https://wiki.ubuntulinux.jp/UbuntuTips/FileHandling/RenameCommand

2010年7月28日水曜日

linux GUI表示について

GNOME Display Managerが表示できなくなった場合は
service gdm stop
service gdm start
で解消できるかも

2010年6月30日水曜日

about git

http://marklodato.github.com/visual-git-guide/

2010年6月17日木曜日

テキストファイル内のタブをスペースに置き換えるには

1. linuxコマンドで実行する場合
expand --tab=4 before.txt > after.txt

2. vimで実施する場合
:set expandtab
:set ts=4
:retab


逆の動作をする場合
linux:
unexpand before.txt > after.txt

2010年6月16日水曜日

2010年6月11日金曜日

How to: Meld for Git diffs in Ubuntu Hardy

Are you using Git in Ubuntu and want to use an external visual diff viewer? It's easy! I will be using Meld for this example but most visual diff tools should be similar. If you don't already have Meld, then install it:

sudo apt-get install meld

Ok. Now let's begin by breaking it. Enter this into a terminal:

git config --global diff.external meld

Then navigate to a Git tracked directory and enter this (with an actual filename):

git diff filename

Meld will open but it will complain about bad parameters. The problem is that Git sends its external diff viewer seven parameters when Meld only needs two of them; two filenames of files to compare. One way to fix it is to write a script to format the parameters before sending them to Meld. Let's do that.

Create a new python script in your home directory (or wherever, it doesn't matter) and call it diff.py. and "chmod 777 /home/nathan/diff.py"

#!/usr/bin/python

import sys
import os

os.system('meld "%s" "%s"' % (sys.argv[2], sys.argv[5]))

Now we can set Git to perform it's diff on our new script (replacing the path with yours):

git config --global diff.external /home/nathan/diff.py
git diff filename

This time when we do a diff it will launch Meld with the right parameters and we will see our visual diff.

2010年6月10日木曜日

class final 領域の初期化

public class Eval {

private static final HashMap sSceneResources
= new HashMap();


public String getString(Integer toget) {
String ret = (String)sSceneResources.get(toget);
return ret;
}

static {
sSceneResources.put(2,new String("2"));
sSceneResources.put(3,new String("3"));
}
}

2010年3月7日日曜日

gdb でソースを解析する

gdb でソースを解析する

1. coredumpを有効化
ulimit -c unlimited

2. レジスタの表示
(gdb) info reg

3. 特定のレジスタを表示する
(gdb) p $eax

4. x 特定のメモリの中身を表示する
(gdb) x $pc //通常表示
(gdb) x/i $pc //機械命令として
(gdb) x/10i $pc //pcから10個の機械命令として

5. x86プロセッサの場合、PCはeipレジスタで、FPはebpレジスタです。

6. (gdb) frame でframe情報を表示し、
(gdb) frame number でframe を切り替える。

2010年2月18日木曜日

emacs & svn

下記プラグインを利用する。
psvn.el

こいつを~/.emacs-dirに保存し
~/.emacsを編修する

###################
(setq load-path
(append
(list (expand-file-name "~/.emacs-dir/")) load-path))

(require 'psvn)
###################

使い方についてpsvn.elを開いて参照してください。

2010年2月7日日曜日

Ubuntu でパッケージのソースコードを入手する

元ネタ:
http://masaoo.blogspot.com/2009/07/ubuntu.html

あるコマンドのソースコードを調べてみたいとか、見てみたいということがあります。
そんなときは apt-get で簡単にソースコードを取ってくることができます。

以下は dig コマンドのソースを取ってくる場合の例。
1. which コマンドで dig コマンドの保存場所を調べます。

# which dig
/usr/bin/dig

2. dpkg コマンドで dig コマンドが含まれるパッケージを調べます。

# dpkg -S /usr/bin/dig
dnsutils: /usr/bin/dig

3. dnsutils のソースコードを apt-get で取得します。

# mkdir dig
# cd dig
# apt-get source dnsutils

4. ls で見るとこんな感じになります。

あとは bind9-9.4.2.dfsg.P2 ディレクトリ内を調べます。
他のコマンドでも同様のやり方でいけます。

# ls
bind9-9.4.2.dfsg.P2 bind9_9.4.2.dfsg.P2-2ubuntu0.1.dsc
bind9_9.4.2.dfsg.P2-2ubuntu0.1.diff.gz bind9_9.4.2.dfsg.P2.orig.tar.gz

投稿者 まさお 時刻: 19:40
ラベル: Ubuntu

2010年1月23日土曜日

bash コマンドの結果を配列として格納する

コマンドの結果を配列として格納する。

$ls_result=($(ls))
$echo ${ls_result[@]}

2010年1月17日日曜日

C言語defineテクニック

以下定義の理由
#define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0)


if (addr)
DUMP_WRITE(addr,nr);
else
do_something_else();

(unsigned long)(&((type *)0)->member))
構造体のメンバーmemberのシフト量