<?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>everburning &#187; Screencasts</title>
	<atom:link href="http://everburning.com/news/category/screencasts/feed/" rel="self" type="application/rss+xml" />
	<link>http://everburning.com</link>
	<description>picking at the fringes of reality</description>
	<lastBuildDate>Wed, 04 Jan 2012 18:42:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>EventMachine Screencast &#8212; EM-HTTP-Request</title>
		<link>http://everburning.com/news/eventmachine-screencast-em-http-request/</link>
		<comments>http://everburning.com/news/eventmachine-screencast-em-http-request/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 00:52:42 +0000</pubDate>
		<dc:creator>dj2</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Screencasts]]></category>
		<category><![CDATA[em-http-request]]></category>
		<category><![CDATA[EventMachine]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://everburning.com/?p=606</guid>
		<description><![CDATA[<p><img src="http://everburning.com/wp-content/uploads/2009/07/IMG_6037-300x200.jpg" alt="IMG_6037" title="IMG_6037" width="300" height="200" class="alignleft size-medium wp-image-608" />I decided to try my hand at creating a screencast the other day. I took a look at the EventMachine EM-HTTP-Request library and created a simple shell program to do single and multi requests. Take a look and let me know what you think.</p>
<ul>
<li><a href='http://everburning.com/wp-content/uploads/2009/07/eventmachine-em_http_request-screencast_1.m4v' >EventMachine Screencast &#8212; EM-HTTP-Request</a></li>
</ul>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw3">require</span> <span class="st0">&#8216;rubygems&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;eventmachine&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;em-http&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;pp&#8217;</span></p>
<p><span class="re0">$stdout</span>.<span class="me1">sync</span> = <span class="kw2">true</span></p>
<p><span class="kw1">class</span> KeyboardHandler &lt; <span class="re2">EM::Connection</span><br />
&nbsp; <span class="kw1">include</span> <span class="re2">EM::Protocols::LineText2</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">def</span> post_init<br />
&nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; <span class="kw1">end</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">def</span> receive_line<span class="br0">&#40;</span>line<span class="br0">&#41;</span><br />
&nbsp; &nbsp; line.<span class="kw3">chomp</span>!<br />
&nbsp; &nbsp; line.<span class="kw3">gsub</span>!<span class="br0">&#40;</span>/^\s+/, <span class="st0">&#8221;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span><span class="br0">&#40;</span>line<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="kw1">when</span> /^get <span class="br0">&#40;</span>.<span class="me1">*</span><span class="br0">&#41;</span>$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; site = $<span class="nu0">1</span>.<span class="kw3">chomp</span><br />
&nbsp; &nbsp; &nbsp; sites = site.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&#8216;,&#8217;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; multi = <span class="re2">EM::MultiRequest</span>.<span class="me1">new</span><br />
&nbsp; &nbsp; &nbsp; sites.<span class="me1">each</span> <span class="kw1">do</span> |s|<br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">add</span><span class="br0">&#40;</span><span class="re2">EM::HttpRequest</span>.<span class="me1">new</span><span class="br0">&#40;</span>s<span class="br0">&#41;</span>.<span class="me1">get</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; multi.<span class="me1">callback</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">responses</span><span class="br0">&#91;</span><span class="re3">:succeeded</span><span class="br0">&#93;</span>.<span class="me1">each</span> <span class="kw1">do</span> |h|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pp h.<span class="me1">response_header</span>.<span class="me1">status</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pp h.<span class="me1">response_header</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">responses</span><span class="br0">&#91;</span><span class="re3">:failed</span><span class="br0">&#93;</span>.<span class="me1">each</span> <span class="kw1">do</span> |h|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;#{h.inspect} failed&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">when</span> /^exit$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; EM.<span class="me1">stop</span></p>
<p>&nbsp; &nbsp; <span class="kw1">when</span> /^help$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;get URL[,URL]* &nbsp; &#8211; gets a URL&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;exit &nbsp; &nbsp; &nbsp;- exits the app&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;help &nbsp; &nbsp; &nbsp;- this help&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span></p>
<p>EM::run <span class="br0">&#123;</span><br />
&nbsp; EM.<span class="me1">open_keyboard</span><span class="br0">&#40;</span>KeyboardHandler<span class="br0">&#41;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw3">puts</span> <span class="st0">&quot;Finished&quot;</span></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></description>
			<content:encoded><![CDATA[<p><img src="http://everburning.com/wp-content/uploads/2009/07/IMG_6037-300x200.jpg" alt="IMG_6037" title="IMG_6037" width="300" height="200" class="alignleft size-medium wp-image-608" />I decided to try my hand at creating a screencast the other day. I took a look at the EventMachine EM-HTTP-Request library and created a simple shell program to do single and multi requests. Take a look and let me know what you think.</p>
<ul>
<li><a href='http://everburning.com/wp-content/uploads/2009/07/eventmachine-em_http_request-screencast_1.m4v' >EventMachine Screencast &#8212; EM-HTTP-Request</a></li>
</ul>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw3">require</span> <span class="st0">&#8216;rubygems&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;eventmachine&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;em-http&#8217;</span><br />
<span class="kw3">require</span> <span class="st0">&#8216;pp&#8217;</span></p>
<p><span class="re0">$stdout</span>.<span class="me1">sync</span> = <span class="kw2">true</span></p>
<p><span class="kw1">class</span> KeyboardHandler &lt; <span class="re2">EM::Connection</span><br />
&nbsp; <span class="kw1">include</span> <span class="re2">EM::Protocols::LineText2</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">def</span> post_init<br />
&nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; <span class="kw1">end</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">def</span> receive_line<span class="br0">&#40;</span>line<span class="br0">&#41;</span><br />
&nbsp; &nbsp; line.<span class="kw3">chomp</span>!<br />
&nbsp; &nbsp; line.<span class="kw3">gsub</span>!<span class="br0">&#40;</span>/^\s+/, <span class="st0">&#8221;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span><span class="br0">&#40;</span>line<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="kw1">when</span> /^get <span class="br0">&#40;</span>.<span class="me1">*</span><span class="br0">&#41;</span>$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; site = $<span class="nu0">1</span>.<span class="kw3">chomp</span><br />
&nbsp; &nbsp; &nbsp; sites = site.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&#8216;,&#8217;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; multi = <span class="re2">EM::MultiRequest</span>.<span class="me1">new</span><br />
&nbsp; &nbsp; &nbsp; sites.<span class="me1">each</span> <span class="kw1">do</span> |s|<br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">add</span><span class="br0">&#40;</span><span class="re2">EM::HttpRequest</span>.<span class="me1">new</span><span class="br0">&#40;</span>s<span class="br0">&#41;</span>.<span class="me1">get</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; multi.<span class="me1">callback</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">responses</span><span class="br0">&#91;</span><span class="re3">:succeeded</span><span class="br0">&#93;</span>.<span class="me1">each</span> <span class="kw1">do</span> |h|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pp h.<span class="me1">response_header</span>.<span class="me1">status</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pp h.<span class="me1">response_header</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; multi.<span class="me1">responses</span><span class="br0">&#91;</span><span class="re3">:failed</span><span class="br0">&#93;</span>.<span class="me1">each</span> <span class="kw1">do</span> |h|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;#{h.inspect} failed&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">when</span> /^exit$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; EM.<span class="me1">stop</span></p>
<p>&nbsp; &nbsp; <span class="kw1">when</span> /^help$/ <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;get URL[,URL]* &nbsp; &#8211; gets a URL&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;exit &nbsp; &nbsp; &nbsp;- exits the app&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">puts</span> <span class="st0">&quot;help &nbsp; &nbsp; &nbsp;- this help&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw3">print</span> <span class="st0">&quot;&gt; &quot;</span><br />
&nbsp; &nbsp; <span class="kw1">end</span><br />
&nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span></p>
<p>EM::run <span class="br0">&#123;</span><br />
&nbsp; EM.<span class="me1">open_keyboard</span><span class="br0">&#40;</span>KeyboardHandler<span class="br0">&#41;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw3">puts</span> <span class="st0">&quot;Finished&quot;</span></div>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feverburning.com%2Fnews%2Feventmachine-screencast-em-http-request%2F&amp;title=EventMachine+Screencast+%26%238212%3B+EM-HTTP-Request" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://everburning.com/news/eventmachine-screencast-em-http-request/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://everburning.com/wp-content/uploads/2009/07/eventmachine-em_http_request-screencast_1.m4v" length="22405958" type="video/x-m4v" />
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.238 seconds -->

