'Weather Forecast' Calendar Service in PHP

The BBC provide 3 day weather RSS feeds for most locations in the UK. I thought it would be interesting to create a web service to turn the weather feed into calendar feed format, so I could have a constantly updated forecast of the next 3 days of weather mapped on to my iPhone’s calendar. Here it is on my iPhone: Overview The service is separated into five files: ical.php – this contains the class ical which corresponds to a single calendar feed. A method called ‘addevent’ allows you to add new events to the calendar, and a method called ‘returncal’ redirects the resulting calendar file to the browser so people can subscribe to it using their calendar application. forecast.php – this file contains the class forecast, which has properties for all aspects that we want to record for each day’s forecast, ie: Wind Speed and Humidity. It also contains the forecast set, which is a collection of forecast objects. The set class is serializable, which means each forecast object can be stored in a text file, including the Wind Speed, Humidity and all other things we want to record for each day. scrape-weather.php – this file contains code that scrapes the weather feed, populates the forecast set with all the weather information for the next 3 days, and stores the result in a file called forecasts.ser. forecasts.ser – this is all the data for the three day weather forecast, in serialized format. It is automatically deleted and recreated when the scrape-weather.php script is run. reader.php – this file converts the forecasts.ser file into an iCal calendar, and outputs the iCal formatted result to the calendar application that accesses reader.php page. It uses two external libraries: ...

February 24, 2011 · 4 min · David Craddock

Find large files by using the OSX commandline

To quickly find large files to delete if you have filled your startup disk, enter this command on the OSX terminal: sudo find / -size +500000 -print This will find and print out file paths to files over 500MB. You can then go through them and delete them individually by typing rm “”, although there is no undelete so make sure you know you won’t miss them.

February 22, 2011 · 1 min · David Craddock

Finding files in Linux modified between two dates

You use the ’touch’ command to create two blank files, with a last modified date that you specify - one with a date of the start of the range you want to specify, and the second with a date at the end of the range you want to specify. Then you reference to those two files in your find command: touch /tmp/temp -t 200604141130 touch /tmp/ntemp -t 200604261630 find /data/ -cnewer /tmp/temp -and ! -cnewer /tmp/ntemp

February 16, 2011 · 1 min · David Craddock

Writing simple email alerts in PHP with MagpieRSS

I wrote an email alerter that sends me an email whenever the upcoming temperature may dip below freezing. It uses the Magpie RSS reader to pull down a 3 day weather forecast that is provided for my area in RSS form by the BBC weather site. It then parses this forecast and determines if either today’s or tomorrow’s weather may dip below freezing. If it might, it sends an email to my email address to warn me. ...

February 12, 2011 · 1 min · David Craddock

Reverting back to a previous version in CVS - the magic "undo" feature

If you’ve committed some code into to CVS, and made a mistake on that commit, you will want to know how to revert to a previously saved version. Here is the command line command for CLI versions of CVS: $ cvs update -D '1 week ago' Run this command in the main directory of your checked out working copy. This will revert your working copy to the version of the code that was checked in ‘1 week ago’ from the present date. You also use commands like “1 day ago” and “5 days ago”. ...

January 28, 2011 · 1 min · David Craddock

Netbeans for simple Java GUI Applications

I’ve been writing some simple Java GUI applications using the Netbeans IDE. It allows you to quickly make event-driven GUI applications, and generates a lot of skeleton code that you’ll need, but don’t necessarily want to type out. It reminds me of the IDE designer of Visual Basic 6, which allowed you to mock up simple GUIs with code in almost no time at all, although the VB language itself often proved difficult. With Netbeans you are using Java, and so you can make some powerful software with little effort.

December 7, 2010 · 1 min · David Craddock

Converting week numbers to dates

Here is some python code I adapted from this stackoverflow post to get the first day of a week specificed by a week number. This method includes leap year and summer time differences. import time def weeknum(num,year): instr = str(year)+" "+str(num-1)+" 1" print time.asctime(time.strptime(instr,'%Y %W %w')) Here is me exectuting the code in Python’s IDLE shell: See that the first week of 2009 actually started in 2008, but by the end of that week we are in 2009.

November 24, 2010 · 1 min · David Craddock

Mac BBC Radio Player

Quite cool little app that allows you to listen to different BBC Radio programmes from within a standalone application, instead of iPlayer: http://whomwah.github.com/radioaunty/

November 16, 2010 · 1 min · David Craddock

MediaMonkey allows you to transfer music from any computer onto your guest iPhone

MediaMonkey is a popular free media player for Windows. It has a great feature that allows you to transfer to and from an iPhone that is not registered with your computer. Normally only one iTunes install can be associated with your iPhone, but MediaMonkey allows you another way to transfer music and audio files with a ‘guest’ iPhone. Check it out, it works: MediaMonkey

November 14, 2010 · 1 min · David Craddock

Applications I Reccomend

Software I use on my macbook & PC: DVDRipper Pro for Mac - DVD ripping, can also rip to ISO Handbrake for Mac - Transcoding from DVD rip to iPhone-playable file iMovie for Mac - Video editing BabasChess for Windows - Best chess client for internet play Hypercam 2 - Best screencapture utility Skype for both - For reliable messaging as well as voice and video chat Virtual Clone Drive for Windows - For mounting ISO images iTunes for Mac - Best music player, and keeps media synced with iPhone VLC Player for both - For watching movies DVD Player for Mac - For watching DVDs ...

July 19, 2010 · 2 min · David Craddock