Saturday, May 31, 2008

Basic and digest HTTP authentication when using Google App Engine URL fetch API

When using Google AppEngine's URL fetch API it's not obvious how to do a basic digest HTTP/S authentication, so here's a self-explainable code snippet for doing so:

import base64

username = "johnsmith"
pw = "cookie1234"

encoded = base64.b64encode(username + ':' + pw)
authstr = "Basic "+encoded

url = "https://api.del.icio.us/rename?new=bla1&old=bla2"

mheaders = {'Authorization':authstr,}

result = urlfetch.fetch(url,headers = mheaders)

Other useful HTTP request headers you could add to the mheaders dict above are:

"User-Agent" : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14",
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive": "300",
"Connection": "keep-alive",
"Accept": "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
"Cache-Control": "max-age=0",
both of these were very handy when implementing the del.icio.us tag cleaner.

Thursday, May 29, 2008

Reference list of interview questions for a software engineer position

These are all non-technical and have been collected from several websites. They're also ordered by what I would try first.

  • So, tell me a little about yourself.
  • What are you passionate about?
  • What relevant experience do you have?
  • Do you have any questions to ask me?
  • Questions on the projects listed on the Resume.
  • Tell me what you know about this company.
  • Have you done anything to further your experience?
  • How do you keep yourself updated on the latest tools, techniques, technologies etc?
  • What steps would you go through when given a though problem to solve involving a completely new technology?
  • What motivates you to do a good job?
  • Talk about the last 2 technical books you read.
  • If given a new programming problem, what is your first step in producing code?
  • Tell me a suggestion you have made that was implemented.
  • What are the really important aspects of software development?
  • Is there anyone you just could not work with?
  • If your previous co-workers were here, what would they say about you?
  • Has anything ever irritated you about people you’ve worked with?
  • What is your ideal team size?
  • How would you deal with changes being made a week or so before the ship date?
  • Why do you want to work at X Company?
  • How would you deal with a bug that no one wants to fix?
  • So, explain why I should hire you.
  • If you had enough money to retire right now, would you?
  • What’s your greatest strength?
  • What’s your biggest weakness?
  • What have you learned from mistakes on the job?
  • What do you like about your current job? What don't you like?
  • How would you rate your current management?
  • How are you when you’re working under pressure?
  • Are you willing to put the interests of X Company ahead of your own?
  • Let’s talk about salary. What are you looking for?
  • Why are you looking (or why did you leave you last job)?
Some additional tips.

mdworker process 100% CPU usage on Apple OS X

I've noticed more than once a very high cpu usage on OSX and it turns out that the culprit was the mdworker process from Spotlight (text indexing service).

There seems to be several causes to this. In my case the reason was that it was trying to index the contents of a zipped file currently being downloaded by Transmission (bittorrent client). The same could probably happen for any other zip file or directory full of files being downloaded by another tool.

The solution was to add my download directory to Spotlight's ignore list: System Preferences -> Spotlight -> Privacy tab -> Drag your typical download location to the list.

Restarting Finder and Spotlight after that is a good idea.

Monday, May 12, 2008

Trânsito do Rio de Janeiro e São Paulo no celular em tempo real

Aponte o browser de seu celular para http://transito.isnotworking.com/ e acompanhe o trânsito em tempo real nos principais corredores do RJ e SP.

Atualizado a cada 3 minutos com informações do MapLink e CET-RIO.

Friday, May 09, 2008

Quick note to Mr. Gladwell

Your articles and books are very interesting, but please avoid making them this long.

Tuesday, May 06, 2008

Amazon Kindle e-book reader return over investment

I've fallen in love with the Amazon Kindle e-book reader the first time I heard of it, several months ago. I believe it hadn't even been available for ordering yet. But alas, I live in Brazil so I wouldn't enjoy one of its best features: downloading books wirelessly and instantly without paying for bandwidth or messing with wireless providers. All of that at any time of day or night and at any place in the country (no WiFi required).

Today I just came across a great Kindle review and noticed that the author did mention how cheap Kindle e-books can be compared to dead-tree versions of it, but he didn't do a back-of-the-envelope return over investment calculation for it:

A brand new Kindle costs you around $410. Hardcover book releases cost on average $27 (shipping included), which you can get on Kindle for $10. So for each new book release you buy on Kindle you save $17. But wait, you're not going to buy only new releases. Let's say you buy a few backcatalog items, which sell at Kindle for $6. So let's mix those two together and say you save on average $19 for every book you buy.

That means Kindle pays itself after 22 books. Which for many book lovers means 2 years or less of usage. If you consider all the added value of not carrying heavy books around and keeping many books on its internal memory available for you to reference or skim at your convenience, then that return comes even earlier!

Side-note 1: Actually, maybe this is exactly the math Mr Bezos wants us to do: he doesn't really want us to buy Kindles, but to buy these 22 e-books to make Kindle pay itself. Profit margins for paper books are probably ridiculously low (compared to e-books) so he wants to get away from it as soon as possible.

Side-note 2: If, like me, you're outside the USA, here are some reasons why it may take some time for it to become more widely available:

It uses Sprint to download books, which is only available in the US. This is one of the main features of the Kindle over all other ebook readers, and it is truly a wonderful feature.

Another answer is that many of the publishers whose works they are offering do not permit Kindle to sell them abroad, as they often have contracts with vendors in those other countries who do not want to see competition coming from the US.

A third answer is payment. It is true that you can use a credit card issued in another country for payment of a US bill, but it imposes some overhead on their operations, which being brand new most likely doesn't have full support for such things yet, including the problems of currency conversions.

Sunday, May 04, 2008

Histórico dos fundos de investimento do Unibanco

Compilei em uma única página web um histórico em forma de scatter plots dos principais fundos de investimento do Unibanco. Ajuda a saber o que os outros clientes andam fazendo em relação a esses fundos.

Segue o link:
Histórico dos fundos de investimento do Unibanco
(atualizado diariamente)

A maioria dos indicadores é obvio, mas apenas para detalhar: Captação = Captação geral de recursos - Resgates

Os dados são obtidos das paginas disponibilizadas publicamente pelo próprio Unibanco.

Sempre quis parar para aprender a investir direito (day-trading, mercado de opções, etc) mas nunca priorizei. Principal motivo é que não tenho paciência de acompanhar minuto a minuto e nem seria viável fazer isso no meu trabalho.

Alguns dos fundos historiados:

UNIBANCO INFRA-ESTRUTURA
UNIBANCO ENERGIA
UNIBANCO FLEX MULTIMERCADO
UNIBANCO STRATEGY
UNICLASS MULTI
UNIBANCO ADVANTAGE DI
UNIBANCO VALE DO RIO DOCE
UNIBANCO RENDA FIXA PLUS
UNIBANCO TELECOM
UNIBANCO CLASSE MUNDIAL
UNICLASS DI
UNIBANCO TIMING
UNIBANCO SUSTENTABILIDADE
UNIBANCO PETROBRAS
UNIBANCO BLUE
UNIBANCO RENDA FIXA
UNIBANCO LIQUIDEZ DI

Saturday, May 03, 2008

Money saving tip for book lovers

Try this quick estimate on the number of days needed for you to finish all your unread books: Multiply the number of books left by 300 (average number of pages in a book) and divide by the average number of pages you read daily (figure that out by dividing your weekly reading capacity by 7). Normally you'd need to divide by 365 again to get the years-till-next-buy estimate. You'll find out that you'll take a lot longer to hit the "Proceed to checkout" button again.