Archive for the ‘Programming’ Category

WSGI: a resposta para a questão definitiva sobre Python, a web e tudo mais?

Wednesday, April 23rd, 2008

Pessoal, publiquei minha palestra do FISL 9.0 no SlideShare:
(more...)

strace on Mac OS X Leopard

Monday, February 25th, 2008

One of the most important tools for sysadmins and programmers working in the Linux/BSD environment is called strace. As it took me some time to find out where is "strace for Mac", I thought it would be worth documenting here...

Making a long story short: in Tiger it was called ktrace, in Leopard it's called dtrace, but it's simpler if you just call dtruss.

Here are some examples directly from the dtruss man page:

dtruss df -h     # run and examine the "df -h" command

dtruss -p 1871   # examine PID 1871

dtruss -n tar    # examine all processes called "tar"

For a more "real-life" example, please see this article: Why DTrace Makes Leopard a Must-Have Upgrade -- you'll even learn how to prevent Time Machine from consuming all your CPU.

UPDATE: Just after posting this I discovered that:

1. There's a really cool GUI for DTrace called Instruments. After playing with it for just a few minutes I was able to detect that it was psyco that was causing Python 2.4 to segfault when running web2ldap. Now back to a little more tinkering to discover why...

2. Leopard/DTrace provides one command that I always wanted: iotop, to show which processes are responsible for the disk I/O (more dtrace commands here). Now to the question: is there a Linux version? The answer is: yes, and it's written in Python (and requires a kernel >= 2.6.20).

Python: A Linguagem do Ano

Tuesday, January 8th, 2008

Esse post é apenas pra comemorar a escolha de Python como "A" Linguagem de 2007 no índice TIOBE, com o maior crescimento entre todas (2%) e finalmente ultrapassando Perl.

P.S.: Java continua em primeiro, mas como o índice conta apenas linhas de código escritas, vai ser difícil ganhar essa posição — e, diga-se de passagem, ainda bem!

Universidade Direta

Wednesday, September 19th, 2007

Estava eu aqui fazendo os exercícios de um dos melhores livros de programação de todos os tempos (leia-se: Kerninghan & Ritchie), quando lembrei do último post de Oliveira.

Na auto-denominada condição de membro fundador da Universidade Direta (porque na Universidade Direta é assim, você se autonomeia-se a si mesmo com o título que preferir), me senti na obrigação de comentar algo aqui no blog*.

Oliveira esqueceu de citar uma parte muito importante: o diploma - aliás, certificado - da nossa Universidade. Sendo uma Universidade extremamente moderna e atualizada, e ao mesmo tempo preocupada com tudo o que concerne à preservação do meio ambiente, a Universidade Direta declara que jamais imprimirá *um* certificado sequer, garantindo a preservação de milhares e milhares de árvores do nosso lindo e brega planetinha, e aproveitando para protestar contra essa história toda de diploma, certificado e papeladas em geral.

Em segunda instância, gostáriamos de frisar novamente que achamos todo e qualquer certificado totalmente desnecessário. Maaaaas... Para os mais inseguros, podemos enviar por e-mail um PDF simples, com a seguinte frase escrita em letras grandes e amigáveis: "Eu Sou Foda!" Assim, aquele que precisar de algo ao qual recorrer num eventual momento de incerteza com seu próprio ser ou simplesmente por querer provar para alguém que sabe, mesmo sem saber, terá sua tábua de salvação disponível imediatemente ao alcance do mouse (ou do locate, ou do Spotlight, conforme a qualidade e o grau de nerdice do cidadão).

Aqui vão as cadeiras que estou pagando só no setor de Línguas Estrangeiras e Estranhas (nenhuma coincidência que as duas primeiras línguas também sejam as preferidas de Alemão :-)):

Ah, também tem a (falta de) disciplina "Gringo's Bar", mas essa só 'while $ > 0'... ;)

E jamais esqueça o velho conselho Jedi (by Mestre CLX):

Não deixe a faculdade atrapalhar seus estudos.

* Esse post também vai ao ar como resposta e em agradecimento à tirinha-homenagem que Karlisson lançou há alguns dias: Nota dez e meio. Obrigado, Nerdson! :D

Studying SQLAlchemy

Saturday, August 18th, 2007

Well, I could be stealing, I could be killing, I could even be programming... But today, inspired by this enlightening SQLAlchemy diagram and some great docs, I decided to just... draw.
... 

(more...)

Vim Tips

Tuesday, July 25th, 2006

I decided to write down some Vim commands I use frequently and others that I've been discovering recently, check it out.

I've created it as a separate page, as I intend to keep updating it regularly.

Now reading… #1

Friday, July 21st, 2006

One of my passions definitely is reading, and you can expect many posts about this subject here. After trying to read too many books in parallel, I've found a formula which works very well for me: one technical book (almost always from the Diginet ever-growing library) and one non-technical/fiction book (these ones I have to buy :)).

Now I'm reading The Pragmatic Programmer, which is one of the best books on programming I've ever read. It is almost like a complete programming course in a compact form (actually learning a programming language is left as an exercise to the reader ;)). The subjects vary: from things that you usually learn on college (like BNF grammars and big-O-notation) to things that you will normally won't learn on college (like being pragmatic).

In the way, you will find many good practices and advice, like the importance of using a source code control system, admitting there's no such thing as perfect software, and using "tracer bullets" (ie. iterative design, instead of a big pile of requirements that doesn't solve any of the client's problems). I could go on and on, but you really have to read the book to see everything.

Another interesting thing about the book is that almost all chapters start with some quote related to the subject, but one in particular doesn't. It's called "Temporal Coupling". It is basically about analyzing your code to see if all the assumptions some piece of code makes about what was executed before it are really necessary, so that the program can run smoothly in concurrent environments later. Then, soon after I read this chapter, my copy of The Ultimate Hitchhiker's Guide arrived, and when I opened it in the last book ("Mostly Harmless") I found this quote:

Anything that happens, happens.
Anything that, in happening, causes something else to happen, causes something else to happen.
Anything that, in happening, causes itself to happen again, happens again.
It doesn't necessarily do it in chronological order, though.

Well, I thought this would be a great opening for that chapter and e-mailed the authors with this suggestion. Andrew Hunt answered my e-mail and apparently he liked the idea ("Most excellent!" were his words). Let's see if it comes in the next edition... :D