Archive

Author Archive

Scrolling on GNU Screen

June 9th, 2009 Dante Regis No comments

Interesting tip for those using GNU Screen. If you need to scroll up and see output already hidden from the screen, just press

Ctrl + A , [

This will get you into “copy mode”. I didn’t look around for how to actually copy, but you can scroll with the arrow keys.

To get out of copy mode, just press “[” again.

Categories: linux Tags:

Using ABNTEX on Max OS X

December 18th, 2008 Dante Regis No comments

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.

Categories: howto, mac Tags:

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

December 16th, 2008 Dante Regis 2 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!

Categories: programming, rails Tags:

[Cool Sites] A great meal planner with shopping list

November 27th, 2008 Dante Regis 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.

Categories: Uncategorized Tags:

Factory Girl and has_many / has_many :through associations

November 19th, 2008 Dante Regis 7 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.

Categories: programming, rails Tags:

Mobile Operator Idiocy

November 15th, 2008 Dante Regis No comments

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.

Categories: Uncategorized Tags:

Star rating system with jQuery

November 10th, 2008 Dante Regis No comments

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!

Categories: Uncategorized Tags:

bash_completion blissness on Mac OS X Leopard

October 27th, 2008 Dante Regis 3 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. ;)

Categories: Uncategorized Tags:

Installing Sphinx on OS X Leopard

October 25th, 2008 Dante Regis No comments

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.

http://www.viget.com/extend/installing-sphinx-on-os-x-leopard/

Categories: Uncategorized Tags:

Problems with jailbroken or unlocked iPhone

September 12th, 2008 Dante Regis No 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.

Categories: Uncategorized Tags: , ,