修改 EXIF 的命令:exiftool

數位相機的日期設定錯了,所以拍出來的照片裡的日期也是錯誤的,就想說不知道有沒有工具可以修正。

找了一下,看到可以用 exiftool:

此外,也可以用 jhead ,視覺化介面可以用 picasa (雖然現在 Google 好像沒繼續開發了)。

修改的指令大致就是這樣子,這是要往後平移兩天的:exiftool “-ExifIFD:CreateDate+=0:0:2 00:00:0” your_photo.jpg

然後也要記得改 -ExifIFD:DateTimeOriginal 跟 -IFD0:ModifyDate 。

要查看目前的 EXIF 資訊,一樣也可以用 exiftool :exiftool -s -a -u -g1 your_photo.jpg

在 shell script 判別發行套件

一般來說,可以用 lsb_release -i ,但是如果沒安裝 lsb-release 的話,就不會有這個指令可以用;uname 只會提供架構、核心版本等資訊;/etc/issues 的話,每個發行套件對這個檔案的內容都不盡相同,難以用規則來解析。

這時候倒是可以利用 /etc/os-release ,我檢查了 Arch Linux、Ubuntu、Raspbian、Debian 幾個發行套件,發現都會有這個檔案。在檔案裡,就有不少資訊可供判別,至少都會有 ID 跟 NAME ,有些則會多了 ID_LIKE 。

  • ID 是標識,以 Ubuntu 為例,ID=ubuntu
  • NAME 是發行套件名稱,以 Ubuntu 為例,NAME=”Ubuntu”
  • ID_LIKE 是描述從哪個發行套件繁衍出來的,以 Ubuntu 為例,ID_LIKE=debian

透過 . /etc/os-release 或 source /etc/os-release ,就可以藉著使用 ID、NAME、ID_LIKE 這些變數來判別發行套件了。

參考自:command line – How to get Ubuntu distribution’s full code name? – Ask Ubuntu

BubbleUPnPServer

Server 部份是免費,主要是輔助 app transcoding (轉換格式)用的。
Windows/Linux 都可以安裝,安裝指南:http://bubblesoftapps.com/bubbleupnpserver/

依照指南,有提供 Ubuntu/Arch Linux 以及其他 distro 的安裝方法,在 Arch Linux 下要先裝 ffmpeg,這是用來轉換格式用的。用 yaourt -Ss 搜索 bubbleupnpserver,就可以找到,但結果顯示 out of date ,後來我就沒有用 yaourt 來安裝。
後來直接拿 tarball 來手動安裝,tarball 裡有提供 script 與 jar,這很簡單,Java 跨平台,再搭配 supervisord 就可以在開機時自動啟動。

因為 BubbleUPnPServer 並不是 Media Server,它算是一個 Proxy Server,所以不會跟 minidlna 衝突,但你用 BubbleUPnP app 找網路上 DLNA Server 時,會看到兩個,一台是 BubbleUPnPServer,一台是 MiniDLNA Server。指南裡是說,他可以幫你修正原來 DLNA Server 傳錯的資訊。

BubbleUPnPServer 啟動以後,可以用 Web 進去修改設定,使用的 Port 有兩個:

  • udp 1900
  • TCP 58050 (http), 58051 (https)

License 也是一個 app,在 Google Play 上可以找到,是個需要付費的 app,關鍵字一樣是 BubbleUPnP ,或是用 com.bubblesoft.android.bubbleupnp.unlocker 來找就能找到。

在 Linux 下摹擬 Serial Port

之前試 java rxtx 函式庫時找到的方法,雖然在 Linux 下都是操作檔案,不過檔案跟真的 Serial port 有點差異,後來我是用 socat 指令來摹擬。

socat -d -d pty,raw,echo=1 STDOUT

這行指令會在 /dev/pts 下建立一個 node,假若是 PTY is /dev/pts/7,那麼就 sudo ln -s /dev/pts/7 /dev/ttyS0 ,這樣 /dev/ttyS0 就可以當作 Serial Port 來用了,可以設 baud rate 等等 serial port 特有的參數。接著執行程式,可以在執行 socat 的 console 看到程式寫到 serial port 的訊息。

要對接也是可以的,這時要用:

socat -d -d pty,raw,echo=1 pty,raw,echo=1

這會在 /dev/pts 下建立兩個 node。

備註:

  1. 要用 ln 建 symbolic link 的原因是 rxtx 只檢查 ttyS*, ttySA*, ttyUSB* 資料來源

GitLab 與 Docker

之前就想要裝 GitLab,無奈,裝 GitLab 的相依性實在太多,後來就不了了之。時間飛快,今年年初時,知道了 Docker 這個東西,然後最近想到應該是可以把 GitLab 裝到 Docker 裡,這樣子 GitLab 的環境乾淨,也不會動到原本伺服器上的設定。於是就上網 Google ,果然已經有人做好了 (sameersbn/docker-gitlab),那就不囉唆,立刻來試試看。

網站上的安裝步驟其實已經蠻清楚了,這裡我就紀錄我改的部份。我用 fig 來進行客製化,所以就先下載他的 fig.yml,原本的 fig.yml 裡有三個 container,一個是 gitlab,一個是 postgresql,一個是 redis。我移掉了 postgresql 跟 redis,這邊我改用 host 的 mysql 與 redis,並且設定必要的環境變數。fig 的安裝一定要用 python2 的 pip 來安裝,否則會有問題,目前還沒移植到 python3 上。

