Posted in Coding, Ruby on March 23rd, 2007 by alex / No Comments »
I can’t be the first person to come up with this, but since Google doesn’t show anything, I figured I’d share it.
Take the following code:
class Rect
d"Calculates the area of the rectangle." do
def area
length * height
end
end
d"The height of the rectangle." do
attr_accessor :height
end
d"The length of the rectangle." do
attr_accessor :length
end
end
This lets us do:
irb(main):035:0> Rect.__doc__(:length)
=> "The length of the rectangle."
irb(main):036:0> Rect.__doc__(:area)
=> "Calculates the area of the rectangle."
Yay! Docstrings! So, how does this work?
Read the rest of this entry »
Posted in Coding, Ruby on March 6th, 2007 by alex / No Comments »
…is broken. Well, not really, but it does feel that way sometimes. Not only is the version of Ruby rather out of date (1.8.2), it’s split into separate packages so that you’re never sure if you’ve got everything you need, or if, when something’s not working, it’s because you just forgot to apt-get install something.
As an example, I was trying to get the wonderful Mechanize library working the other day. No matter what I tried, it just wouldn’t fly with the native Ruby – it complained about the Net::HTTP#use_ssl? method not being available. I couldn’t find any combination of packages that would do it. My usual port of call would be checkinstall, or possibly hacking the gem itself, but for one reason and another that wasn’t a viable option this time, and I didn’t have the time to get the editor out and get my hands dirty.
Enter Backports. I’d not had cause to use it before, but it really saved my bacon this time. Ruby 1.8.5 installed cleanly, Mechanise works, and the client and I are happy bunnies. Yay. Check there for instructions – it’s dead simple, and if you’re using a Sarge box, I reckon it’s too good not to know about.
Posted in Coding, WPF, XAML on February 14th, 2007 by alex / No Comments »
Woo, long time no update.
Anyhoo, in my WPF explorations today, I managed to trigger this little gem:
System.ArgumentOutOfRangeException : '100' is not a valid
Percent value for a KeyTime. The Percent value must be a number
from 0.0 to 1.0.
What the hell were they thinking?
Posted in Projects, Ruby on December 4th, 2006 by alex / No Comments »
I’ve just kicked off a new project, and because I’ve been looking for an excuse for a while, I thought I’d give Django a try.
Python was an interim language which I toyed with a while ago, but I discovered Ruby before I got that comfortable with it. Nevertheless, I did enjoy it, and I am familiar enough with it that the language barrier wasn’t an issue. After a couple of days, it became clear that Django just wasn’t cutting it – I’ve reverted to Rails as a result. There were two main problems I had which made me shift, and I don’t think it’s just me being stuck in my ways.
The first of these was that Django doesn’t have anything like Rails’ migrations. These are an absolute godsend, to the extent that on the past couple of PHP projects I’ve been shanghaied into, I’ve duplicated their functionality as much as possible. They save me so much time and hassle.
The second is the half-hearted nature of Django’s testing framework. Admittedly, I was using 0.95 rather than the development version, but it’s really quite paltry compared to what you get out of the box with Rails. I just couldn’t get comfortable in the same way as I found I did quite quickly when I first started learning Rails.
It’s quite possible that these problems will go away by the time Django hits 1.0, or even that they’re addressed well enough in the development version that I’d be happy with that. I have serious reservations about learning a framework with a development version, though – it’s too easy to stumble on a dev bug and not know if it’s a fault in your own code.
I’ll probably come back to Django at some point – it’s got a lot to recommend it – but for me it’s just not quite there yet.
Posted in Uncategorized on December 3rd, 2006 by alex / No Comments »
Paul Kedrosky’s Infectious Greed: The Economics & Emotion of Global Warming
The conversation in the comments on this blog entry is almost a perfect example of what I don’t understand about the current debate about climate change. On the one hand, we have a fairly large body of evidence to state that we may be causing climate change through our actions, and that this climate change may become irreversible.
On the other, we have a counter-argument saying that because it might not be us, we don’t need to worry. Sometimes an economical backup is thrown into this, saying that to do anything would be too damaging to the global/local/whatever economy.
Surely the downside of irreversible climate change is so bad that we can’t possibly take the risk?
Posted in Uncategorized on December 1st, 2006 by alex / No Comments »
Release The Music » Sign our petition
I’m really not one for political canvassing, but this is important. If you’re in the UK, please go and put your name to this petition.
A little background, if you’re not aware. A government report looks set to recommend that copyright on recordings is not extended from the current 50 years to 95 years. This is in direct opposition to the stated position of the major record labels. There’s a little more info here.
I can’t see a rational justification to extension at all, but the music lobby is powerful. By adding it to the petition, your name can be used to counter their argument.
releasethemusic
Posted in Cool People on November 8th, 2006 by alex / No Comments »
Red James : New Vision
Just found this photographer’s site. I love the feel of the photos. Really powerful stuff.
Posted in Coding, Shaxam, XAML on September 11th, 2006 by alex / No Comments »
Just made a quick update to the Lexicon page. In a nutshell, it turns out that you can animate PerspectiveCameras in exactly the same way as Model3Ds, because they support a Transform property. I haven’t had a chance to play with it properly yet, but it means no more fiddling with Vector3DAnimations to change LookDirection any more. Woohoo!
Oh, and it looks like the same applies to Lights. More Woohoo!
Posted in Coding, Cool stuff, Uncategorized on September 11th, 2006 by alex / No Comments »
Listening To Reason: First Impressions of L#
This looks really fun. One of the main issues I’ve had with Lisp in the past is that the libraries seem to be completely foreign. With a well-known and understandable library behind it, L# could well be the answer to that. Shame it doesn’t compile, though…
Posted in Coding, Ruby on September 9th, 2006 by alex / No Comments »
Refactoring is one of those areas that those people with Big Flashy IDEs like to complain has very little support in Ruby. To a large degree, there’s truth in that – Ruby’s syntax is complex, and its dynamism means that there are some things that you just can’t predict at writing time, so doing things like method renaming is really quite difficult. So, what to do? Changing things to make their names more accurately reflect their function is a fairly critical refactoring operation. Well, if we can’t do it at write time, how about runtime?
Read the rest of this entry »