I am Hack Sparrow
Captain of the Internets.

Archive for October, 2011

How to install MongoDB on Mac OS X

If you are looking for a straightforward, no-headache way to install Mongodb on Mac OS X you have come to the right place. If you are looking for a customized, tricky installation from source, you need to look somewhere else. There are many ways to install MongoDB on MacOS X: from source, binary download, MacPorts, and Homebrew to name what I am aware about. Go the Homebrew way, and ditch the rest. In fact, use Homebrew for managing all your packages ...

Using MySQL with Node.js

New to Node.js and wondering if you can use your old friend MySQL with it? Good news - it is surprisingly very easy to get MySQL working with Node.js. This article guides you through the process. First of all, you'll need to install an aptly named Node.js module called . [code] $ npm install mysql [/code] The module is entirely written in Node.js, and implements an async MySQL client. Mad respect to t ...

Check object type in PHP

Been working on something where you need to check the type of PHP objects? Doing that is pretty straightforward. In fact, there are two ways to do it, I'll show you both. You know there are predefined object types in PHP, you just call the is_* functions to test. The following code shows you how to do the _is* testing. is_nul ...

Email validation Regex in PHP

Here is a good regex in PHP which will help you validate a vast number of possible emails, also it is case-insensitive. Useful for checking if an input is a valid email or not. [code] /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i [/code] Below is an example in PHP which validates the va ...

How to open tar.gz File in Linux

This post is a quick instruction on how to open tar.gz files in Linux. So you came across a file that has the extension .tar.gz and have no idea how to open it. Let's say you downloaded , here's how you open it. [code] $ tar -zxvf node-v0.4.12.tar.gz ... $ ls -la drwxr-xr-x node-v0.4.12 -rw-rw-r-- node-v0.4.12.tar.gz [/code] In the above example tar -zxvf will extract the contents of to a direc ...