<?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>{ Code: Impossible } &#187; software development</title>
	<atom:link href="http://codeimpossible.com/tag/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeimpossible.com</link>
	<description>this = HowI.Roll();</description>
	<lastBuildDate>Thu, 09 Sep 2010 15:45:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Works on my machine weekly project #1</title>
		<link>http://codeimpossible.com/2009/04/05/works-on-my-machine-weekly-project-1/</link>
		<comments>http://codeimpossible.com/2009/04/05/works-on-my-machine-weekly-project-1/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 04:34:49 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://codeimpossible.com/?p=347</guid>
		<description><![CDATA[Download the source code mentioned in this blog post.
 
I&#8217;m a hopeless code junkie. I love to write code. Most people do one thing for work and then another for their hobby. My girlfriend for instance works as an IT / Systems Engineer  and her other thing is photography.
My other thing is writing more code. I never [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.box.net/shared/hacsh3b3s4" target="_blank">Download the source code mentioned in this blog post.</a></p>
<p> </p>
<p><img class="alignleft" title="works-on-my-machine-starburst" src="http://wpup.codeimpossible.com/2009/06/works-on-my-machine-starburst.jpg" alt="works-on-my-machine-starburst" />I&#8217;m a hopeless code junkie. I love to write code. Most people do one thing for work and then another for their hobby. My girlfriend for instance works as an IT / Systems Engineer  and her other thing is photography.</p>
<p><em>My</em> other thing is writing <strong>more</strong> code. I never did this with any of my previous jobs (save dish washer&#8230; I did wash dishes when I was at home but I wasn&#8217;t trying out new, cooler ways to wash them).</p>
<p>&#8230; So where was I? Oh, right code junkie. So, I really like to write code and what I&#8217;ve decided to do is start a new small project each week and try to use some new chunk of .Net or a new library and I&#8217;ll post the end results of my efforts here for you all.</p>
<p>All of these projects will be offered under the CodeImpossible &#8220;works on my machine&#8221; code quality guarantee. But I&#8217;ll never post something that flat-out doesn&#8217;t work.</p>
<p>Sound good? Cool, let&#8217;s kick it off &#8211; as the first entry into this space I&#8217;d like to present <strong>TweetCommander</strong>.</p>
<p>TweetCommander is a small .Net v3.5 console application that lies in wait, watching a twitter account for any new Direct Messages from another user (we&#8217;ll call this person the &#8220;owner&#8221;).</p>
<p>When a direct message from the owner is found, TweetCommander will check to see if it contains certain text, and depending on that text, will perform a series of actions on the machine it is running on.</p>
<p>TweetCommander will support three commands: &#8220;current_screenshot&#8221;, &#8220;exit&#8221;, and &#8220;set_interval&#8221;.</p>
<ul>
<li>Sending &#8220;current_screenshot&#8221; will tell TweetCommander to take a screen capture of the Windows desktop, upload it to TwitPic, and then send the url for that image to the owner user in a Direct Message.</li>
<li>Sending &#8220;exit&#8221; will cause TweetCommander to exit</li>
<li>The &#8220;set_interval&#8221; is followed by a number that represents the number of seconds TweetCommander should wait between requests for new direct messages from twitter. This is more to avoid the API limit than anything else.</li>
</ul>
<p><strong>Settings</strong><br />
TweetCommander will need to store the Twitter ID for the last successfully processed Direct Message somewhere so we aren&#8217;t constantly processing the same commands over and over again. The end user won&#8217;t need to be aware of this value but it&#8217;s worth mentioning anyway.</p>
<p>We&#8217;ll also need to store the wait interval so we don&#8217;t lose this information if we need to restart TweetCommander for whatever reason.</p>
<p>Okay, so here is the settings file I have so far:</p>
<p><img class="aligncenter size-full wp-image-348" title="tweet_mon_console_settings" src="http://wpup.codeimpossible.com/2009/04/tweet_mon_console_settings.jpg" alt="tweet_mon_console_settings" width="473" height="170" /></p>
<p><strong>Working with Twitter</strong><br />
All right so now we need to be able to interact with Twitter. Now, I don&#8217;t want to write my own API library so I&#8217;ll <a href="http://code.google.com/p/tweetsharp" target="_blank">go out and get the latest copy of TweetSharp</a> which will give me a nice, readable interface to twitter&#8217;s API. After getting this built I&#8217;ll be able to get the most recent direct messages using the following code:</p>
<pre class="prettyprint"><code>
var directMessages = FluentTwitter.CreateRequest()
	.AuthenticateAs(
		TWITTERACCOUNT_USERNAME,
		TWITTERACCOUNT_PASSWORD)
	.DirectMessages()
	.Received()
	.Since(Properties
		.Settings
		.Default
		.LastProcessedCommandID)
	.AsJson()
	.Request()
	.AsDirectMessages();
</code></pre>
<p>Thats pretty freakin&#8217; sweet I must say. Tweet# really takes the brain work out of working with twitter and there is no way to look at that code and <strong>not</strong> understand what it is doing immediately. Epic win.</p>
<p>To get this running on your machine, just<a href="http://www.box.net/shared/hacsh3b3s4" target="_blank"> grab the source from my box.net folder</a>, and change these values at the top of the Program.cs file:</p>
<pre class="prettyprint"><code>
// this is our "owner account" we will only act upon direct messages
// send from this user
private static string TWITTEROWNER  = "codeimpossible"; 

// this is our listener accounts username
private static string TWITTERACCOUNT_USERNAME = "someuser";

// this is our listener accounts password
private static string TWITTERACCOUNT_PASSWORD = "somepassword";
</code></pre>
<p><em>Note: The solution file for this contains a reference to a compiled version of  the Tweet# library that contains </em><a href="http://code.google.com/p/tweetsharp/issues/detail?id=36"><em>a quick patch I made for an issue that affects uploading an image to Twitpic</em></a><em>. However this issue has been fixed officially in the most recent source.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://codeimpossible.com/2009/04/05/works-on-my-machine-weekly-project-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
