<?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>ADM Blog</title> <atom:link href="http://blog.another-d-mention.ro/feed/" rel="self" type="application/rss+xml" /><link>http://blog.another-d-mention.ro</link> <description>No matter how you see things, reality changes when you reach understanding</description> <lastBuildDate>Fri, 22 Jul 2011 06:56:49 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1</generator> <item><title>Pixel Programming</title><link>http://blog.another-d-mention.ro/programming/pixel-programming/</link> <comments>http://blog.another-d-mention.ro/programming/pixel-programming/#comments</comments> <pubDate>Fri, 22 Jul 2011 06:56:22 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[64k]]></category> <category><![CDATA[demo]]></category> <category><![CDATA[photoshop]]></category> <category><![CDATA[pixel]]></category> <category><![CDATA[programming]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=856</guid> <description><![CDATA[If you're old enough you may have seen the times when programmers wrote code as optimal as possible given the computers available back then. I remember 3D shooter games that would average 300 - 400 KB in size and you would play countless levels for days. Here's for example a 96 KB 3D shooter game [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you're old enough you may have seen the times when programmers wrote code as optimal as possible given the computers available back then. I remember 3D shooter games that would average 300 - 400 KB in size and you would play countless levels for days. Here's for example a 96 KB 3D shooter game called <a
href="http://www.theprodukkt.com/kkrieger">.kkriger </a> that will leave you breathless.</p><p><a
target="_blank" href="http://blog.another-d-mention.ro/wp-content/uploads/2011/07/full1.jpg"><img
src="http://blog.another-d-mention.ro/wp-content/uploads/2011/07/full1-300x225.jpg" alt="full1 300x225 Pixel Programming" title="full1" width="300" height="225" class="aligncenter size-medium wp-image-857" /></a></p><p>If you try now to explain people these days that it takes less space to write a 3 minutes HD animated video and music clip than than it takes to store a 32×32 pixel icon they won't believe you. Not now when a plain jpeg image used on some website is > 50KB. So here's a guy called <a
target="_blank" href="http://www.iquilezles.org/">Iñigo Quílez</a> who demonstrates just that using the image analogy. He writes a x86 real mode demo using Photoshop. The entire program is done by creating a 9x9 pixels image, filling each pixels with carefully chosen colors to represent the correct opcodes (who needs compilers, right ?) The image is then saved in a .raw format (no headers) then renames it to a .com file so that Windows recognize it as a executable. The animation is a infinite moving tunnel with a gray colored texture created with an XOR pattern, blurred, and deformed using a <a
target="_blank" href="http://www.iquilezles.org/www/articles/deform/deform.htm">plane deformation</a> technique to produce the animation.</p><p>This is the "source code" resized 10 times in a png extension</p><p><img
src="http://blog.another-d-mention.ro/wp-content/uploads/2011/07/pixel01.png" alt="pixel01 Pixel Programming" title="" width="90" height="90" class="aligncenter size-full wp-image-858" /></p><p>And here's the guy in action proving his mad skills.</p><div
style="text-align:center"> <iframe
width="640" height="510" src="http://www.youtube.com/embed/FvS_DG8yIqQ?hd=1" frameborder="0" allowfullscreen></iframe></div><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/pixel-programming/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Read data directly from base64 without decoding</title><link>http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/</link> <comments>http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/#comments</comments> <pubDate>Fri, 01 Jul 2011 13:06:55 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Java Script]]></category> <category><![CDATA[base64]]></category> <category><![CDATA[decode]]></category> <category><![CDATA[javascript]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=855</guid> <description><![CDATA[So here's the catch. You have a binary input you want to mess with in your browser for whatever reason. First problem you encounter is when you load the file. In IE you will have trouble reading a binary string because it uses null terminated strings, and your file will end at the first 0x00 [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/' rel='bookmark' title='Permanent Link: jQuery.quickEach'>jQuery.quickEach</a></li></ol>]]></description> <content:encoded><![CDATA[<p>So here's the catch. You have a binary input you want to mess with in your browser for whatever reason. First problem you encounter is when you load the file. In IE you will have trouble reading a binary string because it uses null terminated strings, and your file will end at the first 0x00 byte found. If you manage to overcome that but trust me it is very CPU intensive. See the source of <a
href="http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/">Read/Load files from ZIP in Javascript</a> post. You will have to create a vbScript that will convert the received AJAX response into an array with decimal values for each byte in the file. Depending on your file size, it will take accordingly (10+ seconds * file KB). For every other browser it works just fine with plain strings.</p><p>Okay, one other potential issue may come if you need to receive the data into a JSON string or XML or whatever beside a plain binary file. Then you have to use BASE64 encoding and decode your data into a variable but must keep in mind the first issue with the null characters. My solution to this problem is to create a method to read directly from the BASE64 encoded string at arbitrary locations without decoding the entire thing.</p><p>Here's an example of a binary file:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">Offset<span style="color: #009900;">&#40;</span>h<span style="color: #009900;">&#41;</span>00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
&nbsp;
00000000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F     ...............
00000010 <span style="color: #CC0000;">19</span> <span style="color: #CC0000;">84</span> <span style="color: #CC0000;">74</span> <span style="color: #CC0000;">68</span> <span style="color: #CC0000;">69</span> <span style="color: #CC0000;">73</span> <span style="color: #CC0000;">20</span> <span style="color: #CC0000;">69</span> <span style="color: #CC0000;">73</span> <span style="color: #CC0000;">20</span> <span style="color: #CC0000;">61</span> <span style="color: #CC0000;">20</span> <span style="color: #CC0000;">74</span> <span style="color: #CC0000;">65</span> <span style="color: #CC0000;">73</span> <span style="color: #CC0000;">74</span>     ..<span style="color: #000066; font-weight: bold;">this</span> <span style="color: #000066; font-weight: bold;">is</span> a test</pre></div></div><p>You have 32 bytes in this file, with BASE64 encoding you get a 46 chars length string:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">   AAECAwQFBgcICQoLDA0ODxmEdGhpcyBpcyBhIHRlc3Q<span style="color: #339933;">=</span></pre></div></div><p>A usage example:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Base64Native<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;AAECAwQFBgcICQoLDA0ODxmEdGhpcyBpcyBhIHRlc3Q=&quot;</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>data.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs 32;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">readBoolean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs false; - reads a byte and casts it to a boolean value</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">readByte</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs 1;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">readWord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs 515; - reads a 16 bit number</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">readInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs 67438087; - reads a 32 bit number</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">seek</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">28</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// moves the pointer to byte 28 (0x1C)</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">readString</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">bytesAvailable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// outputs 'test'; reads a string from position 28 to the end of the file</span></pre></div></div><p>And here's the class</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Base64Native <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> keyStr <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=&quot;</span><span style="color: #339933;">,</span>
        length <span style="color: #339933;">=</span> data.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">length</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/=/g</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        ptr <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> keyIdx<span style="color: #009900;">&#40;</span>idx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> keyStr.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>idx<span style="color: #009900;">&#41;</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;">function</span> readByte<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;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>length <span style="color: #339933;">-</span> ptr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">throw</span> Error<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'End of stream!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> blockIndex <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>ptr <span style="color: #339933;">/</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> subIndex <span style="color: #339933;">=</span> ptr<span style="color: #339933;">++</span> <span style="color: #339933;">%</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> ptrChr <span style="color: #339933;">=</span> blockIndex <span style="color: #339933;">+</span> subIndex<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">!</span>subIndex <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>keyIdx<span style="color: #009900;">&#40;</span>ptrChr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span>keyIdx<span style="color: #009900;">&#40;</span>ptrChr <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> subIndex <span style="color: #339933;">===</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">&amp;&amp;</span>
               <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>keyIdx<span style="color: #009900;">&#40;</span>ptrChr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span>keyIdx<span style="color: #009900;">&#40;</span>ptrChr <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>keyIdx<span style="color: #009900;">&#40;</span>ptrChr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span>  keyIdx<span style="color: #009900;">&#40;</span>ptrChr <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #009966; font-style: italic;">/* Returns the available bytes left in the file to read */</span>
        bytesAvailable <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> length <span style="color: #339933;">-</span> ptr<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Reads and returns a 8 bit number and increments the position of the index accordingly */</span>
        readByte <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> readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Reads and returns a 32 bit number and increments the position of the index accordingly */</span>
        readInt <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: #009900;">&#40;</span>readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #CC0000;">24</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span>readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span>readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #CC0000;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Reads 1 byte and returns the boolean value of it and increments the position of the index accordingly */</span>
        readBoolean <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> Boolean<span style="color: #009900;">&#40;</span>readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Reads and returns a 16 bit number and increments the position of the index accordingly */</span>
        readWord <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> readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #CC0000;">8</span> <span style="color: #339933;">|</span> readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Reads and returns a string of length 'len' and increments the position of the index accordingly */</span>
        readString <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-style: italic;">/*String*/</span>len<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                data <span style="color: #339933;">+=</span> String.<span style="color: #660066;">fromCharCode</span><span style="color: #009900;">&#40;</span>readByte<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> data<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Moves the index into the file at location newpos */</span>
        seek <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>newpos<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ptr <span style="color: #339933;">=</span> newpos<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* Returns the position of the index in the file */</span>
        position <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> ptr<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009966; font-style: italic;">/* The length of the data */</span>
        length <span style="color: #339933;">:</span> length
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div> </pre><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/' rel='bookmark' title='Permanent Link: jQuery.quickEach'>jQuery.quickEach</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>This is water</title><link>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/this-is-water/</link> <comments>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/this-is-water/#comments</comments> <pubDate>Sat, 25 Jun 2011 15:20:48 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Stories for a IT Audience]]></category> <category><![CDATA[david]]></category> <category><![CDATA[foster]]></category> <category><![CDATA[life]]></category> <category><![CDATA[work]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=854</guid> <description><![CDATA[Adapted from a commencement speech given by David Foster Wallace to the 2005 graduating class at Kenyon College. Mr. Wallace, 46, died last Friday, after apparently committing suicide There are these two young fish swimming along, and they happen to meet an older fish swimming the other way, who nods at them and says, "Morning, [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/the-truth-about-working-in-the-it-industry/' rel='bookmark' title='Permanent Link: The truth about working in the IT industry'>The truth about working in the IT industry</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/life-as-a-programmer/' rel='bookmark' title='Permanent Link: Life as a programmer'>Life as a programmer</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Adapted from a commencement speech given by David Foster Wallace to the 2005 graduating class at Kenyon College. Mr. Wallace, 46, died last Friday, after apparently committing suicide</p><p>There are these two young fish swimming along, and they happen to meet an older fish swimming the other way, who nods at them and says, "Morning, boys, how's the water?" And the two young fish swim on for a bit, and then eventually one of them looks over at the other and goes, "What the hell is water?"</p><p>If at this moment, you're worried that I plan to present myself here as the wise old fish explaining what water is to you younger fish, please don't be. I am not the wise old fish. The immediate point of the fish story is that the most obvious, ubiquitous, important realities are often the ones that are the hardest to see and talk about. Stated as an English sentence, of course, this is just a banal platitude -- but the fact is that, in the day-to-day trenches of adult existence, banal platitudes can have life-or-death importance. That may sound like hyperbole, or abstract nonsense.</p><p>A huge percentage of the stuff that I tend to be automatically certain of is, it turns out, totally wrong and deluded. Here's one example of the utter wrongness of something I tend to be automatically sure of: Everything in my own immediate experience supports my deep belief that I am the absolute center of the universe, the realest, most vivid and important person in existence. We rarely talk about this sort of natural, basic self-centeredness, because it's so socially repulsive, but it's pretty much the same for all of us, deep down. It is our default-setting, hard-wired into our boards at birth. Think about it: There is no experience you've had that you were not at the absolute center of. The world as you experience it is right there in front of you, or behind you, to the left or right of you, on your TV, or your monitor, or whatever. Other people's thoughts and feelings have to be communicated to you somehow, but your own are so immediate, urgent, real -- you get the idea. But please don't worry that I'm getting ready to preach to you about compassion or other-directedness or the so-called "virtues." This is not a matter of virtue -- it's a matter of my choosing to do the work of somehow altering or getting free of my natural, hard-wired default-setting, which is to be deeply and literally self-centered, and to see and interpret everything through this lens of self.</p><p>People who can adjust their natural default-setting this way are often described as being "well adjusted," which I suggest to you is not an accidental term.</p><p>Given the triumphal academic setting here, an obvious question is how much of this work of adjusting our default-setting involves actual knowledge or intellect. This question gets tricky. Probably the most dangerous thing about college education, at least in my own case, is that it enables my tendency to over-intellectualize stuff, to get lost in abstract arguments inside my head instead of simply paying attention to what's going on right in front of me. Paying attention to what's going on inside me. As I'm sure you guys know by now, it is extremely difficult to stay alert and attentive instead of getting hypnotized by the constant monologue inside your own head. Twenty years after my own graduation, I have come gradually to understand that the liberal-arts cliché about "teaching you how to think" is actually shorthand for a much deeper, more serious idea: "Learning how to think" really means learning how to exercise some control over how and what you think. It means being conscious and aware enough to choose what you pay attention to and to choose how you construct meaning from experience. Because if you cannot exercise this kind of choice in adult life, you will be totally hosed. Think of the old cliché about "the mind being an excellent servant but a terrible master." This, like many clichés, so lame and unexciting on the surface, actually expresses a great and terrible truth. It is not the least bit coincidental that adults who commit suicide with firearms almost always shoot themselves in the head. And the truth is that most of these suicides are actually dead long before they pull the trigger. And I submit that this is what the real, no-bull- value of your liberal-arts education is supposed to be about: How to keep from going through your comfortable, prosperous, respectable adult life dead, unconscious, a slave to your head and to your natural default-setting of being uniquely, completely, imperially alone, day in and day out.</p><p>That may sound like hyperbole, or abstract nonsense. So let's get concrete. The plain fact is that you graduating seniors do not yet have any clue what "day in, day out" really means. There happen to be whole large parts of adult American life that nobody talks about in commencement speeches. One such part involves boredom, routine, and petty frustration. The parents and older folks here will know all too well what I'm talking about.</p><p>By way of example, let's say it's an average day, and you get up in the morning, go to your challenging job, and you work hard for nine or ten hours, and at the end of the day you're tired, and you're stressed out, and all you want is to go home and have a good supper and maybe unwind for a couple of hours and then hit the rack early because you have to get up the next day and do it all again. But then you remember there's no food at home -- you haven't had time to shop this week, because of your challenging job -- and so now after work you have to get in your car and drive to the supermarket. It's the end of the workday, and the traffic's very bad, so getting to the store takes way longer than it should, and when you finally get there the supermarket is very crowded, because of course it's the time of day when all the other people with jobs also try to squeeze in some grocery shopping, and the store's hideously, fluorescently lit, and infused with soul-killing Muzak or corporate pop, and it's pretty much the last place you want to be, but you can't just get in and quickly out: You have to wander all over the huge, overlit store's crowded aisles to find the stuff you want, and you have to maneuver your junky cart through all these other tired, hurried people with carts, and of course there are also the glacially slow old people and the spacey people and the ADHD kids who all block the aisle and you have to grit your teeth and try to be polite as you ask them to let you by, and eventually, finally, you get all your supper supplies, except now it turns out there aren't enough checkout lanes open even though it's the end-of-the-day-rush, so the checkout line is incredibly long, which is stupid and infuriating, but you can't take your fury out on the frantic lady working the register.</p><p>Anyway, you finally get to the checkout line's front, and pay for your food, and wait to get your check or card authenticated by a machine, and then get told to "Have a nice day" in a voice that is the absolute voice of death, and then you have to take your creepy flimsy plastic bags of groceries in your cart through the crowded, bumpy, littery parking lot, and try to load the bags in your car in such a way that everything doesn't fall out of the bags and roll around in the trunk on the way home, and then you have to drive all the way home through slow, heavy, SUV-intensive rush-hour traffic, etcetera, etcetera.</p><p>The point is that petty, frustrating crap like this is exactly where the work of choosing comes in. Because the traffic jams and crowded aisles and long checkout lines give me time to think, and if I don't make a conscious decision about how to think and what to pay attention to, I'm going to be pissed and miserable every time I have to food-shop, because my natural default-setting is the certainty that situations like this are really all about me, about my hungriness and my fatigue and my desire to just get home, and it's going to seem, for all the world, like everybody else is just in my way, and who are all these people in my way? And look at how repulsive most of them are and how stupid and cow-like and dead-eyed and nonhuman they seem here in the checkout line, or at how annoying and rude it is that people are talking loudly on cell phones in the middle of the line, and look at how deeply unfair this is: I've worked really hard all day and I'm starved and tired and I can't even get home to eat and unwind because of all these stupid g-d- people.</p><p>Or, of course, if I'm in a more socially conscious form of my default-setting, I can spend time in the end-of-the-day traffic jam being angry and disgusted at all the huge, stupid, lane-blocking SUV's and Hummers and V-12 pickup trucks burning their wasteful, selfish, forty-gallon tanks of gas, and I can dwell on the fact that the patriotic or religious bumper stickers always seem to be on the biggest, most disgustingly selfish vehicles driven by the ugliest, most inconsiderate and aggressive drivers, who are usually talking on cell phones as they cut people off in order to get just twenty stupid feet ahead in a traffic jam, and I can think about how our children's children will despise us for wasting all the future's fuel and probably screwing up the climate, and how spoiled and stupid and disgusting we all are, and how it all just sucks, and so on and so forth...</p><p>Look, if I choose to think this way, fine, lots of us do -- except that thinking this way tends to be so easy and automatic it doesn't have to be a choice. Thinking this way is my natural default-setting. It's the automatic, unconscious way that I experience the boring, frustrating, crowded parts of adult life when I'm operating on the automatic, unconscious belief that I am the center of the world and that my immediate needs and feelings are what should determine the world's priorities. The thing is that there are obviously different ways to think about these kinds of situations. In this traffic, all these vehicles stuck and idling in my way: It's not impossible that some of these people in SUV's have been in horrible auto accidents in the past and now find driving so traumatic that their therapist has all but ordered them to get a huge, heavy SUV so they can feel safe enough to drive; or that the Hummer that just cut me off is maybe being driven by a father whose little child is hurt or sick in the seat next to him, and he's trying to rush to the hospital, and he's in a way bigger, more legitimate hurry than I am -- it is actually I who am in his way. Or I can choose to force myself to consider the likelihood that everyone else in the supermarket's checkout line is just as bored and frustrated as I am, and that some of these people probably have much harder, more tedious or painful lives than I do, overall.</p><p>Again, please don't think that I'm giving you moral advice, or that I'm saying you're "supposed to" think this way, or that anyone expects you to just automatically do it, because it's hard, it takes will and mental effort, and if you're like me, some days you won't be able to do it, or you just flat-out won't want to. But most days, if you're aware enough to give yourself a choice, you can choose to look differently at this fat, dead-eyed, over-made-lady who just screamed at her little child in the checkout line -- maybe she's not usually like this; maybe she's been up three straight nights holding the hand of her husband who's dying of bone cancer, or maybe this very lady is the low-wage clerk at the Motor Vehicles Dept. who just yesterday helped your spouse resolve a nightmarish red-tape problem through some small act of bureaucratic kindness. Of course, none of this is likely, but it's also not impossible -- it just depends on what you want to consider. If you're automatically sure that you know what reality is and who and what is really important -- if you want to operate on your default-setting -- then you, like me, will not consider possibilities that aren't pointless and annoying. But if you've really learned how to think, how to pay attention, then you will know you have other options. It will actually be within your power to experience a crowded, loud, slow, consumer-hell-type situation as not only meaningful but sacred, on fire with the same force that lit the stars -- compassion, love, the sub-surface unity of all things. Not that that mystical stuff's necessarily true: The only thing that's capital-T True is that you get to decide how you're going to try to see it. You get to consciously decide what has meaning and what doesn't. You get to decide what to worship...</p><p>Because here's something else that's true. In the day-to-day trenches of adult life, there is actually no such thing as atheism. There is no such thing as not worshipping. Everybody worships. The only choice we get is what to worship. And an outstanding reason for choosing some sort of God or spiritual-type thing to worship -- be it J.C. or Allah, be it Yahweh or the Wiccan mother-goddess or the Four Noble Truths or some infrangible set of ethical principles -- is that pretty much anything else you worship will eat you alive. If you worship money and things -- if they are where you tap real meaning in life -- then you will never have enough. Never feel you have enough. It's the truth. Worship your own body and beauty and sexual allure and you will always feel ugly, and when time and age start showing, you will die a million deaths before they finally plant you. On one level, we all know this stuff already -- it's been codified as myths, proverbs, clichés, bromides, epigrams, parables: the skeleton of every great story. The trick is keeping the truth up-front in daily consciousness. Worship power -- you will feel weak and afraid, and you will need ever more power over others to keep the fear at bay. Worship your intellect, being seen as smart -- you will end up feeling stupid, a fraud, always on the verge of being found out. And so on.</p><p>Look, the insidious thing about these forms of worship is not that they're evil or sinful; it is that they are unconscious. They are default-settings. They're the kind of worship you just gradually slip into, day after day, getting more and more selective about what you see and how you measure value without ever being fully aware that that's what you're doing. And the world will not discourage you from operating on your default-settings, because the world of men and money and power hums along quite nicely on the fuel of fear and contempt and frustration and craving and the worship of self. Our own present culture has harnessed these forces in ways that have yielded extraordinary wealth and comfort and personal freedom. The freedom to be lords of our own tiny skull-sized kingdoms, alone at the center of all creation. This kind of freedom has much to recommend it. But of course there are all different kinds of freedom, and the kind that is most precious you will not hear much talked about in the great outside world of winning and achieving and displaying. The really important kind of freedom involves attention, and awareness, and discipline, and effort, and being able truly to care about other people and to sacrifice for them, over and over, in myriad petty little unsexy ways, every day. That is real freedom. The alternative is unconsciousness, the default-setting, the "rat race" -- the constant gnawing sense of having had and lost some infinite thing.</p><p>I know that this stuff probably doesn't sound fun and breezy or grandly inspirational. What it is, so far as I can see, is the truth with a whole lot of rhetorical bullshit pared away. Obviously, you can think of it whatever you wish. But please don't dismiss it as some finger-wagging Dr. Laura sermon. None of this is about morality, or religion, or dogma, or big fancy questions of life after death. The capital-T Truth is about life before death. It is about making it to 30, or maybe 50, without wanting to shoot yourself in the head. It is about simple awareness -- awareness of what is so real and essential, so hidden in plain sight all around us, that we have to keep reminding ourselves, over and over: "This is water, this is water."</p><div
style="text-align:right">David Foster Wallace on Life and Work</div><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/the-truth-about-working-in-the-it-industry/' rel='bookmark' title='Permanent Link: The truth about working in the IT industry'>The truth about working in the IT industry</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/life-as-a-programmer/' rel='bookmark' title='Permanent Link: Life as a programmer'>Life as a programmer</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/this-is-water/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Steve Wozniak wrote BASIC for the Apple computer in binary</title><link>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/steve-wozniak-wrote-basic-for-the-apple-computer-in-binary/</link> <comments>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/steve-wozniak-wrote-basic-for-the-apple-computer-in-binary/#comments</comments> <pubDate>Thu, 16 Jun 2011 16:36:08 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Stories for a IT Audience]]></category> <category><![CDATA[apple]]></category> <category><![CDATA[basic]]></category> <category><![CDATA[binary]]></category> <category><![CDATA[programmer]]></category> <category><![CDATA[steve]]></category> <category><![CDATA[wozniak]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=851</guid> <description><![CDATA[“If you wanted to write a computer program like the programs of the Apple II, you would write your program with another computer that would compile the code and turn it into 1s and 0s that my microprocessor could understand. Well, I couldn’t afford this little program called a compiler. You could rent terminals and [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/the-story-of-mel-a-real-programmer/' rel='bookmark' title='Permanent Link: The Story of Mel, a Real Programmer'>The Story of Mel, a Real Programmer</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/life-as-a-programmer/' rel='bookmark' title='Permanent Link: Life as a programmer'>Life as a programmer</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://blog.another-d-mention.ro/wp-content/uploads/2011/06/download-150x150.jpg" alt="download 150x150 Steve Wozniak wrote BASIC for the Apple computer in binary" title="" width="150" height="150" class="alignleft size-thumbnail wp-image-852" />“If you wanted to write a computer program like the programs of the Apple II, you would write your program with another computer that would compile the code and turn it into 1s and 0s that my microprocessor could understand. Well, I couldn’t afford this little program called a compiler. You could rent terminals and time-shared computer systems, and pay a certain amount of money per month, and you could actually write your programs. But since I couldn’t afford that, either, I wrote my programs on one side of a piece of paper by hand. Then I wrote the 1s and 0s that they would translate into on the other side, figuring it out from little cards I had about how the microprocessors work. No other project that large has probably ever been done that way. I still have the whole handwritten manual. But that made me very intimate with the code. Every little line mattered a lot, and it was a representation of myself, too. It had to be so perfect that nobody else could have thought of a better way. If I ever thought of any little section of code that had a slightly better way, I would change it and go that way. The lack of money actually helped lead to that because the lack of money forced me to be very intimate with the code I was writing. Then I would have to type the 1s and 0s into my computer. For BASIC, it took me 40 minutes. I’d turn on the power, type it in for 40 minutes, test that there weren’t any errors, and then go on debugging the next section. So it was like, no tools, no money—I did it all myself without tools, and that led to a very noticeable type of skill excellence.”</p><p><a
href="http://makingitbigcareers.com/steve-wozniak-wrote-basic-for-the-apple-computer-in-binary/" target="_blank">source</a></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/the-story-of-mel-a-real-programmer/' rel='bookmark' title='Permanent Link: The Story of Mel, a Real Programmer'>The Story of Mel, a Real Programmer</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/programming-is-like-sex/' rel='bookmark' title='Permanent Link: Programming is like sex'>Programming is like sex</a></li><li><a
href='http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/life-as-a-programmer/' rel='bookmark' title='Permanent Link: Life as a programmer'>Life as a programmer</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/misc/stories-for-a-it-audience/steve-wozniak-wrote-basic-for-the-apple-computer-in-binary/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>jQuery.quickEach</title><link>http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/</link> <comments>http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/#comments</comments> <pubDate>Wed, 04 May 2011 09:13:08 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Java Script]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[plugin]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=847</guid> <description><![CDATA[With jQuery, when you need to iterate all elements with a specific class for example, you use the each() method and inside the callback function you must convert the DOM element you receive as this to a jQuery object in order to access it's jQuery specific methods: $(this) This is not such a big issue [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/parse-xml-in-javascript-with-jquery/' rel='bookmark' title='Permanent Link: Parse XML in JavaScript with jQuery'>Parse XML in JavaScript with jQuery</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li></ol>]]></description> <content:encoded><![CDATA[<p>With jQuery, when you need to iterate all elements with a specific class for example, you use the <code>each()</code> method and inside the callback function you must convert the DOM element you receive as <code>this</code> to a jQuery object in order to access it's jQuery specific methods: <code>$(this)</code><br
/> This is not such a big issue but if you have a lot of items and/or do this often, then times ads up. It would be a blast to have the <code>this</code> object directly as a jQuery instance. So here's a $ little plugin that does exactly that</p><p>Source website:<br
/> <a
href="http://jsperf.com/jquery-each-vs-quickeach" target="_blank">http://jsperf.com/jquery-each-vs-quickeach</a></p><p>The code:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">quickEach</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</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: #003366; font-weight: bold;">var</span> jq <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>
       el<span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>i <span style="color: #339933;">&lt;</span> len <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>el <span style="color: #339933;">=</span> jq<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;">this</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>jq<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> el<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">delete</span> jq<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;">throw</span> e<span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">delete</span> jq<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><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>If you run the test on that page, on most browsers you'll see that quickEach() is about 80% faster than native each()</pre><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/parse-xml-in-javascript-with-jquery/' rel='bookmark' title='Permanent Link: Parse XML in JavaScript with jQuery'>Parse XML in JavaScript with jQuery</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>For Javascript devs</title><link>http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/</link> <comments>http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/#comments</comments> <pubDate>Wed, 30 Mar 2011 08:08:18 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Java Script]]></category> <category><![CDATA[html]]></category> <category><![CDATA[htmtag]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[querytag]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=846</guid> <description><![CDATA[If you write Javascript apps you may want to dynamically add some HTML here and there and having HTML strings that need concatenation with different variables is bad and ugly at the same time. So here is a little nugget you might find useful. 1 2 3 4 5 // standard style x = '&#60;div [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you write Javascript apps you may want to dynamically add some HTML here and there and having HTML strings that need concatenation with different variables is bad and ugly at the same time. So here is a little nugget you might find useful.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #006600; font-style: italic;">// standard style</span>
    x <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div class=&quot;'</span> <span style="color: #339933;">+</span> classnames <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; rel=&quot;'</span> <span style="color: #339933;">+</span> somevar <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; id=&quot;'</span> <span style="color: #339933;">+</span> othervar <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span> <span style="color: #339933;">+</span> content <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// html tag style</span>
    x <span style="color: #339933;">=</span> htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">:</span>classname<span style="color: #339933;">,</span> rel<span style="color: #339933;">:</span>somevar<span style="color: #339933;">,</span> id<span style="color: #339933;">:</span>othervar<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><h3>Usage</h3><p> <code>htmlTag(tagName [, attributes [, content]])</code><br
