Category: Tips & Tricks

Hardware upgrade for the MacBook Pro 15″ (early 2011)

In this article I will briefly describe the hardware upgrade process on my MacBook Pro 15″ (early 2011). Hopefully, it will help some of you considering to buy similar hardware. After searching for a SATA 3 6Gb/s SSD I came across the recently released hard drive from Corsair. It was relatively cheap and promised a great deal of performance. Here are the specifications of my new SSD and RAM.

SSD Specifications
Corsair ForceGT 120GB SATA 3 6Gb/s Solid-State Hard Drive
Unformatted capacity: 120GB
Read performance (max): 555MB/s
Write performance (max): 515MB/s
Interface type: SATA 3 6Gb/s

RAM Specifications
Capacity: 4GB x 2: 8GB
Compatibility: SO-DIMM, 204 Pins
Technology: DDR3 SDRAM
Speed: 1600MHz

Before the upgrade the first thing I did was creating a clone of my existing HDD in to the new SSD. Since the SSD wasn’t formatted I have created a Mac OS Extended (Journaled) partition with the GUID option. When it was ready I used the Carbon Copy Cloner to copy the content from my HDD.

You can find the instructions on the following video.

iFixit also has a nice guide on its website. Link1 and Link2.

Once everything was put in place, it was time to start the MBP. In my case it took a bit too long for the login window to appear. In fact it was longer than my old HDD. It was perhaps due to hard drive cache. So I reseted the cache following the instructions on Apple help pages. After the PRAM reset the booting up was extremely fast. The large applications such as Photoshop, Xcode and iPhoto loaded instantly.

However when the speed tests were conducted I couldn’t achieve the read/write speeds mentioned on the specs. In fact it was way too low compared to the maximum. Never the less the performance boost I got was enormous and couldn’t imagine why it took too long for the transition.

How to reset Spotlight?

When Spotlight gets corrupted you can use the mdutil tool to clea up or reset the metadata stores as follows. Keep in mind that you have to execute it as an admin user if you want to reset the entire disk.

To erase all the local stores

sudo mdutil -E /

To set the indexing status ON

sudo mdutil -i on /

Other useful parameters
-p Spotlight caches indexes of some network devices locally. This option requests that a local caches be flushed to the appropriate network device.

-E This flag will cause each local store for the volumes indicated to be erased. The stores will be rebuilt if appropriate.

-i on | off
Sets the indexing status for the provided volumes to on or off. Note that indexing may be delayed due to low disk space or other conditions.

-s Display the indexing status of the listed volumes.

-a Apply command to all volumes.

-v Print verbose information when available.

Source: Apple

How to reset the Contextual Menu in Lion?

Open the, copy and paste the following command and hit Return.

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user

How to hide/unhide Library folder in Lion?

After upgrading to Lion you may not see the ~/Library folder. If you want to unhide it, try the following command on the

chflags nohidden ~/Library

The changes to take effect the Finder should be restarted

killall Finder

To hide the ~/Library folder

chflags hidden ~/Library

How to SSH into Terminals without entering the password?

When you want to access a remote terminal using ssh, general procedure is to run something similar to,

ssh username@server

and then enter the password. However if you have to do it regularly, entering the ssh command and the password can become annoying. The following guide will give you some tips to easily manage the above process without all the hassle.

