Its the USB age, chuck dvd drives!

USB = pen drive, SD card reader, iPod or your-favorite-usb-mass-storage device

Find below, a compilation of sources that explain the process of installing various Operating Systems available for us mortals.

Installing Windows 7 from USB

Installing Windows XP from USB

Installing OpenSolaris from USB

Installing Ubuntu from USB

Installing Leopard from USB

So chuck those dvd drive’s out the fuckin window!

Installing WordPress Locally on Your Mac OS X

What is WordPress ?

WordPress is an open source blog tool and publishing platform powered by PHP and MySQL. It is often customized into a content management system (CMS). It has many features including a plug-in architecture and a template system. WordPress is used by over 14.7% of Alexa Internet’s “top 1 million” websites and as of August 2011, it powers 22% of all new websites. WordPress is currently the most popular CMS in use on the Internet.

What is MAMP?

MAMP stands for Macintosh, Apache, MySQL, and PHP. MAMP is an application you can install on your Mac which allows you to have access to a local PHP server and MySQL server. Essentially, MAMP gives you all of the tools you need to run WordPress on your machine, for development and testing purposes. You can accomplish this in different ways, but the other ways aren’t nearly as simple (see MacOS_X_Local_Mirror for the long, manual version of installing PHP and MySQL on your Mac).

Step 1: Installing MAMP

Before you can install MAMP on your Mac, you’ll need to download it from the MAMP website. MAMP requires that your Mac be running Mac OS X 10.4.x or later.

Once the MAMP download is complete, double-click the MAMP disk image (it should be something like MAMP_2.0.3.dmg), and you should get a MAMP window pop up. Drag the MAMP folder (not MAMP PRO – we’ll save that walk-through for another time) to the Applications folder.

Step 2: Basic MAMP Settings

