<?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>soledad penadés &#187; php</title>
	<atom:link href="http://soledadpenades.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Wed, 25 Apr 2012 21:10:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>My favourite GIMP plug-ins</title>
		<link>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/</link>
		<comments>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:11:04 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3896</guid>
		<description><![CDATA[When I used Ubuntu I normally installed a fancy package called gimp-plugin-registry that came with most of the plug-ins I liked, and then some more stuff that I never used. I had learnt to ignore that, but there was still the pain of not knowing where things were. Some filters went to &#8220;Colors&#8221;, others to [...]]]></description>
			<content:encoded><![CDATA[<p>When I used Ubuntu I normally installed a fancy package called gimp-plugin-registry that came with most of the plug-ins I liked, and then some more stuff that I never used. I had learnt to ignore that, but there was still the pain of not knowing where things were. Some filters went to &#8220;Colors&#8221;, others to &#8220;Light and shadow&#8221;, etc. It was extremely hard to remember where each filter was meant to be.</p>
<p>Now that I&#8217;m using Arch I couldn&#8217;t find any equivalent package but I thought that it was OK&#8211;that way I would only install what I really needed to install. In the process I&#8217;ve found a couple more plug-ins that I didn&#8217;t know about, so it&#8217;s been quite productive.</p>
<p>What I&#8217;ve done is I&#8217;ve written a script that takes care of downloading the scripts from the specified URLs, placing them in the appropriate gimp folder (~/.gimp2-6/scripts in my case), and the best of all is that it also patches them so that all are under the <em>Filters/Photo</em> menu entry. Yay! No more wandering around menus and submenus! My brain is now happy, I can just focus on playing with the pictures!</p>
<p>If you want to use this script just <a href="https://raw.github.com/sole/snippets/master/gimp/favourite_plugins/install.rb">download it</a> (it&#8217;s on my <a href="https://github.com/sole/snippets/blob/master/gimp/favourite_plugins/install.rb">snippets</a> repository). You might want to modify it as you wish. There are a couple of TO DO&#8217;s but the file is fully functional (as long as you&#8217;ve got Ruby installed).</p>
<p>Oh, and pardon my rudimentary Ruby. It&#8217;s been ages since I last wrote anything with Ruby. I still don&#8217;t know what I want to use. Ideally I&#8217;d like something as easy as php but with a syntax that is a mix of Python and Ruby, and lots of easy functional and metaprogramming.</p>
<p>I guess my problem is that I know too much, but still so little, not enough. Maybe if I just knew one language, I would be happy with that one. In any case, I&#8217;ll keep on experimenting and try to decide what I like best. Maybe my Japanese side will win over the European one? Who knows!</p>
<p>Meanwhile, be sure to enjoy the filters! Wooo!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3896&amp;md5=93933ba93dad096b62848ff634652238" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2012/02/12/my-favourite-gimp-plug-ins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2012%2F02%2F12%2Fmy-favourite-gimp-plug-ins%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=My+favourite+GIMP+plug-ins&amp;amp;description=When+I+used+Ubuntu+I+normally+installed+a+fancy+package+called+gimp-plugin-registry+that+came+with+most+of+the+plug-ins+I+liked%2C+and+then+some+more+stuff+that+I+never+used.+I+had+learnt+to+ignore+that%2C+but+there+was+still+the+pain+of+not+knowing+where+things+were.+Some+filters+went+to+%22Colors%22%2C+others+to+%22Light+and+shadow%22%2C+etc.+It+was+extremely+hard+to+remember+where+each+filter+was+meant+to+be.%0D%0A%0D%0ANow+that+I%27m+using+Arch+I+couldn%27t+find+any+equivalent+package+but+I+thought+that+it+was+OK--that+way+I+would+only+install+what+I+really+needed+to+install.+In+the+process+I%27ve+found+a+couple+more+plug-ins+that+I+didn%27t+know+about%2C+so+it%27s+been+quite+productive.%0D%0A%0D%0AWhat+I%27ve+done+is+I%27ve+written+a+script+that+takes+care+of+downloading+the+scripts+from+the+specified+URLs%2C+placing+them+in+the+appropriate+gimp+folder+%28%7E%2F.gimp2-6%2Fscripts+in+my+case%29%2C+and+the+best+of+all+is+that+it+also+patches+them+so+that+all+are+under+the+Filters%2FPhoto+menu+entry.+Yay%21+No+more+wandering+around+menus+and+submenus%21+My+brain+is+now+happy%2C+I+can+just+focus+on+playing+with+the+pictures%21%0D%0A%0D%0AIf+you+want+to+use+this+script+just+download+it+%28it%27s+on+my+snippets+repository%29.+You+might+want+to+modify+it+as+you+wish.+There+are+a+couple+of+TO+DO%27s+but+the+file+is+fully+functional+%28as+long+as+you%27ve+got+Ruby+installed%29.%0D%0A%0D%0AOh%2C+and+pardon+my+rudimentary+Ruby.+It%27s+been+ages+since+I+last+wrote+anything+with+Ruby.+I+still+don%27t+know+what+I+want+to+use.+Ideally+I%27d+like+something+as+easy+as+php+but+with+a+syntax+that+is+a+mix+of+Python+and+Ruby%2C+and+lots+of+easy+functional+and+metaprogramming.%0D%0A%0D%0AI+guess+my+problem+is+that+I+know+too+much%2C+but+still+so+little%2C+not+enough.+Maybe+if+I+just+knew+one+language%2C+I+would+be+happy+with+that+one.+In+any+case%2C+I%27ll+keep+on+experimenting+and+try+to+decide+what+I+like+best.+Maybe+my+Japanese+side+will+win+over+the+European+one%3F+Who+knows%21%0D%0A%0D%0AMeanwhile%2C+be+sure+to+enjoy+the+filters%21+Wooo%21&amp;amp;tags=gimp%2Cphp%2Cplugins%2Cpython%2Cruby%2Cblog" type="text/html" />
	</item>
		<item>
		<title>A hack to parse RSS feeds with php</title>
		<link>http://soledadpenades.com/2012/01/21/a-hack-to-parse-rss-feeds-with-php/</link>
		<comments>http://soledadpenades.com/2012/01/21/a-hack-to-parse-rss-feeds-with-php/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 17:19:37 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3883</guid>
		<description><![CDATA[Just happened to assemble this script hack recently, out of the requirement for a quick&#8217;n'dirty feed parsing feature: $feed_contents = file_get_contents&#40;$feed_url&#41;; $xml = simplexml_load_string&#40;$feed_contents, LIBXML_NOCDATA&#41;; $feed_array = json_decode&#40;json_encode&#40;$xml&#41;&#41;; print_r&#40;$feed_array&#41;; // Surprise!! Now this evidently is not SimplePie or Magpie RSS or whatever feed reader library tickles your fancy*, but assuming the feed will never be [...]]]></description>
			<content:encoded><![CDATA[<p>Just happened to assemble this <del datetime="2012-01-21T16:52:31+00:00">script</del> hack recently, out of the requirement for a quick&#8217;n'dirty feed parsing feature:</p>
<div class="syhi_block"><code><span style="color: #000088;">$feed_contents</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/simplexml_load_string"><span style="color: #990000;">simplexml_load_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed_contents</span><span style="color: #339933;">,</span> LIBXML_NOCDATA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<span style="color: #000088;">$feed_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/json_encode"><span style="color: #990000;">json_encode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Surprise!!</span></code></div>
<p>Now this evidently is <em>not</em> <a href="http://simplepie.org/">SimplePie</a> or <a href="http://magpierss.sourceforge.net/">Magpie RSS</a> or whatever feed reader library tickles your fancy<a href="http://www.phrases.org.uk/bulletin_board/5/messages/888.html"><super>*</super></a>, but assuming the feed will never be malformed, it can save you lots of time! Isn&#8217;t that what php was meant for? :-P<br />
<span id="more-3883"></span><br />
At first it surprised me that it would even work&#8211;but it seems that the JSON module interoperates very nicely with SimpleXML objects. At the end you get an associative array in $feed_array which is a nice representation of the RSS 2 feed. It&#8217;s important to highlight the <strong>LIBXML_NOCDATA</strong> parameter, as it makes sure the CDATA nodes are read as text. Otherwise you would just get empty feed items, etc.</p>
<p>Obviously for this to work you need both the JSON and SimpleXML modules installed and enabled in your server. Since that&#8217;s something that always worries me, I wrote another quick script to test whether the hack would work on the server:</p>
<div class="syhi_block"><code><span style="color: #000088;">$functions</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;">'simplexml_load_string'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'json_decode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$functions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$f</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' exists? '</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'yes'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'no'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></code></div>
<p>It should output something like&#8230;</p>
<div class="syhi_block"><code>simplexml_load_string yes<br />
json_decode yes</code></div>
<p>Happy hacking! :-P</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3883&amp;md5=15f8fcbbdc06d67bd17dfd2a232b5df0" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2012/01/21/a-hack-to-parse-rss-feeds-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2012%2F01%2F21%2Fa-hack-to-parse-rss-feeds-with-php%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=A+hack+to+parse+RSS+feeds+with+php&amp;amp;description=Just+happened+to+assemble+this+script+hack+recently%2C+out+of+the+requirement+for+a+quick%27n%27dirty+feed+parsing+feature%3A%0D%0A%0D%0A%0D%0A%24feed_contents+%3D+file_get_contents%28%24feed_url%29%3B%0D%0A%24xml+%3D+simplexml_load_string%28%24feed_contents%2C+LIBXML_NOCDATA%29%3B+%0D%0A%24feed_array+%3D+json_decode%28json_encode%28%24xml%29%29%3B%0D%0Aprint_r%28%24feed_array%29%3B+%2F%2F+Surprise%21%21%0D%0A%0D%0A%0D%0ANow+this+evidently+is+not+SimplePie+or+Magpie+RSS+or+whatever+feed+reader+library+tickles+your+fancy%2A%2C+but+assuming+the+feed+will+never+be+malformed%2C+it+can+save+you+lots+of+time%21+Isn%27t+that+what+php+was+meant+for%3F+%3A-P%0D%0A%0D%0AAt+first+it+surprised+me+that+it+would+even+work--but+it+seems+that+the+JSON+module+interoperates+very+nicely+with+SimpleXML+objects.+At+the+end+you+get+an+associative+array+in+%24feed_array+which+is+a+nice+representation+of+the+RSS+2+feed.+It%27s+important+to+highlight+the+LIBXML_NOCDATA+parameter%2C+as+it+makes+sure+the+CDATA+nodes+are+read+as+text.+Otherwise+you+would+just+get+empty+feed+items%2C+etc.%0D%0A%0D%0AObviously+for+this+to+work+you+need+both+the+JSON+and+SimpleXML+modules+installed+and+enabled+in+your+server.+Since+that%27s+something+that+always+worries+me%2C+I+wrote+another+quick+script+to+test+whether+the+hack+would+work+on+the+server%3A%0D%0A%0D%0A%0D%0A%24functions+%3D+array%28%27simplexml_load_string%27%2C+%27json_decode%27%29%3B%0D%0Aforeach%28%24functions+as+%24f%29+%7B%0D%0A++echo+%24f+.+%27+exists%3F+%27+.+%28function_exists%28%24f%29+%3F+%27yes%27+%3A+%27no%27%29+.+%27%0A%27%3B%0D%0A%7D%0D%0A%0D%0A%0D%0AIt+should+output+something+like...%0D%0A%0D%0A%0D%0Asimplexml_load_string+yes%0D%0Ajson_decode+yes%0D%0A%0D%0A%0D%0AHappy+hacking%21+%3A-P&amp;amp;tags=feeds%2Chacks%2Cjson%2Cphp%2Crss%2Ctrick%2Cxml%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Debunking Smarty myths</title>
		<link>http://soledadpenades.com/2010/06/14/debunking-smarty-myths/</link>
		<comments>http://soledadpenades.com/2010/06/14/debunking-smarty-myths/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 12:12:30 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Comment]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[myths]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2661</guid>
		<description><![CDATA[I have found yet another article condemning the use of Smarty because&#8230; [...] When you add a template language on top of this the template language has to be interpreted, converted to php and then interpreted as php and outputted. This doubles the amount of work that the cpu has to do to return the [...]]]></description>
			<content:encoded><![CDATA[<p>I have found yet <a href="http://codesanity.net/2010/06/dont-use-smarty/">another article</a> condemning the use of <a href="http://www.smarty.net/">Smarty</a> because&#8230;</p>
<blockquote><p>[...] When you add a template language on top of this the template language has to be interpreted, converted to php and then interpreted as php and outputted. This doubles the amount of work that the cpu has to do to return the page the user requested [...]</p></blockquote>
<p>All right, Toms of the world: did you ever have a look at Smarty&#8217;s temporary directory? (hint: it&#8217;s usually called <em>templates_c</em>)</p>
<p>Because if you had done so, you would have noticed that the <em>only</em> times the templates are parsed are </p>
<ul>
<li>a) the first time the template is loaded</li>
<li>b) when the template has been modified</li>
</ul>
<p>All the other times Smarty simply includes the compiled (read: <em>pre-parsed</em> or <em>generated</em>) templates, which consist in <strong>php code</strong>! (that can be therefore accelerated with php op-code accelerators)</p>
<p>Now, once you recover from this possibly traumatic revelation, let me tell you something else: you can also <strong>cache entire pages</strong> with Smarty! And those will hardly involve your php interpreter at all when being served to the user, because most of the content will have already been generated! How <em>smart</em> is that?</p>
<p>I can understand you don&#8217;t want to use Smarty because it&#8217;s yet another syntax to be learnt, or because you don&#8217;t want to add another layer of complexity to your code, or maybe simply because you don&#8217;t like its syntax. But give credit where credit is due: Smarty has helped <strong>lots</strong> of high traffic sites get way further than they would have reached had they relied on php templating only, thanks to Smarty&#8217;s cache functionality. </p>
<p>And that&#8217;s an achievement few template systems hold.</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=2661&amp;md5=46502241e8cf72cbca81c98aec9ca714" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/06/14/debunking-smarty-myths/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2010%2F06%2F14%2Fdebunking-smarty-myths%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=Debunking+Smarty+myths&amp;amp;description=I+have+found+yet+another+article+condemning+the+use+of+Smarty+because...%0D%0A%0D%0A%5B...%5D+When+you+add+a+template+language+on+top+of+this+the+template+language+has+to+be+interpreted%2C+converted+to+php+and+then+interpreted+as+php+and+outputted.+This+doubles+the+amount+of+work+that+the+cpu+has+to+do+to+return+the+page+the+user+requested+%5B...%5D%0D%0A%0D%0AAll+right%2C+Toms+of+the+world%3A+did+you+ever+have+a+look+at+Smarty%27s+temporary+directory%3F+%28hint%3A+it%27s+usually+called+templates_c%29%0D%0A%0D%0ABecause+if+you+had+done+so%2C+you+would+have+noticed+that+the+only+times+the+templates+are+parsed+are+%0D%0A%0D%0A%0D%0A%09a%29+the+first+time+the+template+is+loaded%0D%0A%09b%29+when+the+template+has+been+modified%0D%0A%0D%0A%0D%0AAll+the+other+times+Smarty+simply+includes+the+compiled+%28read%3A+pre-parsed+or+generated%29+templates%2C+which+consist+in+php+code%21+%28that+can+be+therefore+accelerated+with+php+op-code+accelerators%29%0D%0A%0D%0ANow%2C+once+you+recover+from+this+possibly+traumatic+revelation%2C+let+me+tell+you+something+else%3A+you+can+also+cache+entire+pages+with+Smarty%21+And+those+will+hardly+involve+your+php+interpreter+at+all+when+being+served+to+the+user%2C+because+most+of+the+content+will+have+already+been+generated%21+How+smart+is+that%3F%0D%0A%0D%0AI+can+understand+you+don%27t+want+to+use+Smarty+because+it%27s+yet+another+syntax+to+be+learnt%2C+or+because+you+don%27t+want+to+add+another+layer+of+complexity+to+your+code%2C+or+maybe+simply+because+you+don%27t+like+its+syntax.+But+give+credit+where+credit+is+due%3A+Smarty+has+helped+lots+of+high+traffic+sites+get+way+further+than+they+would+have+reached+had+they+relied+on+php+templating+only%2C+thanks+to+Smarty%27s+cache+functionality.+%0D%0A%0D%0AAnd+that%27s+an+achievement+few+template+systems+hold.&amp;amp;tags=cache%2Cmyths%2Cphp%2Csmarty%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Delicatessen v2</title>
		<link>http://soledadpenades.com/2009/11/17/delicatessen-v2/</link>
		<comments>http://soledadpenades.com/2009/11/17/delicatessen-v2/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 10:27:39 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[delicatessen]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=1807</guid>
		<description><![CDATA[Let me introduce Delicatessen v2, the new version of my WordPress plug-in for finding out who&#8217;s bookmarked your posts in delicious.com It has taken a bit too long to produce this version, but it at last behaves like a nice netizen, and won&#8217;t spam delicious.com with too many queries in a very little time, therefore [...]]]></description>
			<content:encoded><![CDATA[<p>Let me introduce <a href="http://soledadpenades.com/projects/wordpress/delicatessen/">Delicatessen v2</a>, the new version of my WordPress plug-in for finding out who&#8217;s bookmarked your posts in delicious.com</p>
<p>It has taken a bit too long to produce this version, but it at last behaves like a nice <em>netizen</em>, and won&#8217;t spam delicious.com with too many queries in a very little time, therefore you won&#8217;t get banned ;)</p>
<p><img src="/imgs/delicatessen-screenshot-1.png" alt="Delicatessen" /></p>
<p>More info and downloads in the <a href="http://soledadpenades.com/projects/wordpress/delicatessen/">Delicatessen</a> page.</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=1807&amp;md5=629aa99f408063287e3ce9a920fbb065" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2009/11/17/delicatessen-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2009%2F11%2F17%2Fdelicatessen-v2%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=Delicatessen+v2&amp;amp;description=Let+me+introduce+Delicatessen+v2%2C+the+new+version+of+my+WordPress+plug-in+for+finding+out+who%27s+bookmarked+your+posts+in+delicious.com%0D%0A%0D%0AIt+has+taken+a+bit+too+long+to+produce+this+version%2C+but+it+at+last+behaves+like+a+nice+netizen%2C+and+won%27t+spam+delicious.com+with+too+many+queries+in+a+very+little+time%2C+therefore+you+won%27t+get+banned+%3B%29%0D%0A%0D%0A%0D%0A%0D%0AMore+info+and+downloads+in+the+Delicatessen+page.&amp;amp;tags=delicatessen%2Cdelicious%2Cphp%2Cplugin%2Cwordpress%2Cblog" type="text/html" />
	</item>
		<item>
		<title>SyHi: my minimalistic syntax highlighting plug-in for WordPress</title>
		<link>http://soledadpenades.com/2009/11/02/syhi-my-minimalistic-syntax-highlighting-plug-in-for-wordpress/</link>
		<comments>http://soledadpenades.com/2009/11/02/syhi-my-minimalistic-syntax-highlighting-plug-in-for-wordpress/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:50:43 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[syhi]]></category>
		<category><![CDATA[syntax highlighting]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=1486</guid>
		<description><![CDATA[I had been using Code Snippet for a year, or a couple of years (I can&#8217;t really remember), and was more or less happy with it. Apart from the fact that it didn&#8217;t preserve some stuff properly, like double dashes and quotes. So then I tried adding another plug-in to the mix, Preserve Code Formatting. [...]]]></description>
			<content:encoded><![CDATA[<p>I had been using <a href="http://blog.hackerforhire.org/code-snippet/">Code Snippet</a> for a year, or a couple of years (I can&#8217;t really remember), and was more or less happy with it. Apart from the fact that it didn&#8217;t preserve some stuff properly, like double dashes and quotes. So then I tried adding another plug-in to the mix, <a href="http://coffee2code.com/wp-plugins/preserve-code-formatting/">Preserve Code Formatting</a>. But both at the same time didn&#8217;t work out as I <del datetime="2009-11-02T12:04:59+00:00">expected</del> hoped. </p>
<p>The solution? </p>
<p><strong>I made a new plug-in</strong>. It&#8217;s <em>very minimalistic</em>, starting with its name: <a href="http://soledadpenades.com/projects/wordpress/syhi/">SyHi</a>.</p>
<h3>How does it work?</h3>
<p>The problem with other plug-ins is that they apply their formatting and then let WordPress continue modifying the posts&#8217; text. That&#8217;s a totally bad idea, and that&#8217;s why quotes and dashes were systematically altered. On the other hand, this little clever plug-in takes the code blocks apart, sets them aside while leaving placeholder text where they were, and when WordPress has finished with all its filtering and texturizing, SyHi replaces the placeholder texts with the preserved, syntax highlighted beatiful pieces of code that the author entered.</p>
<p>The resulting code not only is nice to look at, but can be copied and pasted into a compiler and it will work with <strong>no modifications</strong> at all. No more <q>please replace em dashes with double hyphens because WordPress modified the snippet&#8217;s output&#8230;</q>: your blog readers  can now simply copy and paste!</p>
<h3>Alphatesters needed</h3>
<p>So far I have tested SyHi with a test blog and this blog too. It looks fine, but I would be more than happy if somebody else wants to have a go at testing it. I would even add you to the <em>Thanks</em> section!</p>
<p><del datetime="2009-11-02T13:43:53+00:00">Unfortunately, the plug-in is not yet available in the wp-plugins directory; I&#8217;m waiting for them to approve my request so that you can install it from within the plugins admin page.</del></p>
<p>Plug-in page at WordPress directory: <a href="http://wordpress.org/extend/plugins/syhi/">SyHi</a>. You can also clone <a href="http://github.com/sole/SyHi">the SyHi github repository</a> or <a href="http://github.com/sole/SyHi/downloads">download the latest version</a> from there.</p>
<h3>Samples</h3>
<p>So you don&#8217;t believe me when I say this plug-in works great?</p>
<h4>Using Python</h4>
<div class="syhi_block"><code>noise_output = <span style="color: #dc143c;">wave</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'noise.wav'</span>, <span style="color: #483d8b;">'w'</span><span style="color: black;">&#41;</span><br />
noise_output.<span style="color: black;">setparams</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">44100</span>, <span style="color: #ff4500;">0</span>, <span style="color: #483d8b;">'NONE'</span>, <span style="color: #483d8b;">'not compressed'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, SAMPLE_LEN<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; value = <span style="color: #dc143c;">random</span>.<span style="color: black;">randint</span><span style="color: black;">&#40;</span>-<span style="color: #ff4500;">32767</span>, <span style="color: #ff4500;">32767</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; packed_value = <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'h'</span>, value<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; noise_output.<span style="color: black;">writeframes</span><span style="color: black;">&#40;</span>packed_value<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; noise_output.<span style="color: black;">writeframes</span><span style="color: black;">&#40;</span>packed_value<span style="color: black;">&#41;</span><br />
<br />
noise_output.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></code></div>
<h4>What about php?</h4>
<div class="syhi_block"><code><span style="color: #000000; font-weight: bold;">class</span> SyHi<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$code_blocks</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$geshi_instance</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Execute pre and post process functions before and after each post content is processed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</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: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pre_process'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</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: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_process'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Same for each comment</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_text'</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: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pre_process'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_text'</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: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_process'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add the css stylesheet link to the &lt;head&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_head'</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: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></code></div>
<h4>OK and what about C/C++?</h4>
<div class="syhi_block"><code><span style="color: #0000ff;">void</span> luisita_reportErrors<span style="color: #008000;">&#40;</span>lua_State <span style="color: #000040;">*</span>L, <span style="color: #0000ff;">int</span> st<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>st <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; std<span style="color: #008080;">::</span><span style="color: #0000dd;">cerr</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;ERROR -- &quot;</span> <span style="color: #000080;">&lt;&lt;</span> lua_tostring<span style="color: #008000;">&#40;</span>L, <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; lua_pop<span style="color: #008000;">&#40;</span>L, <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// removes error message</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></code></div>
<p>As you can see, double dashes are being respected, quotes are kept as they are, and code is nicely highlighted. And if you&#8217;re <em>still</em> feeling skeptical, keep browsing posts in this blog, since all code snippets go through SyHi.</p>
<p><strong>Update:</strong> added the link to the plug-in&#8217;s repository :)</p>
<p><strong>Update 2:</strong> let me clarify something: this plug-in can beautify snippets in pretty much every programming language you can think of, thanks to the huge language support provided by GeSHi. I have shown you only three examples as a simple demonstration, but you can even show Z80 assembler code! </p>
<p>The full list of supported languages is in the left column of <a href="http://qbnz.com/highlighter/">the GeSHi website</a>, under the <em>Supported Languages header</em>. Heck, it even has support for a language called <em>BrainFuck</em>!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=1486&amp;md5=e08b1bd701b2690ea04078aa6803c552" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2009/11/02/syhi-my-minimalistic-syntax-highlighting-plug-in-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2009%2F11%2F02%2Fsyhi-my-minimalistic-syntax-highlighting-plug-in-for-wordpress%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=SyHi%3A+my+minimalistic+syntax+highlighting+plug-in+for+WordPress&amp;amp;description=I+had+been+using+Code+Snippet+for+a+year%2C+or+a+couple+of+years+%28I+can%27t+really+remember%29%2C+and+was+more+or+less+happy+with+it.+Apart+from+the+fact+that+it+didn%27t+preserve+some+stuff+properly%2C+like+double+dashes+and+quotes.+So+then+I+tried+adding+another+plug-in+to+the+mix%2C+Preserve+Code+Formatting.+But+both+at+the+same+time+didn%27t+work+out+as+I+expected+hoped.+%0D%0A%0D%0AThe+solution%3F+%0D%0A%0D%0AI+made+a+new+plug-in.+It%27s+very+minimalistic%2C+starting+with+its+name%3A+SyHi.%0D%0A%0D%0AHow+does+it+work%3F%0D%0A%0D%0AThe+problem+with+other+plug-ins+is+that+they+apply+their+formatting+and+then+let+WordPress+continue+modifying+the+posts%27+text.+That%27s+a+totally+bad+idea%2C+and+that%27s+why+quotes+and+dashes+were+systematically+altered.+On+the+other+hand%2C+this+little+clever+plug-in+takes+the+code+blocks+apart%2C+sets+them+aside+while+leaving+placeholder+text+where+they+were%2C+and+when+WordPress+has+finished+with+all+its+filtering+and+texturizing%2C+SyHi+replaces+the+placeholder+texts+with+the+preserved%2C+syntax+highlighted+beatiful+pieces+of+code+that+the+author+entered.%0D%0A%0D%0AThe+resulting+code+not+only+is+nice+to+look+at%2C+but+can+be+copied+and+pasted+into+a+compiler+and+it+will+work+with+no+modifications+at+all.+No+more+please+replace+em+dashes+with+double+hyphens+because+WordPress+modified+the+snippet%27s+output...%3A+your+blog+readers++can+now+simply+copy+and+paste%21%0D%0A%0D%0AAlphatesters+needed%0D%0A%0D%0ASo+far+I+have+tested+SyHi+with+a+test+blog+and+this+blog+too.+It+looks+fine%2C+but+I+would+be+more+than+happy+if+somebody+else+wants+to+have+a+go+at+testing+it.+I+would+even+add+you+to+the+Thanks+section%21%0D%0A%0D%0AUnfortunately%2C+the+plug-in+is+not+yet+available+in+the+wp-plugins+directory%3B+I%27m+waiting+for+them+to+approve+my+request+so+that+you+can+install+it+from+within+the+plugins+admin+page.%0D%0A%0D%0APlug-in+page+at+WordPress+directory%3A+SyHi.+You+can+also+clone+the+SyHi+github+repository+or+download+the+latest+version+from+there.%0D%0A%0D%0ASamples%0D%0A%0D%0ASo+you+don%27t+believe+me+when+I+say+this+plug-in+works+great%3F%0D%0A%0D%0AUsing+Python%0D%0A%0D%0A%0D%0Anoise_output+%3D+wave.open%28%27noise.wav%27%2C+%27w%27%29%0D%0Anoise_output.setparams%28%282%2C+2%2C+44100%2C+0%2C+%27NONE%27%2C+%27not+compressed%27%29%29%0D%0A%0D%0Afor+i+in+range%280%2C+SAMPLE_LEN%29%3A%0D%0A++++++++value+%3D+random.randint%28-32767%2C+32767%29%0D%0A++++++++packed_value+%3D+struct.pack%28%27h%27%2C+value%29%0D%0A++++++++noise_output.writeframes%28packed_value%29%0D%0A++++++++noise_output.writeframes%28packed_value%29%0D%0A%0D%0Anoise_output.close%28%29%0D%0A%0D%0A%0D%0AWhat+about+php%3F%0D%0A%0D%0A%0D%0Aclass+SyHi%0D%0A%7B%0D%0A%09protected+%24code_blocks%3B%0D%0A%09protected+%24geshi_instance+%3D+null%3B%0D%0A%0D%0A%09public+function+__construct%28%29%0D%0A%09%7B%0D%0A%09%09%2F%2F+Execute+pre+and+post+process+functions+before+and+after+each+post+content+is+processed%0D%0A%09%09add_filter%28%27the_content%27%2C+array%28%26%24this%2C+%27pre_process%27%29%2C+2%29%3B%0D%0A%09%09add_filter%28%27the_content%27%2C+array%28%26%24this%2C+%27post_process%27%29%2C+1000%29%3B%0D%0A%0D%0A%09%09%2F%2F+Same+for+each+comment%0D%0A%09%09add_filter%28%27comment_text%27%2C+array%28%26%24this%2C+%27pre_process%27%29%2C+2%29%3B%0D%0A%09%09add_filter%28%27comment_text%27%2C+array%28%26%24this%2C+%27post_process%27%29%2C+1000%29%3B%0D%0A%0D%0A%09%09%2F%2F+Add+the+css+stylesheet+link+to+the+%0D%0A%09%09add_action%28%27wp_head%27%2C+array%28%26%24this%2C+%27add_css%27%29%2C+1%29%3B%0D%0A%09%7D%0D%0A%7D%0D%0A%0D%0A%0D%0AOK+and+what+about+C%2FC%2B%2B%3F%0D%0A%0D%0A%0D%0Avoid+luisita_reportErrors%28lua_State+%2AL%2C+int+st%29%0D%0A%7B%0D%0A++++if+%28st+%21%3D+0%29%0D%0A++++%7B%0D%0A++++++++std%3A%3Acerr+&amp;amp;tags=open+source%2Cphp%2Cplugin%2Csyhi%2Csyntax+highlighting%2Cwordpress%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>

