Using ABNTEX on Max OS X

•December 18, 2008 • 1 Comment

If you ever want to use ABNT rules on Latex documents, ABNTex is a great resource. ABNT for those who don’t know, is Brazil’s national “ISO”. 

My experience using it on a Mac was very straightforward. First, I download and installed MacTeX. It is a huge download, more than 1GB. It may work if you get the smaller versions, but I never tested.

Then, I was as simple as downloading ABNTex and unpacking it on ~/Library/texmf/tex/latex . This directory structure may not exist, so you may need to create the folders after Library. 

Done. It worked fine for my monograph latex files.

Rails Functional Testing of mime types other than HTML (XML, JSON etc)

•December 16, 2008 • 15 Comments

I noticed something interesting these days. Even though most Rails websites boasts the benefits of Test Driven Development, most examples they give us don’t test the whole app functionality. 

How come? Well, REST was the word of the day, it is now deep inside our brains, right? But have you ever seen an example test of the XML output of Rails? Surely not. Every guide, tutorial and example shows only how to test for the default output, which is HTML. 

So what? That ought to be easy, right? Just add :format after the get, post, put or delete function and you will be fine, you must think. Well, I have been working on a project and had to test if the Atom Feed would work ok. I must say it was one of the most frustrating tests I have ever written. 

Turns out that, even though you can do something like this:


formatted_posts_url(:format => :atom)

you CAN’T do that on testes:

get :index, :format => :atom

 

You know why? Because, even though you CAN use symbols (:atom) on your code, you CAN’T use on tests FOR THE FORMAT. Let’s rephrase it: You can use symbols on tests when specifying the action, the parameters and everything else BUT NOT THE FORMAT of the request. So the code above will give you a mysterious HTTP 406 Error Code.

So, to prevent you from loosing a full day where you felt productive, like I did, the following code will work:

get :index, :format => "atom"

Best!

[Cool Sites] A great meal planner with shopping list

•November 27, 2008 • 1 Comment

Starting the series of cool sites you should visit, there’s a meal planner with shopping list building and recipes from great chefs, all with reviews and nice pictures called Tasty Planner. Very cool, worth a visit.

Factory Girl and has_many / has_many :through associations

•November 19, 2008 • 15 Comments

If you want to create has_many and has_many through associations in factory_girl as I once did, you will need to put it inside square brackets:

Factory.define :user do |user|
  user.name "My Name"
  user.groups {|groups| [groups.association(:group)]}
end

This will ensure that user.groups is not overriden by a single Group object, but by an array with a Group inside.

Mobile Operator Idiocy

•November 15, 2008 • Leave a Comment

We have a mobile carrier here in Brazil called Vivo. If I’m not wrong (and I may be) it belongs to Telefonica, the spanish company. It has a website completely incompatible with any browser other than Internet Exploder. And, believe it or not, it is a official iPhone seller on this country (you can’t run IE on a iPhone). So a client of the company, Mr. Fernando Caprio, asked them about Firefox and other browsers compatibility with the site. Their answer:

Dear Mr. Fernando, good morning!

Regarding your e-mail, we inform you that our website is built on a MSDE database and all programing is done in files with a HTML extension. The software Firefox is incompatible with this extension.

Ain’t this neat? Firefox doesn’t support HTML! We should all move ASAP to Windows and IE6! After all, which other browser would enable us to read this blazing new technology? HTML Extension! Beware: it may take over the web!

I hope you guys have a glimpse of the customer care mobile carriers have here in our country.

Star rating system with jQuery

•November 10, 2008 • Leave a Comment

Pretty self-explaining. Very, very good. Give it a try:

http://php.scripts.psu.edu/rja171/widgets/rating.php

It makes star-rating as simple as one line!

Don’t forget to thank the author!

bash_completion blissness on Mac OS X Leopard

•October 27, 2008 • 4 Comments

Debian-like bash_completion! I missed you! But no more!

To install it just do:

sudo port install bash-completion
echo "source /opt/local/etc/bash_completion" >> ~/.bash_profile
chmod +x ~/.bash_profile

EDIT: You must have MacPorts installed to run the first command. http://www.macports.org  Tip from KA, on the commets.

If you don’t know yet what is bash_completion, it is  a feature for shells to autocomplete commands. Example: You are on a git repository. You type git fe and press TAB, bash_completion will fill “fetch” for you. If you have branches, they are autocompleted too. GNU Tar only shows files compatible with the filters you selected. So if you tar xvzf my-softw TAB, it will complete only filenames that are on tar.gz or tgz format and that starts with the string you already typed.

It is heaven again. ;)

 
Follow

Get every new post delivered to your Inbox.