Now that you’ve got MAMP installed on your system, launch (located at /Applications/MAMP/

While you’re editing settings, MAMP might prompt you for an administrator password. This is required because MAMP needs to run two processes: mysqld (MySQL) and httpd (Apache), and depending on the settings you set for those processes, you may or may not need to input your password.

Once you open MAMP, click the Preferences button. Next, click over to “Ports.” The default MAMP ports are 8888 for Apache, and8889 for MySQL. If you use this configuration, you shouldn’t get asked for your password, but you’d need to include the port number in the URL (localhost:8888). If you’d like to leave the port number out of the URL, change the Apache port to 80. The downside of using port 80 as your MAMP Apache port is that you’ll always be asked for your password.

On the PHP tab, select PHP version 5. The PHP minimum requirement for WordPress was raised to 5.2.4+ in version 3.2.

Lastly, on the Apache tab, you’ll need to set a document root. This is where all of your files are going to be for your local web server. An example of a document root is /Users/USERNAME/Sites/wordpress/.

Once you’re done editing all of the settings, hit OK to save them.

Step 3: Starting MAMP Servers & Creating The Database

To start the MAMP Apache and MySQL servers, simply click “Start Servers” from the main MAMP screen. Your MAMP servers have now been started.

Once the MAMP servers start, the MAMP start page should open in your default web browser. If not, click on “Open start page” in the MAMP window. Once that’s open, select phpMyAdmin from the webpage.

Under “Create new database”, enter in a database name such as “wordpress”, and press “Create.”

Step 4: Downloading and Installing WordPress

Now it’s time to download WordPress. Once you’ve downloaded and unzipped the WordPress download, open up the “wordpress” folder. Click and drag all of the files from the wordpress folder to your MAMP document root (I use/Users/USERNAME/Sites/wordpress/).

Lastly, we’ve got to run WordPress’ famous 5-minute install. Visit your local site (localhost:port or localhost:port/wordpress), and enter the following information into the database setup form:

database name: wordpress
database host/server: localhost
database user: root
database password: root

Once that’s complete, enter a blog name and email address, and you’re ready to use WordPress on your Mac.

Five dangerous coding standard rules

Bad Rule #1: Do not divide; use right shift

As worded, the above rule is way too broad. It’s not possible to always avoid C’s division operator. First of all, right shifting only works as a substitute for division when it is integer division and the denominator is a power of two (e.g., right shift by one bit to divide by 2, two bits to divide by 4, etc.). But I’ll give BadAdvice the benefit of the doubt and assume that he meant to write that you should “Use right shift as a substitute for division whenever possible”. This, of course, is unnecessary in many cases as a good optimizing compiler can also see that you are dividing by a fixed power of 2 and shift accordingly if that is faster on the target processor.

For his example, BadAdvice shows code to compute an average over 16 integer data samples, which are accumulated into a variable sum, during the first 16 iterations of a loop. On the 17th iteration, the average is computed by right shifting sum by 4 bits (i.e., dividing by 16).

Perhaps the worst thing about this example code is how much it is tied to a pair of #defines for the magic numbers 16 and 4. A simple but likely refactoring to average over 15 instead of 16 samples would break the entire example–you’d have to change from the right shift to a divide proper.

It’s also easy to imagine someone changing the first #define from 16 to 15 without realizing the significance of the second; in which case, you’d get a subtle bug in that the sum of 15 samples would still be divided by 16.

Better Rule: Shift bits when you mean to shift bits and divide when you mean to divide.

There are many sources of bugs in software programs. The original programmer creates some bugs. Other bugs result from misunderstandings by those who later maintain, extend, port, and/or reuse the code. Thus it is my view that coding rules should emphasize readability and portability above efficiency. The choice to deviate from a good coding rule in favor of efficiency should be taken only within a subset of the code. Except when there is a very specific function or construct that needs to be optimized by hand, efficient code generation should be left entirely in the hands of the compiler.

Bad Rule #2: Use variable types in relation to the maximum value that variable may take.

BadAdvice gives the example of a variable named seconds, which holds integer values from 0 to 59. And he shows choosing char for the type over int. His stated goal is to reduce memory use.

In principle, I agree with the underlying practices of not always declaring variables int and choosing the type (and signedness) based on the maximum range of values. However, I think it essential that any practice like this be matched with a corresponding practice of always declaring specifically sized variables using C99’s portable fixed-width integer types.

It is difficult to understand the reasoning of the original programmer from:

char seconds; 

Did he choose char because it is just big enough or for some other reason? Was he counting on the compiler to tread char as unsigned by default, as some do?  The intent behind variables declared short and long also difficult to decipher. A short integer may be 16-bits or 32-bits (or something else entirely), depending on the compiler and target processor–a width the original programmer may have (or may not have) relied upon.

Better Rule: Whenever the width of an integer matters, use C99’s portable fixed-width integer types.

A variable declared uint16_t leaves no doubt about the original intent as it is very clearly meant to be a container for an unsigned integer value no wider than 16-bits. This type selection adds new and useful information to the source code and makes programs both more readable and more portable. Now that C99 has standardized the names of fixed-width integer types, declarations involving short and long should no longer be used. Even char should only be used for actual character (i.e., ASCII) data. (Of course, there may still be int variables around, where size does not matter, such as in loop counters.)

Where portable efficiency concerns exist, remember that C99’s stdint.h also defines uint_leastN_t and uint_fastN_t, which allocate storage of at least N bits and the fastest container at least that wide respectively.

Bad Rule #3: Avoid >= and use <

As worded in the heading, I can’t say I understand this rule or its goal sufficiently, but to illustrate it BadAdvice gives the specific example of an if-else if wherein he recommends:

if (speed < 100) ... else if (speed > 99) 

instead of:

if (speed < 100) ... < else if (speed >= 100) 

Say what? First of all, why not just use else for that specific scenario, as speed must be either below 100 or 100 or above?

Additionally, even if we assume we need to test for < 100 first and then for >= 100 second, why would anyone in their right mind prefer to use > 99? That would be confusing to any reader of the code. To me it reads like a bug and I need to keep going back over it to find the logical problem with the apparently mismatched range checks. Additionally, I believe that BadAdvice’s terse rationale that less code will result to be untrue. Any half decent compiler should be able to optimize any comparison as needed for the underlying processor.

(Remember you’ll often do far better when you can compare for equality or inequality vs. zero.)

Better Rule: Use whatever comparison operator is easiest to read in a given situation.

It is my strongly held belief that one of the very best things any embedded programmer can do (other than make their code work properly, of course) is to make their code as readable as possible to as broad an audience as possible. That way another programmer who needs to modify your code, a peer doing code review to help you find bugs, or even yourself years later, will find the code hard to misinterpret.

Bad Rule #4: Avoid variable initialization while defining

BadAdvice says that following this fourth rule will make initialization faster. He gives the example of unsigned char MyVariable = 100; (not preferred) vs.

// Before entering forever loop in main MyVariable = INITIAL_VALUE;
#define INITIAL_VALUE 100 unsigned char MyVariable;

Though it’s unclear from the above pseudo-code, let’s assume that MyVariable is a local stack variable. (It could also be global.) I don’t think there should be any (portably) noticeable efficiency gain from switching to the latter. And I do think that following this rule creates an opening to forget to do the initialization or to unintentionally place the initialization code within a conditional clause.

Better Rule: Initialize every variable as soon as you know the initial value.

I’d much rather see every variable initialized at declaration with the narrowest possible scoping and creation of the variable postponed as long as possible. Remember that if you’re using a C99 or C++ compiler, you can declare a variable anywhere within the body of a function.  Right before its first use is a great place to declare and immediately initialize any variable.

Bad Rule #5: Use #defines for constant numbers

The example given for this rule is of defining three constant values, including:

#define OFF 0 #define ON 1

BadAdvice’s rationale is given as “Increased convenience of changing values in a single place for the whole file. Provides structure to the code.” And I agree that using named constants instead of so-called “magic numbers” sprinkled around the code is a valuable practice. However, I think there is often a better way to go about this.

Better rule: Declare constants using static const or enum.

C’s const keyword can be used to declare a variable of any type as unable to be changed at run-time. This is a preferable way of declaring constants, as they are in this way given a type that can be used to make comparisons properly and enabling them to be type-checked by the compiler if they are passed as parameters to function calls. In C++, the use of const won’t cost you any memory storage. To avoid the use of run-time memory for constants declared this way in C, simply add the static keyword to the declaration. For example:

static const uint8_t OFF = 0; static const uint8_t ON = 1;

Alternatively, enumeration sets may be used to declare integer constants. I recommend this technique when the constants come in related groups, such as named colors or:

enum { OFF = 0, ON };

Either const-declared variables or enumerations can be used to achieve much of what programmers use preprocessor defines for (except preprocessor macros). So while I agree with BadAdvice that #defines are preferable over magic numbers, I only use #define as a last resort when naming a constant.

Scary thoughts

There are two scary things about these and a few of the other rules on BadAdvice’s blog. First, is that they are out there on the Internet to be found with a search for embedded C coding rules. Second, is that BadAdvice’s brief bio is a designer of medical devices and industrial controls. I’m not sure which is worse. But I do hope the above reasoning and proposed better rules gets you thinking about how to develop more reliable embedded software with fewer bugs.


Resizing Windows in latest Mac OS Lion

A great new feature in Lion is the ability to resize windows in a much more flexible way. Whereas Snow Leopard only allowed resizing a window using a “handle” in the bottom right corner of every window, in Lion placing your mouse near any edge of a window will result in a new “Resize” cursor indicating that you can resize the window from there.

If this wasn’t enough, there are a few other new resizing features that can make this even more useful.

Firstly, holding the Option key while resizing results in both sides of the window resizing equally. For example, if you have a full screen window and resize it by Option-dragging the left side in towards the centre, the right side will also move in by an equal amount. If you resize from a corner using this method, it essentially has the effect of anchoring the window by its centre rather than by the opposing corner as usual.

Secondly, holding the Shift key while resizing forces the window to keep the same proportions. This is similar to when you resize an image and want to avoid stretching it in one direction. If you double the width of a window, the height will be doubled as well.

Finally, you can use the Command key to resize windows in the background without moving them to the front. This has actually been around since before Lion, but it has become much more useful now you can resize windows from any edge.

Now, if you really want to be a pro, you can try using the modifier keys in combinations. You can also press and release Option and Shift at various points while you are already resizing to add and remove the constraints.

Bonus Tip: If you go to resize a window from an edge, but instead drag the mouse cursor in the wrong direction (i.e. drag up/down while resizing from the left/right edges) you can move the window around. This means you no longer have to only move windows using the title bar at the top.

Source: macosxtips

10 must-know Google Search tricks

By now you know how to use Google to search for a flight, look up a definition, or solve a simple math problem. But what if you want to do a search comparison or want information from a certain time period? Here we bring you 10 tips and tricks for searching Google like a pro.

Google Squared

Searching for a comparison chart on a certain topic? Try using Google Squared for a collection of information. For instance, try searching Google Squared for “roller coasters” to see a chart of the top 20 tallest roller coasters, or check out chart of hurricanes for images, descriptions, and damage estimates of recent hurricanes.

Wonder Wheel

Not quite sure what you’re looking for? Google’s Wonder Wheel gives another way of looking at the related searches near what you’re looking for.

Located in the left-hand sidebar, Wonder Wheel produces a circular chart with searches that other people have done recently that are related to yours.

Search history

Need to find something you have found on Google before? Try searching your own Google search history. Sign into your Google account and enable web history.

Run your searches and then visit to see your search history and revisit previous searches. Search history also syncs to your mobile device.

Google Voice Search

Google Voice Search lets you speak your search queries into your mobile device while on the go. Google Voice Search app is available on iPhone, BlackBerry, and Nokia S60 V3 phones. If you have an Android phone, search for the “Voice Search” app in Android Market.


For those who want info from a certain time period, Timeline option is a sure shot help. Located in the left-hand toolbar, the feature lets you zoom in on any time range and see news pulled from assorted sources, including books, news, and web pages. Searching for the Anglo-French Wars, for instance, brings up a timeline that runs from 1600-2010, stepping down into individual years, then months.

Google Images

Want to filter your results in Google Images. Try searching for a word that could be found in a range of images, such as names like heather or raven or cliff. Towards the bottom of the left-hand sidebar in Google Images, you will find a dedicated option to only clip art, photos, or line drawings.

Searching files

Trying to find a particular type of file? Google doesn’t only look for HTML. Type what you’re looking for and then add ‘filetype:tag’ on the end. For instance, ‘filetype:doc’ will only results with those types of file. This search supports PDF, Microsoft Office formats, Shockwave Flash and so.

Google Suggest

To compare different Google Suggest results side-by-side, go to to get a visual comparison of two search prefixes. Though not a Google product, Web Seer was built by two Googlers and gives interesting insight into Google results.

Search in the URL

If you know there’s a specific string of letters or words in the URLs of pages you are looking for, you can use “inurl” to find them.

For example, many websites with public webcams have URLs that contain “view/view.shtml”. So search for inurl:view/view.shtml and your search results will display the URLs for webcams around the world.

Searching websites

You can search a wide variety of sites by inserting > before the type of site you want to search. For example, [penguins site:>.edu] searches for penguins across all .edu sites. [crater image site:>] searches for crater images across

Disable Spotlight Indexing in Mac OS 10.6 – Snow Leopard

Disabling Spotlight in Snow Leopard is pretty easy, launch the Terminal and type the following command:

sudo mdutil -a -i off

This tells the Spotlight manager to disable all indexing on all volumes, the command will require your administrative password to execute.

Re-enabling Spotlight in Mac OS X 10.6 Snow Leopard is just as easy, just reverse the command to:

sudo mdutil -a -i on

Now Spotlight indexing will be back on and work as usual.