<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Silveira Neto</title>
	<atom:link href="http://silveiraneto.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description>come with me, on the way I&#039;ll explain.</description>
	<lastBuildDate>Tue, 09 Feb 2010 06:49:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>1º Café com Tapioca de 2010</title>
		<link>http://silveiraneto.net/2010/02/09/1%c2%ba-cafe-com-tapioca-de-2010/</link>
		<comments>http://silveiraneto.net/2010/02/09/1%c2%ba-cafe-com-tapioca-de-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 06:49:11 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Atlântico]]></category>
		<category><![CDATA[Caelum]]></category>
		<category><![CDATA[café com tapioca]]></category>
		<category><![CDATA[CCT]]></category>
		<category><![CDATA[CEJUG]]></category>
		<category><![CDATA[José Donizetti]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3157</guid>
		<description><![CDATA[Essa quarta-feira acontece o primeiro CEJUG Café com Tapioca de 2010.
O foco serão duas palestras ministradas pelo José Donizetti da Caelum, sendo a primeira sobre VRaptor 3 e a segunda sobre Test Driven Development.
O evento será realizado no auditório do Atlântico.
Maiores informações no site do evento.
]]></description>
			<content:encoded><![CDATA[<p>Essa quarta-feira acontece o primeiro <a title="Café com Tapioca" href="http://www.cejug.org/eventos/cafe-com-tapioca/">CEJUG Café com Tapioca</a> de 2010.</p>
<p>O foco serão duas palestras ministradas pelo <a title="Twitter dele" href="http://twitter.com/josedonizetti">José Donizetti</a> da <a title="Caelum" href="http://www.caelum.com.br/">Caelum</a>, sendo a primeira sobre <a title="VRaptor" href="http://vraptor.caelum.com.br/">VRaptor 3</a> e a segunda sobre <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a>.</p>
<p>O evento será realizado no auditório do <a title="Atlântico" href="http://www.atlantico.com.br/">Atlântico</a>.</p>
<p><a title="CCT" href="http://www.cejug.org/eventos/cafe-com-tapioca/cct-de-fevereiro-com-vraptor-e-tdd/">Maiores informações no site do evento</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/02/09/1%c2%ba-cafe-com-tapioca-de-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perigeu Lunar de 2010</title>
		<link>http://silveiraneto.net/2010/01/30/perigeu-lunar-2010/</link>
		<comments>http://silveiraneto.net/2010/01/30/perigeu-lunar-2010/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 06:07:06 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[astronomia]]></category>
		<category><![CDATA[Canon]]></category>
		<category><![CDATA[Canon Powershot G10]]></category>
		<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3148</guid>
		<description><![CDATA[
Hoje devido a Lua ter chegado ao perigeu da órbita com a Terra coincidentemente na noite de lua cheia, tivemos uma lua 14% maior e uma luminosidade 30% maior.
Eu já havia tentado tirar fotos da lua diversas vezes, sempre frustradas. Hoje consegui fotos com uma qualidade mínima, onde se pode distinguir alguns das principais montanhas, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-3149 aligncenter" title="perigeu lunar" src="http://silveiraneto.net/wp-content/uploads/2010/01/perigeu_lunar.jpg" alt="" width="600" height="450" /></p>
<p>Hoje devido a Lua ter chegado ao perigeu da órbita com a Terra coincidentemente na noite de lua cheia, tivemos uma lua <a title="referencia" href="http://www.tudonahora.com/noticia/brasil/2010/01/29/83101/hoje-e-noite-de-lua-cheia-a-mais-brilhante-de-2010">14% maior e uma luminosidade 30% maior</a>.</p>
<p>Eu já havia tentado tirar fotos da lua diversas vezes, sempre frustradas. Hoje consegui fotos com uma qualidade mínima, onde se pode distinguir alguns das principais montanhas, crateras e mares da Lua. São fotos a partir de algumas tentativas da janela do meu quarto, sem nenhum equipamento especial além da própria câmera, <em>Canon PowerShot G10</em>.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm5.static.flickr.com/4029/4314085461_d6baf493b8.jpg" alt="lua" /></p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm5.static.flickr.com/4054/4314821336_baf318b687.jpg" alt="lua" /></p>
<p>Essa é uma das fotos, passando por um aumento do contraste no Gimp:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2750/4314822032_0e253f4ea7.jpg" alt="lua" /></p>
<p>O restante das fotos estão <a title="Álbum Lua" href="http://www.flickr.com/photos/silveiraneto/sets/72157623185046169/">neste álbum no Flickr</a>.</p>
<p>Eu achei um <a title="mapa lunar" href="http://www.anos-luz.pro.br/lua.htm">bom mapa lunar</a> e destaquei sobre a foto alguns lugares que foram possíveis distinguir na foto.</p>
<p style="text-align: center;"><img class="size-full wp-image-3151 aligncenter" title="lua destaques" src="http://silveiraneto.net/wp-content/uploads/2010/01/lua_destaques.png" alt="" width="500" height="300" /></p>
<p>Algumas dicas para tirar uma boa foto da lua <em>Canon PowerShot G10</em>:</p>
<ul>
<li>Manter ela bem parada, num apoio ou tripé.</li>
<li>Sem flash.</li>
<li>Colocar ela no modo manual.</li>
<li>Ajustar de exposição do obturador para 1/200 ou menos.</li>
<li>Colocar o Zoom ótico em 5X.</li>
<li>Colocar a resolução da foto no máximo, 14.7 megapixels.</li>
<li>Ajustar a focagem manual para o mais distante possível.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/30/perigeu-lunar-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Contando Algarismos Em Um Intervalo</title>
		<link>http://silveiraneto.net/2010/01/29/contando-algarismos-em-um-intervalo/</link>
		<comments>http://silveiraneto.net/2010/01/29/contando-algarismos-em-um-intervalo/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 23:21:59 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[compreensão de lista]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[programação funcional]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3142</guid>
		<description><![CDATA[Quantos zeros tem entre um e mil?
É mais fácil responder perguntas desse tipo escrevendo pequenos programas usando o suporte a programação funcional e compreensão de lista que algumas linguagens como Python oferecem.
Para contar os zeros de um número, transformamos ele em uma string e contamos quantas substrings &#8216;0&#8242; ele contém. Por exemplo o 800:


str&#40;800&#41;.count&#40;'0'&#41;
# 2


Para [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Quantos zeros tem entre um e mil?</strong></p>
<p>É mais fácil responder perguntas desse tipo escrevendo pequenos programas usando o suporte a <a href="http://pt.wikipedia.org/wiki/Programa%C3%A7%C3%A3o_funcional">programação funcional</a> e <a href="http://pt.wikipedia.org/wiki/List_comprehension">compreensão de lista</a> que algumas linguagens como Python oferecem.</p>
<p>Para contar os zeros de um número, transformamos ele em uma string e contamos quantas substrings &#8216;0&#8242; ele contém. Por exemplo o 800:</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">800</span><span style="color: black;">&#41;</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># 2</span></pre>
</div>
</div>
<p>Para gerar uma lista ordenada com os elementos do intervalo entre um e mil, inclusive os valores um e mil:</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">1001</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># [1, 2, ... , 999, 1000]</span></pre>
</div>
</div>
<p>Pegamos esse intervalo  e geramos uma outra lista onde cada elemento é a contagem dos zeros do número do intervalo.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">1001</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
<span style="color: #808080; font-style: italic;"># [0, 0, ... , 0, 3]</span></pre>
</div>
</div>
<p>Por exemplo, 1 não tem nenhum zero. Dois também não. 999 também não. 1000 tem três.</p>
<p>Somamos todos os elementos da lista temos o número de algarismos zero entre um e mil.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #008000;">sum</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">1001</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre>
</div>
</div>
<p>E a resposta é 192.</p>
<p>O mesmo poderia ser obtido contando quantos zeros há na representação de string da lista do intervalo.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">1001</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">count</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'0'</span><span style="color: black;">&#41;</span></pre>
</div>
</div>
<p>Mas essa abordagem apesar de menor é menos geral se você quiser modifica-la para contagens mais complexas.</p>
<p>A diferença do range pro xrange é que o range constrói a lista real do intervalo real em memória e o xrange uma representação da lista do intervalo. Em geral mas não sempre, a performasse do xrange é melhor.</p>
<p>De toda forma, em ambos os casos, o resultado é o mesmo.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/29/contando-algarismos-em-um-intervalo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>pés no paraíso</title>
		<link>http://silveiraneto.net/2010/01/28/pes-no-paraiso/</link>
		<comments>http://silveiraneto.net/2010/01/28/pes-no-paraiso/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 07:26:14 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[Canon Powershot G10]]></category>
		<category><![CDATA[CC-BY-SA]]></category>
		<category><![CDATA[janeiro]]></category>
		<category><![CDATA[Jericoacoara]]></category>
		<category><![CDATA[reveillon]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3136</guid>
		<description><![CDATA[
Gostei dessa minha foto (tamanho original). Ficou com uma boa composição, dois planos, no plano da frente meus pés deitados na rede, o que dá uma sensação de imersão para o observador para se sentir no meu ponto de vista. No plano de fundo vários elementos, cada um contando uma história diferente, um cara jogando [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-3139 aligncenter" title="silveira pés paraíso jericoacoara" src="http://silveiraneto.net/wp-content/uploads/2010/01/silveira_pes_paraiso_jericoacoara.jpg" alt="" width="640" height="480" /></p>
<p>Gostei dessa minha foto (<a href="http://farm3.static.flickr.com/2742/4245299168_8e10e75e1c_o.jpg">tamanho original</a>). Ficou com uma boa composição, dois planos, no plano da frente meus pés deitados na rede, o que dá uma sensação de imersão para o observador para se sentir no meu ponto de vista. No plano de fundo vários elementos, cada um contando uma história diferente, um cara jogando frescobol, uma jangada velejando, alguém remando num caiaque, uma menina nadando e um menino no raso fazendo uma onda. No meio disso a gradiente entre a água cristalina e o fundo azul. Não dá pra ver mas a rede fica armada entre dois coqueiros dentro da água.</p>
<p>Fotografia feita numa <em>Canon Powershot G10</em>, na Lagoa do Paraíso, perto de Jericoacoara, Ceará. Livre sobs os termos da <a title="Creative Commons" href="http://creativecommons.org/licenses/by-sa/3.0/deed.pt">Creative Commons Atribuição-Compartilhamento pela mesma Licença</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/28/pes-no-paraiso/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Miojo Script</title>
		<link>http://silveiraneto.net/2010/01/28/miojo-script/</link>
		<comments>http://silveiraneto.net/2010/01/28/miojo-script/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 05:37:29 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[libnotify]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[miojo]]></category>
		<category><![CDATA[notify]]></category>
		<category><![CDATA[notify-send]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3133</guid>
		<description><![CDATA[O pre-requisito é o notify-send, um utilitário de linha de comando do libnotify. No Ubuntu:
sudo aptitude install libnotify-bin
E aqui o script em si:
sleep 5m; notify-send "aviso" "tirar o miojo do fogo"
Pronto, depois de cinco minutos isso vai aparecer:

]]></description>
			<content:encoded><![CDATA[<p>O pre-requisito é o notify-send, um utilitário de linha de comando do libnotify. No Ubuntu:</p>
<p><code>sudo aptitude install libnotify-bin</code></p>
<p>E aqui o script em si:</p>
<p><code>sleep 5m; notify-send "aviso" "tirar o miojo do fogo"</code></p>
<p>Pronto, depois de cinco minutos isso vai aparecer:</p>
<p style="text-align: center;"><img class="size-full wp-image-3134 aligncenter" title="notify" src="http://silveiraneto.net/wp-content/uploads/2010/01/notify.png" alt="" width="427" height="258" /></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/28/miojo-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easily Sortable Date and Time Representation</title>
		<link>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/</link>
		<comments>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 01:55:26 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[ISO 8601]]></category>
		<category><![CDATA[Jochen Voss]]></category>
		<category><![CDATA[Markus Kuhn]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[representation]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3130</guid>
		<description><![CDATA[I was looking for a date and time representation useful for registering stock quotes in a simple plain file.
I found that the standard ISO 8601 is just the answer for this, it&#8217;s called &#8220;Data elements and interchange formats — Information interchange — Representation of dates and times&#8221;. Here is a example:
2010-01-20 22:14:38
There&#8217;s this good article from [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a date and time representation useful for registering stock quotes in a simple plain file.</p>
<p>I found that the standard <a title="Wikipedia on ISO 8601" href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> is just the answer for this, it&#8217;s called &#8220;Data elements and interchange formats — Information interchange — Representation of dates and times&#8221;. Here is a example:</p>
<blockquote><p>2010-01-20 22:14:38</p></blockquote>
<p>There&#8217;s this good article from <a title="A summary of the international standard date and time notation" href="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">Markus Kuhn, &#8220;A summary of the international standard date and time notation&#8221;</a>. <strong>This notation allow us to using simple lexicographical order the events.</strong></p>
<p>Some examples of how to do this in Python (thanks for the <a href="http://seehuhn.de/pages/pdate">Jochen Voss article &#8220;Date and Time Representation in Python&#8221;</a>) The first for displaying the current date and time:</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> strftime
<span style="color: #ff7700;font-weight:bold;">print</span> strftime<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y-%m-%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># 2010-01-20 22:34:22</span></pre>
</div>
</div>
<p>Another possibility is using strftime from datetime object.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
now = <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> now.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y-%m-%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># 2010-01-20 22:12:31</span></pre>
</div>
</div>
<p>Is that. Using this notation in the begging of each line is easy to sort them in any language or using the unix <a href="http://en.wikipedia.org/wiki/Sort_%28Unix%29">sort</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/20/easily-sortable-date-and-time-representation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extração de Dados e Fundos de Investimento do Banco do Brasil</title>
		<link>http://silveiraneto.net/2010/01/11/extracao-de-dados-e-fundos-de-investimento-do-banco-do-brasil/</link>
		<comments>http://silveiraneto.net/2010/01/11/extracao-de-dados-e-fundos-de-investimento-do-banco-do-brasil/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 00:02:42 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[ações]]></category>
		<category><![CDATA[aplicações]]></category>
		<category><![CDATA[Banco do Brasil]]></category>
		<category><![CDATA[bolsa de valores]]></category>
		<category><![CDATA[CRON]]></category>
		<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[fundo de investimento]]></category>
		<category><![CDATA[fundos]]></category>
		<category><![CDATA[fundos de investimento]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Mineração de Dados]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[screen scraping]]></category>
		<category><![CDATA[Web Harvest]]></category>
		<category><![CDATA[web scraping]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3112</guid>
		<description><![CDATA[
Eu não achei onde coletar os dados diários de rentabilidade dos fundos de investimento do Banco do Brasil em formato bem estruturado.
Num mundo ideal as coisas seriam assim, você faria uma requisição numa url como esta:
http://bb.com.br/apps/rentabilidade?fundo=Siderurgia&#38;saida=xml
E ele cuspiria um XML com as informações da rentabilidade diária desse fundo, isso se eu não especificasse através de [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-3118 aligncenter" title="unicornio" src="http://silveiraneto.net/wp-content/uploads/2010/01/unicornio1.jpg" alt="" width="400" height="440" /></p>
<p>Eu não achei onde coletar os dados diários de rentabilidade dos <a title="Fundos de Investimento do Banco do Brasil" href="http://www21.bb.com.br/portalbb/rentabilidade/index.jsp?tipo=01">fundos de investimento do Banco do Brasil</a> em formato bem estruturado.</p>
<p>Num mundo ideal as coisas seriam assim, você faria uma requisição numa url como esta:</p>
<blockquote><p>http://bb.com.br/apps/rentabilidade?fundo=Siderurgia&amp;saida=xml</p></blockquote>
<p>E ele cuspiria um XML com as informações da rentabilidade diária desse fundo, isso se eu não especificasse através de outro parâmetro qual a data ou intervalo de datas desejado ou outro tipo de dados para saída como YAML ou JSON. Mas por enquanto não temos isso, nem unicórnios, então temos de fazer as coisas do jeito mais difícil, que é puxando os <a title="tabela dos fundos de investimento" href="http://www21.bb.com.br/portalbb/rentabilidade/index.jsp?tipo=01">dados feitos para humanos</a> e escrevendo um programa pra extrair à força os dados que desejamos e quem sabe usar eles para algum uso relacionado a <a href="http://pt.wikipedia.org/wiki/Minera%C3%A7%C3%A3o_de_dados">mineração de dados</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-3113 aligncenter" title="bb fundos de investimento" src="http://silveiraneto.net/wp-content/uploads/2010/01/bb_fundos_de_investimento.png" alt="" width="494" height="318" /></p>
<p>A primeira abordagem que eu tentei foi a de criar <a href="http://silveiraneto.net/2009/12/25/python-fast-xml-parsing/">um desses pequenos parsers XML que eu já mostrei como fazer antes</a>, mas o código fonte desse documento se mostrou muito incompatível com o XML que o parser estava disposto a trabalhar. A solução alternativa foi tratar o documento linha a linha.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># abrimos o documento referenciado pela url</span>
url = <span style="color: #483d8b;">'http://www21.bb.com.br/portalbb/rentabilidade/index.jsp?tipo=01'</span>
documento = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># fundo de investimento que me interessa</span>
fundo = <span style="color: #483d8b;">'small caps'</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># estados</span>
INICIO = 0
ACHOU_FUNDO = <span style="color: #ff4500;">1</span>
FIM = <span style="color: #ff4500;">2</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># estado inicial</span>
estado = INICIO
&nbsp;
<span style="color: #808080; font-style: italic;"># vamos analisar linha a linha do fluxo do documento</span>
<span style="color: #ff7700;font-weight:bold;">for</span> linha <span style="color: #ff7700;font-weight:bold;">in</span> documento:
	<span style="color: #808080; font-style: italic;"># simplificamos, tudo pra minusculas</span>
	linha = linha.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># no inicio, procura uma linha que tenha o fundo</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> estado == INICIO <span style="color: #ff7700;font-weight:bold;">and</span> linha.<span style="color: black;">find</span><span style="color: black;">&#40;</span>fundo<span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span>:
		estado = ACHOU_FUNDO
&nbsp;
	<span style="color: #808080; font-style: italic;"># depois, procuramos o proximo inicio de tabela html.</span>
	<span style="color: #808080; font-style: italic;"># dessa linha, pegamos o que vem depois do primeiro &amp;gt;</span>
	<span style="color: #808080; font-style: italic;"># e entao o que vem antes do primeiro &amp;lt;</span>
	<span style="color: #808080; font-style: italic;"># e trocamos a virgula por ponto.</span>
	<span style="color: #ff7700;font-weight:bold;">elif</span> estado == ACHOU_FUNDO <span style="color: #ff7700;font-weight:bold;">and</span> linha.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'
'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'&amp;lt;'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span>,<span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span>
		estado = FIM</pre>
</div>
</div>
<p>E para usar:</p>
<blockquote><p>$ python rendimento_small_caps.py<br />
0.881</p></blockquote>
<p>Geralmente estamos mais interessados em saber o valor da cota daquele fundo, daí podemos calcular o rendimento total sabendo a cota que compramos a ação inicialmente. Nesse caso o dado está na 11º coluna.</p>
<div class="wp_syntax">
<div class="code">
<pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># abrimos o documento referenciado pela url</span>
url = <span style="color: #483d8b;">'http://www21.bb.com.br/portalbb/rentabilidade/index.jsp?tipo=01'</span>
documento = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># fundo de investimento que me interessa</span>
fundo = <span style="color: #483d8b;">'small caps'</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># estados</span>
INICIO = 0
ACHOU_FUNDO = <span style="color: #ff4500;">1</span>
FIM = <span style="color: #ff4500;">2</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># estado inicial</span>
estado = INICIO
coluna = 0
&nbsp;
<span style="color: #808080; font-style: italic;"># vamos analisar linha a linha do fluxo do documento</span>
<span style="color: #ff7700;font-weight:bold;">for</span> linha <span style="color: #ff7700;font-weight:bold;">in</span> documento:
	<span style="color: #808080; font-style: italic;"># simplificamos, tudo pra minusculas</span>
	linha = linha.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;"># no inicio, procura uma linha que tenha o fundo</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> estado == INICIO <span style="color: #ff7700;font-weight:bold;">and</span> linha.<span style="color: black;">find</span><span style="color: black;">&#40;</span>fundo<span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span>:
		estado = ACHOU_FUNDO
&nbsp;
	<span style="color: #808080; font-style: italic;"># para cada coluna, conta a coluna, mas nao faz nada</span>
	<span style="color: #ff7700;font-weight:bold;">elif</span> estado == ACHOU_FUNDO <span style="color: #ff7700;font-weight:bold;">and</span> linha.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'
&amp;lt;= 11:
		coluna += 1
&nbsp;
	# quando chegar na coluna onze, retira o conteudo entre os sinais &amp;gt; e &amp;lt;
	# e troca virgula por ponto, transforma em float e joga na tela
	if estado==ACHOU_FUNDO and coluna == 11:
		print float(linha.split('</span><span style="color: #66cc66;">&amp;</span>gt;<span style="color: #483d8b;">')[1].split('</span><span style="color: #66cc66;">&amp;</span>lt;<span style="color: #483d8b;">')[0].replace('</span>,<span style="color: #483d8b;">','</span>.<span style="color: #483d8b;">'))
		estado = FIM</span></pre>
</div>
</div>
<blockquote><p>$ python cota_small_caps.py<br />
6.156906634</p></blockquote>
<p>Essa é uma abordagem que eu não gosto nem recomendo porque ela é muito frágil e está extremamente acoplada a formatação de dados para humanos. Esta formatação está interessada no saída gráfica que o usuário vai obter e não em facilitar a extração (não humana) desses dados. Isso torna a solução muito frágil:</p>
<ul>
<li>Se mudarem os nomes internos dos elementos, a solução pode falhar.</li>
<li>Se mudarem a formatação da tabela, a solução pode falhar.</li>
<li>Se mudarem a disposição interna dos elementos html, a solução pode falhar.</li>
<li>Se mudarem a url do documento, a solução vai falhar.</li>
<li>Se o documento não puder mais ser tratado linha a linha, a solução vai falhar feio.</li>
</ul>
<p>É provável que quando você estiver lendo isso ela nem funcione mais do jeito que está descrita aqui.</p>
<p>Por outro lado, a solução funciona e nesse caso é o que me interessa. Quando ela quebrar, se ainda for do meu interesse eu posso rapidamente conserta-la e os dados já coletados no passado continuam válidos.</p>
<p>Isso somado  a uma programa como o Cron pode se tornar uma ferramenta realmente poderosa.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/11/extracao-de-dados-e-fundos-de-investimento-do-banco-do-brasil/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bolo e Jujubas</title>
		<link>http://silveiraneto.net/2010/01/09/bolo-e-jujubas/</link>
		<comments>http://silveiraneto.net/2010/01/09/bolo-e-jujubas/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 03:18:39 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3108</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm5.static.flickr.com/4039/4252486917_13eba7ca46.jpg" alt="Aniversário do Ramiro" /></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/09/bolo-e-jujubas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Font List</title>
		<link>http://silveiraneto.net/2010/01/05/java-font-list/</link>
		<comments>http://silveiraneto.net/2010/01/05/java-font-list/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 21:10:00 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[AWT]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Larabie]]></category>
		<category><![CDATA[Larabie Fonts]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3102</guid>
		<description><![CDATA[Here&#8217;s a program that lists fonts available in your JVM. You can also set the environment variable JAVA_FONTS to specify the font directory.


import java.awt.GraphicsEnvironment;
&#160;
public class ListFonts &#123;
	public static void main&#40;String args&#91;&#93;&#41;&#123;
		GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment&#40;&#41;;
		for&#40;String font:e.getAvailableFontFamilyNames&#40;&#41;&#41;&#123;
			System.out.println&#40;font&#41;;
		&#125;
	&#125;
&#125;


By using pipes you can count how many fonts you have:
java ListFonts&#124;wc -l
On my Ubuntu machine here I got 556 because [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a program that lists fonts available in your JVM. You can also set the environment variable <a title="IBM JVM Enviromment variables" href="http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/appendixes/env_var/env_jvm.html">JAVA_FONTS</a> to specify the font directory.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.GraphicsEnvironment</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ListFonts <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">GraphicsEnvironment</span> e <span style="color: #339933;">=</span> <span style="color: #003399;">GraphicsEnvironment</span>.<span style="color: #006633;">getLocalGraphicsEnvironment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> font<span style="color: #339933;">:</span>e.<span style="color: #006633;">getAvailableFontFamilyNames</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>font<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>By using pipes you can count how many fonts you have:</p>
<blockquote><p>java ListFonts|wc -l</p></blockquote>
<p>On my Ubuntu machine here I got 556 because I use those excellent, free and indispensable <a href="http://www.larabiefonts.com/">Larabie Fonts</a>.</p>
<p>For looking up for a font with &#8220;sans&#8221; in its name, using a case insensitive grep:</p>
<blockquote><p>java ListFonts|grep -i &#8220;sans&#8221;</p></blockquote>
<p>I get a list like this:</p>
<blockquote><p>
DejaVu Sans<br />
DejaVu Sans Condensed<br />
DejaVu Sans Light<br />
DejaVu Sans Mono<br />
FreeSans
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/01/05/java-font-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gimp Small Miracles</title>
		<link>http://silveiraneto.net/2009/12/28/gimp-small-miracles/</link>
		<comments>http://silveiraneto.net/2009/12/28/gimp-small-miracles/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 14:52:18 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[GNU Image Manipulation Program]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[photo retouch]]></category>
		<category><![CDATA[photograph]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[picture]]></category>
		<category><![CDATA[portrait]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3090</guid>
		<description><![CDATA[Some times a good picture is ruined by a little detail or someone that shouldn&#8217;t be there. If you are willing to trade a complete portraying of the reality for a better photo, here are some tips for Gimp. Use them wisely.
Here is the original photo of two friends playing a game, and an unwanted [...]]]></description>
			<content:encoded><![CDATA[<p>Some times a good picture is ruined by a little detail or someone that shouldn&#8217;t be there. If you are willing to trade a complete portraying of the reality for a better photo, here are some tips for <a title="Gnu Image Manipulator Program" href="http://www.gimp.org/">Gimp</a>. Use them wisely.</p>
<p>Here is the original photo of two friends playing a game, and an unwanted stranger raising his arms right in the middle of the picture.</p>
<p style="text-align: center;"><img class="size-full wp-image-3091 aligncenter" title="original photo with unwanted person" src="http://silveiraneto.net/wp-content/uploads/2009/12/photo_original.jpg" alt="" width="600" height="450" /></p>
<p>Here is the most useful tools from the <a title="Gimp Tool Box Documentation" href="http://docs.gimp.org/2.6/en/gimp-concepts-usage.html#gimp-concepts-toolbox">Gimp tool box</a> and how to use them:</p>
<p style="text-align: center;"><img class="size-full wp-image-3093 aligncenter" title="gimp clone tool" src="http://silveiraneto.net/wp-content/uploads/2009/12/gimp_clone_tool.png" alt="" width="340" height="150" /></p>
<p><a title="Gimp Clone Tool Documentation" href="http://docs.gimp.org/2.6/en/gimp-tool-clone.html">Clone tool</a>. The most common tool to create remove unwanted things. Usually you use them by getting a background theme and cloning it to cover what you want to hide. The best way to use this tool is when you have a not uniform background, like a wall or grass, where a small pattern repeats.</p>
<p><img class="size-full wp-image-3092 aligncenter" title="gimp lasso tool" src="http://silveiraneto.net/wp-content/uploads/2009/12/gimp_lasso_tool.png" alt="" width="336" height="138" /></p>
<p><a title="Gimp Lasso Documentation" href="http://docs.gimp.org/2.6/en/gimp-tool-free-select.html">Free Selection (Lasso)</a>. When the clone tool is not enough because patterns are too big or too shapeless, the best is use the lasso tool. Get a good piece of the background or another object and them copy and paste over what you want to hide. Maybe what you need to select and copy is not in the same image you are working, you can get information from another picture and use in your main picture. This was what I had to do in this example.</p>
<p>Sometimes you have to change the brightness and contrast to match the pasted selection with the main picture.</p>
<p style="text-align: center;"><img class="aligncenter" title="gimp perpective tool" src="http://silveiraneto.net/wp-content/uploads/2009/12/gimp_perpective_tool.png" alt="" width="340" height="142" /></p>
<p><a title="Gimp Perpective Tool Documentation" href="http://docs.gimp.org/2.6/en/gimp-tool-perspective.html">Perpective tool</a>. This is a very powerful tool because allows you to use a selection from another image but was taken from another point of view and you need to correct it&#8217;s perspective. By doing that you can retrieve a lot of information that your picture don&#8217;t have by taking them from another pictures. You can also use to fit a pattern.</p>
<p style="text-align: center;"><img class="size-full wp-image-3095 aligncenter" title="gimp smudge tool" src="http://silveiraneto.net/wp-content/uploads/2009/12/gimp_smudge_tool.png" alt="" width="340" height="140" /></p>
<p><a title="Gimp Smudge Documentation" href="http://docs.gimp.org/2.6/en/gimp-tool-smudge.html">Smudge tool</a>. When you are handling uniform colors and straight shapes this is a good tool. You can smudge a pasted selection in the boundaries to it match with the main picture. You can also use it to stretch or squeeze shapes, but they have to be very color uniform to it work well. For more complex shapes you can use the <a title="Gimp IWarp Filter Documentation" href="http://docs.gimp.org/en/plug-in-iwarp.html">IWarp filter</a>.</p>
<p>So, I guess this is the most important about them. Another time I can do some videos showing how to use them better. In this work you can spot several little mistakes because I was very clumsy and in hurry, but the result is satisfactory.</p>
<p><span style="font-size: x-big;"><strong>Before</strong></span></p>
<p style="text-align: center;"><img class="aligncenter" title="original photo with unwanted person" src="http://silveiraneto.net/wp-content/uploads/2009/12/photo_original.jpg" alt="" width="600" height="450" /></p>
<p><span style="font-size: x-big;"><strong>After</strong></span></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-3098" title="photo after" src="http://silveiraneto.net/wp-content/uploads/2009/12/photo_after1.jpg" alt="" width="600" height="450" /></p>
<p>Next time ask people to get out of the way when taking a picture.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/12/28/gimp-small-miracles/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
