<?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>Wed, 20 Aug 2008 17:16:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Installing memcached on OS X 10.5.4 Leopard</title>
		<link>http://readystate4.com/2008/08/19/installing-memcached-on-os-x-1054-leopard/</link>
		<comments>http://readystate4.com/2008/08/19/installing-memcached-on-os-x-1054-leopard/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 22:42:09 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[memcached]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/08/19/installing-memcached-on-os-x-1054-leopard/</guid>
		<description><![CDATA[I used the guide here to install Memcached on my Macbook Pro, but seeing how it was written over 3 years old I decided to write an updated version for installing on OSX Leopard. Here goes:
Beforehand: You need to install Xcode 3.0 Developer Tools. If you don&#8217;t have it installed it&#8217;s on the Leopard Install [...]]]></description>
			<content:encoded><![CDATA[<p>I used the guide <a href="http://www.petercooper.co.uk/archives/000693.html" title="Installing memcached on OS X 10.4 Tiger">here</a> to install Memcached on my Macbook Pro, but seeing how it was written over 3 years old I decided to write an updated version for installing on OSX Leopard. Here goes:</p>
<p>Beforehand: You need to install Xcode 3.0 Developer Tools. If you don&#8217;t have it installed it&#8217;s on the Leopard Install CD that came with your Mac. You also have to install the X11 windowing environment on the same disc.</p>
<ol>
<li>If you don&#8217;t have it already, download Macports:<br />
<a href="http://www.macports.org/install.php">http://www.macports.org/install.php</a></p>
<p>Here&#8217;s the Leopard universal binary direct link:<br />
<a href="http://svn.macports.org/repository/macports/downloads/MacPorts-1.6.0/MacPorts-1.6.0-10.5-Leopard.dmg">http://svn.macports.org/repository/macports/downloads/MacPorts-1.6.0/MacPorts-1.6.0-10.5-Leopard.dmg</a> (416kb)</li>
<li>Macports will install itself to <code>/opt/local/bin</code> but on my machine I didn&#8217;t have a PATH variable set there so if you type &#8220;port&#8221; in your terminal and don&#8217;t get anything either, continue following this step, else just continue on to the next one.
<p>Open up terminal and type: </p>
<pre>nano .bash_profile (return key)</pre>
<p>Find the first unused line and type:</p>
<pre>PATH=$PATH:/opt/local/bin</pre>
<p>To save your changes press <code>ctrl-o</code> (return key) and <code>ctrl-x</code> to quit.<br />
Refresh your profile by typing: </p>
<pre>. .bash_profile</pre>
</li>
<li>To test that your Macports is working (and to update to the newest version):
<pre>sudo port -v selfupdate</pre>
</li>
<li>Install libevent. It&#8217;s a dependency of memcached:
<pre>sudo port install libevent</pre>
</li>
<li>Install memcached:
<pre>sudo port install memcached</pre>
</li>
<li>Set an environment variable to stop libevent using kqueue (should force it to use select, which is slower, but actually works). I have no idea what this does, just following the original guide, but it&#8217;s related to <a href="http://blog.segment7.net/articles/2006/03/02/fast-memcached-on-os-x">making memcached faster</a> :
<p>Open up terminal and type: </p>
<pre>nano .bash_profile (return key)</pre>
<p>Find the first unused line and type: </p>
<pre>EVENT_NOKQUEUE=yes</pre>
<p>To save your changes press <code>ctrl-o</code> (return key) and <code>ctrl-x</code> to quit.<br />
Refresh your profile by typing: </p>
<pre>. .bash_profile</pre>
</li>
<li>Run memcached (this gives it 24MB of memory max, and puts it on port 11211 - note that specifying a hostname will not work on OS X):
<pre>memcached -d -m 24 -p 11211</pre>
</li>
<li>Telnet to your memcache to make sure it&#8217;s working:
<pre>telnet localhost 11211</pre>
<p>If you see &#8220;Connected to localhost&#8221;, you&#8217;re connected.</p>
<p>Type <code>quit</code> to close the connection and try reconnecting again to make sure you did step 6 properly.</p>
<p>You&#8217;re done!</li>
</ol>
<p>To stop memcached, type this in your console:</p>
<pre>killall memcached</pre>
<p>To start memcached in verbose mode (so it outputs what it&#8217;s doing) add <code>-vv</code> to the startup script.</p>
<p>Feel free to create a bash script to startup memcached with your right settings, mine looks like this:</p>
<pre style="margin-bottom: 15px;">
#!/usr/bin/env bash

memcached -d -m 24 -p 11211
echo "memcached started..."
</pre>
<p><strong>Related links:</strong><br />
<a href="http://www.petercooper.co.uk/archives/000693.html">Installing memcached on OS X 10.4 Tiger</a><br />
<a href="http://www.macports.org/install.php">Installing Macports</a><br />
<a href="http://www.danga.com/memcached/">Memcached homepage</a></p>
<p><strong>Further reading:</strong><br />
<a href="http://www.lullabot.com/articles/setup-memcached-mamp-sandbox-environment">Setup a Memcached-Enabled MAMP Sandbox Environment</a><br />
<a href="http://www.rubynaut.net/articles/2008/02/12/install-ruby-memcached-on-macosx">Install ruby memcached on MacOSX</a></p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/08/19/installing-memcached-on-os-x-1054-leopard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to add Ruby (.rhtml) support to your existing MAMP setup with eRuby</title>
		<link>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/</link>
		<comments>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 02:30:50 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[Apache]]></category>

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

		<guid isPermaLink="false">http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/</guid>
		<description><![CDATA[Adding Ruby HTML support to your existing MAMP setup is great for experimenting and for building quick single serving apps where a whole Rails setup would be overkill. This is how I added Ruby RHTML page support to my current MAMP setup:
Download and compile eRuby

Download and unzip http://www.modruby.net/en/index.rbx/eruby/download.html
Go to the unzipped directory in terminal
type ./configure.rb
type [...]]]></description>
			<content:encoded><![CDATA[<p>Adding Ruby HTML support to your existing <a href="http://www.mamp.info/en/index.php">MAMP</a> setup is great for experimenting and for building quick single serving apps where a whole Rails setup would be overkill. This is how I added Ruby RHTML page support to my current MAMP setup:</p>
<h3>Download and compile eRuby</h3>
<ol>
<li>Download and unzip <a href="http://www.modruby.net/en/index.rbx/eruby/download.html">http://www.modruby.net/en/index.rbx/eruby/download.html</a></li>
<li>Go to the unzipped directory in terminal</li>
<li>type ./configure.rb</li>
<li>type make</li>
<li>type make install</li>
<li>Copy the generated eruby file to your local cgi-bin</li>
</ol>
<h3>Modify your httpd.conf settings</h3>
<ol>
<li>add this line to add the rhtml support:
<pre>AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby</pre>
</li>
<li>And modify this line so your server will look for index.rhtml pages in directories:<br />
<code>DirectoryIndex index.html index.shtml index.rhtml</code></li>
</ol>
<h3>Running straight .rb files outside your cgi-bin folder (optional)</h3>
<p>You can run any scripts from your cgi-bin if you properly add the #!(she bang) location to your ruby intepreter at the top of your scripts, but you can also make these scrips run outside of your cgi-bin by just adding this line to your httpd.config, just add the .rb extension to the filename:</p>
<pre>AddHandler cgi-script .rb</pre>
<p>I was doing this for awhile so I could execute scripts through the web but the RHTML method is better. Still, there could be applicable reasons for a person to want to do this.  Just keep in mind, that when accessing Ruby scripts directly from a webpage you must at least specify a content-type (puts: &#8220;content-type: text/plain\n&#8221;) in your header or use the convenient <a href="http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html">cgi class</a> from the Ruby standard library that does that (and a whole lot more) for you.</p>
<h3>Improving Performance (optional)</h3>
<p>The above is a really quick way to add Ruby support to your local webserver however, there&#8217;s one downside - it has to start up the Ruby interpreter everytime you hit an rhtml file with your browser. If you want something a little more dedicated look into the <a href="http://modruby.net/en/">mod_ruby</a> apache module which embeds a Ruby interpreter into Apache&#8217;s (inside your web server&#8217;s memory), to let Ruby CGI scripts execute natively, so scripts start up and run far faster. This is the equivalent as mod_php for PHP, that&#8217;s built into your MAMP setup.</p>
<p>Additionally, as a speed boost, you could use <a href="http://www.fastcgi.com/">fast cgi</a> to keep the eRuby interpreter instantiated, if for some reason you can&#8217;t use mod_ruby.</p>
<p><strong>Helpful links:</strong><br />
http://www.rubycentral.com/book/web.html</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript argument unpacking: converting an array into a list of arguments</title>
		<link>http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/</link>
		<comments>http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 23:43:30 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/</guid>
		<description><![CDATA[Ruby has a cool operator by the name of splat(*) that lets you unpack an array as arguments on the fly. See this code below for an example:

&#160;
# Define the item array
item1 = &#91;'Jack', '39', 'Panda'&#93;
&#160;
# Define a regular function that takes three arguments
def hi&#40;name, age, type&#41;
  puts 'Hi ' + name + '! [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby has a cool operator by the name of splat(*) that lets you unpack an array as arguments on the fly. See this code below for an example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">&nbsp;
<span style="color:#008000; font-style:italic;"># Define the item array</span>
item1 = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Jack'</span>, <span style="color:#996600;">'39'</span>, <span style="color:#996600;">'Panda'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Define a regular function that takes three arguments</span>
<span style="color:#9966CC; font-weight:bold;">def</span> hi<span style="color:#006600; font-weight:bold;">&#40;</span>name, age, type<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'Hi '</span> + name + <span style="color:#996600;">'! You are '</span> + age + <span style="color:#996600;">' and a '</span> + type + <span style="color:#996600;">'!'</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Call the function using item1 and the splat operator</span>
hi<span style="color:#006600; font-weight:bold;">&#40;</span>*item1<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># Outputs: Hi Jack! You are 35 and a Panda!</span></pre></div></div>

<p>While JavaScript does not have such a convenient operator, experimenting around, I&#8217;ve found a good enough solution:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> item1 = <span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'Jack'</span>, <span style="color: #3366CC;">'39'</span>, <span style="color: #3366CC;">'Panda'</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> hi<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">name</span>, age, type<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
     console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Hi '</span> + <span style="color: #000066;">name</span> + <span style="color: #3366CC;">'! You are '</span> + age + <span style="color: #3366CC;">' and a '</span> + type + <span style="color: #3366CC;">'!'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
hi.<span style="color: #006600;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>, item1<span style="color: #66cc66;">&#41;</span>;
<span style="color: #009900; font-style: italic;">// Outputs to your Firebug console: Hi Jack! You are 39 and a Panda!</span></pre></div></div>

<p>The apply method is built into all functions in JavaScript and allows you to call a method of an object in the context of a different object (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Function:apply">Moz dev page here</a>). Think about it as the equivalent of temporarily moving that method off the current object (the window object if it&#8217;s a global function) and attaching it to another object before calling it. </p>
<p>The primary reason to use this method is for changing the <code>this</code> keyword reference inside of the called function, but it has the added benefit of optionally requiring an array of arguments that get passed to the called function. We basically keep the this keyword as the window object (could have specified window instead of <code>this</code>) and use it to unpack our array for us.</p>
<p>This solution is also useful in any situation where you have a function that takes an unlimited number of arguments and you want to to eventually send those arguments to another function that also accepts any number of arguments.  This situation is exactly what was puzzling me as I was working on creating a &#8220;safe&#8221; version of Firebug&#8217;s <code>console.log</code> that would work normally in Firefox but alert each argument separately in Internet Explorer.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pwning (JailBreaking) your iPhone 3g with 2.0.1 firmware</title>
		<link>http://readystate4.com/2008/08/11/pwning-jailbreaking-your-iphone-3g-with-201-firmware/</link>
		<comments>http://readystate4.com/2008/08/11/pwning-jailbreaking-your-iphone-3g-with-201-firmware/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 00:01:22 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/08/11/pwning-jailbreaking-your-iphone-3g-with-201-firmware/</guid>
		<description><![CDATA[

Excuse another iPhone posts, I have some juicy programmerly entries coming up I just have a few friends that are interested in this and want to save them some time.
The 2.0.1 firmware which came out just a few days ago was just the thing I was waiting for - it fixed the craziness and slowness [...]]]></description>
			<content:encoded><![CDATA[<div class="thumb_left" style="width: 410px;"><img src="http://readystate4.com/images/blog/pwnage.jpg" alt="My brother Mark, his girlfriend Jen, and their iPhones"/>
</div>
<p>Excuse another iPhone posts, I have some juicy programmerly entries coming up I just have a few friends that are interested in this and want to save them some time.</p>
<p>The 2.0.1 firmware which came out just a few days ago was just the thing I was waiting for - it fixed the craziness and slowness that was going on with (all?) my iphone (hour long backups anyone?) as well as the slow texting and &#8220;apple screen of death&#8221;. It came, in fact, just when I decided to jailbreak my iPhone for the second time. </p>
<p>The first time I did it was back before 2.0 firmware and it was the high life. I had SSH, VNC clients, silly games, and an Apache web server running from my phone. I gave all that up for the light saber app and international keyboard support. But now I have the best of both worlds again, and the five hours it cost me can be yours in less than one following my quick guide.</p>
<p>At first jailbreaking your iPhone was really hard. You had to do all kinds of things in terminal and cross reference about three or four tutorials that all weren&#8217;t quite right. Then it got really easy - just go to a web site using your phone&#8217;s browser and BAM, your iPhone got to pass go and collect two hundred dollars. Now it&#8217;s somewhere in the middle. Freedom is in the form of a downloadable app called Pwnage (Mac only but there should be a Windows equivalent by now). Basically, jailbreaking your phone under the 2.0 firmware involves rewriting the latest firmware update and making a custom &#8220;altered&#8221; one for you to restore with - don&#8217;t worry it&#8217;s a lot easier than it sounds and as far as I can tell, it&#8217;s impossible to brick your phone, it would have happened to me from all the things I&#8217;ve tried. So here&#8217;s what to do:</p>
<ol>
<li>Backup your iPhone and restore it to factory condition (you can restore your backed-up files later.) </li>
<li>Visit this link and download Pwnage to your desktop (don&#8217;t run it or unzip it): http://blog.iphone-dev.org/post/45276976/good-morning </li>
<li><b>IMPORTANT: Do not use some app to unzip the file.</b> It creates weird permission issues and it looks like 80% who tried this including myself wasted a lot of time reformatting their phones several times. Instead, open up Terminal, change directories to your desktop, and unzip the file with this command: <code>tar -jxvf PwnageTool_2.0.2.tbz</code></li>
<li>For some reason, iTunes keeps backups of all your firmware updates - this seems incredibly wasteful to me since they&#8217;re about 250mb a piece. Inside of <code>/Users/USERNAME/Library/iTunes/Mobile Backups</code> is where they&#8217;re located.
<p>Go ahead and move the 2.0.1 update (iPhone1,2_2.0.1_5B108_Restore.ipsw) to your desktop. </p>
<p>(If you&#8217;re having trouble finding this folder just type <code>open /Users/USERNAME/Library/iTunes/Mobile\ Backups</code>, where USERNAME is the current logged in user. If you don&#8217;t know who the current logged in user is type <code>whoami</code> in Terminal.</li>
<li>Ok, now run Pwnage in Expert mode (simple mode is awesome but it only auto-detects and tries to use the 2.0 firmware, not 2.01.) Browse for your latest software update file (IPSW) on your desktop. Here you have a bunch of options. Just do this:
<p>Click General, then the next button, and unclick Activate the phone. Hit the Back button.</p>
<p>OPTIONAL: Click custom logos, next, and uncheck them if you don&#8217;t want them. Hit the back button.</p>
<p>Click the Build button and the next button. In about 5-10 minutes you should have your new IPSW file. Here it should ask you to do some magically things with your iphone, including putting it into recovery mode. It&#8217;s SLIGHTLY tricky but you just have to get the timing right to get into recovery mode. Last time I remember, it&#8217;s 10 seconds on home and sleep buttons followed by 5 seconds on home button. Just follow the pictures (don&#8217;t look at the words, they throw you off.)</li>
<li>Switch back to iTunes. It&#8217;ll say it detects your phone in revovery mode. Option click the restore button - it will allow you to pick a file. Pick the custom one from your desktop. In a few minutes you&#8217;re done!
<p>You should see 2 new icons on your springboard. The old familiar Installer, where you can install apps with. And the new installer called Cyndia. Try to open up Cyndia - if it crashes, that means there were some permission issues when you initially unzipped pwnage. Try again.</li>
<li>Optionally, restore from your backup in step 1. Now install apps to your hearts content!</li>
<p></p>
<p>Do note that right now a lot of 1.0 jailbreak apps haven&#8217;t been ported to the new 2.0 framework yet. Still there is a lot of cool stuff including having an  interactive terminal, the ability to SSH/SFTP into your phone and SSH out to other machines, Ruby, Perl, Python, and Java support, Lighttpd web sever, an NES emulator, MxTube (let&#8217;s you download full res Youtube vids to your phone), lots of abilities to customize themes, logos, ringtones on your phone, SVN, CVS, IRC clients, Lynx, and the list goes on.</p>
<p>If you have any trouble with the above and you have my phone number feel free to call me, else just leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/08/11/pwning-jailbreaking-your-iphone-3g-with-201-firmware/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Things I dig about the new iPhone 3g</title>
		<link>http://readystate4.com/2008/07/18/what-i-dig-about-the-new-iphone-3g/</link>
		<comments>http://readystate4.com/2008/07/18/what-i-dig-about-the-new-iphone-3g/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 16:38:31 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/07/18/what-i-dig-about-the-new-iphone-3g/</guid>
		<description><![CDATA[
My brother Mark, his girlfriend Jen, and their iPhones.

I got into a conversation about the differences I notice between the old iPhone and the new iPhone 3g. Here&#8217;s my quick list (ordered by what I appreciate the most):

 The headphone jack: is flush now instead of recessed so you can use any headphones you like [...]]]></description>
			<content:encoded><![CDATA[<div class="thumb_right"><a href="http://flickr.com/photos/jendoolee/1019785256/"><img alt="My brother Mark, his girlfriend Jen, and their iPhones" src="http://farm2.static.flickr.com/1369/1019785256_62f563ad4e_m.jpg" /></a>
<div>My brother Mark, his girlfriend Jen, and their iPhones.</div>
</div>
<p>I got into a conversation about the differences I notice between the old iPhone and the new iPhone 3g. Here&#8217;s my quick list (ordered by what I appreciate the most):</p>
<ol>
<li> The headphone jack: is flush now instead of recessed so you can use any headphones you like (I&#8217;d upgrade just for this INCREDIBLE feature, probably the greatest thing about the new iPhone - I mean what will the great minds at Apple think of next?)</li>
<li> The sound: on the speakers is louder and less distorted. I can actually watch a TV show or movie on my iPhone in a quiet room and hear it clearly. I still prefer my headphones (Etymotic Er-4 p&#8217;s) but it&#8217;s nice to have the option. I think the overall sound quality on calls is better, too.</li>
<li> The GPS: rocks. Not as fast or efficient as a regular GPS device but locating myself with Maps is <em>a lot</em> faster and more accurate, plus it tracks me as I&#8217;m moving around with a cool &#8220;sonar&#8221; animation (compared to the old system where you just had to hit the &#8220;find me&#8221; button to relocate yourself.) This is extremely useful when using Maps with driving as I don&#8217;t always know if I&#8217;m started out in the right direction.</li>
<li> 3g: mucho faster. I hear you can&#8217;t get it in a lot of areas but in NYC it seems to be working great. It makes using the internet bearable on the iPhone. Connecting to a wireless point still blows it away but again, it brings using the internet on the go a recreational thing, instead of just a I-really-need-this-information-right-now-and-this-is-my-only-option thing.</li>
<li> Lots of small physical enhancements: Apple is really good at this. They&#8217;ve probably improved fifty things physically on the iPhone that you&#8217;ll never notice. One that I noticed right away is that the headphone jack &#8220;grips&#8221; your headphone plug, locking it in place. You can actually (lightly) swing your iPhone around by the headphones (I don&#8217;t recommend this.) This helps dramatically as dozens of times I&#8217;d be walking down the street, listening to my old iPhone in my jean pocket, only to get eventually unplugged. This never happens anymore.</li>
<li> The Apps: fun and fast (compared to their web app counterparts). Even though you can use the new app system on your old version 1 iPhones, location based apps like Yelp really shine with the GPS.</li>
</ol>
<p>The iPhone continues to be a game-changer and this recent update was more evolutionary than revolutionary but it was certainly needed. There&#8217;s a lot more new stuff I really dig, like international keyboard support and a (sorta) native AIM and Twitter clients but this stuff is also available with the new firmware update on the old iPhones as well, and I wanted to keep this entry focused on the differences.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/18/what-i-dig-about-the-new-iphone-3g/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Inject jQuery into any page / A better jQuery bookmarklet</title>
		<link>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/</link>
		<comments>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 22:53:32 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/</guid>
		<description><![CDATA[The problem
I had to find out the language codes of all supported languages in TinyMCE (this page), but unfortunately, they were only listed in the actual download link for each file. A quick sprinkle of jQuery code in my Firebug console would have returned me a list easily but this page didn&#8217;t have it - [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem</h3>
<p>I had to find out the language codes of all supported languages in TinyMCE (<a href="http://services.moxiecode.com/i18n/">this page</a>), but unfortunately, they were only listed in the actual download link for each file. A quick sprinkle of jQuery code in my Firebug console would have returned me a list easily but this page didn&#8217;t have it - which lead me to consider making a bookmarklet to add jQuery on any page. </p>
<h3>The solution:</h3>
<p>My wonderful coworker Bryan told me immediately about a simple bookmarklet that does the above called <a href="http://www.google.com/search?hl=en&#038;client=firefox-a&#038;rls=org.mozilla%3Aen-US%3Aofficial&#038;hs=Dty&#038;q=jQuerify&#038;btnG=Search">jQuerify</a>. Looking through it, I saw a few potential issues with this script and also decided I wanted something a little more personal, so I came up with my own version:</p>
<p><a href="javascript:(function(){if(!window.jQuery){var s=document.createElement('script');s.src='http://jquery.com/src/jquery-latest.js';document.getElementsByTagName('head')[0].appendChild(s);var z=setInterval(function(){if(window.jQuery){$j=jQuery.noConflict();alert('jQuery loaded!');window.clearInterval(z)}},100)}if(!window.$){window.$=function(x){return document.getElementById(x)}}})();">$jQuerify</a></p>
<p>Notable differences:</p>
<ul>
<li>Moved the jQuery shortcut <code>$</code> to <code>$j</code>. I always do this on any site I work on because I find <code>$</code> is used by so many other libraries and scripts that I want to minimize conflicts. Using <code>$j</code> also for sure tells me I&#8217;m using jQuery.</li>
<li>If <code>$</code> isn&#8217;t being used it becomes a shortcut to <code>document.getElementById</code>. I think it&#8217;s what people naturally expect <code>$</code> to do, and in my daily coding I like using <code>$('id');</code> better than <code>$j('#id')[0];</code> when all I want to do is return an element.
<li>Added an initial check for jQuery to prevent running the script unnecessary.</li>
</ul>
<p>The full source looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #66cc66;">&#40;</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: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!window.<span style="color: #006600;">jQuery</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> s=document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #66cc66;">&#41;</span>;
        s.<span style="color: #006600;">src</span>=<span style="color: #3366CC;">'http://jquery.com/src/jquery-latest.js'</span>;
        document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> z=setInterval<span style="color: #66cc66;">&#40;</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: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>window.<span style="color: #006600;">jQuery</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                $j = jQuery.<span style="color: #006600;">noConflict</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'jQuery loaded!'</span><span style="color: #66cc66;">&#41;</span>;
                window.<span style="color: #006600;">clearInterval</span><span style="color: #66cc66;">&#40;</span>z<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>,<span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!window.$<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	window.$=<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>x<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span>x<span style="color: #66cc66;">&#41;</span>;<span style="color: #66cc66;">&#125;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><a href="javascript:(function(){if(!window.jQuery){var s=document.createElement('script');s.src='http://jquery.com/src/jquery-latest.js';document.getElementsByTagName('head')[0].appendChild(s);var z=setInterval(function(){if(window.jQuery){$j=jQuery.noConflict();alert('jQuery loaded!');window.clearInterval(z)}},100)}if(!window.$){window.$=function(x){return document.getElementById(x)}}})();">$jQuerify</a> <-- Try me out, drag me to your tool bar.</p>
<h3>Happy endings</h3>
<p>Now I can just hop back over to the <a href="http://services.moxiecode.com/i18n/">TinyMCE Language Pack Download page</a>, run my bookmarklet, type the following in Firebug:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$j<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#examplecontent form:first table tbody tr'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>c,i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> country = $j<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'td:eq(2) label'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #003366; font-weight: bold;">var</span> code= $j<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'td:eq(1) a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">match</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/<span style="color: #66cc66;">&#40;</span>?:code=<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>..<span style="color: #66cc66;">&#41;</span>/</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span>;
    console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span>c,country,<span style="color: #3366CC;">'='</span>,code<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>And the list is returned:</p>
<pre>
0 Arabic = ar
1 Bokmål, Norwegian; Norwegian Bokmål = nb
2 Bosnian = bs
3 Bulgarian = bg
4 Catalan; Valencian = ca
5 Chamorro = ch
6 Chinese = zh
7 Croatian = hr
8 Czech = cs
9 Danish = da
10 Dutch; Flemish = nl
11 English = en
12 Estonian = et
13 Finnish = fi
14 French = fr
15 German = de
16 Greek, Modern (1453-) = el
17 Hebrew = he
18 Hungarian = hu
19 Interlingua (International Auxiliary Language Association) = ia
20 Italian = it
21 Japanese = ja
22 Korean = ko
23 Latvian = lv
24 Lithuanian = lt
25 Macedonian = mk
26 Malay = ms
27 Northern Sami = se
28 Norwegian Nynorsk; Nynorsk, Norwegian = nn
29 Persian = fa
30 Polish = pl
31 Portuguese = pt
32 Romanian = ro
33 Russian = ru
34 Sardinian = sc
35 Serbian = sr
36 Sichuan Yi = ii
37 Sinhala; Sinhalese = si
38 Slovak = sk
39 Slovenian = sl
40 Spanish; Castilian = es
41 Swedish = sv
42 Tatar = tt
43 Turkish = tr
44 Twi = tw
45 Ukrainian = uk
46 Vietnamese = vi
</pre>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tips and tricks for Firefox 3</title>
		<link>http://readystate4.com/2008/07/05/tips-and-tricks-for-firefox-3/</link>
		<comments>http://readystate4.com/2008/07/05/tips-and-tricks-for-firefox-3/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 23:37:24 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/07/05/tips-and-tricks-for-firefox-3/</guid>
		<description><![CDATA[Lifehacker has a great post on tips and tricks for Firefox 3. Favorites include deleting mistyped URL&#8217;s in the new URL suggestion window and auto-complete entries (I hate when my mistakes get saved!), making web applications like gmail launch instead of default desktop apps, enabling spell-checking in single line input fields (as apposed to just [...]]]></description>
			<content:encoded><![CDATA[<p>Lifehacker has a great post on <a href="http://lifehacker.com/396312/power-users-guide-to-firefox-3">tips and tricks for Firefox 3.</a> Favorites include deleting mistyped URL&#8217;s in the new URL suggestion window and auto-complete entries (I hate when my mistakes get saved!), making web applications like gmail launch instead of default desktop apps, enabling spell-checking in single line input fields (as apposed to just textareas), and lastly, for Mac FF3 users with the default Safari skin, adding favicons back in your bookmark toolbar.</p>
<p>Firefox 3&#8217;s new ability to <a href="http://lifehacker.com/392287/set-firefox-3-to-launch-gmail-for-mailto-links">register web apps to link protocols</a> is most interesting. As a web developer you&#8217;ll be able to create your own protocols for your web app via JavaScript using a method added to the <code>navigator</code> object called <code> <a title="Mozilla Dev Center entry on registerProtocolHandler" href="http://developer.mozilla.org/en/docs/DOM:window.navigator.registerProtocolHandler">registerProtocolHandler</a></code> . For example, registering the mailto protocol to your gmail looks like this:</p>
<p>javascript:window.navigator.registerProtocolHandler(&#8221;mailto&#8221;,&#8221;https://mail.google.com/mail/?extsrc=mailto&#038;url=%s&#8221;,&#8221;GMail&#8221;)</p>
<p>This has some really exciting potential for web apps!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/05/tips-and-tricks-for-firefox-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Note to jQuery developer team: Please use curly brackets!</title>
		<link>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/</link>
		<comments>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 17:25:37 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/</guid>
		<description><![CDATA[If you haven&#8217;t gathered so far, I think the jQuery JavaScript library is the dog&#8217;s bollocks. Its small, efficient, and has improved my life as a developer almost as much as Firebug. jQuery gets flack occasionally for containing complex or cryptic code full of ternary operators and multiple variable declarations in a single statement (eg. [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t gathered so far, I think the <a href="http://jquery.com/">jQuery</a> JavaScript library is the dog&#8217;s bollocks. Its small, efficient, and has improved my life as a developer almost as much as <a href="http://getfirebug.com/">Firebug</a>. jQuery gets flack occasionally for containing complex or cryptic code full of ternary operators and multiple variable declarations in a single statement (eg. a=b=1), which I mostly see as concise and efficient coding however, there&#8217;s one thing about the jQuery library that I can&#8217;t stand. It&#8217;s something every developer should do and if you&#8217;re not doing it then you&#8217;re a jerk and that, ladies and gentlemen, is omitting your curly brackets.</p>
<p>Look at this code snippet from the jQuery library to see what I mean:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span> ; i &lt; length; i++ <span style="color: #66cc66;">&#41;</span>
	<span style="color: #009900; font-style: italic;">// Only deal with non-null/undefined values</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>options = arguments<span style="color: #66cc66;">&#91;</span> i <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #009900; font-style: italic;">// Extend the base object</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> <span style="color: #000066;">name</span> <span style="color: #000066; font-weight: bold;">in</span> options <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> src = target<span style="color: #66cc66;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #66cc66;">&#93;</span>, copy = options<span style="color: #66cc66;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #66cc66;">&#93;</span>;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Prevent never-ending loop</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> target === copy <span style="color: #66cc66;">&#41;</span>
				<span style="color: #000066; font-weight: bold;">continue</span>;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Recurse if we're merging object values</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> deep &amp;&amp; copy &amp;&amp; <span style="color: #000066; font-weight: bold;">typeof</span> copy == <span style="color: #3366CC;">&quot;object&quot;</span> &amp;&amp; !copy.<span style="color: #006600;">nodeType</span> <span style="color: #66cc66;">&#41;</span>
				target<span style="color: #66cc66;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #66cc66;">&#93;</span> = jQuery.<span style="color: #006600;">extend</span><span style="color: #66cc66;">&#40;</span> deep,
					<span style="color: #009900; font-style: italic;">// Never move original objects, clone them</span>
					src || <span style="color: #66cc66;">&#40;</span> copy.<span style="color: #006600;">length</span> != <span style="color: #003366; font-weight: bold;">null</span> ? <span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#93;</span> : <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>
				, copy <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Don't bring in undefined values</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> copy !== undefined <span style="color: #66cc66;">&#41;</span>
				target<span style="color: #66cc66;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #66cc66;">&#93;</span> = copy;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// Return the modified object</span>
<span style="color: #000066; font-weight: bold;">return</span> target;</pre></div></div>

<p style="margin-top:10px;">
Coding in this way leads is extremely error-prone especially for open-souce projects where many others are modifying your code. Please stop it.</p>
<p>Love,</p>
<p>A dedicated user</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating a usable JavaScript Library</title>
		<link>http://readystate4.com/2008/07/02/creating-a-usable-javascript-library/</link>
		<comments>http://readystate4.com/2008/07/02/creating-a-usable-javascript-library/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 05:48:59 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://readystate4.com/2008/07/02/creating-a-usable-javascript-library/</guid>
		<description><![CDATA[I&#8217;m working on small JavaScript library for cross-(sub)domain communication through iframes for users of our platform and my target audience will have little to no JavaScript experience. While I&#8217;m going to have extensive documentation, my goal really is to make this library like HTML - easy to understand and pickup, without necessary having to consult [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on small JavaScript library for cross-(sub)domain communication through iframes for users of our platform and my target audience will have little to no JavaScript experience. While I&#8217;m going to have extensive documentation, my goal really is to make this library like HTML - easy to understand and pickup, without necessary having to consult a reference. Generally, I want one site creator (we call them affiliates) to look at another person&#8217;s site, say &#8220;How did he do that?&#8221;, view the source code, copy it, and implement it on her own site by altering the code.</p>
<p>My initial setup code (to configure/initialize) the library looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">document.<span style="color: #006600;">domain</span>=<span style="color: #3366CC;">'mydomain.com'</span>;
Library.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'sub.domain.com'</span>,<span style="color: #CC0000;">5166</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>After looking back at it I thought about converting it to this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">document.<span style="color: #006600;">domain</span>=<span style="color: #3366CC;">'mydomain.com'</span>;
Library.<span style="color: #006600;">setCommunity</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'sub.domain.com'</span><span style="color: #66cc66;">&#41;</span>;
Library.<span style="color: #006600;">setAffiliateSiteId</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">5166</span><span style="color: #66cc66;">&#41;</span>;
Library.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>This is really clean and easy to understand but a little much if I need to add a ton more settings in the future.<br />
My latest iteration looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">document.<span style="color: #006600;">domain</span>=<span style="color: #3366CC;">'mydomain.com'</span>;
Library.<span style="color: #006600;">configure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>community:<span style="color: #3366CC;">'sub.domain.com'</span>, affiliateSiteId: <span style="color: #CC0000;">5166</span>, showErrors: <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Although passing (JSON) objects around isn&#8217;t the most easy to understand for people with little or no JavaScript knowledge, it isn&#8217;t <i>that</i> unreadable and I really feel the pros outweighed the cons. In some of my methods there will be so many arguments that passing an object would be necessary and the user implementing the library is going to have to learn the syntax regardless. Plus passing data in a regular argument (x,y,z) format isn&#8217;t really good for optional parameters of which they&#8217;ll be a ton of in this library.<br />
I&#8217;ve also decided to remove the initialize method and just auto-initialize once you&#8217;ve configured your settings. The more I can take away from the process the better.</p>
<p>Lastly, I added an optional error mode that will trigger an alert if you&#8217;re doing something wrong. The idea would be to disable it (remove or set  it to false) when you&#8217;re ready for production. This may add substantial bloat to the codebase so it may not stay in - or I could keep this feature in the dev version of the code and recommend affiliates use the production version after the initial creation process.</p>
<p class="update" style="padding: 5px; background-color: lightgreen"><b>Note:</b> The library isn&#8217;t actually called &#8220;Library&#8221;. I&#8217;m hiding it&#8217;s name until it&#8217;s ready. ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/02/creating-a-usable-javascript-library/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mozilla&#8217;s &#8220;home&#8221; JavaScript function</title>
		<link>http://readystate4.com/2008/06/30/mozillas-home-javascript-function/</link>
		<comments>http://readystate4.com/2008/06/30/mozillas-home-javascript-function/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 22:08:14 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/06/30/mozillas-home-javascript-function/</guid>
		<description><![CDATA[I came across an interesting bug in someone&#8217;s code today. They had an iframe that was dynamically created and it&#8217;s url was different depending on whether the variable home was true or not. They had declared home a few lines earlier but the condition was always returning true no matter what. Turns out, there is [...]]]></description>
			<content:encoded><![CDATA[<p>I came across an interesting bug in someone&#8217;s code today. They had an iframe that was dynamically created and it&#8217;s url was different depending on whether the variable <code>home</code> was true or not. They had declared <code>home</code> a few lines earlier but the condition was always returning true no matter what. Turns out, there is already a variable of the same name in Mozilla-based browsers. It&#8217;s a function that when called, takes you to your home page set in your browser preferences.</p>
<p>I don&#8217;t have time to hack around with it at the moment, but I&#8217;d imagine that this is a slight security risk. Similar to Jeremiah Grossman&#8217;s <a href="http://jeremiahgrossman.blogspot.com/2006/08/i-know-where-youve-been.html">CSS History Hack</a> that can potentially tell all the sites you&#8217;ve visited recently, this one would tell what user&#8217;s home pages were set to. Initial thoughts are that this would be hard to do since the only way to call this function without leaving the page is to call it in an iframe (<a href="http://readystate4.com/tests/mozilla_home_function_in_an_iframe.html">tried it and it works</a>) but iframe sandboxing restrictions prevent code from the parent frame from seeing or accessing the contents of this iframe (or it&#8217;s <code>window.location</code> object) since it&#8217;s from a different domain. A quick check shows that this function doesn&#8217;t exist in Safari or Internet Explorer.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/06/30/mozillas-home-javascript-function/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
