<?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; Code</title>
	<atom:link href="http://soledadpenades.com/category/code/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>Aduki shader</title>
		<link>http://soledadpenades.com/2011/11/11/aduki-shader/</link>
		<comments>http://soledadpenades.com/2011/11/11/aduki-shader/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 00:29:21 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[exciting]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3837</guid>
		<description><![CDATA[Got this toying with Mr.doob&#8217;s GLSL Sandbox. See it live. It&#8217;s my first shader ever!! :D Here&#8217;s the code: #ifdef GL_ES precision highp float; #endif uniform float time; uniform vec2 resolution; void main&#40; void &#41; &#123; &#160; &#160; &#160; &#160; vec2 position = gl_FragCoord.xy / resolution.xy; &#160; &#160; &#160; &#160; float color = 0.0; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Got this toying with Mr.doob&#8217;s GLSL Sandbox. See it <a href="http://mrdoob.com/projects/glsl_sandbox/#A/5d00000100bc0100000000000000119a48c65ab5aec1f910f780dfdfe473e599a211a90304ab6a650a0bdc710e60d9ef6827f7e37c460aba047c4de9e20bce74f0e6773fe3b4b7d379f6f885aacf346330fef1ffee566139968f57db637a7fabad10c58d9ee59035429f68fd37377ae69569d2c30059acf29a58281c4208405f4e5bc30a50a7c8e7027cfa1ecffac22c377e315721df5df0a66223c85eb9d95115798c7316717b7c9af15adb0947d4a23000ecf23ccea69a3efca86546965506f270c0473216586b6a6976d8f1b9a57097efa959606b77f4c6855a87739df56eb283673ddebbe179433b0ac54a5ffe64eb9d2a133f029ba7d4f0b73fc7910219c5b891bc6334e6de1dfef9488c4b">live</a>.</p>
<p>It&#8217;s my first shader ever!! :D</p>
<p>Here&#8217;s the code:</p>
<div class="syhi_block"><code><span style="color: #009900;">#ifdef GL_ES</span><br />
<span style="color: #000066; font-weight: bold;">precision</span> <span style="color: #000066; font-weight: bold;">highp</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #000066;">;</span><br />
<span style="color: #009900;">#endif</span><br />
<br />
<span style="color: #333399; font-weight: bold;">uniform</span> <span style="color: #000066; font-weight: bold;">float</span> time<span style="color: #000066;">;</span><br />
<span style="color: #333399; font-weight: bold;">uniform</span> <span style="color: #000066; font-weight: bold;">vec2</span> resolution<span style="color: #000066;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #000066;">&#40;</span> <span style="color: #000066; font-weight: bold;">void</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">vec2</span> position <span style="color: #000066;">=</span> <span style="color: #551111;">gl_FragCoord</span><span style="color: #000066;">.</span><span style="color: #006600;">xy</span> <span style="color: #000066;">/</span> resolution<span style="color: #000066;">.</span><span style="color: #006600;">xy</span><span style="color: #000066;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">float</span> color <span style="color: #000066;">=</span> <span style="color: #0000ff;">0.0</span><span style="color: #000066;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">float</span> t <span style="color: #000066;">=</span> time <span style="color: #000066;">/</span> <span style="color: #0000ff;">8.0</span><span style="color: #000066;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">float</span> r <span style="color: #000066;">=</span> <span style="color: #0000ff;">0.7</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">0.35</span> <span style="color: #000066;">*</span> <span style="color: #000066;">&#40;</span><span style="color: #993333; font-weight: bold;">sin</span><span style="color: #000066;">&#40;</span>position<span style="color: #000066;">.</span><span style="color: #006600;">x</span> <span style="color: #000066;">+</span> t<span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #993333; font-weight: bold;">sin</span><span style="color: #000066;">&#40;</span>position<span style="color: #000066;">.</span><span style="color: #006600;">x</span> <span style="color: #000066;">+</span> t <span style="color: #000066;">*</span> <span style="color: #0000ff;">5.0</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">float</span> g <span style="color: #000066;">=</span> <span style="color: #0000ff;">1.0</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">0.5</span> <span style="color: #000066;">*</span> <span style="color: #993333; font-weight: bold;">sin</span><span style="color: #000066;">&#40;</span>t<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">float</span> b <span style="color: #000066;">=</span> <span style="color: #0000ff;">0.7</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">0.35</span> <span style="color: #000066;">*</span> <span style="color: #000066;">&#40;</span><span style="color: #993333; font-weight: bold;">sin</span><span style="color: #000066;">&#40;</span>position<span style="color: #000066;">.</span><span style="color: #006600;">y</span> <span style="color: #000066;">+</span> t <span style="color: #000066;">*</span> <span style="color: #0000ff;">1.7</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #993333; font-weight: bold;">sin</span><span style="color: #000066;">&#40;</span>position<span style="color: #000066;">.</span><span style="color: #006600;">y</span> <span style="color: #000066;">+</span> t<span style="color: #000066;">*</span><span style="color: #0000ff;">0.5</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span><br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #551111;">gl_FragColor</span> <span style="color: #000066;">=</span> <span style="color: #000066; font-weight: bold;">vec4</span><span style="color: #000066;">&#40;</span> <span style="color: #000066; font-weight: bold;">vec3</span><span style="color: #000066;">&#40;</span> r<span style="color: #000066;">,</span> g<span style="color: #000066;">,</span> b <span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> <span style="color: #0000ff;">1.0</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span><br />
<br />
<span style="color: #000066;">&#125;</span></code></div>
<p><span id="more-3837"></span><br />
I actually wanted to replicate the crappy plasma effect I did for &#8220;<a href="http://soledadpenades.com/projects/demoscene/killotrona-by-ppg/">Killotrona</a>&#8220;, but the <a href="https://github.com/sole/demoscene/blob/master/releases/ppg/ppg_03_ktn/src/FXsinusplasma.cpp">original code</a> is an scary, terrible mess:</p>
<div class="syhi_block"><code><span style="color: #666666;">// [...]</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #000080;">=</span><span style="color:#800080;">0.7</span><span style="color: #000040;">+</span><span style="color:#800080;">0.5</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #000040;">+</span>t <span style="color: #000040;">+</span> vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #000040;">+</span>t<span style="color: #000040;">*</span><span style="color: #0000dd;">5</span> <span style="color: #000040;">+</span> vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//+0.5*sin(vertexList[x][y].x+t);</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span><span style="color: #000080;">=</span><span style="color: #0000dd;">2</span><span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>t<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #666666;">//1+0.5*(sin(vertexList[x][y].x+t*0.1 + vertexList[x][y].z)+sin(vertexList[x][y].y+t*2 + vertexList[x][y].z));</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #000080;">=</span><span style="color:#800080;">0.7</span><span style="color: #000040;">+</span><span style="color:#800080;">0.5</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span><span style="color: #000040;">+</span>t<span style="color: #000040;">*</span><span style="color:#800080;">1.7</span> <span style="color: #000040;">+</span> vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span><span style="color: #000040;">+</span>t<span style="color: #000040;">*</span><span style="color:#800080;">0.5</span> <span style="color: #000040;">+</span> vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">+</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #008080;">;</span><br />
<br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #000080;">=</span><span style="color: #0000dd;">fmod</span><span style="color: #008000;">&#40;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span> <span style="color: #000040;">+</span> this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span>,<span style="color:#800080;">1.1</span><span style="color: #000040;">+</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>t<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #000080;">=</span><span style="color: #0000dd;">fmod</span><span style="color: #008000;">&#40;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span> <span style="color: #000040;">+</span> this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span>,<span style="color:#800080;">1.1</span><span style="color: #000040;">+</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>t<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<br />
aux<span style="color: #000080;">=</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span><span style="color: #008080;">;</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">y</span><span style="color: #000080;">=</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #008080;">;</span><br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>colorList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">x</span><span style="color: #000080;">=</span>aux<span style="color: #008080;">;</span><br />
<br />
this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertexList<span style="color: #008000;">&#91;</span>x<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>y<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">z</span><span style="color: #000080;">=</span><span style="color: #0000dd;">10</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>t<span style="color: #000040;">*</span><span style="color:#800080;">0.1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">+</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>t<span style="color: #000040;">*</span><span style="color:#800080;">0.5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #666666;">// [...]</span></code></div>
<p>Although it&#8217;s a bit hard to follow, that code updates a list of colours on each iteration, and these colours are then used for the next iteration. I have no idea how to do this with shaders&#8230; I have the notion that you need a texture of sorts to store that kind of values but I&#8217;m not sure.</p>
<p>Also, it&#8217;s not shown in the above fragment but the code also scales the entire output cyclically:</p>
<div class="syhi_block"><code><span style="color: #0000ff;">float</span> sx<span style="color: #000080;">=</span><span style="color:#800080;">1.5</span><span style="color: #000040;">+</span><span style="color:#800080;">0.5</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">sin</span><span style="color: #008000;">&#40;</span>t_elapsed<span style="color: #000040;">*</span><span style="color:#800080;">0.1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">+</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>t_elapsed<span style="color: #000040;">*</span><span style="color:#800080;">0.2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">float</span> sy<span style="color: #000080;">=</span><span style="color:#800080;">1.5</span><span style="color: #000040;">+</span><span style="color:#800080;">0.5</span><span style="color: #000040;">*</span><span style="color: #0000dd;">cos</span><span style="color: #008000;">&#40;</span>t_elapsed<span style="color: #000040;">*</span><span style="color:#800080;">0.1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
glScalef<span style="color: #008000;">&#40;</span>sx,sy,<span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></code></div>
<p>I guess this could be emulated by multiplying the values we send to the various sin() functions with the output of another sin which is function of time, so that the scaling is cyclical, but again, I&#8217;m quite unsure&#8230;</p>
<p>It&#8217;s nice to see how clean GLSL code is, though. I might even finally learn it after five years promising to do so! But I have an excuse: having to include <a href="http://glew.sourceforge.net/">glew</a> and all that is just so cumbersome&#8230;!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3837&amp;md5=3856a23a1eb23a88843d4542810c27c1" 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/2011/11/11/aduki-shader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML5&#8242;s custom attributes minigotcha</title>
		<link>http://soledadpenades.com/2011/10/16/html5s-custom-attributes-minigotcha/</link>
		<comments>http://soledadpenades.com/2011/10/16/html5s-custom-attributes-minigotcha/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 19:29:27 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[custom attributes]]></category>
		<category><![CDATA[dataset]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[notes to self]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3760</guid>
		<description><![CDATA[I was trying to set a Javascript Object as the value for a custom attribute, but I was just getting &#8220;[Object object]&#8221; as the value when reading it back. This is actually the toString() version of my object, and was also my &#8216;fault&#8217; for not reading the specs (or for daring to attempt something risky!), [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to set a Javascript Object as the value for a custom attribute, but I was just getting &#8220;[Object object]&#8221; as the value when reading it back. This is actually the toString() version of my object, and was also my &#8216;fault&#8217; for not reading the specs (or for daring to attempt something risky!), as <strong>the custom attributes can only contain strings</strong>:</p>
<blockquote><p>
element . dataset<br />
Returns a DOMStringMap object for the element&#8217;s data-* attributes.
</p></blockquote>
<p> (<a href="http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data-with-the-data-attributes"># source</a>)</p>
<blockquote><p>
[...] The custom data attributes is transformed to a key for the DOMStringMap entry [...]
</p></blockquote>
<p> (<a href="https://developer.mozilla.org/en/DOM/element.dataset"># source</a>)</p>
<p>Or more specifically, only &#8216;DOMStrings&#8217; are allowed.</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3760&amp;md5=4258a2b75d70e87ab75adc3911957b48" 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/2011/10/16/html5s-custom-attributes-minigotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Line spacing inconsistencies when pasting to Firefox from gedit</title>
		<link>http://soledadpenades.com/2011/08/19/line-spacing-inconsistencies-when-pasting-to-firefox-from-gedit/</link>
		<comments>http://soledadpenades.com/2011/08/19/line-spacing-inconsistencies-when-pasting-to-firefox-from-gedit/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 17:09:46 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[gedit]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3624</guid>
		<description><![CDATA[I was adding some productions to escena.org when I noticed something strange about the way the info section of the latest productions was looking. I was slightly distracted by the excitement of watching all those intros and demos that I hadn&#8217;t heard before about, so it took me a while to notice what it was [...]]]></description>
			<content:encoded><![CDATA[<p>I was adding some <a href="http://escena.org/productions/1">productions</a> to escena.org when I noticed something strange about the way the info section of the latest productions was looking. I was slightly distracted by the excitement of watching all those intros and demos that I hadn&#8217;t heard before about, so it took me a while to notice what it was exactly that &#8220;didn&#8217;t quite look right&#8221;. It was <strong>the spacing</strong>!</p>
<p>Or more exactly, <strong>the double spacing</strong> that I was <a href="http://escena.org/productions/id/114/">seeing</a>, instead of just a single line as in the original!</p>
<p>Initially willing (or expecting) to put the blame on me, I examined my back-end code first, but there is nothing dealing with double spacing or &#8220;Windows spacing&#8221; correction, such as automatically replacing <em>\r\n</em> with <em>\n</em> only.<br />
<span id="more-3624"></span><br />
I then remembered that when I developed this section a year ago I was using Chrome as my main browser, so I wondered if it was a Firefox-only error that had slipped thru back then. Therefore, I repeated my test with Chrome: opened a FILE_ID.DIZ with <a href="http://projects.gnome.org/gedit/">gedit</a>, copied the text and pasted it to the corresponding textarea. Clicked on save&#8230; and the result came out OK! Simple single line-endings were received by PHP, as one would expect.</p>
<p><q>So it&#8217;s a Firefox thing then</q>, I thought. Not so fast, it can still get more bizarre. But before I get to that, let me show you a little piece of test code I wrote to ensure nothing else was interfering in the process:</p>
<div class="syhi_block"><code><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<br />
<span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$pasted_text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'POST'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pasted_text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;n&quot;&gt;&lt;/span&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pasted_text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;r&quot;&gt;&lt;/span&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$txt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'You pasted this:&lt;br /&gt;&lt;pre&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/pre&gt;&lt;br /&gt;(end of your paste)'</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;!DOCTYPE HTML&gt;<br />
&lt;html&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$txt</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;textarea name=&quot;text&quot; placeholder=&quot;PASTE SOMETHING HERE, press submit&quot; rows=&quot;20&quot; cols=&quot;80&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pasted_text</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/textarea&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;submit&quot; value=&quot;submit&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;style&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pre {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background: #eee;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-family: Monaco,&quot;Andale Mono&quot;,&quot;Bitstream Mono&quot;,Courier,terminal;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-size: 12px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: auto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line-height: 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: 10px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: auto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; max-width: 99%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .n {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: 0 10px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background: #f00;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .r {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: 0 10px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background: #0f0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/style&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/body&gt;<br />
&lt;/html&gt;</code></div>
<p><small>(you can download it <a href="https://gist.github.com/1156911">from here</a>, in case you want to test it too)</small></p>
<p>What the test code does is simply highlight <strong>&#8216;\n&#8217;</strong> characters with <strong>red</strong>, and <strong>&#8216;\r&#8217;</strong> characters with <strong>green</strong>, so I can visually see what has been added. It&#8217;s not exactly like a full-grown hex editor, but it&#8217;s more practical for testing in the browser.</p>
<p>Then, if I use the following test text <small>(please ignore the fact that some characters are garbled because of the encoding&#8211;though if you don&#8217;t understand Spanish it should all look fine to you!)</small>:</p>
<div class="syhi_block"><code>Esta es una peque€a rutina realizada en Turbo Pascal 6.0.<br />
Est  programada por motivo de una mini-competici¢n que hicimos en el area<br />
SUR.DEMOS de SurNet.<br />
Espero que os guste ;-)</code></div>
<p>When run with Firefox, I get this:</p>
<p><img src="/imgs/2011/paste_firefox.png" alt="pasting to firefox" /></p>
<p>(notice the double spacing: there are double sequences of <em>\n\r</em>s)</p>
<p>And with Chrome it&#8217;s fine:</p>
<p><img src="/imgs/2011/paste_chrome.png" alt="pasting to chrome" /></p>
<p>And here comes the fun: when I copy the text <em>from Chrome</em> and paste it in Firefox. What do you think will happen? Will it double the space when I press Submit?</p>
<p><img src="/imgs/2011/paste_firefox2.png" alt="pasting to firefox, again" /></p>
<p>No! This time it works properly! Crazy! Or what? Well, I have made more tests to try to pinpoint what&#8217;s happening.</p>
<p><strong>Test one:</strong> copy from a txt file that I created on this computer (so it&#8217;s all Linux line endings), paste into Firefox: WORKS. Paste into Chrome: WORKS.</p>
<p>Some guy reported (for <a href="http://code.google.com/p/synergy-plus/issues/detail?id=443">another</a> product) that copying <strong>from Gnome terminal</strong> or <strong>gedit</strong> to Firefox got him strange results, so I tested the Gnome terminal bit too. Works on Firefox and Chrome: no extra line endings.</p>
<p><strong>Test two:</strong> I converted the original text file from <a href="http://en.wikipedia.org/wiki/Code_page_437">Code Page 437</a> (the old MSDOS encoding) to UTF-8, and opened it with gedit, and pasted it into Firefox: DOESN&#8217;T WORK! Double line spacing again! I guess a \r is a \r is a \r, no matter what the encoding! (fortunately).</p>
<p><strong>Test three:</strong> Opened the file with GVim. Copied everything and pasted into Firefox: WORKS. Single line spacing as expected.</p>
<h3>Conclusion?</h3>
<p>Before drawing up a conclusion, I&#8217;ll summarise the facts:</p>
<ol>
<li>In all the tests that &#8220;fail&#8221;, the copy-paste <em>source</em> is gedit, and the content is a file with MS-Dos line endings.</li>
<li>It only fails with Firefox</li>
</ol>
<p>So this is what I think is happening: gedit is getting confused by the MS-Dos line endings, and &#8220;something is wrong&#8221; in the data it puts in the clipboard when I press CTRL+C. Then Firefox gets sort of crazy when it gets those &#8220;wrong&#8221; characters or whatever gedit is storing in the clipboard, and tries to correct it&#8230; but ends up adding double the required line spacing.</p>
<p>On the other hand, Chrome seems to be able to &#8220;recover&#8221; from possibly malformed data, and proceeds in the normal way we expect: <em>not</em> duplicating content.</p>
<p>However I&#8217;m not too sure about this theory. I&#8217;d like to <em>see</em> the raw clipboard contents (this time, with a proper hex editor), to find out what is in there, but I haven&#8217;t been able to find any program which does it. And I&#8217;m not sure I want to start digging X-Clipboard protocol RFC&#8217;s or whatever it is that they use for their specs in order to find out how to communicate with the daemon which is listening to CTRL+C/CTRL+V key presses.</p>
<p>Do any of you have any pointer? Any idea? (other than telling people to not to use gedit!). A server-side solution is not exactly the best idea, since although I can detect whether the user is using Firefox, I don&#8217;t have any way to detect if a text was pasted from gedit! And blindly replacing groups of \r\n\r\n with just \r\n won&#8217;t work either: what if the text file indeed contains two carriage returns?</p>
<p>Decisions, decisions!</p>
<p>Update: found a gedit <a href="https://bugzilla.gnome.org/show_bug.cgi?id=640439">bug</a> which might be related to this issue!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3624&amp;md5=0f6f6bbc68b312d97cf32175241ce6be" 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/2011/08/19/line-spacing-inconsistencies-when-pasting-to-firefox-from-gedit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;insufficient permissions for device&#8221;</title>
		<link>http://soledadpenades.com/2011/07/18/insufficient-permissions-for-device/</link>
		<comments>http://soledadpenades.com/2011/07/18/insufficient-permissions-for-device/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 14:07:44 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[udev]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3596</guid>
		<description><![CDATA[Yes, another of those note-to-self posts, since each time I try to connect a new device to the computer I&#8217;ve already forgotten how this is done :-) Here are the official instructions, with a list of vendor IDs. If your vendor is not on this list, try to find out the vendor id by connecting [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, another of those <em>note-to-self</em> posts, since each time I try to connect a new device to the computer I&#8217;ve already forgotten how this is done :-)<br />
<span id="more-3596"></span><br />
Here are the <a href="http://developer.android.com/guide/developing/device.html">official instructions</a>, with a list of vendor IDs. If your vendor is not on this list, try to find out the vendor id by connecting the device with USB and running:</p>
<div class="syhi_block"><code>lsusb</code></div>
<p>For example, if we got this output:</p>
<div class="syhi_block"><code>Bus 001 Device 008: ID 0fce:615d Sony Ericsson Mobile Communications AB</code></div>
<p>the vendor ID is <strong>0fce</strong>, i.e. the four numbers to the left of the semicolon on the left of the Vendor name (gee! this is overcomplicated!)</p>
<p>Then /etc/udev/rules.d/51-android.rules must be edited (by root) and the proper vendor must be added. For example:</p>
<div class="syhi_block"><code>SUBSYSTEM==&quot;usb&quot;, ATTR{idVendor}==&quot;0fce&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot;</code></div>
<p>Now I still haven&#8217;t exactly found which steps are really necessary and in which order, but seems that you might need to do some or all of the following actions so that the device is finally recognised:</p>
<ul>
<li>unplug the phone, maybe disable and enable USB debugging in it</li>
<li>kill and restart the adb server:
<div class="syhi_block"><code>adb kill-server; adb start-server</code></div>
</li>
<li>restart the udev service:
<div class="syhi_block"><code><span style="color: #c20cb9; font-weight: bold;">sudo</span> restart udev</code></div>
</li>
</ul>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3596&amp;md5=af43e24f944d4c63b2327ece803d3013" 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/2011/07/18/insufficient-permissions-for-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

