<?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 &#187; ia</title>
	<atom:link href="http://silveiraneto.net/tag/ia/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description></description>
	<lastBuildDate>Fri, 09 Mar 2012 04:13:27 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>baia fria</title>
		<link>http://silveiraneto.net/2010/04/14/baia-fria/</link>
		<comments>http://silveiraneto.net/2010/04/14/baia-fria/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 01:11:59 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[arte]]></category>
		<category><![CDATA[Atlântico]]></category>
		<category><![CDATA[bastos]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[ia]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3322</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2010/04/14/baia-fria/" title="baia fria"></a>Aquele ali no canto é o Bastos.]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2010/04/14/baia-fria/" title="baia fria"></a><p style="text-align: center;"><img class="size-full wp-image-3321 aligncenter" title="frio" src="http://silveiraneto.net/wp-content/uploads/2010/04/frio.jpg" alt="" width="600" height="450" /></p>
<p>Aquele ali no canto é o <a href="http://bastost.com/">Bastos</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/04/14/baia-fria/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twitter Bot @rudaufc versão 1</title>
		<link>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/</link>
		<comments>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 19:54:18 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[Comida]]></category>
		<category><![CDATA[CRON]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[culinária]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[ia]]></category>
		<category><![CDATA[inteligência artificial]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Restaurante Universitário]]></category>
		<category><![CDATA[robô]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[SH]]></category>
		<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[ufc]]></category>
		<category><![CDATA[Universidade Federal do Ceará]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2927</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/" title="Twitter Bot @rudaufc versão 1"></a>Este aqui é um bot bem simples para Twitter. Diariamente, as nove da manhã ele posta qual vai ser o cardápio do RU (Restaurante Universitário) da UFC naquele dia. Assim, quando vai batendo a hora da fome, os alunos podem &#8230;<p class="read-more"><a href="http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/" title="Twitter Bot @rudaufc versão 1"></a><p><center><img src="http://silveiraneto.net/wp-content/uploads/2009/11/robo.jpg" alt="robô" title="robô" width="117" height="227" class="alignnone size-full wp-image-2933" /></center></p>
<p>Este aqui é um bot bem simples para Twitter.</p>
<p>Diariamente, as nove da manhã ele posta qual vai ser o cardápio do RU (<a href="http://www.ufc.br/portal/index.php?option=com_content&#038;task=view&#038;id=6842&#038;Itemid=87">Restaurante Universitário</a>) da <a href="http://www.ufc.br">UFC</a> naquele dia.</p>
<p>Assim, quando vai batendo a hora da fome, os alunos podem entrar no perfil <a href="http://www.twitter.com/rudaufc">@rudaufc</a> e olhar qual vai ser o prato do dia, ou quem está seguindo ele no Twitter pode ter a agradável surpresa de ver todo dia o que vai ser servido hoje.</p>
<p>Aqui está o código fonte do arquivo rudaufc.sh:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Twitter bot @rudaufc</span>
<span style="color: #007800;">login</span>=<span style="color: #ff0000;">&quot;rudaufc&quot;</span>
<span style="color: #007800;">senha</span>=<span style="color: #ff0000;">&quot;suasenhaaqui&quot;</span>
&nbsp;
<span style="color: #007800;">segunda</span>=<span style="color: #ff0000;">&quot;Picadinho com legumes ou bife na chapa. Salada de macarrão com cenoura. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">terca</span>=<span style="color: #ff0000;">&quot;Franco guisado ou coxas de frango ao forno . Salada de acelga, cenoura e passas. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">quarta</span>=<span style="color: #ff0000;">&quot;# Feijoada à moda RU ou bisteca . Salada de repolho branco, cenoura e abacaxi. Arroz. Feijão com abóbora e batata doce&quot;</span>
<span style="color: #007800;">quinta</span>=<span style="color: #ff0000;">&quot;Frango à passarinho ou frango chinês. Salada de Alface, Tomate e Cebola. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">sexta</span>=<span style="color: #ff0000;">&quot;# Isca ao molho ou maravilha de carne. Salada de acelga com cenoura. Arroz. Feijão com abóbora e batata doce.&quot;</span>
&nbsp;
<span style="color: #007800;">dia</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span><span style="color: #c20cb9; font-weight: bold;">w</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">log</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot;-$$.log&quot;</span>
<span style="color: #007800;">dir</span>=<span style="color: #ff0000;">&quot;/home/silveiraneto/rudaufc&quot;</span>
<span style="color: #007800;">msg</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dia</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #666666; font-style: italic;">#	&quot;0&quot;) msg=$domingo ;;</span>
	<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$segunda</span> <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$terca</span> <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$quarta</span> <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$quinta</span> <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$sexta</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #666666; font-style: italic;">#	&quot;6&quot;) msg=$sabado ;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
curl <span style="color: #660033;">-u</span> <span style="color: #007800;">$login</span>:<span style="color: #007800;">$senha</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">status</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$msg</span>&quot;</span> http:<span style="color: #000000; font-weight: bold;">//</span>twitter.com<span style="color: #000000; font-weight: bold;">/</span>statuses<span style="color: #000000; font-weight: bold;">/</span>update.xml <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$log</span></pre></div></div>

<p>A mágica toda está na capacidade do <a href="http://en.wikipedia.org/wiki/CURL">Curl</a> de acessar facilmente a <a href="http://apiwiki.twitter.com/">API do Twitter</a> para enviar mensagens.</p>
<p>Para que o script execute diariamente as nove da manhã ele está alocado em um servidor com a <a href="http://pt.wikipedia.org/wiki/Crontab">crontab</a> configurada da seguinte maneira:</p>
<pre>
0 5 * * *  . /caminho_para_onde_ele_esta/rudaufc.sh
</pre>
<p><small>ps: leve em conta que o servidor está em um fuso horário diferente do Brasil.</small></p>
<p>Nessa versão o prato de cada dia está hardcoded no script, o que não é o ideal e faz com que semanalmente eu tenha que atualizar o script inserindo os pratos da semana manualmente. Eu espero que a próxima versão seja capaz de descobrir esses pratos e se atualizar sem nenhuma interferência.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Gerando permutações</title>
		<link>http://silveiraneto.net/2008/01/19/gerando-permutacoes/</link>
		<comments>http://silveiraneto.net/2008/01/19/gerando-permutacoes/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 14:53:15 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[ia]]></category>
		<category><![CDATA[inteligência artificial]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[listas]]></category>
		<category><![CDATA[Prolog]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Wladimir]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/01/19/gerando-permutacoes/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/01/19/gerando-permutacoes/" title="Gerando permutações"></a>Muitas vezes para resolver uma única instância de um problema é mais rápido ataca-lo com força bruta do que encontrar um algoritmo geral com uma boa ordem de complexidade. Permutações são de grande utilidade nesse tipo de abordagem. Permutações em &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/01/19/gerando-permutacoes/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/01/19/gerando-permutacoes/" title="Gerando permutações"></a><p>Muitas vezes para resolver uma única instância de um problema é mais rápido ataca-lo com força bruta do que encontrar um algoritmo geral com uma boa ordem de complexidade. Permutações são de grande utilidade nesse tipo de abordagem.</p>
<p><span style="font-weight: bold">Permutações em Prolog:</span></p>
<p>Esse é um código em Prolog que o <a href="http://lia.ufc.br/~wladimir/">Wladimir Araujo</a> passou na cadeira de <a href="/tag/inteligencia-aritficial/">IA</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="prolog" style="font-family:monospace;">select<span style="color: #009900;">&#40;</span>X<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>X<span style="color: #339933;">|</span>Xs<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> Xs<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
select<span style="color: #009900;">&#40;</span>X<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>Y<span style="color: #339933;">|</span>Ys<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>Y<span style="color: #339933;">|</span>Zs<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:-</span> select<span style="color: #009900;">&#40;</span>X<span style="color: #339933;">,</span> Ys<span style="color: #339933;">,</span> Zs<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
permutar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
permutar<span style="color: #009900;">&#40;</span>Xs<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>Z<span style="color: #339933;">|</span>Zs<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:-</span>
    select<span style="color: #009900;">&#40;</span>Z<span style="color: #339933;">,</span> Xs<span style="color: #339933;">,</span> Ys<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    permutar<span style="color: #009900;">&#40;</span>Ys<span style="color: #339933;">,</span> Zs<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></div></div>

<p><span style="font-weight: bold">Permutações em Python:</span><br />
Esse é um código de um certo Michael Davies que eu tirei <a href="http://snippets.dzone.com/posts/show/753">daqui</a>. Ele gera uma lista com todas as permutações de uma lista. Muito bonitinho. :)</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> all_perms<span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span>=<span style="color: #ff4500;">1</span>:
        <span style="color: #ff7700;font-weight:bold;">yield</span> <span style="color: #008000;">str</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> perm <span style="color: #ff7700;font-weight:bold;">in</span> all_perms<span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>perm<span style="color: black;">&#41;</span>+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">yield</span> perm<span style="color: black;">&#91;</span>:i<span style="color: black;">&#93;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>:<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + perm<span style="color: black;">&#91;</span>i:<span style="color: black;">&#93;</span></pre></div></div>

