<?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>Codec</title>
	<atom:link href="http://www.trembl.org/codec/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trembl.org/codec</link>
	<description>A Personal Polylogic Code/Decode &#039;Zettelkasten&#039;</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:38:01 +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>Swapping div elements with jQuery</title>
		<link>http://www.trembl.org/codec/818/</link>
		<comments>http://www.trembl.org/codec/818/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 03:35:27 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[replaceWidth]]></category>
		<category><![CDATA[swapping]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=818</guid>
		<description><![CDATA[I found myself in need for swapping div elements. On the one hand, elements, which are situated next to each other (in the code), on the other hand I also wanted to swap only sub-elements of these divs. How can this be done with jQuery? Let&#8217;s start with the first case, swapping adjunct divs. &#60;div [...]]]></description>
			<content:encoded><![CDATA[<p>I found myself in need for swapping div elements. On the one hand, elements, which are situated next to each other (in the code), on the other hand I also wanted to swap only sub-elements of these divs.</p>
<p>How can this be done with jQuery?</p>
<p>Let&#8217;s start with the first case, swapping adjunct divs.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;element&quot; id=&quot;e0&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;element&quot; id=&quot;e1&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;element&quot; id=&quot;e2&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;element&quot; id=&quot;e3&quot;&gt;...&lt;/div&gt;
&lt;div class=&quot;element&quot; id=&quot;e4&quot;&gt;...&lt;/div&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// get a handle on the elements</span>
<span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.elements&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// let's assume, we want to swap #e2 and #e3</span>
<span style="color: #003366; font-weight: bold;">var</span> leftElement <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>elements<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> rightElement <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>elements<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
leftElement.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>rightElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// inserts leftElement after rightElement</span></pre></div></div>

<p><em>insertAfter</em> takes the object, with with the method is associated (leftElement) and inserts the object&#8217;s div after the div specified as a method argument. Here&#8217;s more on <a href="http://stackoverflow.com/questions/698301/is-there-a-native-jquery-function-to-switch-elements">SO</a> about it.</p>
<p>In a previous version of the code, i mistakenly though, that it&#8217;s necessary to replace the leftElement with the right one prior to inserting&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// NG</span>
leftElement.<span style="color: #660066;">replaceWith</span><span style="color: #009900;">&#40;</span>rightElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
leftElement.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span>rightElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This also seemed to work ok. Only later I found out, that any jQuery data() objects connected to the rightElement will get wiped when <em>replaceWith</em> is being called.</p>
<p>Finally you&#8217;ll also want to do an update to the elements array, to get them in their new order:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.elements&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><!-- The second case, swapping only parts of elements works quite similar: </p>
<p>		var leftControl = $(pb.controls[nr]);			// get handler to cached controls<br />
		var rightControl = $(pb.controls[nr+1]);<br />
	//	leftControl.replaceWith(right);					// remove rightEmptyCell control &#038; replace left control with it</p>
<p>		rightControl.insertAfter(leftControl);			// right control is inserted after left control<br />
		$("#rightEmptyCell").append(leftControl);		// left control is appended to #rightEmptyCell</p>
<p>--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/818/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swapping Array Items in Javascript</title>
		<link>http://www.trembl.org/codec/814/</link>
		<comments>http://www.trembl.org/codec/814/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 07:55:04 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=814</guid>
		<description><![CDATA[var myArray = &#91;&#34;a&#34;, &#34;c&#34;, &#34;b&#34;&#93;; myArray.swap&#40;1, 2&#41;; console.log&#40;myArray&#41;; // [&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]; &#160; Array.prototype.swap=function&#40;a, b&#41; &#123; this&#91;a&#93;= this.splice&#40;b, 1, this&#91;a&#93;&#41;&#91;0&#93;; return this; &#125; It could also be done with a temp var, but this solution seems to be the most elegant. The key to this is in the additional arguments the splice() function can [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
myArray.<span style="color: #660066;">swap</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>myArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;];</span>
&nbsp;
Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">swap</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>a<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>a<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It could also be done with a temp var, but this solution seems to be the most elegant. The key to this is in the additional arguments the splice() function can accept.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">splice<span style="color: #009900;">&#40;</span>start<span style="color: #339933;">,</span> itemCount<span style="color: #339933;">,</span> additionalItems ...<span style="color: #009900;">&#41;</span></pre></div></div>

<p>splice() removes elements denominated by the <em>start</em> and <em>itemCount</em> argument, and &#8211; if specified &#8211; inserts <em>additional items</em> at the same position.</p>
<p>Also important to note is that splice() returns an <em>array</em>. And to turn that array into an item again we need to select it directly with [0].</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/814/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Getting the element index from a list of identical class elements</title>
		<link>http://www.trembl.org/codec/812/</link>
		<comments>http://www.trembl.org/codec/812/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 07:32:45 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[selection]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=812</guid>
		<description><![CDATA[Let&#8217;s say you have a number of identical class elements: &#60;div class=&#34;myClass&#34;&#62;One Title&#60;/div&#62; &#60;div class=&#34;myClass&#34;&#62;Another Title&#60;/div&#62; &#60;div class=&#34;myClass&#34;&#62;Brrrr&#60;/div&#62; &#60;div class=&#34;myClass&#34;&#62;Zzzzzz&#60;/div&#62; And you want to get a particular element from this list. var myArray = $&#40;&#34;.myClass&#34;&#41;; var thirdElement = myArray&#91;2&#93;; console.log&#40;thirdElement&#41;; // &#60;div class=&#34;myClass&#34;&#62;Brrrr&#60;/div&#62; But note, that myArray[2] is the HTML element, not an jQuery object. [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have a number of identical class elements:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;myClass&quot;&gt;One Title&lt;/div&gt;
&lt;div class=&quot;myClass&quot;&gt;Another Title&lt;/div&gt;
&lt;div class=&quot;myClass&quot;&gt;Brrrr&lt;/div&gt;
&lt;div class=&quot;myClass&quot;&gt;Zzzzzz&lt;/div&gt;</pre></div></div>

<p>And you want to get a particular element from this list.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myClass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> thirdElement <span style="color: #339933;">=</span> myArray<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>thirdElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// &lt;div class=&quot;myClass&quot;&gt;Brrrr&lt;/div&gt;</span></pre></div></div>

<p>But note, that <em>myArray[2]</em> is the HTML element, not an jQuery object. If you want to access it via jQuery, you&#8217;ll have to &#8220;arm&#8221; it&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myClass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> thirdElement <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>myArray<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>thirdElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// [&lt;div class=&quot;myClass&quot;&gt;Brrrr&lt;/div&gt;]</span></pre></div></div>

<p>Interrating over a jQuery selected list can be done with the each() function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">myArray.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myElement <span style="color: #339933;">=</span> myArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// this</span>
	<span style="color: #006600; font-style: italic;">// element</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>myElement</em>, <em>element</em> and <em>this</em> would all hold the same value at each iteration. <em>i</em> is obviously the index counter. </p>
<p>It&#8217;s also described quite clearly at the <a href="http://api.jquery.com/index/">jQuery Docs</a>, but I think it&#8217;s important enough to reiterate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/812/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying Arrays in Javascript with slice(0)</title>
		<link>http://www.trembl.org/codec/813/</link>
		<comments>http://www.trembl.org/codec/813/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 08:10:17 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[slice]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=813</guid>
		<description><![CDATA[Using Arrays in Javascript retain their values by references. var oneArray = &#91;&#34;a&#34;, &#34;b&#34;, &#34;c&#34;&#93;; var anotherArray = oneArray; anotherArray&#91;0&#93; = &#34;z&#34;; &#160; console.log&#40;oneArray, anotherArray&#41;; // [&#34;z&#34;, &#34;b&#34;, &#34;c&#34;], [&#34;z&#34;, &#34;b&#34;, &#34;c&#34;] Ok, but let&#8217;s say you&#8217;ll need to make a copy of the array. How do you do that? var oneArray = &#91;&#34;a&#34;, &#34;b&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>Using Arrays in Javascript retain their values by references.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> oneArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> anotherArray <span style="color: #339933;">=</span> oneArray<span style="color: #339933;">;</span>
anotherArray<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;z&quot;</span><span style="color: #339933;">;</span>
&nbsp;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>oneArray<span style="color: #339933;">,</span> anotherArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// [&quot;z&quot;, &quot;b&quot;, &quot;c&quot;], [&quot;z&quot;, &quot;b&quot;, &quot;c&quot;]</span></pre></div></div>

<p>Ok, but let&#8217;s say you&#8217;ll need to make a <em>copy</em> of the array. How do you do that?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> oneArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> anotherArray <span style="color: #339933;">=</span> oneArray.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
anotherArray<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;z&quot;</span><span style="color: #339933;">;</span>
&nbsp;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>oneArray<span style="color: #339933;">,</span> anotherArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;], [&quot;z&quot;, &quot;b&quot;, &quot;c&quot;]</span></pre></div></div>

<p>If you&#8217;d really, really want you could also wrap it into a prototype function. Although the code-characters savings are minimal.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">copy</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> anotherArray <span style="color: #339933;">=</span> oneArray.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//vs</span>
<span style="color: #003366; font-weight: bold;">var</span> anotherArray <span style="color: #339933;">=</span> oneArray.<span style="color: #660066;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Minimal, but maybe contextually for self-explaining.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/813/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuji Xerox ApeosPort (DocuCentre) IV C3370 &amp; OSX Lion</title>
		<link>http://www.trembl.org/codec/811/</link>
		<comments>http://www.trembl.org/codec/811/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 09:01:49 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[printer]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=811</guid>
		<description><![CDATA[Setting up the ApeosPort C3370 in OSX Lion should not be difficult at all. Download the latest drivers, install, select and there you go. Right? Not quite. Selecting &#8220;FX ApeosPort-IV C3370 v3017.104 PS&#8221; or similar driver did not produce a workable connection to the printer. Rather it produced some annoying &#8216;beep&#8217; sounds at the printer [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up the ApeosPort C3370 in OSX Lion should not be difficult at all. Download the latest drivers, install, select and there you go. Right? Not quite.</p>
<p>Selecting &#8220;FX ApeosPort-IV C3370 v3017.104 PS&#8221; or similar driver did not produce a workable connection to the printer. Rather it produced some annoying &#8216;beep&#8217; sounds at the printer every time I was trying to print. But it did not produce any print-outs.</p>
<p>Thanks to <a href="http://populationjim.com/2011/02/22/fun-fact-1-fujixerox-docucentre-iv-c3370-vs-mac-os/">this</a> I found that the solution is to select the following driver: &#8220;FX Print Drive for Mac OX v1.2.2&#8243; (or whatever the latest version might be). It&#8217;s working!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/811/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Circos comes to OSX-town!</title>
		<link>http://www.trembl.org/codec/810/</link>
		<comments>http://www.trembl.org/codec/810/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 03:33:19 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[circos]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=810</guid>
		<description><![CDATA[Circos, the Perl-package for visualizing data and information in a circular layout is an immensely popular application in the bio-informatics/bio-visualization community. And rightly so, as it able to produce visually stunning and appealing graphics. Because its the native environment is bio-informaticians, the software is written in Perl. For those without Perl experience, it can be [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://circos.ca/">Circos</a>, the Perl-package for visualizing data and information in a circular layout is an immensely popular application in the bio-informatics/bio-visualization community. And rightly so, as it able to produce visually stunning and appealing graphics.</p>
<p>Because its the native environment is bio-informaticians, the software is written in Perl. For those without Perl experience, it can be slightly frustrating to set it up on OSX (as it was for me). Here are the steps I needed to do to get it running, hope that this might reduce the trouble and let others get to work on their visualization more quickly.</p>
<p>The whole installation process is also detailed on the <a href="http://circos.ca/software/installation/">Installation</a> page.</p>
<p><strong>1 Getting Circos</strong><br />
Download the <a href="http://circos.ca/software/download/">software, tutorials, tools and courses</a></p>
<p><strong>2 Testing the modules</strong><br />
Go the the circosX-XX/bin folder and run: ./test.modules<br />
This gives you a list of the installed Perl modules, and &#8211; more importantly &#8211; the ones still missing.</p>
<p><strong>3 Install the missing modules</strong><br />
Switch to the super user with &#8216;su&#8217;.<br />
For each missing modules say: cpan -i Modulename::Subname</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cpan -i Config::General
cpan -i Graphics::ColorObject
cpan -i Math::VecStat
etc, etc</pre></div></div>

<p>All worked swimmingly, except GD was making a bit of trouble.</p>
<p><strong>4 Installing GD</strong><br />
The graphics library GD has to be present on your system. If it&#8217;s not, install it. (I am with <a href="http://mxcl.github.com/homebrew/">homebrew</a>, therefore installing GD is done like that: <em>brew install gd</em>)</p>
<p>Still after installing GD, installing the Perl module would not work. But after applying a little force, it went fine:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cpan -i -f GD</pre></div></div>

<p><strong>5 Adding circos to your path</strong><br />
Adding the circos &#8216;bin&#8217; directory to your path lets you call the circos program directly without specifying the whole path. That&#8217;s a good thing.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">PATH=&quot;/path/to/circos-0.55/bin:${PATH}&quot;
export PATH</pre></div></div>

<p>After that, everything should work and your Circos adventure can begin&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/810/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Measuring Text in Canvas</title>
		<link>http://www.trembl.org/codec/809/</link>
		<comments>http://www.trembl.org/codec/809/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 03:10:00 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=809</guid>
		<description><![CDATA[HTML Canvas allows for the drawing of text with ctx.fillStyle = &#34;666&#34;; // text color ctx.textAlign = &#34;center&#34;; // alignment ctx.font = &#34;normal 12px Helvetica Neue&#34;; // font ctx.fillText&#40;&#34;my Text, x , y); // draw Sometimes, you might want to draw a border around the text. Getting the textHeight should not present a problem, after [...]]]></description>
			<content:encoded><![CDATA[<p>HTML Canvas allows for the drawing of text with</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">ctx.<span style="color: #660066;">fillStyle</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;666&quot;</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">// text color</span>
ctx.<span style="color: #660066;">textAlign</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;center&quot;</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">// alignment</span>
ctx.<span style="color: #660066;">font</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;normal 12px Helvetica Neue&quot;</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">// font</span>
ctx.<span style="color: #660066;">fillText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;my Text, x , y);		// draw</span></pre></div></div>

<p>Sometimes, you might want to draw a border around the text. Getting the textHeight should not present a problem, after all we can set the font size directly. But textWidth is not fixed in that way, because it depends (nnnn) on the actual text that is being displayed.</p>
<p>ctx.<a href="https://developer.mozilla.org/en/Drawing_text_using_a_canvas#measureText">measureText</a> takes the text as an argument and returns an object with a <em>width</em> property, describing the width of the text.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> texttWidth <span style="color: #339933;">=</span> ctx.<span style="color: #660066;">measureText</span><span style="color: #009900;">&#40;</span>columnName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>width</em> is for now the only inhabitant of that object, but it would be a fair guess, that it might be more densely populate in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/809/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replacing HTML elements with jQuery&#8217;s replaceWith</title>
		<link>http://www.trembl.org/codec/806/</link>
		<comments>http://www.trembl.org/codec/806/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 08:23:56 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=806</guid>
		<description><![CDATA[Let&#8217;s say you are having some HTML elements that should only be enabled, if the browser sports certain features. By default, the element is disabled, like in the following example: &#60;div id=&#34;item&#34; class=&#34;disabled&#34;&#62;Open File...&#60;/div&#62; Next, we check in Javascript is this certain feature is supported. If it is, we replace the disabled element with an [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you are having some HTML elements that should only be enabled, if the browser sports certain features. By default, the element is disabled, like in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;item&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;disabled&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Open File...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Next, we check in Javascript is this certain feature is supported. If it is, we <a href="http://api.jquery.com/replaceWith/">replace</a> the disabled element with an active version.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSupported<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#item'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replaceWith</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a id=&quot;openFile&quot;&gt;Open File...&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Which results in this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;item&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Open File...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Simple, but effective.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/806/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursively removing .svn directories</title>
		<link>http://www.trembl.org/codec/805/</link>
		<comments>http://www.trembl.org/codec/805/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 03:27:06 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[backticks]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=805</guid>
		<description><![CDATA[When you&#8217;are working with Subversion, the situation might be familiar: You have checked-out some directories and want to check them in at another repository. Subversion is not happy to do that, it complains with a friendly reminder, that &#8216;your directory&#8217; is already under version control. The proper way to do it, would probably be to [...]]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;are working with Subversion, the situation might be familiar: You have checked-out some directories and want to check them in at another repository. Subversion is not happy to do that, it complains with a friendly reminder, that <em>&#8216;your directory&#8217; is already under version control</em>. </p>
<p>The proper way to do it, would probably be to <a href="http://svnbook.red-bean.com/en/1.0/re10.html">export a clean directory tree</a>, but sometimes this option is not available.</p>
<p>Here&#8217;s a simple shell script to recursively remove all the hidden &#8216;.svn&#8217; directories:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> d <span style="color: #660033;">-name</span> .svn<span style="color: #000000; font-weight: bold;">`</span></pre></div></div>

<p>Wether it is better to use backticks or xargs is being discussed <a href="http://superuser.com/questions/64792/xargs-vs-backtick">elsewhere</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/805/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freezing Objects and Arrays in Javascript</title>
		<link>http://www.trembl.org/codec/804/</link>
		<comments>http://www.trembl.org/codec/804/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 07:50:15 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[freeze]]></category>
		<category><![CDATA[isFrozen]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[object]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=804</guid>
		<description><![CDATA[Since the ECMA-262 specifications (aka Javascript 1.8.5 aka ECMAScript 5th Edition) it is possible prevent Objects from accepting any changes to their properties. After applying Object.freeze(myObj) it won&#8217;t be possible to change, add or remove properties from myObj. So far so good. As in Javascript Arrays also inherit from Object, I could see not reason, [...]]]></description>
			<content:encoded><![CDATA[<p>Since the ECMA-262 specifications (aka Javascript 1.8.5 aka ECMAScript 5th Edition) it is possible prevent Objects from accepting any changes to their properties. After applying <em>Object.freeze(myObj)</em> it won&#8217;t be possible to change, add or remove properties from <em>myObj</em>.</p>
<p>So far so good.</p>
<p>As in Javascript Arrays also inherit from Object, I could see not reason, why freezing an array should not work.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'b:2'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
Object.<span style="color: #660066;">freeze</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Object.<span style="color: #660066;">isFrozen</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>       <span style="color: #006600; font-style: italic;">// returns true</span>
obj.<span style="color: #660066;">a</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>                 <span style="color: #006600; font-style: italic;">// new assignment has no affect</span>
obj.<span style="color: #660066;">a</span><span style="color: #339933;">;</span>                      <span style="color: #006600; font-style: italic;">// returns 1</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
Object.<span style="color: #660066;">freeze</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Object.<span style="color: #660066;">isFrozen</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      <span style="color: #006600; font-style: italic;">// returns true</span>
arr<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
arr<span style="color: #339933;">;</span>                       <span style="color: #006600; font-style: italic;">// returns [10, 2] ... ouch!</span></pre></div></div>

<p>It turns out, that it seems to be an implementation bug in Safari (5.1). It&#8217;s working in the latest Firefox and Chrome releases.</p>
<p>To check whether freezing arrays works in your brower, click the following button:<br />
<button onClick="javascript:checkTheFreezer()">Check the Freezer!</button></p>
<p>ps. I asked the question first on Stack Overflow: <a href="http://stackoverflow.com/questions/7509894/freezing-arrays-in-javascript">&#8216;Freezing&#8217; Arrays in Javascript?</a>. Thanks for the constructive answers.</p>
<p><script type="text/javascript">
function checkTheFreezer() {
	var arr = ["icecream", "peas", "pizza"];
	var str = "Original Array: " + arr + "\n\n";
	Object.freeze(arr);
	str += "Array is frozen? " + Object.isFrozen(arr) + "\n";
	arr[0] = "hot cocoa";
	str += "Frozen Array: " + arr + "\n\n";
	if (arr[0]==="hot cocoa") {
		str += "Array freeze DOES NOT work.";
	} else {
		str += "Array freeze works.";
	}
	alert(str);
}
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/804/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

