<?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>cObaia.net &#187; programação</title>
	<atom:link href="http://cobaia.net/categorias/programacao/feed/" rel="self" type="application/rss+xml" />
	<link>http://cobaia.net</link>
	<description>PHP, Javascript and some code around it!</description>
	<lastBuildDate>Sun, 29 Jan 2012 03:56:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>And so you code</title>
		<link>http://cobaia.net/2010/12/and-so-you-code/</link>
		<comments>http://cobaia.net/2010/12/and-so-you-code/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 18:34:01 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=723</guid>
		<description><![CDATA[And so you code]]></description>
			<content:encoded><![CDATA[<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/Eq3CuMDXaPs?fs=1&amp;hl=pt_BR"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Eq3CuMDXaPs?fs=1&amp;hl=pt_BR" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="306"></embed></object><br />
<a href='http://www.youtube.com/watch?v=Eq3CuMDXaPs' >And so you code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2010/12/and-so-you-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vagas Programador de Interface Conrad Caine</title>
		<link>http://cobaia.net/2010/11/vagas-programador-de-interface-conrad-caine/</link>
		<comments>http://cobaia.net/2010/11/vagas-programador-de-interface-conrad-caine/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 13:04:01 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=717</guid>
		<description><![CDATA[A CONRAD CAINE, agência digital com escritórios em Munich, Pelotas e Buenos Aires procura programadores de interface para integrar a equipe de Pelotas-RS. Responsabilidades &#8211; Codificar páginas que funcionem perfeitamente em diversos browsers, de uma maneira fiel ao projeto original (funcionalmente e visualmente); &#8211; Codificar interfaces interativas utilizando JavaScript/Ajax; &#8211; Pesquisar novas técnicas de desenvolvimento; [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://conrad-caine.com">CONRAD CAINE</a>, agência digital com escritórios em Munich, Pelotas e Buenos Aires procura programadores de interface para integrar a equipe de Pelotas-RS.</p>
<p><strong>Responsabilidades</strong></p>
<p>    &#8211; Codificar páginas que funcionem perfeitamente em diversos browsers, de uma maneira fiel ao projeto original (funcionalmente e visualmente);<br />
    &#8211; Codificar interfaces interativas utilizando JavaScript/Ajax;<br />
    &#8211; Pesquisar novas técnicas de desenvolvimento;<br />
    &#8211; Aplicar com sucesso técnicas de SEO;<br />
    &#8211; Escrever código limpo e bem organizado;</p>
<p><strong>Qualificações</strong></p>
<p>    &#8211; Experiência na utilização das bibliotecas JavaScript mais conhecidas no mercado;<br />
    &#8211; Conhecimento acerca das técnicas de SEO;<br />
    &#8211; Habilidade para desenvolver websites com um alto padrão de usabilidade / acessibilidade;<br />
    &#8211; Fluência nos padrões W3C (HTML/XHTML/CSS);<br />
    &#8211; Pró-ativo e autodidata;<br />
    &#8211; Rápido na solução de bugs;<br />
    &#8211; Habilidade para entregar estimativas corretas;<br />
    &#8211; Inglês intermediário/avançado;<br />
    &#8211; Experiência com Photoshop/Fireworks;</p>
<p>Currículos devem ser enviados para <a href="mailto:jobs.pelotas@conrad-caine.com?subject=Programador de Interface">jobs.pelotas@conrad-caine.com</a>, com o título &#8220;Programador de Interface&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2010/11/vagas-programador-de-interface-conrad-caine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top funny source code comments</title>
		<link>http://cobaia.net/2010/09/top-funny-source-code-comments/</link>
		<comments>http://cobaia.net/2010/09/top-funny-source-code-comments/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 17:49:44 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=684</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 /* * OK; before you read the following code know what I am trying to do. * I needed to get the list of child catagories from the root node so that * the root node didn't appear in the selection [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox"><table><tr id="p68423"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p684code23"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * OK; before you read the following code know what I am trying to do.
 * I needed to get the list of child catagories from the root node so that
 * the root node didn't appear in the selection box. But for some stupid
 * fucking reason the stupid fucking DBA wont let me access the items using
 * indices and I instead have to use their stupid fucking Iterator
 * implementation. So there.
 */</span>
<span style="color: #000088;">$firstList</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRootNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildren</span><span style="color: #009900;">&#40;</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;">$firstList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>                <span style="color: #666666; font-style: italic;">// wtf?</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68424"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code24"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// if i ever see this again i'm going to start bringing guns to work</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68425"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code25"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//hack for ie browser (assuming that ie is a browser)</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68426"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p684code26"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68427"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p684code27"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// </span>
<span style="color: #006600; font-style: italic;">// Dear maintainer:</span>
<span style="color: #006600; font-style: italic;">// </span>
<span style="color: #006600; font-style: italic;">// Once you are done trying to 'optimize' this routine,</span>
<span style="color: #006600; font-style: italic;">// and have realized what a terrible mistake that was,</span>
<span style="color: #006600; font-style: italic;">// please increment the following counter as a warning</span>
<span style="color: #006600; font-style: italic;">// to the next guy:</span>
<span style="color: #006600; font-style: italic;">// </span>
<span style="color: #006600; font-style: italic;">// total_hours_wasted_here = 16</span>
<span style="color: #006600; font-style: italic;">//</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68428"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code28"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// TODO: Fix this. Fix what?</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68429"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p684code29"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// no comments for you</span>
<span style="color: #006600; font-style: italic;">// it was hard to write</span>
<span style="color: #006600; font-style: italic;">// so it should be hard to read</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68430"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code30"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// I will give you two of my seventy-two virgins if you can fix this.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68431"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code31"><pre class="javascript" style="font-family:monospace;">options.<span style="color: #660066;">BatchSize</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">300</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Madness? THIS IS SPARTA!</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68432"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p684code32"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// I am not responsible of this code.</span>
<span style="color: #006600; font-style: italic;">// They made me write it, against my will.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68433"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p684code33"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//Dear future me. Please forgive me.</span>
<span style="color: #006600; font-style: italic;">//I can't even begin to express how sorry I am.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68434"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code34"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">double</span> penetration<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// ouch</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68435"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code35"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># To understand recursion, see the bottom of this file.</span></pre></td></tr></table></div>

<p>At the bottom file:</p>

<div class="wp_codebox"><table><tr id="p68436"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code36"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># To understand recursion, see the top of this file.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68437"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code37"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//I am not sure why this works but it fixes the problem.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68438"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p684code38"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//somedev1 - 6/7/02 Adding temporary tracking of Logic screen</span>
<span style="color: #006600; font-style: italic;">//somedev2 - 5/22/07 Temporary my ass</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68439"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p684code39"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * You may think you know what the following code does.
 * But you dont. Trust me
 * Fiddle with me, and youll spend many a sleppless
 * night cursing the moment you thought you be clever 
 * enough to &quot;optimize&quot; the code below.
 * Now close this file and go play with something else.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68440"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code40"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// drunk, fix later</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68441"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p684code41"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Magic. Do not touch.</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68442"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p684code42"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// I dedicate all this code, all my work, to my wife, Darlene, who will</span>
<span style="color: #006600; font-style: italic;">// have to support me and our three children and the dog once it gets</span>
<span style="color: #006600; font-style: italic;">// released into the public</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p68443"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p684code43"><pre class="java" style="font-family:monospace;"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> up <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Something is really wrong.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">throw</span> up<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ha ha</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p68444"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p684code44"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//When I wrote this, only God and I understood that I was doing</span>
<span style="color: #006600; font-style: italic;">//Now, God only knows</span></pre></td></tr></table></div>

<p>Some more <a href="http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2010/09/top-funny-source-code-comments/feed/</wfw:commentRss>
		<slash:comments>126</slash:comments>
		</item>
		<item>
		<title>MySQL, Multiple select in the same table with the result together and order condition applied on all result</title>
		<link>http://cobaia.net/2010/08/mysql-multiple-select-in-the-same-table-with-the-result-together-and-order-condition-applied-on-all-result/</link>
		<comments>http://cobaia.net/2010/08/mysql-multiple-select-in-the-same-table-with-the-result-together-and-order-condition-applied-on-all-result/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 13:31:32 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=654</guid>
		<description><![CDATA[Today I needed made a multiple select, more than one SELECT command in the same table, but the result should comes together and I also needed apply one condition for ORDER in all result. Firstly I tried read if CakePHP has supports for it, but CakePHP doesn&#8217;t has, so I pass to try a MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed made a multiple select, more than one SELECT command in the same table, but the result should comes together and I also needed apply one condition for ORDER in all result.</p>
<p>Firstly I tried read if CakePHP has supports for it, but CakePHP doesn&#8217;t has, so I pass to try a MySQL query solution for that, and that solution is the command <a href="http://dev.mysql.com/doc/refman/5.0/en/union.html">UNION</a>.</p>
<p>For example:</p>
<p>Table <strong>people</strong></p>
<p><strong>id<br />
name<br />
</strong><strong>age </strong></p>
<p><strong><span style="font-weight: normal;">If for example we want show <strong>30 person with age equal 2</strong>0 and more </span>20 with the age equal 10.</strong></p>
<p>With the union condition this is simple.</p>

<div class="wp_codebox"><table><tr id="p65448"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p654code48"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> people <span style="color: #993333; font-weight: bold;">WHERE</span> age<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">20</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">UNION</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> people <span style="color: #993333; font-weight: bold;">WHERE</span> age<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>So how you can check, it&#8217;s  pretty simple, make your two queries and apply the command UNION, if you want to apply one order or another thing in the result you should put it in the end</p>

<div class="wp_codebox"><table><tr id="p65449"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p654code49"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> people <span style="color: #993333; font-weight: bold;">WHERE</span> age<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">20</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">UNION</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> people <span style="color: #993333; font-weight: bold;">WHERE</span> age<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> name <span style="color: #993333; font-weight: bold;">ASC</span>;</pre></td></tr></table></div>

<p>Worth remembering, the fields that result will come should be equal, this in the case that you are not using the same table, but two tables distinct with different fields between these.</p>
<p>In the case of CakePHP framework, apply the query method of your model for example:</p>

<div class="wp_codebox"><table><tr id="p65450"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p654code50"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
(SELECT Node.* FROM nodes AS Node WHERE type=3 ORDER BY date DESC LIMIT 30)
UNION
(SELECT Node.* FROM nodes AS Node WHERE type!=3 ORDER BY date DESC LIMIT 200) 
ORDER BY date DESC;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2010/08/mysql-multiple-select-in-the-same-table-with-the-result-together-and-order-condition-applied-on-all-result/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Xavante na WEB, Experimento em HTML5, CSS3, jQuery e CakePHP com Crawler usando phpQuery</title>
		<link>http://cobaia.net/2010/08/xavante-na-web-experimento-em-html5-css3-jquery-e-cakephp-com-crawler-usando-phpquery/</link>
		<comments>http://cobaia.net/2010/08/xavante-na-web-experimento-em-html5-css3-jquery-e-cakephp-com-crawler-usando-phpquery/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 01:56:32 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=650</guid>
		<description><![CDATA[Hoje postei no ar um experimento(projeto) o Xavante na Web, para testar algumas tecnologias são elas HTML5, CSS3, Jquery e o phpQuery, junto com a integração de algumas API&#8217;s, hoje 09.08 de agosto a do twitter já está no ar, e a do Flickr e Youtube, virão em seguida visto que as duas já foram [...]]]></description>
			<content:encoded><![CDATA[<p>Hoje postei no ar um <a href="http://xavante.cobaia.net">experimento(projeto)</a> o Xavante na Web, para testar algumas tecnologias são elas HTML5, CSS3, <a href="http://jquery.com">Jquery</a> e o <a href="http://code.google.com/p/phpquery/">phpQuery</a>, junto com a integração de algumas API&#8217;s, hoje 09.08 de agosto a do twitter já está no ar, e a do Flickr e Youtube, virão em seguida visto que as duas já foram codificadas bastando o cacheamento das mesmas.</p>
<p>Para o mesmo foi gasto 3 horas de desenvolvimento, mais 1 hora de acertos que com sua publicação ficou beirando as 5 horas, usando P<a href="http://php.net">HP 5.2</a>, <a href="http://mysql.org">MySQL 5</a> e <a href="http://cakephp.org">CakePHP 1.3</a>.</p>
<p>O <a href="http://xavante.cobaia.net">Xavante na Web</a>, nada mais é que um agregador de notícias, assuntos, imagens vídeos relacionados ao Grêmio Esportivo Brasil, meu time de coração!</p>
<p>Pretendo nele ir aplicando novas técnicas, e por em prática HTML5 e CSS3 que venho estudando, para o mesmo criei uma Classe PHP para fazer a parte de <a href="http://pt.wikipedia.org/wiki/Web_crawler">Crawler</a>, que após eu ter uma suite de teste dela pretendo publicar por aqui, por hora é isso.</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2010/08/xavante-na-web-experimento-em-html5-css3-jquery-e-cakephp-com-crawler-usando-phpquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP adicionando Paths de Controllers, Models, Helpers, Components, Views, Plugins, Locales e Shell.</title>
		<link>http://cobaia.net/2009/08/cakephp-adicionando-paths-de-controllers-models-helpers-components-views-plugins-locales-e-shell/</link>
		<comments>http://cobaia.net/2009/08/cakephp-adicionando-paths-de-controllers-models-helpers-components-views-plugins-locales-e-shell/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 13:42:52 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=593</guid>
		<description><![CDATA[Uma funcionalidade legal do CakePHP é a possibilidade de adicionar novos PATHS (caminho de diretórios) que contenham código fonte, com isso por exemplo é possível criar um diretório onde podemos fazer compartilhamento de plugins com diversos projetos. Todos esses Paths você pode definir no bootstrap de sua aplicação esse se encontra em: config/bootstrap.php 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>Uma funcionalidade legal do <a href="http://cakephp.org">CakePHP</a> é a possibilidade de adicionar novos PATHS (caminho de diretórios) que contenham código fonte, com isso por exemplo é possível criar um diretório onde podemos fazer compartilhamento de plugins com diversos projetos.</p>
<p>Todos esses Paths você pode definir no bootstrap de sua aplicação esse se encontra em: <code>config/bootstrap.php</code></p>

<div class="wp_codebox"><table><tr id="p59352"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p593code52"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$controllerPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$viewPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$modelPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$helperPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$componentPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$pluginPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$vendorPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$localePaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$shellPaths</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Pode ser passados vários PATHS no <code>array</code>, e todos serão adicionados junto com os PATHS padrões do CakePHP 1.2.</p>
<p>Além da funcionalidade de compartilhar código, pode se fazer algumas especializações com esse tipo de funcionalidade, com criatividade e lógica é possível criar controllers com mesmo nome e dependendo da situação um dos dois serem chamados, assim como fazer overwrite das classes de modelo, etc&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2009/08/cakephp-adicionando-paths-de-controllers-models-helpers-components-views-plugins-locales-e-shell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Novas versões do CakePHP, CakePHP 1.2, CakePHP 2 e Cake 3</title>
		<link>http://cobaia.net/2009/08/novas-versoes-do-cakephp-cakephp-1-2-cakephp-2-e-cake-3/</link>
		<comments>http://cobaia.net/2009/08/novas-versoes-do-cakephp-cakephp-1-2-cakephp-2-e-cake-3/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 02:07:09 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=587</guid>
		<description><![CDATA[Foi lançada duas novas versões do CakePHP, um novo released da versão 1.2 (CakePHP 1.2) e uma versão de desenvolvimento do Cake 3. Curiosidade da versão do Cake 3 é a mudança de nome que provavelmente foi dada por causa da licensa do &#8220;PHP&#8221;. 3. The name "PHP" must not be used to endorse or [...]]]></description>
			<content:encoded><![CDATA[<p>Foi lançada duas novas versões do CakePHP, um novo released da versão 1.2 (CakePHP 1.2) e uma versão de desenvolvimento do Cake 3.</p>
<p>Curiosidade da versão do Cake 3 é a mudança de nome que provavelmente foi dada por causa da licensa do &#8220;PHP&#8221;.</p>
<pre>  3. The name "PHP" must not be used to endorse or promote products
     derived from this software without prior written permission. For
     written permission, please contact group@php.net.</pre>
<p>Veja toda a Licensa do <a href="http://www.php.net/license/3_01.txt">PHP aqui</a>.</p>
<p>Ou seja só pode usar o nome PHP em algum produto com autorização do PHP, não sei se as outras versões possuem essa autorização mas todavia, acho que o Cake está encaminhando a mudar o nome.</p>
<p>O released CakePHP 1.2.4.8284, é de bug fixes, com pequenas mudanças, e alguns bugs fixed, assim como melhorias nos tests. Todas as mudanças na versão do CakePHP 1.2 pode ser visto no <a href="https://trac.cakephp.org/wiki/changelog/1.2.x.x/8284">changelog</a>.</p>
<p>Enquanto a versão <a href="http://code.cakephp.org/cake3">Cake 3</a>, está sendo desenvolvida utilizando os recursos do PHP 5.3, como funções anonimas e namespace, que irão ajudar muito principalmente no desenvolvimento de plugins que será muito mais fácil, pois será agora possível a criação de pacotes. Assim como o conflito com o nome de classes que não irão correr mais, e isso é um grande ponto.</p>
<p>A versão Cake3 será totalmente reformulada e vale a pena acompanhar o <a href="http://code.cakephp.org/cake3">repositório</a> o que está por vir.</p>
<p>Em paralelo está sendo desenvolvido o <a href="http://code.cakephp.org/cakephp2">CakePHP 2</a>, que será um refactoring do código do CakePHP 1.2 para PHP 5 para rodar em strict com o PHP 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2009/08/novas-versoes-do-cakephp-cakephp-1-2-cakephp-2-e-cake-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.2 problemas de Encode UTF-8 ISO-8859-1</title>
		<link>http://cobaia.net/2009/08/cakephp-1-2-problemas-de-encode-utf-8-iso-8859-1/</link>
		<comments>http://cobaia.net/2009/08/cakephp-1-2-problemas-de-encode-utf-8-iso-8859-1/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 14:59:03 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=584</guid>
		<description><![CDATA[Seguido várias pessoas tem problemas com encode no desenvolvimento com CakePHP 1.2, são pequenos erros que levam a fazer isso, para solucionar os mesmos normalmente é simples, porém vou buscar descrever aqui onde a maioria pode ocorrer: Database Config No config/database.php, onde definimos a conexão a base de dados do CakePHP, é possível definir nomes [...]]]></description>
			<content:encoded><![CDATA[<p>Seguido várias pessoas tem problemas com encode no desenvolvimento com CakePHP 1.2, são pequenos erros que levam a fazer isso, para solucionar os mesmos normalmente é simples, porém vou buscar descrever aqui onde a maioria pode ocorrer:</p>
<h3>Database Config</h3>
<p>No <code>config/database.php</code>, onde definimos a conexão a base de dados do CakePHP, é possível definir nomes de atributos que serão os nomes do tipo de conexão a base de dados.</p>
<p>Exemplo:</p>

<div class="wp_codebox"><table><tr id="p58456"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p584code56"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> DATABASE_CONFIG <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'driver'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mysql'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'persistent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'host'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'login'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'database'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'abccc'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'encoding'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'utf8'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>O importante aqui é definir o hash enconding no array do attributo da sua configuração de banco, no caso foi definido utf8 (sem o hífen).</p>
<h3>Aplicação Charset</h3>
<p>No arquivo <code>config/core.php</code>, existe a configuração de encoding a ser definida para aplicação:</p>

<div class="wp_codebox"><table><tr id="p58457"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p584code57"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Application wide charset encoding
 */</span>
	Configure<span style="color: #339933;">::</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'App.encoding'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Sete nela o mesmo encode que você está usando ao longo da aplicação.</p>
<h3>Charset do HTML</h3>
<p>Outro local que definimos o encode da aplicação agora no caso o encode do HTML, é no helper Html, no layout verificar o:</p>

<div class="wp_codebox"><table><tr id="p58458"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p584code58"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Por padrão o arquivo <code>views/layouts/default.ctp</code> já contei a impressão do meta charset, e não é necessário passar parâmetro para o mesmo, visto que já foi definido no <code>config/core.php</code> o encoding default da aplicação, logo o HtmlHelper pega o que foi definido no <code>config/core.php</code>. </p>
<p>Se o seu arquivo de layout não contem a sua adição pode ser necessária.</p>
<h3>Database</h3>
<p>Por último se continuar ainda com problemas de encoding, é necessário verificar seu banco de dados criado, verifique se o mesmo está setado com o encode esperado, assim como as tabelas e os atributos do tipo string estão também usando o mesmo encode.</p>
<h3>Files</h3>
<p>Outra verificação a ser feita é o encode dos arquivos, vale lembrar que os arquivos PHP devem estar no mesmo encode do resto da aplicação, para verificar isso no linux você pode usar o comando file: <code>file arquivo.php</code>, ele irá enformar o encode do arquivo, caso esteja errado converta o arquivo para o encode correto.</p>
<p>Esses processos são triviais ao longo do desenvolvimento com o CakePHP, e para aqueles que estão com algum problema provavelmente, algum desses processos descritos devem estar levando a sua aplicação CakePHP a apresentar esse tipo de error.</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2009/08/cakephp-1-2-problemas-de-encode-utf-8-iso-8859-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Facilitar a configuração de projetos PHP</title>
		<link>http://cobaia.net/2009/07/facilitar-a-configuracao-de-projetos-php/</link>
		<comments>http://cobaia.net/2009/07/facilitar-a-configuracao-de-projetos-php/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 17:08:26 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=580</guid>
		<description><![CDATA[Resolvi criar um simples script para facilitar a configuração de projetos PHP, a cada vez que eu ia começar 1, era necessário eu criar um novo virtual host, adicionar no hosts o alias do ip, restartar apache, etc&#8230; Então fiz um script simples, realmente simples em PHP para executar por linha de comando PHP-CLI, vou [...]]]></description>
			<content:encoded><![CDATA[<p>Resolvi criar um simples script para facilitar a configuração de projetos PHP, a cada vez que eu ia começar 1, era necessário eu criar um novo virtual host, adicionar no hosts o alias do ip, restartar apache, etc&#8230;</p>
<p>Então fiz um script simples, realmente simples em PHP para executar por linha de comando PHP-CLI, vou deixar a disposição para alguém que queria:</p>
<p>create-project.php</p>

<div class="wp_codebox"><table><tr id="p58060"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p580code60"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * Template of virtual host
	 */</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;VirtualHost *:80&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;ServerName <span style="color: #006699; font-weight: bold;">{$argv[1]}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DocumentRoot <span style="color: #006699; font-weight: bold;">{$argv[2]}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;directory <span style="color: #006699; font-weight: bold;">{$argv[2]}</span>&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;	Options Indexes FollowSymLinks MultiViews<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;	AllowOverride All<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$tempalte</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;	Order allow,deny<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;	allow from all<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/directory&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;ErrorLog /var/log/apache2/<span style="color: #006699; font-weight: bold;">{$argv[1]}</span>_error.log<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;   LogLevel warn<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;    CustomLog /var/log/apache2/<span style="color: #006699; font-weight: bold;">{$argv[1]}</span>_access.log combined<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>        
	<span style="color: #000088;">$template</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$template</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/etc/apache2/sites-available/<span style="color: #006699; font-weight: bold;">{$argv[1]}</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'x'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$template</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ln -s /etc/apache2/sites-available/<span style="color: #006699; font-weight: bold;">{$argv[1]}</span> /etc/apache2/sites-enabled/<span style="color: #006699; font-weight: bold;">{$argv[1]}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/etc/hosts&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a+'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;127.0.0.1 <span style="color: #006699; font-weight: bold;">{$argv[1]}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/etc/init.d/apache2 restart'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Created with success the config for: '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Para usar basta executar como root:</p>
<pre>
sudo php create-project.php nome_projeto /var/diretorio/
</pre>
<p>E pronto, ele criara o vhost, insere no hosts o alias, aponta o vhost para o diretório indicado e restarta o apache.</p>
<p>Ele funciona no Ubuntu linux, não testei em outras distros, e provavelmente possa não funcionar.</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2009/07/facilitar-a-configuracao-de-projetos-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.2 Validação de formulários sem Modelos</title>
		<link>http://cobaia.net/2009/07/cakephp-1-2-validacao-de-formularios-sem-modelos/</link>
		<comments>http://cobaia.net/2009/07/cakephp-1-2-validacao-de-formularios-sem-modelos/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 22:12:23 +0000</pubDate>
		<dc:creator>Vinícius Krolow</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programação]]></category>

		<guid isPermaLink="false">http://cobaia.net/?p=576</guid>
		<description><![CDATA[No CakePHP, as regras de definições são definidas nos modelos, então como fazemos quando queremos gerar um formulário, porém esse formulário não necessariamente vai ser salvo em um banco de dados, logo não tem modelo. Para fazer isso na verdade criamos um modelo, esse modelo usamos como citado no post anterior. Ou seja, um modelo [...]]]></description>
			<content:encoded><![CDATA[<p>No CakePHP, as regras de definições são definidas nos modelos, então como fazemos quando queremos gerar um formulário, porém esse formulário não necessariamente vai ser salvo em um banco de dados, logo não tem modelo.</p>
<p>Para fazer isso na verdade criamos um modelo, esse modelo usamos como citado no <a href="http://cobaia.net/2009/07/cakephp-model-sem-tabela/">post anterior</a>. Ou seja, um modelo sem tabela.</p>
<p>Vamos por em prática com um caso de um formulário de contato:</p>
<h3>Criando o modelo, sem tabela no CakePHP</h3>
<p>file contact.php</p>

<div class="wp_codebox"><table><tr id="p57664"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p576code64"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$useTable</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$validate</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'notEmpty'</span><span style="color: #339933;">,</span> 
						<span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Can't be empty the field name&quot;</span><span style="color: #339933;">,</span>
						<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'email'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span>
						 <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Put a email valid&quot;</span><span style="color: #339933;">,</span>
						<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'notEmpty'</span><span style="color: #339933;">,</span> 
						<span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Can't be empty the field message&quot;</span><span style="color: #339933;">,</span>
						<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Definidos três campos a serem validados, name, email e message.</p>
<p>Agora na view:</p>

<div class="wp_codebox"><table><tr id="p57665"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p576code65"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contact'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'/contact/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #339933;">&lt;</span>fieldset<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #339933;">&lt;/</span>fieldset<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Send'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Criamos o form usando nosso modelo, onde guardamos a regra de validação, e mandamos imprimir os campos.</p>
<p>No controller:</p>

<div class="wp_codebox"><table><tr id="p57666"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p576code66"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> ContactController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Contact'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$uses</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contact'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</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: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Contact</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</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;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Contact</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//send mail</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Pronto usamos o modelo para validar os campos de formulário antes de fazermos nosso envio do email de contato.</p>
]]></content:encoded>
			<wfw:commentRss>http://cobaia.net/2009/07/cakephp-1-2-validacao-de-formularios-sem-modelos/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

