<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Limber Lambda &#187; Administration</title>
	<atom:link href="http://thelimberlambda.com/category/administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://thelimberlambda.com</link>
	<description>Eric Smith's technical musings</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:09:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thelimberlambda.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Limber Lambda &#187; Administration</title>
		<link>http://thelimberlambda.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thelimberlambda.com/osd.xml" title="The Limber Lambda" />
	<atom:link rel='hub' href='http://thelimberlambda.com/?pushpress=hub'/>
		<item>
		<title>Exposing your Applications Guts using IronPython</title>
		<link>http://thelimberlambda.com/2010/02/14/exposing-your-applications-guts-using-ironpython/</link>
		<comments>http://thelimberlambda.com/2010/02/14/exposing-your-applications-guts-using-ironpython/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 18:11:12 +0000</pubDate>
		<dc:creator>Eric Smith</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://skepticabin.wordpress.com/?p=245</guid>
		<description><![CDATA[Application guts (or indeed anyone’s guts) isn’t typically on ones “list of things to see”.  Quite often though, when presented with some perplexing behaviour on live, you end up wishing that you’d added a key piece of logging code to get you to the point where you had just enough visibility to be able to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=245&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Application guts (or indeed anyone’s guts) isn’t typically on ones “list of things to see”.  Quite often though, when presented with some perplexing behaviour on live, you end up wishing that you’d added a key piece of logging code to get you to the point where you had just enough visibility to be able to solve the problem.</p>
<p>As it turns out, if you’re writing a .NET application, there isn’t a tremendous amount of difference between a Debug and a Release build.  That’s because, of course, the compiler isn’t spitting out real machine code, but rather MSIL, and if any kind of optimisation ever happens, it happens at JIT time.  At the end of the day, if you’re talking .NET, the difference between being able to debug your application boils down to the availability of some .pdb’s and <a href="http://www.hanselman.com/blog/DebugVsReleaseTheBestOfBothWorlds.aspx">an INI file</a> … that’s it.</p>
<p>Never-the-less, you may not actually have a copy of Visual Studio or <a href="http://msdn.microsoft.com/en-us/library/bb190764.aspx">WinDbg with Son-of-Strike</a> installed on the machine that you’re interested in poking around your badly behaving live application with.  That’s why you’d be particularly interested in employing the services of a worthy logging framework like <a href="http://logging.apache.org/log4net/">Log4Net</a> or the logging block from <a href="http://msdn.microsoft.com/en-us/library/cc467894.aspx">Entlib</a> at the outset of your enterprise development stint.  Just increase your log level to “debug” and you’re a-for-away … right?</p>
<p>There are a couple of issues with this:</p>
<ul>
<li>Typically, you need to restart your application or service to get the higher logging level into effect—maybe you have a situation where you don’t want to do that; you just want to view state?</li>
<li>What if, even on debug level, you’re not emitting the detail that you need?  At the end of the day, you’re at the mercy of the vigilance of the developer who wrote the debug entries—they may just not be enough.</li>
</ul>
<p>How about bundling a little back-door into your app?  You could:</p>
<ul>
<li>Get at it using something available on any PC, namely telnet;</li>
<li>Do anything that you would be able to do using code, only <em>dynamically.</em></li>
</ul>
<p>Enter <strong>PythonServer</strong>, <a href="http://github.com/merowig/PythonServer">available on github</a>.  Let’s take it for a run using the (very) simple sample application:</p>
<p><pre class="brush: csharp;">

static void Main()
{
	Console.WriteLine(&quot;Starting...&quot;);
	var theFibber = new Fibber();
	var pythonServer = new TheLimberLambda.Utils.PythonServer(2323,
		new [] { new NameBinding(&quot;fibber&quot;, theFibber) });
	pythonServer.Start();
	Console.ReadLine();
}

</pre></p>
<p>SimpleSample fires up a console, instantiates an instance of Fibber and starts an instance of PythonServer, listening on port 2323.</p>
<p>Fibber is just an implementation of <span style="font-family:'Courier New';">IEnumerable&lt;int&gt;</span> that spits out Fibonacci terms, but the key point is that it was instantiated in and lives inside the SimpleSample process.  We keep SimpleSample from exiting by waiting for input on the console.</p>
<p>Telnet’ing into localhost on port 2323 gives us an interactive Python command-line, so legal Python will execute as expected:</p>
<p><a href="http://skepticabin.files.wordpress.com/2010/02/image1.png"><img style="display:inline;border-width:0;" title="image" src="http://skepticabin.files.wordpress.com/2010/02/image_thumb1.png?w=684&#038;h=219" border="0" alt="image" width="684" height="219" /></a></p>
<p>The real kicker here though is that we have access to our SimpleSample process, and anything that we decided to publish is available to us (in SimpleSample’s case, that would include our instance of Fibber).  Since Fibber implements IEnumerable, we can benefit from IronPython’s automatic recognition of anything IEnumerable as a Python iterator:</p>
<p><a href="http://skepticabin.files.wordpress.com/2010/02/image2.png"><img style="display:inline;border-width:0;" title="image" src="http://skepticabin.files.wordpress.com/2010/02/image_thumb2.png?w=684&#038;h=223" border="0" alt="image" width="684" height="223" /></a></p>
<p>Here we’re using the <a href="http://docs.python.org/library/itertools.html">itertools</a> package that comes with Python (or in our case, IronPython) to grab the first 10 items of the Fibonacci series.</p>
<p>Because we’re referencing a single instance of Fibber, and because the state of “where we are” in the series is maintained, we can telnet in from a difference spot, and ask for the next two items:</p>
<p><a href="http://skepticabin.files.wordpress.com/2010/02/image3.png"><img style="display:inline;border-width:0;" title="image" src="http://skepticabin.files.wordpress.com/2010/02/image_thumb3.png?w=684&#038;h=273" border="0" alt="image" width="684" height="273" /></a></p>
<p>Thus, we have a Python interface into potentially any .NET application.</p>
<h3>Name Binding</h3>
<p>Now, how did the name “fibber” become available to us, you may ask?  The key is the <span style="font-family:'Courier New';">IEnumerable&lt;NameBinding&gt; </span>that we passed to the PythonServer constructor.  At some point we need to provide some translation between the python namespace and the object instances of interest.  Presently, PythonServer does this using a dead simple string-to-reference map provided up-front.</p>
<p>Going under the bonnet and taking a squiz at the code that gets executed when a connection is made to the server, we notice the introduction of a <span style="font-family:'courier new';">ScriptScope</span> instance:</p>
<p><pre class="brush: csharp;">

		private void InitialiseScriptRuntime(Socket socket)
		{
			_ScriptRuntime.IO.SetOutput(new SocketConverserStream(socket), Encoding.ASCII);
			_ScriptRuntime.IO.SetErrorOutput(new SocketConverserStream(socket), Encoding.ASCII);
			_ScriptScope = _ScriptRuntime.CreateScope(&quot;py&quot;);
		}

</pre></p>
<p>… and binding names is just a matter of setting <span style="font-family:'courier new';">ScriptScope</span> variables, thusly:</p>
<p><pre class="brush: csharp;">

		private void BindScriptScopeNames(IEnumerable&lt;NameBinding&gt; nameBindings)
		{
			foreach (var binding in nameBindings)
				_ScriptScope.SetVariable(binding.Name, binding.Target);
		}

</pre></p>
<p>I will admit that PythonServer has a way to go, and could do with a whole bunch of things, including:</p>
<ul>
<li>A solid security model.  At the moment PythonServer should really only be used in controlled environments since of course there is no authentication (or encryption) to speak of—SSH should fit nicely here;</li>
<li>Integration of the name binding interface into your favourite IoC container.</li>
</ul>
<p>As a start though, this provides a great means of getting into your process in a relatively hassle-free way.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/skepticabin.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/skepticabin.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/skepticabin.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=245&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelimberlambda.com/2010/02/14/exposing-your-applications-guts-using-ironpython/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b4cf8c0d26636bfbef4bcba057b27f01?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Serfsmith</media:title>
		</media:content>

		<media:content url="http://skepticabin.files.wordpress.com/2010/02/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://skepticabin.files.wordpress.com/2010/02/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://skepticabin.files.wordpress.com/2010/02/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Binary or not?</title>
		<link>http://thelimberlambda.com/2008/08/10/binary-or-not/</link>
		<comments>http://thelimberlambda.com/2008/08/10/binary-or-not/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 18:50:26 +0000</pubDate>
		<dc:creator>Eric Smith</dc:creator>
				<category><![CDATA[Administration]]></category>

		<guid isPermaLink="false">http://skepticabin.wordpress.com/?p=24</guid>
		<description><![CDATA[Recently after listening to an episode of Hanselminutes it occurred to me that a measure of whether or not you&#8217;re a Unix geek is how often you see this kind of thing: In short, if you don&#8217;t see it at all or have never noticed strange characters at the start of your text file, you&#8217;re [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=24&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently after listening to an <a href="http://www.hanselminutes.com/default.aspx?showID=135">episode of Hanselminutes</a> it occurred to me that a measure of whether or not you&#8217;re a Unix geek is how often you see this kind of thing:</p>
<p><a href="http://skepticabin.files.wordpress.com/2008/08/binaryornot1.jpg"><img class="alignnone size-medium wp-image-31" src="http://skepticabin.files.wordpress.com/2008/08/binaryornot1.jpg?w=300&#038;h=49" alt="" width="300" height="49" /></a></p>
<p>In short, if you don&#8217;t see it at all or have never noticed strange characters at the start of your text file, you&#8217;re likely to reply &#8220;to hear the sea?&#8221; to the question &#8220;what&#8217;s your favourite shell?&#8221;.  In that case, do yourself a favour, go under the bonnet a little and learn about <a href="http://en.wikipedia.org/wiki/Byte_order_mark">byte order marks</a> (it&#8217;s all about enrichment).</p>
<p>Further, if it interests you enough, you may find yourself checking out the hex equivalent of your text file&#8211;how you go about that is very telling.  <a href="http://www.hanselman.com/blog/">Hanselman</a> belied his roots by doing this:</p>
<p><code>debug Foo.txt</code> (and then enter &#8216;d&#8217;)</p>
<p>On the other hand, having a rather more unixy background, I would do the following:</p>
<p><code>xxd Foo.txt</code></p>
<p>To be honest, <code>debug</code> wouldn&#8217;t have occurred to me &#8211; if I had not had <a href="http://www.cygwin.com/">cygwin</a> installed, I would probably have ended up downloading a (free/share-ware) editor that provides such a feature.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/skepticabin.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/skepticabin.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/skepticabin.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/skepticabin.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/skepticabin.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=24&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelimberlambda.com/2008/08/10/binary-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b4cf8c0d26636bfbef4bcba057b27f01?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Serfsmith</media:title>
		</media:content>

		<media:content url="http://skepticabin.files.wordpress.com/2008/08/binaryornot1.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>One less visual annoyance</title>
		<link>http://thelimberlambda.com/2008/08/07/one-less-visual-annoyance/</link>
		<comments>http://thelimberlambda.com/2008/08/07/one-less-visual-annoyance/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 05:22:59 +0000</pubDate>
		<dc:creator>Eric Smith</dc:creator>
				<category><![CDATA[Administration]]></category>

		<guid isPermaLink="false">http://skepticabin.wordpress.com/?p=18</guid>
		<description><![CDATA[My take on this issue may not apply to everyone, but everytime some little app decides to contribute to the &#8220;system tray balloon tooltip&#8221; party I feel obliged to click on the damn thing just to get rid of it.  In a world where there is way too much clicking to start with, I&#8217;d rather [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=18&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My take on this issue may not apply to everyone, but everytime some little app decides to contribute to the &#8220;system tray balloon tooltip&#8221; party I feel obliged to click on the damn thing just to get rid of it.  In a world where there is way too much clicking to start with, I&#8217;d rather not care.</p>
<p>Here&#8217;s how to suppress balloon tooltips:</p>
<p><code>[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]<br />
"EnableBalloonTips"=dword:00000000</code></p>
<p>You may ask: &#8220;Will a <code>dword:00000001</code> get them to come back again?&#8221;.  I tried&#8211;doesn&#8217;t seem to work.  Evidently the presence of the entry suppresses them.  Go figure.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/skepticabin.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/skepticabin.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/skepticabin.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/skepticabin.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/skepticabin.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelimberlambda.com&amp;blog=2436519&amp;post=18&amp;subd=skepticabin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelimberlambda.com/2008/08/07/one-less-visual-annoyance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b4cf8c0d26636bfbef4bcba057b27f01?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Serfsmith</media:title>
		</media:content>
	</item>
	</channel>
</rss>
