Pages

Wednesday, February 27, 2013

Change screen resolution of Ubuntu 12.10 on Parallels 7

When I installed Ubuntu 12.10 using Parallel 7 and installed the Parallels Tools, it seems that the screen resolution is fixed to 800 x 600 pixels only. Gladly that there is a workaround for this problem. It is by using the Parallels Tools from Parallels 8. Credit to the post here: http://forum.parallels.com/showpost.php?p=657046&postcount=53 The steps are as follows:
  1. Download the trial version of Parallels 8.
  2. Mount the dmg file of Parallels 8.
  3. Open terminal, go to the mounted dmg, for example in my system I did like this:
    $ cd /Volumes/Parallels\ Desktop\ 8/
  4. Copy the iso file of the Parallel Tools to my home directory (or any directory), example:
    $ cp ./Parallels\ Desktop.app/Contents/Resources/Tools/prl-tools-lin.iso ~/
  5. Mount the iso from the Ubuntu 12.10, and upgrade the Parallels Tools from Ubuntu 12.10 terminal, example:
    $ cd /media/{your-Ubuntu-user}/Parallels\ Tools $ sudo ./install
That's all :)

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 :)

Sunday, May 08, 2011

Workaround for Lifehacker or gizmodo automatically redirect the browser from .com to .jp

I sometimes experienced that lifehacker.com or gizmodo.com do redirection automatically to lifehacker.jp or gizmodo.jp. Possibly that the website is either checking the ip address of the user or the browser's local language setting. This auto redirection is quite annoying when accessing the page from google search result, because instead of showing the correct page, it shows the front page of the Japanese version. To solve this annoying redirection, add subdomain "us." in front of the url of lifehacker.com or gizmodo.com page.

For example, if the original URL is:
http://lifehacker.com/5799574/top-10-fixes-for-the-webs-most-annoying-problems

it will become:
http://us.lifehacker.com/5799574/top-10-fixes-for-the-webs-most-annoying-problems

Once the us.lifehacker.com is loaded, it will stay in the English version although we omit the subdomain "us." until we delete the cookies.

That's all :)

Update 2013/4/30:
There are few changes at lifehacker and gizmodo, so that this tips is no longer working. You can check the new changes here:
http://lifehacker.com/welcome-to-the-new-lifehacker-472650381
http://gizmodo.com/welcome-to-the-new-gizmodo-481330297

That's all :)

Monday, February 28, 2011

How to hibernate instead of standby when closing the lid of macbook(pro|air)

Sometimes, we probably prefer to hibernate my mbp instead of make it standby when closing the lid. I am wondering why there is no GUI setting for this simple matter. The only way that I know is by using command pmset from the terminal window as follow:

(1) To enable the hibernate:
$ sudo pmset -a hibernatemode 5

(2) To switch back (standby):
$ sudo pmset -a hibernatemode 0

Or for more detail of pmset command, read the manual (man pmset).

That's all :)

Saturday, February 26, 2011

How to show full path in Mac OSX Finder window title bar

To show the complete path in the Finder title bar of Mac OSX (maybe only for OSX 10.5 and newer), type the following two commands in terminal:

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
$ killall Finder

And to reverse:

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO
$ killall Finder

That's all :)

Friday, January 14, 2011

How to add shortcut to sidebar OSX

To add shortcut to the finder's sidebar on OSX:
  1. drag and drop the folder or,
  2. select the folder, press: Command+T

That's all :)

Friday, December 24, 2010

Windows could not start because the following file is missing or corrupt \windows\SYSTEM32\CONFIG\SYSTEM

Three days ago, a friend asked me to recover his laptop (winXP) from the following error which always appeared during booting:
Windows could not start because the following file is missing or corrupt \windows\SYSTEM32\CONFIG\SYSTEM