SSH to a remote host from a local machine without entering the password.

  1. Open the (/Applications/Utilities/
  2. Navigate to the .ssh folder.
  3. cd ~/.ssh/

    If the .ssh directory doesn’t exist you can create it using,

    mkdir ~/.ssh
  4. Create security key pairs if they don’t exist.
  5. ssh-keygen -t rsa
  6. Copy the generated public key to the remote host.
  7. scp username@server:~/.ssh/
  8. SSH into the remote host in a regular fashion for the one last time.
  9. ssh username@server

    Copy the key to the authorized_keys list.

    cat >> .ssh/authorized_keys
  10. Remove the file.
  11. rm
  12. Exit from the remote server.
  13. exit
  14. Add an alias entry in your local .bashrc to make the process even simpler.
  15. vim .bashrc

    and insert

    alias anyname='ssh username@server'
  16. Restart the
  17. That’s all. Now you should be able to ssh to the remote terminal from your local machine simply by running


    on the
    Have fun!

Compare two folders on Terminal

One of the simplest way to compare the folders’ content is to use the diff utility.

Open the (/Applications/Utilities/

diff -rq folder1 folder2

If you want to compare ~/Documents/Oldfolder with ~/Documents/Newfolder,

diff -rq ~/Documents/Oldfolder ~/Documents/Newfolder

Here the r parameter tells the diff to run recursively and q tells it to output the short version of the results.

How to organize the Vim plugins?

I am a big fan of the Vim editor for many years. However installing, updating and removing Vim plugins require a great deal of time and effort. In this article I would like to introduce a couple of tools, which makes the whole process a breeze. The basic idea is instead of copying plugin files to different directories, just leave them where they are and load them when Vim starts. To remove a plugin, simply delete the corresponding subdirectory.


  • Vim Editor Version 7.0 or higher(Some plugins won’t work with older vim versions)
  • Ruby
  • Git

The last two applications are part of the xCode bundle.

  1. Before we start, it is probably a good idea to create a backup of the old plugins.
    Backup the .vimrc file

    cp .vimrc .vimrc_backup
  2. Backup the .vim folder
    mv .vim .vim_backup
  3. Create “bundle” subfolder within .vim folder.
    mkdir -p .vim/bundle

    (This is where all the plugin directories will be copied)

  4. Download the pathogen plugin from
    cd .vim

    (navigate to .vim directory)

    git clone git://

    (This will download the latest pathogen plugin)

    cp -r ~/.vim/vim-pathogen/autoload ~/.vim/

    (This will copy the autoload directory to .vim folder)

  5. To load pathogen when vim starts, add the following lines in .vimrc
    vim ~/.vimrc

    call pathogen#runtime_append_all_bundles()
    call pathogen#helptags()
    filetype plugin indent on

  6. Remove the vim-pathogen folder.
    rm -rf ~/.vim/vim-pathogen

    (remove the empty folder)

  7. The next step is to download all your favourite plugins into the bundle directory and keep them sync with the latest updates. The Ruby script written by Tammer Saleh comes in handy for this purpose. Once you customize the script by including all the plugins you want to use, all you have to do is to run the script in regular intervals.
  8. Download the latest Ruby script to .vim directory.
    The modified ruby script can be downloaded here.
  9. Open the script and activate your favourite plugins. You can also add new plugins from git, mercurial repositories or even zipped bundles from Once you are ready with the activated collection save the script and run to install.
    ruby update_plugins

You can find my own vim setup on GitHub. Download the complete package and customize it as necessary. Please read the README for installation instructions.


  1. Tim Pope’s pathogen:
  2. Ruby script(Tammer Saleh):

How to edit hosts file on Mac OS X (Snow Leopard)?

If you want to bind an ip address to a host name or block a certain applications from connecting to a specific server address, you can add that information to the hosts file. Here is how you do it.

  1. Log in as an admin. user.
  2. Open the located at Applications > Utilities >
  3. Use
    sudo nano /private/etc/hosts

    to open the hosts file

  4. Add the corresponding record.
  5. Press Control+o to save and Control+x to exit the nano editor.
  6. Use
    dscacheutil -flushcache

    to clear DNS cache.

That’s all. Have fun!

How to install pkg file commandline?

Recently, when I tried to install a pkg file, just by double clicking, it gave an error. In such situations commandline installer tool comes handy. Here is how you can use it.

sudo installer -pkg <pkg name> -target /

(Usually the target location is the root folder. However you can also point it to some other location depending on your requirements)
Here is an example.

sudo installer -pkg ~/Downloads/iStockphotoApertureExport.pkg -target /

Use the built-in TFTP client to trasfer firmware onto your router

Worst thing happened yesterday while I was updating my router(WGR614v9
54 Mbps Wireless Router) firmware. Usually updating the firmware is an easy process. All you have to do is log in to the router via any web browser and upload the latest firmware file. In my case I did manage to upload the file but when the router restarted the power button started blinking. The blinking power button indicates that the firmware is corrupt.

In such a situation only way to save the router is to transfer the firmware file through router’s built-in TFTP server. If you are comfortable with the the process is really easy. Here are the steps.

  • Fire-up the (/Applications/Utilities/
  • cd to the location where the firmware file (with .chk extension) is located.
  • Issue the following commands and hit return
  • tftp -e <ip address of your router>

    (Command to connect to the tftp server)

    put <firmware filename>

    (Copy the firmware file from the local machine to the server)


    (Quit the tftp connection)
    This method worked well with my router. However there may be different ways to transfer the file with other brands.