iconfu iconfu iconfu is the world's largest collection of free, open-source icons and it comes with a handy image editor, so you can tweak icons to suit your needs exactly or even draw your own from scratch
invert blue resize move up verbose drawmode lighter previews remove swap animator library library draw shift up make a copy large editor explorer your icon contract agreement tag

25 June 2010

Go to prison for sharing music with your friends

According to a leaked document obtained by La Quadrature du Net, our delightful EU leaders want to criminalise not-for-profit music sharing, as part of ongoing ACTA negotiations. In other words, you do some free marketing on behalf of Big Content Industry, they put you in jail. Is this the kind of world you want to live in?

Thanks to boingboing for the link.

18 June 2010

"PassengerEnabled off" not working

We needed to disable a Rails site for a little bit and figured PassengerEnabled off and a little bit of apache mod_rewrite would do the trick in the least painful way ... but Passenger refused to turn itself off and kept serving our (slightly broken) rails app!

After some hours of bewildered searching and starting to doubt our sanity, we found the culprit: PassengerHighPerformance on - cut that line and PassengerEnabled off works as advertised.

This is not even slightly Phusion's fault, btw - PassengerHighPerformance is clearly marked as experimental and flaky in their excellent docs. What we need to do, in the general case, is figure out a foolproof way of advertising the presence of a potentially buggy option in our config files (whatever the software product is) so it's easy for any team member to eliminate likely causes of incorrect behaviour when the bug-hunt is on.

This article is a start, I guess :)

11 February 2010

ActionMailer and Multiple SMTP Accounts (useful with gmail)

ActionMailer works with only one smtp account; a single google apps account is limited to 500 (or 2000) mails per day; my app legitimately needs more. Besides, I'd rather notifications come from an appropriately named account rather than a generic "no-reply@example.com" address. Here's what I came up with. Firstly, config/smtp.yml describes my various accounts - I settled on one per mailer class. Secondly, a patch to ActionMailer::Base enables switching smtp accounts based on the mailer class.

Here's an example with four mailers: an account mailer, an exception notifier (works with the lovely ExceptionNotifier plugin), a "share this" mailer so your site can be all viral and stuff, and a prize mailer for the good news.

config/smtp.yml

defaults: &defaults
  address:        smtp.gmail.com
  port:           587
  domain:         example.com
  authentication: !ruby/sym plain

account_mailer:
  <<: *defaults
  user_name:      accounts@example.com
  password:       "pw1"

prize_mailer:
  <<: *defaults
  user_name:      winner@example.com
  password:       "pw2"

exception_notifier:
  <<: *defaults
  user_name:      dev_team_obviously_sucks@example.com
  password:       "pw3"

share_this_mailer:
  <<: *defaults
  user_name:      share_this@example.com
  password:       "pw4"

ActionMailer::Base patch

require 'smtp_tls'

module ActionMailer
  class Base
    cattr_accessor :smtp_config

    self.smtp_config = YAML::load(File.open("#{RAILS_ROOT}/config/smtp.yml"))

    def smtp_settings
      smtp_config[mailer_name].symbolize_keys
    end
  end
end

I put this in config/initializers/action_mailer.rb. And that's it! No changes required to your mailers or email templates or anything else in your application. As you can see, the patch merely overrides ActionMailer's smtp_settings class method and replaces it with an instance method that decides at sending-time which smtp configuration to use.

We needed to do this because sendmail was failing erratically - some users weren't getting any mail from our app at all - presumably due to hypersensitive spam filters somewhere on the chain, maybe related to my not understanding how SPF records are supposed to work.

You could easily fancify this to switch SMTP config based on the time of day, or based on your user's locale (so you can use a nicely localised "from" address - Google overrides the "from" address sent by ActionMailer), or even based on whether the Moon is in Scorpio if you cared. Just replace the call to mailer_name with a call to your config-switching method.

I understand that rails 3 is beautifuller in many ways including the way ActionMailer works so this might well be obsolete in a few months except for you suckers working on legacy systems. I hope this helps, let me know one way or the other.

07 February 2010

it wasn't git actually

Ouch! Panic!

$ git push origin master
fatal: unable to fork

and later,

$ git push origin master
fatal: git-pack-objects failed (Resource temporarily unavailable)

But it had nothing to do with git or a corrupted repository as google seemed to be trying to suggest; it was rather my trusty mac running out of something. The solution: shut down itunes and try again.

30 January 2010

Upgrading Gutsy to Hardy

My slicehost slice was running Gutsy (Ubuntu 7.10), but when I switched my projects from my personal svn server to github, gutsy only had an early version of git that doesn't support submodule ... the only way to upgrade git was to upgrade my ubuntu.

After a quick mysql backup, these are the instructions that worked:

sudo vi /etc/apt/sources.list
# [ replace each "gutsy" with "hardy" ]
sudo apt-get update
sudo apt-get dist-upgrade

I found this solution on ubuntugeek.com. It worked first time, like a charm. Congratulations ubuntu team ... linux has come a long, long way

29 January 2010

Back up your mysql database with mysqldump

I don't use this often so I end up googling it every time I need it.

mysqldump -u root -p database_name > sql_dump_file

Now I know exactly where to find it and I don't have to scan a whole article just to get the syntax.

Change "root" to the user you normally use; you an also specify -ppassword (no space between -p and the password) so you don't have to enter the password interactively ... security issues etc but if you're running this from a script I'm not sure what the alternative is.

28 January 2010

What kind of World do You want to inhabit?

Whatever you think of Stallman, go have a look at this quick dystopia, and imagine what kind of world you would like to live in. Then head over to boingboing and learn about ACTA. I preferred the days when Russia and China were the bad guys, and they were far away.