Author Image

Michael Chen 的技術文件

程式設計、開放原始碼軟體、技術雜談

Cover image

In Perl, you do not need to declare the type of a variable in advance. Sometimes, it is confusing because you do not know the type of the variable and you do not know what method to use. By using ref with a object, you can know the class (or type) of the object. Say we want to extract some data from some xml files. XML::LibXML is Perl binding for 繼續閱讀

Cover image

Since hash is a one-way relation, you cannot directly sort by hash values and get hash keys in Perl. However, by customized sort subroutine, you can also sort by hash values. This post shows the trick. You still need hash keys for later use, so we sort hash keys here. The catch is in the by_value subroutine. Here we pass $a and $b to the subroutine and compare them by 繼續閱讀

Cover image

According to the official page, rJava is a Low-level interface to Java VM very much like .C/.Call and friends. A strange error occurs while I try to load rJava insido RStudio. Reason: image not found According to the thread, starting RStudio and setting LD_LIBRARY_PATH variable from terminal can solve the problem. $ LD_LIBRARY_PATH=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/server: open -a RStudio You may make an alias for the command in ~/.bashrc. 繼續閱讀

Cover image

When we want to search from a page, we open the search page and type keywords in the search bar. It is annoying to repeat the process multiple times. Is there faster way to reduce the repeat? Firefox bookmarks comes with a convienent function called keyword search. You can try a built-in keyword search now by typing google keyword in the location bar. ! To use keyword search in Firefox, 繼續閱讀

Cover image

Coherent PDF Tools is a command line PDF tool for Windows, Mac and Unix. It is free for non-commercial use. I wanted to remove all bookmarks in the PDF file and re-edit them and Coherent PDF Tools can remove all bookmarks in single command. After some try, it simply worked. Here I introduce how to edit bookmarks with Coherent PDF Tools. This tutorial was tested on OS X 10.9. Coherent 繼續閱讀

Cover image

JavaScript is a popular web language initially implemented on Netscape Navigator and later adapted on virtually all browsers. Since a JavaScript engine is a part of a browser, we had to embed JavaScript file in a HTML page, to load the script from the browser, and to use function like prompt() or alert() to receive from and response to developers. Nevertheless, with Node.js, we can program in JavaScript like in 繼續閱讀

Cover image

If we want to convert comma- or space-seperated text files to Excel ones, we have to open Excel and do manual conversion. Is there automatic way to do batch conversion? Of course, you can do batch conversion without opening Excel with Data::Table::Excel. Data::Table::Excel is a Perl module to convert between Data::Table objects and Excel (xls/xlsx) files. Data::Table reads CSV, SQL database and Excel files and converts them to CSV, HTML 繼續閱讀

Cover image

For GUI mac software, AppCleaner is an easy way to safely and cleanly uninstall it on Mac. However, there is no easy method to uninstall PKG packages on Mac. I have written a small script to uninstall PKG packages on my homebin repo. You can easily download it with curl or wget. $ curl https://raw.githubusercontent.com/cwchen123/homebin/master/removepkg > removepkg $ chmod +x removepkg $ mkdir /usr/local/bin $ mv removepkg /usr/local/bin The script 繼續閱讀

Cover image

Although some system package managers on Linux or Unix provides Ruby gems as package, you still want to gem to install updated or specific gems sometimes. One popular way is using RVM, a command-line tool which allow you to manage multiple Ruby environment. Nevertheless, if you do not need multiple Ruby versions in one system, you may also choose to install Ruby gems to local directories like home directory. By 繼續閱讀