顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

plowprobe


plowdown 取消了 -c 選項,不過多了 plowprobe。

plowprobe可以輸出的格式比 plowdown -c 多了很多


printf選項比較重要的的參數
--------------------------------------------------------
* %c probe function return status (0 for success, 13 for dead link, see list below)
* %f filename (can be empty string)
* %s filesize in bytes (can be empty string if not available). Note: it's often approxi‐mative.


Return Code
--------------------------------------------------------
0 Success.
1 Fatal error. Upstream site updated or unexpected result.
2 No available module (provided URL is not supported).
3 Network error. Mostly curl related.
4 Authentication failed (bad login/password).
5 Timeout reached (refer to -t/--timeout command-line option).
6 Maximum tries reached (refer to -r/--max-retries command-line option).
7 Captcha generic error.
8 System generic error.
10 Link alive but temporarily unavailable.
11 Link alive but requires a password.
12 Link alive but requires some authentication (private or premium link).
13 Link is dead.
14 Can't download link because file is too big (need permissions).
15 Unknown command line parameter or incompatible options.


Return code 跟plowdown一樣。 裡面比較重要的是0跟13, 0=> Ok, 13=> dead link。

keepassx 2

keepassx現在有PPA可以用了。
 
sudo apt-add-repository ppa:keepassx/daily   
sudo apt-get update
sudo apt-get install keepassx

keepassx 自動開啟資料庫


使用master password開啟(折騰版XD)


 * install gnome-keyring-query to get password from gnome-keyring
 
     * sudo apt-add-repository ppa:wiktel/ppa
     * sudo apt-get update
     * sudo apt-get install gnome-keyring-query

 * start gnome-keyring-daemon
          
     gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh
              
 * settings              
    
     1. start seahorse and add a new keyring
     2. add a new key using gnome-keyring-query [set] [keyname] # 不知道為什麼只能用gnome-keyring-query設定的key才能正常動作?!
                              
 * command
          
     keepassx --password $(gnome-keyring-query get {keepassx master password}){your database}

使用keyfile開啟

* chmod database and keyfile with permission 600
           
* command

    keepassx --keyfile {your_keyfile} {your_database}

Txt to epub


requirement:
  • pandoc 1.6+

testbook content

% book title
% author
簡介


# Chapter One(章節標題的上下最好有兩行空行,這樣pandoc判讀上比較不會有問題)


Chapter one is over.


# Chapter Two


Chapter two has just begun.

 

 command

pandoc input_file -o output_file
 
 
參考:

命令列下複製多個檔案與批次轉換圖檔

Copy range of files

cp file{01..34}.bmp [dst]

Batch convert BMP to JPEG

  1. mogrify -format jpg *.bmp
  2. for i in *.bmp; do convert ${i} ${i%bmp}jpg; done # {i%bmp} 會把bmp去除
  3. find -name *.bmp -type f -exec convert '{}' '{}'.jpg ;
Reference:

Build KeePassX v2.0 alpha4


KeePassX終於可以相容於Keepass2了, 這下可以擺脫keepass2 + mono了。
主要是使用mono的程式目前只有keepass2。但是卻要消耗500Mib+的硬碟空間=_=
外加程式反應慢,輸入/顯示等問題。

System: Linux Mint 13

下載:
Source code

編譯前準備:
  • cmake
  • libgcrypt11-dev
  • zlib1g-dev
Steps:
  1. mkdir build
  2. cd build
  3. cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_VERBOSE_MAKEFILE=ON
  4. make -j2
  5. checkinstall -D make install #製作.deb包,並方便日後刪除
Reference:

Zim capture

 Zim Capture 可以將Firefox中網頁中選擇的「文字」直接匯入到zim中的addon

另一個功能相同的Firefox addon

zim-clip

-----------------------------------------------------------------------------
var args = new Array("--       plugin","quicknote","text="+escaped_string,"namespace="+zimcapture.namespace,"encoding=url","option:url="+escaped_uri);
        process.run(false, args, args.length);

上面是 Zim Capture的程式碼,主要就是呼叫Quick Note這個Zim core plugin來達成。
不過Quick Note本身只支援「文字」啊。
-----------------------------------------------------------------------------
       
====== Quick Note ======
The "Quick Note" plugin offers a dialog for inserting quick notes into a notebook. It can be invoked from the commandline and can therefore easily be bound to keyboard shortcuts or used in scripts.

Dependencies: This plugin has no additional dependencies.

Commandline: zim --plugin quicknote [OPTIONS]

