Blog

Archive for January 2012

Adding default interpolations into I18n

By ayates.

Heres a quick and dirty monkeypatch for adding default Interpolations into I18n (v0.6.1).

module I18n
  class << self
    attr_accessor :default_interpolations

    def interpolate_hash_with_default_interpolations(string, values)
      values ||= {}
      values = (default_interpolations || {}).merge(values)

      interpolate_hash_without_default_interpolations(string, values)
    end

    alias_method_chain :interpolate_hash, :default_interpolations

  end
end

In my case I'm adding the defaults in using a before filter, allowing me to set a customer's currency e.g.

def set_default_interpolations
  I18n.default_interpolations = { currency: current_currency.symbol }
end

Splitting Rails routes into multiple files

By ayates.

I was just asked how you would split your Rails routes file into multiple files for instance in the case of having an application frontend and a set of routes serving your application's API.

Now, I have a number of applications which work this way and utilize routing constraints to determine which routes should be used but splitting them into more manageable individual files is a nice idea so, my first thought...

The new DanChristian.net goes live!

By ayates.

Dcnet V2.5 HomeThe minor redesign and migration of DanChristian.net from Wordpress to RefineryCMS is now complete and live, with the new video gallery for free music/saxophone lessons!

In the last three days since launch the site has already demonstrated a 350% increase in traffic. There is more work to be done here, but the relaunch is off to a good start.

Check it out if you're interested in taking up the saxophone, new lessons daily and more content to come soon.

I was hating GoDaddy before it was cool...

By ayates.

I see a lot of posts recently about how pathetic GoDaddy are, and why you should leave them. There was their fickle SOAP support, their general marketing attitude - you know, how they try and sell you 50 other products between you selecting a domain and paying for it, even their support emails have marketing in them... you're trying to get some help and they're just trying to sell you more stuff. They are without a doubt a marketing monster, and to them this is far more important than customer support.

SSH keep-alive / timeout

By ayates.

If you find you're having a hard time keeping a connection, your SSH sessions are locking up or disconnecting after short periods of inactivity and it's driving you slightly insane you can set the SSH keep-alive interval in your .ssh/config:

Open or create your ssh/config file in your editor of choice e.g.

vi ~/.ssh/config

And add the following line to your file:

ServerAliveInterval 15

This indicates the number of seconds after which a message will be sent to the server to keep the connection alive, only if no data is received from the server in that period. The default value for this is 0 (never). Check the man page for more information.

Hello World

By ayates.

I finally found some time to put together my blog - the design for which I created last year and has been sat on my desktop for the last 6 months, just starring at me.