2013年8月10日 星期六

MOMI 魔米M1 把玩心得

MOMI 魔米M1

偶爾把玩約兩個星期,RK3188 四核心 A9 CPU,此版內建 8GB 空間,惡搞非常方便,用起來也很順。

此次使用的軟體版本是 Momi-M1_4.2__root_20130619.zip ,把它當成 server 不關機,可能有熱當的現象?例如開機一陣子後,重開機時,曾碰過進不了畫面,或是進入後 wifi 網路不會自動重啓,並且手動啓動 wifi 也開不了等,須拔掉電源線過一陣子(30秒~3分鐘)再重新啓動才能解決,但也不排除是 app 惹的禍或是冷氣不夠冷 XD

其他不方便的地方是在上頭寫程式的問題,因為 adb devices 偵測不到,無法方便地看到 console 端噴的訊息,寫 Android app 實在綁手綁腳。討論區提供的 windows drives 應該是燒機時用的且 Windows XP 比較順利。

扣除上述工程師的抱怨外,我倒還是會推薦一般使用者用看看 :D 露天大概賣台幣2000上下,CP值不錯。

[OSX] 關掉 tar -czf 時產生多餘 ._* 開頭的檔案 @ Mac 10.8

使用 tar -zcvf result.tar.gz reslut_dir 後,用 tar -tvf result.tar.gz 時,會看到多餘的 ._ 開頭的檔案。

例如 result_dir 只有 test.sh ,但壓縮完會多 ._test.sh 檔案:

$ ls result_dir
test.sh

$ tar -zcvf result.tar.gz result_dir
a result_dir
a result_dir/test.sh

$ tar -tvf result.tar.gz
result_dir/._test.sh
result_dir/test.sh


關掉方式是設定環境變數 COPYFILE_DISABLE=1,例如一次性 COPYFILE_DISABLE=1 的用法:

$ COPYFILE_DISABLE=1 tar -zcvf result.tar.gz result_dir

2013年8月9日 星期五

Android 開發筆記 - 依照檔案 Content-type / MIME Type 開啓對應 app

專門的 app 一定會希望無時無刻把使用者留在自己家裡,但是什麼都自己來真的太累了 XD 所以,處理特定 Content-type 檔案時,就乾脆叫出系統內其他 app 來負責吧!鄉民用語:「閃開!讓專業的來!」

File file = new File("/sdcard/path/file");
Intent mIntent = new Intent();
mIntent.setAction(Intent.ACTION_VIEW);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setDataAndType(Uri.fromFile(file), "image/jpeg");
startActivity(mIntent);


上述建立在自己知道該檔案類型,若不知道的話,就先用其他方式找吧!

此外,連續用上述方式開啓 3 次檔案,就必須連按三次 back 鍵才能離開外部 app 回到自家 app,這時可以透過 Intent.FLAG_ACTIVITY_NO_HISTORY 來限制外部 app 一離開前景就不進 history ,方便按一下 back 就回去自家 app 啦

mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_HISTORY);

Android 開發筆記 - 從 Android Service 發動 startActivity

若是只是單純從一個 Activity 發動另一個 Activity:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com.tw")));

若是從 Service 發動 StartActivity 則需須指定 Intent.FLAG_ACTIVITY_NEW_TASK 方可正常運行:

Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com.tw"));
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mIntent);

[Linux] 解決 apt-get 之 gzip: stdout: No space left on device 問題 @ Ubuntu 12.04 Server

噴訊息:

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-#.#.#-##-generic with 1.
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

接著查看 /boot:

$ df  -h
Filesystem              Size  Used Avail Use% Mounted on
...
/dev/sda1               228M  218M     0 100% /boot


解法:

$ uname -a
Linux 3.2.0-51-generic #77-Ubuntu SMP Wed Jul 24 20:18:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

代表現在跑 Linux 3.2.0-51 也算正常吧,那就把其他清掉吧

$ dpkg -l 'linux-image-*' | grep '^ii'
ii  linux-image-3.2.0-29-generic        3.2.0-29.46                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-35-generic        3.2.0-35.55                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-37-generic        3.2.0-37.58                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-38-generic        3.2.0-38.61                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-39-generic        3.2.0-39.62                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-40-generic        3.2.0-40.64                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-41-generic        3.2.0-41.66                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-43-generic        3.2.0-43.68                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-44-generic        3.2.0-44.69                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-45-generic        3.2.0-45.70                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-48-generic        3.2.0-48.74                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-49-generic        3.2.0-49.75                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-51-generic        3.2.0-51.77                         Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-server                  3.2.0.51.61                         Linux kernel image on Server Equipment

開始慢慢清掉之前裝過的:(此例還保留前一份linux-image-3.2.0-49-generic這份)

$ sudo apt-get purge linux-image-3.2.0-29-generic linux-image-3.2.0-35-generic linux-image-3.2.0-37-generic linux-image-3.2.0-38-generic linux-image-3.2.0-39-generic linux-image-3.2.0-40-generic linux-image-3.2.0-41-generic linux-image-3.2.0-43-generic linux-image-3.2.0-44-generic linux-image-3.2.0-45-generic  linux-image-3.2.0-48-generic

再次查看: 

$ df -h
Filesystem              Size  Used Avail Use% Mounted on
...
/dev/sda1               228M   51M  165M  24% /boot


收工