You run to the grocery store. You forgot all about your hot date who’s coming over soon and expecting a lovely home-cooked meal. As you run down the aisles, picking up the ingredients you typed in on your phone, you realize you’re going to be late. Not a good first impression… The items in the list are all over the place, making you run back and forth through the grocery store aisles as if you work there. If only there was a quick and easy way to view your shopping list already categorized…
Well now there is!
I’d like you all to meet Superbetize. This site will take your list of groceries, and categorize (super-betize!) them in different sections found in most grocery stores (e.g. produce, frozen foods, household supplies, etc.). The site provides a nice mobile interface as well so you can easily use it on your phone while traversing the grocery store aisles.
I am very proud of Superbetize. Some may even say that I’m super proud of it. I believe I’ve managed to solve a problem experienced by many, but spoken about by none. I also used this project as an excuse to learn some new and interesting technologies. Those include: Bootstrap, mod_rewrite, and cron jobs.
I want to introduce you to a problem I had while developing this site. The ‘groceries array’ that I use to actually sort through the grocery list was manually created by yours truly. I knew there was no way I’d be able to get everything right the first time, between all the different brands, categories, and spellings of product names. I needed a way to update this groceries array regularly with items that weren’t already in the list. This is where cron jobs come in to play.
Cron jobs are scripts that run on a schedule. These are usually used for automated backups or system administration. For each script, you can simply tell it the interval to run (daily at noon, Fridays at 5pm or once a year on April 20th). I created a simple cron script to run once a week that will collect all of the ‘Uncategorized’ items (which were stored in a separate table in my database) that went through Superbetize, and email that list to me. It works beautifully.
Once a week, on Sunday nights at 1am, I get an automated email coming from my hosting provider (where the cron script is hosted), with a list of all of the uncategorized items that were sorted in the past week. I simply add those items manually to my groceries array in the proper category, and update the live grocery array! This way you know if Superbetize couldn’t get your item once, next time it’ll be in the proper place 😉
Ideas, suggestions, and criticisms are welcome! Enjoy!