Options:
* notebook=URI          Select the notebook in the dialog
* namespace=STRING      Fill in the namespace in the dialog
* basename=STRING       Fill in the page name in the dialog
* text=TEXT             Provide the text directly
* input=stdin           Provide the text on stdin
* input=clipboard       Take the text from the clipboard
* encoding=url          url encoded utf-8 text
* encoding=base64       base64 encoded utf-8 text
* option:url=STRING     Set template parameter

幾個小工具

fc
===========================
Windows底下有個程式fc,可以比較兩個檔案的不同之處,並以16進位的方式輸出

Linux版:::

    cmp -l $1 $2 | awk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}'

bwrite [filename] [offset(10進位)] [data] [data_size]
===========================
非常簡單的存檔修改法

    printf $3 | dd of="$1" bs=1 seek=$2 count=$4 conv=notrunc
   
10進位 > 16進位
===========================

     printf '%x\n' 346
   
16進位 > 10進位
===========================

    echo $((0xff))


Watch Youtube

之前在Mint 11時,Minitube就有問題。 到了Mint 13還是有問題= =
解決的方法是更新到1.7.1以後的版本就可以了。
這篇稍微提到問題是因為GStreamer bug: minitube crashes on 12.04 64bit [closed]
不過官方庫裡的版本比較舊,要用PPA的版本。:
sudo add-apt-repository ppa:ferramroberto/minitube
sudo apt-get update
sudo apt-get install minitube
之前是以 gmediafinder 作為替代品,支援的網站比minitube多。
不過使用上有點小問題: 在全螢幕時會不斷模擬按下'a'鍵。(如果開著文字編輯器就很明顯了)
安裝 gmediafinder:
sudo apt-add-repository ppa:s-lagui/ppa
sudo apt-get update
sudo apt-get install gmediafinder 

ffmpeg with mp3 encoder


之前在用youtube-dl將youtube轉成mp3時,會發生問題。
原本以為要重編ffmpeg 將libmp3lame編入ffmpeg中。
現在有比較簡單的解決方法:
sudo apt-get --reinstall install ffmpeg libavcodec-extra-53 # for Ubuntu 12.04/Mint 13
參考文章:

安裝Catalyst 12.4


安裝Catalyst 12.4,網路上找到兩種裝法。
  1. 不建立發行版本的套件
  2. 建立發行版本的套件(比較麻煩點)

不建立發行版本的安裝方法
  1. 先移除之前的安裝版本:
  2. sudo sh /usr/share/ati/fglrx-uninstall.sh
    sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev* xorg-driver-fglrx
  3. 從AMD網站下載 Catalyst 12.4
  4. 執行 installer:
  5. chmod +x amd-driver-installer-12-4-x86.x86_64.run
    sudo sh ./amd-driver-installer-12-4-x86.x86_64.run
  6. 產生一個新的X設定檔:
  7. sudo aticonfig --initial -f
  8. 重開機:
sudo reboot
我照著上面的方法裝過一次,執行 dpkg -l | grep fglrx 的結果是空的@_@,不過基本上沒什麼大問題就是。
只是不能安裝影片播放硬體加速的套件。(裝上後cpu使用率有下降一些)
64bit去執行 installer --buildpkg,因為缺少32bit函式庫,會build不出來。

建立發行版本的安裝方法
  1. 要讓--buildpkg不出錯,要先作列的準備工作。:
  2. sudo apt-get install build-essential cdbs dh-make dkms execstack dh-modaliases fakeroot libqtgui4
    
    
    # 64bit 額外需要安裝下列套件
    sudo apt-get install ia32-libs-multiarch:i386 lib32gcc1 libc6-i386
    cd /usr ; sudo ln -svT lib /usr/lib64
  3. 從AMD網站下載 Catalyst 12.4
  4. 建立並安裝.deb:
  5. chmod +x amd-driver-installer-12-4-x86.x86_64.run
    sudo sh ./amd-driver-installer-12-4-x86.x86_64.run
    
    
    sh ./amd-driver-installer-12-4-x86.x86_64.run --buildpkg Ubuntu/precise # for Ubuntu 12.04/Mint 13
    sudo dpkg -i fglrx*.deb
  6. 產生一個新的X設定檔:
  7. sudo aticonfig --initial -f
  8. 重開機:
  9. sudo reboot
  10. 以root權限執行Catalyst:
  11. gksudo amdcccle
  12. 安裝影片播放硬體加速的相關套件:
     sudo apt-get install xvba-va-driver libva-glx1 libva-egl1 vainfo 

