Posts

Latex installation on Archlinux

Nowadays, if we want to use LaTeX, we have to install the texlive package for it. And it is very easy to install all of those needed packages on Archlinux. $ sudo pacman -S texlive-core texlive-langcjk texlive-latexextra texlive-pictures Then, you can enjoy it now!

Basic exception usage in php

Theory If you have not already, check the official php documentation on exceptions at http://php.net/manual/en/language.exceptions.php. Besides some php specifics, here you can find basic example how to use try catch blocks and how to work with exceptions. Example goes like this: function inverse($x) { if (!$x) { throw new Exception('Division by zero.'); } else return 1/$x; } try { echo inverse(5) . "\n"; echo inverse(0) . "\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } // Continue execution echo 'Hello World'; Through this example you can see that if a process finds itself in a problematic situation, it can throw an exception. This exception can be caught, and that way we will prevent system to run into some php fatal error. This are the theoretical basics, however, the real question is how and where to use exception handling in your  applications and scripts. Front Controller Front C...

Convert XmlDocument to XElement

XmlElement x = objXmlDocument.documentElement; You might need this if you are creating a WCF service that accepts XElement as parameter but user has a dataset to be converted to Xelement XmlDocument xDoc = new XmlDataDocument(YourDataset); XmlElement x = xDoc.DocumentElement; example :  DataSet ds = new DataSet();  ds.Tables.Add("students"); ds.Tables[0].Columns.Add("Name");  DataRow dr1 = ds.Tables[0].NewRow(); dr1[0] = "Alan"; ds.Tables[0].Rows.Add(dr1);  XmlDocument xDoc = new XmlDataDocument(ds);  XmlElement x = xDoc.DocumentElement;

NOKIA N900 upgrade

There are 3 ways to upgrade your N900. OTA Over The Air. YES! Upgrade your phone online. Its easily but might cause problems after OTA. PC suite Use NOKIA OVI suite or NOKIA Software Updater. Upgrade your phone with PC suite and backup your file before you starting. That's the safest way to upgrade your N900! But all chinese support will be lost after upgraded. Rewrite with flasher Get the flasher with latest ROM file. Rewrite the ROM with latest version. You don't have to rewrite eMMC content unless the system crashed. Besides, if you've been upgrade your phone but ran into some problems, you'd better rewrite your ROM again with the same version. All chinese support also will be lost after upgraded. You can easily done with above way for upgrading. Enjoy yourself! ps. I already upgraded my N900 to PR 1.3. XD

Why exception handling is important in php?

    I work as a professional programmer for 10 years and in those 10 years I met a bunch of different developers. In plenty of them, especially in web / php developers, I could notice a lack of understanding of the concept of throwing and catching exceptions and what does it serves for. Of course, the first I noticed it at myself. In this blog I would like to point out a number of useful things that proper use of the exception can make, and which were slipping from my hands for a few years too.      Exceptions are providing a standardized way to control problematic processes and they are reducing the possibility of fatal errors in the application . If process throws exception, you are forced to handle situation in your application, and it will automatically reduce the possibility that some problem sleeps out whit out being processed. When you're working with exceptions, you are handling problems at low level, so it will not make you problems with your highe...

Chinese font can not be show correctly with JAVA application on FreeBSD

I ran into this problem as I installed the freemind. After searching with Google, the following steps can solve the problem. Create a directory named "fallback" in JRE path # cd /usr/local/jdk1.6.0/jre/lib/fonts # mkdir fallback Link a TrueType that I wanted to the new directory # cd fallback/ # ln -s /usr/local/lib/X11/fonts/TrueType/bsmi001p.ttf ./bsmi001p.ttf Restart the JAVA application After restarting, the JAVA application will show chinese font properly. ps. Many thanks for Tim's help.

Homebrew - Another package manager for Mac OS X

前陣子在 plurk 上看到 Rex 大提到 Homebrew,一開始也不曉得那是什麼? 慢慢才知道原來是另一種套件管理工具。 今天在看到 ihower 大大的 blog 文章後,索性就動起來手來,先把 MacPorts uninstall 掉,然後再依照 ihower 大大提供的步驟把 homebrew 裝了起來。(作法請參考 ihower 大大的 原文 ) Homebrew 是一套 ruby based 的套件管理程式,它的特性如下﹕ 不佔用系統空間 不重覆安裝 mac 系統中已內建的工具 ruby based 的 portfile,易於修改、自訂 使用者可很快的建立自己想要的套件 個人用了之後,覺得 MacPorts 更新較快、內容較多,但,Homebrew 則是標榜不重覆,簡易使用。 果真簡易!