Solar Power in Portugal

I live in Australia. Australia is the driest inhabited continent on the planet (Antarctica is the driest) and we get a phenomenal amount of sunshine, as many Queenslanders will testify — Queensland has the worlds highest rate of skin cancer.

Unfortunately for Australia we have lots of coal and more importantly a very powerful coal industry. So while countries like Portugal are doing the right thing. We are told renewables are too expensive, blah, blah. Lies. Coal is too cheap and the coal industry is too powerful.

Our leaders and economists tell us we are in a resources boom why don’t we put that money to good use and follow Portugal’s lead.

Why eating fish is not as good as you might think.

It’s about 13 years ago that I gave up eating commercially caught fish as a personal protest against the practice. I would eat fish caught locally (in fact the last fish I ate was a trout barbecued in butter and garlic caught by a friend’s neighbour) but this only lasted a year or so and I stopped shortly afterwards

After reading this article in the Guardian I see that nothing has changed. In fact it’s got worse.

A couple of facts from the article:

  • There is 32 million tonnes of bycatch a year, i.e. about one third of all fish caught are thrown away
  • For every prawn you eat fish weighting 10—20 times the weight are thrown away. Yes that’s right for every 1Kg of prawns you eat 10 to 20 Kgs of all kinds of fish are caught, often left to die on the deck while the prawns are being pulled out, and then thrown back overboard.

There are many, many other horrifying points raised in the article and I implore you to read it.

Finally: ” … that by 2050 we will only be able to meet the fish protein needs of half the world population: all that will be left for the unlucky half may be, as he puts it, ‘jellyfish and slime’.”. And the really sad thing about this whole affair is that the half won’t be the fat and over fed west.

Rails caching woes

I’ve just been going round in circles trying to work out why my caching sweeper in rails was not working after I changed the relationship between two models.

I have a post and comment model which was a has_many/belongs_to relationship which I recently change to has_and_belongs_to_many. That part was fine but when I deployed to staging when I tried to delete a comment I was getting NoMethodError on a nil object error. Ummm. So after spending a good few hours banging my head against the brick wall conveniently located on my desk for moments such as this and invoking the “I really like rails but some bits of it …” mantra I finally worked it out.

When the object is passed to the after_destroy method the object has already been deleted from the database and given that ActiveRecord lazily loads, when I tried to access the post object from the comment object it did a dummy spit because it’s trying to load an object via another object that doesn’t exist.

So I changed the method to before_destroy and all is good. You might argue this is incorrect as you would want to make sure that the object has actually been deleted before the cache is invalidated but in all honesty I don’t care. The worst case that can happen is that I invalidate and object from the cache that still exists.

Problogger

In the name of winning two monitors from here I’m writting this blog post. Good luck to me!

Oh what fun it would be if I won.

Theory

There is much said in the name of a theory. So I just want to clarify the different meanings and their uses of the word theory. There are two main meanings: the vernacular and the “science” definition.

In the vernacular the general meaning of theory is conjecture; something that is speculated, I could easily say “I have a theory that the sun is blue”. Now I might have pulled this out of my arse but it is a valid use of the word theory and I will get labeled (justifiably so) a crank if I start peddling “theories” like that.

In science a theory is a “logical explanation” or a “testable model” (both quotes from the mighty wikipedia). So if I say “I’ve got this mathematical theory that says the sun is blue” it would be wrong. There is no testable model that says the sun is blue (well this isn’t strictly true as there is a component of the sun’s light that is blue but sunlight, if measured across the full spectrum of visible light, is generally considered to be white).

The people who believe in creationism and “Intelligent design” are being very disingenuous when they say evolution is only a theory. They are applying the vernacular meaning to the scientific theory of evolution. As such they should (justifiably) be called cranks.

Just though I’d try and clear that up! For a longer discussion on this, as always, see wikipedia.

Note to Self — caps lock -> escape

printf "! Esc on caps Lock\n \
remove Lock = Caps_Lock\n \
keysym Caps_Lock = Escape\n"  > $HOME/.Xmodmap

Project Honey Pot

