﻿<?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>Programming By A Tool &#187; Uncategorized</title>
	<atom:link href="http://byatool.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://byatool.com</link>
	<description>This is my recorded stumbling through ASP.Net, Framework 3.5, C# 3.0, Ajax, Javascript, and Love.  Stay, learn, destroy.  It's your life.</description>
	<lastBuildDate>Thu, 03 May 2012 17:28:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Culture shock of scaling back from full-time work&#8230;</title>
		<link>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/</link>
		<comments>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 18:22:24 +0000</pubDate>
		<dc:creator>Amy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[IT Life]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=2355</guid>
		<description><![CDATA[As a blessing, my husband recently got promoted to full-time status at his job.  This meant that I was able to leave my full-time job that was interesting, but demanding and stressful.  After a few weeks of re-calibrating and getting a lot of home projects finished, I found that I really missed writing and coding.  [...]]]></description>
			<content:encoded><![CDATA[<p>As a blessing, my husband recently got promoted to full-time status at his job.  This meant that I was able to leave my full-time job that was interesting, but demanding and stressful.  After a few weeks of re-calibrating and getting a lot of home projects finished, I found that I really missed writing and coding.  I wrote a few simple things to get warmed up, but I&#8217;m really glad that I did because it&#8217;s breathtaking how quickly those skills will slip if you don&#8217;t use them often.</p>
<p>I, like many young (okay, youngish) moms with kids in school, would like to find something useful and if possible profitable to do in the 6 or so hours a day while the kids are away.  I&#8217;m finding that getting part-time or freelance work isn&#8217;t as easy as I thought.  The consensus that I&#8217;ve read has been that for the most part, you&#8217;re going to have to tap all your network of peers/friends/family to get leads then start out working for little to no pay in order to build a reputation.  I pretty much suspected this, but what I didn&#8217;t fully realize is something my sister brought up:</p>
<p>&#8220;Contracting/consulting can be awful in usually two ways: 1) What is available is the bottom of the barrel, makes no sense, and nobody else will work on it.  2) The project is interesting, but it has become a steaming pile of spaghetti code and they want you to wave your magic mouse and have it all fixed two weeks ago for next to nothing.&#8221;</p>
<p>So&#8230; here&#8217;s my dilemma.  I want to be able to work part-time or telecommute so that I can keep my 10+ years of experience and skills sharp, but I would like to eventually get paid.</p>
<p>What I can&#8217;t understand is why more companies don&#8217;t allow their IT employees to have more flexibility provided that they well document the work they do and get it in on time.  Especially because office space is a premium and gas prices are through the roof right now.  In Pittsburgh, we have spectacularly bad traffic and highway infrastructure.  If business owners know how expensive it is for employees to commute/park/bus downtown, why don&#8217;t they give them the option to take a small pay cut and telecommute?  Both sides win that way.</p>
<p>Anyway, in the meantime while I&#8217;m fishing for contract leads, I&#8217;d like to start developing some small bite-sized projects.  jQuery and Javascript are good and familiar to me so far, but do the readers have any suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/culture-shock-of-scaling-back-from-full-time-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Off Topic:  Finally Hit 500 on Deadlift</title>
		<link>http://byatool.com/uncategorized/off-topic-finally-hit-500-on-deadlift/</link>
		<comments>http://byatool.com/uncategorized/off-topic-finally-hit-500-on-deadlift/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 14:53:11 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Pointless]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Lifting]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1968</guid>
		<description><![CDATA[Yeah I know, kind of lame to announce this on a programming blog, but this is a huge thing for me. I&#8217;ve come close to 500 quite a few times but there was always something that set me back. It isn&#8217;t the best lift ever, but still happy with it overall as I didn&#8217;t cheat [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah I know, kind of lame to announce this on a programming blog, but this is a huge thing for me.  I&#8217;ve come close to 500 quite a few times but there was always something that set me back.  It isn&#8217;t the best lift ever, but still happy with it overall as I didn&#8217;t cheat the pull in any way.  And as making claims without proof on the internet is pretty common, I figured I&#8217;d post the video.  </p>
<p>Looking to set a new personal record on the bench at 330 this week.  325 is something that I&#8217;ve done on a few occasions, but like I said, something always came up.</p>
<p>WARNING:  Sound is probably bad unless you want to hear a nerd war cry at the end&#8230; That and apparently I swore at the end too.</p>
<p><object width="400" height="224" ><param name="allowfullscreen" value="true" /><param name="movie" value="http://www.facebook.com/v/1429248910453" /><embed src="http://www.facebook.com/v/1429248910453" type="application/x-shockwave-flash" allowfullscreen="true" width="400" height="224"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/off-topic-finally-hit-500-on-deadlift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mock SQLAlchemy scoped_session query and Why Python is My BFF</title>
		<link>http://byatool.com/uncategorized/mock-sqlalchemy-scoped_session-query-and-why-python-is-my-bff/</link>
		<comments>http://byatool.com/uncategorized/mock-sqlalchemy-scoped_session-query-and-why-python-is-my-bff/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 15:55:10 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1954</guid>
		<description><![CDATA[sqlAlchemy has sessionmaker to create a session from which you can use query to get whatever you need. For example: someSession.query(SomeTableRepresentationObject).filter...ect If you&#8217;ve used sqlalchemy, nothing new going on here but it wouldn&#8217;t be me if I didn&#8217;t point out the obvious and take three sentences to do so. Now what you may run into [...]]]></description>
			<content:encoded><![CDATA[<p>sqlAlchemy has sessionmaker to create a session from which you can use query to get whatever you need.  For example:</p>
<pre>someSession.query(SomeTableRepresentationObject).filter...ect</pre>
<p>If you&#8217;ve used sqlalchemy, nothing new going on here but it wouldn&#8217;t be me if I didn&#8217;t point out the obvious and take three sentences to do so.</p>
<p>Now what you may run into is something like this:</p>
<pre><span style="color: #0000ff;">def</span> getCountOfUsersByUserName(userName, session):
  <span style="color: #0000ff;">return</span> session.query(<span style="color: #008080;">User</span>).filter(<span style="color: #008080;">User</span>.userName == userName).count()</pre>
<p>Ok now that I typed that out, I see it&#8217;s kind of a dumb method.  But f&#8211;k it, what&#8217;s done is done.</p>
<p>Now from a testing situation, this could look tough. After all if you come from a more static language background like I did, you should know how hard things can be to mock at times.  (.Net Session&#8230; I&#8217;m looking at you with judging eyes.  Sooooo judging.)  But this isn&#8217;t a static language, it&#8217;s Python.</p>
<p>For purposes of making things less confusing, which is hard for me, when I use the word &#8220;Object&#8221; I mean method OR class.  And remember as always, &#8220;banana&#8221; is the safe word.</p>
<p>You see, to mock that out all you need is an object that has a query object that takes in something and a filter object on the query object that takes in something and has a count method on it.  Yeah that totally makes sense.  Try working it backward.</p>
<p>Filter has one parameter and a count method on it.  Whatever that parameter is, it doesn&#8217;t matter since it is Python.  As long as Filter takes in one parameter, you have a winner.</p>
<p>Query, like Filter, takes in one parameter and has a object named Filter on it.  Once again, it doesn&#8217;t matter what&#8217;s passed into Query, just that it takes something in.</p>
<p>Session is basically an object that has no parameters and has a Query object on it.</p>
<p>Now in a static language, this would be annoying.  You would need 3 interfaces and mock a whole ton of stuff dynamically with something like <a href="http://www.ayende.com/projects/rhino-mocks.aspx"> Rhino Mocks</a> or just create a bunch of classes of those interfaces that you can pass in.  Either way, there are complications.  Once you get into things like Web Session or ViewState, it&#8217;s a ton of work.  Python?  Eh, you can do it in 20ish lines.  How you ask?  Well I&#8217;ll show you how!</p>
<pre>	<span style="color: #0000ff;">class</span> mockFilter(object): <span style="color: #008000;">#This is the ONE parameter constructor</span>
		<span style="color: #0000ff;">def</span> __init__(self):
			self._count = 0
			self._first = <span style="color: #008080;">dynamicObject</span>()

		<span style="color: #0000ff;">def</span> first(self):  <span style="color: #008000;">#This is the another method that's just coming along for the ride.</span>
			<span style="color: #0000ff;">return</span> self._first

		<span style="color: #0000ff;">def</span> count(self):  <span style="color: #008000;">#This is the needed Count method</span>
			<span style="color: #0000ff;">return</span> self._count

	<span style="color: #0000ff;">class</span> mockQuery(object):<span style="color: #008000;"> #This is the ONE parameter constructor</span>
		<span style="color: #0000ff;">def</span> __init__(self):
			self._filter = <span style="color: #008080;">mockFilter</span>()

		<span style="color: #0000ff;">def</span> filter(self, placeHolder):<span style="color: #008000;"> #This is used to mimic the query.filter() call</span>
			<span style="color: #0000ff;">return</span> self._filter 

	<span style="color: #0000ff;">class</span> mockSession(object):
		<span style="color: #0000ff;">def</span> __init__(self):
			self._query = <span style="color: #008080;">mockQuery</span>()
			self.dirty = []

		<span style="color: #0000ff;">def</span> flush(self):
			<span style="color: #0000ff;">pass</span>

		<span style="color: #0000ff;">def</span> query(self, placeHolder):  <span style="color: #008000;">#This is used to mimic the session.query call</span>
			<span style="color: #0000ff;">return</span> self._query

  <span style="color: #008000;">#and this... </span><a href="http://www.youtube.com/watch?v=ETgk56xT4Mk"><span style="color: #008000;">THIS IS SPARTA!!1111</span></a><span style="color: #008000;">... yeah I know, I'm about 3 years too late on that joke.</span></pre>
<p>How does this work?  Say I have the method from above:</p>
<pre><span style="color: #0000ff;">def</span> getCountOfUsersByUserName(userName, session):
  <span style="color: #0000ff;">return</span> session.query(<span style="color: #008080;">User</span>).filter(<span style="color: #008080;">User</span>.userName == userName).count()</pre>
<p>I could test it using this:</p>
<pre>  session = mockSession()
  session.query(<span style="color: #800000;">''</span>).filter(<span style="color: #800000;">''</span>)._count = 0 <span style="color: #008000;">#Initialize the mock session so it returns 0 from count()</span>

  getCountOfUsersByUserName(<span style="color: #800000;">'sadas'</span>, session)</pre>
<p>And boom, you have mocking in ten minutes or less or your code is free.</p>
<p>As you can see, the highly dynamic nature of Python makes it a great fit for any project that will need unit tests and mocking.  And which project doesn&#8217;t?  You know what I&#8217;m sayin&#8217;?  You now what I&#8217;m saying&#8217;?  High five!</p>
<p>Note:  dynamicObject is <a href="http://byatool.com/pontification/python-double-tee-eff-exclamation-mark-one-one/">&#8230;. nothing but a cheesy class that inherits Object but has nothing on it. (Turns out that if I did someObject = Object() I couldnâ€™t do this since Object by default doesnâ€™t contain the ability to add things dynamicallyâ€¦ and this was by design.)</a></p>
<p>And yes, I just quoted myself.  I am that awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/mock-sqlalchemy-scoped_session-query-and-why-python-is-my-bff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dear Microsoft,</title>
		<link>http://byatool.com/uncategorized/dear-microsoft/</link>
		<comments>http://byatool.com/uncategorized/dear-microsoft/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 19:00:00 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1220</guid>
		<description><![CDATA[If it takes a whole paragraph to explain what &#8220;continue&#8221; means,Â  maybe you should rethink the button text and/or layout. Sincerely, Sean]]></description>
			<content:encoded><![CDATA[<p>If it takes a whole paragraph to explain what &#8220;continue&#8221; means,Â  maybe you  should rethink the button text and/or layout.</p>
<p>Sincerely,</p>
<p>Sean</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/dear-microsoft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pop Question:  Why does this error exist?</title>
		<link>http://byatool.com/uncategorized/pop-question-why-does-this-error-exist/</link>
		<comments>http://byatool.com/uncategorized/pop-question-why-does-this-error-exist/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 17:35:50 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=498</guid>
		<description><![CDATA[So I was searching for something today and came across this: Real page. Can you find the (possible) humor in this and why you don&#8217;t allow error pages like this to EVER show?]]></description>
			<content:encoded><![CDATA[<p>So I was searching for something today and came across this:</p>
<pre>
<img src="http://byatool.com/wp-content/uploads/2009/02/erorbad.png" alt="Whoa Boy" title="Whoa Boy" width="957" height="363"/>
</pre>
<p>Real page.  Can you find the (possible) humor in this and why you don&#8217;t allow error pages like this to EVER show?</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/uncategorized/pop-question-why-does-this-error-exist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

