Archive for August, 2008

More Github failures

Sunday, August 24th, 2008

Output from my trusty svn_up script, which also pulls git:

git detected in arkx
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in arkx, retry manually?
 
git detected in couchrest
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in couchrest, retry manually?
 
git detected in globalite
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in globalite, retry manually?
 
git detected in masquerade
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in masquerade, retry manually?
 
git detected in rack
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in rack, retry manually?
 
git detected in relaxdb
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in relaxdb, retry manually?
 
git detected in rest-client
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in rest-client, retry manually?
 
git detected in thin
executing: git pull
github.com[0: 65.74.177.129]: errno=Connection refused
fatal: unable to connect a socket (Connection refused)
!!! command ‘git pull’ failed in thin, retry manually?

Does anyone else think that it is not really acceptable for a large number of important source repositories to just go down at the drop of a hat?

UPDATE: from github.wordpress.com:

github 7:46 pm on August 23, 2008 | 0 | # |
We’ve taken the site down for approximately 3 hours while we’re upgrading our servers.

THREE HOURS??!!!

Hash.to_struct

Friday, August 22nd, 2008

There’s a bit of a gotcha I encountered recently with OpenStruct. If you create a new one from a Hash with the key, uh, “hash” – then try to read the value back out by doing mystruct.hash – you’ll get the object ID instead. No idea why, I’d certainly never realised .hash was a synonym for .object_id before, but it fails in the worst possible way – looks like it works, accepts the information, and then casually hands you back the wrong value when you least expect it:

>> require 'ostruct'
=> true
>> hsh = {:hash => 'hash!'}
=> {:hash=>"hash!"}
>> os = OpenStruct.new(hsh)
=> #
>> os.hash
=> 18782890

Can’t have that. I had already extended Hash to ease OpenStruct creation, so I modified that to check for key/keyword collisions first.

class Hash
  def to_struct
    if self.keys.map {|k| OpenStruct.respond_to?(k)}.include?(true)
      raise 'reserved word as hash key'
    end
    OpenStruct.new(self)
  end
end

Gotta love those Ruby one-liners : )

So why do this kind of thing at all? Well, Rails has spoiled me with all its method_missing sugar. So if I’m doing something like this:

SITE_CONFIG = {:default_language => 'en'}

I don’t want to access it like this:

SITE_CONFIG[:default_language]

OK, pretty silly reason, but it makes a difference to me! Hey, that’s why I use Ruby in the first place.

>> SITE_CONFIG = {:default_language => 'en'}.to_struct
=> #
>> SITE_CONFIG.default_language
=> "en"

It’s the little things.

Of course the real lesson here is not to use common keywords/class methods as hash keys or anywhere else.

Rails – getting milli/microseconds into strftime

Wednesday, August 20th, 2008

I think this is the only way to do it.

>> Time.now.strftime("%Y/%m/%d %H:%M:%S.#{Time.now.usec} %z")
=> "2008/08/20 01:22:28.367899 +0000"

At the microsecond level, it’s possible for Time.now to change mid-evaluation, so if you *really* care about timing you could freeze the time object first and read from that:

>> now = Time.now
=> Wed Aug 20 01:40:26 +0000 2008
>> now.strftime("%Y/%m/%d %H:%M:%S.#{now.usec} %z %Z")
=> "2008/08/20 01:40:26.597940 +0000 UTC"

Happily, Time.parse will read that straight out of the box:

>> n = now.strftime("%Y/%m/%d %H:%M:%S.#{now.usec} %z %Z")
=> "2008/08/20 01:40:26.597940 +0000 UTC"
>> Time.parse(n)
=> Wed Aug 20 01:40:26 +0000 2008
>> Time.parse(n).usec
=> 597940

Song of the Week

Tuesday, August 19th, 2008

To celebrate Nightwish’s promotion to a probation A-list band, I’ll celebrate by uploading their 14-minute track The Poet and the Pendulum, the bombastic, overblown, teen-poetry-esque but very enjoyable first track from their most recent album.

The Poet and the Pendulum – mp3, 32M

If 14-minute Finnish symphonic power metal rock operas aren’t your thing, I recommend this previous post of a 15-minute Japanese symphonic power metal rock opera, still available.

Lyrics after the break for those who love to sing along!

(more…)

Band list changes

Tuesday, August 19th, 2008

I promoted Nightwish to A-list status, and demoted a few to B-list – let’s see how long that lasts. I also deleted any C-list bands, since there’s so many of them a list becomes kind of endless and futile.

Interesting to maintain a “list of favourite bands” over multiple years. Revisiting it every year or so certainly weeds out the spurious entries, and re-affirms the deserving.

Bryan Scary, Imitation of the Sky

Thursday, August 7th, 2008

Song of the week is from the “new” Bryan Scary album, Flight of the Knife.

Imitation of the Sky

I’ve been on a bit of a new music spree recently, having gotten sick of everything I had, so expect a mini-flood of “songs of the week/day/hour”.

Github becoming more unreliable

Sunday, August 3rd, 2008

Github down again

Gee, I guess centralising source control around a single website might have some downsides after all.

iView is excellent

Friday, August 1st, 2008

Australian ABC’s new iView internet service, in which they offer good-quality streaming flash video of most of their interesting shows, is fantastic. ABC is Australia’s tax-funded government broadcasting system; it’s generally pretty good.

This is exactly what I want ABC to be doing with my tax dollars. We pay for all this content to be made, it should be available free to everyone on the net, in good quality, at any time. This first version is an excellent start. It’s still a bit slow and the quality could be better, but I’m sure that will come in time. Much better than the BBC’s “iPlayer” application. Now hopefully they will drastically increase not only the quality but the range and back catalogue, and add more download options.

Now if only SBS would offer something similar – that is the only other channel worth watching on Australian television and as soon as they do so I won’t be able to see much point owning a television at all.

Check it out if you’re interested in watching Australian taxpayer-funded TV programming. ABC News, 4 Corners and Foreign Correspondent are best for news. If you’re after comedy, the Chaser is currently on break but The Gruen Transfer is high quality.

Oh, and it’s unmetered for iiNet : ) Internode to unmeter it soon too, apparently.