/> or<br
/> <code>htmlTag(tagName [, content [, attributes]])</code></p><p>The function can be called with one, two or three arguments. Beside the first one which is the name of the tag (string), the other two are optional and can be placed in whatever order you like.<br
/> For <strong>img</strong> tags, the content argument is set as <i>src</i> attribute or as <i>value</i> attribute for <strong>input</strong> tags if the attributes argument doesn't specify otherwise</p><p><i>attributes</i> argument must be an object with key:value pairs and will be expanded as attributes of the tag<br
/> <i>content</i> argument is a string or number</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> classname <span style="color: #339933;">=</span> <span style="color: #3366CC;">'test'</span><span style="color: #339933;">,</span> somevar <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> id <span style="color: #339933;">=</span> <span style="color: #3366CC;">'mydiv'</span><span style="color: #339933;">,</span> content <span style="color: #339933;">=</span> <span style="color: #3366CC;">'hello'</span><span style="color: #339933;">;</span>
&nbsp;
    htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">:</span>classname<span style="color: #339933;">,</span> rel<span style="color: #339933;">:</span>somevar<span style="color: #339933;">,</span> id<span style="color: #339933;">:</span>othervar<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> content<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">:</span>classname<span style="color: #339933;">,</span> rel<span style="color: #339933;">:</span>somevar<span style="color: #339933;">,</span> id<span style="color: #339933;">:</span>othervar<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// will both return &lt;div class='test' rel='2' id='mydiv'&gt;hello&lt;/div&gt;</span>
