<?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>Blog do Tiago</title>
	<atom:link href="http://blog.tiagomadeira.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tiagomadeira.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 May 2012 06:23:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Mostrando uma agenda do Google Calendar no seu site</title>
		<link>http://blog.tiagomadeira.com/mostrando-uma-agenda-do-google-calendar-no-seu-site/</link>
		<comments>http://blog.tiagomadeira.com/mostrando-uma-agenda-do-google-calendar-no-seu-site/#comments</comments>
		<pubDate>Sun, 06 May 2012 06:14:07 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Software Livre]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1155</guid>
		<description><![CDATA[Escrito em PHP. Pode ser usado no tema do seu WordPress. Requer CURL. Faz cache do calendário para não ter que baixá-lo sempre que alguém entra no seu site. Desenvolvido para um site que vai sair nos próximos dias. Use, modifique e distribua como quiser. (Não me responsabilizo por qualquer problema. Fiz pra um caso <a href='http://blog.tiagomadeira.com/mostrando-uma-agenda-do-google-calendar-no-seu-site/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Escrito em PHP. Pode ser usado no tema do seu WordPress. Requer CURL. Faz cache do calendário para não ter que baixá-lo sempre que alguém entra no seu site. Desenvolvido para um site que vai sair nos próximos dias. Use, modifique e distribua como quiser. (Não me responsabilizo por qualquer problema. Fiz pra um caso específico. A checagem de erros é meio porca.)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'America/Sao_Paulo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$events</span> <span style="color: #339933;">=</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;cached_calendar.xml&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$last</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$last</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// Mude 3600 para o tempo (em segundos) que você quiser que o cache expire</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$last</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// Substitua o e-mail do calendário do Google CodeJam pelo e-mail do seu calendário (público)</span>
    <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://www.google.com/calendar/feeds/google.com_jqv7qt9iifsaj94cuknckrabd8%40group.calendar.google.com/public/full&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_FILE<span style="color: #339933;">,</span> <span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;feed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;entry&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$entries</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$children</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$children</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$child</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tagName</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;gd:when&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;startTime&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$st</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;startTime&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$time_to_sort</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$st</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> date_i18n<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, d/M&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H:i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$st</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;endTime&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$et</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;endTime&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H:i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$et</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$day</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$events</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">&quot;time_to_sort&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$time_to_sort</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">&quot;day&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$day</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">&quot;start&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$start</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">&quot;end&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$end</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">&quot;title&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$title</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> cmp<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_to_sort&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_to_sort&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">strcmp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> ? <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">usort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$events</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;cmp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$events</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$lastDay</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$events</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'day'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$events</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$events</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'start'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$events</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'end'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastDay</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h3 class=<span style="color: #000099; font-weight: bold;">\&quot;</span>day<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;span&gt;<span style="color: #006699; font-weight: bold;">$day</span>&lt;/span&gt;&lt;/h3&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;li&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Você pode modificar aqui para mostrar o horário de término ($end).</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>time<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">{$start}</span>&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;strong&gt;<span style="color: #006699; font-weight: bold;">{$title}</span>&lt;/strong&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;/li&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$lastDay</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;Nenhum evento cadastrado.&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/mostrando-uma-agenda-do-google-calendar-no-seu-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump email addresses from files</title>
		<link>http://blog.tiagomadeira.com/dump-email-addresses-from-files/</link>
		<comments>http://blog.tiagomadeira.com/dump-email-addresses-from-files/#comments</comments>
		<pubDate>Thu, 03 May 2012 06:58:38 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Futilidades]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1144</guid>
		<description><![CDATA[Suppose you have a lot of .doc, .docx, .xls, .xlsx, .gz, .bz2, .pdf and text in general (.csv, .txt etc.) files and want to dump all the (unique) email addresses from them. How would you do it? Here is a simple solution I&#8217;ve just implemented (and probably didn&#8217;t test enough, so tell me if you <a href='http://blog.tiagomadeira.com/dump-email-addresses-from-files/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a lot of .doc, .docx, .xls, .xlsx, .gz, .bz2, .pdf and text in general (.csv, .txt etc.) files and want to dump all the (unique) email addresses from them. How would you do it? Here is a simple solution I&#8217;ve just implemented (and probably didn&#8217;t test enough, so tell me if you find any bug):</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: #007800;">tmp</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">tempfile</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">ext</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${1#*.}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>A-Z<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>a-z<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$ext</span> <span style="color: #000000; font-weight: bold;">in</span>
            docx <span style="color: #000000; font-weight: bold;">|</span> xlsx<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #666666; font-style: italic;"># requires: http://blog.kiddaland.net/2009/07/antiword-for-office-2007/</span>
                cat_open_xml <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            doc<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #666666; font-style: italic;"># requires: antiword</span>
                antiword <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            xls<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #666666; font-style: italic;"># requires: catdoc</span>
                xls2csv <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            gz<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gunzip</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            bz2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bunzip2</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #c20cb9; font-weight: bold;">zip</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            pdf<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #666666; font-style: italic;"># requires: xpdf-utils</span>
                <span style="color: #007800;">t</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">tempfile</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                pdftotext <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #007800;">$t</span>
                <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$t</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$t</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #007800;">text</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #660033;">-b</span> <span style="color: #660033;">--mime-type</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/\/.*//'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;z<span style="color: #007800;">$text</span>&quot;</span> = <span style="color: #ff0000;">&quot;ztext&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$tmp</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">esac</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #7a0874; font-weight: bold;">shift</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$tmp</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-o</span> <span style="color: #660033;">-E</span> <span style="color: #ff0000;">'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b'</span> \
         <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>A-Z<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>a-z<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-u</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$tmp</span></pre></div></div>

<p>(the email regexp is explained here: <a href="http://www.regular-expressions.info/email.html">regular-expressions.info/email.html</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/dump-email-addresses-from-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Como baixar fotos dos álbuns da UOL</title>
		<link>http://blog.tiagomadeira.com/como-baixar-fotos-dos-albuns-da-uol/</link>
		<comments>http://blog.tiagomadeira.com/como-baixar-fotos-dos-albuns-da-uol/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 05:17:38 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Futilidades]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1122</guid>
		<description><![CDATA[Se você não é nerd, não tem tempo, não tem coração e não tem curiosidade, recomendo que ignore todo o texto e leia somente o item 3. Por causa da forma como os álbuns de fotos do UOL são feitas, copiar suas fotos é uma tarefa difícil para a maioria dos usuários. Não acho que <a href='http://blog.tiagomadeira.com/como-baixar-fotos-dos-albuns-da-uol/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><em>Se você não é nerd, não tem tempo, não tem coração e não tem curiosidade, recomendo que ignore todo o texto e leia somente o item 3.</em></p>
<p>Por causa da forma como os álbuns de fotos do UOL são feitas, copiar suas fotos é uma tarefa difícil para a maioria dos usuários. Não acho que a UOL faça assim de propósito, mas por uma questão de usabilidade mesmo: há dois botões enormes em cima das fotos para você avançar para a próxima foto ou voltar para a anterior, e é por causa deles que você não consegue ver o &#8220;Copiar endereço da imagem&#8221; quando clica com a tecla direita na área da imagem (porque você não está realmente clicando na imagem, mas num botão transparente).</p>
<p>No entanto, há várias formas de copiar fotos dos álbuns da UOL. Neste post apresento algumas. Para testar, você pode tentar aplicar essas ideias <a href="http://educacao.uol.com.br/album/2012/04/04/protesto-de-professores-da-rede-municipal-de-sao-paulo.htm">neste álbum</a>.</p>
<h3>0. Soluções toscas</h3>
<p>Como eu disse no início, os webmasters do UOL aparentemente não fazem os álbuns se comportarem assim de propósito, mas por causa de botões gigantes. A maneira mais fácil de copiar uma foto de um álbum do UOL é clicar bem na coluna exatamente no meio dela, evitando as duas setas. Você pode passar o mouse devagar pelo meio da foto até que o seu cursor deixe de ser uma mãozinha e seja uma seta. Pra saber se você deve ir pra esquerda ou pra direita é só ir na direção da seta que você não está vendo.</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/a.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/a-650x453.png" alt="" title="a" width="650" height="453" class="aligncenter size-large wp-image-1123" /></a></p>
<p>Outra solução também tosca é simplesmente tirar um screenshot da tela em que você está (apertar a tecla PrintScreen na maioria dos computadores deve funcionar) e recortar a imagem. Eu imagino que essa seja a solução mais usada, mas pessoalmente acho ela terrível.</p>
<p>Não pare de ler! Prometo que as próximas soluções vão ser mais legais.</p>
<h3>1. Somente para o Firefox: desativar estilos</h3>
<p>Desativar o CSS da página é uma forma fácil de acabar com todo seu leiaute e dessa forma copiar a imagem sem se preocupar com perfumarias. Você provavelmente pode fazer isso em qualquer navegador usando plugins (e nos navegadores que não suportam CSS é até mais fácil: você nem precisa fazer nada!) e no Firefox em particular há um botão no menu (Exibir &raquo; Estilos &raquo; Sem estilos).</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/b.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/b-650x365.png" alt="" title="b" width="650" height="365" class="aligncenter size-large wp-image-1124" /></a></p>
<h3>2. JavaScript na barra de endereço</h3>
<p>Em geral, você pode escrever um script na barra de endereço para executá-lo na página em que você está. Há um tempo atrás todos os navegadores aceitavam isso, mas aparentemente muitos têm desativado esse recurso por questões de segurança, inclusive o Firefox. De qualquer maneira, se seu navegador suportar, você pode simplesmente digitar:
<pre>javascript:document.getElementById("setaEsq").style.width=document.getElementById("setaDir").style.width="50px";void(0);</pre>
<p> na barra de endereço quando estiver na página do álbum do qual quer baixar fotos.</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/c.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/c-650x240.png" alt="" title="c" width="650" height="240" class="aligncenter size-large wp-image-1125" /></a></p>
<p>Isso vai reduzir o tamanho dos botões, fazendo com que a área clicável seja bem maior.</p>
<p><small><strong>Exercício para quem souber ou quiser aprender JavaScript:</strong> Escreva um script que abra a foto numa nova aba em vez de simplesmente deixá-la clicável. Transforme-o num bookmarlet (veja o próximo item).</small></p>
<h3>3. Bookmarlet</h3>
<p>A solução anterior nos incentiva a criar um botão que execute esse script para não termos que decorá-lo nem copiá-lo sempre. Eis aqui esse botão para você: <a href='javascript:document.getElementById("setaEsq").style.width=document.getElementById("setaDir").style.width="50px";void(0);'>Aumentar área clicável das fotos dos álbuns da UOL</a>. Clique com a tecla direita nesse link e adicione-o aos seus favoritos. Quando você estiver num álbum, clique nesse favorito e a imagem vai se tornar magicamente clicável :)</p>
<h3>4. Firefox e GreaseMonkey</h3>
<p>Se você usa Firefox e tem instalada a extensão GreaseMonkey, instale o seguinte user script (que executa o mesmo código que colei no item 2) e sempre que você abrir um álbum as fotos serão clicáveis: <a href='http://blog.tiagomadeira.com/wp-content/uploads/2012/04/fotosuol.user.js'>Download do userscript</a></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// ==UserScript==</span>
<span style="color: #006600; font-style: italic;">// @name Copiador de fotos UOL</span>
<span style="color: #006600; font-style: italic;">// @description Torna mais fácil copiar fotos de álbuns da UOL</span>
<span style="color: #006600; font-style: italic;">// @author  Tiago Madeira &lt;contato@tiagomadeira.com&gt;</span>
<span style="color: #006600; font-style: italic;">// @include http*://*.uol.com.br/album/*</span>
<span style="color: #006600; font-style: italic;">// @version 0.9</span>
<span style="color: #006600; font-style: italic;">// ==/UserScript==</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;setaEsq&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;50px&quot;</span><span style="color: #339933;">;</span>
        document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;setaDir&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;50px&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Mas estou lendo este post em 2020 e o UOL mudou! Ou eu quero baixar fotos do site X, não do UOL!</h3>
<p>A solução 1 (desativar estilos) funciona em 99% dos casos. Não quer ver sites sem estilo? Continue lendo.</p>
<p><strong>5.</strong> Se você não quiser utilizá-la e se você estiver usando Firefox, pode clicar no ícone ao lado do endereço do site na barra de endereço e aí no botão &#8220;Mais informações&#8221;. Isso vai abrir uma tela com uma seção &#8220;Mídia&#8221; onde é possível ver e salvar imagens, ícones e vídeos que seu navegador baixou para mostrar a página. Esse método funciona também para copiar vídeos HTML5, inclusive do YouTube:</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/e.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/e-650x411.png" alt="" title="e" width="650" height="411" class="aligncenter size-large wp-image-1127" /></a></p>
<p><strong>6.</strong> Se você não quiser procurar uma imagem no meio de um monte de mídias, a última versão do seu navegador deve ter um botão &#8220;Inspecionar elemento&#8221; no menu de contexto sempre que você clica com a tecla direita em qualquer lugar da página. Usando essa ferramenta é possível ver o código HTML do que você está vendo (ela é diferente e melhor do que simplesmente ver o código-fonte da página porque usando a inspeção de elementos você vê o código do momento atual, depois dos scripts mudarem as coisas). Se você pedir para inspecionar alguma coisa transparente em cima da imagem, em geral não vai ser difícil achar a própria imagem. Este screenshot é do Chrome:</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/f.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/04/f-650x386.png" alt="" title="f" width="650" height="386" class="aligncenter size-large wp-image-1128" /></a></p>
<p>Há inúmeras soluções mais nerds, mas quis manter a lista com sugestões fáceis e que não precisam de nada além do seu navegador. Alguma outra ideia simples, criativa e divertida? Blogue por aí ou me conte pra eu aumentar a lista!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/como-baixar-fotos-dos-albuns-da-uol/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>43 anos de Internet</title>
		<link>http://blog.tiagomadeira.com/43-anos-de-internet/</link>
		<comments>http://blog.tiagomadeira.com/43-anos-de-internet/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 00:56:09 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Ciência da Computação]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1106</guid>
		<description><![CDATA[Há exatos 43 anos foi escrito o primeiro RFC (Request for Comments), motivo pelo qual muitos comemoramos no dia 7 de abril o nascimento da Internet. Imagino que poucas pessoas já leram ou sabem o que são RFCs fora do meio nerd: em resumo, são simples documentos de texto com não mais de 80 caracteres <a href='http://blog.tiagomadeira.com/43-anos-de-internet/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Há exatos 43 anos foi escrito o primeiro RFC (Request for Comments), motivo pelo qual muitos comemoramos no dia 7 de abril o nascimento da Internet. Imagino que poucas pessoas já leram ou sabem o que são RFCs fora do meio nerd: em resumo, são simples documentos de texto com não mais de 80 caracteres de largura que regulamentam os protocolos usados na Internet e são fundamentais para o desenvolvimento dos programas que você usa diariamente, inclusive o que você está usando para abrir o meu blog (seja no seu computador, no seu celular, ou no seu <a href="https://www.youtube.com/watch?v=9c6W4CCU9M4">óculos</a>).</p>
<p>Traduzi para o português (meio correndo e talvez porcamente; me corrijam se acharem alguma coisa muito errada) e recomendo a leitura do texto abaixo, escrito pelo cara que fez o primeiro RFC e publicado pelo <a href="https://www.nytimes.com/2009/04/07/opinion/07crocker.html">The New York Times</a> há três anos (para o aniversário de 40 anos da Internet). Além do valor histórico, acho que é um texto que tem muito a ver com o debate sobre as possibilidades que a internet do Wikileaks e do Mega Upload nos abre hoje e sobre os valores democráticos da rede, que têm sido duramente combatidos pelo conservadorismo do governo dos Estados Unidos e por iniciativas como a SOPA nos EUA e a Lei Azeredo no Brasil.</p>
<h3>Como a Internet obteve suas regras</h3>
<p><em>* Stephen Crocker</em></p>
<p>Hoje é uma data importante na história da Internet: é o aniversário de 40 anos dos chamados RFCs (Request of Comments). Fora da comunidade técnica, poucos sabem o que são RFCs, mas esses simples documentos moldaram o funcionamento interno da Internet e têm desempenhado um papel significativo no seu sucesso.</p>
<p>Quando os RFCs nasceram, não havia a World Wide Web. Mesmo no final de 1969, havia apenas uma rede rudimentar ligando quatro computadores em quatro centros de pesquisa: a UC Los Angeles, o Stanford Research Institute, a UC Santa Barbara e a Universy of Utah em Salt Lake City. O governo financiou a rede e os cem ou menos cientistas da computação que a utilizaram. Era uma comunidade tão pequena que todo mundo se conhecia.</p>
<p>Muito planejamento e muitas deliberações tinham sido feitos sobre a base da tecnologia da rede, mas ninguém tinha pensado muito no que fazer com ela. Então, em agosto de 1968, um punhado de estudantes e funcionários dos quatro locais começaram a se reunir intermitentemente pessoalmente para tentarem descobrir. (Fui sortudo o suficiente para ser um dos estudantes da UCLA incluídos nessas grandes discussões.) Só na primavera seguinte nós percebemos que deveríamos começar a escrever nossos pensamentos. Pensamos que talvez devêssemos juntar memorandos temporários e informais sobre os protocolos da rede, as regras pelas quais os computadores trocam informação. Me ofereci para organizar nossas primeiras notas.</p>
<p>O que deveria ser uma tarefa simples acabou se tornando um projeto desesperador. Nossa intenção era apenas encorajar outras pessoas a dialogarem, mas fiquei preocupado que soasse como se estivéssemos tomando decisões oficiais ou afirmando autoridade. Na minha cabeça, eu estava incitando a ira de algum professor de prestígio em algum estabelecimento da Costa Leste. Eu estava realmente perdendo o sono com a coisa toda e quando finalmente decidi escrever meu primeiro memorando, que lidava com a comunicação básica entre dois computadores, era madrugada. Tive que trabalhar no banheiro para não incomodar os amigos com quem eu estava hospedado, que estavam todos dormindo.</p>
<p>Ainda com medo de soar presunçoso, rotulei a nota &#8220;Request for Comments&#8221; (Pedido de Comentários). O RFC 1, escrito 40 anos atrás, deixou muitas perguntas sem resposta e logo se tornou obsoleto. Porém, os RFCs se enraizaram e floresceram. Eles se tornaram o método formal de publicar padrões do protocolo da Internet, e hoje são mais de 5000, todos disponíveis online.</p>
<p>Começamos a escrever essas notas antes que nós tivéssemos e-mail e mesmo antes que a rede estivesse realmente funcionando, então nós escrevíamos nossas visões para o futuro no papel e mandávamos pelo correio. Enviávamos uma impressão para cada grupo de pesquisa e eles tinham que tirar suas cópias.</p>
<p>Os primeiros RFCs variavam de grandes visões para detalhes mundanos, embora o segundo rapidamente tenha se tornado o mais comum. Menos importante do que o conteúdo desses primeiros documentos era o fato de que eles eram disponíveis de forma gratuita e qualquer um poderia escrever um. Em vez de um modelo de tomada de decisão baseado em autoridade, nós confiamos num processo que chamamos de &#8220;consenso básico e código em execução&#8221;. Todo mundo era bem-vindo a propôr ideias e, se pessoas suficientes gostassem e usassem, o projeto se tornava um padrão.</p>
<p>No fim, todos entendiam que havia uma utilidade prática em escolher fazer a mesma tarefa da mesma forma. Por exemplo, se quiséssemos mover um arquivo de uma máquina para a outra, se você projetasse o processo de uma forma e eu projetasse de outra, então qualquer pessoa que quisesse falar com nós dois teria que usar duas formas diferentes para fazer a mesma coisa. Então houve muita pressão natural para evitar tais inconvenientes. Provavelmente ajudou que naqueles dias nós evitávamos patentes e outras restrições; sem incentivo financeiro para controlar os protocolos, era muito mais fácil chegar a acordos.</p>
<p>Isso foi o melhor para a abertura dos projetos técnicos, e a cultura dos processos abertos foi essencial para permitir que a internet crescesse e evoluísse da forma tão espetacular como fez. Na verdade, nós provavelmente não teríamos a web sem eles. Quando os físicos do CERN quiseram publicar um monte de informações numa forma que as pessoas pudessem facilmente pegá-las e adicionarem às mesmas, eles simplesmente construíram e testaram suas ideias. Por causa do fundamento que colocamos no RFC, eles não tiveram que pedir permissão, ou fazerem quaisquer mudanças nas operações básicas da Internet. Outros logo copiaram-os &#8212; centenas de milhares de usuários de computador, então centenas de milhões, criando e compartilhando conteúdo e tecnologia. Isso é a Web.</p>
<p>Posto de outra forma, nós sempre tentamos projetar cada novo protocolo para ser útil tanto para seu próprio fim como para serem um bloco de construção disponível para outros. Nós não pensamos nos protocolos como produtos acabados, mas deliberadamente expusemos suas arquiteturas internas para fazer fácil que os outros os aproveitassem. Isso era a antítese da atitude das velhas redes de telefonia, que desencorajavam fortemente quaisquer acréscimos ou utilizações que elas não haviam sancionado.</p>
<p>É claro que o processo para publicar ideias e escolher padrões eventualmente se tornou mais formal. Nossas reuniões soltas e anônimas cresceram e se semi-organizaram no que chamamos de Network Working Group (Grupo de Trabalho da Rede). Nas quatro décadas desde lá, esse grupo evoluiu, se transformou algumas vezes e hoje é a Internet Engineering Task Force (Força de Tarefa da Engenharia da Internet). Ela tem alguma hierarquia e formalidade, mas não muita, e continua a ser gratuita e acessível a qualquer um.</p>
<p>Os RFCs cresceram também. Eles não são mais realmente pedidos de comentários, porque eles são publicados somente depois de muita examinação. Mas a cultura que foi construída no início continuou a desempenhar um papel importante em manter as coisas mais abertas do que elas poderiam ter sido. Ideias são aceitas e classificadas pelos seus méritos, com tantas ideias rejeitadas como aceitas.</p>
<p>A medida que reconstruirmos nossa economia, espero que tenhamos em mente o valor da transparência, especialmente em indústrias que raramente a tiveram. Seja na reforma do sistema de saúde ou na inovação da energia, as maiores recompensas virão não do que o pacote de incentivo paga diretamente, mas das perspectivas que abrimos para os outros explorarem.</p>
<p>Me lembrei do poder e da vitalidade dos RFCs quando eu fiz a minha primeira viagem para Bangalore, India, há 15 anos atrás. Fui convidado a dar uma palestra no Indian Institute of Science e durante a visita fui apresentado a um estudante que construiu um sistema de software bastante complexo. Impressionado, perguntei onde ele havia aprendido a fazer tudo aquilo. Ele respondeu simplesmente: &#8220;Eu baixei os RFCs e li.&#8221;</p>
<p><em>* Stephen D. Crocker escreveu o <a href="https://tools.ietf.org/html/rfc1">primeiro RFC</a> há exatos 43 anos.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/43-anos-de-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress plugin: Admin Anti-forget Alarm</title>
		<link>http://blog.tiagomadeira.com/admin-anti-forget-alarm/</link>
		<comments>http://blog.tiagomadeira.com/admin-anti-forget-alarm/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 06:11:03 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Software Livre]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1090</guid>
		<description><![CDATA[I wrote a small WordPress plugin to prevent users from publishing a post without excerpt or thumbnail, or with a too big excerpt, or with a too small thumbnail, or with an uppercase-only title. This screenshot is showing some of the messages the plugin displays in portuguese. For some of my websites it&#8217;s important to <a href='http://blog.tiagomadeira.com/admin-anti-forget-alarm/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I wrote a small WordPress plugin to prevent users from publishing a post without excerpt or thumbnail, or with a too big excerpt, or with a too small thumbnail, or with an uppercase-only title.</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/03/wordpress.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/03/wordpress-650x305.png" alt="" title="wordpress" width="650" height="305" class="aligncenter size-large wp-image-1091" /></a><br /><small>This screenshot is showing some of the messages the plugin displays in portuguese.</small></p>
<p>For some of my websites it&#8217;s important to require the editors to fix some stuff before publishing something, and it looks like this is a useful feature for <a href="http://meyerweb.com/eric/thoughts/2008/06/10/wanted-excerpt-exacter/">other people</a> as well. There is even a <a href="https://wordpress.org/extend/plugins/require-thumbnail/">Require Thumbnail</a> plugin in the WordPress Plugin Directory that seems to do one of the things I&#8217;ve just implemented.</p>
<p>The plugin works with two different types of requirements: ths first generates errors (i.e., you can&#8217;t publish if you don&#8217;t fix it) and the second generates warnings (i.e., you will receive a message but you can proceed to publish if you really want to do that).</p>
<p>I thought of not releasing the plugin (because it&#8217;s written in Portuguese and you don&#8217;t have a cool interface to decide what&#8217;s required yet), but in a fashion of overstated bazaar I decided to push the code anyway (without putting in the WordPress plugin directory, of course) so that other people can collaborate if they want to. Take a look :)</p>
<p><strong>Github project home page:</strong> <a href="https://github.com/tmadeira/antiforget">https://github.com/tmadeira/antiforget</a><br />
<strong>Git repository to clone:</strong> https://github.com/tmadeira/antiforget.git<br />
<strong>Code (PHP):</strong> <a href="https://github.com/tmadeira/antiforget/blob/master/antiforget.php">https://github.com/tmadeira/antiforget/blob/master/antiforget.php</a><br />
<strong>Download:</strong> <a href="https://github.com/tmadeira/antiforget/zipball/master">antiforget.zip</a> <em>(this is pre-alpha: I provide no warranty!)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/admin-anti-forget-alarm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Como mostrar o último post de cada categoria no WordPress?</title>
		<link>http://blog.tiagomadeira.com/como-mostrar-o-ultimo-post-de-cada-categoria-no-wordpress/</link>
		<comments>http://blog.tiagomadeira.com/como-mostrar-o-ultimo-post-de-cada-categoria-no-wordpress/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 06:32:06 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[Futilidades]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1043</guid>
		<description><![CDATA[O WordPress é um dos meus programas preferidos e um dos que mais consome as madrugadas já faz alguns anos. Escrevi inúmeros temas, alguns plugins (um único genérico o suficiente para ser público) e já modifiquei algumas partes do código (embora hoje seja raro isso ser necessário). Acho muito simples e me divirto ao programar <a href='http://blog.tiagomadeira.com/como-mostrar-o-ultimo-post-de-cada-categoria-no-wordpress/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>O <a href="http://wordpress.org/">WordPress</a> é um dos meus programas preferidos e um dos que mais consome as madrugadas já faz alguns anos. Escrevi inúmeros temas, alguns plugins (<a href="http://blog.tiagomadeira.com/retrospective/">um único genérico o suficiente para ser público</a>) e já modifiquei algumas partes do código (embora hoje seja raro isso ser necessário).</p>
<p>Acho muito simples e me divirto ao programar em PHP para a web (talvez porque eu faça isso há uns dez anos). Gosto muito da forma como o WordPress é escrito e, com efeito, seu lema é <strong>Code is poetry</strong> &#8212; <em>Código é poesia</em>. Sua documentação e seu código são muito didáticos e foram, assim como seus temas e as tabelas no banco de dados, evoluindo de acordo com o tempo: as atualizações sempre têm novas features e formas mais genéricas e mais elegantes de fazer as coisas.</p>
<p>O WordPress é um software livre usado por <a href="http://w3techs.com/technologies/overview/content_management/all">mais de 15% da web</a> (um número incrível!) e tem uma comunidade que produz várias extensões (temas e plugins). Gosto tanto dele que certa vez (no final de 2007) <a href="http://www.pblog.com.br/2007/12/03/camisas-do-wordpress-de-graca-quem-vai-querer/">escrevi um plugin só para ganhar uma camiseta</a> (que é tamanho G e ainda assim uso de vez em quando).</p>
<p>Propaganda e blogagem a parte, me deparei com um problema interessante em um dos sites que administro com ele no último fim de semana (a gente sempre se depara com problemas interessantes no WordPress também): dado uma categoria com várias subcategorias, gostaria de mostrar um link para o último post de cada uma de suas subcategorias na página inicial.</p>
<p>Uma solução trivial seria fazer uma query pedindo os filhos de uma dada categoria (usando a tabela <tt>wp_term_taxonomy</tt>) e uma query por categoria para descobrir seu último post (usando as tabelas <tt>wp_posts</tt> e <tt>wp_term_relationships</tt>). Suponha (até o final desse post) que a categoria-mãe de todas as categorias que eu quero mostrar na página seja a de ID 33. Então, essa solução seria algo como:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT term_id FROM wp_term_taxonomy
                      WHERE parent = 33 AND taxonomy = 'category'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cid</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_row</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$posts_query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT p.ID, p.post_name, p.post_title
                                FROM wp_posts AS p,
                                     wp_term_relationships AS r
                                WHERE p.ID = r.object_ID AND r.term_taxonomy_id = '<span style="color: #006699; font-weight: bold;">$cid</span>'
                                ORDER BY p.post_date DESC
                                LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts_query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$permalink</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_row</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts_query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// Faça o que quiser com o post aqui</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;A categoria <span style="color: #006699; font-weight: bold;">$cid</span> não tem posts.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Não deve ser difícil de entender, mas dá pra resolver de forma ainda mais simples que essa. O WordPress é fantástico e usar as funções dele próprio é bem mais simples, genérico e resolve o problema. A função <a href="https://codex.wordpress.org/Function_Reference/get_categories">get_categories</a> aceita um monte de parâmetros, mas só precisamos do <tt>child_of</tt>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>get_categories<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'child_of=33'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$cat</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;numberposts=1&amp;category=<span style="color: #006699; font-weight: bold;">{$cat-&gt;term_id}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Faça o que quiser com o post aqui</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><small>(quem entrou no post procurando a solução pro problema pode parar por aqui se não for nerd)</small></p>
<p>Porém, eu queria resolver o problema com uma única query. Achei que seria mais elegante resolver o problema todo no banco de dados sem escrever em PHP e achei que poderia ficar mais rápido. Acho que não ficou mais elegante e não faço ideia se fica mais rápido (fiquei com a impressão de que seja pior porque faço JOIN de quatro tabelas enormes), nem acho que tenha volume de dados (ainda) no site em que implementei isso pra realmente me preocupar, mas me diverti fazendo. Então segue o resultado:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> p.ID <span style="color: #990099; font-weight: bold;">AS</span> id<span style="color: #000033;">,</span>
       <span style="color: #009900;">CASE</span> <span style="color: #009900;">WHEN</span> <span style="color: #FF00FF;">&#40;</span>p.post_date <span style="color: #CC0099;">&gt;</span> <span style="color: #000099;">DATE_SUB</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">CURDATE</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #CC0099; font-weight: bold;">INTERVAL</span> <span style="color: #008080;">1</span> <span style="color: #9900FF; font-weight: bold;">MONTH</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #009900;">THEN</span>
           p.post_title
       <span style="color: #009900;">ELSE</span>
           <span style="color: #008000;">''</span>
       <span style="color: #009900;">END</span> <span style="color: #990099; font-weight: bold;">AS</span> title<span style="color: #000033;">,</span>
       <span style="color: #000099;">GROUP_CONCAT</span><span style="color: #FF00FF;">&#40;</span>c.slug<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> cat
<span style="color: #990099; font-weight: bold;">FROM</span> wp_posts <span style="color: #990099; font-weight: bold;">AS</span> p
<span style="color: #990099; font-weight: bold;">INNER</span> <span style="color: #990099; font-weight: bold;">JOIN</span>
    <span style="color: #FF00FF;">&#40;</span>
        <span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #000099;">MAX</span><span style="color: #FF00FF;">&#40;</span>p.post_date<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> post_date<span style="color: #000033;">,</span> c.term_ID <span style="color: #990099; font-weight: bold;">AS</span> cid<span style="color: #000033;">,</span> <span style="color: #000099;">COUNT</span><span style="color: #FF00FF;">&#40;</span>p.ID<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> <span style="color: #000099;">count</span> <span style="color: #990099; font-weight: bold;">FROM</span>
            wp_posts <span style="color: #990099; font-weight: bold;">AS</span> p<span style="color: #000033;">,</span>
            wp_term_relationships <span style="color: #990099; font-weight: bold;">AS</span> r<span style="color: #000033;">,</span>
            wp_terms <span style="color: #990099; font-weight: bold;">AS</span> c
        <span style="color: #990099; font-weight: bold;">WHERE</span>
            p.ID <span style="color: #CC0099;">=</span> r.object_ID <span style="color: #CC0099; font-weight: bold;">AND</span>
            c.term_ID <span style="color: #CC0099;">=</span> r.term_taxonomy_ID <span style="color: #CC0099; font-weight: bold;">AND</span>
            p.post_status <span style="color: #CC0099;">=</span> <span style="color: #008000;">'publish'</span> <span style="color: #CC0099; font-weight: bold;">AND</span>
            p.post_type <span style="color: #CC0099;">=</span> <span style="color: #008000;">'post'</span>
        <span style="color: #990099; font-weight: bold;">GROUP BY</span> c.term_id
    <span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> <span style="color: #990099; font-weight: bold;">last</span> <span style="color: #990099; font-weight: bold;">ON</span> p.post_date <span style="color: #CC0099;">=</span> <span style="color: #990099; font-weight: bold;">last</span>.post_date
<span style="color: #990099; font-weight: bold;">INNER</span> <span style="color: #990099; font-weight: bold;">JOIN</span> wp_term_relationships <span style="color: #990099; font-weight: bold;">AS</span> r <span style="color: #990099; font-weight: bold;">ON</span> p.ID <span style="color: #CC0099;">=</span> r.object_ID
<span style="color: #990099; font-weight: bold;">INNER</span> <span style="color: #990099; font-weight: bold;">JOIN</span> wp_terms <span style="color: #990099; font-weight: bold;">AS</span> c <span style="color: #990099; font-weight: bold;">ON</span> c.term_id <span style="color: #CC0099;">=</span> r.term_taxonomy_ID
<span style="color: #990099; font-weight: bold;">INNER</span> <span style="color: #990099; font-weight: bold;">JOIN</span> wp_term_taxonomy <span style="color: #990099; font-weight: bold;">AS</span> t <span style="color: #990099; font-weight: bold;">ON</span> t.term_id <span style="color: #CC0099;">=</span> r.term_taxonomy_ID
<span style="color: #990099; font-weight: bold;">WHERE</span>
    c.term_id <span style="color: #CC0099;">=</span> <span style="color: #990099; font-weight: bold;">last</span>.cid
    <span style="color: #CC0099; font-weight: bold;">AND</span> t.parent <span style="color: #CC0099;">=</span> <span style="color: #008080;">33</span>
    <span style="color: #CC0099; font-weight: bold;">AND</span> t.taxonomy <span style="color: #CC0099;">=</span> <span style="color: #008000;">'category'</span>
    <span style="color: #CC0099; font-weight: bold;">AND</span> p.post_status <span style="color: #CC0099;">=</span> <span style="color: #008000;">'publish'</span>
    <span style="color: #CC0099; font-weight: bold;">AND</span> p.post_type <span style="color: #CC0099;">=</span> <span style="color: #008000;">'post'</span>
    <span style="color: #808080; font-style: italic;"># AND last.count &gt;= 3</span>
<span style="color: #990099; font-weight: bold;">GROUP BY</span> p.ID <span style="color: #990099; font-weight: bold;">ORDER BY</span> p.post_date <span style="color: #990099; font-weight: bold;">DESC</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">last</span>.<span style="color: #000099;">count</span> <span style="color: #990099; font-weight: bold;">DESC</span><span style="color: #000033;">;</span></pre></div></div>

<p>A query (que na verdade é duas) ordena o resultado por data, retorna o título vazio caso o post seja de mais de um mês atrás, junta as categorias (separando-as por vírgula) se um mesmo post for o último de mais de uma categoria e neste caso ordena as categorias por ordem decrescente de número de posts na mesma.</p>
<p><small>(A parte comentada seria para caso eu só quisesse mostrar o último post de categorias com três ou mais posts.)</small></p>
<p>Usei o resultado da query da seguinte forma:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $query é a string com aquele SQLzão</span>
<span style="color: #000088;">$print_final_li</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #339933;">,</span> MYSQL_ASSOC<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;li&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$permalink</span> <span style="color: #339933;">=</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$print_final_li</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Veja também: &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$permalink</span><span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$title</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> get_the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;home-thumbnail&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span> <span style="color: #339933;">=&gt;</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$cats</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;cat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cats</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$low</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$up</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$low</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>cat<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://<span style="color: #006699; font-weight: bold;">$low</span>.juntos.org.br/<span style="color: #000099; font-weight: bold;">\&quot;</span>
                 title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Juntos! <span style="color: #006699; font-weight: bold;">$up</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$up</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$print_final_li</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>post<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$permalink</span><span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$title</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #339933;">,</span> MYSQL_ASSOC<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$cats</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;cat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cats</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$low</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$up</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$low</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>cat<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://<span style="color: #006699; font-weight: bold;">$low</span>.juntos.org.br/<span style="color: #000099; font-weight: bold;">\&quot;</span>
                 title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Juntos! <span style="color: #006699; font-weight: bold;">$up</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$up</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$print_final_li</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><small>(e se você quiser vê-lo em prática, entre em <a href="http://juntos.org.br/">juntos.org.br</a> e procure por <em>&#8220;Juntos pelo Brasil&#8221;</em>)</small></p>
<p>Não ficou bonitinho? Se por um lado gostei da solução, por outro fiquei imaginando que deva ser um SQL tremendamente ingênuo e digno da minha inexperiência com grandes bancos de dados. O que você acha? Consegue pensar numa forma mais simples, mais eficiente e mais elegante de resolver o mesmo problema? Ou ao menos sem subqueries?</p>
<p>Acho que as relações necessárias já ficaram explícitas na query que eu escrevi, mas segue o diagrama do banco de dados do WordPress pra quem precisar:</p>
<p><a href="http://blog.tiagomadeira.com/wp-content/uploads/2012/03/WP3.0-ERD.png"><img src="http://blog.tiagomadeira.com/wp-content/uploads/2012/03/WP3.0-ERD-650x656.png" alt="" title="WP3.0-ERD" width="650" height="656" class="aligncenter size-large wp-image-1079" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/como-mostrar-o-ultimo-post-de-cada-categoria-no-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copa do Mundo</title>
		<link>http://blog.tiagomadeira.com/copa-do-mundo/</link>
		<comments>http://blog.tiagomadeira.com/copa-do-mundo/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 04:48:49 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[EUA]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1026</guid>
		<description><![CDATA[Na primeira vez que fui pra empresa, topei com um cara simpático que trabalha no andar de cima. Acho que seu nome é Nicholas, mas não que isso seja relevante. Perguntei pra ele alguma coisa e ele me ajudou a chegar na porta da empresa. Na saída do trabalho, hoje, ele me viu de longe <a href='http://blog.tiagomadeira.com/copa-do-mundo/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Na primeira vez que fui pra empresa, topei com um cara simpático que trabalha no andar de cima. Acho que seu nome é Nicholas, mas não que isso seja relevante. Perguntei pra ele alguma coisa e ele me ajudou a chegar na porta da empresa. Na saída do trabalho, hoje, ele me viu de longe e perguntou se deu certo o trabalho e como estavam as coisas. Conversa padrão e tudo está fine, cool e nice. Interessante foi a continuação da conversa.</p>
<p><em>&#8220;Qual o site mais famoso do Brasil pra compra e venda de tickets?&#8221;</em> Primeiro eu entendi passagens aéreas, então falei do decolar.com e do submarinoviagens.com.br. Ao entender que a pergunta tratava de ingressos (pra shows, ele disse então), falei do ingresso.com.br. <em>&#8220;Ingresso é ticket em português, falei.&#8221;</em> Ele respondeu, pra minha surpresa: <em>&#8220;Eu sei&#8221;</em>. Pra fazer a conversa fluir, continuei dizendo, voluntariamente, que há sites também onde as pessoas compram ingressos de futebol como o ingressofacil.com.br.</p>
<p>Ele não falou nada, mas pareceu muito interessado e pareceu ter anotado o endereço na sua cabeça, o que me deixou curioso. Então eu perguntei inocentemente se ele era de alguma empresa de venda de ingressos. Surpreendemente ele disse que não. Novamente por pura curiosidade, aí, perguntei se ele estava planejando fazer algum serviço de venda de ingressos pros EUA ou algo do tipo. Também disse que não. Eu olhei com uma cara de curiosidade pra ele e ele continuou: <em>&#8220;Meu interesse é no Brasil mesmo.&#8221;</em></p>
<p>Estranhando bastante a conversa, perguntei então o porquê. Enfim, mistério resolvido: ele falou que está estudando o Brasil por causa da Copa do Mundo e das Olimpíadas. Não é incrível? É a segunda vez em dois dias que alguém me pergunta algo sobre a Copa de 2014.</p>
<p><em>&#8220;Bom&#8230; De fato acho que dá pra ganhar muito dinheiro com a Copa.&#8221;</em> foi a última coisa que falei, contemplativo, antes de nos despedirmos.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/copa-do-mundo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TV e café da manhã</title>
		<link>http://blog.tiagomadeira.com/tv-e-cafe-da-manha/</link>
		<comments>http://blog.tiagomadeira.com/tv-e-cafe-da-manha/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 04:47:45 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[EUA]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1040</guid>
		<description><![CDATA[(originalmente publicado no Facebook na manhã da quinta-feira 09/02 &#8212; horários em UTC-8 &#8212; estou copiando pra cá pra registrar) 7:32 &#8212; Passou uma propaganda de car title loan aqui na TV que pareceu muito aquela propaganda &#8220;Refinancie sua casa&#8221; do filme &#8220;Capitalismo: uma história de amor&#8221; do Michael Moore. 7:39 &#8212; A pessoa fala <a href='http://blog.tiagomadeira.com/tv-e-cafe-da-manha/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><em>(originalmente publicado no Facebook na manhã da quinta-feira 09/02 &#8212; horários em UTC-8 &#8212; estou copiando pra cá pra registrar)</em></p>
<p>7:32 &#8212; Passou uma propaganda de car title loan aqui na TV que pareceu muito aquela propaganda &#8220;Refinancie sua casa&#8221; do filme &#8220;Capitalismo: uma história de amor&#8221; do Michael Moore.</p>
<p>7:39 &#8212; A pessoa fala um pouco no jornal e termina com: &#8220;Coloquei mais informações na minha página no Facebook.&#8221; Além dos Twitters dos editores que fazem comentários no rodapé da tela, várias vezes aparecer o letreiro &#8220;Acesse nosso Twitter (ou nossa página no Facebook) pra ver as breaking news.&#8221; e tal. Bem interessante. A televisão aqui tá muito voltada pras redes sociais.</p>
<p>7:50 &#8212; Rá! Descobri (<a href="http://www.instructables.com/id/How-to-Open-a-Milk-Carton/step3/Start-opening/">pela internet</a>) como abrir uma caixa de leite. Da próxima vez nem vou precisar de tesoura :)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/tv-e-cafe-da-manha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Empresa</title>
		<link>http://blog.tiagomadeira.com/empresa/</link>
		<comments>http://blog.tiagomadeira.com/empresa/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 04:44:44 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[EUA]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1036</guid>
		<description><![CDATA[Originalmente publicado no Facebook às 21h45 (UTC-8) da quarta-feira 08/02. Um pouco modificado pra registrar no blog. Até queria falar do sol e da manhã de carnaval (a canção do Orfeu Negro tocava na Starbucks, com letra em português, quando entrei lá hoje), das crianças que caminhavam pra escola, das moças de bicicleta que pilotavam <a href='http://blog.tiagomadeira.com/empresa/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><em>Originalmente <a href="https://www.facebook.com/madeira.usp/posts/3259486444828">publicado no Facebook</a> às 21h45 (UTC-8) da quarta-feira 08/02. Um pouco modificado pra registrar no blog.</em></p>
<p>Até queria falar do sol e da manhã de carnaval (a canção do Orfeu Negro tocava na Starbucks, com letra em português, quando entrei lá hoje), das crianças que caminhavam pra escola, das moças de bicicleta que pilotavam na direção oposta, do piano de cauda numa casa com porta aberta (eu quase entrei pra tocar, mas fiquei com medo de ser preso), da forma diferente como as pessoas aqui se relacionam, do céu estrelado e dos olhos das ruas às 19h00, mas (maldito jet lag!) são só 21h20 e já estou morrendo de sono pra escrever sobre essas coisas românticas agora (e, além do mais, no Brasil acho que deve estar todo mundo dormindo mesmo, já que aí são 3h20).</p>
<p>Então: Agora que já deixei registrado que essas coisas aconteceram (estou me sentindo mais ou menos como quando cheguei em São Paulo notando essas coisas pequenas), escreverei sobre coisas mais diretas mesmo (também interessantes, na minha opinião) e, mais precisamente, sobre o estágio.</p>
<p>Voltei há pouco do primeiro dia na empresa. Fui muito bem recebido. Há gente de todo lugar. Almocei com um alemão, um búlgaro e um americano. Do meu lado senta um espanhol. Já conhecia daqui um egípcio. Conheci também um canadense. Todos muito simpáticos, aparentemente ótimos programadores, dispostos a conversar e a ensinar o que estão fazendo.</p>
<p>Meu desktop é o maior computador que já vi. A resolução é algo como 2560&#215;1600. É quatro vezes a tela que estou acostumado (o louco é que todo mundo na empresa usa dois monitores desse tamanho!). Roda Ubuntu.</p>
<p>O laptop que me deram é um MacBook Pro (roda Mac).</p>
<p>Passei o dia configurando os computadores; resolvendo a papelada; conhecendo as pessoas; usando, conhecendo e lendo partes do código do imo.im (aliás, a partir de quando arranjar um celular acho que vou passar o dia online em todos os mensageiros instantâneos que uso pelo aplicativo do imo.im pra Android, que achei o máximo).</p>
<p>A empresa tem lanches e refrigerantes de graça. Todos os dias também oferece almoço ou jantar. É bem localizada e é perto de casa, tem várias bolas (de basquete, futebol, vôlei), uma mesa de sinuca, aparelhos de ginástica (falando nisso, me ofereceram academia), gostei bastante do ambiente.</p>
<p>Próximos passos mais burocráticos por lá: social security number, plano de saúde, resolver o complicado formulário W-4 e descobrir quanto vou pagar de imposto.</p>
<p>O mais importante e aí não mais burocrático: descobrir o que vou desenvolver. Me parece que vai ser bem legal.</p>
<p>Terminada a propaganda (acho que sou facilmente impressionável) e mudando de assunto pra algo ainda nerd (na verdade, mais nerd), mas não-tão-relacionado: amanhã às 8h00 (14h00 em São Paulo) tem single round match do TopCoder. Vou fazer antes de ir trabalhar se estiver acordado e disposto. <em>(nota da reedição pro blog: não fui muito bem, mas paritcipei :))</em> Participem aí, pessoas que tão no acampamento em Campinas e demais maratonistas!</p>
<p>No mais, até me acostumar com a dinâmica da empresa e com o fuso horário, acho que só vou conseguir aproveitar bem o tempo livre do fim de semana.</p>
<p>Quero muito bolar uma estratégia pra me aproximar dos estudantes de Stanford pra ter com quem tomar uma cerveja conversando sobre aleatoriedades e descobrir como é a universidade aqui.</p>
<p>Por falar em Stanford, só hoje lembrei que é a universidade do grande Donald Knuth.</p>
<p>Melhor parar de escrever antes que eu caia em cima do teclado de sono e que o texto fique tão grande que ninguém leia.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/empresa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Palo Alto</title>
		<link>http://blog.tiagomadeira.com/palo-alto/</link>
		<comments>http://blog.tiagomadeira.com/palo-alto/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 04:41:49 +0000</pubDate>
		<dc:creator>Tiago Madeira</dc:creator>
				<category><![CDATA[EUA]]></category>

		<guid isPermaLink="false">http://blog.tiagomadeira.com/?p=1034</guid>
		<description><![CDATA[Originalmente publicado no Facebook às 9h15 (UTC-8) da quarta-feira 08/02. Um pouco modificado pra registrar no blog. Só consegui internet agora. Cheguei bem, estou ótimo. Obrigado pela preocupação a todos que perguntaram. Neste momento, sentado numa Starbucks na University Ave em Palo Alto. Mudar de fuso é muito confuso (aqui é seis horas mais cedo <a href='http://blog.tiagomadeira.com/palo-alto/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><em>Originalmente <a href="https://www.facebook.com/madeira.usp/posts/3254876489582">publicado no Facebook</a> às 9h15 (UTC-8) da quarta-feira 08/02. Um pouco modificado pra registrar no blog.</em></p>
<p>Só consegui internet agora. Cheguei bem, estou ótimo. Obrigado pela preocupação a todos que perguntaram. Neste momento, sentado numa Starbucks na University Ave em Palo Alto.</p>
<p>Mudar de fuso é muito confuso (aqui é seis horas mais cedo do que em São Paulo): acordei às 4h00 e não conseguia dormir. Aí assisti três horas de televisão. Superbowl, vitória de Santorum sobre Romney em três estados nas prévias republicanas, muita pressão pros EUA intervirem militarmente na Síria na CNN, muita discussão sobre a crise na Europa e muitas críticas à Grécia no DW, uma mulher no exército dos EUA tem mais chance de ser estuprada por um colega de trabalho do que ser morta pelo inimigo, Occupy Oakland: câmara municipal foi contra resolução que proibiria protestos no porto, California: proibição de casamento gay é considerada ilegal por tribunal&#8230; entre outras coisas que chamaram menos atenção.</p>
<p>Palo Alto é uma cidade fantástica, linda. As casas aqui no centrinho perto de Stanford, parecem aquelas casas que a gente vê em filme.</p>
<p>Cheguei às 8h20 na empresa e não havia ninguém (acho que isso é bom, significa que eles não trabalham muito cedo! ;)). Vou dar uma volta por aqui e voltar pra empresa (descobri lendo e-mail que tenho que estar às 10h00 lá &#8212; agora são 9h15).</p>
<p>Se sair cedo, vou dar um pulo na Universidade mais tarde. Vi umas coisas interessantes por aqui. A noite, quando já devo ter internet em casa, escrevo algo menos confuso no meu blog. <em>(Nota da edição pro blog: Até escrevi outra notinha, mas acho que nada menos confusa.)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tiagomadeira.com/palo-alto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

