2011年1月31日 星期一

一個好用的 irssi plugin - irssi-libnotify

irssi 是一個在終端機文字模式下面連 IRC 的工具
通常 irssi 的使用方式是搭配 screen 或是 tmux
然後找一台一直開著 BSD/Linux 主機在上面掛著
不過也有的人用久了即使是在本機上面使用也是開 irssi
然後就會開始想著有沒有辦法在別人丟你訊息的時候能夠在桌面上跳出通知
irssi-libnotify 就是這樣的工具
在 GNU/Linux 上面使用要另外搭配 notify-send 這個指令
如果使在 Ubuntu 上面就是直接安裝 libnotify-bin 這個套件

首先把 notify.pl 裝進 .irssi/scripts/ 底下
$ mkdir -p ~/.irssi/scripts/
$ wget http://irssi-libnotify.googlecode.com/svn/trunk/notify.pl -O ~/.irssi/scripts/notify.pl

使用方法是在 irssi 啟動後輸入
/load perl
/script load notify

這樣之後當別人丟訊息的時候就會收到桌面通知了~ :)

P.S. 目前有中文亂碼的問題

2011年1月5日 星期三

BetaRadio v1.2 釋出

功能跟 v1.1 一樣沒有改變,不過程式碼完全使用 Vala 重寫一遍。
原始碼下載:http://betaradio.googlecode.com/files/betaradio-1.2.tar.bz2
編譯方法請參考 http://code.google.com/p/betaradio/wiki/InstallationFromSourceCode

PPA for Ubuntu 9.10/10.04/10.10
$ sudo add-apt-repository ppa:fourdollars/betaradio
$ sudo apt-get update
$ sudo apt-get install betaradio

2010年12月19日 星期日

在 Mac OS X 10.4.11 上使用 MacPorts 1.9.1 來建立 Perl 以及 Python 的開發環境

在安裝 MacPorts 1.9.1 之前要把 Xcode 裝好
然後去下載 MacPorts 1.9.1 來安裝
之後再使用 root 權限執行下面這段 script 就大功告成啦~ :D
gist: 747325
#! /bin/bash
# Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
# Mac OS X 10.4.11 + MacPorts 1.9.1 -- 2010/12/19

set -e -x

# Upgrade MacPorts
port selfupdate
port upgrade outdated || (port deactivate subversion && port clean subversion && port install subversion)

# Install Perl
port install perl5 +perl5_12

# Install Python
port install python27 +no_tkinter
port install python_select
python_select python27

# Install Vim
port install vim +perl +python27

# Install Git
port install git-core +python27

# Clean
port -u uninstall
以上這段 script 安裝了 perl/python/vim/git

2010年12月17日 星期五

Taiwan Radio Tuner 小更新 - 新增學術電台分類

線上版 http://fd.idv.tw/radio/ 以及 Google Chrome Extension - Taiwan Radio Tuner 都加入了學術電台的新分類

目前只有三個學術電台,分別是
  • PTT Radio - PTT Radio 網路電台
  • PTT Radio - OnlyMayDay
  • THBS - 清華大學校園電台
往後還會陸陸續續增加更多台灣的學術電台,歡迎提供資訊。

2010年11月24日 星期三

Bazaar 的分支使用方式

Bazaar 的分支使用方式與 Mercurial 跟 Git 都不太一樣
它比較類似 Subversion 的使用方式以下是簡單的示範

首先要建立一個 shared repository
~$ bzr init-repository hello

然後在 hello 這個目錄底下再建立個別的 branch 目錄
~/hello$ bzr init trunk

或是直接從遠端拉變更資料回來
~/hello$ bzr branch lp:ubuntu/hello trunk

如果是要做本地端分支的話,要再建立另一個新的目錄 (這邊有點類似使用 svn copy 的分支方式)
~/hello$ bzr branch trunk my-branch

如果是要建立遠端的分支的話,則是利用 Launchpad 提供的服務
~/hello/my-branch$ bzr push lp:~fourdollars/hello/my-branch

所以 Bazaar 的缺點是不像 Mercurial 跟 Git 那樣在一次的 clone 之後就可以將所有的分支都抓下來了,但是另外的好處就是由 Launchpad 提供的整合介面,讓 Patch Provider 也可以透過 Launchpad 來提 Merge Request,而 Reviewer 只要在 Launchpad 上面點一下 Accept 就可以自動 merge 了,這樣反而省下了許多指令的使用,至於是好是壞則是見仁見智囉。