&nbsp;
    htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span>
    <span style="color: #006600; font-style: italic;">// &lt;img src='hello' /&gt;</span>
    htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>src<span style="color: #339933;">:</span><span style="color: #3366CC;">'myImage.jpg'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span>
    <span style="color: #006600; font-style: italic;">// &lt;img src='myImage.jpg' /&gt; content is discarded and attributes src is used as source</span>
&nbsp;
    htmlTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span>id<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span>
    <span style="color: #006600; font-style: italic;">// &lt;input type=&quot;text&quot; name=&quot;mydiv&quot; value=&quot;hello&quot; /&gt;</span></pre></td></tr></table></div><h3>The code</h3><p></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> htmlTag<span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> r<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt; &quot;</span><span style="color: #339933;">+</span>type<span style="color: #339933;">,</span>o<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>v<span style="color: #339933;">=</span><span style="color: #3366CC;">''</span><span style="color: #339933;">,</span>x<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>a<span style="color: #339933;">=</span>arguments<span style="color: #339933;">;</span>
    a.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">3</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">typeof</span> a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>o<span style="color: #339933;">=</span>a<span style="color: #009900;">&#91;</span><span style="color: #339933;">-</span>~<span style="color: #339933;">!</span>x<span style="color: #009900;">&#93;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">=</span>a<span style="color: #009900;">&#91;</span><span style="color: #339933;">-</span>~x<span style="color: #009900;">&#93;</span><span style="color: #339933;">||</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span>a.<span style="color: #660066;">length</span><span style="color: #339933;">==</span><span style="color: #CC0000;">2</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'object'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>o<span style="color: #339933;">=</span>a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">=</span>a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">||</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> o<span style="color: #009900;">&#41;</span>r<span style="color: #339933;">+=</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;='&quot;</span><span style="color: #339933;">+</span>o<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#40;</span>type<span style="color: #339933;">==</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">||</span>type<span style="color: #339933;">==</span><span style="color: #3366CC;">'br'</span><span style="color: #339933;">||</span>type<span style="color: #339933;">==</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>o.<span style="color: #660066;">src</span><span style="color: #339933;">&amp;&amp;</span>v<span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>type<span style="color: #339933;">==</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>r<span style="color: #339933;">+=</span><span style="color: #3366CC;">&quot; src='&quot;</span><span style="color: #339933;">+</span>v<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;' /&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>type<span style="color: #339933;">==</span><span style="color: #3366CC;">'input'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>r<span style="color: #339933;">+=</span><span style="color: #3366CC;">&quot; value='&quot;</span><span style="color: #339933;">+</span>v<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;' /&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>r<span style="color: #339933;">+=</span><span style="color: #3366CC;">' /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>r<span style="color: #339933;">+=</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">+</span>v<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt; &quot;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #339933;">+</span>type<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> r<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> queryTag<span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span>htmlTag.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>queryTag function just wraps the newly created html in a jQuery object so you can have something like this</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#menu&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>
             queryTag<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'menuItem'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Click me'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</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;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'clicked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#41;</span></pre></td></tr></table></div><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Delete old snapshots from Alfresco</title><link>http://blog.another-d-mention.ro/misc/software/delete-old-snapshots-from-alfresco/</link> <comments>http://blog.another-d-mention.ro/misc/software/delete-old-snapshots-from-alfresco/#comments</comments> <pubDate>Tue, 04 Jan 2011 09:37:48 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Software]]></category> <category><![CDATA[alfresco]]></category> <category><![CDATA[avm]]></category> <category><![CDATA[delete]]></category> <category><![CDATA[remove]]></category> <category><![CDATA[snapshots]]></category> <category><![CDATA[store]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=843</guid> <description><![CDATA[If you're an Alfresco user, you may have noticed that it creates a snapshot of the store every time you publish something in the staging sandbox. In time this ads up to a lot of MB. If you wish to delete old snapshots of your store, here's the way to do it with version 2.2+ [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/alfresco-cifs-shared-drive-authentication-problem/' rel='bookmark' title='Permanent Link: Alfresco CIFS shared drive authentication problem'>Alfresco CIFS shared drive authentication problem</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you're an Alfresco user, you may have noticed that it creates a snapshot of the store every time you publish something in the staging sandbox. In time this ads up to a lot of MB. If you wish to delete old snapshots of your store, here's the way to do it with version 2.2+ of Alfresco using the AVM Console</p><p>First, open up the console at http://host:port/alfresco/faces/jsp/admin/avm-console.jsp<br