The solution is straightforward from Microsoft website (http://support.microsoft.com/kb/307545). In brief:
The first step is to gain access to windows OS by replacing the broken registry file with the default registry file (windows installation CD is required). The second step is to copy the latest system restore registry file (hopefully your system restore is enabled) to replace the default registry file.

To be more detail, those steps are done as follow:

  1. boot using the WinXP installation CD, select repair

  2. after entering the command prompt, manually copy (overwrite) the registry file (SYSTEM, SOFTWARE, SAM, SECURITY, DEFAULT) from C:\WINDOWS\REPAIR\ to C:\WINDOWS\SYSTEM32\CONFIG\ (you might want to backup the original files)

  3. restart to save mode.

  4. gain access to System Volume Information folder (http://support.microsoft.com/kb/309531/), inside the folder, find sub folder with name _restore {GUID}\RPx\snapshot. For example: C:\System Volume Information\_restore{D86480E3-73EF-47BC-A0EB-A81BE6EE3ED8}\RP1\Snapshot

  5. copy the following files from the Snapshot folder to any other folders: _REGISTRY_USER_.DEFAULT, _REGISTRY_MACHINE_SECURITY, _REGISTRY_MACHINE_SOFTWARE, _REGISTRY_MACHINE_SYSTEM, _REGISTRY_MACHINE_SAM. Rename each of the files to DEFAULT, SECURITY, SOFTWARE, SYSTEM, SAM, respectively.

  6. boot using WinXP installation CD, select repair

  7. after entering the command prompt, manually copy (overwrite) the file from step (5) to C:\WINDOWS\SYSTEM32\CONFIG\

  8. restart.

  9. finish, or according to the microsoft website, you should try to restore the setting to previous restore point (Start, All Programs, Accessories, System Tools, System Restore, Restore to a previous restore point).


That's all :)

Tuesday, June 29, 2010

Colored ls in MacOSX terminal

To have a colored ls in MacOSX terminal:
  1. edit or create ~/.profile
  2. add line:
    export CLICOLOR=1

That's all :)

Friday, February 12, 2010

Emulating HASP HL Basic

About a month ago, I was asked to remove the protection of a software (it looks like the software is specially developed --not for public sale) which is using usb key to protect the unauthorized execution.

First of all, I would like to give credit to the reverse engineering team board, even though I never post any message there, but their board contains invaluable information to help me complete this task. Please notice that I share this information only for educational purpose and only as a note for myself. If you have trouble, please don't ask me. Go to the board instead. :)

Gladly, the usb key type is HASP HL Basic, which is simpler to emulate. Here is the step I've done to successfully emulate the usb key:
  1. Get the password-1 and password-2 of the usb key
    Tool required: hasploger
    Plug the usb key and run hasploger. Then, execute the protected software. Hasploger will be able to get the password-1 and password-2 of the usb key.
  2. Dump the usb key (password-1 and password-2 from step (1) are required)
    Tool required: h5dmp
    The size of the dump file is 719 bytes (hasp.dmp)
  3. Create dummy memory file
    Tool required: any, notepad text editor is also possible
    Since hasp HL Basic does not contain memory, create file with any content with size 112 bytes (hhl_mem.dmp)
  4. Convert the dump file from step (2) and (3) to registry file to be used by emulator
    Tool required: UniDumpToReg
  5. Install emulation
    Tool required: I am using multikey_19.0.2-x86 to emulate the key in vista (32bit). While in XP I am using vbus_0.15.4.
    By using the example of registry file from multikey/vbus, modify the registry file from step (4). Then, install the registry and the emulation tool.
  6. Done.

All of the tools are available freely in the internet, however, it takes time to find.

That's all :)

Update #1 (2010/11/03)
I've just realized that I miss-typed when I checked my files,the correct multikey file that I was using is multikey_18.0.2-x86. Probably there's a new update now since it had been months.

That's all :)

Friday, October 30, 2009

How to set NetBeans locale to English

My Windows OS has Japanese language as its default locale. However, I am still having troubles understanding Japanese anyway lol. When I try to install JDK+NetBeans, by defaults it will start with the default locale of my system --that is Japanese. After googling here and there, finally found the way to run the NetBeans in English:

Execute the NetBeans with startup parameter --locale:
netbeans --locale en

or

Edit the configuration files (usually in \etc\netbeans.conf), find the entry started with netbeans_default_options="..." and insert the locale parameter to it:
netbeans_default_options="--locale en ..."

Reference:
http://wiki.netbeans.org/FaqMessagesInEnglish

That's all :)

Saturday, July 25, 2009

How to merge file dll to exe C#

Today, at work I have to create a demo application using C# to automatically launch IE and open certain URL and modify its form input. Since this task requires SHDocVW and MSHTML components, I have to let dll files accompany the exe file. But there is a requirement that the application shall consist of one single executable. Hence, I have to find a way to merge the dll to executable. Gladly, after searching in the internet, I found that it is very simple.

The step is as follows:

  1. Download ILMerge from microsoft site here.

  2. Install and copy the ilmerge.exe to windows directory or simply make the PATH to installation directory (to let us execute ilmerge.exe from anywhere)

  3. Go to the project properties, Build Events. Assuming the dll files are in the same directory of the Target, enter the following code to the post built even command line:
    ilmerge /wildcards /out:$(TargetDir)my-final-app.exe $(TargetPath) $(TargetDir)*.dll

To have a better understanding on how to execute ilmerge, I suggest to read the ilmerge.doc which is located in the installation folder.

That's all :)

Thursday, April 16, 2009

how to change gimp language setting

After changing some regional and language settings in my vista to Japanese, if I run gimp, it displays unreadable character instead of English. I found this url is very helpful to change the language of gimp (in XP, Linux, and MacOSX):
http://docs.gimp.org/en/gimp-fire-up.html#gimp-concepts-running-language

For vista, it is very similar with XP, example is to use English (en):
  1. go to control panel, system, advanced system settings
  2. click Environment variables..
  3. add new environment variable (click New...):
    variable name: LANG
    variable value: en
  4. Ok. Finish.

That's all :)

Thursday, April 02, 2009

Cannot display Hidden Folders and Files

If you have just infected by some worm or mallware, probably your windows cannot display hidden folders and files although you already set the hidden files options from explorer.
Copy paste the following text to notepad, and save it (for example: repair.reg), then double click to make changes to windows registry.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden]
"Text"="@shell32.dll,-30499"
"Type"="group"
"Bitmap"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,53,00,\
48,00,45,00,4c,00,4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,34,00,00,\
00
"HelpID"="shell.hlp#51131"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\NOHIDDEN]
"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"Text"="@shell32.dll,-30501"
"Type"="radio"
"CheckedValue"=dword:00000002
"ValueName"="Hidden"
"DefaultValue"=dword:00000002
"HKeyRoot"=dword:80000001
"HelpID"="shell.hlp#51104"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL]
"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"Text"="@shell32.dll,-30500"
"Type"="radio"
"ValueName"="Hidden"
"DefaultValue"=dword:00000002
"HKeyRoot"=dword:80000001
"HelpID"="shell.hlp#51105"
"CheckedValue"=dword:00000001

