星期六, 4月 09, 2011

星期二, 2月 22, 2011

7z (7zip) 壓縮檔案包含路徑的方式

因為想把整個目錄底下的檔案及子目錄都壓縮起來備份. 所以去 google 一下如何把路徑名稱也一併包含在壓縮檔中.
語法:
7z a zipfile_name.7z @ziplistfile.lst

其中 ziplistfile.lst 裡包含了有要壓縮的檔名及路徑.
如果目錄的結構如下:

dir1\1.bin
2.bin
3.prj
a.exe
+--- subdir1\
a.txt
b.txt
c.bin
+--- subdir2\
1.txt
2.doc
3.doc
++---subdir22
20.txt
21.txt

我要把 dir1\a.exe 及 subdir1 及 subdir2 底下的檔案全壓縮. 那麼 ziplistfile.lst 的內容就會像以下這樣:

a.exe
subdir1\
subdir2\

之後把這些寫成 batch file, 存在要壓縮的目錄下, 就可以很容易達成要壓縮的目地了.
batch file 的內容(把檔名加入日期):

setlocal
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyymmdd_hhmm=%date:~0,4%%date:~5,2%%date:~8,2%_%hh%%time:~3,2%

7z a backup_%yyyymmdd_hhmm%.7z @backupfilelist.txt
move backup__%yyyymmdd_hhmm%.7z .\backup

這樣就 ok 了.

如果不想把 subdir2\subdir22 給包進去, 再寫一個 exculde file list (exfilelist.txt):

subdir2\subdir22\

接下來把 command 改成:
7z a -x@exfilelist.txt backup_%yyyymmdd_hhmm%.7z @backupfilelist.txt

ok!

星期一, 12月 20, 2010

美光推新型記憶體裝置 延長NAND產品壽命

美光推新型記憶體裝置 延長NAND產品壽命
"新款ClearNAND裝置將錯誤管理技術整合在同一個NAND封裝內...", 應該和 eMMC 相同, 只是名稱不同.

星期三, 12月 01, 2010

在 Ubuntu 10.04 下安裝 Canon MP568

今天想到要在 Ubuntu 下安裝 MP568 printer, 用 Google 找了一下,找到了 Canon 自己有出 Linux 下的 driver.
http://support-asia.canon-asia.com/contents/ASIA/EN/0100236502.html
下載解開後有2個檔案,先安裝 cnijfilter-common_3.20-1_i386.deb
再安裝 cnijfilter-mp560series_3.20-1_i386.deb
接著在 系統/管理/列印 下新增 printer,
使用 PPD 檔案,在 cnijfilter-mp560series_3.20-1_i386.deb 中可以用套件安裝程式看到路徑。
可以列印了 :-)

星期一, 11月 08, 2010

Python 使用 subprocess module 呼叫外部程式

# 當呼叫內建的指令,如 dir 時, Popen()裡的 shell 要設為 True
# stdout 可以設成檔案輸出, 如下:
fopen = open('hello.txt','w')
subprocess.Popen('dir',shell = True, stdout = fopen)
fopen.close()

星期二, 10月 26, 2010

將 source code 的原始編排放入 blog 中

使用下列網站:
http://codeformatter.blogspot.com/2009/06/about-code-formatter.html

只要將 source code 貼上, 就會產生對應的 html, 再貼入 blog 中就可以了.

使用 python 呼叫 DLL

使用 BCB 來撰寫 DLL

 extern "C" __declspec(dllexport) int __stdcall ReturnAplusB(int a,int b)  
{
return a+b+1;
}

/* 注意 __stdcall 這個宣告很重要,不然 python 會找不到而出現錯誤訊息 */

使用 python 呼叫 DLL


 from ctypes import *  
def main():
dll = windll.LoadLibrary("DllTest.dll")
c = c_short(1)
d = c_short(3)
a = dll.ReturnAplusB(c,d)
print 'the return value : %d'%a
a = dll.ReturnAplusB(4,6)
print 'the return value : %d'%a
a = dll._Print1()
print 'the return value : %d'%a
if __name__ == '__main__':
main()