/> In the command line box, write</p><pre>lsver, mystore</pre><p>(where mystore is the name of your store)<br
/> This command will list all the snapshots. Now, you can remove individual snapshots by their id with</p><pre>rmver, mystore, version</pre><p>or remove a bunch of snapshots between two dates with</p><pre>rmvers, mystore, 2010-06-25T10:43:06.214Z, 2010-12-09T12:30:26.769Z</pre><p>The dates you can get from the list of snapshots. The documentation says that the date must be in ISO 8601 but I got an error trying to copy-paste the date from the list with the timezone at the end (+01:00) so I replaced that with Z and worked just fine.</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/alfresco-cifs-shared-drive-authentication-problem/' rel='bookmark' title='Permanent Link: Alfresco CIFS shared drive authentication problem'>Alfresco CIFS shared drive authentication problem</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/misc/software/delete-old-snapshots-from-alfresco/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Gnome – multiple monitor taskbar</title><link>http://blog.another-d-mention.ro/how-tos/gnome-%e2%80%93-multiple-monitor-taskbar/</link> <comments>http://blog.another-d-mention.ro/how-tos/gnome-%e2%80%93-multiple-monitor-taskbar/#comments</comments> <pubDate>Sat, 13 Nov 2010 00:19:12 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[How To's]]></category> <category><![CDATA[Stuff]]></category> <category><![CDATA[gnome]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[monitor]]></category> <category><![CDATA[taskbar]]></category> <category><![CDATA[ultramon]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=841</guid> <description><![CDATA[If you are using Linux on multiple monitors you are surely going to miss Utramon, but don’t worry. You can get your task-bar on multiple monitors using the following instructions Instructions: 1.) Right click on anywhere on the launch-bar, click “New Panel” 2.) Drag that to any monitor. 3.) Right click on that panel, and [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stuff/windows-7-quotes-problem/' rel='bookmark' title='Permanent Link: windows 7 quotes problem'>windows 7 quotes problem</a></li><li><a
href='http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li><li><a
href='http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/' rel='bookmark' title='Permanent Link: Use clipboard (copy/paste) in C# console application'>Use clipboard (copy/paste) in C# console application</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you are using Linux on multiple monitors you are surely going to miss Utramon, but don’t worry. You can get your task-bar on multiple monitors using the following instructions</p><p>Instructions:<br
/> 1.) Right click on anywhere on the launch-bar, click “New Panel”<br
/> 2.) Drag that to any monitor.<br
/> 3.) Right click on that panel, and click “Add to Panel”<br
/> 4.) Select “Window List” under Desktop and Windows<br
/> 5.) Click Add.<br
/> 6.) Add as many widgets you want to the taskbar<br
/> 7.) Click Close, and you’re done.</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/stuff/windows-7-quotes-problem/' rel='bookmark' title='Permanent Link: windows 7 quotes problem'>windows 7 quotes problem</a></li><li><a
href='http://blog.another-d-mention.ro/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li><li><a
href='http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/' rel='bookmark' title='Permanent Link: Use clipboard (copy/paste) in C# console application'>Use clipboard (copy/paste) in C# console application</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/how-tos/gnome-%e2%80%93-multiple-monitor-taskbar/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Read/Load files from ZIP in JavaScript</title><link>http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/</link> <comments>http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/#comments</comments> <pubDate>Fri, 01 Oct 2010 10:40:05 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Java Script]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[chrome]]></category> <category><![CDATA[firefox]]></category> <category><![CDATA[ie]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[load]]></category> <category><![CDATA[opera]]></category> <category><![CDATA[parse]]></category> <category><![CDATA[read]]></category> <category><![CDATA[safari]]></category> <category><![CDATA[zip]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=837</guid> <description><![CDATA[At work we do a lot of JavaScript applications that have little to no HTML files (beside the index), everything is generated by JavaScript and we have tons of .js files that load at runtime and to reduce the size we have to minify them and that is really hard to debug and watch in [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/' rel='bookmark' title='Permanent Link: Read data directly from base64 without decoding'>Read data directly from base64 without decoding</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol>]]></description> <content:encoded><![CDATA[<p>At work we do a lot of JavaScript applications that have little to no HTML files (beside the index), everything is generated by JavaScript and we have tons of .js files that load at runtime and to reduce the size we have to minify them and that is really hard to debug and watch in the browser if something goes wrong. So I've made this JavaScript class that comes to help. What can you do is Zip up all your assets (js, images, css) and use ZipLoader class to read the zip and unpack your resources whenever you need them. It's small (10KB), easy to use and quite fast considering the extraction is made by JavaScript.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #006600; font-style: italic;">// loads and caches the zip file</span>
   <span style="color: #003366; font-weight: bold;">var</span> loader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ZipLoader<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'files.zip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// creates a style node in the document header and appends the style</span>
   loader.<span style="color: #660066;">LoadCSS</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'files.zip://style.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// creates a script node in the document header and appends the script</span>
   loader.<span style="color: #660066;">loadScript</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'files.zip://jquery.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// returns the file content</span>
   <span style="color: #003366; font-weight: bold;">var</span> someFileYouNeed <span style="color: #339933;">=</span> loader.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;files.zip://myFile.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// returns the base64 encoded image usable as img source</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span> loader.<span style="color: #660066;">loadImage</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'files.zip://images/logo.png'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>The level of compression using zip surpasses the js and css minification in all the ways possible. For example, My current application has 79 files (js, and few css) and they all sum up to 924KB in size. Zipping all those 96 files using Ultra compression level gives me 1 file of 126 KB => 1 server request. That's something.</p><p>The best performance is made Opera (strangely), then Firefox, Crome, Safari and last IE (no surprise here, I was expecting it before I even started).</p><p><del