Install wine1.5


sudo apt-build --reinstall install wine # wine1.5
錯誤訊息:
E: The value 'apt-build' is invalid for APT::Default-Release as such a release is not available in the sources
apt-build version 0.12.42
雖然有錯誤訊息,不過編譯完的檔案放在 /var/cache/apt-build/repository/
自己再用 dpkg -i 手工安裝就好。
原因看來似乎是apt-build的bug? from here

# Get cpu information
cat /proc/cpuinfo
AMD Phenom(tm) II X4 945 Processor -> amdfam10
File: /etc/apt/apt-build.conf
build-dir = /var/cache/apt-build/build
repository-dir = /var/cache/apt-build/repository
Olevel = -O2
mtune = -march=amdfam10
options = " -pipe -mmmx -msse -msse2 -msse3 -msse4a -m3dnow -mpopcnt -fomit-frame-pointer -mabm -combine"
make_options = " -j4"
依照這樣的設定,大約15分鐘就可以編譯完成。比起我之前的編譯設定,速度實在是快很多啊。
參考文章:

Wine can't find gnome-keyring-pkcs11.so


System:Mint 13
在執行winecfg出現下列錯誤訊息:
p11-kit: couldn't load module:
    /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so:
    /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so:
cannot open shared object file: No such file or directory
問題的原因是Ubuntu 64bit上面沒有預設裝上32bit libs。
解決方法安裝Getblibs 參考 Getlibs – 32 bit libraries on your 64 bit Ubuntu
Steps:
# install getlibs
wget https://launchpad.net/~jcollins/+archive/jaminppa/+build/1482994/+files/getlibs_2.06-0ubuntu1%7Eppa2_all.deb

sudo dpkg -i getlibs_2.06-0ubuntu1~ppa2_all.deb
# Install the 32bit library
getlibs -p gnome-keyring:i386
# Create pkcs11 directory in /usr/lib/i386-linux-gnu
sudo mkdir /usr/lib/i386-linux-gnu/pkcs11
# Make the symbolic link
sudo ln -s /usr/lib32/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so

caja

caja toolbar button

File: /usr/share/caja/ui/caja-navigation-window-ui.xml
+<toolitem ....>
操作 XML
剪下 <toolitem name="Cut" action="Cut"/>
複製 <toolitem name="Copy" action="Copy"/>
貼上 <toolitem name="Paste" action="Paste"/>
刪除 <toolitem name="Delete" action="Delete"/>
屬性 <toolitem name="Properties" action="Properties"/>
新增目錄 <toolitem name="New Folder" action="New Folder"/>

 

caja script directory

${HOME}/.config/caja/scripts/
caja variables(caja換成nautilus一樣可以跑,為了相容吧)
Name Description
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS newline-delimited paths for selected files (only if local)
NAUTILUS_SCRIPT_SELECTED_URIS newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY position and size of current window

Name
Description
CAJA_SCRIPT_SELECTED_FILE_PATHS
newline-delimited paths for selected files (only if local)
CAJA_SCRIPT_SELECTED_URIS
newline-delimited URIs for selected files
CAJA_SCRIPT_CURRENT_URI
URI for current location
CAJA_SCRIPT_WINDOW_GEOMETRY
position and size of current window
CAJA_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS
newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)
CAJA_SCRIPT_NEXT_PANE_SELECTED_URIS
newline-delimited URIs for selected files in the inactive pane of a split-view window
CAJA_SCRIPT_NEXT_PANE_CURRENT_URI
URI for current location in the inactive pane of a split-view window

 

caja-actions

參考 http://forums.mate-desktop.org/viewtopic.php?f=17&t=36
不知道什麼時候會入庫?

apt-get 安裝指定的版本


apt-get 安裝指定的版本
  1. apt-cache showpkg <pkgname> 查詢版本
  2. apt-get install pkgname=version
參考資料:
How to install a specific version of a Debian package using apt-get

cookies.sqlite → cookies.txt

Linux下,將Firefox的cookies.sqlite轉換成curl可以接受的cookie格式:


sqlite3 -separator $'\t' cookies.sqlite \
    'select host, "TRUE", path, case isSecure when 0 then "FALSE" else "TRUE" end, expiry, name, value from moz_cookies' > cookies.txt


Reference:

Install PIL on Linux Mint 11 x64

Install PIL on Linux Mint 11 x64

