<?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>PicaTeclas &#187; código</title>
	<atom:link href="http://picateclas.net/posts/category/codigo/feed/" rel="self" type="application/rss+xml" />
	<link>http://picateclas.net</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 10:30:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Acelera la carga de wordpress activando la compresión</title>
		<link>http://picateclas.net/posts/acelera-la-carga-de-wordpress-activando-la-compresion/</link>
		<comments>http://picateclas.net/posts/acelera-la-carga-de-wordpress-activando-la-compresion/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 18:45:42 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[compresión]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=110</guid>
		<description><![CDATA[Acelerar la carga de tu blog (hecho con wordpress) activando la compresión "zlib", siempre que tu host lo soporte, es tan sencillo como añadir lo siguiente en el header.php de tu theme: &#60;?php ini_set('zlib.output_compression', 'On'); ini_set('zlib.output_compression_level', '1'); ?&#62; Esto permitirá que los datos se transmitan desde tu servidor hasta el navegador del visitante comprimidos, ahorrando [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_112" class="wp-caption aligncenter" style="width: 495px"><a href="http://picateclas.net/wp-content/uploads/2010/06/compresionwordpress.jpg"><img class="size-full wp-image-112 " title="compresionwordpress" src="http://picateclas.net/wp-content/uploads/2010/06/compresionwordpress.jpg" alt="Podéis observar la mejora en la cantidad de información transmitida al cargar una web..." width="485" height="416" /></a><p class="wp-caption-text">Podéis observar la mejora en la cantidad de información transmitida al cargar una web...</p></div>
<p style="text-align: left;">Acelerar la carga de tu blog (hecho con wordpress) activando la compresión "zlib", siempre que tu host lo soporte, es tan sencillo como añadir lo siguiente en el header.php de tu theme:</p>
<p><code lang="php"><br />
&lt;?php<br />
ini_set('zlib.output_compression', 'On');<br />
ini_set('zlib.output_compression_level', '1');<br />
?&gt;<br />
</code></p>
<p>Esto permitirá que los datos se transmitan desde tu servidor hasta el navegador del visitante comprimidos, ahorrando un tiempo de transmisión interesante. Para comprobar si tienes activado el soporte de zlib, puedes observar la salida de phpinfo en tu servidor. Y para comprobar si está funcionando la compresión, prueba la herramienta de <a href="http://www.port80software.com/support/p80tools.asp">Port80</a>.</p>
<p>Vía | <a href="http://www.wprecipes.com/compress-wordpress-output-and-speed-your-blogs-load-speed">WPRecipes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/acelera-la-carga-de-wordpress-activando-la-compresion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acceder a una variable de scriplet con JSTL (y viceversa)</title>
		<link>http://picateclas.net/posts/acceder-a-una-variable-de-scriplet-con-jstl-y-viceversa/</link>
		<comments>http://picateclas.net/posts/acceder-a-una-variable-de-scriplet-con-jstl-y-viceversa/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:08:13 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[jstl]]></category>
		<category><![CDATA[scriptlets]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=104</guid>
		<description><![CDATA[Aunque mezclar scriptlets y JSTL en las páginas JSP es una mala práctica (hace el código mucho más difícil de mantener), a veces es complicado de evitar tener que compartir variables entre código java incrustado en los JSP (scriptlets) y las etiquetas JSTL. Para poder compartir valores de variable entre ambos existe el contexto de [...]]]></description>
			<content:encoded><![CDATA[<p>Aunque mezclar <a href="http://java.sun.com/products/jsp/tags/11/syntaxref11.fm5.html">scriptlets</a> y <a href="http://java.sun.com/products/jsp/jstl/">JSTL</a> en las páginas JSP es una mala práctica (hace el código mucho más difícil de mantener), a veces es complicado de evitar tener que compartir variables entre código java incrustado en los JSP (scriptlets) y las etiquetas JSTL. Para poder compartir valores de variable entre ambos existe el contexto de la página:</p>
<h3>Acceder a una variable de un scriptlet con JSTL</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p104code6'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1046"><td class="code" id="p104code6"><pre class="java" style="font-family:monospace;">&lt;% String miVariable = &quot;Cadena&quot;; pageContext.setAttribute(&quot;miVariable&quot;, miVariable); %&gt;</pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p104code7'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1047"><td class="code" id="p104code7"><pre class="java" style="font-family:monospace;">&lt;c:out value=&quot;miVariable&quot;/&gt;</pre></td></tr></table></div>

<h3>Acceder a una variable de JSTL mediante scriptlets</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p104code8'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1048"><td class="code" id="p104code8"><pre class="java" style="font-family:monospace;">&lt;c:set var=&quot;miVariable&quot; value=&quot;Cadena&quot;/&gt;</pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p104code9'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1049"><td class="code" id="p104code9"><pre class="java" style="font-family:monospace;">&lt;%
String miVariable= (String)pageContext.getAttribute(&quot;miVariable&quot;);
out.print(miVariable);
%&gt;</pre></td></tr></table></div>

<p>Las variables usadas pueden ser objetos complejos, siempre que se importen mediante</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p104code10'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10410"><td class="code" id="p104code10"><pre class="java" style="font-family:monospace;">&lt;%@page import=&quot;paquete.nombre.de.la.clase&quot;%&gt;</pre></td></tr></table></div>

<p>Vía | <a href="http://www.melandri.net/2009/09/16/scriptlet-and-jstl-variable-sharing/">Alessandro Melandri</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/acceder-a-una-variable-de-scriplet-con-jstl-y-viceversa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtener el espacio ocupado por las bases de datos de MySQL</title>
		<link>http://picateclas.net/posts/obtener-el-espacio-ocupado-por-las-bases-de-datos-de-mysql/</link>
		<comments>http://picateclas.net/posts/obtener-el-espacio-ocupado-por-las-bases-de-datos-de-mysql/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 12:08:23 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[disco]]></category>
		<category><![CDATA[espacio]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=102</guid>
		<description><![CDATA[En The Arctel Journal tienen un pequeño y útil fragmento de código MySQL para obtener el espacio ocupado por los datos de las distintas bases de datos MySQL de un servidor: SELECT table_schema, count(*) TABLES, concat(round(sum(table_rows)/1000000,2),'M') rows,concat(round(sum(data_length)/(1024*1024*1024),2),'G') DATA,concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx,concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size,round(sum(index_length)/sum(data_length),2) idxfrac FROM information_schema.TABLES group by table_schema; O la versión en Mb y miles de filas [...]]]></description>
			<content:encoded><![CDATA[<p>En <a href="http://arcterex.net/blog/archives/2008/08/20/finding_mysql_table_disk_usage.html">The Arctel Journal</a> tienen un pequeño y útil fragmento de código MySQL para obtener el espacio ocupado por los datos de las distintas bases de datos MySQL de un servidor:</p>
<blockquote>
<pre><code><tt><tt>SELECT
   table_schema, count(*) TABLES,
   concat(round(sum(table_rows)/1000000,2),'M')
   rows,concat(round(sum(data_length)/(1024*1024*1024),2),'G')
   DATA,concat(round(sum(index_length)/(1024*1024*1024),2),'G')
   idx,concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G')
   total_size,round(sum(index_length)/sum(data_length),2) idxfrac
FROM
   information_schema.TABLES group by table_schema; </tt></tt></code></pre>
</blockquote>
<p>O la versión en Mb y miles de filas (en vez de GB y millones de filas):</p>
<blockquote><p>SELECT table_schema, count(  *   )<br />
TABLES , concat( round( sum( table_rows )  /1000, 2  ) ,  'K'  )<br />
ROWS , concat( round( sum( data_length )  /  ( 1024 *1024  ) , 2  ) ,  'Mb'  )<br />
DATA , concat( round( sum( index_length )  /  ( 1024 *1024  ) , 2  ) ,  'Mb'  ) idx, concat( round( sum( data_length +  index_length )  / ( 1024 *1024  ) , 2  ) ,  'Mb'  ) total_size, round( sum( index_length )  / sum( data_length ) , 2  ) idxfrac<br />
FROM information_schema.TABLES<br />
GROUP  BY table_schema;</p></blockquote>
<p>Para ejecutarlo podemos recurrir a PhpMyAdmin, alguna herramienta similar, ejecutar el comando mediante la consola o crear un pequeño script que lo ejecute y muestre los resultados en pantalla...</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/obtener-el-espacio-ocupado-por-las-bases-de-datos-de-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expresión regular para encontrar vídeos de YouTube en un texto</title>
		<link>http://picateclas.net/posts/expresion-regular-para-encontrar-videos-de-youtube-en-un-texto/</link>
		<comments>http://picateclas.net/posts/expresion-regular-para-encontrar-videos-de-youtube-en-un-texto/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 23:48:47 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[código]]></category>
		<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[expresión regular]]></category>
		<category><![CDATA[miniaturas]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[vídeos]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=98</guid>
		<description><![CDATA[Con la siguiente expresión regular podremos encontrar los identificadores de los vídeos que se encuentren en vídeos de youtube (tanto como links como si están incrustados): /youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)[&#38;\w;=\+_\-]*/ Esto permite extraer el identificador único del vídeo, que sirve para enlazarlo, incrustarlo u obtener su imagen. Por ejemplo, para obtener la URL de la imagen thumnail del [...]]]></description>
			<content:encoded><![CDATA[<p>Con la siguiente expresión regular podremos encontrar los identificadores de los vídeos que se encuentren en vídeos de youtube (tanto como links como si están incrustados):</p>
<p><code>/youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)[&amp;\w;=\+_\-]*/</code></p>
<p>Esto permite extraer el identificador único del vídeo, que sirve para enlazarlo, incrustarlo u obtener su imagen. Por ejemplo, para obtener la URL de la imagen thumnail del vídeo podremos usar:<br />
<code lang="php"><br />
preg_match('/youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)[&amp;\w;=\+_\-]*/',$texto);<br />
$img="http://i2.ytimg.com/vi/{$match[1]}/default.jpg";</code></p>
<p>Vía | <a title="View user profile." href="/user/147742">d0t101101</a> en el <a href="http://drupal.org/node/88192#comment-877835">Foro de Drupal</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/expresion-regular-para-encontrar-videos-de-youtube-en-un-texto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creación de un bot de twitter sencillo con PHP</title>
		<link>http://picateclas.net/posts/creacion-de-un-bot-de-twitter-sencillo-con-php/</link>
		<comments>http://picateclas.net/posts/creacion-de-un-bot-de-twitter-sencillo-con-php/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 01:12:50 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[código]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=94</guid>
		<description><![CDATA[Twitter tiene un API bastante sencillo sobre el cual se pueden desarrollar aplicaciones de un modo bastante fácil. Con unas pocas líneas podemos montar un bot de twitter que cada hora envíe un mensaje, como explico en BloqNum. $username = 'nombreDeLaCuenta'; $password = 'passwordDeLaCuenta'; date_default_timezone_set('Europe/Madrid'); $hora = date('g'); if ($hora == '1') $message = "Xa [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter <a href="http://apiwiki.twitter.com/">tiene un API bastante sencillo</a> sobre el cual se pueden desarrollar aplicaciones de un modo bastante fácil. Con unas pocas líneas podemos montar un bot de twitter que cada hora envíe un mensaje, como <a href="http://bloqnum.com/posts/la-torre-de-la-berenguela-te-da-la-hora-en-twitter/">explico en BloqNum</a>.</p>
<p><code lang="php"><br />
$username = 'nombreDeLaCuenta';<br />
$password = 'passwordDeLaCuenta';</code></p>
<p><code lang="php">date_default_timezone_set('Europe/Madrid');</p>
<p>$hora = date('g');</p>
<p>if ($hora == '1')<br />
$message = "Xa é a unha... ";<br />
else<br />
$message = "Xa son as ".$hora."... ";</p>
<p>for ($i = 0; $i &lt; $hora; $i++){<br />
$message .= 'TOLON! ';<br />
}</p>
<p>$url = 'http://twitter.com/statuses/update.xml';</p>
<p>$curl_handle = curl_init();<br />
curl_setopt($curl_handle, CURLOPT_URL, "$url");<br />
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);<br />
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($curl_handle, CURLOPT_POST, 1);<br />
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");<br />
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");<br />
$buffer = curl_exec($curl_handle);<br />
curl_close($curl_handle);</p>
<p>if (empty($buffer)) {<br />
echo '--error-'.$message;<br />
} else {<br />
echo '--exito-'.$message;<br />
}<br />
</code></p>
<p>Después, con un proceso de cron se automatiza la ejecución del cliente cada hora, para que se publique el mensaje cada 60 minutos. Este archivo enviará el mensaje cada vez que se visite, con lo cual si se quiere proteger habría que añadirle una contraseña o no ponerlo en una ruta accesible públicamente.</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/creacion-de-un-bot-de-twitter-sencillo-con-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mostrar un listado anidado de términos de taxonomía en Drupal</title>
		<link>http://picateclas.net/posts/mostrar-un-listado-anidado-de-terminos-de-taxonomia-en-drupal/</link>
		<comments>http://picateclas.net/posts/mostrar-un-listado-anidado-de-terminos-de-taxonomia-en-drupal/#comments</comments>
		<pubDate>Wed, 20 May 2009 09:45:22 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[terms]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=92</guid>
		<description><![CDATA[Buscando cómo mostrar un listado aninado de los términos (terms) de un vocabulario (una categoría de Drupal, o taxonomy), encontré este útil fragmento de código en Drupal.org. Para que funcione esto es necesario usar el módulo Taxonomy. ?Ver código PHP&#60;?php // El ID del vocabulario de la taxonomia del que queremos crear la lista de [...]]]></description>
			<content:encoded><![CDATA[<p>Buscando cómo mostrar un listado aninado de los términos (<em>terms</em>) de un vocabulario (una categoría de Drupal, o <em>taxonomy</em>), encontré <a href="http://drupal.org/node/223675#comment-900999">este útil fragmento de código</a> en Drupal.org. Para que funcione esto es necesario usar el módulo <a href="http://drupal.org/handbook/modules/taxonomy">Taxonomy</a>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p92code12'); return false;">Ver código</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9212"><td class="code" id="p92code12"><pre class="php" style="font-family:monospace;">&lt;?php
            // El ID del vocabulario de la taxonomia del que queremos crear la lista de terminos
            $vid = 10;
&nbsp;
            $depth = 0;
            $num_at_depth = 0;
            $tree = taxonomy_get_tree($vid);
&nbsp;
            print &quot;&lt;ul class=\&quot;menu\&quot;&gt;\n&lt;li&gt;&quot;;
            foreach ($tree as $term) {
            $diffdepth=0;
              if ($term-&gt;depth &gt; $depth) {
                print &quot;\n&lt;ul&gt;\n&lt;li&gt;&quot;;
                $depth = $term-&gt;depth;
                    $num_at_depth = 0;
              }
              if ($term-&gt;depth &lt; $depth) {
                $diffdepth= $depth -$term-&gt;depth;
                while ($diffdepth &gt; 0){
                    print &quot;&lt;/li&gt;\n&lt;/ul&gt;\n&quot;;
                    $diffdepth -- ; 
                }
                    $depth = $term-&gt;depth;
              }
              if (($term-&gt;depth == $depth) &amp;&amp; ($num_at_depth &gt; 0)) {
                  print &quot;&lt;/li&gt;\n&lt;li&gt;&quot;;
                }
              print l($term-&gt;name, 'taxonomy/term/' . $term-&gt;tid);
                $num_at_depth ++;
            }
            print &quot;&lt;/li&gt;\n&lt;/ul&gt;\n&quot;;
?&gt;</pre></td></tr></table></div>

<p>El crédito va al autor, <a href="http://drupal.org/user/219531">billyboylindien</a></p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/mostrar-un-listado-anidado-de-terminos-de-taxonomia-en-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reemplazo masivo en cadenas de texto con SQL</title>
		<link>http://picateclas.net/posts/reemplazo-masivo-en-cadenas-de-texto-con-sql/</link>
		<comments>http://picateclas.net/posts/reemplazo-masivo-en-cadenas-de-texto-con-sql/#comments</comments>
		<pubDate>Wed, 06 May 2009 15:16:09 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[administración]]></category>
		<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[actualizar]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=90</guid>
		<description><![CDATA[Actualizar muchas entradas de una base de datos que contengan un determinado texto puede ser tedioso (me refiero a programar algún script para que lo haga, porque hacerlo a mano seria digno del siglo XIX si hay muchos datos...). Así, para actualizar los registros de una tabla entera aplicando el patrón de reemplazo deseado, sólo [...]]]></description>
			<content:encoded><![CDATA[<div id="sql-1">
<div class="sql">Actualizar muchas entradas de una base de datos que contengan un determinado texto puede ser tedioso (me refiero a programar algún script para que lo haga, porque hacerlo a mano seria digno del siglo XIX si hay muchos datos...).</div>
<div class="sql">Así, para actualizar los registros de una tabla entera aplicando el patrón de reemplazo deseado, sólo habrá que utilizar una consulta SQL:</div>
<div class="sql">
<ol>
<li style="font-family: 'Courier New',Courier,monospace; font-weight: normal; font-style: normal; color: #3a6a8b;">
<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">UPDATE</span> table_name <span style="color: #993333; font-weight: bold;">SET</span> column_name = <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #006600; font-weight: bold;">(</span>column_name,<span style="color: #ff0000;">"original_string"</span>,<span style="color: #ff0000;">"replace_string"</span><span style="color: #006600; font-weight: bold;">);</span></div>
</li>
</ol>
</div>
<div class="sql">Un ejemplo de aplicación sería actualizar todos los links hacia un determinado host o URL de los posts de una base de datos de wordpress para que apunten a otro:</div>
<div class="sql">
<div id="sql-2">
<div class="sql">
<ol>
<li style="font-family: 'Courier New',Courier,monospace; font-weight: normal; font-style: normal; color: #3a6a8b;">
<div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`wp_posts`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`post_content`</span> = <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #006600; font-weight: bold;">(</span><span style="color: #ff0000;">`post_content`</span>,<span style="color: #ff0000;">"picateclas.com/directorioantiguo/"</span>,<span style="color: #ff0000;">"picateclas.com/nuevodirectorio"</span><span style="color: #006600; font-weight: bold;">)</span></div>
</li>
</ol>
</div>
</div>
<p>Vía | <a href="http://www.liewcf.com/blog/archives/2005/04/mass-replace-string-in-mysql-database/">LiewCF</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/reemplazo-masivo-en-cadenas-de-texto-con-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reemplazar saltos de línea (/n) de un textarea con JavaScript</title>
		<link>http://picateclas.net/posts/reemplazar-saltos-de-linea-n-de-un-textarea-con-javascript/</link>
		<comments>http://picateclas.net/posts/reemplazar-saltos-de-linea-n-de-un-textarea-con-javascript/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 07:41:10 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[saltos de línea]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=77</guid>
		<description><![CDATA[Reemplazar los saltos de línea (\n) de un textarea en una página web mediante javascript es muy sencillo usando una expresión regular. Espero que sirva a aquellos que quer&#225;is mejorar vuestra formaci&#243;n en java: ?Ver código HTML&#160; &#60;html&#62; &#60;head&#62; &#60;script&#62; function nl2br(str){ str=str.replace(/\n/gi,&#34;&#60;br /&#62;&#34;); return str; } function reformat(){ document.dummy.area.value=nl2br(document.dummy.area.value); } &#60;/script&#62; &#60;/head&#62; &#60;body&#62; &#60;form [...]]]></description>
			<content:encoded><![CDATA[<p>Reemplazar los saltos de línea (\n) de un textarea en una página web mediante javascript es muy sencillo usando una expresión regular. Espero que sirva a aquellos que quer&aacute;is mejorar vuestra formaci&oacute;n en java:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p77code14'); return false;">Ver código</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7714"><td class="code" id="p77code14"><pre class="html" style="font-family:monospace;">&nbsp;
 &lt;html&gt;
 &lt;head&gt;
 &lt;script&gt;
 function nl2br(str){
   str=str.replace(/\n/gi,&quot;&lt;br /&gt;&quot;);
   return str;
 }
 function reformat(){
 	document.dummy.area.value=nl2br(document.dummy.area.value);
 }
 &lt;/script&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;form name=&quot;dummy&quot; id=&quot;dummy&quot;&gt;
 &lt;textarea name=&quot;area&quot; id=&quot;area&quot; rows=&quot;10&quot; cols=&quot;50&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
 &lt;input type=&quot;button&quot; name=&quot;nl2br&quot; id=&quot;nl2br&quot; onclick=&quot;reformat()&quot; value=&quot;Eliminar Saltos de Línea&quot; /&gt;
 &lt;/form&gt;
 &lt;/body&gt;
 &lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/reemplazar-saltos-de-linea-n-de-un-textarea-con-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rotar una BufferedImage en Java</title>
		<link>http://picateclas.net/posts/rotar-una-bufferedimage-en-java/</link>
		<comments>http://picateclas.net/posts/rotar-una-bufferedimage-en-java/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 12:20:54 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[fragmentos útiles]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=74</guid>
		<description><![CDATA[Me he llevado cierto tiempo encontrar una función para conseguir rotar 90 grados una imagen de tipo BufferedImage en Java, así que una vez he hallado cómo hacerlo qué menos que compartirlo por si os es útil: ?Ver código JAVA public BufferedImage rotate90DX(BufferedImage bi) { int width = bi.getWidth(); int height = bi.getHeight(); &#160; BufferedImage [...]]]></description>
			<content:encoded><![CDATA[<p>Me he llevado cierto tiempo encontrar una función para conseguir rotar 90 grados una imagen de tipo BufferedImage en Java, así que una vez he hallado cómo hacerlo qué menos que compartirlo por si os es útil:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p74code17'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7417"><td class="code" id="p74code17"><pre class="java" style="font-family:monospace;">	 public BufferedImage rotate90DX(BufferedImage bi)
	    	{
	    		int width = bi.getWidth();
	    		int height = bi.getHeight();
&nbsp;
	    		BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
&nbsp;
	    		for(int i=0; i&lt;width; i++)
	    			for(int j=0; j&lt;height; j++)
	    				biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j));
&nbsp;
	   		return biFlip;
	  }</pre></td></tr></table></div>

<p>Y en el sentido inverso sería así...</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p74code18'); return false;">Ver código</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7418"><td class="code" id="p74code18"><pre class="java" style="font-family:monospace;">	    	public BufferedImage rotate90SX(BufferedImage bi)
	    	{
	    		int width = bi.getWidth();
	    		int height = bi.getHeight();
&nbsp;
	    		BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
&nbsp;
	    		for(int i=0; i&lt;width; i++)
	    			for(int j=0; j&lt;height; j++)
	    				biFlip.setRGB(j, i, bi.getRGB(i, j));
&nbsp;
	    		return biFlip;
	    	}</pre></td></tr></table></div>

<p>Vía | <a href="http://snippets.dzone.com/posts/show/2936">Snippet en Dzone</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/rotar-una-bufferedimage-en-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guía rápida de introducción a jQuery</title>
		<link>http://picateclas.net/posts/guia-rapida-de-introduccion-a-jquery/</link>
		<comments>http://picateclas.net/posts/guia-rapida-de-introduccion-a-jquery/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 11:49:55 +0000</pubDate>
		<dc:creator>zetxek</dc:creator>
				<category><![CDATA[breves]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutoriales]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://picateclas.net/?p=69</guid>
		<description><![CDATA[jQuery es una librería muy útil para desarrollos web, y sobre todo para evitar reinventar la rueda al usar javascript, ya que nos ahorra muchos problemas de compatibilidad entre navegadores, carencias o limitaciones del lenguaje, etc. A pesar de su gran documentación online o los libros sobre la librería publicados, puede que su sintaxis resulte [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com">jQuery</a> es una librería muy útil para desarrollos web, y sobre todo para evitar reinventar la rueda al usar javascript, ya que nos ahorra muchos problemas de compatibilidad entre navegadores, carencias o limitaciones del lenguaje, etc.</p>
<p>A pesar de su gran <a href="http://docs.jquery.com/">documentación online</a> o l<a href="http://www.west-wind.com/WebLog/posts/370180.aspx">os libros sobre la librería publicados</a>, puede que su sintaxis resulte un tanto extraña para un novato, además de no saber muy bien cuáles son las posibilidades reales de jQuery. Para ello, es muy útil <a href="http://dotnetslackers.com/articles/ajax/JQuery-Primer-Part-1.aspx">este artículo</a> de DotNetStacklers (es la primera parte, espero que pronto publiquen la segunda). Y por cierto, los desarrolladores en .NET pueden aprovechar para darle una oportunidad a jQuery ahora que <a href="http://brennan.offwhite.net/blog/2008/02/01/intellisense-for-jquery-in-visual-studio-2008/">se integrará con el Intellisense en Visual Studio</a>...</p>
]]></content:encoded>
			<wfw:commentRss>http://picateclas.net/posts/guia-rapida-de-introduccion-a-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
