Stepping stone in Mephisto 0.8

When I set up this blog some weeks ago (and in my opinion, it is still under construction), I tried to use themes like Stepping Stone, Ocadia, and others, but almost every theme I tried to upload any of them, I got error messages, like this one: Invalid theme uploaded: [ThemeError] No such file or directory - templates.

I tried to solve this by myself, so I started hacking. First, I opened the Stepping Stone and the Red Sky at Night zip files, the latter imported successfully into Mephisto. And then I saw that the Stepping Stone zip had a ’stepping_stone’ directory and nothing else in the root, while the Red Sky at Night had all the structure right from the beginning.

After I generated a new zip with a similar structure, the second try gave me this message: Invalid theme uploaded: [ThemeError] No such file or directory - javascripts. Now, looking again, the zip file didn’t have a javascripts directory in it. Directory created, nothing, inside, third try to upload: Theme imported Successfully!

I looked at the Red Sky at Night zip, and its javascripts directory was empty too, so I don’t think it will be much of a problem. If anyone somewhere reads this, and would like to have a working copy of Stepping Stone and Ocadia themes, post a comment and I will upload it.

P.S.: Thanks for the creators of the themes.

Unicode support in rails. Quickly.

  1. Create the database with Unicode support. In MySQL, for example, it would be something like this:
    create table onon_development character set utf8;
  2. Add a meta tag to your template. It can be like this one:<meta http-equiv="content-type" content="text/html; charset="UTF-8"></meta>
  3. Everytime you wanna do Unicode-friendly operations, use the method chars of the String class, instead of using it directly.
  4. Done!

Linus on Git

I just finished watching to this video. Everybody is talking about Git, and this video explained a lot of things to me, so I recommend it.

Just one comment: Besides Linus being a genius, I can\’t tell the difference whether he is making fun or just having no respect of other people.

Premature optimization is the root of all evil

Last weekend I was playing with Ruby in spoj when I had a doubt about optimizing a piece of code or not. I decided not optimizing. And then, after I got an AC, I uploaded the optimized version.

The results.

All I did was cache the answers, but the input for the tests maybe doesn’t repeat very often, if it does. This makes the “optimized” version almost 18% slower.

So, the lesson learned is: Premature optimization is the root of all evil.

Tales from the real world: LDAP

Having lunch at Nagoya:

me: I’m hearing about LDAP a lot these days, does someone know what it is?
colleague: It’s an authentication protocol.
me: Wich protocol does it run over?
colleague: Most of the time, Linux. Sometimes in Unix too.

Setting up Mongrel in a Ubuntu system

I was trying to install Mongrel in my Ubuntu system, but unsuccessfully. After typing sudo gem install mongrel, the following error popped up:

lucas@lucas-laptop:~$ sudo gem install mongrel
Building native extensions.  This could take a while...
ERROR:  Error installing mongrel:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install mongrel
extconf.rb:1:in `require\': no such file to load -- mkmf (LoadError)
from extconf.rb:1

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/ext/fastthread/gem_make.out
</macro:code>

After searching a little for the answer, it seems like I had a broken ruby installation. I needed the ruby-dev package installed, because mongrel uses C/C++ in somes places for better performance.

This site explains everything in details and how you can solve it:

And now the quick solution for the problem:

sudo apt-get install build-essential
sudo apt-get install ruby1.8-dev
sudo gem install mongrel

Thank you all at soakedandsoaped.com for this tip!