2011年1月7日

在 ubuntu 10.04 安裝 gretl 1.9.3x - 有關 gnuplot 的問題

用 gnuplot for gretl 的方法, 但是有錯誤(在執行 gnuplot 時):
XXX@ubu1004:/$ /opt/gnuplot/bin/gnuplot
/opt/gnuplot/bin/gnuplot: error while loading shared libraries: libwx_gtk2u_richtext-2.8.so.0: cannot open shared object file: No such file or directory
找了很多方法, 都不能決解, 
後來乾脆直接下載 gnuplot (4.4.0-1)  (for maverick ) 的 binary 檔來試試
 @ http://packages.ubuntu.com/maverick/gnuplot

但要先安裝

gnuplot-nox (>= 4.4.0-1)
gnuplot-x11 (>= 4.4.0-1)
裝好以後 gnuplot 的部份應該OK了 (可以在終端機中打 gnuplot, 看版本是不是 4.4)
接著安裝我自已打包的 gretl_1.9.3-1_i386.deb

安裝好 gretl 之後, 依 在 ubuntu 9.10 裝 自行打包的 gretl 1.8.6 這篇的說明:

  • 1. 在 /usr/local/lib 下, 找到 libgretl-1.0.so.0 和其它 3 個以 libgretl* 開始的檔案, 都複製到 /usr/lib 
  • 2. 找不到 lapack.so.0 ...
  • /usr/local/bin/gretl_x11: error while loading shared libraries: liblapack.so.3: cannot open shared object file: No such file or directory
少了 lapack, 試著在 synaptic 裝 liblapack-dev, 之後用管理權限, 在 /usr/lib 下, 找到 liblapack.so, 複制成 liblapack.so.3; 再用管理權限, 在 /usr/lib 下, 找到 libblas.so, 複制成 libblas.so.3Ok 了, gretl 和 gnuplot 都可以正常執行了

2010年12月28日

在 ubuntu 9.10 安裝 gretl 1.9.3x - 有關 gnuplot 的問題

如果覺得自行 compile 麻煩的話, 不妨試試 [在 ubuntu 10.04 安裝 gretl 1.9.3x - 有關 gnuplot 的問題] 這一篇的方法

gretl 網站的原始方法
這個步驟是成功的: see Install Gnuplot 4.4.0 on Ubuntu Linux
sudo apt-get install libwxgtk2.8-dev libpango1.0-dev libreadline5-dev libx11-dev libxt-dev texinfo libgd2-xpm-dev

Then we download and compile gnuplot (run each command/line in a terminal)
  • wget http://sourceforge.net/projects/gnuplot/files/gnuplot/4.4.0/gnuplot-4.4.0.tar.gz/download
  • tar xzf gnuplot-4.4.0.tar.gz
  • mkdir build && cd build
  • ../gnuplot-4.4.0/configure --with-readline=gnu
  • make
  • sudo make install
Compile 後, gnuplot 的子目錄位置是:
/usr/local/bin/gnuplot


用 gnuplot for gretl 的方法, 但是有錯誤(在執行 gretl 時):
/opt/gnuplot/bin/gnuplot: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /opt/gnuplot/bin/gnuplot)


另外有成功地 compile gnuplot, 在安裝以下的 packages 之後 (參見):
sudo apt-get install automake checkinstall libwxgtk2.8-dev libpango1.0-dev libreadline5-dev libx11-dev libxt-dev texinfo libgd2-xpm-dev  liblua5.1-dev

另見 gnuplot 4.4.2@sourceforge

再執行:

./prepare
./configure --with-readline=gnu --with-lua


*from http://gretl.sourceforge.net/gnuplot_for_gretl.html

Build from source

Note that for this to succeed you will need to have the "devel" packages for GTK+ and Xorg installed.
export CVSROOT=:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot
 cvs login
 cvs -z3 checkout gnuplot
Just hit Enter when asked for a password. Then
sh ./prepare
 ./configure --prefix=/opt/gnuplot
 make
 sudo make install
The choice of installing to /opt/gnuplot is designed to avoid collisions with gnuplot as installed by your Linux distro.

Packaged binary

