Apr 18
A forage into Ruby
I’ve been experimenting with Ruby (and with the Rails framework) the last few days after a need came up for a console based application with a large degree of string manipulation. I have been using Python and Perl for similar jobs before - in fact I run a number of Python scripts that have proved to be extremely useful. A lot of the legacy code I work with is written in VBA (Visual Basic for Applications) within Access and Excel so this was another possible choice.
I wanted to avoid hosting my code within Access due to a possible rollout of Access 2003 soon and the fact that I needed to access mailstores - the thought of using ADO scared me and I don’t have a machine I can dedicate a copy of Outlook to so this effectively ruled out VBA.
Perl has loads of libraries available on CPAN and Python seems to be going the same way but the quality of community code can be suspect - I’ve never run into a problem with it myself, I use CPAN libraries all over the place - especially on my web server - and I didn’t want to be supporting third party libraries as well as my own code.
We are effectively a C# shop for new development - just myself and my boss keeping the legacy code up to date really - so I had to consider this as an option. .Net provides a nice SMTP library but not POP3 or IMAP… so that brought me back to the same problem I had with Perl and Python. I spent about half a day with a CodeProject IMAP library but it was not feature complete and after scoping out the changes I’d need decided I might as well have written the library myself.
I’ve been looking into Ruby and Rails recently for a personal database project and knew that Rails provided a lot of functionality. Now, I know that technicaly Rails is a community third party library but it is so much more refined and integrated than a hodge podge of CPAN modules thrown together. And, Rails provides IMAP straight “out of the box”. I loaded up Ruby.Net only to find that neither them or IronRuby supports Rails yet! This project was proving more complicated than I had expected - and I hadn’t written a line of code yet.
So I made the decision to write this application in neat Ruby on Rails without linking to .Net binary in the hope that Ruby.Net will catch up eventually! (Rails support is expected in the next version apparently)
My first surprise was that Rails just works. I did not have to go through any rigmarole to get Net::IMAP to work - just
require 'net/imap'
and I was off. As I didn’t have access to the rails scaffold I used DBI to access a Microsoft SQL Server instance with the amazingly complicated
require 'dbi'
which is shorter even than PHP’s database linking code. Opening a handle with
dbh = DBI.connect('DBI:ODBC:MY_DSN')
gave me immediate access to the ability to run SQL with sensible data returns.
Suffice to say, I was impressed. A few helper functions later, and some hastily learnt Ruby conditional statements for error catching
var = var ? var : " "
to remove nils from strings - this technique even works when passing parameters - amazing. Features available in Perl like
run_my_long_complex_function(variable) unless defined?(use_simple_mode)
are so much cleaner and clearer to read in Ruby - plus the excellent “PickAxe” (Programming Ruby - possibly the best Ruby textbook) not only encourages this technique - it’s the one it teaches you.
More impressive and powerful functions that let you pass in chunks of code (’blocks’) using “yields” are likely to be my next excitement but so far I haven’t needed them.
The only thing I can say is that I had some 22 lines of error checking code using if then else etc - Ruby first impressed with the ability to use ? : notation which reduced it to about 8 lines. Then I realised that I could use conditional formatting like the unless example above. Then Ruby amazed me with the ability to use them both together - did you realise that if blocks are expressions, not statements - Ruby did. That code is now 1 line - and it works just as well.
I muchly look forward to developing the rest of the feature set in Ruby as I’m sure it’ll keep impressing me with it’s ability to make programming interesting again!
2 commentsMar 19
Arthur C Clarke
I’m not one given to obituary’s - but celebrating life and remembering the good times only works if you know someone close enough to be able to say “I know how this person felt. I know what they would want to hear right now”. I’m not in this situation today, I feel sadness and an undeniable loss.
Hours ago one of the finest science fictions writers to ever grace us with his prose passed away. Arthur C Clarke, author of 2001, the Rama series and countless short stories (from which I know him best) was the visionary of the last half of the 20th century. Without him so many ideas would never have been explained so clearly, so many young readers would never have looked upward and pondered the questions he asked and our world would have been worse for it.
At a time of such rapid scientific change - a telephone in every household connected by satellites? - who else but Clarke could have theorised the domestic demand and provided the idea of how to do it - 9 years before Bell Labs got there and actually started to build them. For a Science Fiction writer to have had such a direct impact on society is remarkable, but somehow, when we are talking about Clarke, it is not so remarkable - it is easy to have expected nothing less.
I will mourn his passing, as will all of his readers, because we have lost something special - a mind filled with ideas and revolutions that will not come again.
Remembering the good times will not be difficult - Clarke has left a wondrous collection of his ideas - the fruits of his genius - in every library in every English speaking town. I for one will console myself with knowing that his memory will long outlive my own.
From us carbon based bipeds to our lost spirit - we thank you for all that you have given us.
A humble reader.
More obituary’s
No commentsNov 24
DDD6 as it happens
Well - posting from the foyer of Microsoft’s Thames Valley HQ during DDD6.
The emphasis is most definately on scripting - but that was clear from the agenda. As always, SQL and databases in general are getting a lot of exposure but hidden in are gems like Ben Lamb’s excellent introduction to Microsoft Powershell.
Even burdened down by the black death, Ben gave an interesting, and most importantly, practical demonstration of the new .Net/administrative CLI.
Other highlights so far include Chris Hay and his well placed use of Monty Python demonstrating Silverlight 1.1 - I look forward to his next session building a twitter app!
No commentsOct 18
Firefox gets down with the natives
Firefox 3, due out “soon”, is at a conundrum. Do they want to maintain a familiar look and feel across borders or go native on each platform?
News.com covers the story nicely.
Personally I agree that fitting in to the host system is a good idea - it makes for easier integration and one could argue shorter learning times but as a user of three separate operating systems (Windows, Ubuntu and OSX) I like that Firefox looks the same on all of them. I use Google Browser Sync to keep my bookmarks up to date, del.icio.us (and it’s firefox addon) for the rest and don’t have to worry about it. I use Firefox far more than any other application - can’t imagine my day to day life without it.
I’m probably bias - in fact I am - because I don’t like the look of Safari or of IE so I naturally want Firefox to look like Firefox. I don’t use Opera because I don’t know how it works and because I’m afraid it won’t do what I want. I know Firefox will but that isn’t the reason I use it. Something about it feels right.
I’m writing this on a machine without Firefox (need to put Portable Apps Firefox on the network!) and I feel icky inside. It’s a browser with tabbing so I’m able to survive having 20 web pages open without clogging up the OS but it just doesn’t feel right. I can’t bring myself to think of using Firefox and having it look.. like this. It’s just wrong.
So I would definately definately keep Firefox looking as it does - or at least ship the current default skin as an option. I guess that’s the great thing about open software -if I don’t like it, I don’t have to lump it.
No commentsOct 12
Developer Day 2007 - DDD6
The UK development community event DeveloperDeveloperDeveloper is returning this year to Microsoft’s Reading Campus. DDD6 will be held on November 24th 2007 and the agenda is now open for voting and shaping.
To show your opinion, visit:
http://www.developerday.co.uk/ddd/votesessions.asp
No commentsSep 24
DNS in Linux
I have a world of problems with DNS in Linux. My Ubuntu box is sat on a Windows 2000 domain and usually holds it’s own. It’s not a member of Active Directory nor does it import great knowledge from Active Directory - it is an island of peace amongst the Kerberos hoades.
Most recent problem - after an unscheduled, shall we say ungraceful, shutdown of the box it appeared to have dropped off the network. After a lot of faffing I found that the DNS servers were not specified anywhere, the machine became static IP from DHCP assigned between the last reboots so evidently I didn’t set it up correctly the first time. After trying several solutions this helped:
http://blog.technomancy.org/2006/09/21/adding-a-static-dns-server-to-resolvconf/
Excerpt:
In order to assign a static nameserver, you must edit the file /etc/resolvconf/resolv.conf.d/base, and add you “nameserver x.x.x.x” line there. This file is automatically included at the start of the /etc/resolv.conf file that resolvconf generates.
To add a search domain I similarly added “search xxx.com” to the same file.
- Update
I have recently installed Ubuntu 6.10 (I know, I’m still about 2 releases behind) and I didn’t have this problem. Good work team Ubuntu!
No commentsSep 10
My Website
As part of my coordinated online presence I have put together a website at http://pcurd.co.uk/
Please enjoy. Applause optional.
No commentsSep 10
M4 in the morning

