<?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>Darian Shimy</title>
	<atom:link href="http://www.darianshimy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.darianshimy.com</link>
	<description></description>
	<lastBuildDate>Sat, 01 Oct 2011 06:06:15 +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>WebSockets that Reconnect</title>
		<link>http://www.darianshimy.com/2011/09/websockets-that-reconnect/</link>
		<comments>http://www.darianshimy.com/2011/09/websockets-that-reconnect/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 06:06:15 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[websocket]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=569</guid>
		<description><![CDATA[Here is a JavaScript sample of a WebSocket that will try to reconnect every second if the connection is lost to the server. This is completely transparent to the end-user. function WS&#40;&#41; &#123; var _self = this; this.start = function&#40;&#41; &#8230; <a href="http://www.darianshimy.com/2011/09/websockets-that-reconnect/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a JavaScript sample of a WebSocket that will try to reconnect every second if the connection is lost to the server.  This is completely transparent to the end-user.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> WS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> _self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">start</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> ws<span style="color: #339933;">;</span>
    ws <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> WebSocket<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ws://example.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					
    ws.<span style="color: #660066;">onmessage</span> <span style="color: #339933;">=</span> <span style="color: #003366; 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: #006600; font-style: italic;">// Do something</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ws.<span style="color: #660066;">onclose</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      clearTimeout<span style="color: #009900;">&#40;</span>_self.<span style="color: #660066;">refresh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setTimeout<span style="color: #009900;">&#40;</span>_self.<span style="color: #660066;">start</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>            
  <span style="color: #009900;">&#125;</span>
  _self.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #003366; font-weight: bold;">new</span> WS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/09/websockets-that-reconnect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passenger and ruby-oci8 (Oracle)</title>
		<link>http://www.darianshimy.com/2011/09/passenger-and-ruby-oci8-oracle/</link>
		<comments>http://www.darianshimy.com/2011/09/passenger-and-ruby-oci8-oracle/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 05:06:22 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ruby-oci8]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=558</guid>
		<description><![CDATA[Oracle is going to drive a man to drink.  After getting our rake migrations to run with this solution, our application had issues.  We run our Rails app in Passenger + Apache2.  After we deployed, we got this error: ERROR: &#8230; <a href="http://www.darianshimy.com/2011/09/passenger-and-ruby-oci8-oracle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oracle is going to drive a man to drink.  After getting our rake migrations to run with <a href="http://www.darianshimy.com/2011/09/ruby-oci8-library-problems/">this solution</a>, our application had issues.  We run our Rails app in Passenger + Apache2.  After we deployed, we got this error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 gem.</pre></div></div>

<p>As it turns out, Passenger does not pick up the LD_LIBRARY_PATH and the only way I&#8217;m aware of set it is to create a wrapper for the ruby binary.  To fix this, create the file /usr/local/bin/passenger-ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#!/bin/sh
&nbsp;
export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2
exec &quot;/usr/bin/ruby&quot; &quot;$@&quot;</pre></div></div>

<p>Then update passenger.conf and change PassengerRuby to:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">PassengerRuby /usr/local/bin/passenger-ruby</pre></div></div>

<p>Don&#8217;t forget to restart Apache. Good luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/09/passenger-and-ruby-oci8-oracle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RabbitMQ on OS X via MacPorts</title>
		<link>http://www.darianshimy.com/2011/09/rabbitmq-on-os-x-via-macports/</link>
		<comments>http://www.darianshimy.com/2011/09/rabbitmq-on-os-x-via-macports/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 16:05:53 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[rabbitmq]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=553</guid>
		<description><![CDATA[MacPorts installs an old version of RabbitMQ. To get the latest, you need to add the RabbitMQ repository as described here: http://www.rabbitmq.com/macports.html However, when you try and install it, it throws the following error: $ sudo port install rabbitmq-server Error: &#8230; <a href="http://www.darianshimy.com/2011/09/rabbitmq-on-os-x-via-macports/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>MacPorts installs an old version of RabbitMQ. To get the latest, you need to add the RabbitMQ repository as described here:</p>
<p><a href="http://www.rabbitmq.com/macports.html">http://www.rabbitmq.com/macports.html</a></p>
<p>However, when you try and install it, it throws the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ sudo port install rabbitmq-server
Error: Unable to open port: tar: +CONTENTS: Not found in archive
tar: Error exit delayed from previous errors.
To report a bug, see</pre></div></div>

<p>As it turns out, there is a bug in MacPorts 2.0.1.</p>
<p><a href="http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-September/014855.html">http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-September/014855.html</a></p>
<p>Upgrading to 2.0.3 resolved it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/09/rabbitmq-on-os-x-via-macports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby-oci8 library problems</title>
		<link>http://www.darianshimy.com/2011/09/ruby-oci8-library-problems/</link>
		<comments>http://www.darianshimy.com/2011/09/ruby-oci8-library-problems/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 03:25:52 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Everything Else]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=550</guid>
		<description><![CDATA[We started using Oracle with a Ruby on Rails 2.3.x project. I will say, it has been nothing but a pain. After getting the Oracle Instant Client installed and the ruby-oci library compiled, I kept hitting this error during the &#8230; <a href="http://www.darianshimy.com/2011/09/ruby-oci8-library-problems/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We started using Oracle with a Ruby on Rails 2.3.x project. I will say, it has been nothing but a pain. After getting the Oracle Instant Client installed and the ruby-oci library compiled, I kept hitting this error during the deployment (BTW: this was on Ubuntu 10.04):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 gem.</pre></div></div>

<p>But it was installed. Testing from irb:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">irb(main):001:0&amp;gt; require 'rubygems'
=&amp;gt; true
irb(main):002:0&amp;gt; require 'oci8'
LoadError: libaio.so.1: cannot open shared object file: No such file or directory - /usr/lib/ruby/gems/1.8/gems/ruby-oci8-2.0.6/lib/oci8lib_18.so
	from /usr/lib/ruby/gems/1.8/gems/ruby-oci8-2.0.6/lib/oci8lib_18.so
	from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib/ruby/gems/1.8/gems/ruby-oci8-2.0.6/lib/oci8.rb:38
	from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
	from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from (irb):2
	from :0</pre></div></div>

<p>After some snooping around, I found the libaio library missing. Sigh.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ apt-get install libaio-dev</pre></div></div>

<p>Now it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/09/ruby-oci8-library-problems/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hot Potato &#8211; A Real-time Processing Framework</title>
		<link>http://www.darianshimy.com/2011/07/hot-potato/</link>
		<comments>http://www.darianshimy.com/2011/07/hot-potato/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 16:00:22 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[hotpotato]]></category>
		<category><![CDATA[realtime]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=536</guid>
		<description><![CDATA[Today, I am happy to announce the availability of HotPotato.  Hot Potato is an open source real-time processing framework written in Ruby. Originally designed to process the Twitter firehose at 3,000+ tweets per second, it has been extended to support &#8230; <a href="http://www.darianshimy.com/2011/07/hot-potato/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today, I am happy to announce the availability of HotPotato.  Hot Potato is an open source real-time processing framework written in Ruby. Originally designed to process the Twitter firehose at 3,000+ tweets per second, it has been extended to support any type of streaming data as input or output to the framework. The framework excels with applications such as, social media analysis, log processing, fraud prevention, spam detection, instant messaging, and many others that include the processing of streaming data.</p>
<p>Related Links:</p>
<ul>
<li>GitHub Repository: <a href="http://github.com/dshimy/HotPotato">http://github.com/dshimy/HotPotato</a></li>
<li>Google Group: <a href="http://groups.google.com/group/hotpotato-rb">http://groups.google.com/group/hotpotato-rb</a></li>
<li>Presentation: <a href="http://www.slideshare.net/dshimy/hot-potato-8704624">http://www.slideshare.net/dshimy/hot-potato-8704624</a></li>
<li>My Profile: <a href="http://profiles.google.com/dshimy">http://profiles.google.com/dshimy</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/07/hot-potato/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Signal Handling</title>
		<link>http://www.darianshimy.com/2011/04/signal-handling/</link>
		<comments>http://www.darianshimy.com/2011/04/signal-handling/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 04:33:46 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=486</guid>
		<description><![CDATA[A signal is a way to notify a process of an event from another process. A signal handler allows one execute code when a signal is received. For example, the most common signal sent from the command-line is SIGINT via &#8230; <a href="http://www.darianshimy.com/2011/04/signal-handling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A signal is a way to notify a process of an event from another process. A signal handler allows one execute code when a signal is received. For example, the most common signal sent from the command-line is SIGINT via CTRL-C. The default behavior is to terminate the application. We can change that to print diagnostic information:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'INT'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'DEBUG: ...'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC0066; font-weight:bold;">sleep</span> <span style="color:#006666;">60</span></pre></div></div>

<p>Start the above program and press CTRL-C or kill -2 pid. You can optionally add an exit statement to the code block as well to exit.</p>
<p><strong>Why do I care?</strong></p>
<p>If you just write Rails apps then you probably won’t, however if you write a daemon or long running process, there is a good chance you’ll want to handle the signal appropriately. For example, I had a long running perfomance test script and didn’t want to loose the data if I decided to stop the process. In this case (similar to the example), I had the application print the progress to STDOUT before exiting.</p>
<p><strong>References:</strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Signal_(computing)">http://en.wikipedia.org/wiki/Signal_(computing)</a></li>
<li><a href="http://www.ruby-doc.org/core/classes/Signal.html">http://www.ruby-doc.org/core/classes/Signal.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/04/signal-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EventMachine Process Control</title>
		<link>http://www.darianshimy.com/2011/03/eventmachine-process-control/</link>
		<comments>http://www.darianshimy.com/2011/03/eventmachine-process-control/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 16:26:58 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[daemons]]></category>
		<category><![CDATA[eventmachine]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=507</guid>
		<description><![CDATA[A while ago I wrote a pilot project for a real-time twitter analysis tool using eventmachine and websockets. It worked perfectly, but there were questions how to deploy it to production. Specifically, how to handle process management, logging, configuration, deployment, &#8230; <a href="http://www.darianshimy.com/2011/03/eventmachine-process-control/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote a pilot project for a real-time twitter analysis tool using <a href="http://rubyeventmachine.com/">eventmachine</a> and <a href="https://github.com/igrigorik/em-websocket">websockets</a>.  It worked perfectly, but there were questions how to deploy it to production.  Specifically, how to handle process management, logging, configuration, deployment, and monitoring.  This post describes how I handled process management.</p>
<p>Process management is a facility to support starting and stopping of long running processes as well as inquire if a process is running.  Generally, only one instance of the process should be running, so support for checking for a running process is needed.</p>
<p>Starting and stopping the process can easily be handled by the <a href="http://daemons.rubyforge.org/">Daemons Gem</a>.  From their webpage: &#8220;Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands.&#8221;</p>
<p>In the code example below, we wrap our <code>websocket.rb</code> file located in the <code>./lib/websockets</code> directory.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
APP_ROOT = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">expand_path</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/..'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
APP_ENV =  ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;APP_ENV&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">&quot;development&quot;</span>
<span style="color:#ff6633; font-weight:bold;">$LOAD_PATH</span>.<span style="color:#9900CC;">unshift</span><span style="color:#006600; font-weight:bold;">&#40;</span>APP_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/lib'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#ff6633; font-weight:bold;">$LOAD_PATH</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>APP_ROOT <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/lib'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'daemons'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'websockets'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> stop_and_exit
  <span style="color:#008000; font-style:italic;"># Do something useful here....</span>
  <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">0</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'INT'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> stop_and_exit <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'TERM'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span> stop_and_exit <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
options = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:app_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Websocket'</span>,
  <span style="color:#ff3333; font-weight:bold;">:multiple</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>,
  <span style="color:#ff3333; font-weight:bold;">:log_output</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
  <span style="color:#ff3333; font-weight:bold;">:dir_mode</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:normal</span>,
  <span style="color:#ff3333; font-weight:bold;">:dir</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>APP_ROOT, <span style="color:#996600;">'log'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
Daemons.<span style="color:#9900CC;">run</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>APP_ROOT, <span style="color:#996600;">'lib'</span>, <span style="color:#996600;">'websockets'</span>, <span style="color:#996600;">'websocket.rb'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, options<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Running <code>./websocket -h</code> yields:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">websocket -h
Usage: Websocket &lt;command&gt; &lt;options&gt; -- &lt;application options&gt;
&nbsp;
* where &lt;command&gt; is one of:
  start         start an instance of the application
  stop          stop all instances of the application
  restart       stop all instances and restart them afterwards
  reload        send a SIGHUP to all instances of the application
  run           start the application and stay on top
  zap           set the application to a stopped state
  status        show status (PID) of application instances
&nbsp;
* and where &lt;options&gt; may contain several of the following:
&nbsp;
    -t, --ontop                      Stay on top (does not daemonize)
    -f, --force                      Force operation
    -n, --no_wait                    Do not wait for processes to stop
&nbsp;
Common options:
    -h, --help                       Show this message
        --version                    Show version</pre></div></div>

<h2>References</h2>
<ul>
<li><a href="http://daemons.rubyforge.org/">http://daemons.rubyforge.org/</a></li>
<li><a href="http://rubyeventmachine.com/">http://rubyeventmachine.com/</a></li>
<li><a href="https://github.com/igrigorik/em-websocket">https://github.com/igrigorik/em-websocket</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/03/eventmachine-process-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Efficient Real-Time Memory De-duplication</title>
		<link>http://www.darianshimy.com/2011/02/efficient-real-time-memory-de-duplication/</link>
		<comments>http://www.darianshimy.com/2011/02/efficient-real-time-memory-de-duplication/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 06:33:31 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[realtime]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=497</guid>
		<description><![CDATA[De-duplication is the process of removing duplicates from a collection. Hashes and bloom filters are common tools to use when implementing de-duplication, however, there are times when these are not fast enough. It is fairly simple to implement a memory &#8230; <a href="http://www.darianshimy.com/2011/02/efficient-real-time-memory-de-duplication/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>De-duplication is the process of removing duplicates from a collection.  Hashes and bloom filters are common tools to use when implementing de-duplication, however, there are times when these are not fast enough.  It is fairly simple to implement a memory efficient real-time de-duplication system using two hashes.  The secret is in adding the objects to both hashes and every n objects (or time-based) making the current hash become the next and clearing the current once the number of objects reaches a certain threshold.  </p>
<p>This is easier explained by a simple reference implementation in Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># A memory efficient deduplication class used in cases where a</span>
<span style="color:#008000; font-style:italic;"># duplicate object can only occur within n objects of each other.</span>
<span style="color:#9966CC; font-weight:bold;">class</span> MemoryDedup
&nbsp;
  <span style="color:#008000; font-style:italic;"># Returns a new deduper.</span>
  <span style="color:#008000; font-style:italic;">#</span>
  <span style="color:#008000; font-style:italic;"># == Options</span>
  <span style="color:#008000; font-style:italic;"># * &lt;tt&gt;:size&lt;/tt&gt; - the number of objects to store in the cache</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@size</span> = options<span style="color:#006600; font-weight:bold;">&#123;</span>:size<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">1000</span>
    <span style="color:#0066ff; font-weight:bold;">@current</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    @<span style="color:#9966CC; font-weight:bold;">next</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Returns true if the object has been seen in the past :size unique</span>
  <span style="color:#008000; font-style:italic;"># objects, false otherwise.</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> exists?<span style="color:#006600; font-weight:bold;">&#40;</span>obj<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#0066ff; font-weight:bold;">@current</span>.<span style="color:#9900CC;">size</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#0066ff; font-weight:bold;">@size</span>
      <span style="color:#0066ff; font-weight:bold;">@current</span> = @<span style="color:#9966CC; font-weight:bold;">next</span>
      @<span style="color:#9966CC; font-weight:bold;">next</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    @<span style="color:#9966CC; font-weight:bold;">next</span><span style="color:#006600; font-weight:bold;">&#91;</span>obj<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@current</span>.<span style="color:#9900CC;">has_key</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>obj<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0066ff; font-weight:bold;">@current</span><span style="color:#006600; font-weight:bold;">&#91;</span>obj<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/02/efficient-real-time-memory-de-duplication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sinaglo &#8211; A Sinatra-based Blog backed by MongoDB</title>
		<link>http://www.darianshimy.com/2011/01/sinaglo-a-sinatra-based-blog-backed-by-mongodb/</link>
		<comments>http://www.darianshimy.com/2011/01/sinaglo-a-sinatra-based-blog-backed-by-mongodb/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 00:59:17 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=503</guid>
		<description><![CDATA[I will say, I love the simplicity of Sinatra and MongoDB and Sinaglo is a great way to demonstrate Sinatra and MongoDB working together for a semi-useful application. Sinaglo is everything you need and nothing you don&#8217;t. This started out as a project &#8230; <a href="http://www.darianshimy.com/2011/01/sinaglo-a-sinatra-based-blog-backed-by-mongodb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I will say, I love the simplicity of <a href="http://www.sinatrarb.com/">Sinatra</a> and <a href="http://www.mongodb.org">MongoDB</a> and <a href="https://github.com/dshimy/sinaglo">Sinaglo</a> is a great way to demonstrate Sinatra and MongoDB working together for a semi-useful application.</p>
<p>Sinaglo is everything you need and nothing you don&#8217;t.  This started out as a project to learn more about Sinatra and turned out to be a useful blog software.  No, it does not do what WordPress does, but it does everything I needed it to do.  If anything, this should be a good starting point for a Sinatra based application.  Find it here:</p>
<p><a href="https://github.com/dshimy/sinaglo">https://github.com/dshimy/sinaglo</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2011/01/sinaglo-a-sinatra-based-blog-backed-by-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.3.8 Deprecation Warning</title>
		<link>http://www.darianshimy.com/2010/05/rails-2-3-8-deprecation-warning/</link>
		<comments>http://www.darianshimy.com/2010/05/rails-2-3-8-deprecation-warning/#comments</comments>
		<pubDate>Tue, 25 May 2010 23:00:34 +0000</pubDate>
		<dc:creator>Darian Shimy</dc:creator>
				<category><![CDATA[Everything Else]]></category>

		<guid isPermaLink="false">http://www.darianshimy.com/?p=476</guid>
		<description><![CDATA[If you happen to come across the following deprecation warning: DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. &#40;called from new at /Users/dshimy/.rvm/gems/ruby-1.8.7-p249/gems/actionpack-2.3.8/lib/action_controller/middleware_stack.rb:72&#41; Take a look at your config/environment.rb file for the following: config.action_controller.session = &#123; &#8230; <a href="http://www.darianshimy.com/2010/05/rails-2-3-8-deprecation-warning/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you happen to come across the following deprecation warning:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. <span style="color: #7a0874; font-weight: bold;">&#40;</span>called from new at <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>dshimy<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.8.7-p249<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>actionpack-2.3.8<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>action_controller<span style="color: #000000; font-weight: bold;">/</span>middleware_stack.rb:<span style="color: #000000;">72</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Take a look at your config/environment.rb file for the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#ff3333; font-weight:bold;">:secret_key</span>    <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'_sample_session'</span>,
    <span style="color:#ff3333; font-weight:bold;">:secret</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'00000000000000000000'</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>and change it to:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#ff3333; font-weight:bold;">:key</span>    <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'_sample_session'</span>,
    <span style="color:#ff3333; font-weight:bold;">:secret</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'00000000000000000000'</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.darianshimy.com/2010/05/rails-2-3-8-deprecation-warning/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

