Cleaning up this town
Kelly Goto has just finished her talk – very interesting. Maybe not in terms of real concepts, but definately has supplied food for though.
Now listening to Jeremy Keith about AJAX. Been eXcellent so far :)
Kelly Goto has just finished her talk – very interesting. Maybe not in terms of real concepts, but definately has supplied food for though.
Now listening to Jeremy Keith about AJAX. Been eXcellent so far :)
That’s right kiddies, I have arrived in Sydney and I’m waiting for the first talks to start.
I’ve set up a Flickr feed (You can see the results down the bottom of the sidebar, to your right. Please mind the gap.
I’ve set up Shozu to send any photos I take from my picture phone straight to Flickr in (almost) real time, so enjoy the love. Assuming that I remember to take some photos :)
So watch this space for all the latest news from the coolest web conference this side of Sydney harbour…
…until webdirections 06. I’m starting to get rather excited about it all now. Even though I don’t actually have accomodation yet :)
I’ve quite looking forward to meeting the international and national speakers – it will be really cool to meet the big thinkers in the web industry, like Molly Holzschlag, Derek Featherstone and Andy Clarke (not to mention the others!). Hopefully it will leave me motivated and full of beans. Not that I’m not motivated at the moment, but you can never have to much.
Tim Lucas and Cameron Adams obviously have way to much time on their hands, as they released Web directions connections. Cool little app – both Miles and I spent a little too much time playing with it this morning, even though neither really could afford to (work hasn’t really eased up).
Speaking of 88 Miles (Leave me alone – it’s been a big week and I can’t be bothered coming up with a proper segway*), things are ramping up. I’ve made a few tweaks with the design and copy, and it seems to be attracting more sign-ups like a bees to the honeypot. It would be cool to get some big names in the web industry to have a look and blog about it. Now, where to find some poeple of high-enough profile… Hmmm.
On a personal note, I finally graduated last night, so I’m now officially a Bachelor of Computer Science (Hons). Thankyou god it is all over…
It would be a safe bet that my next post will be from Sydney (if my laptop makes it back in time), so until then…
I’m sorry, I don’t remember authorising anyone to make it the end of August already. The last 30 days have been CRAZY. In no particular order:
The business and mobile phone versions of 88 Miles was released, so not you can track your time when you are out of the office. The business version allows one person to manage the time of many other people, which makes running a small office much easier.
My laptop video card decided to goto the big ol’ interweb in the sky, so I have been with out it for the last two weeks. Apparently trying to source a motherboard for a computer that is barely two years old is a less that trivial task. This has meant that I have had to use my Linux machine for day-to-day use (other than at work) which has been interesting to say the least. One tidbit of wisdom – don’t try running major OS updates of a production server late on a Saturday night. It results in spending much of Sunday testing backup systems :)
The WA Web Awards have come and gone. I had the honour of chairing the awards this year, and might I say, even though a stupid amount of time went into organising it, it was well worth it. We had 130 enteries, sold out all 114 tickets in a week and managed to pull the whole thing together all whilst working fulltime.
The new sit down dinner format really added to the night, it felt so much more awards night like. I must put out a big thankyou to the rest of the committee – there were some hairy moments in the last couple of weeks, but it all came together on the night. Congratulations to all of the winners – especially Freckle Creative, who took out the coverted “Best overall” award. There are photos for your viewing pleasure on Flickr.
The Sunday after the web awards (that is 2 days after the web awards) Bam Creative moved offices. And, I must say that I like the new digs – they have a much better feel about them and it seems to be much more condusive to work (Which is a handy thing for a work place).
Work at Bam has been non-stop of the past two weeks, the three of four major projects I’ve been working on have pushed the boundries of my sanity, but since some would argue I was already insane, there may not be too much difference… On top of that my MadPilot work still seems to be trickling in, regardless of how much I tell people that I’m working full time now.
Luckily, next month is Web Directions, so I can at least enjoy a couple of days off. I’m really excited about the event, it’ll be great to meet some of the big names in the web industry. I find these sorts of events really inspiring and invigorating. I’ll try and blog my way through it, just like every other man and his dog!
Web developers deal with scheduled jobs a lot. Any online application that deals with paid subscriptions needs to remind users when they need to pay up. Other apps may require data mining services to be run on a nightly basis.
This is pretty easy to do – run a cronjob under *nix or a scheduled task under windows. However, where things get tricky is when you have spent an in ordinate amount of time coding business logic into you application. Duplicating this logic for an external script to be run by cron is pretty silly, not to mention bug-prone. However there is a quick and simple solutions: Web services!
By setting up a web service that does your maintainence, you can leverage the classes and business rules that you have already written. For example, if we take a Model-View-Controller framework (such as Rails or CakePHP) we may have logic that will do data manipulations before the data is saved to the database. There is no way I would want to try and emulate what these frameworks do in an external script. By using web services, you are calling the framework natively and you avoid all of these problems.
How it works
It is really simple:
The beauty is that you don’t even need to bother setting up the web service using SOAP or XML-RPC – REST will do the job quite nicely, especially since the web service is designed to only be used by you. However, when using rails I like to use SOAP, because it is so easy to setup and use. Here is a simple example:
class HousekeepingController < ApplicationController
wsdl_service_name ‘Housekeeping’
web_service_api HouseKeepingAPI
def maintain()
# Run you maintainence script here
end
end
This file is the webservices controller. You would add your logic here – this may be expiring users or automatically checking email.
class HousekeepinApi < ActionWebService::API::Base
api_method :maintain, :returns => [:string]
end
This file defines the method to the web service caller. I usually set the return to type :string so I can output statistical messages or errors that occur during the job.
#!/usr/bin/ruby -w
require ‘soap/wsdlDriver’
include SOAP
begin
wsdl = ‘path_to_wsdl_file’
factory = WSDLDriverFactory.new(wsdl)
housekeeping = factory.create_rpc_driver
out = housekeeping.maintain
put_s out
rescue Exception
$stderr.print “An error occured: #{$!}n“
$stderr.print “Detailes error description, if any:n“
raise
end
This file is called by the cronjob. You will need to replace the string path_to_wsdl_file with the path to the real WSDL file. You get get the WSDL file from a Rails web service by querying /:controller/wsdl (so in this example http://www.yoursite.com/housekeeping/wsdl – pipe the returned xml to a file and save it.
Then it is just a matter of adding the housekeeping_run.rb command to you cronjob! Cron will even email you the results that get returned by your service – Nifty!
Nice an easy, eh?
I use a Toshiba Satellite M70 which has an Intel ProSet Wireless 2200BG Wireless network card.
I have had a couple of problems with the wireless card though:
After a little Googling, it became apparent that the issue is the driver. Easy – go and get the latest driver from Toshiba, right? Wrong – I updated to the lastest version and still no fix.
The solution: Just on to the intel website, select Wireless > Wireless LAN Products menu item on the left and select the wireless card you have.
Download the 123Mb (?!) driver file and install. You will lose your saved Access Point information though.
If you are like me and prefer to have Windows manage you connections, Right-click on the task bar icon and select “Allow Windows to Manage my connections”.
If you are also like me and HATE erronoues taskbar icons, open the Intel Wireless Manager (Start > Programs > Intel PROSet Wireless > Intel PROSet Wireless). Click the Tools > Applications Settings menu and uncheck the “Show application icon in the taskbar” checkbox.
That should do the job quite nicely.
Exciting news just to hand! The perth web industry has been going to through a bit of a shake up of late – perpetual freelancers taking full time jobs (That’s me), stalwalts of the industry going out on there own, mergers and aquisitions.
“Mergers and aquisitions”, you say?
“I’ve heard but nothing!”
Yes, dear reader, this little secret has been very well kept (rare for the industry over here) – two major players in the boutique web arena have joined forces in a super-mega-power play of gigantic small business proportions.
Bam creative (my new place of employ) has recently aquired Cube7 (an old client of mine). Customary website here. This is extremely exciting news as both of these companies are well sort after in the local market.
This event is being simul-blogged by Miles Burke and Simon Wright.
Oh, what a fun Sunday morning I had. I wake up, chill out and go make myself some breakfast. At around 11, I decide to go and check my email. Turn on the laptop – Blue screen of death. Huh? Something about Windows not being able to load the SOFTWARE hive because it doesn’t exist or is corrupt. Oh crap.
OK. No need to panic. I try booting in Safe Mode. No sugar – same BSOD. Not good. After a quick google, I find http://www.kellys-korner-xp.com/xp_sys32.htm which tells me that I can restore my SYSTEM and SOFTWARE hive to a clean state by booting into the recovery console. For those playing at home, there are a number of files located in the system32/config directory of your windows install that hold some fairly critical tid-bits of information, such as application settings and such. Without them, your computer doesn’t know what is installed, or how they should run.
Now we are getting somewhere, I think. So I boot into the recovery console. It is at this point that I realise that I don’t know my administrator password. It is also at this point that I realise that I cannot go any further without knowing my administrator password.
Some more googling and I find a number of applications that claim to be able to reset windows passwords from a bootable CD. I download a couple, but find them less than helpful – It would have been more productive for me to throw nerf balls at a number of post-it notes with letters on them, and entered the resulting characters in a megre attempt at a brute force attack.
It is at this point that I realise I should do something I should have done in the first place – I dropped my trusty Knoppix CD into the drive. Luckily, Knoppix 4.0 can mount and write to NTFS drives, so I could complete the steps in the above tutorial. This is what I did:
This mounts the windows drive to the /mnt/hda1 directory in full read/write mode. I needed to add the force option because I has rebooted XP incompletely and the Filesystem was complaining that I needed to run chkdsk.
Next I copied the /mnt/hda1/WINDOWS/repair/software to /mnt/hda1/WINDOWS/system32/config/software
After rebooting, and waiting the 30 minutes it takes for chkdsk to check everything, Windows was booting! Woohoo! Oh. not quite. All of my user settings were gone. And on closer inspection so where all of my program settings, and hardware settings – in fact Windows was denying all knowledge of any of my software. Whilst choking back tears (I really didn’t have time this week to re-install everything all over – I only did it a month ago) I tried to do a System Restore. Guess what? The registry clean out had hosed them as well. (A big thanks to Microsoft for putting this information in the registry, which is what you are trying to restore…)
Not to be deterred, I figured that the System Restore info would still have to be there somewhere, after all, it is saved as files in a hidden directory right? After a quick Google, I found out that my hypothesis was indeed correct via http://wiki.djlizard.net/SVI.
Booting back into Knoppix and mounting the drive again, I went into the System Volume Information directory. I had two _restore{insert_stupid_amount_of_characters_here} in there. A quick ls -la gave me the older directory. In I went to a fairly recent RP folder and lo and behold I find the files that I needed. I copied them over (according to the tutorial) and voila! Everything was back up and running! God bless System Restore points. I want to glass the registry though.
As an active member of the Port80 community, I am more often than not in attendence at the Port 80 monthly meetups at the pub. It is amazing what crazy ideas are hatched at these informal meetups (It’s a great system – a group of like-minded people meetup and and talk shop over a couple of beers).
I was chatting about 88 Miles and SEO and Kay piped up and said that if I could get people to link to it using the term Simple time tracking, it would help my rankings for that particular term. My response (and I don’t know if this says something about me) was:
“Right, I’ll by everyone one who links to it using the term “Simple time tracking” a beer at the next meeting.
Well Nick Cowie was the first to comply with his less than subte approach, which I find mildly amusing.
So I’m putting the call out. If you are in WA or going to be in WA, and you are going to show up at the next meeting (on 2 August 2006) AND you link to http://www.88miles.net in your blog using a title attribute or text of “Simple time tracking”, I’ll buy you a beer.
That’s right. It’s in writing, so I can’t get out of it :P
I recently started a new project in CakePHP and thought it time to use version 1. But it seems the way that the validator code works has changed, so here is the updated code:
The following goes in app_model.php
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[empty</span>](http://www.php.net/empty)<span class="br0">(</span><span class="re0">$data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$this</span>-><span class="me1">data</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>!<span class="re0">$this</span>-><span class="me1">beforeValidate</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="kw2">false</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>![isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validate</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="kw2">true</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>![empty</span>](http://www.php.net/empty)<span class="br0">(</span><span class="re0">$data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$data</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span> <span class="kw1">elseif</span> <span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">data</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$this</span>-><span class="me1">data</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$data</span><span class="br0">[</span><span class="re0">$this</span>-><span class="me1">name</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$data</span> = <span class="re0">$data</span><span class="br0">[</span><span class="re0">$this</span>-><span class="me1">name</span><span class="br0">]</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$errors</span> = [array</span>](http://www.php.net/array)<span class="br0">(</span><span class="br0">)</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validate</span> <span class="kw1">as</span> <span class="re0">$field_name</span> => <span class="re0">$validators</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$validators</span> <span class="kw1">as</span> <span class="re0">$validator</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span> <span class="br0">(</span>[preg_match</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$validator</span><span class="br0">[</span><span class="st0">‘expression’</span><span class="br0">]</span>, <span class="re0">$data</span><span class="br0">[</span><span class="re0">$field_name</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$errors</span><span class="br0">[</span><span class="re0">$field_name</span><span class="br0">]</span> = <span class="re0">$validator</span><span class="br0">[</span><span class="st0">‘message’</span><span class="br0">]</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$this</span>-><span class="me1">validationErrors</span> = <span class="re0">$errors</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="re0">$errors</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
The validation helper method (See my previous post) looks like this:
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$messages</span> = <span class="st0">“”</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">if</span><span class="br0">(</span>[isset</span>](http://www.php.net/isset)<span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validationErrors</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$this</span>-><span class="me1">validationErrors</span> <span class="kw1">as</span> <span class="re0">$tag</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">foreach</span><span class="br0">(</span><span class="re0">$tag</span> <span class="kw1">as</span> <span class="re0">$element</span> => <span class="re0">$message</span><span class="br0">)</span> <span class="br0">{</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="re0">$messages</span> .= [empty</span>](http://www.php.net/sprintf)<span class="br0">(</span><span class="re0">$message</span><span class="br0">)</span> ? <span class="st0">‘Error in field: ‘</span> . <span class="re0">$element</span> : <span class="re0">$message</span><span class="br0">)</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <ins class="in"> </ins> <span class="kw1">return</span> <span class="re0">$messages</span>;
</div>
</li>
<li class="li1">
<div class="de1">
<ins class="in"> </ins> <ins class="in"> </ins> <span class="br0">}</span>
</div>
</li>