Friday 16 February 2007

Embracing change

Well, I got bored with the messy old template so I chose a new one. Hope you like it. I use the singular in referring to the audience 'cos I doubt there is more than one person reading my blog, huh Pete?

Also ditched the Google Ajax search as that got annoying.

Talking of annoying, my snap preview script got ditched during the template change so I had to bung it back in. Another 3 minutes of my life wasted, sheesh!

Wednesday 14 February 2007

ruby caching

Is so easy.

Drop the following in your environment.rb


module ActionView::Helpers::CacheHelper
  def cache(name = {}, options = nil, &block)
    @controller.cache_erb_fragment(block, name, options)
  end
end

class ActionController::Caching::Fragments::UnthreadedFileStore
  def read(name, options = nil)
    if options.is_a?(Hash) && options.has_key?(:ttl)
      ttl = options[:ttl]
    else
      ttl = 0
    end

    fn = real_file_path(name)

    # if cache expired act as if file doesn't exist
    return if ttl > 0 && File.exists?(fn) && (File.mtime(fn) < (Time.now - ttl))
    File.open(fn, 'rb') { f f.read } rescue nil
  end
end


And you can cache with ttl in views selectively:

<% cache("some_name", :ttl => x.minutes or hours or days) do -%>Heavy old content<% end %>

Of course, you can always manually expire content too:

expire_action :action => 'action_that_created_the_content'

This is not my own work. I found it and just wanted to share!

irony

There is a new movie out called Hot Fuzz from the same guys who did Shaun of the Dead: Working Title. They were apparently thinking about doing a sequal to SOTD called 'From Dusk Till Shaun'. Neat.

The strap line for Hot Fuzz is 'Small town. Big Cops. Moderate Violence'.

Hmm, since when has violence ever been moderate? Not that Hot Fuzz is guilty of glossing over violence, I see this a lot in TV listings: moderate this, mild that. Like the darker side of the human condition is so easy going. As Grissom says (sort of), 'allowances made by society makes it easy for us to excuse our every action and not take responsibility for what we do'.

:I'm going to inflict mild to moderate violence on you random person
:Okay, violence to my person in moderation I can handle mildly psychopathic man but beyond a modest beating you may struggle to rationalise your already questionable acts

Doesn't quite make sense. Verging on the oxymoronic.

Tuesday 6 February 2007

Woo Hoo!

I won something! I rarely win prizes in raffles and that kind of thing. This is great!

Win too - its easy and seems to be catch free although I'll surely blog as soon as I receive spam....



BTW - it was a £10 Amazon voucher....

Sunday 4 February 2007

Happy days

Well so far it's been a cracking good Feb for English sport. An utter pummeling of the Australian cricket team which has been on the cards all summer you have to admit...and the Socttish rugger team got shown what for thanks to Billy, Jonny and Harry along with 13 other super start friends.

This Six Nations is going to be a cracker...or will it? The only downer on a weekend of great sport (Wales & Ireland game included) is the whining has-been Jonathan Davies. For the love of Rugby, please, BBC do not continue to employ this f***wit. Such blatant bias against anything English, Irish, Scottish, French or Italian (you get the picture) is delivered via whining, nasaly bile sodden, nonsense soaked ignorance thus soiling quality sporting entertainment.

In a similar vein to Sniff Petrol's most worthy 'Stop the Cock' campaign I suggest a 'Stop the biased whiner' movement to increase everyones enjoyment of the 6 Nations and up coming World Cup on the BBC.

Friday 2 February 2007

Happy Friday....

I'm hung over. Go away and leave me alone.