要存取 host 的 mysql 與 redis,要注意幾點:

  1. 確定 host 的 mysql 跟 redis 是可以以 port 的方式存取,另外也要允許外部 IP 的連線。mysql 是修改 my.cnf 裡的 [mysqld] section,主要是設定 port ,重新啟動之後應該就可以;至於 redis,則是改 redis.conf 裡的 bind,將其改為 bind 0.0.0.0 ,重新啟動以後就可以。
  2. host 的 IP,在 docker container 裡,照理說是用 gateway 的 IP 就可以。一般都是找到 netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}' 這指令,但這得在 docker container 裡執行,fig.yml 裡沒辦法指定這個。後來是看到說直接用 host IP 也可以,所以我就直接指定,看起來是沒問題。

等設定好之後,直接 fig up,fig 就會幫你 pull image、建立 image 然後開始執行,第一次執行需要花一點時間。這邊我碰到的怪情況:

  1. docker 有問題,執行有問題,去查看 log ,看到 operation not supported 。查了很久,查不出來什麼問題,後來重開機,居然就沒問題了。事後猜想,可能是因為在 docker run 之前有更新過 kernel,archlinux 更新 kernel 都是使用 replace 的方式,或許是因為這樣而有問題。
  2. 使用預設的帳號跟密碼無法登入,這個得使用 docker exec -it gitlab_gitlab_1 bash 進入 container 裡,執行 sudo -u git -H bash -c “bundle exec rake gitlab:setup RAILS_ENV=production” 以後,就可以解決。

更換 Ubuntu 開機過程的佈景主題

Ubuntu 開機過程其實是可以更換圖片的,甚至已經提供了不少佈景主題可以使用:apt-cache search plymouth-theme

plymouth-theme-ubuntu-logo - graphical boot animation and logger - ubuntu-logo theme
plymouth-theme-ubuntu-text - graphical boot animation and logger - ubuntu-logo theme
mythbuntu-default-settings - default settings for Mythbuntu
plymouth-theme-edubuntu - Plymouth is an application that runs very early
plymouth-theme-fade-in - graphical boot animation and logger - fade-in theme
plymouth-theme-glow - graphical boot animation and logger - glow theme
plymouth-theme-kubuntu-logo - graphical boot animation and logger - kubuntu-logo theme
plymouth-theme-kubuntu-text - graphical boot animation and logger - kubuntu-text theme
plymouth-theme-lubuntu-logo - plymouth theme for Lubuntu
plymouth-theme-lubuntu-text - plymouth text theme for Lubuntu
plymouth-theme-sabily - plymouth theme for Sabily (graphical theme)
plymouth-theme-sabily-text - plymouth theme for Sabily (text theme)
plymouth-theme-script - graphical boot animation and logger - script theme
plymouth-theme-solar - graphical boot animation and logger - solar theme
plymouth-theme-spinfinity - graphical boot animation and logger - spinfinity theme
plymouth-theme-text - graphical boot animation and logger - text theme
plymouth-theme-ubuntu-gnome-logo - graphical boot animation and logger - ubuntu-gnome-logo theme
plymouth-theme-ubuntu-gnome-text - graphical boot animation and logger - ubuntu-gnome-text theme
plymouth-theme-ubuntustudio - Ubuntu Studio Plymouth theme
plymouth-theme-xubuntu-logo - graphical boot animation and logger - xubuntu-logo theme
plymouth-theme-xubuntu-text - graphical boot animation and logger - xubuntu-text theme

你可以使用 apt-get install 來安裝,這些佈景主題會被安裝到 /lib/plymouth/themes/ 目錄下,安裝以後,該如何使用呢? 可以用 update-alternative 來替換,在 terminal 輸入 sudo update-alternative default.plymouth 以後,就可以選擇你喜愛的佈景主題了。

網路上也有人自行去修改 theme,調整字的位置、圖形等等的,用 ubuntu plymouth 去找,就可以找到相關的資訊了。

編譯 gcin (Ubuntu 14.04)

在 Ubuntu 14.04 編譯 gcin,需要安裝這些套件:

  • libgtk-3-dev
  • libgtk2.0-dev
  • libanthy-dev
  • libqt4-dev
  • libqt4-dev-bin
  • qtbase5-private-dev
  • libxtst-dev
  • libappindicator3-dev
  • libchewing3-dev (Optional)
  • qt5-default (Optional)
  • qtchooser (Optional)

gcin 的原始碼可以在這裡取得,在 2.8.2 裡,新酷音的支援被關掉,可以自己修改 configure 來打開設定。qt5-default 跟 qtchooser 是可以不用安裝的,這是 QT5 使用的標頭檔與工具。

fbterm

ArchLinux 裡安裝 fbterm 的方法很簡單,就 pacman -S fbterm 完以後,照說明做就行了。執行 fbterm 以後,中文卻沒正常顯示,猜想應該是沒指定字型的關係。所以我輸入 exit ,退出 fbterm,接著加裝了 wqy-microhei-lite :pacman -S wqy-microhei-lite ,接著看 man fbterm,參考裏面的說明,去修改 $HOME/.fbtermrc 裡的 font-names (.fbtermrc 在第一次執行 fbterm 時,會自動產生),將其改為 WenQuanYi Micro Hei Mono Light,並調整字體大小,然後重新執行一次 fbterm 就可以了。

在 pacman -Ss fbterm 時,有看到 fcitx-fbterm,所以 fbterm 也可以使用中文輸入法,目前只有這個。

Prolific pl2303 usb to serial In Virtualbox

原本以為,在 USB 那邊切過去就可以,但 Guest 裡的 Windows XP 在安裝驅動程式以後還是無法使用。

後來還是在 VirtualBox 裡設定,啟用 COM1,然後連接埠模式選”主機裝置”,連接埠設 Ubuntu Host 偵測到的 “/dev/ttyUSB0″。這樣應該是沒問題,再看看。