M4 in the morning 2, originally uploaded by PCurd.
The M4 in the morning is a scary place. It’s a standstill and it’s not fun. This morning I faced the view of 45 minutes of other car’s behinds.
Not the most pleasing way to spend one’s morning.

Sep 5
The Hoff
Recently my ISP’s holding company, “Pipex Internet Ltd”, has been using David Hasselhoff as their mascot/front man for what I can only imagine is comedy reasons.
For example:

(Me and The Hoff in a publicity Web2.0 tool generated picture)
If you have managed to live in sufficiently large holes for the last 55 years, David Hasslehoff is a legend of television and film acting. He was of course the star of Knight Rider, a superb piece of early 80’s entertainment and financier/star of Baywatch - according to the Guinness Book of World Records, Baywatch is the most watched TV show in the world, with over 1.1 billion viewers.
Now it had occurred to me that someone is paying for this and that it might be me. Surely some percentage of my monthly subscription is going to Pipex rather than my own ISP so some percentage of that money must be going to The Hoff… Whilst advertising is important, and what with The Hoff being a meme at the moment I have no problem with that. I for one welcome our hair chested overlord. However the story gets complicated once you realise that Pipex has been sold to Tiscali.. now Tiscali has no mascot that I am aware of, no media attention beyond their own advertising and so I began to fear - is The Hoff still receiving my pennies? Only one way to find out - email accounts!
My Email:
Good evening,
I notice from recent media coverage that elements of the Pipex Group, owners of Freedom2Surf, have been sold to Tiscali.
As a long standing customer I would be interested in knowing how the distribution of my monthly subscription will be effected by this change in ownership. Particularly if a proportion of my fee will still be going directly to The Hoff as I imagine it has since Pipex recruited their legendary mascot?
I appreciate you taking the time to respond to this request, it may well be a deciding factor in whether I remain a customer of Freedom2Surf in the coming months.
Regards,
Peter Curd
Now Freedom2Surf have excellent support staff, very helpful and knowledgeable but I was not expecting as full a reply as I received.
Their Reply: (names changed to protect the innocent)
Hi Peter
We can confirm that Pipex Internet Ltd including Freedom2Surf has been sold to Tiscali UK.
Your monthly subscription will continue to be paid directly to Freedom2Surf as it always has been and there will be no change to this.
Unfortunately at this time we can not confirm what if any proportion of this subscription will be paid towards ‘The Hoff’.
I am sorry we could not fully answer your query at this time.
If you have any further queries please reply to this email or alternatively telephone the billing team on the number shown below.
Kind regards
*****
Freedom2Surf Billing Team
Sadly my question remains unanswered, but perhaps it is best left that way.
No commentsAug 8
Online Music Services
I’m a huge fan of free (as in beer), and who isn’t?, but I do get scared by free music. Free music can be found at a multitude of places but this post isn’t about where, it’s about how.
My current favourite is Seeqpod which spiders the web using something they call biomimetic search and discovery. Effectively, it is designed to mix up good ole’ fashioned guesswork and copy (hence the mimetic) the way that human minds link information and recall connections. It’s a very cool idea and from the results it gets, it works. Certainly a new approach to trawling podcasts etc. But most scary of all is the built in audio player. Not only can you search for music, as you can with some jiggery pokery in google but you can listen to it directly within the results. Isn’t that a littttle close to breaking some RIAA noses? The video player launches videos within the indexed sites video tool (for example a YouTube video opens in the recently launched external YouTube player) which at least pushes some of the load off to the video site. You could, and I would, argue that the site only indexes what is already available rather than actually distributing works however that argument hasn’t worked well before, Digg, and I can’t see it working in every case.
Is the guy who gives you stolen goods breaking the law? Yes. Is the guy who tells you where the guy who gives you stolen goods breaking the law? Pretty much, yes. It’s conspiracy to commit an offence.
More so than any legal problem, how do they intend to stay in business? There are no adverts on the site. Not even the ubiquitous Google AdSense to be seen. It’s currently a university project form UC’s Lawrence Berkeley National Laboratory which might explain that. Perhaps a future link to Amazon will fund it? I assume that no music data crosses their servers so really all they have is an indexing business to run. The page itself is AJAX and Flash so limited bandwidth there and frequent users will have it all cached anyway.
Maybe it’s not so hard to be innovative for free these days?
I’d be interested in any music services you can recommend. Criteria are : Free as in beer, bonus points for OSS; able to find a range of music; easy; fast; Firefox compatible.
No comments
