<?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>Possibility and Probability &#187; Python</title>
	<atom:link href="http://ironboundsoftware.com/blog/category/programming/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://ironboundsoftware.com/blog</link>
	<description>Droplets of Yes and No</description>
	<lastBuildDate>Wed, 28 Dec 2011 01:37:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Today&#8217;s Django lesson</title>
		<link>http://ironboundsoftware.com/blog/2011/12/27/todays-django-lesson/</link>
		<comments>http://ironboundsoftware.com/blog/2011/12/27/todays-django-lesson/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 01:37:16 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://ironboundsoftware.com/blog/?p=400</guid>
		<description><![CDATA[Today I was working on re-doing my main website. I have built the site in Django, and then when I&#8217;m ready to publish I use the static generator module to create an html snapshot of the pages that I then upload to the server. Basically I wanted the fun of using Django, but the ease [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was working on re-doing <a href="http://ironboundsoftware.com">my main website</a>. I have built the site in <a href="https://www.djangoproject.com/">Django</a>, and then when I&#8217;m ready to publish I use the static generator module to create an html snapshot of the pages that I then upload to the server. Basically I wanted the fun of using Django, but the ease of serving up static html pages.</p>
<p>The last time I did this, the version of Django was 0.9 and today&#8217;s version is 1.3.1. As a I started work on the site I discovered some things here and there that had changed in the years in-between those version. The one that bit me the hardest was this: I could view the main page (/), but any other page (including index) would give me a 404 error.</p>
<p>This was really weird because the mappings existed in the urls.py file, but a 404 error means it couldn&#8217;t be found. If it was a programmatic error you would expect a 500 error, but I never saw one.</p>
<p>Slowly but surely I tore the system apart looking to see what could cause mapped urls to disappear in Django. Eventually I discovered the root cause was how static resources are handled.</p>
<p>One of the changes in the new versions of Django was to add functionality for handling static resources. The biggest change (at least as far as my ancient code was concerned) was in introduction of the STATIC_URL variable. According the documentation this is the prefix for static resources (like css, javascript) that are referenced by the web page that is being built by Django.</p>
<p>In my laziness many years ago, I just plopped the main CSS file (and everything else) in the root of the web directory so that in the html pages didn&#8217;t have to have paths on them. So when I was adding the STATIC_URL variable to make sure my CSS file would actually load, I set the variable this way:</p>
<blockquote><p>STATIC_URL = &#8216;/&#8217;</p></blockquote>
<p>&#8230;because it wouldn&#8217;t let me put an empty string of &#8221;. Well, it turns out that this was wrong wrong wrong. Django was looking at the incoming requests as I tried to visit the pages of the site and checking the static directory to see if there was anything there (which there wasn&#8217;t, just my CSS file).</p>
<p>Once I realized this, I changed it to:</p>
<blockquote><p>STATIC_URL = &#8216;/static/&#8217;</p></blockquote>
<p>&#8230;which basically forces you to create a directory to hold your static files. Which is right right right right. Basically Django was forcing me to clean up my act and code the site in a much cleaner manner. As soon as I did that all of the 404 errors went away and I was able to hit every page in my urls.py file.</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2011/12/27/todays-django-lesson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choices &#8211; The hidden powers of python</title>
		<link>http://ironboundsoftware.com/blog/2011/02/06/choices-the-hidden-powers-of-python/</link>
		<comments>http://ironboundsoftware.com/blog/2011/02/06/choices-the-hidden-powers-of-python/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 19:40:45 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ironboundsoftware.com/blog/?p=398</guid>
		<description><![CDATA[The other day I saw something about this interesting posting on Stack Overflow: What are the lesser-known but useful features of the Python programming language? As someone who loves to work in Python and is always looking for a better way to get things done, I had to read this article right away. I was [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I saw something about this interesting posting on Stack Overflow: <a href="http://stackoverflow.com/questions/101268/hidden-features-of-python/102062">What are the lesser-known but useful features of the Python programming language?</a> As someone who loves to work in Python and is always looking for a better way to get things done, I had to read this article right away.</p>
<p>I was pretty pleased with myself that I knew a lot of the things listed, and I was really happy when I ran into some nuggets that I knew nothing about. For example, I did not know that you could do this in Python:</p>
<blockquote><p>1 &lt; x &lt;10</p></blockquote>
<p>To me, that is really awesome because not only is what you would write in a mathematical sense, but it also is much more concise and what you would see in a pseudo-code representation of a program. That is the power of Python, taking an idea (a computer program) and presenting it in a readable manner. Being able to use the above type of expression just takes us further down that path of readability and that is a good thing. And yes, you can write crappy code in Python, but at least you have the choice: many languages simply have one way to do things. Choices are good.</p>
<p>And speaking of choices, I thought this feature was very cool, even if I would never use it:</p>
<blockquote><p>from __future__ import braces</p></blockquote>
<p>That allows the use of {} instead of white space in a Python program. I know some people can&#8217;t stand the indention rules of the language and feel more comfortable when they are &#8220;braced&#8221; (for impact?), but the fact the language has features to be able to turn this on? That is 1 million pounds of awesome in  a 5 pound sack.</p>
<p>There is a ton of other neat tricks there, go and read up and see what you can do to make your code work more for you! Choice is a great thing. With Python, you have lots of great choices you can make. And if you decide to make no choices, you still wind up with pretty readable code which is always a good thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2011/02/06/choices-the-hidden-powers-of-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python in the Amazon cloud</title>
		<link>http://ironboundsoftware.com/blog/2010/12/30/python-in-the-amazon-cloud/</link>
		<comments>http://ironboundsoftware.com/blog/2010/12/30/python-in-the-amazon-cloud/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 23:22:12 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://ironboundsoftware.com/blog/?p=393</guid>
		<description><![CDATA[I have a couple ideas rolling around in my head, and recently I decided to take advantage of Amazon&#8217;s AWS service since they are offering a &#8220;free&#8221; tier. (Basically its free if you are below certain generous limits on resource utilization.) Since python is my weapon of choice these days, I set about to figure out how [...]]]></description>
			<content:encoded><![CDATA[<p>I have a couple ideas rolling around in my head, and recently I decided to take advantage of <a href="http://aws.amazon.com">Amazon&#8217;s AWS service</a> since they are offering a &#8220;free&#8221; tier. (Basically its free if you are below certain generous limits on resource utilization.) Since python is my weapon of choice these days, I set about to figure out how to get python up and running on an EC2 instance.</p>
<p>If you are going to go down the Linux route with AWS (and honestly why wouldn&#8217;t you?), then you are in luck since python ships on most modern distributions. But, while python is &#8220;batteries included&#8221; there are some really nice projects out there that it is good to take advantage of. Installing these projects is where you start to find out there are differences in the EC2 AMI&#8217;s.</p>
<p>My first attempt was with the default Amazon AMI. It seemed like a good choice, but the more I played with it, the more I realized that it was pretty bare-bones. easy_install is included, but when running it to try and install something you run into permissions problems.</p>
<p>Because this is supposed to be a nice experiment, I only played around with it for a hour or so. My patience exhausted, I went looking for an alternative and ran right into the perfect match: <a href="http://www.activestate.com/press-releases/activestate-launches-amazon-ec2-cloud-offering-python-developers">ActiveState has an AMI specifically for python developers</a></p>
<p>This is awesome because ActiveState puts out a really nice Windows package for Python (and other lesser languages). I fired up their AMI instance and have found it to be really nice. I put my python project out there earlier this month and it ran without a problem&#8230; until the code crashed because I forgot to put a try catch block in place. <img src='http://ironboundsoftware.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Seriously though, I really like this AMI. Not only is a nice python distribution there, but they also included gcc so if you need to compile something, you don&#8217;t have to go far. The easy_install script runs like a dream, and I haven&#8217;t had any problems with it at all. In fact, my whole experiment (which seems to getting attention mostly from blog aggregators at the moment) has only cost me a total of $0.19. Yes, only 19 cents! And 1 cent of that was from the ActiveState Python AMI (the other 18 cents was from my playing around with the Amazon AMI that wasn&#8217;t that great).</p>
<p>Now to get back to my ideas, and sling some python code out into the cloud&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/12/30/python-in-the-amazon-cloud/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TDD and honesty in code</title>
		<link>http://ironboundsoftware.com/blog/2010/09/10/tdd-and-honesty-in-code/</link>
		<comments>http://ironboundsoftware.com/blog/2010/09/10/tdd-and-honesty-in-code/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 16:02:48 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://ironboundsoftware.com/blog/?p=375</guid>
		<description><![CDATA[I&#8217;m working on a little project to help keep track of satellites. Specifically, I&#8217;m taking an existing code base (the AIAA SGP4 code which is written in C/C++), wrapping it with python, and then eventually putting a web front end on it. The end goal is that astronomers will be able to use this code/website to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a little project to help keep track of satellites.</p>
<p>Specifically, I&#8217;m taking an existing code base (the <a href="http://pdf.aiaa.org/preview/CDReadyMAST06_1308/PV2006_6753.pdf">AIAA SGP4 code</a> which is written in C/C++), wrapping it with <a href="http://python.org">python</a>, and then eventually putting a web front end on it. The end goal is that astronomers will be able to use this code/website to check their observations to see if there was a satellite in their field of view when they took their measurements.</p>
<p>Since I&#8217;m using a known library in to create something new, this seemed like a really great opportunity to use some Test Driven Development (TDD) to ensure that as I build up the parts of the system, the numbers stay true and that the code stays honest.</p>
<p>This is working out really well. Combining python&#8217;s unit test module with <a href="http://somethingaboutorange.com/mrl/projects/nose">nosetests</a> allows me to quickly bang out a test to make sure that the positional numbers that the SGP4 code generates is what the documentation says it should be. By using TDD I can map out where the code needs to go a little better: As I find something that is missing I can write out a quick test that will fail. When I run nosetests, I have that failure glaring at me telling me where more code is needed.</p>
<p>For example, I have one set of test data that gives the observer&#8217;s location in standard latitude and longitude coordinates. My code isn&#8217;t quite expecting this, the <a href="http://www.minorplanetcenter.org/iau/mpc.html">MPC format </a>is a little bit different. This is a problem that is easy to fix, but I have a plethora of problems at the moment and I need to make sure this one gets taken care of properly. So I opened up the python file that tests the Observatory class and added in a failing test that called <em>testLatLongToXYZ(). </em>When I run the tests I now see that this is a failing method which gives me the mental kick in the pants to go and implement that method, even if it is just a stub.</p>
<p>Why do I say just a stub? Because putting in the stub lets  me do two things: 1) I&#8217;ve now got something there, and 2) I can now update the test to call that stub. The secret is that the test should now call the stub and expect it to pass, but the stub should always return something (None, False, -1, etc.) to indicate that it failed.</p>
<p>This acts as a pointer to an area that needs improvement in the code. This is what TDD is all about. You keep repeating this process until you converge on a &#8220;correct&#8221; answer which is a method that does just what it needs to do. In theory, and so far my practice confirms this, the resulting code should be smaller and more accurate.</p>
<p>For me this is a great thing because it encourages code that is more honest. What is honest code? To me, it is code that does what it says and nothing else. The shorter the code is, the more focused it is. The python language is very expressive and allows you to do a lot without saying a lot. This power can lead you to try and do too much in one function. Once you have a function that not only converts Lat and Long, but also converts polar coordinates and writes satellite data to the database, can you really honestly call that function <em>convertLatLongToXYZ()</em>?</p>
<p>This is especially valuable in the scientific context of this astronomy related code. The code is open source, and in the event there is a problem with it, as people dig into the code they need to have confidence that the code is relatively well written. At a high level the tests give them the numerical sense of ease that it is working when the tests run and show the proper numbers being returned. At a low level, seeing that the code is broken up into small logical sections gives the confidence that once  problem is found it can be corrected, tested, and shown that there are minimal side effects in other parts of the program.</p>
<p>As the lone developer on this project, this type of check-and-balance gives me a lot of hope that I&#8217;ll be able to produce something that is accurate and useful to the community at large. Openness and honesty help build confidence and trust. If you are interested in the project, be sure to check it out:</p>
<p><a href="https://bitbucket.org/nloadholtes/obssatid">ObsSatId: A python astronomy project to wrap the SGP4 code to check for satellites</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/09/10/tdd-and-honesty-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python function overloading via multimethods</title>
		<link>http://ironboundsoftware.com/blog/2010/07/21/python-function-overloading-via-multimethods/</link>
		<comments>http://ironboundsoftware.com/blog/2010/07/21/python-function-overloading-via-multimethods/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 02:13:57 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://ironboundsoftware.com/blog/?p=361</guid>
		<description><![CDATA[One of my favorite features of OO languages like Java is the ability to overload a method, which is where you have several methods with the same name, but they take in different types in their arguments. I love the python language, but as I blogged about a while ago, not having overloaded methods in [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite features of OO languages like Java is the ability to overload a method, which is where you have several methods with the same name, but they take in different types in their arguments.</p>
<p>I love the python language, but as I blogged about a while ago, <a href="http://ironboundsoftware.com/blog/2007/05/29/a-shortfall-of-python-no-function-overloading/">not having overloaded methods in python</a> is kind of a bummer. But do you have to trade your dynamic freedom in for static types to gain this? It turns out that with a little ingenuity, you can get that functionality using the <a href="http://en.wikipedia.org/wiki/Multiple_dispatch">generic dispatch pattern</a> and python&#8217;s decorator syntax.</p>
<p>The example on the above wiki page is nice and concise, but I think that <a href="http://alexgaynor.net/2010/jun/26/multimethods-python/">Alex Gaynor&#8217;s blog post about multimethods is the best</a> example of how to implement this useful idea. In leiu of an explanation of how it works, Alex gives us a unit test that exercises the mutimethod class and the dispatch/overloading idea that it brings to life. As long as you know what a <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">decorator</a> is the code does make sense.</p>
<p>There are other examples of using a <a href="http://mike.axiak.net/blog/2010/06/25/python-generic-dispatch/">dispatch</a>, but I feel that Alex&#8217;s is more clear. These are of course no substitute for having function overloading built into the python language, but having the functionality wrapped up in a nice neat class like this is a very good thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/07/21/python-function-overloading-via-multimethods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linking against Python on the Mac</title>
		<link>http://ironboundsoftware.com/blog/2010/05/29/linking-against-python-on-the-mac/</link>
		<comments>http://ironboundsoftware.com/blog/2010/05/29/linking-against-python-on-the-mac/#comments</comments>
		<pubDate>Sat, 29 May 2010 14:00:12 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.ironboundsoftware.com/blog/?p=344</guid>
		<description><![CDATA[Today while working with swig I kept running into problems trying to get python to read the generated output files. The error I finally wound up with was: Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap It turns out that on the Mac [...]]]></description>
			<content:encoded><![CDATA[<p>Today while working with <a href="http://swig.org">swig</a> I kept running into problems trying to get python to read the generated output files. The error I finally wound up with was:</p>
<blockquote>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Fatal Python error: Interpreter not initialized (version mismatch?)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Abort trap</div>
<blockquote><p>Fatal Python error: Interpreter not initialized (version mismatch?)</p></blockquote>
<blockquote><p>Abort trap</p></blockquote>
</blockquote>
<div>It turns out that on the Mac (OSX 10.6) that you have to pass gcc a special flag if you want to link against the python library. Traditionally you would do something like this:</div>
<blockquote>
<div>gcc myfile.c -l<strong>python</strong> -shared -o mylib.so</div>
</blockquote>
<div>But on the Mac is you have the Mac specific installer version of python (I think as opposed to building it at the command line), there is no libpython.so on your system, so the <em>-lpython</em> flag never works.</div>
<div>The solution is to use the <em>-framework</em> which tells gcc to look into the framework directory where OSX stores all of its specially configured tools/utilities/programs. (If you are wondering the python 2.6 framework is kept at this location: /Library/Frameworks/Python.framework/Versions/2.6/)</div>
<div>So using the example above, the proper incantation to produce a useable shared library linked against python is:</div>
<blockquote>
<div>gcc myfile.c -<strong>framework python</strong> -shared -o mylib.so</div>
</blockquote>
<div>That should produce something useable.</div>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/05/29/linking-against-python-on-the-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion and Mercurial in the same place</title>
		<link>http://ironboundsoftware.com/blog/2010/04/24/subversion-and-mercurial-in-the-same-place/</link>
		<comments>http://ironboundsoftware.com/blog/2010/04/24/subversion-and-mercurial-in-the-same-place/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 21:35:30 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.ironboundsoftware.com/blog/?p=341</guid>
		<description><![CDATA[In a previous post I talked about trying to use Mercurial (hg) in a Subversion (svn) world. Its been almost 2 months, and I&#8217;ve learned quite a bit about hg and how to use it in a svn based environment. At the time it seemed like the obvious choice was to get something (hgsubversion) that [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I talked about trying to use <a href="http://mercurial.selenic.com/">Mercurial</a> (hg) in a Subversion (svn) world. Its been almost 2 months, and I&#8217;ve learned quite a bit about hg and how to use it in a svn based environment.</p>
<p>At the time it seemed like the obvious choice was to get something (<a href="http://www.bitbucket.org/durin42/hgsubversion/">hgsubversion</a>) that would let hg talk directly to the svn server, but still allow me to explore DVCS workflows. It turns out that this isn&#8217;t the case. Luckily there are several different approaches that can be used.</p>
<h1>I coulda been a contender&#8230;</h1>
<p>The idea behind hgsubversion is to use hg as your version control tool. This extension lets it &#8220;talk&#8221; to svn servers, so you only need one tool. It sounds like a really great idea, but I ran into some stumbling blocks that while not necessarily show stoppers, they did cause me to look around for alternatives (more on that later). Here&#8217;s the issues, good and not-so-good, that I had with this extension:</p>
<ul>
<li><strong>Poor support in cygwin &#8211; </strong>Installing this on cygwin was a bitch-and-half. Getting all of the pieces to compile and install was a major act that I just couldn&#8217;t pull off. Which is a bummer, I do love me some command line. However, <a href="http://tortoisehg.bitbucket.org/">TortoiseHg</a> to the rescue!</li>
<li>It works great on the mac &#8211; I usually have the most trouble installing new stuff on my mac, but hgsubversion works like a champ with no problems.</li>
<li><strong>TortoiseHg rocks -</strong> This program is amazing. It worked correctly right out of the box, and took no effort to get up and running on my windows machine. It really let me get started on this little experiment.</li>
</ul>
<p><strong></p>
<h1>&#8220;Other than that Ms. Lincoln&#8230;&#8221;</h1>
<p><span style="font-weight: normal;">Once I  got rolling with TortoiseHg it was time to rock. </span></p>
<p><span style="font-weight: normal;">My main goal was to use hg to spin off branches of my main code tree to do things like experimental refactorings, playing with some unit tests, and to try and work on bugs in isolation. And I have to say after getting past a few growing pains, it really works well for that. I was off to the races, committing and rolling back my work with out a care in the world, knowing that there was a versioning system watching my back.</span></p>
<p><span style="font-weight: normal;">Everything was going to great until I went to commit my changes back to the svn repository. Then I discovered a problem&#8230;</span></p>
<h1>Too many dicks on the dance floor!</h1>
<p><span style="font-weight: normal;">It turns out that hgsubversion is pretty literal in that it converts hg to svn. It took all of the changes I had made in my branches and pushed them upstream to the svn server. The result was a ton of intermediary messages (from my hg checkins) being dumped into the svn log.</span></p>
<p><span style="font-weight: normal;">Now please note that the code was ok. Nothing bad happened, it just looks like I committed a ton to the svn repository.</span></p>
<p><span style="font-weight: normal;">I was under the impression that it was going to just take the diff of the last svn update and the head of the hg and push that. I wasn&#8217;t thrilled with this, so I decided to look for an alternative that would let me do this. It turns out its really easy to do, simply do an hg init in you svn working directory.</span></p>
<h1><span style="font-weight: normal;">Say whaaaaa?</span></h1>
<p><span style="font-weight: normal;">According the <a href="http://mercurial.selenic.com/wiki/WorkingWithSubversion#With_MQ_only">Mercurial wiki for working with subversion</a>, there&#8217;s a couple of different ways to do this. The easiest is to just do a normal <em>svn co </em>and then in that working directory do an <em>hg init</em> and just let the two share a workspace. </span></p>
<p><span style="font-weight: normal;">This sounds just short of insane, but it works out really well. Just make sure to tell both to ignore the other&#8217;s special directories (.hg, .svn). Once you do that the two get along really well. As you spin off hg branches locally, they won&#8217;t know/care that their parent is actually a svn directory. This allows you to check in to your heart&#8217;s content, but when it is time to push back to the svn repository, there will be only one change!</span></p>
<p><span style="font-weight: normal;">Of course, with the good there is also the not-so-good. Here&#8217;s somethings to be aware of. They aren&#8217;t necessarily bad, but like with hgsubversion you need to make sure you are using the right tool in the correct manner:</span></p>
<ul>
<li>One svn commit is one commit. &#8211; <span style="font-weight: normal;">When you make your commit into svn, the hg history disappears. 20 checkins? Svn only sees 1. This can be both good and bad, so make sure that your commit message relays all of the important messages your checkins express.</span></li>
<li>Only one commit message to svn &#8211; <span style="font-weight: normal;">If you are like me, you hate re-typing the same shit over and over. Committing to svn doesn&#8217;t involve the hg messages at all, so you will need to either copy-and-paste the last hg message, or type something new.</span></li>
<li>You need disciple with branch/directory names. &#8211; <span style="font-weight: normal;">Make sure you know what that directory is. This goes for most dev activites, but with the wild free for all that hg allows it gets really important. You can get turned around really easy, especially if you have multiple svn checkouts (i.e. different branches, etc.)</span></li>
</ul>
<p></strong></p>
<p>Overall I really like using hg. Making it work with svn has been a big bonus because now I can get the best of both worlds without having to abandon svn. (That&#8217;s a big bonus as most day jobs rely on svn!)</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/04/24/subversion-and-mercurial-in-the-same-place/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Being subversive with Subversion: Mercurial in the middle</title>
		<link>http://ironboundsoftware.com/blog/2010/02/25/being-subversive-with-subversion-mercurial-in-the-middle/</link>
		<comments>http://ironboundsoftware.com/blog/2010/02/25/being-subversive-with-subversion-mercurial-in-the-middle/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 03:41:52 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.ironboundsoftware.com/blog/?p=329</guid>
		<description><![CDATA[DVCS is a popular topic these days on the internets, but for those of us who code for our day job find that more often than not we have to use the tried-and-true standard of something like CVS. Or if you are lucky, SVN. Personally I think SVN is pretty good (especially compared to CVS), [...]]]></description>
			<content:encoded><![CDATA[<p>DVCS is a popular topic these days on the internets, but for those of us who code for our day job find that more often than not we have to use the tried-and-true standard of something like CVS. Or if you are lucky, SVN. Personally I think SVN is pretty good (especially compared to CVS), but the other day a feature of DVCS&#8217;s caught my eye.</p>
<p>The ability to branch quickly and in a lightweight manner is one of the major selling points of systems like Mercurial and Git. Recently I&#8217;ve been thinking about trying out some refactorings and that can be difficult to do when you need to make sure that you can have a build-able version of your code at all times. Some things just take time, and the whole point of refactoring is to improve your code so rushing through it to meet an unrelated code deadline just doesn&#8217;t make a lot of sense.</p>
<p>Enter <a href="http://mercurial.selenic.com">Mercurial</a>.</p>
<p>There&#8217;s a project for Mercurial called <a href="http://mercurial.selenic.com/wiki/HgSubversion">hgsubversion</a> that will allow you to pull from a subversion repository and make a mercurial repository locally. (Yes, git has something similar) Then you can hack away to your heart&#8217;s content using hg to branch and keep track of changes without pushing the changes out globally to the other SVN users.</p>
<p>This is exactly what all of the cool kids using hg, git, and bzr have been doing for years. Now those of us who talk to SVN can leverage this technique to bring a little more awesomeness to our day-to-day work, and no one is the wiser. At least that&#8217;s my theory.</p>
<p>Installing hgsubversion on a Mac or in Cygwin is like pulling teeth. I take that back, pulling teeth is not as painful. Plus you can leave your teeth under your pillow for some cash&#8230; but I digress. The best way to install it (for me at least) is to do the following:</p>
<ul>
<li>Have the following installed: mercurial, easy_install, the XCode tools (command line tools like gcc)</li>
<li>Get a copy of the python swig bindings for Subversion. <a href="http://www.collab.net/downloads/community/">Collab</a> has prebuilt binaries that seem to work best. I just copied the bindings from /opt/subversion/lib/svn-python/ to my python site-packages directory. I installed Python 2.6, so for me that path is: /Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/site-packages</li>
<li>Get hgsubversion by typing at the command line: <em><code>hg clone http://bitbucket.org/durin42/hgsubversion/ ~/hgsubversion</code></em></li>
<li>cd into ~/hgsubversion/ and type in <em>python setup.py install</em></li>
<li>For me, the system had to download a few things and build them, so make sure you have XCode and the 10.4 SDK installed. (I&#8217;m running XCode 3.2.1 for this exercise)</li>
<li>Hopefully everything completes normally. If it does, do a victory shot. If it fails, do 2 shots and then try to figure out what went wrong.</li>
<li>Next make a file in your home directory called .hgrc</li>
<li>Inside the file put the following:</li>
</ul>
<blockquote><p>[extensions]<br />
rebase=<br />
svn=/Users/&lt;YOUR USERNAME&gt;/hgsubversion/hgsubversion</p></blockquote>
<ul>
<li>This <strong>should</strong> tell hg that you&#8217;ve got something extra for it. I went blind sometime during my attempts to get this working and had a typo in that line that kept me from getting it working for an embarrassingly long time.</li>
<li>If you have done everything right, the moon is in the proper phase, and the wind is blowing from the NW at 7 mph, then this command should let you pull down a project from Google code:</li>
</ul>
<blockquote><p>hg clone svn+http://&lt;A PROJECT OF YOUR CHOICE&gt;.googlecode.com/svn &lt;WHATEVER DIR&gt;</p></blockquote>
<ul>
<li>The end result should be a mercurial repository on your local machine. Refer to the link for hgsubversion for more details about commands and links to other installation instructions. (Some are older than others, and the commands have changed a little bit over time.)</li>
</ul>
<p>So, that&#8217;s what I&#8217;m up to. Hopefully this will let me do some interesting experiments locally without sacrificing the safety blanket of using version control.</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2010/02/25/being-subversive-with-subversion-mercurial-in-the-middle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test with big data sets</title>
		<link>http://ironboundsoftware.com/blog/2009/11/21/test-with-big-data-sets/</link>
		<comments>http://ironboundsoftware.com/blog/2009/11/21/test-with-big-data-sets/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 00:01:36 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.ironboundsoftware.com/blog/?p=326</guid>
		<description><![CDATA[Every so often I re-learn this lesson: Make sure you test your code with the same amount of data that your users will use. Developing with small data sets is fine, and most of the time that is what you want to do as you work out the kinks of the code. But when it [...]]]></description>
			<content:encoded><![CDATA[<p>Every so often I re-learn this lesson: Make sure you test your code with the same amount of data that your users will use.</p>
<p>Developing with small data sets is fine, and most of the time that is what you want to do as you work out the kinks of the code. But when it is time to ship the code, you must test with a large data set.</p>
<p>For rent my resume.com I&#8217;ve been testing one portion of it with 4 different size documents. This is a fluke however, I chose the documents based on the contents not the size. Today I made a simple change that turned out to have some unforeseen ripple effects.</p>
<p>When I write unit tests, they seem to fall into two categories: Tests where I just do a simple check on the size of a return (i.e. did I get 21 items in the list?), and tests where I check the contents of the resulting data.</p>
<blockquote><p>As a side note, you should really do both kinds of tests, not one or the other. Simply checking to see that the right number of things was returned is no substitute for making sure that the correct data was actually returned!</p></blockquote>
<p>Today I was re-running my pyunit tests and one of the four failed because the size of the returned list wasn&#8217;t what was expected. By coincidence this happened to be the biggest data set I was testing with. If I had not had this test, I would have thought everything was ok, but it truth my modified function is returning questionable data!</p>
<p>There are of course other benefits of using larger data sets, mainly seeing how your code works under stress. What works fine for 10 items might not be so great with 1000 items. Testing with a large data set at the end will help catch these problems and will also help you adhere to Knuths&#8217; advice to not optimize code prematurely.</p>
<p>So, now I&#8217;m off to learn how to trace through python code to find out how such a seemingly simple &#8220;fix&#8221; to my code could so subtly break it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2009/11/21/test-with-big-data-sets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rate-my-resume.com is now live</title>
		<link>http://ironboundsoftware.com/blog/2009/10/11/rate-my-resume-com-is-now-live/</link>
		<comments>http://ironboundsoftware.com/blog/2009/10/11/rate-my-resume-com-is-now-live/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 22:27:07 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ironboundsoftware.com/blog/?p=311</guid>
		<description><![CDATA[In my last post, I put up a link to a little project I&#8217;ve been working on. I finally got around to giving it a proper name. (re)Introducing: Rate-my-resume.com Now if you are wondering if your resume is a good match for a particular job posting, you can use my site to find out! At [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, I put up a link to a little project I&#8217;ve been working on. I finally got around to giving it a proper name. (re)Introducing:</p>
<p><a href="http://rate-my-resume.com">Rate-my-resume.com</a></p>
<p>Now if you are wondering if your resume is a good match for a particular job posting, you can use my site to find out! At the moment I&#8217;m giving the score in terms of 0 (being a total non-match) to 100 (being the absolute perfect match). In this economy, the more your resume reflects the skills listed in a particular job, the more likely your resume will be looked at seriously.</p>
<p>If you run your resume through and it gives you a low score, look at your resume and the job posting and try and figure out what keywords are in the job posting that are not in your resume. Then, assuming you have the necessary experience, put those keywords into your resume! Be sure to add them in a way that makes sense to a person, after all humans (especially HR people) don&#8217;t like to read fragments and words peppered into someone&#8217;s resume.</p>
<p><a href="http://rate-my-resume.com">Try out the site with your resume and see how you rank! </a></p>
<p>p.s. Python rocks!</p>
]]></content:encoded>
			<wfw:commentRss>http://ironboundsoftware.com/blog/2009/10/11/rate-my-resume-com-is-now-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