datetime="2010-10-04T10:42:19+00:00">It's a V 1.0 that still needs some work and it doesn't work in IE because that stupid browser overrides the mime type and at first null character in the reading of the zip, the content ends. I will fix this eventually <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Read/Load files from ZIP in JavaScript" class='wp-smiley' title="Read/Load files from ZIP in JavaScript" /> </del> I will also include this as a <a
href="http://code.google.com/p/adm-jclass/">jClass</a> library soon.</p><p><strong>Update:</strong> Fixed it so it works in IE as well. There is a performance issue still. Will fix that too.</p><p>Till then, <a
href="http://another-d-mention.ro/apps/download.php?app=archive">HERE</a> are the sources and a demo.</p><p>The zip in the demo is made using <a
href="http://www.7-zip.org/">7Zip</a> with Ultra Compression level.</p><p>Happy codding.</p><p><a
class="FlattrButton" style="display:none;" href="http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/"></a><br
/> <noscript><a
href="http://flattr.com/thing/183347/ReadLoad-files-from-ZIP-in-JavaScript" target="_blank"><br
/> <img
src="http://api.flattr.com/button/flattr-badge-large.png" alt="flattr badge large Read/Load files from ZIP in JavaScript" title="Flattr this" border="0" /></a></noscript></p><p><script type="text/javascript">google_ad_client = "ca-pub-3771432957882119";
/* InsidePost */
google_ad_slot = "9112434755";
google_ad_width = 468;
google_ad_height = 60;</script><br
/> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/' rel='bookmark' title='Permanent Link: Read data directly from base64 without decoding'>Read data directly from base64 without decoding</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/feed/</wfw:commentRss> <slash:comments>50</slash:comments> </item> <item><title>Parse XML in JavaScript with jQuery</title><link>http://blog.another-d-mention.ro/programming/java-script/parse-xml-in-javascript-with-jquery/</link> <comments>http://blog.another-d-mention.ro/programming/java-script/parse-xml-in-javascript-with-jquery/#comments</comments> <pubDate>Tue, 28 Sep 2010 10:40:42 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Java Script]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[parse]]></category> <category><![CDATA[xml]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=836</guid> <description><![CDATA[Yes, you can do it with XMLDOM and all the other ways out there, but why not use the power of jQuery ? Like so: 1 2 3 4 5 6 7 &#60;root&#62; &#60;items&#62; &#60;item name=&#34;first&#34; id=&#34;1&#34;&#62;Content 1&#60;/item&#62; &#60;item name=&#34;second&#34; id=&#34;2&#34;&#62;Content 2&#60;/item&#62; &#60;/items&#62; &#60;other atribute=&#34;true&#34; /&#62; &#60;/root&#62; 1 2 3 4 var xml = '&#60;root [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/' rel='bookmark' title='Permanent Link: jQuery.quickEach'>jQuery.quickEach</a></li><li><a
href='http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/' rel='bookmark' title='Permanent Link: Read/Load files from ZIP in JavaScript'>Read/Load files from ZIP in JavaScript</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Yes, you can do it with XMLDOM and all the other ways out there, but why not use the power of jQuery ?<br
/> Like so:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td
class="code"><pre class="xml" style="font-family:monospace;">   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;first&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Content 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;second&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Content 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;other</span> <span style="color: #000066;">atribute</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #003366; font-weight: bold;">var</span> xml <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;root ......'</span><span style="color: #339933;">;</span>
   <span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">// and now you can use jquery selectors to get what you want</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;item[name=second]&quot;</span><span style="color: #339933;">,</span> obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 2</span></pre></td></tr></table></div><p></root></pre><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/java-script/jquery-quickeach/' rel='bookmark' title='Permanent Link: jQuery.quickEach'>jQuery.quickEach</a></li><li><a
href='http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/' rel='bookmark' title='Permanent Link: Read/Load files from ZIP in JavaScript'>Read/Load files from ZIP in JavaScript</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/for-javascript-devs/' rel='bookmark' title='Permanent Link: For Javascript devs'>For Javascript devs</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/parse-xml-in-javascript-with-jquery/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
