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

2010年12月10日

Apache 2 - sites.available 的設定

以下本來是試 Apache::ASP 和 mono,看可否在 ubuntu + apache 之下,跑以前寫的 asp 程式。但是發現它們多是適用 asp.net 的架構, 而不是最早以前 IIS 下的簡單 asp 語法。
看來是要忍痛放棄 IIS 了...

<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Alias /asp_web "/home/XXX/asp_web/"
<Directory "/home/XXX/asp_web/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
SetHandler mono
DirectoryIndex index.aspx default.asp index.asp index.htm index.html

</Directory>

</VirtualHost>

轉程式碼, 參見 HTML encoder