my thoughts and ideas

Smarty date timeSpan plugin

If you use Smarty for your templating engine, I’m sure you’ve had to format dates to different formats before. This is a handy modifier plugin which converts a date into something human friendly such as “2 minutes ago”, “Tuesday at 3:52pm”, or “March 12 at 6:49am” much like Facebook does. Works great for comments and message boards!

Simply download it, and extract “modifier.timeSpan.php” into your Smarty/plugins/ directory. To use it, simply add the “timeSpan” modifier to any smarty date variable. For example… {$postDate|timeSpan}

It takes advantage of PHP’s strtotime() function, so just about any date format you input should work just fine, but it works best with the YYYY-MM-DD HH:MM:SS format.

Possible outputs are…
Just now // less than 3 minutes ago
5 minutes ago // less than an hour ago
9 hours ago // less than 24 hours ago
Yesterday at 10:15pm // yesterday
Tuesday at 2:45pm // less than 5 days go
October 8 at 1:30am // more than 5 days ago this year
August 18 2007 at 5:32pm // not this year or in the future

PHP Image Resize – generates thumbnails on demand

I wrote a single file PHP Image Resize script that allows you to generate thumbnail images on demand, and thought I would share it with everyone. It actually generates a new jpg image on demand in the correct size, caches it for later use, and displays it. Its very helpful when creating an image gallery, also supports cropping!

Checkout PHP Image Resize

Google makes fun of IE

HTML5 API Adoption by browser

Yesterday was the first day of the Google I/O 2010 Developers conference. During the keynote speech, Vic Gundotra (VP of Engineering for Google) was talking about HTML5 and how there are APIs to allow developers to create better web applications. A graph was then displayed showing past, present, and future adoption of these APIs by the common web browsers.

Vic Gundotra goes on to say “So where do we expect to be by the end of this year? As you can see all the major APIs are going to be present in all modern browsers”.  As you can see in the slide, IE doesn’t appear to be one of those modern browsers.

Watch the video yourself

Steve Jobs puts Flash on its death bed

On apple.com, Steve Jobs posted an article about his thoughts on Flash. The last paragraph sums it all up by saying…

“New open standards created in the mobile era, such as HTML5, will win on mobile devices (and PCs too). Perhaps Adobe should focus more on creating great HTML5 tools for the future, and less on criticizing Apple for leaving the past behind.”

I read this story today, and as much as I am not a Apple fan – I agree 100% with this. Adobe has refused to accept change and are shooting themselves in the foot.

Adobe Flash has never ran decently on Mac or any mobile device, much like it has never ran decently on Linux. Why? Because they are proprietary and for whatever reason – not adopting. If it was open, this wouldn’t be a problem.

Other companies such as Google (YouTube), Vimeo, Netflix, Facebook, ABC, CBS, CNN, MSNBC, Fox News, ESPN, NPR, Time, The New York Times, The Wall Street Journal, Sports Illustrated, People, National Geographic and many others are already supporting HTML5 video (H.264 video format) – showing their support for open standards and waving goodbye to Flash.

Read Steve Jobs full post here.
Thoughts on Flash

Phoenix Framework

I developed a framework for us to use at the office for web applications. Its very lightweight and fast. The only part I think I need to optimize is the view – but it works for now. The framework is built for web applications, and not really for content sites, though it will work great for one. Its all open-source and built in PHP 5.x

Please feel free to download it and give it a try! Let me know what you think.

Phoenix Framework

Internet radio is the future

Today people listen to music allot differently then they did 5 or 10 years ago. Many people listen to their iPod or other mp3 player when they are on the go.

However with all this technology, there is still the time consuming task of finding and downloading or copying all your music onto your portable device – keeping it synced and so on. Also, you end up listening to the same songs over and over, until you get sick of it and download more. The problem with this is that you will be listening to music you already know and will never discover new songs or bands that you may love. However, you dont want to listen to the radio because they never play anything you like – and you have to listen to commercials.

The solution? Pandora.
[Read the rest of this entry...]

Snow in Texas

It snowed here today, which I’m sure isn’t news to many people – but I don’t recall a time in my life its snowed this much in the Dallas/Fort Worth area. It’s real snow too, not the normal Texas slush snow / ice. Snapped a few pictures with my phone, check them out!

It was already snowing when I woke up at 7:30am, and it hasn’t stopped since (currently 1:30pm). We’re at 4 inches of snow, with some surrounding counties at 6-8 inches.

Google Maps Navigation for Android

Google Maps for Android has a “Navigation” feature which isn’t currently available to iPhone users. This feature turns Google Maps into a turn-by-turn GPS device, with text to speech. Meaning, it will read off exit and street names to you to assist you. It has quite a few interesting features.

Traffic / Travel Time – Tells you the travel time and traffic for your current route.

Alternate Routes – You can easily view and select alternate routes for your trip, incase of traffic or unwanted toll-roads.

Street View – Once you reach your destination, it displays a street view image of the address you are navigating to.

Also, using an Android shortcut, you can create an icon on your phones desktop that automatically navigates you to an address. For example, I’ve setup a icon called ‘Go Home’, and it automatically launches Google Maps and navigates me to my home address – with a single touch.

Checkout the video about it

UI design VS. Database design

Recently I’ve been doing allot of database planning for an eCommerce related product. In the process of doing so, I realized one problem allot of beginner and intermediate programmers have is properly designing a database schema. It seem’s the database structure almost always matches the user interface structure. This sounds logical, however can actually limit what you can do quite a bit.

If you have a product for sale, and that product has images, prices, categories, weight, etc…. In the user-interface, when someone is setting up a new product, the price and weight is filled out by the user while creating the product. This makes perfect sense for a user interface, however – not for a database schema. In the database, the weight and price should be based off of combinations of options for that product – and not tied directly to the product.

Say you have a Playstation3 for sale. The price shouldn’t be tied to the product “Playstation3″. Instead, the price should be tied to an inventory record for this product. Such as Playstation3 – 60GB. The size of the hard drive is an option for this product, which effects the price – thus, the price on the product level is now useless. Your database should reflect this, however the user-interface needs to be designed so that this logic is hidden from the user. (I’ll leave that task to a designer, don’t ask me how).

Robot chassis

I completed the build-out of my robots chassis last night. Its exactly a square foot, and about 8 inches tall. It was a pain getting the training wheels mounted to the motors – but I finally got them mounted after some fabrication work. Anyways, here she is so far…

Robot Chassis