That's all :)

Tuesday, March 31, 2009

How to change ubuntu resolution in Virtual Box

Today, I'm installing Ubuntu 8.04 in Virtual Box, with Vista as the host OS. I'm planning to use it as Qtopia development environment. After the installation is completed, I found that the maximum resolution I could set was only 800x600. After some googling, found the solution as follows:

  1. install linux guest additions in virtual box
    1. Select from menu: Devices, Install Guest Additions... Ubuntu will detect a new CD inserted and mount it automatically.
    2. go to the terminal, run the VBoxLinuxAdditions.run as root
      $ sudo /media/cdrom/VBoxLinuxAdditions-x86.run

  2. edit /etc/X11/xorg.conf using any text editor you're familiar with.
    1. Find section "Device" as follows:
      Section "Device"
              Identifier      "Configured Video Device"
              ...
      EndSection
      Insert additional setting so that the section "Device" will look as follows:
      Section "Device"
              Identifier "Configured Video Device"
              ...
              Driver "vboxvideo"
      EndSection
    2. Find section "Screen" as follows:
      Section "Screen"
              Identifier "Default Screen"
              Device "VirtualBox graphics card"
              Monitor "Generic Monitor" 
              ...
      EndSection
      Modify value of Device and Monitor, and insert some additional setting before EndSection so that the section will look similar with the following (I set resolution 1024x768 here):
      Section "Screen"
              Identifier "Default Screen"
              Device "VirtualBox graphics card"
              Monitor "Generic Monitor"
              DefaultDepth 24
              ....
              SubSection "Display"
                  Depth 24
                  Modes "1024x768"
            EndSubSection
      EndSection

  3. Finish, reboot.

That's all :)

Friday, March 20, 2009

