Archive for November, 2009

Calculating age with PHP using a birth date

Sunday, November 15th, 2009

UPDATED 12/2: Code updated for efficiency and code download link added.

Ran into a problem today– there’s no easy way to add and subtract dates in PHP and be left with standard units (year, month, day, etc), so I whipped up a quick script to do it– the biggest problem is months, here, since PHP deals with second-based timestamps, and months don’t possess a standard number of seconds. Without further ado, here’s the code– I hope it’s helpful to your projects:
(more…)

An easy way to handle previous and next product links

Saturday, November 14th, 2009

I’m working on a custom eCommerce site for a customer right now, and ran into an issue– they wanted to have, on every product page, a forward and back button to get to the previous and next items. The problem with this is that they may have arrived on the product page in a couple of different ways, through search or browsing, with different criteria set.

I came up with this easy routine which goes through the result set, whether it’s search result or category view, then creates an array where the key is the current product ID, and the values are the IDs of the product before and the product afterward. So if I’m on product 157, $ordering[157]['next'] will give me the ID of the next product. Just pop it in a session, and you’re good to go.

Simple and straightforward– feel free to reuse all you like!
(more…)

Importing Basecamp Tasks into iCal

Friday, November 6th, 2009

basecamp-logo-for-fluidI’ve been back and forth a thousand times on Basecamp– I love it and I hate it, and have tried every alternative, but I just keep coming back.  So instead of switching again, I’ve decided I should just start fixing the things that bug me, and I’ve started with the fact that I can’t get a feed of my tasks into iCal.  Since ICS feeds are read-only, there’s no way to be able to check off basecamp tasks in iCal, but I’ve started using Minco to track my time (great app, by the way), and it pulls in a list of items to track from your iCal to do list.  I’m sure you see where this is going– if I can push my Basecamp tasks into iCal, then Minco can see them.  Maybe you have another reason for wanting your tasks in iCal, but this was mine.  Anyway, thanks to Monte Ohrt’s Basecamp PHP API library, I was able to throw together an API tool to pull my tasks and push them out into an ICS feed in just an hour!  I’ve made this tool available so you can easily drop it into iCal and away you go.  Or, if you’d rather dig into it yourself, you can download my code from: http://tr.im/EjnN
(more…)

The Schedule of a Freelance Web Developer

Monday, November 2nd, 2009

It’s closing in on 6 months that I’ve been doing only freelance development– while I moonlighted and worked in an office for years, I love being my own boss, and part of that has been setting my own schedule. It seems like there are never enough hours in the day, but here is the pattern that I’ve found that seems to work, at least for the time being:

10am – Wake up, check and respond to email, deal with any urgent issues

10:30am – Breakfast time– grab a bite and dive in.  Morning time is multi-tasking time– I can do bug fixes, put together bids for projects, etc.  Anything that can be done in under an hour, this is the time for it.  Also, this is when I handle most of my phone and instant-message client communications with clients here in the states.

1pm7pm - This is my ‘me and my wife’ time– generally, Becky and I will voyage into town, go to the gym (we play racquetball every day, and we love it!), maybe watch a movie, have a nice lunch, and enjoy life.  It’s nice to be able to run errands and go to the gym while most people are at work– a real time-saver!

7pm – 3am – This is my focus and get things done time.  I’ll make a couple pots of coffee and get to work– This allows me to have fewer interruptions (I turn off my email alerts and chat and get down to business) and also allows me to communicate with my clients in Australia and, towards the end of the night, the UK.

So if you get an email from me in the middle of the night– don’t be alarmed, that’s just how I work!

Powered by Olark