Git completion

Somethings that annoys me is the lack of autocompletion when using command line tools. Everything that makes you more productive should be done, even a shell alias that replaces two commands in one.

Git autocompletion should be add when installed, but it isn’t. (At least not for me.)
Okay

So how can I add autocompletion support to git?
You have to dig into git source code and go to /contrib/completion path.

The file, in my case (Mac OSX) and usually on Linux, is https://raw.github.com/git/git/master/contrib/completion/git-completion.bash

So what you have to do is:

and add the line source ~/git-completion.bash to your ~/.bashrc

Now you have to reopen your terminal, or run source ~/git-completion.bash

Almost all command line tools have this file, you just have to find the path and do almost the same steps.

How to Fix: JPEG support not available

This the most common problem when someone tries to install PIL library on *nix OS. It happens because you don’t have the libraries necessary to handle this kind of format, or you may have but it is not in the right place. This libraries issues are not a python’s fault. It is caused by the system, and you need to install this libraries like SaltyCrane Blog or Jj’s blog and link to the right location, but it is explained on this articles.

Their solutions solve 90% of the cases, but I need to use PIL in my virtualenv, so I have to make a link from /usr/lib/  to /home/my_user/my_env/lib . In my case, my libjpeg is named libjpeg.so.62 and I don’t have permission (it is not recommended to rename, because it can be used by other programs). So, I created a link in my virtualenv with other name  ln -s /usr/lib/libjpeg.so.62 /home/my_user/my_env/lib/libjpeg.so . Just worked on this way.

If you installed PIL with pip, you just have to uninstall and install again. But if you used easy_install I think you have to delete manually. Google it, because I think there are 2 steps to remove easy_install’ed packages.

Let me know if I wasn’t clear enough.

Thiago Gabriel.

 

Quick tip: UISearchBar more interactive

As we can see with successful apps, transitions, animations and minimalistic design are great approach on mobile development.

Here I’ll give some quick tips when you’re using UISearchBar on iOS.

If you’ve never used UISearchBar, it is better checking here. A VERY complete tutorial.

This post is about the following effects:

In our case, we already have UISearchBar in our .xib and UISearchBarDelegate as protocol on @interface (.h) file.

// MyOwnViewController.h

Don’t forget to set SearchBar’s Delegate on xib. This will link the “actions” of xib with you code.

And the most important is starting now… The .m implementation:

UISearchBarDelegate has many Delegate Methods. Here we’ll be using

searchBarTextDidBeginEditing:(UISearchBar *)searchBar  (that is called when the user touches SearchBar) and
searchBarTextDidEndEditing:(UISearchBar *)searchBar  (that is called when the user touches Cancel or Search)

The code is the following:

 

 

The names are self-explanatory. Here I’m just saying they exist and should be used to enhance the UX. But the first method just works if the Cancel button isn’t set visible.

[searchBar setShowsCancelButton] is available since iOS 3.0 and [navigationController setNavigationBarHidden] is available since iOS 2.0

How to install ruby-1.9.3-p194 on rvm

This is the message I received when I tried to install ruby 1.9.3-p194 on RVM:

Error running ‘tar xjf /Users/thiago/.rvm/archives/ruby-1.9.3-p194.tar.bz2 -C /Users/thiago/.rvm/tmp/rvm_src_66274 ‘, please read /Users/thiago/.rvm/log/ruby-1.9.3-p194/extract.log
There has been an error while trying to extract the source.
Halting the installation.
There has been an error fetching the ruby interpreter. Halting the installation.

On the log file extract.log was the message:
ruby-1.9.3-p194/ext/tk/sample/demos-jp/spin.rb: (Empty error message)
tar: Error exit delayed from previous errors.

I tried to execute  tar xjf /Users/thiago/.rvm/archives/ruby-1.9.3-p194.tar.bz2 -C /Users/thiago/.rvm/tmp/rvm_src_66274 ’ to be sure it wasn’t a RVM issue and it happened the same problem. It is a package issue.

I downloaded another package ruby-1.9.3-p194.tar.bz2 here /Users/MY_USER/.rvm/archives/ and executed the command to install  rvm install ruby-1.9.3-p194

Now every thing happened as expected.

How to fix this error message: “env: pythonr: No such file or directory”

I was trying to execute ./manage.py from django framework, and this message was always appearing on my MacOS Lion: “env: pythonr: No such file or directory”. I tried to change the first line from manage.py and the only temporary solution was to execute like this: python manage.py ... , but it became annoying, I started looking for the solution and I found this solution.

In a nutshell: it was caused because the break like system of the file is probably from windows (rn), and I need the UNIX system (n)

Fast solution: Open the file with VIM vim file.py , execute this command

:set fileformat=unix

and then save and quit with “:x”. I’m not a VIM hardcore expert, neither a VIM user (yet), so take it easy =]

The alternative solution is with dos2unix: I didn’t try this solution because I don’t have dos2unix, but is basically  dos2unix filename.py

Como identificar um vendedor pilantra no Mercado Livre

Muitos internaltas (nunca imaginei que usaria essa expressão) caem em golpes em sites de vendas. Geralmente é bom ter o cuidado de comprar em uma loja que algum amigo já comprou e teve sucesso. Mas e quando é no mercado livre onde qualquer um pode ser vendedor ?

Estava olhando umas televisões no ML para ver se tinha muita diferença das lojas online, e uma dessas ofertas me chamou muito a atenção.

Logo de cara parece uma oferta legítima. Já foram vendidas 25. O vendedor tem boa reputação.

Mas espera aí! Ninguém qualificou alguma negociação por esse produto ?

O vendedor já tem 6 pontos por compra e venda, 28 negociações e contando… E o melhor, a conta foi criada dia 02/04/2012, e dia 04/04/2012 ele ja tinha 6 pontos por compra e venda. Um prodígio.

Vamos descer um pouco e ver os comentários das qualificações. Era a primeira compra de todos, feitas no mesmo dia 04/04/2012. E espera aí… R$9,50????? 6 pessoas compraram essa TV por R$9,50? Ou os caras são muito sortudos, ou é um golpe. Ahhhh, um golpe. O golpe tem que ser feito muito rápido, senão alguma pessoa de verdade acaba clicando em “Comprar” e é claro que TV nenhuma foi vendida por R$9,50. O vendedor criou outras contas e “comprou” pra poder se qualificar de forma positiva. Vamos ver melhor essa TV de R$9,50.

Ele tentou disfarçar as vendas da TV de R$9,50 colocando as perguntas dos comentários, porque ficaria bem estranho fazer algumas vendas sem que ninguém entrasse em contato antes, não é? O engraçado é que pra essa TV ele não aceita retirada (no local, ao invés de enviar por sedex).

Mas na TV de R$950,00 ele aceita, mas só se houver o depósito antes.

Algumas horas depois só se vê reclamação. Mas agora muita gente já teve prejuízo, e algumas vão demorar para perceber. Quanto ao mercado livre, não existe nenhuma opção para denunciar esse tipo de conduta, então enviei uma mensagem pelo twitter, mas até agora não me responderam e nem tomaram nenhuma atitude.

Conclusão: Não existe oferta milagrosa. Muita gente comprou (e ainda está comprando) por impulso por ver um preço que é quase a metade do que é vendido nas lojas, e esquece do princípio básico da internet que é desconfiar de qualquer milagre.