enrii.blog

A passionate programmer’s findings in the world of internet.

Using wget for Server Migration

January 19th, 2012

I thought wget is solely good for downloading stuff when you ssh to your server, it can also be used to access FTP account and recursively pull everything over!

wget -r -l 100 ftp://login:password@domain.com/public_html

-r for recursive
-l 100 for 100 level of depth, wget has a default depth of 5 levels only

I learned about this from this site, but he didn't mentioned about depth. I have to redo the whole process and my client had to wait longer.

Hope you find this useful.

Redirect a Directory to New Location using .htaccess

October 19th, 2011

After migrating system from temporary server to a new server, we will have to request all users to go to the new site.

I am not an expert in Apache rewrite rules, but finally found this way to redirect everything from a specific directory to a new location.

RedirectMatch 301 / http://blog.enrii.com

Save the file as .htaccess, then put the file into the folder you want to redirect (should be somewhere inside your htdocs folder). Replace http://blog.enrii.com with the new site that you want to redirect.

In case it doesn't work, see if the following line in httpd.conf is commented:

LoadModule rewrite_module modules/mod_rewrite.so

Un-comment it if necessary.

That's how I finally got it working. Please let me know if I am not doing it correctly.

Mac OS X Lion

September 11th, 2011

One Apple product after another. Just upgraded to Lion from Snow Leopard on my Macbook Air. Postponed the upgrade for until now due to limited space on my 64GB SSD, also partly due to new process spawned in my personal life.

Although most of the new features are exciting, I find some features in Lion annoying. Apple likes to make decision and thinks that everyone would be happy with their product, either they like or they will have to get use to it then like it. I agree that this approach is the only way to keep things simple and nice.

One such annoying feature would be "Reopen windows when logging back in". I have heard about Mac users who never shuts down the machine because they want to keep their halfway work. This feature will be a great addition for these people. It's not for me, I always like to turn off everything and shut down at the end of day and start from fresh the next day. This feature does not allow me to do something as simple as this!

I will have to untick the checkbox on every shut down. I really need Mac to remember my last input during previous shut down.

As for the good, one main exciting feature for me would be the enhancement to Mail.app that made it works like a real email client.

Other notable feature would be the "natural" scrolling. It actually feels very unnatural in the beginning. Only after you recall how iPad works, it feels much more natural. But scrolling backwards with a mouse doesn't feel natural at all. Had to get the free Scroll Reverser to reverse mouse scroll.

So, was it worth my USD29.90? Maybe. At some point I think Apple is charging more than Microsoft because this is merely increment of 0.1 version instead of a whole new version.

Would be very interested to know what is the conversion ratio from Snow Leopard!

iPad from Singapore

September 6th, 2010

Apple iPad

Apple products are really tempting. I can't imagine myself being one of those geeks who would travel all the way to another country to purchase an Apple product just because I couldn't get it in my country.

Before I left for Singapore 2 days ago, we (my wife and I) have decided not to get iPad, reasons being:

  1. The first version of everything could potentially has undetected flaws. As a developer myself, I always believe end user testing would be the best testing, and iPad has not been in the market long enough and I don't want to be white rat.
  2. There are much more iPad competitors coming up very soon, mainly the Samsung Galaxy Tab that runs on less restricted Android platform.
  3. There are also rumours saying Apple is going to launch a mini iPad which could be much more convenient to bring around.
  4. There is no reason to get an brand new device and jailbreak it the second day, then lose it warranty. I have subscribed to home broadband, office broadband and BlackBerry unlimited packages, and I will need to get another 3G broadband for my iPad. I need to get iPad to tether with BlackBerry and that is not possible unless you jailbreak it.
  5. There are also rumours saying iPad will be in Malaysian Apple store very soon. Why the hassle?

There are much more reasons for not getting iPad at this moment.

All the reasons suddenly dismissed from our mind when we saw the Singaporeans travelling in MRTs surfing net with iPad. We saw some GeekCamp attendees surf net with iPad.

We also thought it wouldn't be easy to find iPad as it could have been wiped out by the Singaporeans, especially the entry level 16GB wifi units.

