On Github | On Twitter

Mr. Dias

Talks about code

  • 25 May 2010

    Ruby Enterprise, Passenger and Encoding hell

    Today I spent several hours with my friend Gleb trying to find a weird bug we we're having importing some rss feeds.

    We have a rake task that will grab an xml feed and import it to our system. When we call this rake task from the command line it would run fine, but if we run it from inside our application, we would get some wrong characters (you know, the usual ???) in the imported items.

    After trying a million ways to get this to work, we found that the problem is that Passenger doesn't pass the environment variables to the application processes, so our import task wouldn't know about our LANG variable. We have this set to LANG=en_us.UTF8 but our process would not see it, which would cause ruby to not use utf8 for the strings.

    The solution was pretty straight forward, just pass the LANG variable when calling the rake task, finding the solution not so straight forward and definitely not fun. The sad part is that this is a known issue with passenger since 2008 and this is the second time it gets me (If you've tried to use an oracle db you know what I'm talking about). If you need more information about this you can check it here.

    Continue Reading Comments

  • 11 Apr 2010

    Emacs support for Jekyll

    If you're using emacs to write your jekyll blog posts, there is a mode to help you with some common tasks. It is originally from metajack. Recently I thought it could be a nice addition to have syntax highlight support for jekyll posts, so I got my hands dirty and after some hours of lisp hacking (this was my first attempt at lisp programming) it was a reallity. It is based on nxhtml so you need it to work.

    Continue Reading Comments

  • 09 Mar 2010

    Setting environment to run migrations with capistrano ext

    If you're using capistrano-ext to deploy to a different server, using a custom environment, you've probably noticed that it always tries to run the migrations for the production environment, like this:

    cd path_to_app/deploy/releases/20100309152738; rake RAILS_ENV=production  db:migrate
    

    Digging through capistrano's source I found the solution is really simple, just set the rails_env variable to the environment you want, in this example staging. So inside config/deploy/staging.rb

    set :rails_env, "staging"
    

    Then when migrations get executed they'll have RAILS_ENV=staging.

    Continue Reading Comments

  • 08 Mar 2010

    Monthly archives for Jekyll

    Recently I moved my blog to Jekyll, while being able to write stuff directly in my favorite editor EMACS, there was some functionality that I was missing from my previous custom blog engine, such as archives. Looking at how I could achieve this, I found Raoul Felix approach to the problem. Instead of patching jekyll, he wrote a small library that wraps around it, called jekyll_ext. Using it was really easy, and based on some of the extensions he created, I was able to provide this functionality in my site.

    Although I had archives generated for me, I was still missing a way to display this information on my site, so I decided to create my own extension.

    Continue Reading Comments

  • 02 Mar 2010

    View your emails with cucumber

    I've been developing some new mailers at work, and I've found it really helpful to be able to view the emails as they are sent to the users. So I've implemented a cucumber step to help me achieve that, inspired on a similar webrat step for web pages.

    Continue Reading Comments

  • 23 Feb 2010

    ActiveRecord migrations from the console

    If you ever run into the situation where one migration doesn’t complete sucessfully, and you’re stuck with a column in a table or a new table, so you can’t drop the migration or execute the migration again, you can always call the migration methods from the console like this:

    Continue Reading Comments

  • 12 Aug 2009

    IE issues with new Element and class with Prototype

    The problem we have is that this code

    new Element('div', {'class':'klassName'})
    

    will work in firefox but in IE (tested on version 8) the className is never set, which was causing some problems with the elements styles.

    Continue Reading Comments

  • 12 Feb 2009

    Git Goodies

    A couple days ago I had to gather some information from a git repository, so I’m sharing this small scripts with you.

    Continue Reading Comments

  • 16 Dec 2008

    Will Paginate And Ajax

    I recently had to implement some ajax pagination for a site. After googling for a while I found a solution, but I couldn’t customize the pagination url’s or I had to specify the paginator to use (will paginate’s default or mine for ajax), so I came up with this solution which fulfils all my needs.

    Continue Reading Comments

  • 09 Dec 2008

    Will Paginate And Merb

    I read something about how to do it in this post by The merbist, albeit the information was not complete.
    So here are my instructions:

    Continue Reading Comments

Tags

  • jekyll
  • rails
  • activerecord
  • encodings
  • emacs
  • ajax
  • prototype
  • passenger
  • will_paginate
  • javascript
  • IE
  • emails
  • shell
  • git
  • migrations
  • ruby
  • archives
  • cucumber
  • merb
  • capistrano

Friend's Links

  • Qvitta
  • Least Significant Bit
  • Jorge Calas

Subscribe

  • RSS

Monthly Archives

  • April 2010 (1 posts)
  • March 2010 (3 posts)
  • February 2010 (1 posts)
  • May 2010 (1 posts)
  • August 2009 (1 posts)
  • February 2009 (1 posts)
  • December 2008 (2 posts)
© 2010 Jorge Dias