Well after being hounded by Mr Palmer (well he suggested that I join a couple of times) to join Project Honey Pot I finally joined and donated some MX records and put it on this website. I want to put it on Limes & Lycopene but there is no script for Ruby as of yet.

There are a number of good introductions to Project Honey Pot: here & here but it essentially boils down to laying traps for spammers (or more specifically harvesters) and then tracking them when they send spam. This information is then made available via their http:BL service which allows you to do a DNS lookup on an ip address to determine if it is a known spammer.

Given that I’ve just finished the new blog and Kathryn is still getting some spam even though she is using akismet (albeit a very small amount) I thought that I use http:BL there. Unfortunately there was no ruby code written that I could find (this is an unusual thing in it’s own right) so I’ve knocked up a small class that interfaces to the http:BL.

The code in it’s entirety is:

And that’s it. You can download a tarball here containing the above code and some tests.

Any comments welcome.

Brittany Spears and Semiconductor Physics

Not to be outdone by Mr Palmers post Britney Spears explains Garbage Collection here is Britney’s Guide to Semiconductor Physics.

But the thing I really love about this site is that if you do a google search for britney spears this site appears ninth. Go Britney!

Inernet Explorer

This article posted on slashdot stating that IE is down to 70% market share in Europe is very encouraging. Microsoft has been playing silly buggers with respect to web browsers for so long it’s nice to finally see some comeuppance. IE has a very poor track record with regards to security, is wantonly non-standards compliant (something that Microsoft has excelled at for years) and is significantly lacking in useful functionality. Here are a few articles to whet your appetite: why you should dump internet explorer, Developers gripe about IE standards inaction, The Web Standards Project and there are plenty more.

So in short if you are using IE change! The most obvious choice is Mozilla but if you are using a Mac then Safari is probably a good choice. Safari is now available under windows but is still in beta. If you use a number of different platforms then again mozilla is probably the best choice.

Do it and the web developers of the world will thank you!

New Blogging Engine

For the past few months I’ve been writing a new blogging engine for Limes & Lycopene. It is written in Ruby on Rails and is designed to provide the functionality need for a blogging engine but nothing more. Although i’ve tried to make it fairly minimal I’ve put some effort into doing the Right Thing™, for example the search functionality is quite sophisticated. If you want to search for ‘lycopene’ in the title you would enter title:lycopene.

Now I know most people at this stage say why on earth would you write you own blogging engine there are loads of them out there. And that would be a fair question! There are a number of reasons:

  • The blog is going to part of a much bigger system and I didn’t want to have to maintain and integrate a third party blog.
  • The existing blog (Wordpress) is extremely unreliable. To give you an example of what I mean I have a script that runs every minute and makes a five request to the blog, if the requests time out after five seconds I restart the server. The server is sometimes restarted 20 times a day. Yes I know it is widely used and therefore “must be reliable for me it isn’t.
  • Google Analytics would not work on Kathryn’s site but would work on mine. This seems to be a product of the theme.
  • The page used to write posts can only be described as evil (yes I know you can change it).
  • Wordpress is written using php which is being run using fcgi under lightty and is not a particularly elegant solution and uses a fair amount of memory (see this post for more details). The machine that runs Limes & Lycopene is a small memory constrained Xen VM and the less running on that machine the better.
  • I wanted to gain more experience using ruby on rails.

So on Saturday afternoon I released the new engine, it wasn’t a particularly pleasant experience, mainly due to exporting the existing data from Wordpress, but it is now done (and the export only needs to be done once). There are a number of defects that need to be fixed but are not serious enough to delay the release. I have to say that I’m very pleased with the results and my admiration for rails has increased dramatically. Let me know what you think.

I would also like to thank Styleshout for there fantastic website template and an even bigger thank you for releasing it under the Creative Commons Attribution 2.5 License. I had been looking for an open source site design for quite a while before I found pixel green so thank you, thank you, thank you.

As I mentioned above there are still a few defect to fix up and some more functionality that really does need to be added but once I’ve done that I will be releasing it under the GPL license. If anyone has any bright ideas for a name please let me know!

Next Page »