However, we really can't deny our luck when we found it at the fourth Apple store, and we have to get ourselves the iPad which damaged us SGD729. Not too expensive but not cheap too.

After owning it for less than 48 hours, I have a mixed feeling with the device.

It really changed the way people uses computer. Apple has done it again. It makes me feel like laptops will not stay for long, or the market share of laptop will drop tremendously.

I believe there are more than 50% of the users who are using computers solely for internet (or Facebook). Big portion of this user group will definitely go for iPad or similar device if they did not fall for netbooks earlier when it hit the market a year ago.

The only downside of the device, is the touch screen keyboard which I was unable to get used to it yet. Although it's hard to type on screen and I keep on getting typos, can see that the iPad is working hard to help me correct the spelling as I type. If much more effort were to be put on typo corrections, users will definitely enjoy the device more.

With all that being said, I don't think it suits me. The problem is not the device, the problem is me.

I do not see it replacing my BlackBerry or MacBook Pro. I'd still prefer to read on my BlackBerry while I commute on public transport because it's not small enough to be carried around. I will still have to use my MacBook to get my work done. There is no point adding a third device into my already heavy bag.

It shall only serve as a device for some light surfing at night, or for some urgent work in the shopping mall, on a non-working day. It's much more for my wife (for her favourite Angry Bird game) than myself.

Windows XP: Troubleshooting Blue Screen (c0000218)

September 2nd, 2010

If you work as computer support at any place, blue screen is inevitable. Haven't seen any blue screens on Windows 7 yet, but having more than ten Windows XP's in the company, I'm keep getting complaint calls.

The initial problem reported:

The computer cannot go past the Windows start up logo screen, then it restarts automatically. After restart, the computer asks whether to go into Safe Mode or to start computer normally.

In my case, the computer hangs or reboots automatically no matter which option I choose.

To get actual problem:

Keep pressing F8 on start up to get into Windows Advanced Options Menu. Then select Disable automatic restart on system failure.

By doing so, the computer will continue to load until the blue screen shows up. That's the place where you could get the error message.

The error I found:

Stop: c0000218 {Registry File Failure} The registry cannot load the hive (file): \SystemRoot\System32\Config\SOFTWARE or its log or alternate

The solution for all kinds of registry problem, in short:

Format the damned PC.

The solution for registry recovery, in long:

The five registry files to be recovered are:

  • system
  • software
  • sam
  • security
  • default

Procedures to copy all registry files from C:\windows\repair\ folder to C:\windows\system32\config\ folder:

  1. Using Windows XP installation CD, get into Recovery Mode.
  2. Go to C:\windows\system32\config folder.
  3. Backup the 5 registry files to a temporary folder.
  4. Copy the 5 registry files from C:\windows\repair\ folder to C:\windows\system32\config folder.
  5. Enter exit to restart to computer.

Procedures to get into Safe Mode to copy last known good registry files to be restored:

  1. Upon start up, press F8 and select Safe Mode to get into Windows Safe Mode.
  2. Get into C:\System Volume Information\_restore{XXXX}\RPXX\snapshot\ (Rule: Check the properties of the folder to get the date of the backup. Always take the latest version.)
  3. You will find these files:
    1. _REGISTRY_USER_.DEFAULT
    2. _REGISTRY_MACHINE_SECURITY
    3. _REGISTRY_MACHINE_SOFTWARE
    4. _REGISTRY_MACHINE_SYSTEM
    5. _REGISTRY_MACHINE_SAM
  4. Copy the files to another temporary folder, preferably to be in C:\Windows folder.
  5. Rename all the 5 files to its original name, e.g. _REGISTRY_USER_.DEFAULT to default.

Finally, get back to Recovery Mode to replace the files you have found from System Volume Information to registry original folder (C:\windows\system32\config).

Done. You should now be able to start your computer normally.

This same procedure will help you recover all kinds of registry corrupted problem that you ever get.

I am trying to keep this guide simple and short, for myself, because I found that the guide provided by Microsoft is too lengthy. You may refer to the Knowledge Base page if this guide does not make any sense.