<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OMGWTFInternet!</title>
	<atom:link href="http://blog.iamnoahcooper.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iamnoahcooper.com</link>
	<description>The internet is one of the largest nets in the entire world. Here are some things that I like/find humorous/want others to see/what-have-you.</description>
	<lastBuildDate>Sun, 10 Mar 2013 12:43:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Server-Sent Events: They&#8217;s Niiice</title>
		<link>http://blog.iamnoahcooper.com/2012/05/server-sent-events-theys-niiice/</link>
		<comments>http://blog.iamnoahcooper.com/2012/05/server-sent-events-theys-niiice/#comments</comments>
		<pubDate>Thu, 24 May 2012 17:50:24 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=377</guid>
		<description><![CDATA[I first heard about Server-Sent Events a few months ago, though I didn&#8217;t have a chance to take &#8216;em out for a test drive until this past week. I have to say, I&#8217;m impressed. Server-Sent Events refers to a new-ish spec which allows a server to push data to the web browser, requiring only a [...]]]></description>
				<content:encoded><![CDATA[<p>I first heard about <a target="_blank" href="http://en.wikipedia.org/wiki/Server-sent_events">Server-Sent Events</a> a few months ago, though I didn&#8217;t have a chance to take &#8216;em out for a test drive until this past week. I have to say, I&#8217;m impressed. </p>
<p>Server-Sent Events refers to <a href="http://dev.w3.org/html5/eventsource/">a new-ish spec</a> which allows a server to push data to the web browser, requiring only a few lines of native JavaScript on the client-side. This new interface drastically simplifies web applications which rely on periodic updates from a server-side application. For example, Mozilla provided <a target="_blank" href="http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/">this example of a &#8220;wall&#8221;</a> built using Server-Sent Events. I wrote some sample code of my own to see just how hard it is to implement Server-Sent Events, and the answer is, it&#8217;s not. </p>
<p><span id="more-377"></span></p>
<p><strong>The Server-Side</strong></p>
<p>The Server-Sent Events spec is really just a new way of solving an old problem. For quite some time, developers have been building client-side applications that periodically refresh themselves with up-to-date information, the obvious example being sites like Facebook and Twitter. Historically, these applications have relied on long polling, where the JavaScript <code>setTimeout</code> method is used to repeatedly make AJAX requests to retrieve fresh data. The biggest change with Server-Sent Events is that the server is given control over this process, using a push rather than a pull. The client makes an HTTP request, and from there the server sends responses at intervals it defines. The benefit of this approach is that the client only makes <em>a single HTTP request which stays open</em>, rather than an ongoing series of requests which come with excess overhead.</p>
<p>As an example, I modified the photo API that I created for <a href="http://blog.iamnoahcooper.com/2012/02/cors-worth-geeking-out-over/">my earlier post on CORS</a> to support Server-Sent Events. Here&#8217;s a look at the modified response from that API:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">retry<span style="color: #339933;">:</span> <span style="color: #CC0000;">8000</span>
data<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;kjonaas&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #3366CC;">&quot;photo&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;large&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://iamnoahcooper.com/kjonaas-elton-cooper/images/motorcycle.jpg&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;small&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://iamnoahcooper.com/kjonaas-elton-cooper/thumbs/motorcycle.jpg&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;caption&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Riding his motorcycle at Auditorium Shores.&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;date&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;02/27/2010&quot;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The first line defines the interval for pushing data to the client in milliseconds. The second is the data to be sent in the message, in this case formatted as json. While my example doesn&#8217;t, the response can also include an <code>event</code>, which as its name implies, allows the server to notify the client when an event occurs. An example would be a login or logout event.</p>
<p><strong>The Client-Side</strong></p>
<p>With the API above complete, I only needed to write a tiny bit of HTML and JavaScript to display a random photo of my son every 8 seconds. If you view source on <a target="_blank" href="http://iamnoahcooper.com/kj_sse.html">http://iamnoahcooper.com/kj_sse.html</a>, you&#8217;ll see the following JavaScript:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">EventSource</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">var</span> source <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> EventSource<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://iamnoahcooper.com/kjonaas-elton-cooper/'</span> <span style="color: #339933;">+</span> 
   <span style="color: #3366CC;">'random.php?format=json_sse&amp;ts='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">new</span> <span style="">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   source.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">var</span> photo <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">kjonaas</span>.<span style="color: #660066;">photo</span><span style="color: #339933;">;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'kjonaas'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;img src=&quot;'</span> <span style="color: #339933;">+</span> 
      photo.<span style="color: #660066;">large</span> <span style="color: #339933;">+</span> 
      <span style="color: #3366CC;">'&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;'</span> <span style="color: #339933;">+</span> 
      photo.<span style="color: #660066;">caption</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The crux of Server-Sent Events on the client-side is the EventSource constructor. As you can see, I simply bound an event listener to the <code>message</code> event that parses the <code>data</code> seen in the response above. Again, after the initial HTTP request is made by the client, it will stay open, and each time the server sends a new message, this function will be fired once more. Pretty cool!</p>
<p><strong>Problems</strong></p>
<p>While <a target="_blank" href="http://caniuse.com/#feat=eventsource">modern browsers such as Firefox, Chrome, Safari, and Opera support Server-Sent Events</a> (and in many cases have for some time now), it&#8217;s worth noting that there are two kind of important browsers that don&#8217;t: Internet Explorer and Android. That shouldn&#8217;t be used as a reason not to implement Server-Sent Events, however! For these browsers, developers can just continue to use long polling. </p>
<p>What&#8217;s more disappointing to me is that it appears that currently <a target="_blank" href="https://developer.mozilla.org/en/Server-sent_events/Using_server-sent_events">Firefox is the only browser that supports Server-Sent Events via CORS</a>, as I can think of plenty of interesting cross-domain applications of Server-Sent Events.</p>
<p>Another slightly annoying issue that&#8217;s going to have to be addressed by browser vendors as Server-Sent Events are more widely adopted is that one cannot directly view message data, because the client doesn&#8217;t seem to know how to render the <code>text/event-stream</code> Content-Type. This made troubleshooting issues I encountered with my API difficult, as neither Firebug nor the Chrome Net panel are capable of displaying the response.</p>
<p><a target="_blank" href="http://blog.iamnoahcooper.com/wp-content/uploads/2012/05/sse-net-panel1.png"><img src="http://blog.iamnoahcooper.com/wp-content/uploads/2012/05/sse-net-panel1-1024x558.png" alt="" width="620" height="337" class="aligncenter size-large wp-image-421" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2012/05/server-sent-events-theys-niiice/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Super Bass&#8221; in JavaScript</title>
		<link>http://blog.iamnoahcooper.com/2012/04/super-bass-in-javascript/</link>
		<comments>http://blog.iamnoahcooper.com/2012/04/super-bass-in-javascript/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 15:39:53 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=331</guid>
		<description><![CDATA[Inspired by Jack Shepherd&#8217;s literal songs. var theBoys=document.getElementsByTagName&#40;'boy'&#41;, deck=&#91;&#93;; function lookForDude&#40;&#41;&#123; var dude; for&#40;i=0;i&#60;theBoys.length;i++&#41;&#123; if&#40;theBoys&#91;i&#93;.system==='boomin\''&#38;&#38;theBoys&#91;i&#93;.top==='down' &#38;&#38;theBoys&#91;i&#93;.AC.coolinSystem&#41;&#123; var theClub=document.getElementById&#40;'club'&#41;; theClub.appendChild&#40;theBoys&#91;i&#93;&#41;; theBoys&#91;i&#93;.blazin++; deck.push&#40;theBoys&#91;i&#93;.getElementsByTagName&#40;'stack'&#41;&#41;; theBoys&#91;i&#93;.ill==theBoys&#91;i&#93;.real==true; theBoys&#91;i&#93;.deal==Math.floor&#40;Math.random&#40;&#41;*2&#41;==1?true:false; while&#40;document.getElementsByTagName&#40;'bottle'&#41;.length&#41;&#123; document.getElementsByTagName&#40;'bottle'&#41;.pop&#40;&#41;; &#125; theBoys&#91;i&#93;.getElementsByTagName&#40;'build'&#41;&#91;0&#93;.style.textAlign='right'; theBoys&#91;i&#93;.temperature--; theBoys&#91;i&#93;.dope=true; if&#40;Math.floor&#40;Math.random&#40;&#41;*2&#41;==1&#41;&#123; for&#40;j=0;j&#60;theClub.getElementsByTagName&#40;'boy'&#41;;j++&#41;&#123; if&#40;theClub.getElementsByTagName&#40;'boy'&#41;&#91;j&#93;.coke.length===0&#41; theClub.getElementsByTagName&#40;'boy'&#41;&#91;j&#93;.coke++; &#125; &#125; document.getElementById&#40;'plane'&#41;.getElementsByTagName&#40;'class'&#41;&#91;0&#93; .appendChild&#40;theBoys&#91;i&#93;&#41;; var trip=function&#40;boy&#41;&#123; if&#40;boy.trip&#41; return 'mutha fuckin\' trip'; &#125;; var isTrip=trip&#40;theBoys&#91;i&#93;&#41;; var ship=&#123; ship:&#123; sailor:theBoys&#91;i&#93; &#125; &#125;; var drip=function&#40;&#41;&#123; [...]]]></description>
				<content:encoded><![CDATA[<p>Inspired by Jack Shepherd&#8217;s <a target="_blank" href="http://lovefromjack.com/c/literal_songs/">literal songs</a>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> theBoys<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'boy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
deck<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> lookForDude<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">var</span> dude<span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>theBoys.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">system</span><span style="color: #339933;">===</span><span style="color: #3366CC;">'boomin<span style="color: #000099; font-weight: bold;">\'</span>'</span><span style="color: #339933;">&amp;&amp;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">top</span><span style="color: #339933;">===</span><span style="color: #3366CC;">'down'</span>
      <span style="color: #339933;">&amp;&amp;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">AC</span>.<span style="color: #660066;">coolinSystem</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">var</span> theClub<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'club'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         theClub.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">blazin</span><span style="color: #339933;">++;</span>
         deck.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'stack'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">ill</span><span style="color: #339933;">==</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">real</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">deal</span><span style="color: #339933;">==</span><span style="">Math</span>.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="">Math</span>.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #CC0000;">1</span><span style="color: #339933;">?</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
         while<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'bottle'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'bottle'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'build'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">textAlign</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'right'</span><span style="color: #339933;">;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">temperature</span><span style="color: #339933;">--;</span>
         theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">dope</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="">Math</span>.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="">Math</span>.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;</span>theClub.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'boy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
               <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theClub.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'boy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">coke</span>.<span style="color: #660066;">length</span><span style="color: #339933;">===</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
                  theClub.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'boy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">coke</span><span style="color: #339933;">++;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
         document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'plane'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>
         .<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">var</span> trip<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>boy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>boy.<span style="color: #660066;">trip</span><span style="color: #009900;">&#41;</span>
               <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'mutha fuckin<span style="color: #000099; font-weight: bold;">\'</span> trip'</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">var</span> isTrip<span style="color: #339933;">=</span>trip<span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">var</span> ship<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>
            ship<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
               sailor<span style="color: #339933;">:</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">var</span> drip<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'lip'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'lip'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>
            .<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'kiss'</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#41;</span>
            theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'drip'</span><span style="color: #339933;">,</span>drip<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#41;</span>
            theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">attachEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ondrip'</span><span style="color: #339933;">,</span>drip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         dude<span style="color: #339933;">=</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">return</span> dude<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>lookForDude<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> slapHo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">var</span> ho<span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      ho<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span>
      ho<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Microsoft.XMLHTTP'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   ho.<span style="color: #660066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'/ho-json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   ho.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   ho.<span style="color: #660066;">onreadystatechange</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>ho.<span style="color: #660066;">readyState</span><span style="color: #339933;">==</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>ho.<span style="color: #660066;">responseText</span>.<span style="color: #660066;">lookin</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">var</span> willHoGetSlapped<span style="color: #339933;">=</span>slapHo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
alert<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Excuse me, you<span style="color: #000099; font-weight: bold;">\'</span>re a hell of a guy.<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>
<span style="color: #3366CC;">'I mean my, my, my you<span style="color: #000099; font-weight: bold;">\'</span>re like pelican fly.<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>
<span style="color: #3366CC;">'I mean, you<span style="color: #000099; font-weight: bold;">\'</span>re so shy and I<span style="color: #000099; font-weight: bold;">\'</span>m lovin<span style="color: #000099; font-weight: bold;">\'</span> your tie.<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>
<span style="color: #3366CC;">'You<span style="color: #000099; font-weight: bold;">\'</span>re like slicker than the guy with the thing on his eye, oh!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> didShe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">function</span> whoTheEffSheIs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>didShe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      alert<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'She is Nicki Minaj, she macks them dudes up.<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>
      <span style="color: #3366CC;">'Back coupes up, and chuck the deuce up.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
whoTheEffSheIs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">var</span> boy<span style="color: #339933;">=</span>lookForDude<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
superBass<span style="color: #339933;">=</span><span style="color: #3366CC;">'boom, badoom, boom, boom, badoom, boom bass'</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> runAway<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
   <span style="color: #000066; font-weight: bold;">var</span> heartbeat<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'heartbeat'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   heartbeat.<span style="color: #660066;">style</span>.<span style="color: #660066;">position</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'absolute'</span><span style="color: #339933;">;</span>
   while<span style="color: #009900;">&#40;</span><span style="">Number</span><span style="color: #009900;">&#40;</span>heartbeat.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span>window.<span style="color: #660066;">innerWidth</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       heartbeat.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="">Number</span><span style="color: #009900;">&#40;</span>heartbeat.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   heartbeat.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'beating'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'/images/drum.png'</span><span style="color: #339933;">;</span>
   boy.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>heartbeat<span style="color: #339933;">,</span>boy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">return</span> boy.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'feeling'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>superBass<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">var</span> canBoyFeelIt<span style="color: #339933;">=</span>runAway<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   boy.<span style="color: #660066;">bass</span><span style="color: #339933;">=</span>superBass<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">function</span> checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>boy.<span style="color: #660066;">bass</span><span style="color: #339933;">===</span>superBass<span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">var</span> isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>theBoys.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'polo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">&amp;&amp;</span>
   <span style="color: #009900;">&#40;</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">entrepreneurial</span><span style="color: #339933;">||</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">mogul</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">var</span> crew<span style="color: #339933;">=</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">childNodes</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;</span>crew.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>crew<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">!==</span>theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>crew<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066; font-weight: bold;">var</span> cap<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      cap.<span style="color: #660066;">style</span>.<span style="color: #660066;">width</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'100%'</span><span style="color: #339933;">;</span>
      theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>cap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mac'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'disabled'</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">var</span> thatLook<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'look'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'her'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>thatLook<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'her'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'her'</span><span style="color: #009900;">&#41;</span>
      .<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'panties'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">var</span> excuseHer<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'p'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      excuseHer.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'You<span style="color: #000099; font-weight: bold;">\'</span>re a hell of a guy.&lt;br /&gt;'</span><span style="color: #339933;">+</span>
      <span style="color: #3366CC;">'You know I really got a thing for American guys.&lt;br /&gt;'</span><span style="color: #339933;">+</span>
      <span style="color: #3366CC;">'I mean, sigh, sickenin<span style="color: #000099; font-weight: bold;">\'</span> eyes.&lt;br /&gt;'</span><span style="color: #339933;">+</span>
      <span style="color: #3366CC;">'I can tell that you<span style="color: #000099; font-weight: bold;">\'</span>re in touch with your feminine side, oh!'</span><span style="color: #339933;">;</span>
      theBoys<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>excuseHer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
whoTheEffSheIs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
canBoyFeelIt<span style="color: #339933;">=</span>runAway<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'her'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'life'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>boy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
boy.<span style="color: #660066;">style</span>.<span style="color: #660066;">position</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'fixed'</span><span style="color: #339933;">;</span>
boy.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'0'</span><span style="color: #339933;">;</span>
boy.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'0'</span><span style="color: #339933;">;</span>
canBoyFeelIt<span style="color: #339933;">=</span>runAway<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
isThatThatSuperBass<span style="color: #339933;">=</span>checkBoysBass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2012/04/super-bass-in-javascript/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>CORS: Worth Geeking Out Over</title>
		<link>http://blog.iamnoahcooper.com/2012/02/cors-worth-geeking-out-over/</link>
		<comments>http://blog.iamnoahcooper.com/2012/02/cors-worth-geeking-out-over/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 17:36:42 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=162</guid>
		<description><![CDATA[As was recently and nerdily mentioned on Connection Caf&#233;, I&#8217;ve been working with the world-class engineering team at Convio to implement support for Cross-Origin Resource Sharing (CORS) in the new release of our API. Despite having been around since Firefox 3.5 (and, like, Chrome 2.0), CORS has received little attention from the web development community [...]]]></description>
				<content:encoded><![CDATA[<p>As was <a target="_blank" href="http://www.connectioncafe.com/posts/2011/12-december/5-nerdiest-upcoming-convio-features.html">recently and nerdily mentioned on Connection Caf&eacute;</a>, I&#8217;ve been working with the world-class engineering team at Convio to implement support for <a target="_blank" href="http://www.w3.org/TR/cors/">Cross-Origin Resource Sharing (CORS)</a> in the new release of our <a target="_blank" title="Convio's Open API" href="http://open.convio.com/api">API</a>. Despite having been around since Firefox 3.5 (and, like, Chrome 2.0), CORS has received little attention from the web development community at large. In my opinion, it is the most revolutionary and exciting change to the Internet in a long while, and deserves much more fanfare than things like, say, <a target="_blank" href="http://www.css3.info/preview/box-shadow/">box-shadow</a>.</p>
<p><span id="more-162"></span></p>
<p><strong>So what is this &#8220;CORS&#8221; thing anyway?</strong></p>
<p>At a super high level, CORS changes one of the fundamental (and annoying) rules of the web, the <a target="_blank" href="http://en.wikipedia.org/wiki/Same_origin_policy">same origin policy</a>, allowing domaina.com to share information with domainb.com. The same origin policy was put in place to prevent would-be hackers from reading personal information about you from the websites you frequent. Were it not for the same origin policy, I could easily embed some code on the page you&#8217;re viewing right now to steal your deets from, say, Amazon.com. While it&#8217;s obviously a really good thing that I can&#8217;t do that, this long-standing rule-with-no-exceptions is unbelievably frustrating for those of us who build web applications. It&#8217;s 2012; a lot has changed since the same origin policy was introduced in Netscape 2.0. There are plenty of completely legit reasons to need to share information across multiple domains. Thankfully, CORS now allows for doing exactly that. To use my previous example, if Amazon.com <em>wants</em> me to be able to read some (not-so-personal) information from its website, all it has to do is simply return a response header, <a target="_blank" href="https://developer.mozilla.org/En/HTTP_access_control">Access-Control-Allow-Origin</a>, indicating that my domain is allowed in.</p>
<p><strong>Try it out!</strong></p>
<p>To give a real life, working example, this <a href="http://iamnoahcooper.com/download.php?file=kj.html">simple little bit of HTML and JavaScript</a> will retrieve and display a random image of my son, <a target="_blank" title="Kjonaas Elton Cooper" href="http://iamnoahcooper.com/kjonaas-elton-cooper">Kjonaas</a>, when placed on any domain.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html5" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;kjonaas&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var xhr=new XMLHttpRequest();
var requestURI='http://iamnoahcooper.com/kjonaas-elton-cooper/random.php';
var ts=new Date().getTime();
var showPhoto=function(xml){
	var photo=xml.getElementsByTagName('photo')[0];
	document.getElementById('kjonaas').innerHTML='<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;'+</span>
<span style="color: #009900;">	photo.getElementsByTagName('large')[0].firstChild.nodeValue+</span>
<span style="color: #009900;">	'&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>'+
	photo.getElementsByTagName('caption')[0].firstChild.nodeValue;
};
if('withCredentials' in xhr){
	xhr.open('get',
	requestURI+'?ts='+ts,
	true);
	xhr.onload=function(){
		showPhoto(this.responseXML.getElementsByTagName('kjonaas')[0]);
	};
	xhr.send();
}
else if(typeof XDomainRequest!='undefined'){
	xhr=new XDomainRequest();
	xhr.open('get',
	requestURI+'?ts='+ts);
	xhr.onload=function(){
		var xml=new ActiveXObject('Microsoft.XMLDOM');
		xml.async=false;
		xml.loadXML(this.responseText);
		showPhoto(xml.getElementsByTagName('kjonaas')[0]);
	};
	xhr.send();
}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>If you examine the HTTP request to that little Kjonaas API I created, you&#8217;ll see the following header included in the response:</p>
<p><code>Access-Control-Allow-Origin: *</code></p>
<p>This is CORS in its most basic form &mdash; because I don&#8217;t need to worry about who can access the information this API returns, I&#8217;ve indicated that any domain that wants to is allowed to retrieve the XML. If I <em>did</em> want to restrict access to the API to, say, my wife&#8217;s website, I&#8217;d just need to return a more explicit header:</p>
<p><code>Access-Control-Allow-Origin: http://www.sarahpcooper.com</code></p>
<p><strong>If it&#8217;s not clear to you yet, I&#8217;m in love with CORS.</strong></p>
<p>I mean seriously enthralled. For years, like so many other web developers who pay their rent by writing AJAX, I&#8217;ve been hacking together solutions to do this exact thing, with various and sundry libraries, hidden iframes, and in moments of true desperation, Flash. The beauty of CORS is that, as seen above, it requires only a few lines of native JavaScript. What&#8217;s more, CORS is supported by <em>almost</em> every modern browser &mdash; Internet Explorer 8+, Firefox 3.5+, Safari 4+, and Chrome have all embraced it, and it works just as well on a phone or tablet as it does on a desktop. The one notable exception is Opera, though they&#8217;ve <a target="_blank" href="http://my.opera.com/core/blog/2011/10/28/cors-goes-mainline">recently announced</a> that support for CORS will be included in Opera 12. </p>
<p><strong>But it&#8217;s not all rainbows and unicorns, not yet at least.</strong></p>
<p>If you actually read my JavaScript above, you&#8217;ll note that I have an obnoxious but necessary <code>if</code> statement. As is so often the case, Microsoft decided to go with its own implementation of CORS rather than the standard adopted by its peers. To take advantage of CORS in IE, web developers must use the proprietary <code>XDomainRequest</code> object. Fortunately, <a target="_blank" href="http://blogs.msdn.com/b/ie/archive/2011/11/29/html5-for-applications-the-fourth-ie10-platform-preview.aspx">IE10 preview</a> indicates that Microsoft may have seen the error of its ways, and will support the standard <code>XMLHttpRequest</code> going forward.</p>
<p>The biggest catch, though, is IE&#8217;s <a target="_blank" href="http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx">Same Scheme policy</a>, which isn&#8217;t terribly well documented, so you might not know it exists until you run into it like I did. Same Scheme says that even with the advent of CORS, domaina.com can only share information with domainb.com if both use the same protocol. If you place my code above on a page served over HTTPS, and attempt to view that page in IE8 or IE9, you&#8217;ll get a JavaScript error. As a web developer for a company whose APIs are generally only accessibly over HTTPS for security reasons, this makes me want to rip every last one of my hairs out of my skull. Hopefully in adding support for <code>XMLHttpRequest</code>, Microsoft will also ditch Same Scheme. It&#8217;s hard to tell if that is the case or not, given that IE10 preview is only available for Windows 8.</p>
<p><strong>Microsoft issues aside, start using CORS!</strong></p>
<p>If you&#8217;re a developer, I strongly encourage you to evangelize for CORS at your company every opportunity you get. It&#8217;s surprisingly simple to implement, especially given how long its taken the Internet to come around to the idea that cross-domain resource sharing is ubiquitous, and not just for people with .ro email addresses hawking cheap Viagra. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2012/02/cors-worth-geeking-out-over/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>4 PETA Campaign Posters I Wish Were Real</title>
		<link>http://blog.iamnoahcooper.com/2012/01/4-peta-campaign-posters-i-wish-were-real/</link>
		<comments>http://blog.iamnoahcooper.com/2012/01/4-peta-campaign-posters-i-wish-were-real/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 02:51:11 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=190</guid>
		<description><![CDATA[You know what I miss most about working for PETA (besides hanging out with A-list celebrities like Benji Madden)? We had this tradition when we launched a new campaign where we&#8217;d get all of the staff, interns, and volunteers together in a meeting room to kick around creative ideas, from how to market the campaign [...]]]></description>
				<content:encoded><![CDATA[<p>You know what I miss most about working for PETA (besides <a target="_blank" href="http://www.peta2.com/lifestyle/ecards/peta2s-valentines-day-e-card/">hanging out with A-list celebrities like Benji Madden</a>)? We had this tradition when we launched a new campaign where we&#8217;d get all of the staff, interns, and volunteers together in a meeting room to kick around creative ideas, from how to market the campaign online to what sorts of props we should use at demonstrations. My favorite part of these brainstorming seshes was coming up with campaign taglines. For whatever reason, some of my most brilliant ideas never actually made it to print. Here are some campaign posters that I wish so hard were real. </p>
<p><strong>1) Premarin</strong></p>
<p>If you&#8217;re not a middle-aged woman, you probably have no fucking clue what a &#8220;Premarin&#8221; is. Premarin is a drug used to treat the symptoms of menopause. As if menopause wasn&#8217;t already gross enough, Premarin is made by <a target="_blank" href="http://www.peta.org/issues/animals-used-for-experimentation/Premarin-A-Prescription-for-Cruelty/Premarin--A-Prescription-for-Cruelty.aspx">strapping rubber bags to forcibly impregnated horses and collecting their urine</a>. I swear to God I&#8217;m not making this shit up &mdash; the name Premarin is in fact an acronym for PREgnant MARes&#8217; urINe. To produce this hot flash piss cocktail, Pfizer keeps horses pregnant for about 12 years straight in stalls so tiny they can&#8217;t even turn around, and deprives them of water in order to squeeze more estrogen out of them.<br />&nbsp;</p>
<p><img src="http://blog.iamnoahcooper.com/wp-content/uploads/2012/01/premarin-poster.jpg" alt="This is Premarin, Don't Let Anyone Tell You Different - PETA poster" width="493" height="373" /><br />&nbsp;</p>
<p><span id="more-190"></span></p>
<p><strong>2) Circuses</strong></p>
<p>Those assholes at Ringling must <strong><em>hate</em></strong> that PETA owns the domain name <a target="_blank" href="http://www.circuses.com">Circuses.com</a>, almost as much as Tyson and Smithfield must hate that it owns <a target="_blank" href="http://www.meat.org">Meat.org</a>. For decades now, PETA&#8217;s activists have been following Ringling&#8217;s caravan of freaks and child molesters everywhere they go, documenting how poorly animals in their care are treated. In just 19 years, at least <a target="_blank" href="http://www.ringlingbeatsanimals.com/">29 elephants have died because of Ringling&#8217;s fuckedupedness</a>, four of which were babies, one of which was an 8-month-old. 29 dead elephants in 19 years. If they were all buried on top of each other, the grave would have to be as deep as a football field.<br />&nbsp;</p>
<p><img src="http://blog.iamnoahcooper.com/wp-content/uploads/2012/01/circuses-poster.png" alt="Here's the Rest of Your Circus - PETA poster" width="494" height="323" /><br />&nbsp;</p>
<p><strong>3) POM</strong></p>
<p>Fortunately <a target="_blank" href="http://www.peta.org/b/thepetafiles/archive/2007/01/25/Victory-POM-Ends-All-Animal-Tests.aspx">PETA won it&#8217;s campaign against POM Wonderful pretty quickly</a>, because honestly, it was confusing as all hell. It was a really difficult campaign to explain to someone at a <a target="_blank" href="http://www.peta.org/b/thepetafiles/archive/2006/12/01/Giant-Rabbit-1-POM-0.aspx">demonstration</a>, largely because of the fact that what POM was doing to animals is too psychotic to believe. Basically, in order to make some pretty outlandish health claims about its bourgie juice, POM was inducing erectile dysfunction in rabbits. It&#8217;s baffling, but true. POM&#8217;s goal in conducting these Dr. Jekyll-esque experiments was to be able to tell consumers that drinking their juice will make your old man weiner stay hard. The fun part of PETA&#8217;s ultimately victorious campaign to stop these experiments was that Naked Juice, one of POM&#8217;s primary competitors, had a &#8220;no animal experiments&#8221; policy. And their company is fucking called Naked Juice. I mean, if there was ever a perfect fit for a partnership with PETA, it&#8217;s a company with the word naked in their name. I really think the straw that broke the camel&#8217;s back was that POM realized naked supermodels like Pamela Anderson make old man weiners harder than any fruity drink ever could. AND HOLY SHIT, I JUST REALIZED THAT PAMELA ANDERSON WAS A PLAYBOY BUNNY AND THE CAMPAIGN WAS ABOUT BUNNIES. In retrospect, I don&#8217;t know how this campaign lasted longer than an afternoon &#8230;<br />&nbsp;</p>
<p><img src="http://blog.iamnoahcooper.com/wp-content/uploads/2012/01/pom-poster.png" alt="Your Pomegranate Juice Had a Face - PETA poster" width="493" height="327" /><br />&nbsp;</p>
<p><strong>4) NASA</strong></p>
<p>Then NASA came along and took crazy animal experiments to a whole new, scary level. Before <a target="_blank" href="http://www.peta.org/b/thepetafiles/archive/2010/12/08/nasa-grounds-monkey-radiation-experiments.aspx">PETA came along and stopped them</a>, NASA planned to spend a few million dollars to see what would happen to monkeys if they bombarded them with high levels of radiation in a sketchy laboratory in Long Island, destroying their brains in the process. I mean, I&#8217;m not <em>really</em> a scientist per se, but I&#8217;m pretty certain that we already have a <a target="_blank" href="http://lmgtfy.com/?q=does+radiation+kill+you">pretty good idea</a> what the effects of prolonged exposure to radiation are. Like death for example. Oh, and in these experiments, which thankfully never went forward, NASA was going to be radiating squirrel monkeys, which if you don&#8217;t already know are just the cutest things since the slow loris. Seriously, Google it. Anyone who would hurt one of those adorable fuckers deserves to be put on a space shuttle aimed straight at the ground.<br />&nbsp; </p>
<p><img src="http://blog.iamnoahcooper.com/wp-content/uploads/2012/01/nasa-poster.png" alt="I'm Not a Space Shuttle - PETA poster" width="493" height="373" /><br />&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2012/01/4-peta-campaign-posters-i-wish-were-real/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>What the fuck is a &#8216;Forbe&#8217;?</title>
		<link>http://blog.iamnoahcooper.com/2011/11/what-the-fuck-is-a-forbe/</link>
		<comments>http://blog.iamnoahcooper.com/2011/11/what-the-fuck-is-a-forbe/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 01:38:27 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=246</guid>
		<description><![CDATA[Google Analytics just helped me discover that there&#8217;s a post on Forbes.com which mentions both whatthefuckisasloth.com and whatthefuckcanidoforseals.com. In an interview with Zach Golden, the mastermind behind whatthefuckshouldimakefordinner.com, Forbes contributor Jesse Thomas writes that What the Fuck Should I Make for Dinner inspired &#8230; &#8220;several knock-offs, like What the F*@# Can I Do for Seals? [...]]]></description>
				<content:encoded><![CDATA[<p>Google Analytics just helped me discover that there&#8217;s a post on <a target="_blank" href="http://www.forbes.com/sites/jessethomas/2011/09/09/why-the-f-should-we-care-what-zach-golden-wants-for-dinner/">Forbes.com</a> which mentions both whatthefuckisasloth.com and whatthefuckcanidoforseals.com. In an interview with Zach Golden, the mastermind behind <a target="_blank" href="whatthefuckshouldimakefordinner.com">whatthefuckshouldimakefordinner.com</a>, Forbes contributor <a target="_blank" href="http://jess3.com/">Jesse Thomas</a> writes that What the Fuck Should I Make for Dinner inspired &#8230;</p>
<div style="background:#f0f0f0;border:1px solid #c4c4c4;margin:16px 10px;padding:10px;-moz-box-shadow:0 0 5px #888;-webkit-box-shadow:0 0 5px#888;box-shadow:0 0 5px #888;">
<p style="font-size:1.5em;margin:0;padding:0;"><em>&#8220;several knock-offs, like What the F*@# Can I Do for Seals? and What the F*@# is a Sloth?&#8221;</em></p>
</div>
<p>This is amazing for two reasons:</p>
<p>1) Dudebro got away with saying fuck like 50 times on a website that&#8217;s usually a bunch of stuffy financial news.<br />2) Of all of the possible websites to have cited as examples, he chose two built by me.</p>
<p>Forbes joins countless other highly-reputable news sites who have name-dropped whatthefuckisasloth, including <a target="_blank" href="http://www.buzzfeed.com/expresident/what-the-fuck-is-a-sloth">BuzzFeed</a>, <a target="_blank" href="http://www.thelmagazine.com/TheMeasure/archives/2010/09/01/in-case-you-were-wondering-what-the-fuck-is-a-sloth-will-clear-everything-up">The L Magazine</a> and yes, even <a target="_blank" href="http://www.gqmagazine.fr/culture-web/la-revue-du-web-gq/diaporama/la-revue-du-web-de-gq-10/2019/image/273021">GQ</a>.</p>
<p>Now if only I could convince the even stuffier folks that monitor Wikipedia to stop <a target="_blank" href="http://en.wikipedia.org/w/index.php?title=Sloth&#038;diff=460050883&#038;oldid=460036840">reverting my edits</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2011/11/what-the-fuck-is-a-forbe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What the fuck is a sloth?</title>
		<link>http://blog.iamnoahcooper.com/2010/08/what-the-fuck-is-a-sloth/</link>
		<comments>http://blog.iamnoahcooper.com/2010/08/what-the-fuck-is-a-sloth/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 17:23:22 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=22</guid>
		<description><![CDATA[Today I got bored and I made this. It all started when I told my wife, Sarah, that she was a sloth (for no particular reason that I can remember), and we both realized that we had no idea what the fuck a sloth was. So, I figured I&#8217;d help other people who were in a [...]]]></description>
				<content:encoded><![CDATA[<p>Today I got bored and I made <a href="http://www.whatthefuckisasloth.com/">this</a>.</p>
<div style="padding-top:12px;padding-bottom:12px;"><a href="http://www.whatthefuckisasloth.com/" target="_blank"><img class="aligncenter size-full wp-image-44" title="Seriously, what the fuck IS a sloth?" src="http://blog.iamnoahcooper.com/wp-content/uploads/2010/08/wtf-sloths.jpg" alt="" width="320" height="232" /></a></div>
<p>It all started when I told my wife, Sarah, that she was a sloth (for no particular reason that I can remember), and we both realized that we had no idea what the fuck a sloth was. So, I figured I&#8217;d help other people who were in a similar situation, and thus <a href="http://www.whatthefuckisasloth.com/" target="_blank">whatthefuckisasloth.com</a> was born.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2010/08/what-the-fuck-is-a-sloth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding YouTube Videos on Secure Web Sites</title>
		<link>http://blog.iamnoahcooper.com/2009/05/embedding-youtube-videos-on-secure-web-sites/</link>
		<comments>http://blog.iamnoahcooper.com/2009/05/embedding-youtube-videos-on-secure-web-sites/#comments</comments>
		<pubDate>Fri, 22 May 2009 23:13:06 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=51</guid>
		<description><![CDATA[Currently YouTube doesn&#8217;t offer an option of embedding its videos via HTTPS, so if you try to add a video to a secure page browsers will display a security warning. If you use swfobject.js instead of the code provided by YouTube (as you should!), you&#8217;ll find the security warning goes away &#8230; in some browsers; IE is [...]]]></description>
				<content:encoded><![CDATA[<p>Currently YouTube doesn&#8217;t offer an option of embedding its videos via HTTPS, so if you try to add a video to a secure page browsers will display a security warning. If you use <a href="http://code.google.com/p/swfobject/" target="_blank">swfobject.js</a> instead of the code provided by YouTube (as you should!), you&#8217;ll find the security warning goes away &#8230; in some browsers; IE is fooled and doesn&#8217;t display a warning, while FireFox will still show its little red exclamation mark in the status bar indicating that not all elements on the page are secure:</p>
<div style="padding-top:12px;padding-bottom:12px;"><img class="aligncenter size-full wp-image-82" title="Firefox doesn't like YouTube" src="http://blog.iamnoahcooper.com/wp-content/uploads/2009/05/YTPlayer-firefox.jpg" alt="" width="320" height="19" /></div>
<p>The same issue occurs in Opera, as well as Flock and other Mozilla browsers.</p>
<p>And obviously, since swfobject is a JavaScript file, if JavaScript is disabled in the browser the only option for showing the video is a plain ol&#8217; Flash object inside <code>noscript</code> tags, and in that case the security warning is displayed for all browsers.</p>
<p>The workaround I came up with is to upload a SWF to the secure site that acts as a proxy and loads the YouTube video (since <a href="http://code.google.com/p/doctype/wiki/ArticleFlashSecurity" target="_blank">Flash has its own security model</a>, it doesn&#8217;t matter that the video is not served via HTTPS).</p>
<p><span id="more-51"></span></p>
<p>Here is an example from <a href="https://secure.peta.org/site/Advocacy?cmd=display&amp;page=UserAction&amp;id=1791" target="_blank">peta2&#8242;s &#8220;Whose Skin Are You In?&#8221;</a> Web site:</p>
<div style="padding-top:12px;padding-bottom:12px;"><a href="https://secure.peta.org/site/Advocacy?cmd=display&amp;page=UserAction&amp;id=1791" target="_blank"><img class="aligncenter size-full wp-image-84" title="Whose Skin Are You In?" src="http://blog.iamnoahcooper.com/wp-content/uploads/2009/05/whoseskin.jpg" alt="" width="320" height="288" /></a></div>
<p>I&#8217;ve posted the SWF I created to Google Code at <a title="Download YouTube SWF Proxy at Google Code" href="http://code.google.com/p/ytplayer/" target="_blank">http://code.google.com/p/ytplayer</a>.</p>
<p>Here&#8217;s the ActionScript that makes it all work:</p>
<pre>Stage.align="TL";
Stage.scaleMode="noscale";
System.security.allowDomain("http://www.youtube.com");
System.security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");

//create a MovieClip to load the player into
ytplayer=createEmptyMovieClip("ytplayer",1);

//create a listener object for the MovieClipLoader to use
ytPlayerLoaderListener={};
var loadInterval:Number;

//When the player clip first loads, we start an interval to check for when the player is ready
ytPlayerLoaderListener.onLoadInit=function(){
   loadInterval=setInterval(checkPlayerLoaded,250);
}
function checkPlayerLoaded():Void{
   //once the player is ready, we can subscribe to events
   if(ytplayer.isPlayerLoaded()){
      ytplayer.setSize(Stage.width,Stage.height);
      clearInterval(loadInterval);
   }
}

//create a MovieClipLoader to handle the loading of the player
ytPlayerLoader=new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);

//load the player
ytPlayerLoader.loadClip("http://www.youtube.com/v/"+vidId+"&amp;hl=en&amp;fs=1",ytplayer);

//adjust size when user clicks full-screen
var listener:Object=new Object();
Stage.addListener(listener);
listener.onFullScreen=respondFunction;
function respondFunction(){
   ytplayer.setSize(Stage.width,Stage.height);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2009/05/embedding-youtube-videos-on-secure-web-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Put TwitStream on Your Site!</title>
		<link>http://blog.iamnoahcooper.com/2009/04/put-twitstream-on-your-site/</link>
		<comments>http://blog.iamnoahcooper.com/2009/04/put-twitstream-on-your-site/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 16:35:25 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=24</guid>
		<description><![CDATA[I tried to find a jQuery plugin I could use with the Twitter Search API to display recent tweets containing a specific keyword or hashtag, but couldn&#8217;t really find one that fit my needs, so I made one! I call it TwitStream.]]></description>
				<content:encoded><![CDATA[<p>I tried to find a <a href="http://www.jquery.com/" target="_blank">jQuery</a> plugin I could use with the <a href="http://apiwiki.twitter.com/Search+API+Documentation" target="_blank">Twitter Search API</a> to display recent tweets containing a specific keyword or <a href="http://twitter.com/hashtags" target="_blank">hashtag</a>, but couldn&#8217;t really find one that fit my needs, so I made one!</p>
<p>I call it <a href="http://iamnoahcooper.com/TwitStream" target="_blank">TwitStream</a>.</p>
<div style="padding-top:12px;padding-bottom:12px;"><a target="_blank" href="http://iamnoahcooper.com/TwitStream"><img class="aligncenter size-full wp-image-47" title="TwitStream" src="http://blog.iamnoahcooper.com/wp-content/uploads/2009/04/example-twitstream.jpg" alt="" width="200" height="229" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2009/04/put-twitstream-on-your-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>People Who Are Not Me</title>
		<link>http://blog.iamnoahcooper.com/2008/10/people-who-are-not-me/</link>
		<comments>http://blog.iamnoahcooper.com/2008/10/people-who-are-not-me/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 12:50:36 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=26</guid>
		<description><![CDATA[I am not: 1) An Ivy league baseball player 2) An executive news director from Spokane 3) A character played by that guy from Punk&#8217;d 4) A major in some space army 5) Someone who takes pictures with fat chicks then tries to hide the evidence 6) The creator of a video blog about contemporary [...]]]></description>
				<content:encoded><![CDATA[<p>I am not:</p>
<p>1) <a href="https://admin.xosn.com/ViewArticle.dbml?DB_OEM_ID=9600&amp;ATCLID=536330" target="_blank">An Ivy league baseball player</a></p>
<p>2) <a href="http://www.newsblues.com/Secure/Source/stations.cgi?station=1493" target="_blank">An executive news director from Spokane</a></p>
<p>3) <a href="http://www.imdb.com/title/tt0867591/" target="_blank">A character played by that guy from Punk&#8217;d</a></p>
<p>4) <a href="http://www.imdb.com/title/tt0533108/" target="_blank">A major in some space army</a></p>
<p>5) <a href="http://members.aol.com/rsmplanotx/noahcooper.htm" target="_blank">Someone who takes pictures with fat chicks then tries to hide the evidence</a></p>
<p>6) <a href="http://www.tilzy.tv/help-my-patients.htm" target="_blank">The creator of a video blog about contemporary psychological overanalyzation and overmedication</a></p>
<p>7) <a href="http://www.time.com/time/magazine/article/0,9171,743928-3,00.html" target="_blank">A lawyer who wants the world to shut down on Sundays</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2008/10/people-who-are-not-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Donate to HRC in honor of Orson Scott Card</title>
		<link>http://blog.iamnoahcooper.com/2008/09/donate-to-hrc-in-honor-of-orson-scott-card/</link>
		<comments>http://blog.iamnoahcooper.com/2008/09/donate-to-hrc-in-honor-of-orson-scott-card/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 06:48:33 +0000</pubDate>
		<dc:creator>noah.cooper</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.iamnoahcooper.com/?p=28</guid>
		<description><![CDATA[Inspired by the recent flood of donations to Planned Parenthood in honor of Sarah Palin, I&#8217;d like to call on rational human beings who believe in consenting adults&#8217; right to marry regardless of their gender to donate to the Human Rights Campaign in honor of Orson Scott Card. Hang on, I&#8217;ll explain &#8230; It turns out that [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.ornery.org/essays/warwatch/2004-02-15-1.html" target="_blank"><img class="alignright size-full wp-image-38" title="Orson Scott Card" src="http://blog.iamnoahcooper.com/wp-content/uploads/2008/09/180px-Orson.scott_.card_.jpg" alt="" width="171" height="200" /></a>Inspired by the recent <a href="http://www.huffingtonpost.com/craig-newmark/donate-to-planned-parenth_b_127343.html" target="_blank">flood of donations to Planned Parenthood in honor of Sarah Palin</a>, I&#8217;d like to call on rational human beings who believe in consenting adults&#8217; right to marry regardless of their gender to <a href="http://www.hrcactioncenter.org/site/Donation2?df_id=10742" target="_blank">donate to the Human Rights Campaign in honor of Orson Scott Card</a>. Hang on, I&#8217;ll explain &#8230;</p>
<p>It turns out that the fella who wrote <em>Ender&#8217;s Game</em>—one of my favorite books in my early teen years—is quite a bigot. Like, <a href="http://www.ornery.org/essays/warwatch/2004-02-15-1.html" target="_blank">a really really crazy bigot</a>.</p>
<p>Here&#8217;s what OSC thinks about legalizing marriage for all Americans:</p>
<blockquote><p>&#8220;Regardless of law, marriage has only one definition, and any government that attempts to change it is my mortal enemy. I will act to destroy that government and bring it down, so it can be replaced with a government that will respect and support marriage, and help me raise my children in a society where they will expect to marry in their turn. Only when the marriage of heterosexuals has the support of the whole society can we have our best hope of raising each new generation to aspire to continue our civilization&#8230;</p></blockquote>
<p><span id="more-28"></span></p>
<blockquote><p>In the first place, no law in any state in the United States now or ever has forbidden homosexuals to marry. Any homosexual man who can persuade a woman to take him as her husband can avail himself of all the rights of husbandhood under the law. Ditto with lesbian women. To get those civil rights, all homosexuals have to do is find someone of the opposite sex willing to join them in marriage.</p>
<p>However emotionally bonded a pair of homosexual lovers may feel themselves to be, what they are doing is not marriage. they are not turning their relationship into what my wife and I have created, because no court has the power to change what their relationship actually is. They steal from me what I treasure most, and gain for themselves nothing at all. They won&#8217;t be married. They&#8217;ll just be playing dress-up in their parents&#8217; clothes.</p>
<p>Homosexual &#8216;marriage&#8217; won&#8217;t accomplish what they hope. They will still be just as far outside the reproductive cycle of life. And they will have inflicted real damage on those of us who are inside it. they will make it harder for us to raise children with any confidence that they, in turn, will take their place in the reproductive cycle.&#8221;</p></blockquote>
<p>Insane much?</p>
<p>So, join me in stickin&#8217; it to Mr. Card. Go to <a href="http://www.hrcactioncenter.org/site/Donation2?df_id=10742" target="_blank">http://www.hrcactioncenter.org/site/Donation2?df_id=10742</a> to make as generous a donation as you can afford and show your support for equal rights regardless of gender or sexual orientation. After you&#8217;re done, be sure to let ol&#8217; Orson know you donated on his behalf:</p>
<p><strong>Orson Scott Card</strong><br />
<strong>P.O. Box 18184</strong><br />
<strong> Greensboro, NC 27419</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iamnoahcooper.com/2008/09/donate-to-hrc-in-honor-of-orson-scott-card/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
