Pages

Saturday, September 29, 2012

Modifying PATH environment variable Windows 7 doesn't work?

For almost a week, I had trouble adding a directory to PATH environment variable in Windows 7 64bit. I was trying to add a path of "C:\Program Files (x86)\gs\gs9.05\bin" to the PATH environment variable, but it just didn't work. I even restarted the PC although it should be unnecessary, opened the command prompt and checked the content of the PATH, but I couldn't find anything wrong. Until finally... found the culprit.. It is the whitespace.

If you add a path, just make sure not to put any whitespace between the semicolon. As an example, the following second path may not work because there is a whitespace between the semicolon ';' and the letter 'C' :
C:\Program files\program 1\bin; C:\Program files\program 2\bin;
To make it work, remove the whitespace between semicolon ';' and the letter 'C':
C:\Program files\program 1\bin;C:\Program files\program 2\bin;

That's all :)

Thursday, July 26, 2012

OSX Mountain Lion workaround to enable web sharing

I have just upgraded to Mountain Lion. But I feel very disappointed that the web sharing feature is missing. I cannot access my local site, but somehow I still can get the default apache page when accessing http://localhost/.

Here is the workaround that I did to re-enable my own site. To make it safe, make sure to make a copy of /etc/apache2/httpd.conf before modifying anything.

(1) Open terminal, switch to root:
$ sudo su -
(2) Go to /etc/apache2/users/:
$ cd /etc/apache2/users $ ls
(3) I found one file Guest.conf. I copy the file into another file (in this case I am using my own user name: chn.conf), and edit the directory location to my Site location in "/Users/chn/Sites":
$ cp Guest.conf chn.conf $ vi chn.conf
It looks like this after the modification:
<Directory "/Users/chn/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
(4) Let apache load PHP module, by editing the httpd.conf:
$ vi /etc/apache2/httpd.conf
Search for the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
and remove the remark "#" in the beginning of the line so it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
(5) Restart the apache service by the following command:
$ apachectl restart
Now I can access my own homepage again.

That's all :)

Monday, July 16, 2012

How to do screen capture in MacOSX in JPG instead of PNG

In MacOSX, we can easily do screen capture and save the image in PNG format to the desktop by the following keyboard shortcuts:
  • Comand+Shift+3 : capture the whole screen.
  • Comand+Shift+4 : capture a particular area by specifying the area using mouse, or by pressing spacebar to select a window.
Nevertheless, we may want to save the screen capture file in a different file format, such as JPG or maybe PDF. To do so, apply the following command in the terminal (the example is using JPG format):
$ default write com.apple.screencapture type jpg $ killall SystemUIServer

That's all :)