參考資料:http://wiki.inkscape.org/wiki/index.php/Working_with_Bazaar

2010年10月9日 星期六

使用 GNU Build System 管理用 Vala 寫的 GTK+ 程式

延續先前的文章『使用 GNU Build System (aka Autotools) 來管理 Vala 編譯流程』

首先準備好 GTK+ 的 Vala 原始碼檔案 MyApp.vala
using Gtk;

namespace ValaTutorial
{
    class MyApp : Gtk.Window
    {
        public MyApp ()
        {
            var button = new Button.with_label ("Click me!");
            add (button);

            button.clicked.connect (on_clicked);
        }

        private void on_clicked (Gtk.Button button)
        {
            stdout.printf ("Ouch!\n");
        }

        public static int main (string[] args)
        {                                                    
            Gtk.init (ref args);

            var app = new MyApp ();
            app.show_all ();

            app.destroy.connect (Gtk.main_quit);

            Gtk.main ();
            return 0;
        }
    }
}
然後再準備一個 Makefile.am
# AM_VALAFLAGS = --pkg gtk+-2.0            

bin_PROGRAMS = MyApp

MyApp_SOURCES = MyApp.vala
MyApp_CPPFLAGS = @GTK_CFLAGS@
MyApp_LDFLAGS = @GTK_LIBS@
MyApp_VALAFLAGS = --pkg gtk+-2.0
第 1,8 行是 Vala 使用外部函式庫時需要的參數,視實際需求選擇使用
效果相當於
$ valac --pkg gtk+2.0 MyApp.vala
最後是自動產生並修改過後的 configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([hello], [0.0], [foo@bar.com])

AM_INIT_AUTOMAKE([-Wall -Werror foreign])

# Checks for programs.
AC_PROG_CC
AM_PROG_VALAC([0.8.0])

# Checks for libraries.
AM_PATH_GTK_2_0                                                 

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
第 14 行會產生出 Makefile.am 所需要的 @GTK_CFLAGS@ 及 @GTK_LIBS@
最後就是一般 GNU Build System 慣用的指令
$ autoreconf -if
$ ./configure
$ make
參考資料:

2010年10月8日 星期五

使用 GNU Build System (aka Autotools) 來管理 Vala 編譯流程

首先要先安裝好需要的軟體套件

以 Ubuntu 10.04 為例
$ sudo apt-get install autoconf automake pkg-config valac vim

Ubuntu 10.04 上面的 Vim 並沒有提供 Vala 的語法著色
還好官方網站上面已經有提供了 Vala/Vim
照著做一遍就好了

準備一個的 hello world 原始碼檔案 hello.vala
void main() {
    stdout.printf("Hello world\n");
}

接者寫一個 Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = hello.vala
hello_CPPFLAGS = @GLIB_CFLAGS@
hello_LDFLAGS = @GLIB_LIBS@

然後將 autoscan 產生出來的 configure.scan 更名為 configure.ac
$ autoscan
$ mv configure.scan configure.ac

再修改成下面這樣
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.65)
AC_INIT([hello],[0.0],[foo@bar.com])

AM_INIT_AUTOMAKE([-Wall -Werror foreign])

# Checks for programs.
AC_PROG_CC
AM_PROG_VALAC([0.8.0])

# Checks for libraries.
AM_PATH_GLIB_2_0(,,,[gobject])                                  

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

第 7 行的
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
會產生一些處理 Makefile.am 的工具出來

第 10 行的
AC_PROG_CC
會檢查 C Compiler 因為 Vala 最終還是會產生 C 的原始檔案

第 11 行的
AM_PROG_VALAC([0.8.0])
當然就是檢查這篇文章的主角 Vala 囉

第 14 行的
AM_PATH_GLIB_2_0(,,,[gobject])
會產生出在 Makefile.am 所使用的 @GLIB_CFLAGS@ 跟 @GLIB_LIBS@
還有會使用到 glib 裡面的 gobject 這個 module

接下來就如同一般的 GNU Build System (aka Autotools) 的慣用方法
使用以下命令來產生 configure 腳本檔案
$ autoreconf -if

然後就是 ./configure && make && make install 這類常見的指令連續技囉~ :P