pppd segmentation fault

At work, I have to develop an embedded system sh3 with busybox and 2.6.12.6 kernel inside it. It is connected to gsm modem through ttySC1. After shutting down several times and rebooting, the pppd occasionally got segmentation fault. The suggestion from debian bug report solves my problem. It is pretty straightforward: Simply delete /var/run/pppd.tdb file (in my system, it is /var/run/pppd2.tdb).

That's all :)

Saturday, February 14, 2009

jwgkvsq.vmx worm/virus RECYCLER folder

To clean up system which automatically creates autorun.inf and RECYCLER folder with jwgkvsq.vmx, download and run this program. After reboot, the system probably will complain about missing dll file. To fix it manually, you can use regedit or msconfig:

Regedit:
  1. run regedit.exe (start menu, run: regedit.exe),
  2. search the dll file name (CTRL+F)
  3. delete the entry which contains the missing dll file. Usually, the entry should be found on registry location: HKCU\Software\Microsoft\Windows\CurrentVersion\Run\

Or MsConfig:
  1. run msconfig.exe (start menu, run: msconfig.exe),
  2. go to startup tab
  3. Uncheck the Startup Item which contains missing dll file on the command.

To clean up the infected flash disk or external disk with FAT file system, simply delete the autorun.inf and RECYCLER folder. But if it has NTFS file system, windows will complain about having unauthorized access to the file and folder. You can use Linux and mount the NTFS volume (probably it must be mounted forcefully with options -o force), then delete them. Live CD such as Ubuntu will do.

That's all :)

Updated:
If the above cleaning process didn't work (somehow, the above process works perfectly on my PC but has no effect on my friend's), scan the system using this tool. After scanning, there are probably some unaccessible files (check the log file). then:
  1. find suspicious hidden dll file on \windows\system32\,
  2. boot to save mode
  3. change the ownership of the file (right click, properties, security, click advanced.. the rest I expect you know how.. ;) ), then
  4. change the access permissions for everyone,
  5. delete the dll file manually.

Perhaps, step (3) to (5) can be applied to remove the autorun.inf and RECYCLER folder too..

That's all :)

Updated #2:
For those who have trouble downloading from antivirus website, I add mirrors for the antivirus:
(2012/10/4: Sorry, the mirrors are no longer available).

PS. Turn off System Restore and unplug your network before executing the removal tool. Otherwise, the virus might not be cleaned up. And refer to microsoft bulletin here to update the vulnerable patch.

If none of the above methods works for you, perhaps you should try to follow the cleaning process from microsoft knowledge base here.

That's all :)

Updated #3:
If you still got problem, The FAQ about conficker from kaspersky might be helpful.

That's all :)

Saturday, February 07, 2009

Zend framework mail: broken kanji

I'm using Zend framework for most of my web projects at work. One of the must-have features is must be able to send email either scheduled routinely using cron or executed manually from the web. Somehow, I found that on certain web based email clients the contents of the email with Japanese kanji is unreadable.

I'm quite surprised that after doing many trial and errors converting the encoding type, the solution is very straightforward. Simply add a line to the header of the email contains MIME-Version information as follows:
$class->addHeader('MIME-Version','1.0');

But I still don't know why it should be added manually.. :S

That's all :)

Saturday, October 18, 2008

disable SELINUX? for smbd.log: Error was Permission denied

I've just tried to setup another samba for my new linux vmware (I'm using CentOS running on VMWare player). As I already has several linux vmware with samba, I simply copied the samba configuration from other linux which already running.

But.. to my surprised, from the new linux vmware+samba, I cannot mount the samba directory from windows. Checking /var/log/smbd.log, found the following error message:
[2008/10/18 00:26:32, 0] smbd/service.c:make_connection_snum(911)
'/home/user1' does not exist or permission denied when connecting to [remote] Error was Permission denied

I already checked that the directory /home/user1 did exist, the user for connecting was also already had permission to access. After searching for the solution, it seems the problem is related with security enhanced linux policy (called SELINUX ?). Executing man smb_selinux will explain everything what should be done. Well, since this system is only for development, I'm not concerning much for security. The easiest way IMO is by disabling SELINUX at /etc/selinux/config. lol..

SELINUX=disabled

That's all :)