<?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>Pau Gay &#187; desarrollo</title>
	<atom:link href="http://paugay.com/blog/category/desarrollo/feed" rel="self" type="application/rss+xml" />
	<link>http://paugay.com/blog</link>
	<description>eres lo que haces, no lo que dices</description>
	<lastBuildDate>Mon, 14 Nov 2011 00:11:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to name interfaces / abstract classes with namespaces</title>
		<link>http://paugay.com/blog/2011/11/name-interfaces-abstract-classes-namespaces.html</link>
		<comments>http://paugay.com/blog/2011/11/name-interfaces-abstract-classes-namespaces.html#comments</comments>
		<pubDate>Mon, 14 Nov 2011 00:11:12 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=466</guid>
		<description><![CDATA[I&#8217;m building a new library with the aim to parse venues from Internet (code on Github). Well, aside from the purpose or usage of the library I&#8217;m using this project development to try to write the domain oriented code and by the way I&#8217;m facing some arquitectural problems. Basically, in the past the most common [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m building a new library with the aim to parse venues from Internet (<a href="https://github.com/paugay/venues">code on Github</a>). Well, aside from the purpose or usage of the library I&#8217;m using this project development to try to write the domain oriented code and by the way I&#8217;m facing some arquitectural problems.</p>
<p>Basically,<strong> in the past</strong> the most common convention for naming interfaces or abstract classes was the following:</p>
<p>For the interface (lib/domain/venue/interface.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">interface</span> venues_domain_venue_interface <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/domain/venue/abstract.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> venues_domain_venue_abstract <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, I want to port this code to <strong>PHP 5.3 Namespace</strong> format. The translation is not that direct, note that &#8220;abstract&#8221; and &#8220;interface&#8221; are reserver keywords and I can not use then to name my clases.</p>
<p>For the interface (lib/Domain/Venue/Interface.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span> <span style="color: #000000; font-weight: bold;">Interface</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/Domain/Venue/Abstract.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> Abstract <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>That will simply break with a PHP Parse Error because the &#8220;Interface&#8221; or &#8220;Abstract&#8221; are reserver keywords.</p>
<p>Researching on Internet I&#8217;ve found the following options:</p>
<p>&nbsp;</p>
<p><strong>1. Prepend the domain name</strong></p>
<p>For the interface (lib/Domain/Venue/VenueInterface.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span> VenueInterface <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/Domain/Venue/VenueAbstract.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> VenueAbstract <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p><strong>2. Append the domain name</strong></p>
<p>For the interface (lib/Domain/Venue/InterfaceVenue.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span> InterfaceVenue <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/Domain/Venue/AbstractVenue.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> AbstractVenue <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p><strong>3. Prepending &#8220;I&#8221; or &#8220;A&#8221;</strong></p>
<p>For the interface (lib/Domain/Venue/IVenue.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span> IVenue <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/Domain/Venue/AVenue.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> AVenue <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p><strong>4. Append &#8220;Class&#8221;</strong></p>
<p>For the interface (lib/Domain/Venue/InterfaceClass.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">interface</span> InterfaceClass <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for the abstract (lib/Domain/Venue/VenueClass.php):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Venues\Domain\Venue<span style="color: #339933;">;</span>
&nbsp;
abstract <span style="color: #000000; font-weight: bold;">class</span> VenueClass <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p><strong>References:</strong></p>
<ul>
<li><a href="http://stackoverflow.com/questions/1150098/naming-of-interfaces-abstract-classes-in-php-5-3-using-namespaces">Naming of interfaces/abstract classes in PHP 5.3 (using namespaces)</a></li>
<li><a href="http://framework.zend.com/wiki/display/ZFPROP/Naming+conventions+for+2.0+-+Matthew+Ratzloff">Zend Framework: Naming conventions for 2.0 &#8211; Matthew Ratzloff Component Proposal</a></li>
<li><a href="http://news.php.net/php.standards/2">PHP Standards and Best Practices for PHP 5.3+ Frameworks and Libraries</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2011/11/name-interfaces-abstract-classes-namespaces.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Facebook access_token</title>
		<link>http://paugay.com/blog/2011/11/get-facebook-access_token.html</link>
		<comments>http://paugay.com/blog/2011/11/get-facebook-access_token.html#comments</comments>
		<pubDate>Wed, 02 Nov 2011 22:53:05 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=452</guid>
		<description><![CDATA[I&#8217;m going to try to document the experience of creating an access_token so my app. can post messages on my Facebook Page. As a summary, I have the following elements: 1) Facebook Page This is the Doonish Facebook Page. It&#8217;s a page that describes the project and that try to get as many fans as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to try to document the experience of creating an <strong>access_token</strong> so my app. can post messages on my Facebook Page. As a summary, I have the following elements:</p>
<p><strong>1) Facebook Page</strong></p>
<blockquote><p>This is the <a href="http://www.facebook.com/pages/Doonish/152266824798004">Doonish Facebook Page</a>. It&#8217;s a page that describes the project and that try to get as many fans as possible.</p></blockquote>
<p><strong>2) Facebook Application</strong></p>
<blockquote><p>In the other side I&#8217;ve created an application for allowing the remote post to my page. This is application that will do that.</p></blockquote>
<p>What I want to do is promote each day a new question from doonish into my <a href="http://www.facebook.com/pages/Doonish/152266824798004">Doonish Facebook Page</a>.</p>
<p>&nbsp;</p>
<h2>How to automatically post in a Facebook Page?</h2>
<p><strong>1) Get application &#8220;access_token&#8221;</strong></p>
<p>The first step is to get application &#8220;token_id&#8221; so we can post to the Facebook Page.</p>
<blockquote>
<pre>https://www.facebook.com/dialog/oauth?</pre>
<pre>    client_id=<strong>{facebook-app-id}</strong>&amp;</pre>
<pre>    redirect_uri=<strong>{your-url}</strong>&amp;</pre>
<pre>    scope=manage_pages&amp;</pre>
<pre>    response_type=token</pre>
</blockquote>
<p>That will return with something like the following:</p>
<blockquote>
<pre>access_token=<strong>{your-access-token}</strong></pre>
</blockquote>
<p><strong>2) Find the page &#8220;access_token&#8221;</strong></p>
<p>Then, using the above token, you can go to the following location:</p>
<blockquote>
<pre>https://graph.facebook.com/me/accounts?</pre>
<pre>    access_token=<strong>{your-access-token}</strong></pre>
</blockquote>
<p>And you will see something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">{
    &quot;data&quot;: [
    {
        &quot;name&quot;: &quot;{your-page}&quot;,
        &quot;access_token&quot;: &quot;{page-token-id}&quot;,
        &quot;category&quot;: &quot;Website&quot;,
        &quot;id&quot;: &quot;{page-id}&quot;
    },
    ...
    ]
}</pre></div></div>

<p><strong>3) Write the actual script</strong></p>
<p>Whith the above &#8220;<strong>page-token-id</strong>&#8221; you can then write a PHP snippet that can do something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Promote
 *
 * This method will automatically post a message on the facebook wall.
 *
 * @param integer $questionId The id of the question that we want to 
 *     promte.
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> promote<span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionId</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generateMessage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$questionId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span>
        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'appId'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'app_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'scope'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'scope'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cookie'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'acceptUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'acceptUrl'</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/feed'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'access_token'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebookConfig</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'cb'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">','</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Hope this code is useful for someone, it took me a while to figure out the right way to do it. I&#8217;ve used <a href="http://developers.facebook.com/docs/reference/php/">Facebook PHP SDK</a> and I&#8217;ve got all the information from the <a href="http://developers.facebook.com/docs/authentication/">Authentication</a> page from Facebook Developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2011/11/get-facebook-access_token.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>doonish: Status update</title>
		<link>http://paugay.com/blog/2011/07/doonish-status-update.html</link>
		<comments>http://paugay.com/blog/2011/07/doonish-status-update.html#comments</comments>
		<pubDate>Sat, 02 Jul 2011 22:09:47 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[doonish]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=428</guid>
		<description><![CDATA[Llevo un tiempo dedicando esfuerzo a doonish.es, el juego de preguntas y respuestas basado en Trivial Pursuit y ahora me he dado cuenta de que he dejado un poco abandonado el blog. Tan solo resumir un poco lo que he estado movido entre manos durante estos últimos meses: 1) Trato especial a los usuarios que [...]]]></description>
			<content:encoded><![CDATA[<p>Llevo un tiempo dedicando esfuerzo a doonish.es, el <a href="http://doonish.es">juego de preguntas y respuestas</a> basado en Trivial Pursuit y ahora me he dado cuenta de que he dejado un poco abandonado el blog.</p>
<p>Tan solo resumir un poco lo que he estado movido entre manos durante estos últimos meses:</p>
<p><strong>1) Trato especial a los usuarios que vienen de Google</strong></p>
<p>Nos dimos cuenta de que nos llegan algunas visitas de Google y antiguamente si el usuario hacía click en nuestra página entraba directamente a la página de la pregunta. Ahora no, ahora si el usuario no tiene cookies (no es un usuario que conocemos) se le muestra directamente la respuesta. Esto lo hacemos porque entendemos que en este caso concreto el usuario quiere conocer la respuesta a la pregunta, así que intentamos satisfacer de algún modo su necesidad.</p>
<p><em>Ejemplo:</em> <a href="http://doonish.es/pregunta/cual-es-la-capital-de-alaska">¿Cuál es la capital de Alaska?</a></p>
<p>Esto es lo que ve un usuario que conocemos:</p>
<p style="text-align: center;"><a href="http://doonish.es/img/blog/doonish-question-cookie.png"><img class="aligncenter" title="Doonish - Usuario con cookie" src="http://doonish.es/img/blog/doonish-question-cookie.png" alt="" width="451" height="379" /></a></p>
<p>Esto es lo que ve un usuario que no conocemos y que viene de google:</p>
<p style="text-align: center;"><a href="http://doonish.es/img/blog/doonish-question-no-cookie.png"><img class="aligncenter" title="Doonish - Usuario sin cookie" src="http://doonish.es/img/blog/doonish-question-no-cookie.png" alt="" width="446" height="301" /></a></p>
<p><strong>2) Ya tenemos SEO</strong></p>
<p>Salió sin buscarlo. Me estuve intercambiando algunos correos con <a href="http://www.tecnoretales.com/">Manel Pérez</a>. Aproveché nuestro buen trato y sus grandes conocimiento (trabaja en el departamento de SEO de <a href="http://softonic.com">Softonic</a>) para preguntarle algunas dudas sobre  SEO. Fuimos charlando y al final vimos que había interés por ambas partes de que se incorporara al equipo de doonish. Ya tenéis la información en la página de &#8220;<a href="http://doonish.es/sobre-nosotros">Sobre nosotros</a>&#8221; de doonish.</p>
<p><a href="http://doonish.es/img/blog/doonish-about-us.png"><img class="aligncenter" title="Doonish - sobre nosotros" src="http://doonish.es/img/blog/doonish-about-us.png" alt="" width="450" height="327" /></a></p>
<p><strong>3) API</strong></p>
<p>En un tiempo récord he escrito una API para doonish. Es muy sencilla pero permite a desarrolladores acceder a la base de datos de preguntas de doonish. De momento no tengo muy claro como enfocarlo y la he hecho privada. Si a alguien le interesa aquí dejo cinco céntimos sobre mas o menos que endpoinds se han habilitado:</p>
<div><em>question.json</em></div>
<div>
<ul>
<li><strong>http://doonish.es/api/question.json</strong></li>
</ul>
</div>
<div><em>question/[CATEGORY].json</em></div>
<ul>
<li><strong>http://doonish.es/api/question/cine.json</strong></li>
<li><strong>http://doonish.es/api/question/corazon-y-famosos.json</strong></li>
</ul>
<div><em>categories.json</em></div>
<div>
<ul>
<li><strong>http://doonish.es/api/categories.json</strong></li>
</ul>
</div>
<div>Esto en principio va a permitir a otros desarrolladores jugar con nuestra base de datos. De momento la API es privada por lo que no se puede ver el contenido, adjunto una imagen para que os hagáis una idea.</div>
<div></div>
<div><a href="http://doonish.es/img/blog/doonish-api.png"><img class="aligncenter" title="Doonish - API" src="http://doonish.es/img/blog/doonish-api.png" alt="" width="448" height="124" /></a></div>
<div>&#8211;</div>
<div>Y bueno, todo esto lo acompaño con <strong>más de 2000 pregunta</strong>s y ya <strong>casi 500 usuarios</strong>. Como decimos en Catalán: &#8220;<em>mica en mica s&#8217;omple la pica</em>&#8221; :) !</div>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2011/07/doonish-status-update.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configurar l&#8217;idioma Català a Linux</title>
		<link>http://paugay.com/blog/2010/07/configurar-lidioma-catala-a-linux.html</link>
		<comments>http://paugay.com/blog/2010/07/configurar-lidioma-catala-a-linux.html#comments</comments>
		<pubDate>Fri, 30 Jul 2010 16:11:40 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=388</guid>
		<description><![CDATA[Estic fent algunes probes per a mostrar les dates a PHP en Català. Al meu servidor local tot funcionava correctament, pero al passar-ho al servidor remot ha deixat de funcionar. El codi font es el següent (en PHP): setlocale&#40;LC_ALL, $lang . &#34;_ES.UTF-8&#34;&#41;; echo strftime&#40;&#34;%A %e de %B del %Y a &#34; . $translate-&#38;gt;_&#40;&#34;las&#34;&#41; . &#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Estic fent algunes probes per a mostrar les dates a PHP en Català. Al meu servidor local tot funcionava correctament, pero al passar-ho al servidor remot ha deixat de funcionar.</p>
<p>El codi font es el següent (en PHP):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">setlocale</span><span style="color: #009900;">&#40;</span>LC_ALL<span style="color: #339933;">,</span> <span style="color: #000088;">$lang</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;_ES.UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">strftime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%A <span style="color: #009933; font-weight: bold;">%e</span> de %B del %Y a &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$translate</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;las&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; %H:%M&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En castellà funcionaba correctament, pero al passar-ho al català no funciona.</p>
<p>Per a que funcioni, he hagut de fer la següent modificació: Obrir el fitxer <strong>/var/lib/locales/supported.d/local</strong> i afegir la darrera línea.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">es_ES<span style="color: #339933;">.</span>UTF<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span> UTF<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span>
ca_ES<span style="color: #339933;">.</span>UTF<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span> UTF<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span></pre></div></div>

<p>Despres de desar el fitxer, he executat la següent comanda:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">sudo dpkg<span style="color: #339933;">-</span>reconfigure locales</pre></div></div>

<p>I ja ha funcionat, ja puc veure la data tant en català com en castellà :) !</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2010/07/configurar-lidioma-catala-a-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterar sobre array en PHP y Javascript</title>
		<link>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html</link>
		<comments>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html#comments</comments>
		<pubDate>Wed, 26 May 2010 13:00:28 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/blog/?p=368</guid>
		<description><![CDATA[¡Porfin lo encontré! En PHP hacemos el típico foreach: foreach&#40;$array as $key =&#38;gt; $value&#41; &#123; echo &#34;clave = &#34; + $key; echo &#34;valor = &#34; + $value; &#125; Y en Javascript también se puede hacer del siguiente modo: for&#40;i in array&#41; &#123; alert&#40;&#34;clave = &#34; + i&#41;; alert&#40;&#34;value = &#34; + array&#91;i&#93;&#41;; &#125;]]></description>
			<content:encoded><![CDATA[<p>¡Porfin lo encontré!</p>
<p>En <strong>PHP</strong> hacemos el típico foreach:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;clave = &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;valor = &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y en <strong>Javascript</strong> también se puede hacer del siguiente modo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> array<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;clave = &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;value = &quot;</span> <span style="color: #339933;">+</span> array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2010/05/iterar-array-php-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Por qué Zend Framework?</title>
		<link>http://paugay.com/blog/2009/12/por-que-zend-framework.html</link>
		<comments>http://paugay.com/blog/2009/12/por-que-zend-framework.html#comments</comments>
		<pubDate>Sat, 26 Dec 2009 09:24:56 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=290</guid>
		<description><![CDATA[El otro día recibí un comentario de un lector de mi blog y me preguntaba: Pau, por que  Zend Framework? Vi que hace un tiempo habías hecho un post sobre CakePHP. Voy a dar la respuesta a este comentario en forma de post. Es cierto que había escrito un post sobre CakePHP. Un amigo (Xavier [...]]]></description>
			<content:encoded><![CDATA[<p>El otro día recibí un comentario de un lector de mi blog y me preguntaba:</p>
<blockquote><p><strong>Pau, por que  Zend Framework? Vi que hace un tiempo habías hecho un post sobre CakePHP.</strong></p></blockquote>
<p>Voy a dar la respuesta a este comentario en forma de post. Es cierto que había escrito un post sobre <a href="http://cakephp.org/">CakePHP</a>. Un amigo (<a href="http://www.alcim.net/">Xavier Orduña</a>) me lo presentó y lo probé. Entonces aún no conocí­a ningún framework de desarrollo y, al topar por primera vez con Cake, me pareció una manera muy rápida de agilizar el desarrollo de una aplicación web.</p>
<p>Un tiempo más tarde, y sin haber profundizado con Cake, probé <a href="http://framework.zend.com/">Zend Framework</a>. También me lo recomendó otro amigo (<a href="http://twitter.com/ccossio">Claudio Cossio</a>) y tengo que confesar que me gustó más que Cake.</p>
<p style="text-align: center;"><img class="aligncenter" title="zf" src="http://dev.juokaz.com/wp-content/uploads/2009/04/logo-zend-framework.jpg" alt="" width="137" height="92" /></p>
<p>Ya llevo un tiempo desarrollando con Zend y después de un par de proyectos, puedo sacar <strong>las siguientes conclusiones</strong>. Antes advierto que no soy un experto en frameworks, he tocado mas o menos en profundidad Zend, he jugado con CakePHP y Django (para Python) y me han hablado muy bien de Symphony, así que ya aviso que mi punto de vista va a estar desviado.</p>
<ol>
<li><strong>Documentación correcta:</strong> Acostumbro a consultar su documentación a menudo y está bastante bien, con ejemplos bastante bien explicados y sobretodo prácticos.</li>
<li><strong>Sencillo</strong>: Es relativamente sencillo de montar una aplicación básica con Zend Framework. Si luego quieres ir un poco más allá ya en cuanto a complejidad, ya vas a tener que mirarte la documentación.</li>
<li><strong>Completitud de módulos</strong>: Tiene módulos para casi todo. Una vez empiezas a programar con él, cada vez que revisas los módulos encuentras alguno que te va a ser útil.</li>
<li><strong>Zend está detrás</strong>: El hecho de que Zend, la compañía que desarrolla PHP está detrás de este framework me da una cierta seguridad de que será mantenido y que dará soporte por mucho tiempo.</li>
<li><strong>Patrones de base de datos:</strong> Me encanta el patrón de diseño que usa ZF para acceso a la base de datos: <em>Table Data Gateway</em> y <em>Row Data Gateway</em>. Me imagino que la mayoría de frameworks deben usar cosas parecidas, pero la manera en que lo resuelve Zend Framework es especialmente cómoda para el programador.</li>
</ol>
<p>Por último, cito las palabras del amigo <a href="http://blog.carlosbuenosvinos.com/">Carlos Buenosvinos</a> en una de las discusiones del <strong>Grupo de programadores PHP Barcelona</strong>, en respuesta a &#8220;<em>¿Qué framework PHP usáis?</em>&#8220;:</p>
<blockquote><p>Has de considerar, la comunidad, la continuidad, performance, si está basado en componentes o no (migrar o nueva aplicación desde 0), contenido en la red, libros (material didáctico), oferta de desarrolladores (en el caso de que quieras contratar), funcionalidades totales, funcionalidades que se adaptan a tus requerimientos, funcionalidades que le faltan para tu aplicación, si tienes desarrolladores en tu equipo que ya conozcan algún framework, soporte con PHP 5.3 (compatibilidad hacia atrás, sin compatibilidad, &#8230;), etc. No te dejes llevar por modas, como siempre, la respuesta es <strong>depende</strong>.</p></blockquote>
<p>Pues nada, saludos y disfruten de las vacaciones de navidad (quien las tenga!).</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/12/por-que-zend-framework.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resumen de iWeekend Barcelona 09</title>
		<link>http://paugay.com/blog/2009/11/resumen-de-iweekend-barcelona-09.html</link>
		<comments>http://paugay.com/blog/2009/11/resumen-de-iweekend-barcelona-09.html#comments</comments>
		<pubDate>Tue, 24 Nov 2009 19:48:40 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[emprendedores]]></category>
		<category><![CDATA[eventos]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=286</guid>
		<description><![CDATA[Este pasado fin de semana he tenido la oportunidad de asistir a iWeekend Barcelona. El evento se ha celebrado en Barcelona Activa y ha agrupado a más de 50 emprendedores que se han repartido para tirar adelante 4 proyectos. En mi opinión, la fase de selección de proyectos es una de las partes más interesantes [...]]]></description>
			<content:encoded><![CDATA[<p>Este pasado fin de semana he tenido la oportunidad de asistir a <a href="http://iweekend.org">iWeekend</a> Barcelona. El evento se ha celebrado en Barcelona Activa y ha agrupado a más de 50 emprendedores que se han repartido para tirar adelante 4 proyectos.</p>
<p style="text-align: center;"><a href="http://iweekend.org"><img class="alignnone" title="iweekend" src="http://www.jordiperez.cat/wp-content/uploads/2009/11/iw_bcn.png" alt="" width="506" height="320" /></a></p>
<p>En mi opinión, la fase de selección de proyectos es una de las partes más interesantes de iWeekend. Los emprendedores proponen la idea y tienen que seducir a los asistentes para atraer los recursos que la desarrolladán durante el fin de semana.</p>
<p>A continuación describo los proyectos que se han llevado a cabo durante este di</p>
<ul>
<li><a href="http://vox-populi.es/">Vox Populi</a>: Sistema de recolección y gestión de incidencias para ayuntamientos via móvil</li>
<li><a href="http://partidodeinternet.es/">Partido de Internet</a>: Movimiento democrático que se constituye como partido político para regenerar la democracia</li>
<li><a href="http://www.goodbuyamigo.com/">GoodBuyAmigo</a>: Plataforma donde pedir consejo a tus amigos antes de hacer una compra online</li>
<li><a href="http://alertas.de/">alertas.de</a> Servicio de alertas al móvil, correo electrónico y redes sociales a partir de unas preferencias especificadas</li>
</ul>
<p>He formado parte del <a href="http://alertas.de/about.php">equipo</a> que ha desarrollado <strong>alertas.de</strong>, junto con <a href="http://www.miguelflorido.net/">Miguel Florido</a> y <a href="http://santiago.lizardo.info">Santiago Lizardo</a>. Hemos tenido la mala suerte de no poder formar parte de un grupo multidisciplinar, pero que nos ha permitido tirar adelante el proyecto con mucha agilidad.</p>
<p><img class="aligncenter" title="alertas-de" src="http://iweekend.org/wp-content/uploads/2009/11/alertas-450x299.jpg" alt="" width="450" height="299" /></p>
<p style="text-align: center;"><em>De izquierda a derecha: Santiago, Pau y Miguel</em></p>
<p>En el otro lado del charco, nuestro estimado socio y amigo <a href="http://twitter.com/ccossio">Claudio Cossio</a> ha promovido el <a href="http://www.maestrosdelweb.com/actualidad/iweekend-mexico/">iWeekend en México</a> obteniendo un éxito rotundo, tanto de asistencia como de repercusión en toda latinoamerica. <strong>¡Enhorabuena!</strong></p>
<p>&#8211;</p>
<p><em>Notas:</em></p>
<ul>
<li>He recopilado algunos post con <a href="http://opinionesde.com/iweekend">opiniones del iWeekend</a>.</li>
<li>En Barcelona Activa me encontré con los chicos de <a href="http://eventuo.com">Eventuo</a>, hacía ya un tiempo que no nos veíamos y hemos dicho de quedar para comer para ponernos al día.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/11/resumen-de-iweekend-barcelona-09.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Conference 2009</title>
		<link>http://paugay.com/blog/2009/10/php-conference-2009.html</link>
		<comments>http://paugay.com/blog/2009/10/php-conference-2009.html#comments</comments>
		<pubDate>Thu, 15 Oct 2009 07:58:29 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[eventos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=280</guid>
		<description><![CDATA[La gente de PHP Barcelona se han animado, como cada año, a montar una la PHP Conference 2009, una conferéncia relacionada con PHP que se celebrará el 30 y 31 de Octubre en el Citilab, en Cornellà. Como podéis ver, el planning parece muy interesante. Seguramente asistiré, como mínimo el sábado. Para los amantes del [...]]]></description>
			<content:encoded><![CDATA[<p>La gente de <a href="http://http://phpbarcelona.org/">PHP Barcelona</a> se han animado, como cada año, a montar una la <a href="http://phpconference.es/">PHP Conference 2009</a>, una conferéncia relacionada con PHP que se celebrará el <strong>30 y 31 de Octubre</strong> en el <a href="http://citilab.eu/inici">Citilab</a>, en Cornellà. Como podéis ver, el <a href="http://phpconference.es/barcelona-php-conference-2009/schedule/">planning</a> parece muy interesante.</p>
<p style="text-align: center;"><img class="aligncenter" title="php conference 09 logo" src="http://phpbarcelona.org/files/logos/PHPBarcelona_Logo002.png" alt="" width="500" height="99" /></p>
<p>Seguramente asistiré, como mínimo el sábado. Para los amantes del Facebook han creado el evento. Si os habéis decidido a venir apuntaros e invitar a todos vuestros colegas.</p>
<blockquote><p><a rel="nofollow" href="http://www.facebook.com/event.php?eid=150863109670" target="_blank">http://www.facebook.com/event.php?eid=150863109670</a></p></blockquote>
<p>De cara a la promoción podéis seguir también a su twitter:</p>
<blockquote><p><a rel="nofollow" href="http://twitter.com/phpbarcelona" target="_blank">http://twitter.com/phpbarcelona</a></p></blockquote>
<p>Han empezado a usar el topic <strong>#phpbcn2009</strong> si alguno se anima a hablar de la conference usándolo más promoción para el evento de una manera sana y gratuita.</p>
<p>¡Espero veros ahí!</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/10/php-conference-2009.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>API de Google Translate</title>
		<link>http://paugay.com/blog/2009/05/api-google-translate.html</link>
		<comments>http://paugay.com/blog/2009/05/api-google-translate.html#comments</comments>
		<pubDate>Sat, 09 May 2009 09:26:06 +0000</pubDate>
		<dc:creator>Pau Gay</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://paugay.com/?p=222</guid>
		<description><![CDATA[Esta mañana he jugado con la API de google translate. Ha sido bastante sencillo ya que hay muchos ejemplos en la web. En mi caso, tengo una aplicación bilingue donde los usuarios pueden escribir la descripción de un producto. La idea es que al cambiar de idioma se cambie el idioma de todo (incluido el [...]]]></description>
			<content:encoded><![CDATA[<p>Esta mañana he jugado con la <a href="http://code.google.com/intl/es-ES/apis/ajaxlanguage/documentation/">API de google translate</a>. Ha sido bastante sencillo ya que hay muchos ejemplos en la web.</p>
<p>En mi caso, tengo una aplicación bilingue donde los usuarios pueden escribir la descripción de un producto. La idea es que al cambiar de idioma se cambie el idioma de todo (incluido el texto insertado por el usuario).</p>
<p>Aquí os dejo el código de pruebas:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.google.com/jsapi&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    google.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;language&quot;</span>, <span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
    function translate<span style="color: #009900;">&#40;</span>source, dest<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        var div_source <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my_div_&quot;</span> <span style="color: #339933;">+</span> source<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        var div_dest <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my_div_&quot;</span> <span style="color: #339933;">+</span> dest<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        alert<span style="color: #009900;">&#40;</span>div_source.<span style="color: #006633;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        google.<span style="color: #006633;">language</span>.<span style="color: #006633;">translate</span><span style="color: #009900;">&#40;</span>div_source.<span style="color: #006633;">value</span>, source, dest, function<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            alert<span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">translation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>result.<span style="color: #006633;">error</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            div_dest.<span style="color: #006633;">value</span> <span style="color: #339933;">=</span> result.<span style="color: #006633;">translation</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</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: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Pues esto es todo.</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/05/api-google-translate.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JAVA Method: boolean isInteger()</title>
		<link>http://paugay.com/blog/2009/02/java-method-boolean-isinteger.html</link>
		<comments>http://paugay.com/blog/2009/02/java-method-boolean-isinteger.html#comments</comments>
		<pubDate>Thu, 05 Feb 2009 13:23:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programacion]]></category>

		<guid isPermaLink="false">http://root.elr1c.es/paugay/?p=100</guid>
		<description><![CDATA[Hoy tenía la necesidad de ver si un texto es un entero o no. He estado buscando un buen rato en google hasta que he dado con ella. Aquí os la dejo: private static boolean isDouble&#40;String str&#41; &#123; try &#123; double v = Double.parseDouble&#40;str&#41;; return true; &#125; catch&#40;NumberFormatException e&#41; &#123; return false; &#125; &#125; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy tenía la necesidad de ver si un texto es un entero o no. He estado buscando <span style="font-weight: bold;">un buen rato</span> en google hasta que he dado con ella. Aquí os la dejo:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isDouble<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">double</span> v <span style="color: #339933;">=</span> <span style="color: #003399;">Double</span>.<span style="color: #006633;">parseDouble</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">NumberFormatException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isInteger<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">int</span> v <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">NumberFormatException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It works! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://paugay.com/blog/2009/02/java-method-boolean-isinteger.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