# prepare:

  • libjpeg62-dev
  • zlib1g-dev
  • libfreetype6-dev
  • liblcms1-dev
  • python-dev

 

# edit setup.py

TCL_ROOT = None
JPEG_ROOT = '/usr/lib/x86_64-linux-gnu', '/usr/include' # libjpeg and libpng are here.
ZLIB_ROOT = JPEG_ROOT
TIFF_ROOT = None
FREETYPE_ROOT = JPEG_ROOT
LCMS_ROOT = None

 

# build & test & install

  • python setup.py build_ext -i
  • python selftest.py
  • sudo python setup.py install
Reference:

aria2 note

aria2 note

速度真的很快,比wget快很多。有空再來試試看XML-RPC那部份。
  • --load-cookies 讀取cookie,可以直接把Firefox的cookies.sqlite丟進來使用。
  • -U 設定user-agent
  • -j 設定同時下載數目
  • -i 輸入檔案,在設定URL的同時,還可以設定額外的參數。 詳細參照http://aria2.sourceforge.net/aria2c.1.html#_input_file
  • -j 設定同時下載的數目
  • -l logfile
  • --log-level=LEVEL (debug, info, notice, warn or error. Default: debug)

As of 1.10.0 release, aria2 uses 1 connection per host by default and has 20MiB segment size restriction.
(1 connection/host, 20MiB segment)

aria2 是把巨鎚,我試著用1.10.9版,抓取1753個頁面的資料。
結果,在3分鐘內發送完所有的request, 並抓完約158MiB的資料量。每個頁面大小約80~100KiB。
比起wget這速度是快很多。光是1 connection就有這麼快的速度,如果再多幾個connection?
想想就蠻恐怖的。或許,在使用aria2抓取網頁的時候,要好好想想怎麼利用這工具,才不會變成黑名單吧>"<。
Reference:

feh

feh速度快,只可惜1.0版不支援讀取ZIP/RAR檔案。不知道未來有沒有可能支援?
不過feh我認為最好的地方是,可以自訂按鍵對應指令(雖然數量只有9個>"<)

usage:

  • -g 設定視窗大小以 'widthxheight'的方式
  • -i 縮圖模式(Index Mode)
    -E or --thumb-height 設定縮圖高度
    -y or --thumb-width 設定縮圖寬度
    --index-dim bool 顯示/隱藏影像大小
    --index-name bool 顯示/隱藏影像檔名
    --index-size bool 顯示/隱藏影像檔案大小
    -o 輸出檔名
  • -t 類似於Index mode, 點選縮圖會出現另外的視窗顯示
  • -S or --sort 排序,除了name跟filename其他都需要配合-p參數
    • name
    • filename
    • width
    • height
    • pixes
    • size
  • --info 執行指令並將結果顯示在feh視窗下方
    feh --info="identify -format '%f: %wx%h' %f" -g 640x480 . #執行ImageMagick取得影像大小
  • --action 自訂每張圖片執行指令
  • --action[1-9] 按下數字鍵1~9,所對應的指令(只能用F1下方的數字鍵)
    feh -g 640x480 --action1="cp %f ~/" # 按下數字鍵1時將檔案複製到使用者家目錄下
    feh -g 640x480 --action2='rm %f" # 按下數字鍵2時將檔案刪除

KeePass 2.x on Mono



OS: Linux Mint 11
KeePass: 2.13

Mint 11預設安裝好了Mono 2.6.7,不過還是缺函式庫:

sudo apt-get install libmono-system-runtime2.0-cli

Usage:(不過預設字型要改一下,不然有些中文字看不到)
mono KeePass.exe

--------------------------------------------------------------------------------
04/26
現在也有打包好的.deb不用在為了Mono的問題去try....
參閱:
http://sourceforge.net/projects/keepass/forums/forum/329220/topic/4503818

Reference:
* Running KeePass under Mono (Linux, Mac OS X, BSD, ...)
* KeePass 2 / Ubuntu 10.10 not starting Monitor

VirtualBox客戶端抓不到USB?


在Linux下VirtualBox安裝完畢後,會出現客戶端抓不到USB的問題。
其實,這是安裝的時候沒有把目前的使用者加入到特定的群組當中,不知道這算不算是bug?


Linux: Mint 11
VirtualBox: 4.1.8


解決方法:
1. sudo groupadd usbfs
2. sudo adduser {current_user} usbfs
3. sudo adduser {current_user} vboxusers

Reference:
* 怎样将当前使用用户添加到vboxusers组中