I am Hack Sparrow
Captain of the Internets.

Archive for September, 2011

JavaScript: get the number of properties in an object WITHOUT LOOPING

Unlike arrays, JavaScript objects do not a have a length property which gives you the number of properties / items in an object. The most common way of getting the number of properties is to loop through the object - not pretty, resource intensive. This had been a long known problem JavaScript developers have been facing for a long time. All modern and superior browsers support a fix for this a ...

How to download file using cURL

So you wanna download files using cURL but don't know how to do that. Fear not, for the super-genius Captain Hack Sparrow is here to show you how to do just that. Learn from these examples: [code] $ curl -O http://example.com/Flag_of_Edward_England.svg [/code] The above usage of cURL with the uppercase option will download the file with the same name as the original. [code] $ curl -o flag.svg http://example.com/Flag_of_Edwar ...

How to install wget on your Mac

Ok, so Mac is cool and stuff, but it doesn't come with wget by default, which in my opinion sucks. wget is a very useful tool and is used for downloading installation files among other stuff; it ought to be there on your Mac. Getting wget on Mac OS X is pretty easy, so worry not. Just follow my instructions. Before that make sure you have a C/C++ compiler on your system, if you have XCode, you ...

How to change Aptana background color on Mac OS

I have settled on Aptana Studio 3 as my project development IDE on the Mac. The first thing I wanted to change was it's color settings - I hate dark background setting in text editors. I tried fiddling around with the Aptana settings using my common sense, but Aptana turned out to be quite tricky in 'hiding' the background-foreground color settings. So I did a quick Google search, only to find instructions for Windows, which only confused m ...

How to repair a crashed MySQL table

Your website stops working and you see a spine-chilling error message "MySQL table is marked as crashed and should be repaired". What now? Well, you need to repair it. There are two approaches to repairing a crashed table. I hope it is not bad news for you, but they will work only for MyISAM engines. If you are using InnoDB, consider restoring the table from a backup (at the cost of loss of some data). The most common reason ...