Pages

Showing posts with label misc. Show all posts
Showing posts with label misc. Show all posts

Friday, August 6, 2010

Upgrading MacBook Pro hard disk drive

I have a 13-inch MacBook Pro (7.1) with 250GB hard disk. And while installing Windows 7 to dual boot with OS X, I realized that I don’t have enough space for storage and installing applications. I had no choice but to upgrade. It is a good choice for two reasons, one I will be out of space before I realize and by then I would have invested considerable amount of time installing and customizing both OSes. Two, I can use the extracted disk for backup and  Time Machine on OS X. With this in mind I order a 500GB (same brand and speed as already installed) hard disk drive (hdd) and a disk enclosure.

My order arrived on time, but little did I realize that I am missing two most important things to begin my work. Those were two types of screw drivers, Phillips #00 to open the back panel (pic. 4) and Torx 6 for removing the mounting screws (pic. 9) on the extracted disk to be put on the new disk (pic. 1 and 2). I read the MacBook Pro handout (pic. 3, the white booklet) on replacing hard disk, but it did not mention those screw drivers.

So, here is what I did to make the overall process of moving from old drive to a new one easy and safe. I started with noting down all the applications installed that are used frequently. Then exported all my calendar events, address book entries and bookmarks among other things to be imported on the new setup. Backed up important data, like pictures, videos and documents. Once this was done I was ready to put the new hdd. I followed the procedure for replacing hdd mentioned in the MacBook Pro booklet provided. The instructions in the booklet are clear, and the pictures below of my endeavor should make it even more lucid. Hence, I am skipping the details of installing it. Only word of caution is to be careful of static and not touching hdd on the top (to avoid harming head and disk) and bottom (to avoid touching the circuitry). Make sure that it is always handled on sides (as in pic. 9 and 10). General idea while handling electronic stuff is to read the cautionary instructions on the device.

Finally, I installed OS X. Though there was a hick up of installer not detecting hdd, besides everything else going fine. I resolved the hdd issue by running disk utility from utilities and creating one partition and formatting it. I also ran a sanity check on the hdd, to be sure. Furthermore, I also noticed that Windows 7 installation on MacBook Pro using bootcamp doesn’t finish in one go. It hung the first time and went fine the second time.

macbook pro 1 macbook pro 2 macbook pro 3 macbook pro 4
macbook pro 5 macbook pro 6 macbook pro 7 macbook pro 8
macbook pro 9 macbook pro 10 macbook pro 11  

(I am sticking with Windows Live writer, as I couldn’t find a free and better alternative.)

Saturday, July 31, 2010

Publishing C/C++ code

It took me a while to figure out how to publish C/C++ code to the blog(spot). While doing so I messed up the post a few times. Finally, I got it working, and the way I wanted it, such that it looks same across the browsers and is well formatted. I tried a few things and some of them didn’t work. What didn’t work for me were plugins in Windows Live Writer (LW) to post code. Some of them didn’t show the colored text for the keywords and some didn’t have uniformity across browsers.

What worked was gvim/vim. Vim provides a command TOhtml to generate html for the code with proper syntax – exactly the way seen in vim. But that is half the job, as BlogSpot doesn’t take the html code with <head> and <body> tags of the generated html. To get it right I had to do two things. First configure vimrc to generate the desired syntax and scheme  (more on this later), and then copying the right part from the generated html. Here I will write about the way I did it using Live Writer (LW).

The published code in previous posts is inside a table, which is easy to draw in LW. So, first draw a table (1x1) in edit mode. Then in source mode copy the html generated by vim, starting from first <font> tag to the closing of it (which is at the end of the file) into that table. Even without LW this is easy to do, just add 1x1 table tags in BlogSpot edit post mode and then paste the generated html code. Explained below.

Copy the vim generated html code (as explained above) between these <td> tags.

<td valign="top" width="625"> {copy here} </td>

Note: Remove <pre> tags if any between the <td> tags.  width  can be adjusted to fit the blog.

After this add bgcolor of the <body> tag from the generated html to the <table> tag in the html code of the post. This will give the background color similar to vim scheme. At this point we have everything in place except the part, that this post won’t look same across the browsers. The reason being, first <font> tag in the pasted code. Where face is set as monospace and not a particular fixed width font, like Courier. Hence, replace whatever there is with this color="#ffffff" size="2" face="Consolas"’. This also gives the color to the ‘regular text’ in the code. In this case white (#ffffff).

This is how it will looked like on completion. Copied code marked in green.

<table border="0" cellspacing="0" cellpadding="3" width="625" bgcolor="#333333">
<tbody> <tr> <td valign="top" width="625">

<font color="#ffffff" size="2" face="Consolas, Courier New">

<Rest of the generated html code>

</font>
</td> </tr> </tbody>
</table>

Example:

1 int main(int argc, char * const argv[]) {
2     return 0;
3 }


Here is the vimrc configuration  used to get the syntax, scheme and the format. Just add these lines to the existing text. Line numbering can be turned off. If vimrc file can’t be located, typing in command - ‘e $MYVIMRC’ – will fetch it. html_use_css, is a switch to enable/disable CSS in the generated html code. The example above is without CSS styles.

set nu
colorscheme desert
syntax on
set guifont=Courier_New:h10
let html_use_css=0

 

(After writing this post, I am thinking of doing away with LW. I had hard time formatting and getting the post as I wanted.)