<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<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/"
	>

<channel>
	<title>ReadyState4</title>
	<link>http://readystate4.com</link>
	<description>JavaScript, Web Development, Ruby, and Technology.</description>
	<pubDate>Thu, 21 May 2009 20:39:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Git: Ignore changes in a working tree file</title>
		<link>http://readystate4.com/2009/05/21/git-ignore-changes-in-a-working-tree-file/</link>
		<comments>http://readystate4.com/2009/05/21/git-ignore-changes-in-a-working-tree-file/#comments</comments>
		<pubDate>Thu, 21 May 2009 20:36:12 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/05/21/git-ignore-changes-in-a-working-tree-file/</guid>
		<description><![CDATA[Lately, I&#8217;ve transferred all my repos over from Subversion to Git and have become familiar enough with the Git SVN bindings to even work on my work projects in Git while still being able to check-in as a regular SVN user. 
I&#8217;ve found that some usual stuff Subversion would ignore in projects Git doesn&#8217;t. The [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I&#8217;ve transferred all my repos over from Subversion to <a href="http://git-scm.com/">Git</a> and have become familiar enough with the <a href="http://flavio.castelli.name/howto_use_git_with_svn">Git SVN bindings</a> to even work on my work projects in Git while still being able to check-in as a regular SVN user. </p>
<p>I&#8217;ve found that some usual stuff Subversion would ignore in projects Git doesn&#8217;t. The Git exclude file doesn&#8217;t work here since these are files being tracked in the working tree that are just specific to your instance. After digging around, I found the proper command to ignore these files:</p>
<pre>
# ignore changes in a working tree file
git update-index --assume-unchanged .classpath
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/05/21/git-ignore-changes-in-a-working-tree-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TinyMCE: TypeError: t.win.document is null in Firebug Console</title>
		<link>http://readystate4.com/2009/05/15/tinymce-typeerror-twindocument-is-null-in-firebug-console/</link>
		<comments>http://readystate4.com/2009/05/15/tinymce-typeerror-twindocument-is-null-in-firebug-console/#comments</comments>
		<pubDate>Sat, 16 May 2009 02:33:33 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/05/15/tinymce-typeerror-twindocument-is-null-in-firebug-console/</guid>
		<description><![CDATA[I came across this error on a site I was helping to troubleshoot today and with a little Googling found it happens when you move the DOM containing a TinyMCE editor to another place in the document: TinyMCE loses it&#8217;s reference to that original element.
To get around this, showing or hiding the editor won&#8217;t work, [...]]]></description>
			<content:encoded><![CDATA[<p>I came across this error on a site I was helping to troubleshoot today and with a little Googling found it happens when you move the DOM containing a TinyMCE editor to another place in the document: TinyMCE loses it&#8217;s reference to that original element.</p>
<p>To get around this, showing or hiding the editor won&#8217;t work, instead destroying the element before you move it and recreating it (same as the previous post) does the trick:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">tinyMCE.<span style="color: #006600;">execCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mceRemoveControl'</span>, <span style="color: #003366; font-weight: bold;">false</span>, <span style="color: #3366CC;">'idOfElement'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">// move DOM element</span>
tinyMCE.<span style="color: #006600;">execCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mceAddControl'</span>, <span style="color: #003366; font-weight: bold;">false</span>, <span style="color: #3366CC;">'idOfElement'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/05/15/tinymce-typeerror-twindocument-is-null-in-firebug-console/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Removing all TinyMCE editors on the page for reinitializing</title>
		<link>http://readystate4.com/2009/05/06/removing-all-tinymce-editors-on-the-page-for-reinitializing/</link>
		<comments>http://readystate4.com/2009/05/06/removing-all-tinymce-editors-on-the-page-for-reinitializing/#comments</comments>
		<pubDate>Wed, 06 May 2009 16:47:49 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[tinymce]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/05/06/removing-all-tinymce-editors-on-the-page-for-reinitializing/</guid>
		<description><![CDATA[Sometimes, one needs to remove (not hide) all TinyMCE editors on the page to run a modified version of the global tinyMCE.init code again. This is the best way I&#8217;ve found to do it so far:

var i, t = tinyMCE.editors;
for &#40;i in t&#41;&#123;
    if &#40;t.hasOwnProperty&#40;i&#41;&#41;&#123;
        [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, one needs to remove (not hide) all TinyMCE editors on the page to run a modified version of the global tinyMCE.init code again. This is the best way I&#8217;ve found to do it so far:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> i, t = tinyMCE.<span style="color: #006600;">editors</span>;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> t<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>t.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        t<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #009900; font-style: italic;">// new tinyMCE.init code here</span></pre></div></div>

<p>Additionally, you can &#8220;destrory&#8221; and &#8220;recreate&#8221; specific editors via:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">tinyMCE.<span style="color: #006600;">execCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mceRemoveControl'</span>, <span style="color: #003366; font-weight: bold;">false</span>, <span style="color: #3366CC;">'idOfElement'</span><span style="color: #66cc66;">&#41;</span>;
tinyMCE.<span style="color: #006600;">execCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mceAddControl'</span>, <span style="color: #003366; font-weight: bold;">false</span>, <span style="color: #3366CC;">'idOfElement'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>If anyone knows a better way, post in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/05/06/removing-all-tinymce-editors-on-the-page-for-reinitializing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript Memoization</title>
		<link>http://readystate4.com/2009/02/25/javascript-memoization/</link>
		<comments>http://readystate4.com/2009/02/25/javascript-memoization/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 17:18:30 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/02/25/javascript-memoization/</guid>
		<description><![CDATA[I was taking a look at my friend Takashi&#8217;s JavaScript tweener which isn&#8217;t released yet and noticed he setup his code in a particular way for a few methods that get called dozens of times a second. He explained to me that it was for optimization through memoization. I ran a test case, and indeed [...]]]></description>
			<content:encoded><![CDATA[<p>I was taking a look at my friend Takashi&#8217;s JavaScript tweener which isn&#8217;t released yet and noticed he setup his code in a particular way for a few methods that get called dozens of times a second. He explained to me that it was for optimization through <a href="http://en.wikipedia.org/wiki/Memoization" title="Wikipedia entry">memoization</a>. I ran a test case, and indeed it&#8217;s much faster. Check it out:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">a = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
a.<span style="color: #006600;">deep</span> = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
a.<span style="color: #006600;">deep</span>.<span style="color: #006600;">variable</span> = <span style="color: #66cc66;">&#123;</span>
    here: <span style="color: #CC0000;">3</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> plain<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    document.<span style="color: #006600;">body</span>.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">createTextNode</span><span style="color: #66cc66;">&#40;</span>a.<span style="color: #006600;">deep</span>.<span style="color: #006600;">variable</span>.<span style="color: #006600;">here</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> memoized<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> z = a.<span style="color: #006600;">deep</span>.<span style="color: #006600;">variable</span>.<span style="color: #006600;">here</span>;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        document.<span style="color: #006600;">body</span>.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">createTextNode</span><span style="color: #66cc66;">&#40;</span>z<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
now = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>, max = <span style="color: #CC0000;">5000</span>; i &lt; max; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        plain<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - now<span style="color: #66cc66;">&#41;</span>;
&nbsp;
now = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>, max = <span style="color: #CC0000;">5000</span>; i &lt; max; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        memoized<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - now<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">// plain:  759</span>
<span style="color: #009900; font-style: italic;">// memoized: 36</span></pre></div></div>

<p>There&#8217;s a more complex example on the subject posted a month ago on <a href="http://ajaxian.com/archives/speed-up-your-javascript-with-memoization">Ajaxian</a> and an easier to understand one on Oliver Steele&#8217;s <a href="http://osteele.com/archives/2006/04/javascript-memoization">blog</a> written back in 2006.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/02/25/javascript-memoization/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery comes to WhiteHouse.gov</title>
		<link>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/</link>
		<comments>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:59:52 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/</guid>
		<description><![CDATA[
Today the new WhiteHouse.gov launched and although it isn&#8217;t exactly XHTML compliant it beats the pants off of most government websites and follows along with the new President&#8217;s plans of deploying a modern communications infrastructure (it&#8217;s also using jQuery and jQuery.thickbox as noted above). 
Copy on the new site explains: &#8220;WhiteHouse.gov will be a central [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://readystate4.com/images/blog/whitehouse.gov-large.jpg"><img src="http://readystate4.com/images/blog/whitehouse.gov-small.jpg" /></a><br />
Today the new WhiteHouse.gov launched and although it isn&#8217;t exactly XHTML compliant it beats the pants off of most government websites and follows along with the new President&#8217;s plans of deploying a modern communications infrastructure (it&#8217;s also using jQuery and jQuery.thickbox as noted above). </p>
<p>Copy on the new site explains: &#8220;WhiteHouse.gov will be a central part of President Obama&#8217;s pledge to make his the most transparent and accountable administration in American history.&#8221;</p>
<p>Regarding Technology, Obama has already talked about:</p>
<ul>
<li>protecting the openness of the internet.</li>
<li>supporting the principle of network neutrality to preserve the benefits of open competition on the internet.</li>
<li>deploying a modern communications infrastructure.</li>
<li>getting true broadband to every community in America.</li>
</ul>
<p>Here&#8217;s looking at a tech-positive presidency!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The difference between != and =!</title>
		<link>http://readystate4.com/2008/12/31/the-difference-between-and/</link>
		<comments>http://readystate4.com/2008/12/31/the-difference-between-and/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 17:38:10 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/12/31/the-difference-between-and/</guid>
		<description><![CDATA[I was helping a friend troubleshoot some of her code today and found the culprit to be a typo in one of her conditional statements:

// var USERID = 12345;
if &#40;USERID =! null&#41;&#123;
     // code
&#125;

Her expression was always resolving to true because she had inverted her != (&#8221;not-null&#8221;) check which was actually [...]]]></description>
			<content:encoded><![CDATA[<p>I was helping a friend troubleshoot some of her code today and found the culprit to be a typo in one of her conditional statements:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// var USERID = 12345;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>USERID =! <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
     <span style="color: #009900; font-style: italic;">// code</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Her expression was always resolving to <code>true</code> because she had inverted her <code>!=</code> (&#8221;not-null&#8221;) check which was actually assigning her variable to the return of a statement evaluation. Her mistake would be clearer to understand formatted as such:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009900; font-style: italic;">// var USERID = 12345;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>USERID = !<span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
     <span style="color: #009900; font-style: italic;">// code</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Since the inverse of <code>false</code>, <code>null</code>, and <code>NaN</code> is <code>true</code> her conditional statement (also an assignment) would always return <code>true</code>. </p>
<p>Which lead me to thinking, the not operator is a great way to write succinct code. In the right context, using the not operator in the right side of an assignment isn&#8217;t a bad idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/12/31/the-difference-between-and/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Improve your jQuery - 25 excellent tips</title>
		<link>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/</link>
		<comments>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:23:04 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/</guid>
		<description><![CDATA[
Here&#8217;s a nice write-up by Jon Hobbs-Smith at tvidesign.com detailing 25 tips on using jQuery as well as regular JavaScript advice. Most of these tips probably aren&#8217;t anything new for the advanced jQuery user (Jon considers himself intermediate, I think that&#8217;s modest), however I love lists like this because there&#8217;s a treasure trove worth of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx"><img src="http://readystate4.com/images/blog/tvidesign_banner.jpg" style="padding-left: 0px;" /></a><br />
Here&#8217;s a nice write-up by Jon Hobbs-Smith at tvidesign.com detailing <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx">25 tips on using jQuery</a> as well as regular JavaScript advice. Most of these tips probably aren&#8217;t anything new for the advanced jQuery user (Jon considers himself intermediate, I think that&#8217;s modest), however I love lists like this because there&#8217;s a treasure trove worth of experience being shared. Altruism at it&#8217;s best!</p>
<p>I plan on writing more entries on my own tips and tricks with JavaScript and jQuery as well as my methods of debugging in various browsers, compression techniques, etc., but in the meantime, I&#8217;ll just comment on Jon&#8217;s list: </p>
<p><strong>2. Use a [jQuery] cheat sheet</strong></p>
<p>I think <a href="http://visualjquery.com/">Visual jQuery</a> is all you need. And now that there&#8217;s live search and clickable examples it&#8217;s even better.</p>
<p><strong>3. Combine all your scripts and minify them</strong></p>
<p>Dead Edward&#8217;s packer is awesome for minifying, but before I do that, I like to run my code through <a href="http://www.jslint.com/">jSlint</a> to make sure it&#8217;s all valid. I ignore line-break errors as I don&#8217;t agree in many cases that it&#8217;s an issue.</p>
<p>Additionally, when I work on large JS codebases with a lot of other people who may not code as strictly as I do, I like to use <a href="http://www.crockford.com/javascript/jsmin.html">JSmin</a> on the minimal setting (cut-and-paste version <a href="http://fmarcia.info/jsmin/test.html">here</a>). The compression benefit is only slightly less and it preserves single linefeeds preventing JS errors where people forgot to end their statements with a semicolon. It also makes the code easier to read and debug in a production enviornment—great for the times you want the benefits of minification without the side effect of obfuscation.</p>
<p><strong>5. Keep selection operations to a minimum by caching</strong></p>
<p>I just wanted to comment in Ron&#8217;s example where he used:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> myList = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.myList'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>First, if I ever reference a jQuery collection in my scripts, I like to append the dollar sign character to the beginning of the variable name to signify that it is, in fact, a jQuery collection:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> $myList = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.myList'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>It&#8217;s a lot more helpful when you access that variable further down the road and don&#8217;t have to question whether it&#8217;s a jQuery wrapped set, an actual HTML element, or something else.</p>
<p>Secondly, whether you&#8217;re using a JS lib or not, I would never search for an HTML collection by class name alone; What the JavaScript engine is doing in the background is looping through every single element on the page which is very intensive. It would be better to find the closest parent container first or search by specific tag name(s):</p>
<p>Good:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> $myList = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ul.myList'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">//added benefit of knowing the type of element you'll</span>
<span style="color: #009900; font-style: italic;">// receive</span></pre></div></div>

<p>Better:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> $myList = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#closest_parent_id .myList'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// searching the children of a parent</span>
<span style="color: #009900; font-style: italic;">// container instead of all the elements on the page</span></pre></div></div>

<p>Best:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> $myList = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#closest_parent_id ul.myList'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// combination of both above</span></pre></div></div>

<p><strong>19. Use noconflict to rename the jquery object when using other frameworks</strong><br />
<strong>22. How to check if an element exists[&#8230;]</strong></p>
<p>As I&#8217;ve probably mentioned before, I always like to use <code>noConflict()</code> in all my projects. I move jQuery to the $j namespace and save <code>$</code> for a shorthand reference to <code>document.getElementById</code> - I think it&#8217;s what most js developers expect and <code>if($('myDiv))</code> is a lot simpler to write out than <code>if($('#myDiv).length !== 0)</code>  or even <code>if($('#myDiv).length)</code>.</p>
<p>Thanks for the link <a href="http://www.insecureweb.com/">Bryan</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blogging from South Korea</title>
		<link>http://readystate4.com/2008/11/09/blogging-from-south-korea/</link>
		<comments>http://readystate4.com/2008/11/09/blogging-from-south-korea/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 13:19:50 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/11/09/blogging-from-south-korea/</guid>
		<description><![CDATA[








I&#8217;m on my vacation now in South Korea, and in keeping related to tech, I have a few things to blog about:

PC bangs (rooms) are all over the place, almost as much as nara bangs (karoake rooms) and the general cost is 1000 won ($1) for two hours of awesomely fast internet!
Both of the PC [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" type="application/x-shockwave-flash" width="600px" height="180px" id="kickWidget_5166_67165" align="middle">
<param name="movie" value="http://serve.a-widget.com/service/getWidgetSwf.kickAction"/>
<param name="FlashVars" value="affiliateSiteId=5166&#038;widgetId=67165&#038;width=600&#038;height=180&#038;revision=1229642991222"/>
<param name="quality" value="high"/>
<param name="wmode" value="transparent"/>
<param name="allowFullScreen" value="true"/>
<param name="menu" value="false"/>
<param name="allowNetworking" value="all"/>
<param name="allowScriptAccess" value="always"/><embed src="http://serve.a-widget.com/service/getWidgetSwf.kickAction" name="kickWidget_5166_67165" width="600px" height="180px" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" align="middle" allowScriptAccess="always" alt="KickApps Widget" allowFullScreen="true" FlashVars="affiliateSiteId=5166&#038;widgetId=67165&#038;width=600&#038;height=180&#038;revision=1229642991222"/></object></p>
<p>I&#8217;m on my vacation now in South Korea, and in keeping related to tech, I have a few things to blog about:</p>
<ol>
<li>PC bangs (rooms) are all over the place, almost as much as nara bangs (karoake rooms) and the general cost is 1000 won ($1) for two hours of awesomely fast internet!</li>
<li>Both of the PC bangs I&#8217;ve been to so far have IE6 installed as the default browser with nothing else (although they&#8217;re all relatively new machines). :(</li>
<li>On the upside, it looks like you can install anything you want (I installed Firefox) but I&#8217;m guessing the computer gets reimaged somehow once you log out. I was also allowed to hook my Macbook up.</li>
<li>Atleast in the area I&#8217;m in (Inchon), wireless networks seem to be less prevalent here than in the US, especially the wide open or free ones (and thusly I&#8217;m at a PC bang.)</li>
<li>Instead of relying on expensive phonecards and such to call the States, I use my <a href="http://www.skype.com/allfeatures/onlinenumber/">Skype number</a> (about $30 for 6 months). It gives me unlimited calling to the US and Canada and my own NYC number friends can call so they don&#8217;t get charged for long distance. Even though I&#8217;m not even close to NYC it still calls them like I it did when I am in my office. Win/win.</li>
<li>I decided to step up from my old 4-year-old Sony Cybershot and bought a <a href="http://www.amazon.com/Nikon-D90-Digital-18-105mm-3-5-5-6G/dp/B001ENOZY4/ref=pd_bbs_sr_1?ie=UTF8&#038;s=electronics&#038;qid=1226236050&#038;sr=8-1">Nikon D90</a> DSLR before the trip. It works just like my old Nikon N80 (non-digital SLR) and I&#8217;ve been enjoying the crisp 12mp images and 1080p video capabilites. I want to make a DVD when I get back in two weeks.
<li>And lastly, Starcraft is just as fun as I remembered it. :(</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/11/09/blogging-from-south-korea/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Charging your iPhone on the go</title>
		<link>http://readystate4.com/2008/10/29/charging-your-iphone-on-the-go/</link>
		<comments>http://readystate4.com/2008/10/29/charging-your-iphone-on-the-go/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 05:09:57 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/10/29/charging-your-iphone-on-the-go/</guid>
		<description><![CDATA[
The Kensington Mini Battery Pack for iPod and iPhone

So I&#8217;m planning a 2 week trip to Korea, and I know during the course of my trip I&#8217;ll probably be watching lots of video on my iphone, potentially siphoning off internet for my MacBook, and reading my Google Reader when I can. All of that would [...]]]></description>
			<content:encoded><![CDATA[<div class="thumb_left" style="width: 120px;"><a href="http://us.kensington.com/html/15462.html"><img src="http://readystate4.com/images/blog/kensington_iphone_charger.gif" /></a></p>
<div>The Kensington Mini Battery Pack for iPod and iPhone</div>
</div>
<p>So I&#8217;m planning a 2 week trip to Korea, and I know during the course of my trip I&#8217;ll probably be watching lots of video on my iphone, potentially siphoning off internet for my MacBook, and reading my Google Reader when I can. All of that would lead to the quick demise of my iPhone&#8217;s battery life - with no AC outlet in sight. To remedy this I&#8217;ve been planning to get an external battery pack - something like the <a href="http://us.kensington.com/html/15462.html">Kensington&#8217;s Mini Battery Pack</a> ($50) [inset left].</p>
<p>The other day, however, I was at the local Duane Reade (popular NYC pharmacy chain) and came across this in the $10 discount bin [inset right].</p>
<div class="thumb_right" style="width: 200px;"><a title="Official site" href="http://www.energizer.com/products/energi-to-go/ipod-charger/Pages/ipod-battery-charger.aspx"><img src="http://readystate4.com/images/blog/energize_iphone_charger.jpg" /></a></p>
<div>Energizer Energi To Go Portable Power for iPod</div>
</div>
<p>It&#8217;s called the <a title="Official site" href="http://www.energizer.com/products/energi-to-go/ipod-charger/Pages/ipod-battery-charger.aspx">Energizer Energi To Go</a> ($10?) and what is basically does is recharge your iPod via two double-A batteries. Although the packaging only advertises charging iPods, I took the chance and bought it considering all the connectors are the same. Sure enough it works great! I&#8217;ve only tested it out twice but I dig it. Here&#8217;s the pros and cons:</p>
<h3>Energizer Energi Pros</h3>
<ul>
<li><strong>It&#8217;s cheap.</strong> Judging from the condition of the packaging this things been around for awhile, and I&#8217;m pretty sure I&#8217;m not the only guy that&#8217;s never heard of it. I mean, Energizer, making an iPod accessory? It even comes with a free pair of batteries.</li>
<li><strong>It&#8217;s easy to charge.</strong> You can get a small box of double-A&#8217;s anywhere and in most countries I assume. I could go camping for days and still be able to make calls and get online.</li>
<li><strong>It&#8217;s small.</strong> Easy to slip in a jacket pocket if you know you&#8217;ll be needing it. It folds compactly when you&#8217;re not using it and also serves as a stand when you are. Here&#8217;s an unoptimized <a href="http://www.energizer.com/SiteCollectionDocuments/video/ipod_charger/demo.wmv">WMV movie (6MB)</a> from their site showing the folding action. Additionally the device has a coin-operated screw area so that you can expand the dock to fit larger or smaller devices.</li>
</ul>
<h3>Energizer Energi Cons</h3>
<ul>
<li><strong>It&#8217;s a little wasteful.</strong> And probably worse for the environment. A set of batteries can charge an iPhone about 1.2 times before being emptied.</li>
<li><strong>Long charge time.</strong> Takes a good couple of hours to charge.</li>
<li><strong>Dock can be a little fickle.</strong> I&#8217;m not sure whether it only happens when the batteries or low but sometimes my iPhone beeps / vibrates constantly as if it&#8217;s constantly getting unplugged and replugged.</li>
</ul>
<p>Overall, I definitely think the pros outweigh the cons, especially for my case where I&#8217;m not going to be using it much. I&#8217;ve got an iPhone dock ready at home and work so the only time I need it would be when I&#8217;m away from both places for longer than a day. The charging time isn&#8217;t so bad either since I can charge and use it at the same time (I only wish it could somehow dock horizontally for MovieTime&trade;.)</p>
<p>This marks the end of my review, so if you have ten dollars burning a whole in your pocket go to your local Duane Reade store and try to pick one up!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/10/29/charging-your-iphone-on-the-go/feed/</wfw:commentRss>
<enclosure url="http://www.energizer.com/SiteCollectionDocuments/video/ipod_charger/demo.wmv" length="5589871" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>String.toCharCode</title>
		<link>http://readystate4.com/2008/10/27/stringtocharcode/</link>
		<comments>http://readystate4.com/2008/10/27/stringtocharcode/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 15:02:19 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/10/27/stringtocharcode/</guid>
		<description><![CDATA[I noticed that JavaScript has a String.fromCharCode for decoding a sequence of numbers to Unicode values but no String.toCharCode for doing the reverse. So here&#8217;s my rendition:

String.prototype.toCharCode = function&#40;&#41;&#123;
    var r = '', string = this.split&#40;''&#41;;
    for &#40;var i in string&#41;&#123;
        r [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that JavaScript has a <a href="https://developer.mozilla.org/En/Sandbox/JS/String.fromCharCode" title="Mozilla Definition">String.fromCharCode</a> for decoding a sequence of numbers to Unicode values but no String.toCharCode for doing the reverse. So here&#8217;s my rendition:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">toCharCode</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> r = <span style="color: #3366CC;">''</span>, string = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> string<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        r += String.<span style="color: #006600;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>string<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">','</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> r.<span style="color: #006600;">substr</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>,r.<span style="color: #006600;">length</span> - <span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #3366CC;">'bob'</span>.<span style="color: #006600;">toCharCode</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">// returns &quot;98,111,98&quot;</span></pre></div></div>

<p class="update" style="padding: 5px; background-color: lightyellow;">
<strong>Update:</strong> version from my good friend <a href="http://blog.nydd.org/about/">Takashi</a> and link to his blog on <a href="http://blog.nydd.org/2008/10/28/process-string/">why it&#8217;s more efficient</a>:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">String.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">toCharCode</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> str = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span>, len = str.<span style="color: #006600;">length</span>, work = <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span>len<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>; i &lt; len; ++i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        work<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = String.<span style="color: #006600;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>str<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> work.<span style="color: #006600;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #3366CC;">'bob'</span>.<span style="color: #006600;">toCharCode</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">// returns &quot;98,111,98&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/10/27/stringtocharcode/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
