<?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>Sun, 29 Jan 2012 23:03:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>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>
		</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>
		</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>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2009/11/17/delicatessen-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</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>
]]></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>
		</item>
		<item>
		<title>&#8220;Blue Tuesday&#8221; sources released</title>
		<link>http://soledadpenades.com/2009/07/10/blue-tuesday-sources-released/</link>
		<comments>http://soledadpenades.com/2009/07/10/blue-tuesday-sources-released/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 11:35:25 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[audacity]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ribbons]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>
		<category><![CDATA[xplsv]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=1138</guid>
		<description><![CDATA[&#8220;Blue Tuesday&#8221; is a direct evolution from the codecolors code base. Since it was all done in a hurry, there were lots of things which didn&#8217;t work as expected. I somehow got rid of some of them when I ported the demo to mac, then I got rid of some extra things these days when [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://soledadpenades.com/imgs/xplsv_bt00.jpg" alt="Blue Tuesday by xplsv" /></p>
<p>&#8220;<a href="http://soledadpenades.com/projects/demoscene/blue-tuesday-by-xplsv/">Blue Tuesday</a>&#8221; is a direct evolution from the <a href="http://soledadpenades.com/projects/demoscene/codecolors-by-ppg/">codecolors</a> code base. Since it was all done in a hurry, there were lots of things which didn&#8217;t work as expected. I somehow got rid of some of them when I ported the demo to mac, then I got rid of some extra things these days when I made the demo work in Linux, prior to releasing these sources. I am not happy with this code; with so many modifications it has grown way too much to be still readable. There are effects whose behaviour is not predictable, things like the ribbons are very inefficient and so on. </p>
<p>I&#8217;m still not completely happy with the synchronization. In the first version trace did a simple flash app in which he tapped a key each time an event happened (e.g. a snare hit) and then generated a list from there. But due to the way the demo is structured, I had to split the list in three parts so that I could check whether an event happened in each effect. Also with so many changes in the code, the synch had gone slightly awry and when I managed to compile the code in Linux, it clearly was asking for a revision.</p>
<p>So I thought about using <a href="http://audacity.sourceforge.net/">Audacity</a> for re-recording the synchronization. I would store each event as a label (Audacity has something called <em>Label Tracks</em>) and then exporting those labels as txt files and processing them to convert them into a .h file with all the events in an array. I had the idea of opening Audacity&#8217;s project with a text editor and found out that it was a simple XML file &#8212; which would make even easier the task of importing the labels&#8217; information, without having to go through the step of exporting to a text file and parsing it.</p>
<p>I then tried to process the XML file with Python, but it was a horrible experience. Since it has a namespace on it and I wanted to do a simple XPath search, it seems I was doomed to fail without installing a couple of Python libraries &#8212; which I didn&#8217;t want to install. My main premise is to make my demos simple to compile, and having to install an extension just for parsing XML is not what I consider &#8220;simple&#8221;. So I resorted to good old PHP&#8217;s XML functions and in 20 minutes the import script was done. <em>That</em> was the easy part. </p>
<p>What was really painful was recording the synch points! Audacity took hanging itself up as a hobby. Thankfully, I have the CTRL+S tic &#8211;in which whenever I&#8217;m working with any program I tend to press CTRL+S regularly, pretty much each time I have typed in something, just in case&#8211; and that prevented me from losing my changes more than once. But it was just annoying to have to kill the program, open it again, say yes to &#8220;yes please recover the project I was working on when you decided to crash&#8221;. Even worse: at some point, the project got corrupted, and when I reopened it again, Audacity just got stuck switching between an sleep/idle status. I had to create a new project with the same mp3, save it and then edit the new project in a text editor, and copy and paste the old label tracks from the initial source project. Luckily it was all XML. I can&#8217;t imagine what would have I done if it had been binary data! (Probably scream a good lot!)</p>
<p>So <strong>lesson learnt</strong>: for making good synchronization you need a dedicated, and probably integrated, piece of software. If I need to do something like this again, I will probably spend a good amount of time in preparing something like <a href="http://vimeo.com/1032692">the editor</a> blackpawn created. Because it wasn&#8217;t only a problem of crashing, it was also the problem of not having a comfortable interface which lets you go back and forth the song, reduce its speed, etc, without having to use the mouse.</p>
<p>This is probably one of the reasons why I prefer to make demos with my own music: it&#8217;s easier to access the original song source files and build a list of events from there if I wanted to :-)</p>
<p>Enough chattering, go <a href="http://www.youtube.com/watch?v=zM8TCe5SW-o">watch the demo</a> or get a nice headache just by <a href="http://github.com/sole/demoscene/tree/6f9ee3a4c504d51a9ad8ba31b6803c696ee993f8/releases/xplsv/blue_tuesday">looking at the code</a> :P</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2009/07/10/blue-tuesday-sources-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

