“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey
Senior Software Engineer, UK

Downgrading Rubygems

Installed latest Rubygems which broken my dev environment.

Rob-Laceys-MacBook-Pro:app roblacey$ ./script/rails s
/Library/Ruby/Site/1.8/rubygems/specification.rb:990:in `date=': invalid date format in specification: "2011-9-23" (Gem::InvalidSpecificationException)
    from /Users/roblacey/repos/app/ruby/1.8/bundler/gems/compass-cb709350942f/compass.gemspec:7
    from /Library/Ruby/Site/1.8/rubygems/specification.rb:1346:in `initialize'
    from /Users/roblacey/repos/app/ruby/1.8/bundler/gems/compass-cb709350942f/compass.gemspec:4:in `new'
    from /Users/roblacey/repos/app/ruby/1.8/bundler/gems/compass-cb709350942f/compass.gemspec:4

One to remember next time something screwy happens, and I am to lazy to use rvm

sudo gem uninstall rubygem-update -v 1.8.10
sudo gem install rubygems-update -v 1.5.2
sudo update_rubygems _1.5.2_

Extracting Blizzard Interface Code and Art

In order to start moving with building Warcraft AddOns you might want to extract the Blizzard UI Code and Art bundles. A little bit fiddly but…

/Applications/World\ of\ Warcraft/World\ of\ Warcraft.app/Contents/MacOS/World\ of\ Warcraft -console

On the login screen hit /~ to open the console and type

> exportInterfaceFiles code
> exportInterfaceFiles art

You should now have two new directories in your World Of Warcraft (/Applications/World of Warcraft/) BlizzardInterfaceArt and BlizzardInterfaceCode directory.

Rob-Laceys-MacBook-Pro:World of Warcraft roblacey$ ls -la
total 3944
drwxrwxrwx  21 roblacey  admin      714 24 May 08:59 .
drwxrwxr-x+ 71 root      admin     2414 22 May 11:45 ..
-rw-r--r--@  1 rl  admin    12292 24 May 08:59 .DS_Store
drwxrwxrwx   3 rl  admin      102  3 May 18:35 Background Downloader.app
drwxrwxrwx   3 rl admin      102  3 May 18:35 Blizzard Updater.app
drwxrwxrwx   3 rl  admin      102 24 May 08:59 BlizzardInterfaceArt
drwxrwxrwx   3 rl  admin      102 24 May 08:59 BlizzardInterfaceCode
drwxrwxrwx   4 rl  admin      136 21 Apr 23:50 Cache
drwxrwxrwx  30 rl  admin     1020 24 May 08:59 Data
drwxrwxrwx   2 rl  admin       68 18 Apr 22:19 Errors
drwxrwxrwx   3 rl  admin      102 22 Apr 00:03 Interface
drwxrwxrwx  11 rl  admin      374 22 May 11:45 Logs
drwxrwxrwx   2 rl  admin       68  3 May 21:02 Movies
-rwxrwxrwx   1 rl  admin    67140 22 May 11:45 Patch.html
drwxrwxrwx  11 rl  admin      374 22 May 11:50 Updates
drwxrwxrwx   5 rl  admin      170 22 May 11:56 WTF
-rwxrwxrwx   1 rl  admin      177 24 May 08:59 WoW.mfil
-rwxrwxrwx   1 rl  admin  1927052 22 May 11:45 WoW.tfil
drwxrwxrwx   3 rl  admin      102  3 May 18:35 World of Warcraft Launcher.app
drwxrwxrwx   3 rl  admin      102  3 May 18:35 World of Warcraft Repair.app
drwxrwxrwx   3 rl  admin      102 22 May 11:45 World of Warcraft.app

World Of Warcraft AddOn - pt 1. Hello World

My first World Of Warcraft AddOn, ok so I found a nice tutorial on WowWiki – http://www.wowwiki.com/AddOn_programming_tutorial/Introduction .

- HelloWorld.toc

## Interface: 40000
## Title: Hello World!
## Notes: My first AddOn
HelloWorld.lua
HelloWorld.xml

- HelloWorld.lua

function HelloWorld()
  print("Hello World!");
end

- HelloWorld.xml

<Ui xmlns="http://www.blizzard.com/wow/ui/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://www.blizzard.com/wow/ui/ 
 ..\..\FrameXML\UI.xsd">
  <Script File="HelloWorld.lua"/>
  <Frame name="HelloWorldFrame">
    <Scripts>
      <OnLoad>
        HelloWorld();
      </OnLoad>
   </Scripts>
  </Frame>
</Ui>

And there if you look in the chat console ‘Hello World!’. Kungla is so impressed he needs to have a proper long sit down.

Code what you mean, not what looks right.

This

redirects = []
redirects << params[:redirect_to] || request.referrer

…does not mean this…

redirects = []
redirects << (params[:redirect_to] || request.referrer)

…it means this.

redirects = []
(redirects << params[:redirect_to]) || request.referrer

I18n Translations with a database backend

Having used Rails I18n translations in yaml for some time, we’ve recently started thinking about how users might want to customise content on the fly, without editing flat files and reloading our application. In my mind it should read from the database.

I found the Il8n Backend Database plugin, however it appears its not Rails 3 compliant yet and we can cope with and probably should build the interface for updating our own translations

https://github.com/dylanz/i18n_backend_database

It seems there was support for ActiveRecord in the i18n gem, but it has since been moved out into the i18n-active_record gem.

./Gemfile

gem 'i18n-active_record', 
  :git => 'git://github.com/svenfuchs/i18n-active_record.git',
  :require => 'i18n/active_record'

./config/initializers/i18n.rb

I18n.backend = I18n::Backend::ActiveRecord
Translation  = I18n::Backend::ActiveRecord::Translation

./db/migrate/20101218175356_create_translations.rb

class CreateTranslations < ActiveRecord::Migration

  def self.up
    create_table :translations do |t|
      t.string   :locale
      t.string   :key
      t.text     :value
      t.text     :interpolations
      t.boolean  :is_proc, :default => false
    end
  end

  def self.down
    drop_table :translations
  end

end

irb

irb(main):001:0> I18n.t('loathsome')
=> "loathsome"
irb(main):002:0> Translation.create(:locale => :en, :key => 'loathsome', :value => 'dave')
=> #<I18n::Backend::ActiveRecord::Translation id: 1, locale: :en, key: "loathsome", value: "dave", interpolations: nil, is_proc: false>
irb(main):003:0> I18n.t('loathsome')
=> "dave"

So fairly simple start, it shouldn’t be too difficult to build an interface to handle this.

You can even keep the existing flat files as a fallback if the translations don’t exist in the database.

./config/initializers/i18n.rb

I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
Translation = I18n::Backend::ActiveRecord::Translation

Fan Funded and Exciting Times

This week has been an interesting one, and its all come at once.

Abominable Iron Sloth

For a start, The Abominable Iron Sloth album has finally seen its release on the 27th April after 4 fours of development hell. The band asked for funding from its fans after the debut release and tour. And it seems to have been one tragedy after another for them, what keeps you down only makes you stronger, eh? And here it is, arrived today with a thanks from Justin.

Stabbing Eden

Pledge Music also got their first Grindcore band on board, Stabbing Eden and I am mightily impressed what what I’ve heard so far so I one of the first to pledge. Their project to fund the recording of their 2nd album “A Second Reason To Hate Us” was launch on the 27th April.

Funeral For A Friend

Firstly, we had Madina Lake, then Tab The Band, but now the biggest metal band so far Funeral For A Friend who went live on Monday, and made their target within 36 hours which is a first for us. Well done those men, but its not over yet.

Thomas Truax

Last but not least, a man we stumbled across lately for a random zombie event in Eastbourne. The very quirky, very eccentric Thomas Truax. If only I could afford one of his famous Sister Spinster contraptions.

installing Redcar editor on Windows in 5 minutes

download

download

[Start Command Prompt with Ruby]

gem install redcar --pre 
redcar install
redcar

how to create a singleton with Io

rl@bloodandguts:~/github/io$ io
Io 20090105
Io> Highlander := Object clone
==>  Highlander_0x1957db0:
  type             = "Highlander"

Io> Highlander clone := Highlander
==>  Highlander_0x1957db0:
  clone            = Highlander_0x1957db0
  type             = "Highlander"

Io> h := Highlander clone
==>  Highlander_0x1957db0:
  clone            = Highlander_0x1957db0
  type             = "Highlander"

Io> h type
==> Highlander
Io> h
==>  Highlander_0x1957db0:
  clone            = Highlander_0x1957db0
  type             = "Highlander"

Io>

New Facebook Tools

Just playing with the new Facebook widgets to see if we can get anything useful out of them.

Pledge Music on Facebook

autotest on ubuntu

Finally got around to sorting out autotest on this ubuntu box, I remembered reading on Mr JohnC’s blog about it. Also found a rather nice article on Autotest notifications on Ubuntu using lib-notify

vi ~/.autotest

module Autotest::GnomeNotify
 
  # Time notification will be displayed before disappearing automatically
  EXPIRATION_IN_SECONDS = 2
  ERROR_STOCK_ICON = "gtk-dialog-error"
  SUCCESS_STOCK_ICON = "gtk-dialog-info"
 
  # Convenience method to send an error notification message
  #
  # [stock_icon]   Stock icon name of icon to display
  # [title]        Notification message title
  # [message]      Core message for the notification
  def self.notify stock_icon, title, message
    options = "-t #{EXPIRATION_IN_SECONDS * 1000} -i #{stock_icon}"
    system "notify-send #{options} '#{title}' '#{message}'"
  end
 
  Autotest.add_hook :red do |at|
    notify ERROR_STOCK_ICON, "Tests failed", "#{at.files_to_test.size} tests failed"
  end
 
  Autotest.add_hook :green do |at|
    notify SUCCESS_STOCK_ICON, "All tests passed, good job!", ""
  end
 
end
GPK of the Day Mad DONNA