<?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>Refactored scope &#187; howto</title>
	<atom:link href="http://ominian.com/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://ominian.com</link>
	<description>PyMethius project notes</description>
	<lastBuildDate>Sun, 06 May 2012 05:03:04 +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>SSH SOCKS proxy and Amazon EC2 to the rescue</title>
		<link>http://ominian.com/2011/10/14/ssh-socks-proxy-and-amazon-ec2-to-the-rescue/</link>
		<comments>http://ominian.com/2011/10/14/ssh-socks-proxy-and-amazon-ec2-to-the-rescue/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 22:36:14 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[amazon-ec2]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ec2 proxy ssh]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=159</guid>
		<description><![CDATA[I&#8217;m currently somewhere in the process of building a hadoop clouster in EC2 for one of my clients and one of the most important parts for keeping my sanity is the ability to access all of the node&#8217;s web interfaces ( jobtracker, namenode, tasktrackers&#8217;, datanodes, etc ). If you aren&#8217;t abs(crazy) all of these machines <a href='http://ominian.com/2011/10/14/ssh-socks-proxy-and-amazon-ec2-to-the-rescue/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently somewhere in the process of building a hadoop clouster in EC2 for one of my clients and one of the most important parts for keeping my sanity is the ability to access all of the node&#8217;s web interfaces ( jobtracker, namenode, tasktrackers&#8217;, datanodes, etc ).  If you aren&#8217;t abs(crazy) all of these machines are jailed inside a locked down security group, a micro walled garden.</p>
<p>SSH -D 8080 someMachine.amazon-publicDNS.com</p>
<p>That will setup a socks between your machine and some instance that should be in the same SG as the hadoop cluster&#8230; now unless you are a saddist and like to write dozens of host file entries, the SOCKS proxy is useless.</p>
<p>But wait!  Proxy Auto-configuration to the rescue! All you really need to get started is here at Wikipedia ( http://en.wikipedia.org/wiki/Proxy_auto-config ) but to be fair a dirt simple proxy might look like:</p>
<caption>hadoop_cluster.pac</caption>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> FindProxyForURL<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> host<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>shExpMatch<span style="color: #009900;">&#40;</span>host<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;*.secret.squirrel.com&quot;</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;">return</span> <span style="color: #3366CC;">&quot;SOCKS5 127.0.0.1:8080&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>shExpMatch<span style="color: #009900;">&#40;</span>host<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;*.internal&quot;</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;">return</span> <span style="color: #3366CC;">&quot;SOCKS5 127.0.0.1:8080&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;DIRECT&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Save this to your harddrive then find the correct &#8220;file:///path/2/hadoop_cluster.pac&#8221;  from there go into your browsers proxy configuration dialog window and paste that URL into the Proxy Auto-configuration box.  After that, going to http://ip-1-2-3-4.amazon.internal in a web browser will automatically go through the SSH proxy into Amazon EC2 cloud space, resolve against Amazon DNS servers, and voila you&#8217;re connected.</p>
<h1>NOTE: Windows users</h1>
<p>It shouldn&#8217;t be a surprise that Microsoft has partially fucked up the beauty that is the PAC.   Fortunately, they provide directions for resolving the issue here ( http://support.microsoft.com/kb/271361 ).</p>
<p>tl;dwrite &#8211; Microsoft&#8217;s network stack caches the results of the PAC script instead of checking it for every request.  If your proxy goes down or you edit the PAC file, those changes can take sometime to actually come into play.  Fortunately Firefox has a nifty &#8220;reload&#8221; button on their dialog box, but Microsoft Internet Explorer and the default Chrome for windows trust Microsofts netstack.</p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/10/14/ssh-socks-proxy-and-amazon-ec2-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Canvas windowing proof of concept/prototype</title>
		<link>http://ominian.com/2011/09/24/html5-canvas-windowing-proof-of-conceptprototype/</link>
		<comments>http://ominian.com/2011/09/24/html5-canvas-windowing-proof-of-conceptprototype/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 12:22:50 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[canvas]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=149</guid>
		<description><![CDATA[Code is here ( https://gist.github.com/a17216d5b1db068ab41b ) Taking a break from a client project today and decided to try something real quick out. For one of my unpublished pet projects ( a near real time web based MUD ) I wanted a little map window to give visual feedback to the user on where exactly they <a href='http://ominian.com/2011/09/24/html5-canvas-windowing-proof-of-conceptprototype/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Code is here ( <a href="https://gist.github.com/a17216d5b1db068ab41b">https://gist.github.com/a17216d5b1db068ab41b</a> ) </p>
<p>Taking a break from a client project today and decided to try something real quick out.   For one of my unpublished pet projects ( a near real time web based MUD ) I wanted a little map window to give visual feedback to the user on where exactly they were.  Fortunately the Canvas API makes this stupid easy.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">       <span style="color: #003366; font-weight: bold;">var</span> oX <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">player</span>.<span style="color: #660066;">x</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">mMX</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rMX</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> oY <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">player</span>.<span style="color: #660066;">y</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">mMX</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rMY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> halfX <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">wMX</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: #003366; font-weight: bold;">var</span> halfY <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">wMY</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> startX <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> oX <span style="color: #339933;">-</span> halfX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> startY <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> oY <span style="color: #339933;">-</span> halfY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> endX <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>startX <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">wMX</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> endY <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>startY <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">wMY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> buffer <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ctx</span>.<span style="color: #660066;">getImageData</span><span style="color: #009900;">&#40;</span>startX<span style="color: #339933;">,</span> startY<span style="color: #339933;">,</span> endX<span style="color: #339933;">,</span> endY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">window</span>.<span style="color: #660066;">putImageData</span><span style="color: #009900;">&#40;</span>buffer<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>First block takes the player or avatars position then scales up their grid position to the map canvas position.  </p>
<p>Second block gets middle point of the window canvas, in this case if the window is 150&#215;150, the origin is (75,75)</p>
<p>Now given the player&#8217;s position in the canvas map it finds the upper left and lower right corners of the map that is going to be copied from the map canvas into the window canvas.  The Math.Max&#8217;s are there to prevent the upper left corner from being an impossible point (123, -50 ).</p>
<p>The end*&#8217;s use of Math.Max is actually crap on my part and isn&#8217;t needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/09/24/html5-canvas-windowing-proof-of-conceptprototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Profiling tools for MongoDB</title>
		<link>http://ominian.com/2011/08/31/profiling-tool-for-mongodb/</link>
		<comments>http://ominian.com/2011/08/31/profiling-tool-for-mongodb/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 12:28:18 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[mongodb]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=145</guid>
		<description><![CDATA[As MongoDb gains more customers, it will become increasing more important to be able to understand what the hell it is doing. I ran across this post this morning, it&#8217;s short but a good place to start in learning about profiling]]></description>
			<content:encoded><![CDATA[<p>As MongoDb gains more customers, it will become increasing more important to be able to understand what the hell it is doing.  I ran across this <a href="http://blog.mongolab.com/2011/08/finding-slow-mongodb-queries-with-mongolab/">post </a>this morning, it&#8217;s short but a good place to start in learning about profiling </p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/08/31/profiling-tool-for-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>metaclass service bus decorator concept</title>
		<link>http://ominian.com/2011/08/25/metaclass-service-bus-decorator-concept/</link>
		<comments>http://ominian.com/2011/08/25/metaclass-service-bus-decorator-concept/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 01:28:57 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[metaclass]]></category>
		<category><![CDATA[oh_snap]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=140</guid>
		<description><![CDATA[While playing around with some idea&#8217;s for making PyProxy completely overridable ( and also potentially undebuggable ) I started playing around with metaclasses. Below is from my toxic directory [ gist url ] from collections import defaultdict from functools import wraps Just some preliminary basic utilities A simple bus implementation, decoratedCalls is a dictionary of <a href='http://ominian.com/2011/08/25/metaclass-service-bus-decorator-concept/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>While playing around with some idea&#8217;s for making PyProxy completely overridable ( and also potentially undebuggable ) I started playing around with metaclasses.</p>
<p>Below is from my toxic directory [ <a href="https://gist.github.com/1172478">gist url</a> ]</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">collections</span> <span style="color: #ff7700;font-weight:bold;">import</span> defaultdict
<span style="color: #ff7700;font-weight:bold;">from</span> functools <span style="color: #ff7700;font-weight:bold;">import</span> wraps</pre></div></div>

<p>Just some preliminary basic utilities</p>
<p>A simple bus implementation, decoratedCalls is a dictionary of service calls, with a list<br />
of callbacks to each service call hook.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">decoratedCalls = defaultdict<span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> call<span style="color: black;">&#40;</span>name, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> name, args, kwargs
    <span style="color: #ff7700;font-weight:bold;">if</span> name <span style="color: #ff7700;font-weight:bold;">in</span> decoratedCalls:
        <span style="color: #ff7700;font-weight:bold;">for</span> cb <span style="color: #ff7700;font-weight:bold;">in</span> decoratedCalls<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span>:
            cb<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span></pre></div></div>

<p>Syntactic suger to add clarity later as to what functions are being bound to what.  Adding in<br />
debug/logging hooks here could allow for easier tracing of what is called for what methods.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> Subscribe<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, name<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">name</span> = name
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__call__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, f<span style="color: black;">&#41;</span>:
        decoratedCalls<span style="color: black;">&#91;</span><span style="color: #008000;">self</span>.<span style="color: black;">name</span><span style="color: black;">&#93;</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>f<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> f</pre></div></div>

<p>Here&#8217;s the actual bus decorator, very simple just wraps the decorated function with a pre and post bus calls.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> BusDecorator<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, name<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">name</span> = name
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__call__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, f<span style="color: black;">&#41;</span>:
&nbsp;
        @wraps<span style="color: black;">&#40;</span>f<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">def</span> decorator<span style="color: black;">&#40;</span>inst, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
            call<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s-pre&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">self</span>.<span style="color: black;">name</span>, inst, args, kwargs<span style="color: black;">&#41;</span>            
            retval = f<span style="color: black;">&#40;</span>inst, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>
            call<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s-post&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">self</span>.<span style="color: black;">name</span>, inst, retval<span style="color: black;">&#41;</span>            
            <span style="color: #ff7700;font-weight:bold;">return</span> retval
        <span style="color: #ff7700;font-weight:bold;">return</span> decorator</pre></div></div>

<p>And here&#8217;s my Bus Metaclass that combines most of the above.</p>
<p><em>The ease of wrapping the target class is accomplished by cdict which is a dictionary of<br />
every defined attribute of the target class.  As you can see it&#8217;s trivial to spin<br />
through and decorate every callable with the BusDecorator</em></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> BusWrap<span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__new__</span><span style="color: black;">&#40;</span>mcs, clsname, bases, cdict<span style="color: black;">&#41;</span>:
&nbsp;
        modName = cdict.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;__module__&quot;</span>, <span style="color: #483d8b;">&quot;unknownclass&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">for</span> name <span style="color: #ff7700;font-weight:bold;">in</span> cdict.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
            prefix = <span style="color: #483d8b;">&quot;%s.%s.%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span> modName, clsname, name<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">callable</span><span style="color: black;">&#40;</span>cdict<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:                
                cdict<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span> = BusDecorator<span style="color: black;">&#40;</span>prefix<span style="color: black;">&#41;</span><span style="color: black;">&#40;</span>cdict<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">type</span>.<span style="color: #0000cd;">__new__</span><span style="color: black;">&#40;</span>mcs, name, bases, cdict<span style="color: black;">&#41;</span></pre></div></div>

<p>Now give a dirt simple class like</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Foo<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #0000cd;">__metaclass__</span> = BusWrap
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;init'd&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> bar<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;bar&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> blah<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;blah&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> ich<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;ich&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> ego<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;lego&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> say<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Saying &quot;</span>, args</pre></div></div>

<p>And two service handlers to pre Foo.bar being called and after Foo.ego is called</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
@Subscribe<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;__main__.Foo.bar-pre&quot;</span><span style="color: black;">&#41;</span>        
<span style="color: #ff7700;font-weight:bold;">def</span> preBar<span style="color: black;">&#40;</span>inst, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>inst, <span style="color: #483d8b;">&quot;ext_info&quot;</span><span style="color: black;">&#41;</span>:
        inst.<span style="color: black;">ext_info</span> = <span style="color: #483d8b;">&quot;Here&quot;</span>
&nbsp;
@Subscribe<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;__main__.Foo.ego-post&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> postEgo<span style="color: black;">&#40;</span>inst, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>inst, <span style="color: #483d8b;">&quot;ext_info&quot;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Extended info is &quot;</span>, inst.<span style="color: black;">ext_info</span></pre></div></div>

<p>Our test shows&#8230;.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">x = Foo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
x.<span style="color: black;">bar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
x.<span style="color: black;">blah</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
x.<span style="color: black;">ich</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
x.<span style="color: black;">ego</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
x.<span style="color: black;">say</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;abba&quot;</span>, <span style="color: #483d8b;">&quot;dabba&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>this as output</p>
<pre>
__main__.Foo.__init__-pre (<__main__.__init__ object at 0x02637890>, (), {}) {}
init'd
__main__.Foo.__init__-post (<__main__.__init__ object at 0x02637890>, None) {}
__main__.Foo.bar-pre (<__main__.__init__ object at 0x02637890>, (), {}) {}
bar
__main__.Foo.bar-post (<__main__.__init__ object at 0x02637890>, None) {}
__main__.Foo.blah-pre (<__main__.__init__ object at 0x02637890>, (), {}) {}
blah
__main__.Foo.blah-post (<__main__.__init__ object at 0x02637890>, None) {}
__main__.Foo.ich-pre (<__main__.__init__ object at 0x02637890>, (), {}) {}
ich
__main__.Foo.ich-post (<__main__.__init__ object at 0x02637890>, None) {}
__main__.Foo.ego-pre (<__main__.__init__ object at 0x02637890>, (), {}) {}
lego
__main__.Foo.ego-post (<__main__.__init__ object at 0x02637890>, None) {}
Extended info is  Here
__main__.Foo.say-pre (<__main__.__init__ object at 0x02637890>, ('abba', 'dabba'), {}) {}
Saying  ('abba', 'dabba')
__main__.Foo.say-post (<__main__.__init__ object at 0x02637890>, None) {}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/08/25/metaclass-service-bus-decorator-concept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plugin&#8217;s for python</title>
		<link>http://ominian.com/2011/08/24/plugins-for-python/</link>
		<comments>http://ominian.com/2011/08/24/plugins-for-python/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 08:23:16 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=139</guid>
		<description><![CDATA[As the #1 google result for &#8220;python plugin&#8221;, the linked to blog post is extremely valuable for jump starting research into implementing your own plugin system ( like me ) or finding one that is viable for implementation in your project ( possibly like me ). These resources highlight one reason why there is not <a href='http://ominian.com/2011/08/24/plugins-for-python/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>As the #1 google result for &#8220;python plugin&#8221;, the linked to blog post is extremely valuable for jump starting research into implementing your own plugin system ( like me ) or finding one that is viable for implementation in your project ( possibly like me ).</p>
<blockquote><p>These resources highlight one reason why there is not a standard Python plug-in framework: there are a variety of different capabilities that a user may want, and the complexity of the framework generally increases as these new capabilities are added </p></blockquote>
<p><a href="http://wehart.blogspot.com/2009/01/python-plugin-frameworks.html">http://wehart.blogspot.com/2009/01/python-plugin-frameworks.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/08/24/plugins-for-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit-testing tools for Python</title>
		<link>http://ominian.com/2011/07/10/unit-testing-tools-for-python/</link>
		<comments>http://ominian.com/2011/07/10/unit-testing-tools-for-python/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 04:44:13 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=128</guid>
		<description><![CDATA[Found this http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy mostly up to date treasure trove of tools with summaries for unit-testing Python. So far the darling in my eye is Python Nose in combination with the Python coverage plugin]]></description>
			<content:encoded><![CDATA[<p>Found <a href="http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy">this http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy</a> mostly up to date treasure trove of tools with summaries for unit-testing Python.  So far the darling in my eye is Python <a href="http://code.google.com/p/python-nose/">Nose</a> in combination with the Python <a href="http://pypi.python.org/pypi/coverage">coverage</a> plugin </p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/07/10/unit-testing-tools-for-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get easy install onto a machine that has python but no wget/curl</title>
		<link>http://ominian.com/2011/06/25/how-to-get-easy-install-onto-a-machine-that-has-python-but-no-wgetcurl/</link>
		<comments>http://ominian.com/2011/06/25/how-to-get-easy-install-onto-a-machine-that-has-python-but-no-wgetcurl/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 22:46:27 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[oh_snap]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=122</guid>
		<description><![CDATA[D:\>d:\Python27\python.exe -m urllib http://peak.telecommunity.com/dist/ez_setup.py &#124; d:\Python27\python.exe]]></description>
			<content:encoded><![CDATA[<pre>
D:\>d:\Python27\python.exe -m urllib http://peak.telecommunity.com/dist/ez_setup.py | d:\Python27\python.exe
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/06/25/how-to-get-easy-install-onto-a-machine-that-has-python-but-no-wgetcurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My client&#8217;s hate me</title>
		<link>http://ominian.com/2011/05/26/my-clients-hate-me/</link>
		<comments>http://ominian.com/2011/05/26/my-clients-hate-me/#comments</comments>
		<pubDate>Fri, 27 May 2011 00:33:35 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=112</guid>
		<description><![CDATA[I&#8217;ve been using mdb-tools, a open source package for extracting Access MDB files, and entering whole new depths of conceptual joy. Application two and three were written in ASP by a college student, they were stop gap measures meant to live for a year or so&#8230; Fast forward 9 years and my client&#8217;s hired me <a href='http://ominian.com/2011/05/26/my-clients-hate-me/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using mdb-tools, a open source package for extracting Access MDB files, and entering whole new depths of<br />
conceptual joy.  Application two and three were written in ASP by a college student, they were stop gap measures meant to live for a year or so&#8230;  Fast forward 9 years and my client&#8217;s hired me to &#8220;fix&#8221; this problem among others.</p>
<p>In 2004 I replaced a USAF MS Access program used by my squadron with a PHP5 app, now 2011 I feel like I&#8217;ve stepped into a time machine and back in the hell that is MS Access and legacy ASP. </p>
<pre>
   CREATE TABLE CredentialLog
 (
	LogID			Integer,
	StudentID			Text (100),
	Cycle			Text (100),
	AppTo			Text (100),
	AppFor			Text (100),
	DayPhone			Text (100),
	Letter1			Text (100),
	Letter2			Text (100),
	Letter3			Text (100),
	Letter4			Text (100),
	Letter5			Text (100),
	Letter6			Text (100),
	Letter7			Text (100),
	Letter8			Text (100),
	Letter9			Text (100),
	Letter10			Text (100),
	Letter11			Text (100),
	Letter12			Text (100),
	Letter13			Text (100),
	Letter14			Text (100),
	Letter15			Text (100),
	DateRec1			DATETIME,
	DateRec2			DATETIME,
	DateRec3			DATETIME,
	DateRec4			DATETIME,
	DateRec5			DATETIME,
	DateRec6			DATETIME,
	DateRec7			DATETIME,
	DateRec8			DATETIME,
	DateRec9			DATETIME,
	DateRec10			DATETIME,
	DateRec11			DATETIME,
	DateRec12			DATETIME,
	DateRec13			DATETIME,
	DateRec14			DATETIME,
	DateRec15			DATETIME,
	DateSent1			DATETIME,
	DateSent2			DATETIME,
	DateSent3			DATETIME,
	DateSent4			DATETIME,
	DateSent5			DATETIME,
	DateSent6			DATETIME,
	DateSent7			DATETIME,
	DateSent8			DATETIME,
	DateSent9			DATETIME,
	DateSent10			DATETIME,
	DateSent11			DATETIME,
	DateSent12			DATETIME,
	DateSent13			DATETIME,
	DateSent14			DATETIME,
	DateSent15			DATETIME,
	Initial1			Text (8),
	Initial2			Text (8),
	Initial3			Text (8),
	Initial4			Text (8),
	Initial5			Text (8),
	Initial6			Text (8),
	Initial7			Text (8),
	Initial8			Text (8),
	Initial9			Text (8),
	Initial10			Text (8),
	Initial11			Text (8),
	Initial12			Text (8),
	Initial13			Text (8),
	Initial14			Text (8),
	Initial15			Text (8)
);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/05/26/my-clients-hate-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A web-console implemented in nodeJS</title>
		<link>http://ominian.com/2011/05/17/a-web-console-implemented-in-nodejs/</link>
		<comments>http://ominian.com/2011/05/17/a-web-console-implemented-in-nodejs/#comments</comments>
		<pubDate>Tue, 17 May 2011 16:44:47 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[NodeJS]]></category>
		<category><![CDATA[hacks]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=107</guid>
		<description><![CDATA[Reading over this ( http://gonzalo123.wordpress.com/2011/05/16/web-console-with-node-js/ ) , I felt this was a pretty good and relatively real world example of nodeJS&#8217;s capabilities. I did find one line near the end very poignant and reflective of my own opinions at the end of the show &#038; tell post I don’t know if node.js is the future <a href='http://ominian.com/2011/05/17/a-web-console-implemented-in-nodejs/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Reading over <a href="http://gonzalo123.wordpress.com/2011/05/16/web-console-with-node-js/">this</a> ( http://gonzalo123.wordpress.com/2011/05/16/web-console-with-node-js/ ) , I felt this was a pretty good and relatively real world example of nodeJS&#8217;s capabilities.  I did find one line near the end very poignant and reflective of my own opinions at the end of the show &#038; tell post </p>
<blockquote><p>I don’t know if node.js is the future or is just another hype, but it’s easy. And cool. Really cool.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/05/17/a-web-console-implemented-in-nodejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New language to the toolset: NodeJS</title>
		<link>http://ominian.com/2011/05/16/new-language-to-the-toolset-nodejs/</link>
		<comments>http://ominian.com/2011/05/16/new-language-to-the-toolset-nodejs/#comments</comments>
		<pubDate>Mon, 16 May 2011 21:35:01 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[NodeJS]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[woot]]></category>

		<guid isPermaLink="false">http://ominian.com/?p=104</guid>
		<description><![CDATA[I&#8217;ve started self-teaching myself NodeJS and not surprisingly there was a recent popular reddit link pointing to a not very short introduction to nodejs here ( http://anders.janmyr.com/2011/05/not-very-short-introduction-to-nodejs.html ) . At this point I haven&#8217;t found any good books for reference lookup&#8230; but hopefully in a week or so I&#8217;ll have gotten spooled up enough to <a href='http://ominian.com/2011/05/16/new-language-to-the-toolset-nodejs/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started self-teaching myself NodeJS and not surprisingly there was a recent popular reddit link pointing to a not very short introduction to nodejs <a href="http://anders.janmyr.com/2011/05/not-very-short-introduction-to-nodejs.html">here</a> ( http://anders.janmyr.com/2011/05/not-very-short-introduction-to-nodejs.html ) .  At this point I haven&#8217;t found any good books for reference lookup&#8230; but hopefully in a week or so I&#8217;ll have gotten spooled up enough to be able to report back.</p>
<p>In the meantime as I use Ubuntu for everything but games, this short article <a href="http://www.codediesel.com/linux/installing-node-js-on-ubuntu-10-04/">here</a> ( http://www.codediesel.com/linux/installing-node-js-on-ubuntu-10-04/ ) was enough to get a working environment running though I recommend using a pristine virtual machine instance to keep things simple.</p>
<p>Last point, a reliable friend &#038; peer of mine recommended I check out this MVC like framework for NodeJS ( http://expressjs.com/ ).  Preliminary it feels like a hybrid between Twistd and CherryPy in Python or Limonade PHP as far as style&#8230; aiming more for simplicity over feature/complexity.</p>
]]></content:encoded>
			<wfw:commentRss>http://ominian.com/2011/05/16/new-language-to-the-toolset-nodejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