## 使用 ctypes module
## 使用 windll, 這個是用來呼叫 windows 中的 DLL.

參考:
http://hi.baidu.com/fangss007/blog/item/461d00f3dc317bc50b46e078.html

星期五, 8月 27, 2010

Install Jdownloader in Ubuntu 10.04

Open the terminal and run the following command
Terminal
sudo add-apt-repository ppa:jd-team/jdownloader
sudo apt-get update
sudo apt-get install jdownloader

星期三, 7月 28, 2010

Ubuntu 上的 Hex Editor

Bless Hex Editor
另外也有 GHex, 但沒有試過。

星期六, 5月 08, 2010

Mount nrg file

使用 kiso 就可以 mount .nrg 檔
安裝方式, 使用 command line:
apt-get install kiso

之後會在"附屬應用程式" 就可找到 Kiso

星期五, 3月 26, 2010

產生 GUID 的方式

使用 BCB compiler

#include "objbase.h"

...
void __fastcall GenerateGUID(void)
{
GUID guid;

CoCreateGuid(&guid); // win32API

AnsiString asGuid = GUIDToString(guid);

}

星期三, 2月 10, 2010

把 chm 檔解開的方式

直接在 dos 視窗下輸入:
hh.exe -decompile extracted_folder filename.chm

非常簡單 !
ref:
http://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help#Applications

星期二, 11月 24, 2009

關閉自動播放功能--使用 gpedit.msc

windows xp professional:

執行 gpedit.msc 指令,啟動「群組原則」系統工具:
-> 電腦設定->系 統管理範本->系統->關閉自動播放 (啟用這項功能)

ref: http://blog.xuite.net/webe_chen/tech/24233425?ref=rel

星期三, 10月 28, 2009

Download YouTube

利用下列的 script
javascript:window.location.href%20=%20'http://youtube.com/get_video?video_id='%20+%20swfArgs['video_id']%20+%20"&fmt=18"%20+%20"&l="%20+%20swfArgs['l']%20+%20"&sk="%20+%20swfArgs['sk']%20+%20'&t='%20+%20swfArgs['t'];

其中參數 :

fmt 參數 下載格式 最高解析度 音質 聲道
無 flv 320*240 64Kbps MP3 單聲道
6 flv 480*360 64Kbps MP3 單聲道
18(HQ) MP4 480*360 128Kbps AAC 立體聲
22(HD) MP4 1280*720 128Kbps AAC 立體聲

參考:
http://taiwan.cnet.com/blog/0,2000089057,20137871,00.htm

星期三, 9月 23, 2009

7zip command line

using 7 zip to compress files listed in backupfilelist.txt

7z a compressed_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%.7z @backupfilelist.txt

或是可以加上時間

setlocal
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyymmdd_hhmm=%date:~0,4%%date:~5,2%%date:~8,2%_%hh%%time:~3,2%
7z a compressed_%yyyymmdd_hhmm%.7z @backupfilelist.txt

星期五, 8月 28, 2009

os.path

使用 os.path.split() 分離路徑及檔名

# === code begin ===
import os
mypath = 'c:\basedir\dirlevel1\dirlevel2\myfile.txt'
basedir, myfilename= os.path.split(mypath)
print basedir, myfilename
# === code end ===

>> c:\basedir\dirlevel1\dirlevel2 myfile.txt

星期四, 8月 27, 2009

在 python 程式中呼叫另一個 python 程式

使用 os.system() 來達成

prog1.py:
# ========= code below ===

print 'this is prog1.py'

# ========= code above ===

prog2.py
# === code below ===

import os

cmd = 'python prog1.py'
os.system(cmd)

# === code above ===

星期三, 8月 05, 2009

How to transfer tuple to list

tuple 無法修改, 要修改其中的 element 就要使用 list. 把 tuple 轉為 list:

a = (1,2,3)
al = list(a)

就這麼簡單...

星期五, 6月 19, 2009

C++ Builder 中的 SysErrorMessage( )

把 GetLastError() 的 Error Code 轉為可閱讀的訊息.

Example:

dwErrorCode = GetLastError();
ShowMessage(SysErrorMessage(dwErrorCode));