<p>Um exemplo de uso:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> all_perms<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span>,<span style="color: #483d8b;">'b'</span>,<span style="color: #483d8b;">'c'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> p
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span>, <span style="color: #483d8b;">'b'</span>, <span style="color: #483d8b;">'c'</span><span style="color: black;">&#93;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'b'</span>, <span style="color: #483d8b;">'a'</span>, <span style="color: #483d8b;">'c'</span><span style="color: black;">&#93;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'b'</span>, <span style="color: #483d8b;">'c'</span>, <span style="color: #483d8b;">'a'</span><span style="color: black;">&#93;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span>, <span style="color: #483d8b;">'c'</span>, <span style="color: #483d8b;">'b'</span><span style="color: black;">&#93;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'c'</span>, <span style="color: #483d8b;">'a'</span>, <span style="color: #483d8b;">'b'</span><span style="color: black;">&#93;</span>
<span style="color: black;">&#91;</span><span style="color: #483d8b;">'c'</span>, <span style="color: #483d8b;">'b'</span>, <span style="color: #483d8b;">'a'</span><span style="color: black;">&#93;</span></pre></div></div>

<p><strong>Outras implementações:</strong><br />
Em outras linguagens o código para gerar permutações geralmente é muito grande, então eu preferi deixar alguns links.</p>
<ul>
<li><a href="http://www.bearcave.com/random_hacks/permute.html">Permutações em C</a></li>
<li><a href="http://www.merriampark.com/perm.htm">Permutações em Java</a></li>
<li><a href="http://snippets.dzone.com/posts/show/3332">Permutações em Ruby</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/01/19/gerando-permutacoes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