If you would prefer to try a pre-built binary, use the following commands to download and install the package.
cd /tmp
 wget http://ricardo.ecn.wfu.edu/pub/gretl/gnuplot-4.5-i586-3.tar.gz
 cd / 
 sudo tar xvfz /tmp/gnuplot-4.5-i586-3.tar.gz
 rm /tmp/gnuplot-4.5-i586-3.tar.gz
Note that this package installs into /opt/gnuplot.

Using the new gnuplot

In gretl, go to Tools/Preferences/General/Programs and change the "gnuplot" entry to read
/opt/gnuplot/bin/gnuplot

* see also Compiling GNUPLOT from CVS with Ubuntu

2010年12月20日

Better RSS Widget for Wordpress

*source: Better RSS Widget
Better RSS Widget 這個 wordpress 的外掛還滿好用的, 它可以將 RSS 放在 sidebar 或正文 (post) 當中, 不過放在 sidebar 好像會讓網頁開啟變慢...

short code 的用法
[better-rss feed=http://careercycu.wordpress.com/feed/ show_date=1 show_summary=1 excerpt=100 items=5]
參見 Support 討論頁

2010年12月15日

控制 wordpress 文章的中文摘要 (expert) 字數

在 function.php 中加入以下的 php 碼

[code]
function utf8_trim($str) {

    $len = strlen($str);

    for ($i=strlen($str)-1; $i>=0; $i-=1){
        $hex .= ' '.ord($str[$i]);
        $ch = ord($str[$i]);
        if (($ch & 128)==0) return(substr($str,0,$i));
        if (($ch & 192)==192) return(substr($str,0,$i));
    }
    return($str.$hex);
}
function mul_excerpt ($excerpt) {
     $myexcerpt = substr($excerpt,0,500);
     return utf8_trim($myexcerpt) . '... ';
}

add_filter('the_excerpt', 'mul_excerpt');
add_filter('the_excerpt_rss', 'mul_excerpt');
[/code]

wordpress 要怎樣才會有 特色圖片

有時裝上某些 theme 會有 "設定特色圖片" (thumbnail) 但有些沒有...
在 主題編輯器下 (theme editor) 的 function.php 中加入下列一行 PHP 指令, 即會跑出 "設定特色圖片" 選項了!

add_theme_support('post-thumbnails');

2010年12月14日

Wordpress 安裝外掛或主題時, 資料夾權限問題

前一篇發現了 Wordpress 安裝外掛或主題時, 資料夾權限問題, 變成要另裝 vsFTP 才能上傳的問題, 在 WordPress搬家注意事項之資料夾、權限設定, 這篇文章得到更方便的解決方法:


開啟 wordpress 根目錄下的「wp-config.php」文件,在最後一行上添加下方代碼。

/** 設定新主機資料夾權限 **/
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

即可!

2010年12月11日

安裝 wordpress 在 ubuntu 10.04

上次發現將 wordpress 安裝在 ubuntu 10.04 上, 媒體檔案上傳時,就可以用中文檔名 (在 windows 平台上不行),但要安裝佈景主題 (theme) 或外掛 (plugin) 時,竟要輸入 “Connection Information“ :

Hostname:127.0.0.1
FTP Username:
FTP Password:
Connection Type:
等資訊。這在安裝在 windows 平台時是沒見過的。看起來是要 ubuntu 上裝一個 FTP server。
在 Google 一番之後,我安裝了 vsftp, 並修改了 /etc/vsftpd.conf 這個預設的資訊檔, 裡面多半採用預設值即可,只有一個特別要注意的是

#local_umask=022

要特別加上 # 號,否則會出現:

Could not create directory. /var/www/wp-content/XXX ...

這種問題。本以為是目錄權限設定不好,但弄了很久,才猜到可能是上述的 FTP 上傳後 unmask 的問題,加上#之後,果然就正常了!

註:
1. vsFTP 帳號用原來的 ubuntu 帳號即可
2. 重新啟動 vsFTP 的指令:

sudo /etc/init.d/vsftpd start
3. 其它參考指令
netstat -ntulp |grep 21
netstat -ntulp |more
sudo /etc/init.d/apache2 restart

4. /etc/vsftpd.conf 檔中的重要內容
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
#local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
#connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem