If you own a Mac and frequently rip audio from streaming content on the internet, then you’ve probably already heard of Audio Hijack. The majority of times I used Audio Hijack was for ripping audio from YouTube videos such as this one. I’ll show you how to download YouTube videos in FLV format, then rip the audio from those videos and save them as an MP3 file, all on Ubuntu.
First Thing’s First: Validate
Have a sweet function written that requires valid variables? Make sure you’re validating those variables at the top of your function. Validating variables before (as apposed to while) they are used is key in making sure that important logic isn’t executed using crappy data.
Here’s an example of validating first, then executing:
/* The good... */
public function insertNewInvoiceItem($item, $quantity)
{
if(!$item instanceof Shop_Item) {
throw new InvalidArgumentException ('Expecting an item to be an instance of Shop_Item.');
}
if(!is_numeric($quantity)) {
throw new InvalidArgumentException('Quantity is not numeric.');
}
// We're good to go. Continue with the function...
}
The method above is also much cleaner than if... else... statements and limits the extra (perhaps useless) work required by your code:
/* The bad... */
public function insertNewInvoiceItem($item, $quantity)
{
if($item instanceof Shop_Item) {
// Do some $item stuff...
if(is_numeric($quantity)) {
// Do some $quantity calculations
} else {
// Uh oh, $quantity was bad but we've
// run some Shop_Item logic already.
}
}
else
{
// $item is not part of Shop_Item
}
}
I used a simple example to demonstrate my point but when this technique is used on more complex logic, it’s benefits are much more obvious.
Happy coding!
CSS & JS Coding Standards / Organization [OOP]
By no means should this article serve as the bible of CSS & JS coding standards, though it should get the ball rolling for those who are unsure where to start. Over the years, I’ve had the privilege of working with many talented developers, each of whom have left little bits and pieces of their coding style behind. From those pieces I’ve assembled this article.
Let’s begin…
Alphabetize Your Code
Alphabetizing your code is an extra organizational step often overlooked. It’s especially helpful in PHP classes containing getter and setter functions, but it also comes in handy for CSS and JS. Often times similarly named elements will be somewhat related in function, so clustering them together makes them easier to find.
I’d recommend alphabetizing everything from JS class and function names, to CSS classes and ID’s. You’ll notice that every code example in this article is alphabetized to further exemplify the point.
Three Bitchin’ PHP Classes – Cache, Last.fm API, Time
There’s nothing like the feeling that comes with typing a few lines in a PHP application and letting some included classes take care of the dirty work; you know, the filthy stuff like caching, calling the Last.fm API, purifying timestamps, and handling file uploads. (Dirty, right?)
All of the following PHP classes are “works in progress”, but hopefully each is mature enough to find its way into your code. Continue reading to view, download, and use each class.
Flicka Video!
Proof that Flicka actually exists and isn’t just Photoshop mockups…
Flicka: Beta Teaser from Flicka on Vimeo.
Official Flicka website gives more information…
Photos, Not Just On Flickr Anymore…
I’ve finished a simple, photography-showcasing website for myself – which comes with a super-unoriginal URL:
photos.iamkoa.net
If you’re interested in photography or have a showcase website of your own, leave a comment.
Props to Flickr, Cufon, jQuery, Masonry, and Lightbox for making the website dazzle.
Flicka – Flickr for Android
An application for Android is about to win the hearts of Flickr fans and photography enthusiasts alike – it’s called Flicka, and it promises to bring the power of Flickr to your Android device.
Here’s a few key features as listed on Flicka’s blog:
- Notifications : Customizable notifications immediately inform you of new Flickr contact uploads, Flickr mail, Photostream comments, etc. directly in your Android notifications bar.
- Favorites : Quickly browse, add, and remove your Flickr favorites. Viewing a favorite (or any photo) gives you the option to easily set the photo as your Android wallpaper or contact icon.
- Search, Groups, Contacts, & Upload : Flicka gives you the ability to preform powerful searches on Flickr – browse, join, or remove yourself from Flickr groups – browse, add, and remove Flickr contacts – and upload content directly from your phone to Flickr.
Flicka needs to be on my phone. Now!
Easily Pimp Your Mac OS X Desktop
Mac OS X may not be as easy as Ubuntu to customize, but thanks to GeekTool, you can make your desktop background a little more useful than just eye-candy. I’ll show you how to easily add a calendar, multiple clocks (display both relative and non-relative time), a live system processes chart, and a system up-time timer (with load averages) to your desktop. Of course you can easily add more items, but this should be enough to get you started.
Sounds completely geeky (and it totally is), but GeekTool makes you and your desktop look awesome – it also increases sexual pleasure and makes you last longer in bed.



