Installing Sphinx on OS X Leopard

•October 25, 2008 • Leave a Comment

Clinton Nixon has written an excelent post on the procedure. He was having problems trying to compile Sphinx on Leopard and found that 2 libraries were outdated on his OS X install: iconv and expat.

After installing both, he managed to get sphinx running.

Follow the instructions on his post to find out more.


Problems with jailbroken or unlocked iPhone

•September 12, 2008 • 4 Comments

Having a jailbroken iphone for a week now, I feel like I have some advice to give. 

First, it is quite easy to jailbreak it. Seriously, the guys at Winpwn have done a GREAT job. The tool itself could be a bit more polished on the corners, but it is fine. One suggestion i could give them is that not always we want to build a custom firmware for the iphone, since we may have already done that. You should be able to just select the pre-built ipsw, which would save you a lot of time.

Since we are on the subject, don’t try to put the phone in DFU mode outside winpwn. Winpwn does some stuff to the iphone on the background while it enters DFU mode, so it can accept your custom firmware. So, just doing it through iTunes won’t work.  I’ve tried it to avoid building a custom firmware and it just doesn’t work.

One important tip: As of today, September, 12th, WinPwn DOES NOT WORK WITH ITUNES 8!!! You can’t jailbreak or unlock your iphone (or ipod touch, but i don’t see any reason you would want to do that) with iTunes 8 installed. If you use Windows, uninstall it, AND REMEMBER TO UNINSTALL APPLE MOBILE SUPPORT TOO!! Then, reinstall iTunes 7.7. You can upgrade to 8 after you jailbreak.

Then there’s the DFU mode. If your iphone is stuck in DFU mode, here is how to exit: Just press Home and Power off buttons on the same time and keep pressing them until the phone resets. Now THIS one has cost me a night of sleep, and I’m giving you for free 😉 .

If you have trouble getting INTO the DFU mode, just remember this: When winpwn asks you if you want to be instructed on how to get INTO there, it will just explain to you. No action is being taken yet. Only after the first countdown will the big deal happen. The instructions are simple:

First, there will be a countdown so you can prepare yourself and put one finger next to the power button and one next to the home button. Then, it will tell you to press and HOLD the power button. Do that for 5 seconds (countdown). The next step will be to hold HOME button while still holding the power button. Do that for 10 seconds (countdown). The last one is to release the power button while still holding the home button. This one will take longer (about 30 seconds) and is the last countdown. Your iphone screen should turn white and then an image should show up telling you that the iphone is ready to receive custom firmwares. Now your iphone is just like you want. When you open iTunes and it tells you that your iphone is in recovery mode, click the recover button while holding left SHIFT. Now you can choose the firmware you just built and go get some coffee.

More lessons to come.

GMail: Howto skip attachment virus verification

•March 12, 2008 • 1 Comment

When I open old messages on gmail, I like to download attachmentes imediately. And by that I mean I can’t even wait 5 or 6 seconds while it’s being scanned for virus! What the hell! I sent the attachment myself, I know it has no virus! It’s now a malware or spyware, nothing! No antivirus will find anything there.

So, to skip antivirus verification on Gmail, like I do, just click FORWARD on the bottom of the message, right below the attachment list. The message to be forwarded will have links to download the attachments on the original message and, better, they don’t need to be scanned! 🙂


Converting Rails Model attributes character encoding

•February 13, 2008 • Leave a Comment

At work we have some legacy database on MySQL with ISO-8859-1 (latin1) encoding. I like to use UTF-8 on my apps, though, so I wanted to convert the data on the database to UTF8 before using on the app, and then back to ISO-8859-1 before saving on the database.

Fortunately, this nice guy, Tom Bak, on the ruby-forum, made a plugin to allow this type of conversion on the fly. It is not available for download here, since blocks zip files, but stop by the forum and download it. While you are there, remember to say thanks to Tom Bak!

Thanks, Tom, great job!

autotest keeps running continuosly even without changing any files?

•December 21, 2007 • Leave a Comment

So, your autotest also keeps running over and over when your Rails code fails? Well, I had this issue here and found that the problem was that, when the tests were run, Ferret updated the index. So, autotest believed that files where changed when they weren’t. Googling a bit I found this code that you should put on your ~/.autotest :

Autotest.add_hook :run do |at|
  at.exceptions = /^(?:\.\/)?(?:db|index|doc|log|public|script|tmp|filestore|vendor\/rails)|\.svn|(?:.*_flymake\.rb$)/

If it does not work, try running autotest with “-v” option, to see which files have changed on autotest concern, and include the relevant directory on the list above.

Hope this helps you! 🙂

Custom Humanize Column Names in Ruby on Rails

•December 10, 2007 • 3 Comments

Henrik, from The Pug Automatic, suggested a great way of having custom column names on the rails validation error messages, by rewriting the human_attribute_name of ActiveRecord. There’s an example on his blog (really worth a look and not only for this specific post) on how to do that. Beware that it uses a deprecated method of ActiveRecord, that may be removed in future versions of Rails (it is still there on Rails 2.0). The workaround is discussed there too on the comments: One could rewrite the humanize method of String – that would make changes global – or we can just ask politely for the core developers not to remove the method :).

Here is an example of how to do that, I used it on an application of mine. On this case, the collumns on the database are in english, which I prefer working with when programming , but the users can barely read Portuguese, so I need to translate to them:

class Ticket < ActiveRecord::Base
    :description => "Descrição",
    :category => "Categoria",
    :title => "Assunto"

  def self.human_attribute_name(attr)
    HUMANIZED_ATTRIBUTES(attr.to_sym) || super

Console input on Ruby: Masking passwords on the command line

•November 19, 2007 • 2 Comments

I like plain old console applications. They are fast (to program, compile and use) and, of course, add a cool factor, like people saying they have absolutely no idea of what you are doing!

Ruby, of course, can do console apps, but it’s not trivial to read user input. And what if you want the user to type a password? You would like, of course, to show them asteriks ‘*’ or nothing at all instead of the plain text being typed.

Well, “highline” gem covers this and much more. What about writing:

ask("Enter your password:  " ) { |q| q.echo = "x" }

And that’s all! That’s quite cool, man. It can even check if the answer matches some regex, or split it by commas, or anything you want
Take a look at it: