<?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></title>
	<atom:link href="http://codeonaboat.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeonaboat.wordpress.com</link>
	<description></description>
	<lastBuildDate>Tue, 21 Feb 2012 21:40:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codeonaboat.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title></title>
		<link>http://codeonaboat.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codeonaboat.wordpress.com/osd.xml" title="" />
	<atom:link rel='hub' href='http://codeonaboat.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Yui Compressor issues with reserved words in JavaScript</title>
		<link>http://codeonaboat.wordpress.com/2012/02/21/yui-compressor-bombs-on-reserved-words-in-javascript/</link>
		<comments>http://codeonaboat.wordpress.com/2012/02/21/yui-compressor-bombs-on-reserved-words-in-javascript/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 21:21:33 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://codeonaboat.wordpress.com/?p=282</guid>
		<description><![CDATA[For the life of me, I could not figure out why I was getting an error while running the Yui compressor on a set of my JavaScript files. The error was very generic and not helpful error : Failed to &#8230; <a href="http://codeonaboat.wordpress.com/2012/02/21/yui-compressor-bombs-on-reserved-words-in-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=282&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the life of me, I could not figure out why I was getting an error while running the Yui compressor on a set of my JavaScript files.</p>
<p>The error was very generic and not helpful</p>
<p><span style="color:#ff0000;">error : Failed to read in the data for the path/file [..\&lt;path&gt;\&lt;filename&gt;]. The most common cause for this is because the path is incorrect or the file name is incorrect &#8230; so please check your path and file names. Until you fix this up, I can&#8217;t continue &#8230; sowwy.</span></p>
<p>The file was present and seemed to be syntactically correct and all.</p>
<p>Finally, thanks to a little squiggly placed by Resharper (which is awesome!!), I found the issue. One of the js functions was called “goto” and that, apparently is reserved by JavaScript for “future use”, and Yui bombs on it.</p>
<p>Renaming it fixed the issue.</p>
<p><strong>UPDATE</strong></p>
<p>To be clear, the YUI compressor is behaving as it was designed to. Reserved words should not be used in JavaScript, as in other languages. However, I will say that the error dumped out when the compressor runs into a reserved word could be better.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/282/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=282&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2012/02/21/yui-compressor-bombs-on-reserved-words-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>Crazy Idea of the Day &#8211; Product Placement in Google Streeview</title>
		<link>http://codeonaboat.wordpress.com/2012/02/20/crazy-idea-of-the-day-product-placement-in-google-streeview/</link>
		<comments>http://codeonaboat.wordpress.com/2012/02/20/crazy-idea-of-the-day-product-placement-in-google-streeview/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 13:59:19 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codeonaboat.wordpress.com/?p=279</guid>
		<description><![CDATA[I was looking up the street view for the Met, and this is what the view from Columbus Avenue looks like. Fresh Direct guys are every where in NYC but not so sure this was unintentional! That&#8217;s some prime product &#8230; <a href="http://codeonaboat.wordpress.com/2012/02/20/crazy-idea-of-the-day-product-placement-in-google-streeview/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=279&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking up the street view for the Met, and this is what the view from Columbus Avenue looks like. Fresh Direct guys are every where in NYC but not so sure this was unintentional! That&#8217;s some prime product placement for a great NYC Startup.</p>
<p>Just FYI, this is on 02/20/2012.</p>
<p><a href="http://codeonaboat.files.wordpress.com/2012/02/freshdirectproductplacement.png"><img class="alignnone size-full wp-image-280" title="Fresh Direct Product Placement on Google Maps" src="http://codeonaboat.files.wordpress.com/2012/02/freshdirectproductplacement.png?w=640&#038;h=356" alt="" width="640" height="356" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=279&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2012/02/20/crazy-idea-of-the-day-product-placement-in-google-streeview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>

		<media:content url="http://codeonaboat.files.wordpress.com/2012/02/freshdirectproductplacement.png" medium="image">
			<media:title type="html">Fresh Direct Product Placement on Google Maps</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server 2008 &#8211; Creating a database from a .bak file</title>
		<link>http://codeonaboat.wordpress.com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/</link>
		<comments>http://codeonaboat.wordpress.com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 05:21:50 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[sql server 2008]]></category>

		<guid isPermaLink="false">http://codeonaboat.wordpress.com/?p=262</guid>
		<description><![CDATA[I&#8217;m not a database expert! Every so often I run into something that seems so simple that should just work but doesn&#8217;t. Searching for solution is a tedious chore of sifting through jargon and unclear explanations, somehow more so in &#8230; <a href="http://codeonaboat.wordpress.com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=262&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not a database expert!</p>
<p>Every so often I run into something that seems so simple that should just work but doesn&#8217;t. Searching for solution is a tedious chore of sifting through jargon and unclear explanations, somehow more so in database land than with other technologies&#8230; what is it with these &#8220;database types&#8221;?</p>
<p>Anyways, creating a database from a .bak file was one of those things. In SSMS, it should really be as simple as</p>
<p>1. Choose the .bak file<br />
2. Give a name to the destination database<br />
3. Press Go</p>
<p>But it&#8217;s not. Yes, there are probably good reason for it&#8230; actually no, all those good reasons are just travesty!</p>
<p>By default, you can only restore databases from .bak files that were created from them. If you try to do something else, you will get the following error.</p>
<p style="text-align:center;"><a href="http://codeonaboat.files.wordpress.com/2012/02/backupsetholdsbackupof1.png"><img class="size-full wp-image-266 aligncenter" title="Error while restoring from a .bak file" src="http://codeonaboat.files.wordpress.com/2012/02/backupsetholdsbackupof1.png?w=640" alt=""   /></a></p>
<p>Similarly if you try to restore using T-SQL</p>
<pre><span style="color:#800000;">RESTORE DATABASE newdatabase</span>
<span style="color:#800000;">FROM DISK = 'c:\DatabaseBackups\dev2012021601.bak'</span></pre>
<p>You will see the following error if the database &#8220;newdatabase&#8221; already exists</p>
<pre><span style="color:#800000;">Msg 3154, Level 16, State 4, Line 1</span>
<span style="color:#800000;">The backup set holds a backup of a database other than the existing 'jb' database.</span>
<span style="color:#800000;">Msg 3013, Level 16, State 1, Line 1</span>
<span style="color:#800000;">RESTORE DATABASE is terminating abnormally.</span></pre>
<p><span style="color:#333333;">or something like this one if it doesn&#8217;t already exist</span></p>
<pre><span style="color:#800000;">Msg 1834, Level 16, State 1, Line 1</span>
<span style="color:#800000;">The file 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\devdb.mdf' cannot be overwritten. It is being used by database 'devdb'.</span>
<span style="color:#800000;">Msg 3156, Level 16, State 4, Line 1</span>
<span style="color:#800000;">File 'dbname' cannot be restored to 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\devdb.mdf'. Use WITH MOVE to identify a valid location for the file.</span>
<span style="color:#800000;">Msg 1834, Level 16, State 1, Line 1</span>
<span style="color:#800000;">The file 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\devdb_1' cannot be overwritten. It is being used by database 'devdb'.</span>
<span style="color:#800000;">Msg 3156, Level 16, State 4, Line 1</span>
<span style="color:#800000;">File 'devdb_log' cannot be restored to 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\devdb_1.ldf'. Use WITH MOVE to identify a valid location for the file.</span>
<span style="color:#800000;">Msg 3119, Level 16, State 1, Line 1</span>
<span style="color:#800000;">Problems were identified while planning for the RESTORE statement. Previous messages provide details.</span>
<span style="color:#800000;">Msg 3013, Level 16, State 1, Line 1</span>
<span style="color:#800000;">RESTORE DATABASE is terminating abnormally.</span></pre>
<p><span style="color:#333333;">If that&#8217;s where you are stuck, the following will help you. </span></p>
<p><span style="color:#333333;">1. In SSMS, open  a query window in the master database of the database server. That&#8217;s where you will run the following queries.</span></p>
<p><span style="color:#333333;">2. See what the &#8220;LogicalName&#8221; of the database that has been backed up in the .bak file is </span></p>
<pre><span style="color:#800000;">RESTORE FILELISTONLY </span>
<span style="color:#800000;">FROM DISK = 'c:\DatabaseBackups\dev2012021601.bak'</span></pre>
<p>This will give you the logical name of the database and its associated log file. Lets assume that the names are &#8220;dbname&#8221; and &#8220;dbname_log&#8221;</p>
<p>3. Now run the following restore command. Make sure that the database &#8220;newdatabase&#8221; doesn&#8217;t already exist.</p>
<pre><span style="color:#800000;">RESTORE DATABASE newdatabase </span>
<span style="color:#800000;">FROM DISK = 'c:\DatabaseBackups\dev2012021601.bak' </span>
<span style="color:#800000;">WITH </span>
<span style="color:#800000;">MOVE 'dbname' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\newdatabase.mdf', </span>
<span style="color:#800000;">MOVE 'dbname_log TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\newdatabase_log.mdf'</span></pre>
<p><span style="color:#333333;"> </span>C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA is the directory where SQL Express usually keeps its data files. You can find the directory your database server is using by selecting a database from it, right clicking and opening the properties dialog and selecting the &#8220;Files&#8221; option from the left.</p>
<p>That should work, and at that point you should be able to access the database &#8220;newdatabase&#8221; populated with all the tables and data from the .bak file.</p>
<p>Good Luck!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/262/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=262&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2012/02/16/sql-server-2008-creating-a-database-from-a-bak-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>

		<media:content url="http://codeonaboat.files.wordpress.com/2012/02/backupsetholdsbackupof1.png" medium="image">
			<media:title type="html">Error while restoring from a .bak file</media:title>
		</media:content>
	</item>
		<item>
		<title>Uploading a file to Amazon S3 using an ASP.NET MVC application directly from the user&#8217;s browser</title>
		<link>http://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/</link>
		<comments>http://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 17:34:42 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[amazon s3]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[mvc3]]></category>
		<category><![CDATA[view]]></category>
		<category><![CDATA[viewmodel]]></category>

		<guid isPermaLink="false">https://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/</guid>
		<description><![CDATA[Amazon S3 is a service where you can store large (or small) files. It is organized in terms of “buckets” so before you can store any thing under your account, you have to create a bucket first (or have access &#8230; <a href="http://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=250&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/s3">Amazon S3</a> is a service where you can store large (or small) files. It is organized in terms of “buckets” so before you can store any thing under your account, you have to create a bucket first (or have access to an existing one). Then you can specify the bucket you want to upload the file into, along with other required pieces of information and even your own metadata. </p>
<p>That is a great solution for a lot of web applications, specially those that are already utilizing Amazon’s web services. And being able to upload directly to Amazon S3 from the user’s browser is important because it saves bandwidth and CPU cycles for you as the application owner and time for everyone involved.</p>
<p><font color="#ffc000"><font color="#800000"><font size="4"><strong>Obviously there are a couple of issues here</strong>!</font></font></font></p>
<p>1. How do you get a user’s browser to bypass your web application, and upload a file directly to Amazon S3’s storage.</p>
<p>2. How do you ensure that the user’s browser communicates only with Amazon S3 and not an impersonator.</p>
<p>3. How do you ensure that none of the parameters of the upload; things like bucket name, the file’s ACL on S3, and other metadata you might specify, are changed by the user or any intermediary during this process (since the upload is not going though your application). </p>
<p>Fortunately there are solutions for each of the above and really at the end of the day it boils down to the same ol’ trick that most cryptography relies on: symmetric and asymmetric keys. I’ll present the code I used to implement this using an ASP.NET MVC application using C# right after I explain the solution in the far more complicated language of English.</p>
<p><strong><font color="#800000" size="4">Solutions</font></strong></p>
<p>1. This one is simple. An HTML form that has a “method” of “post” and an “action” that points to the correct Amazon S3 URI for your bucket will do the trick. Off course the form also needs to have an “input” of type “file” and an “input” of type “submit”. Besides this all the other parameters of the upload; both those that are required by Amazon S3 and others that you might want to store for your purposes, are added as hidden “input” fields to the form.</p>
<p>2. This one is simple too. Just ensure that the form’s action is specified with “https” as the protocol. </p>
<p>Something like this</p>
<p><a href="https://myas3bucket.s3.amazonaws.com"><font color="#808000" size="2" face="Courier New">https://myas3bucket.s3.amazonaws.com</font></a></p>
<p>This will cause the browser to use SSL to communicate with Amazon and the usual handshake, certificate lookup and encryption that goes along with it will ensue.</p>
<p>3. The solution for this is more complicated and judging from the buzz on the web is a source of frustration for many a web developers, and more so for ASP.NET developers because there are not many good code examples available online. The solution boils down this; create a string that has all the parameters of the upload, and then hash that string using your Amazon S3 private key and the HMAC SHA1 algorithm. Upload both that string with the upload parameters and the hash generated using the private key with the HTML form created in step 1, as hidden “input” fields. When Amazon S3 receives the form, it will de-hash the hash (since they have access to your private key), and compare it to the upload parameter string, and to the actual upload parameters. If they match up, they know that the upload parameters were not tampered with, otherwise, they will reject the upload. No one else can generate the correct hash because no one else has your Amazon S3 private key (well, at least that you know about!).</p>
<p>There you have it. Now… </p>
<p><strong><font color="#800000" size="4">Lets move on to the ASP.NET MVC&#160; implementation</font></strong></p>
<p>I was using MVC3 and Razor as my view engine. If you’re new to ASP.NET MVC, you probably want to spend a little time understanding the basics. </p>
<p><strong><font color="#808000">First the ViewModel</font></strong></p>
<p>The members of my ViewModel class are basically the things that the view needs to create the form with it hidden and visible fields, and the form action, method and encapsulation type.</p>
<pre class="csharpcode"><font size="2"><span class="kwrd">public</span> <span class="kwrd">class</span> FileUploadViewModel
{
	<span class="kwrd">public</span> <span class="kwrd">string</span> FormAction { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> FormMethod { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> FormEnclosureType { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> Bucket { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> FileId { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> AWSAccessKey { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> RedirectUrl { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> Acl { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> Base64Policy { get; set; }
	<span class="kwrd">public</span> <span class="kwrd">string</span> Signature { get; set; }
}
</font></pre>
<p><strong><font color="#808000">Next the code to generate an instance of the ViewModel</font></strong></p>
<p>You could package this code as a part of another library or as a part of the helpers in your MVC solution but for this example, I’m not going to get into that.</p>
<p>The key part here is off course the generation of the policy string and then generating the signature, which involves taking the hash of the policy string using your Amazon S3 private key and the HMAC SHA1 hashing algorithm. Having a foundational understanding of encodings and string formats is helpful as always. As Joel and many others have <a href="http://www.joelonsoftware.com/articles/Unicode.html">said</a>, you should familiarize yourself with <a href="http://en.wikipedia.org/wiki/Base64">base64</a> and also what a <a href="http://csharpindepth.com/Articles/General/Strings.aspx">strings and “encoding”</a> mean, specially in .NET.</p>
<p>First lets look at the policy string. The policy string (also called the policy document or the “Access Control” document) must adhere to the rules specified in Amazon S3’s <a href="http://doc.s3.amazonaws.com/proposals/post.html#Access_Control">documentation</a>. You should familiarize yourself with the syntax of the policy string described in it. In the end for my case it ended up looking like like this.</p>
<pre class="csharpcode"><font size="2">
{
	&quot;expiration&quot;: &quot;2011-04-20T11:54:21.032Z&quot;,
  	&quot;conditions&quot;: [
    		[&quot;eq&quot;, &quot;acl&quot;, &quot;private&quot;],
    		[&quot;eq&quot;, &quot;bucket&quot;: &quot;myas3bucket&quot;],
    		[&quot;eq&quot;, &quot;$key&quot;, &quot;myfilename.jpg&quot;],
    		[&quot;content-length-range&quot;, 0, 20971520],
    		[&quot;eq&quot;, &quot;$redirect&quot;, &quot;myredirecturl&quot;],
	]
}
</font></pre>
<p>I used a class marked with the<font color="#808000" size="2" face="Courier New">[DataContract]</font> attribute and used the <font color="#808000" face="Courier New"><font size="2">DataContractJsonSerializer</font> <font color="#333333" face="Georgia">to serialize it into the right format. Beats constructing the string in code.</font></font></p>
<p>Now lets look at how you would generate the signature. You will probably store the private key in web.config like this </p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">appSettings</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">=&quot;AWSAccessKey&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;MyAmazonS3AccessKey&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">=&quot;AWSSecretKey&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;MyAmazonS3SecretKey&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">=&quot;AWSBucket&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;MyAS3Bucket&quot;</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">appSettings</span><span class="kwrd">&gt;</span></pre>
<p>and retrieve it like this before passing it to the method to create the signature.</p>
<pre class="csharpcode"><font size="2">
	<span class="kwrd">string</span> publicKey = <span class="classname">ConfigurationManager</span>.AppSettings[&quot;AWSAccessKey&quot;];
	<span class="kwrd">string</span> secretKey = <span class="classname">ConfigurationManager</span>.AppSettings[&quot;AWSSecretKey&quot;];
	<span class="kwrd">string</span> bucketName = <span class="classname">ConfigurationManager</span>.AppSettings[&quot;AWSBucket&quot;];
</font></pre>
<p>Now let’s look at the “Signature”. In Amazon S3’s <a href="http://doc.s3.amazonaws.com/proposals/post.html#Access_Control">documentation</a> it is defined as </p>
<blockquote>
<p>Signature is the HMAC of the Base64 encoding of the policy</p>
</blockquote>
<p>The function below creates the “Signature”. The parameters are “normal” C# strings. Meaning no additional encoding information is being implied. I have made the function more verbose than normal to clarify the steps involved.</p>
<p><span class="str&gt;&quot;AWSBucket&quot;&lt;/span&gt;];&#013;&#010;&lt;/pre&gt;&#013;&#010;&#013;&#010;&lt;pre class="></p>
<pre class="csharpcode"><font size="2">
<span class="kwrd">private string</span> CreateSignature(<span class="kwrd">string</span> secretKey, <span class="kwrd">string</span> policy)
{
	<span class="kwrd">var</span> encoding = <span class="kwrd">new</span> ASCIIEncoding();
	<span class="kwrd">var</span> policyBytes = encoding.GetBytes(policy);
	<span class="kwrd">var</span> base64Policy = Convert.ToBase64String(policyBytes);

	<span class="kwrd">var</span> secretKeyBytes = encoding.GetBytes(secretKey);
	<span class="kwrd">var</span> hmacsha1 = <span class="kwrd">new</span> HMACSHA1(secretKeyBytes);

	<span class="kwrd">var</span> base64PolicyBytes = encoding.GetBytes(base64Policy);
	<span class="kwrd">var</span> signatureBytes = hmacsha1.ComputeHash(base64PolicyBytes);

	<span class="kwrd">return</span> Convert.ToBase64String(signatureBytes);
}
</font></pre>
<p>Let’s walk through the function. First I am converting the policy string into a series of bytes. To do that you must choose an encoding (because different encodings lead to a different series of bytes for the same string). I choose ASCII because that’s what I found was being used in some of the PHP and Ruby samples I came across. Apparently that is correct because this works. </p>
<p>Once you have the series of bytes for the policy string, you need to convert it into a base64 string, which really means reinterpreting the series of bytes in 6 bit chunks to ensure each chunk stays within a certain range. Anyways, .NET provides the handy <font color="#808000" size="2" face="Courier New">Convert.ToBase64String</font> function to deal with that.</p>
<p>Once you have the base64 encoded policy string, you need to hash it. To do that you create an instance of the .NET HMAC SHA1 hasher, supplying the bytes of the secret key as a parameter to its constructor. Again we get the bytes of the private key using the ASCII encoder. </p>
<p>Now we use that hasher to hash the policy bytes. The result of that is the set of bytes of the signature which can then be converted into the base64 encoded string and returned.</p>
<blockquote>
<p>Base64 encoding has to be used to transmit both the policy string and the generated hash because base64 is a way to guarantee that any kind of characters will be first converted into the ASCII range. That, as I have read, is a fairly common practice. </p>
</blockquote>
<p>So in the end the code to generate the <font color="#333333">view</font> model ends up looking like this</p>
<pre class="csharpcode"><font size="2">
<span class="kwrd">public</span> <span class="classname">FileUploadViewModel</span> <span class="functionname">GenerateViewModel</span>(	<span class="kwrd">string</span> publicKey,
					<span class="kwrd">string</span> secretKey,
					<span class="kwrd">string</span> bucketName,
					<span class="kwrd">string</span> fileName,
					<span class="kwrd">string</span> redirectUrl)
{
	<span class="kwrd">var</span> fileUploadVM = <span class="kwrd">new</span> <span class="classname">FileUploadViewMode</span>();

	fileUploadVM.FormAction = <span class="str">&quot;http://&quot;</span> + bucketName + <span class="str">&quot;.s3.amazonaws.com/&quot;</span>;
	fileUploadVM.FormMethod = <span class="str">&quot;post&quot;</span>;
	fileUploadVM.FormEnclosureType = <span class="str">&quot;multipart/form-data&quot;</span>;

	fileUploadVM.Bucket = bucketName;
	fileUploadVM.FileId = fileName;
	fileUploadVM.AWSAccessKey = publicKey;
	fileUploadVM.RedirectUrl = redirectUrl;

	<span class="rem">// one of private, public-read, public-read-write, or authenticated-read</span>
	fileUploadVM.Acl = <span class="str">&quot;private&quot;</span>;

	<span class="rem">// Do what you have to to create the policy string here</span>
	var policy = <span class="functionname">CreatePolicy</span>();

	<span class="classname">ASCIIEncoding</span> encoding = new <span class="classname">ASCIIEncoding</span>();
	fileUploadVM.Base64Policy =
			<span class="classname">Convert</span>.<span class="functionname">ToBase64String</span>(encoding.GetBytes(policy));
	fileUploadVM.Signature = <span class="functionname">CreateSignature</span>(secretKey, policy);
}
</font></pre>
<p><strong><font color="#808000">Finally the View</font></strong></p>
<p>The view, like I said is using the Razor engine, and simply lays out a “form” that has all the relevant fields Amazon S3 requires and optionally others you care about.</p>
<pre class="csharpcode"><font size="1">
@model TheApp.ViewModels.FileUploadViewModel
@{
    ViewBag.Title = &quot;Upload File&quot;;
    Layout = &quot;~/Views/Shared/_Layout.cshtml&quot;;
}
<span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">id</span><span class="kwrd">=&quot;fileuploaddiv&quot;</span> <span class="attr">class</span><span class="kwrd">=&quot;fileuploaddivclass&quot;</span><span class="kwrd">&gt;</span>
	<span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">action</span><span class="kwrd">=&quot;@Model.FormAction&quot;</span> <span class="attr">method</span><span class="kwrd">=&quot;@Model.FormMethod&quot;</span>
		<span class="attr">enctype</span><span class="kwrd">=&quot;@Model.FormEnclosureType&quot;</span><span class="kwrd">&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;key&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.FileId&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;AWSAccessKeyId&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.AWSAccessKey&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;acl&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.Acl&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;policy&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.Base64EncodedPolicy&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;signature&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.Signature&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;redirect&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;@Model.RedirectUrl&quot;</span> <span class="kwrd">/&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>
			Please specify a file, or a set of files:
			<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;file&quot;</span> <span class="attr">name</span><span class="kwrd">=&quot;file&quot;</span> <span class="attr">size</span><span class="kwrd">=&quot;100&quot;</span> <span class="kwrd">/&gt;
		&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
		<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">=&quot;submit&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;Upload&quot;</span> <span class="kwrd">/&gt;</span>
	<span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
</font></pre>
<p>Hopefully this helps. Feel free to leave feedback and questions. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=250&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>So how many ways can you…</title>
		<link>http://codeonaboat.wordpress.com/2011/02/15/so-how-many-ways-can-you/</link>
		<comments>http://codeonaboat.wordpress.com/2011/02/15/so-how-many-ways-can-you/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 22:51:57 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[logic]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[combination]]></category>
		<category><![CDATA[permutation]]></category>
		<category><![CDATA[probability]]></category>

		<guid isPermaLink="false">https://coab.wordpress.com/2011/02/15/so-how-many-ways-can-you/</guid>
		<description><![CDATA[I get obsessive about math puzzles. Not crazy ones that will take some sort of Aryabhata to figure out but little interesting ones that require intuition and a little obsession to crack. Probability and its puzzles fall right in this &#8230; <a href="http://codeonaboat.wordpress.com/2011/02/15/so-how-many-ways-can-you/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=180&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I get obsessive about math puzzles. Not crazy ones that will take some sort of <a href="http://en.wikipedia.org/wiki/Aryabhata">Aryabhata </a>to figure out but little interesting ones that require intuition and a little obsession to crack. Probability and its puzzles fall right in this zone and most often, books and courses will teach people the formulae but not really instill an understanding of why things work the way they do. So&#8230; I decided to put some information down in a post. It is mostly in the form of definitions of basic concepts and clarifications of what those basics <em>really </em>mean.</p>
<p>So here goes…</p>
<h2><span style="color:#808000;">Universe</span></h2>
<p>This is the set of things you have available to you, to choose from. So if you have a bag with 2 red balls and 3 green balls, then those 5 balls are your universe. If you have 10 kinds of candy bars from which you can choose, say 4, that set of 10 candy bars is your universe.</p>
<h2><span style="color:#808000;">Events and Outcomes</span></h2>
<p>Events are something you are trying to achieve at a higher level, and outcomes are the different ways in which you can achieve that higher level objective or event.</p>
<p>For example if a problem asks you to choose 3 vegetables out of a bag of 10 vegetables, the event is the picking of any 3 vegetables. The outcomes that go to make that event are however many more,</p>
<p><em>10C3 = 10!/(3! * 7!) = 120</em></p>
<p>to be precise.</p>
<p>Similarly if you are trying to pick out 2 Aces from a pack of 52 cards, your event is exactly that, picking out of any 2 Aces, where as the outcomes that enable that event are 6 in number,</p>
<p><em>4C2 = 4!/(2! * 2!)  = 6</em></p>
<h2><span style="color:#808000;">“With Replacement” Vs. “Without Replacement”</span></h2>
<p>If you have a universe of things to choose from (letters, numbers, balls, whatever…), and after you choose one of the things in the universe, you <em>do not </em>put it back into that universe, it’s called “Without Replacement”. If you <em>do </em>put it back, it’s called “With Replacement”. Another way to look at it is that you modify the universe every time you pick one thing in the “Without Replacement” case, and do reset the universe to what it was originally in the “With Replacement” case.</p>
<h2><span style="color:#808000;">“Order Matters” Vs. “Order Does not Matter”</span></h2>
<p>In some problems, the order in which you extract things out of your universe is significant (think about a lottery number, the order of numbers picked <em>is</em> important). In some other cases, the order in which you extract things may not be important (think about the case where you need to pick 3 toys from a basket of toys – usually what order those toys will be picked out <em>is not </em>important).</p>
<p>Whether order is important or not is critical in determining how many ways (or more formally <em>outcomes</em>), there are to satisfy a certain event. To clarify this, lets say I have to figure out how I can extract the letters ‘A’ and ‘D’ from a universe, (‘A’, ‘B’, ‘C’, ‘D’). In other words, my event is the case where ‘A’ and ‘D’ have been extracted out from the universe. If order is important, the number of outcomes is 2 – (‘A’, ‘D’) and (‘D’, ‘A’). If order is not important, the number of outcomes is one, because we are not differentiating between the case where ‘A’ was picked first and ‘D’ last from the case where ‘D’ was picked first and ‘A’ last.</p>
<p>As a rule of intuition, <em>when order is not important you have much fewer outcomes to satisfy the same event.</em></p>
<h2><span style="color:#808000;">The Math</span></h2>
<p>There really is not much math involved in this kind of problems; it’s really about understanding the question, and then imagining  and categorizing the solution. Once you have done that, to save time you can just use one of the existing formulae to give you an answer and save some time.</p>
<h3><em><span style="color:#800000;">Factorial</span></em></h3>
<blockquote><p>n! = n * (n-1) * (n-2) * … 3 * 2 * 1</p></blockquote>
<h3><em><span style="color:#800000;">Permutations</span></em></h3>
<p>If there is <em>no replacement</em>, and <em>you care about the order </em>in which you extract items out of your universe, then the number of ways, or outcomes, you have to extract `r` items from a universe containing `n` items is represented by the expression</p>
<p>nPr,</p>
<p>and can be computed as</p>
<blockquote><p>nPr = n!/(n-r)!</p></blockquote>
<h3><em><span style="color:#800000;">Combinations</span></em></h3>
<p>If there is <em>no replacement</em>, and <em>you do not care about the order</em> in which you extract items out of your universe, then the number of ways, or outcomes, you have to extract `r` items from a universe containing `n` items is represented by the expression</p>
<p>nCr,</p>
<p>and can be computed as</p>
<blockquote><p>nCr = n!/(r! * (n-r)!)</p></blockquote>
<p>As mentioned above, intuitively it should be clear that if you don’t care about the order of extraction, you will have much fewer outcomes. And this formula confirms that intuition.</p>
<h2><span style="color:#808000;">Bringing it Together</span></h2>
<p>Ok, with those basics under your belt, lets try an example that brings together many of these concepts.</p>
<h3><em><span style="color:#800000;">Question</span></em></h3>
<p>If a menu has 10 different dishes available, and any customer is allowed to choose 4 of them, how many combinations of dishes must the chef be prepared to make, in each of the following scenarios.</p>
<ol>
<li>If the customer can choose a dish only once, and the order they pick the dishes in <em>is relevant</em> (meaning “Wonton soup, Lomein, Pot  Sticklers, and General Tso’s Chicken” and “Lomein, Pot Sticklers, Genral Tso’s Chicken and Wonton Soup” are to be regarded as 2 separate combinations).</li>
<li>If the customer can choose a dish only once, and the order they pick the dishes in <em>is irrelevant</em> (meaning “Wonton soup, Lomein, Pot  Sticklers, and General Tso’s Chicken” is the same as “Lomein, Pot Sticklers, Genral Tso’s Chicken and Wonton Soup”; the order is irrelevant).</li>
<li>If the customer can choose a dish multiple times, and the order they pick the dishes in <em>is relevant</em> (meaning “Wonton soup, Lomein, Pot  Sticklers, and General Tso’s Chicken” and “Lomein, Pot Sticklers, Genral Tso’s Chicken and Wonton Soup” are to be regarded as 2 separate combinations).</li>
<li>If the customer can choose a dish multiple times, and the order they pick the dishes in <em>is irrelevant</em> (meaning “Wonton soup, Lomein, Pot  Sticklers, and General Tso’s Chicken” is the same as “Lomein, Pot Sticklers, Genral Tso’s Chicken and Wonton Soup”; the order is irrelevant).</li>
</ol>
<h3><em><span style="color:#800000;">Answer</span></em></h3>
<p>Before getting into each case, lets look at the question as a whole. The following is a break up of what’s supplied as a part of the question:</p>
<p><strong>Universe</strong>: The set of 10 dishes</p>
<p><strong>Event</strong>: The picking of 4 dishes</p>
<p>When the customer can pick one dish only once, it’s really a way to say there is no replacement. When the customer can pick the same dish multiple times, its a way of saying that there is replacement.</p>
<p>Ok, now lets look at each case</p>
<ol>
<li>This is simply the number of permutations in which 4 things can be picked from 10.</li>
<blockquote><p>10P4 = 10!/(10-4)! = 5040</p></blockquote>
<li>This is simply the number of combinations in which 4 things can be picked from 10.</li>
<blockquote><p>10C4 = 10!/(4! * (10-4)!) = 210</p></blockquote>
<li>Since there is replacement here, or in other words the customer can pick the same dish one, two, three or four times, we have many more ways in which 4 dishes can be picked. Also order is relevant, meaning every different combination is valid. So the total number of ways that 4 dishes can be picked out of 10 is</li>
<blockquote><p>10 * 10 * 10 * 10 = 10,000</p></blockquote>
<p>Basically at every point you have the option of picking any of the 10 dishes and you have 4 of these opportunities.</p>
<li>This is the most interesting of the 4 scenarios. Like in (c) you have 10 dishes to choose from all 4 times. However order is not relevant and hence those outcomes where the same things were picked have to be eliminated. Lets start with the answer we have in (c), 10,000. If from those you delete all outcomes that included a dish only once treating order as relevant (a) and then add back the outcomes that included a dish only once treating order as irrelevant (b) you get the following:</li>
<blockquote><p>10,000 – 10P4 + 10C4</p>
<p>=&gt; 10,000 – 10!/6! + 10!/(4! * 6!)</p>
<p>=&gt; 5170</p></blockquote>
<p>However, in that total you still have the outcomes are the same (though their order of dishes is different) that included 1 repeat, 2 repeats and 3 repeats, and they need to be removed from that total. If you figure that one out, post the solution in a comment!</ol>
<p>Here&#8217;s a bonus question, and something I will probably ask you if I ever interview you for a software engineering position. (Don&#8217;t worry, i&#8217;ll be able to figure out whether you knew it before hand <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</p>
<p>A spider eats at most 3 flies a day, and stops trying to catch more flies once he has eaten 3 for the day. Until he fills his quota, he has a 50% chance of catching any fly that pass by his web. What are a fly&#8217;s chances of survival, given that five 5 have passed by the spider&#8217;s web today?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=180&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2011/02/15/so-how-many-ways-can-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>Netflix should tie up with Movie Theaters</title>
		<link>http://codeonaboat.wordpress.com/2011/02/14/netflix-should-tie-up-with-movie-theaters/</link>
		<comments>http://codeonaboat.wordpress.com/2011/02/14/netflix-should-tie-up-with-movie-theaters/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 19:45:40 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[subscription]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://coab.wordpress.com/?p=172</guid>
		<description><![CDATA[I love watching movies, and in New York City, where I live, the cost of watching one movie in a theater is around $13-$15. For two people, that&#8217;s almost $30, and if you have a family of four, that&#8217;s pretty &#8230; <a href="http://codeonaboat.wordpress.com/2011/02/14/netflix-should-tie-up-with-movie-theaters/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=172&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I love watching movies, and in New York City, where I live, the cost of watching one movie in a theater is around $13-$15. For two people, that&#8217;s almost $30, and if you have a family of four, that&#8217;s pretty darn pricey.</p>
<p>No wonder lesser and lesser people are &#8220;going to the movies&#8221;. Well, there are other reasons too I guess. Home theater systems for one, but I don&#8217;t know if their penetration has reached the point that they are causing the masses to stay home. Shitty movies might be another, but shittyness doesn&#8217;t have that great a track record of keeping the masses away from anything. I mean we have <a href="http://en.wikipedia.org/wiki/Michele_Bachmann">this</a> and <a href="http://en.wikipedia.org/wiki/Sarah_Palin">this</a>! Maybe piracy? Now that&#8217;s a whole new conversation, but at the end of the day I do believe; provide something compelling and people will pay (a little).</p>
<p>I was in a bus passing by the United Artists Theater on 1st Ave &amp; 85th St, and its currently playing <a href="http://www.imdb.com/title/tt0947798/">Black Swan</a>, and thought hmm, it would be good to get off the bus and go watch it until my impulse to not pay $30 to some production house kicked in. You can argue if that is justified, but afford it or not, it doesn&#8217;t pass my cost-benefit analysis-o-meter!</p>
<p>So here&#8217;s my idea; I googled it a bit and doesn&#8217;t seem like its been talked about publicly. Netflix, feel free to steal and implement it. Okay, maybe not really. If it works, I would like 50% of the profits. Just putting it out there in the universe, you never know what sticks!</p>
<p>I currently pay somewhere around $10 to get one DVD at home and unlimited streaming of the movies available for instant watching. Pretty good deal, as my cost-benefit analysis-o-meter tells me. Charge me $20, if you can also give me the ability to go to a theater and pay a small amount, say $5 and see a movie.</p>
<p>There are currently around <a href="http://news.cnet.com/8301-31001_3-20029692-261.html">20 million Netflix subscribers</a> in the US and Canada, and here is how much the top grossing movies of 2010 made. Table copied from <a href="http://boxofficemojo.com/yearly/chart/?yr=2010&amp;p=.htm">here</a>.</p>
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td><strong>Rank</strong></td>
<td>Movie Title (click to view)</td>
<td>Studio</td>
<td colspan="2"><strong>Total Gross</strong> /Theaters</td>
<td colspan="2">Opening / Theaters</td>
<td>Open</td>
<td>Close</td>
</tr>
<tr>
<td>1</td>
<td><strong><a href="http://boxofficemojo.com/movies/?id=toystory3.htm">Toy Story 3</a></strong></td>
<td><a href="http://boxofficemojo.com/studio/chart/?studio=buenavista.htm">BV</a></td>
<td><strong>$415,004,880</strong></td>
<td>4,028</td>
<td>$110,307,189</td>
<td>4,028</td>
<td><a href="http://boxofficemojo.com/schedule/?view=bydate&amp;release=theatrical&amp;date=2010-06-18&amp;p=.htm">6/18</a></td>
<td>12/2</td>
</tr>
<tr>
<td>2</td>
<td><strong><a href="http://boxofficemojo.com/movies/?id=aliceinwonderland10.htm">Alice in   Wonderland (2010)</a></strong></td>
<td><a href="http://boxofficemojo.com/studio/chart/?studio=buenavista.htm">BV</a></td>
<td><strong>$334,191,110</strong></td>
<td>3,739</td>
<td>$116,101,023</td>
<td>3,728</td>
<td><a href="http://boxofficemojo.com/schedule/?view=bydate&amp;release=theatrical&amp;date=2010-03-05&amp;p=.htm">3/5</a></td>
<td>7/8</td>
</tr>
<tr>
<td>3</td>
<td><strong><a href="http://boxofficemojo.com/movies/?id=ironman2.htm">Iron Man 2</a></strong></td>
<td><a href="http://boxofficemojo.com/studio/chart/?studio=paramount.htm">Par.</a></td>
<td><strong>$312,433,331</strong></td>
<td>4,390</td>
<td>$128,122,480</td>
<td>4,380</td>
<td><a href="http://boxofficemojo.com/schedule/?view=bydate&amp;release=theatrical&amp;date=2010-05-07&amp;p=.htm">5/7</a></td>
<td>8/19</td>
</tr>
<tr>
<td>4</td>
<td><strong><a href="http://boxofficemojo.com/movies/?id=eclipse.htm">The Twilight   Saga: Eclipse</a></strong></td>
<td><a href="http://boxofficemojo.com/studio/chart/?studio=summitentertainment.htm">Sum.</a></td>
<td><strong>$300,531,751</strong></td>
<td>4,468</td>
<td>$64,832,191</td>
<td>4,468</td>
<td><a href="http://boxofficemojo.com/schedule/?view=bydate&amp;release=theatrical&amp;date=2010-06-30&amp;p=.htm">6/30</a></td>
<td>10/21</td>
</tr>
<tr>
<td>5</td>
<td><strong><a href="http://boxofficemojo.com/movies/?id=harrypotter7.htm">Harry Potter and   the Deathly Hallows Part 1</a></strong></td>
<td><a href="http://boxofficemojo.com/studio/chart/?studio=warnerbros.htm">WB</a></td>
<td><strong>$292,890,256</strong></td>
<td>4,125</td>
<td>$125,017,372</td>
<td>4,125</td>
<td><a href="http://boxofficemojo.com/schedule/?view=bydate&amp;release=theatrical&amp;date=2010-11-19&amp;p=.htm">11/19</a></td>
<td>-</td>
</tr>
</tbody>
</table>
<p>So i&#8217;m not really a finance guy but maybe there is a way to make the numbers work here. Infact, there will probably be a lot of interest in such an offer, even at a higher price point, say $30. Besides it will create economic activity that could be tied back to Netflix, and the movie business in the long run.</p>
<p>I don&#8217;t care about the shitty butter covered corn and sugar they serve at the theater, and yea, noisy idiots do bother me, but i&#8217;ll figure that one out. However, I do love to watch movies on the big screen, and will jump at this offer. Hopefully many others will too.</p>
<p>Finally I would like to say that these opinions are solely mine and I do own a minuscule amount of stock in <a href="http://www.netflix.com/">Netflix</a>, so if their share price was to increase because of this post, maybe I will go and watch a couple more movies at the local theater.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=172&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2011/02/14/netflix-should-tie-up-with-movie-theaters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>Invoking the DELETE verb with the Mootools Request.JSON class</title>
		<link>http://codeonaboat.wordpress.com/2010/10/24/invoking-the-delete-verb-with-the-request-class/</link>
		<comments>http://codeonaboat.wordpress.com/2010/10/24/invoking-the-delete-verb-with-the-request-class/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 21:01:53 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">https://coab.wordpress.com/2010/10/24/invoking-the-delete-verb-with-the-request-class/</guid>
		<description><![CDATA[Recently, I was trying to use the DELETE verb on a URL (using the MooTools Request.JSON class), and found (using Firebug) that the even though I was invoking the request correctly, the actual request going out was a POST. The &#8230; <a href="http://codeonaboat.wordpress.com/2010/10/24/invoking-the-delete-verb-with-the-request-class/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=153&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I was trying to use the DELETE verb on a URL (using the MooTools Request.JSON class), and found (using Firebug) that the even though I was invoking the request correctly, the actual request going out was a POST. The code looks something like this.</p>
<pre class="csharpcode"><span class="kwrd">var</span> req = <span class="kwrd">new</span> Request.JSON(
{
    method: “DELETE”,
    url: url,
});

req.addEvent(<span class="str">"failure"</span>, failurefn);
req.addEvent(<span class="str">"success"</span>, successfn);
req.send(args);</pre>
<div id="codeSnippetWrapper" class="csharpcode-wrapper">On debugging I found that the following piece of code in the MooTools library’s Request class (which is the base class for Request.JSON)</div>
<pre class="csharpcode"><span class="kwrd">if</span> (<span class="kwrd">this</span>.options.emulation &amp;&amp; ![<span class="str">'get'</span>, <span class="str">'post'</span>].contains(method)){
    var _method = <span class="str">'_method='</span> + method;
    data = (data) ? _method + <span class="str">'&amp;'</span> + data : _method;
    method = <span class="str">'post'</span>;
}</pre>
<p>was converting the DELETE request into a POST request, and adding the actual method (DELETE in this case as part of the POST data. It appears that if you want to send any other verb besides a GET or POST as the actual HTTP verb using the Request class, you must set the “emulation” option to false. This is documented in the MooTools <a href="http://mootools.net/docs/core/Request/Request">documentation</a> for the Request class.</p>
<p><a href="http://codeonaboat.files.wordpress.com/2010/10/image1.png"><img style="display:inline;border:0;" title="image" src="http://codeonaboat.files.wordpress.com/2010/10/image_thumb1.png?w=609&#038;h=42" border="0" alt="image" width="609" height="42" /></a></p>
<p>The value of the emulation option defaults to true in the class. So my code now looks something like this (notice the emulation: false):</p>
<pre>var req = <span class="kwrd">new</span> Request.JSON(
{
    method: method,
    url: url,
    emulation: <span class="kwrd">false</span>
});

req.addEvent(<span class="str">"failure"</span>, failurefn);
req.addEvent(<span class="str">"success"</span>, successfn);
req.send(args);</pre>
<p>And everything works as expected.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=153&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2010/10/24/invoking-the-delete-verb-with-the-request-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>

		<media:content url="http://codeonaboat.files.wordpress.com/2010/10/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>NYC Startup Weekend</title>
		<link>http://codeonaboat.wordpress.com/2010/06/23/nyc-startup-weekend/</link>
		<comments>http://codeonaboat.wordpress.com/2010/06/23/nyc-startup-weekend/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 04:16:56 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[collaboration]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[nyc startup weekend]]></category>
		<category><![CDATA[sound spot]]></category>

		<guid isPermaLink="false">http://coab.wordpress.com/?p=134</guid>
		<description><![CDATA[I recently attended the NYC Startup Weekend. Initially I was reluctant thinking it would be a waste of time, not productive etc, but I was surprised. It was an awesome experience, and after the chaos of Friday night, Saturday and &#8230; <a href="http://codeonaboat.wordpress.com/2010/06/23/nyc-startup-weekend/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=134&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently attended the <a href="http://nyc.startupweekend.org/" target="_blank">NYC Startup Weekend</a>. Initially I was reluctant thinking it would be a waste of time, not productive etc, but I was surprised. It was an awesome experience, and after the chaos of Friday night, Saturday and Sunday were exciting days when I worked in a team of 5 people to come up with an interesting concept, and also picked up some Android/Java  programming.</p>
<p>Our idea &#8220;Sound Spot&#8221; got a shout out from the <a href="http://technoverseblog.com/2010/06/finale-startup-weekend-nyc/" target="_blank">Technoverse Blog</a>. Thank You!!</p>
<p>Overall the quality of  pitches was excellent and it was a learning experience through and through. Everything thing from what VCs look for, to how to appeal to an audience, to a completely new platform for development. I highly recommend attending one if possible.</p>
<p>Besides all this there was excellent food at the event (surprisingly I must admit). It was served by <a href="http://organiqueonline.com/" target="_blank">Organique</a>. So good!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=134&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2010/06/23/nyc-startup-weekend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>NAnt, NAntContrib &amp; How can I use msbuild with NAnt?</title>
		<link>http://codeonaboat.wordpress.com/2010/05/17/nant-nantcontrib-how-can-i-use-msbuild-with-nant/</link>
		<comments>http://codeonaboat.wordpress.com/2010/05/17/nant-nantcontrib-how-can-i-use-msbuild-with-nant/#comments</comments>
		<pubDate>Tue, 18 May 2010 01:38:10 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[cruise control]]></category>
		<category><![CDATA[nant]]></category>
		<category><![CDATA[nantcontrib]]></category>

		<guid isPermaLink="false">http://coab.wordpress.com/?p=123</guid>
		<description><![CDATA[I had a simple need&#8230; I wanted to check if my NAnt .build file changes were correct before checking them into source control. We already have Cruise Control.NET setup and it works but I did not have any way to &#8230; <a href="http://codeonaboat.wordpress.com/2010/05/17/nant-nantcontrib-how-can-i-use-msbuild-with-nant/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=123&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><p>I had a simple need&#8230;</p></blockquote>
<p>I wanted to check if my NAnt .build file changes were correct before checking them into source control. We already have Cruise Control.NET setup and it works but I did not have any way to test my changes locally. So I thought I would install NAnt and try to test my changes.</p>
<p>So there I went&#8230; at first I googled my way to nant.sourceforge.net and found NAnt binaries. Downloaded them, unzipped them and tried to run nant.exe on my build file. Failed. Then I googled my way to discovering that I need something called NAntContrib because it has the definition of the task msbuild that I was using in my .build file. OK so I downloaded NAntContrib. But it wasn&#8217;t clear what I should do next. How could I tell nant.exe to load the definition of the msbuild task from NAntContrib binaries?</p>
<p>Anyway, I figured it out (we always do) but had to struggle and google my way around a lot of stuff to get to the point where I was able to run everything.</p>
<p>Here are simple instructions I wish I had. Hopefully they help you out if you&#8217;re stuck with the same issue.</p>
<p><strong>What is NAntContrib?</strong></p>
<p>From the NAntContrib readme.txt</p>
<blockquote><p>&#8220;NAntContrib is the project for tasks and tools that haven&#8217;t made it into the main NAnt distribution yet or for whatever reason don&#8217;t belong there.&#8221;</p></blockquote>
<p><strong>How can I install NAnt and NAnt contrib on my machine?</strong></p>
<p>1. Install NAnt</p>
<ul>
<li>Get the latest Release from here: http://nant.sourceforge.net</li>
<li>You can just get the binaries in zip form and unzip on a folder in your machine (say c:\Program Files\nant)</li>
</ul>
<p>2. Install NAntContrib</p>
<ul>
<li>Get the latest release from here: http://nantcontrib.sourceforge.net</li>
<li>Again you can download the binaries in zip form and unzip into a folder in your machine (say c:\Program Files\nantcontrib)</li>
</ul>
<p><strong>How can I use tasks from NAntContrib in my NAnt?</strong></p>
<p>I was trying to use msbuild which is a task to build a Visual Studio Solution (.sln) file. Here is how I got it to work.</p>
<p>This is how I defined my &#8220;build&#8221; target in the my .build file</p>
<pre>&lt;target name="build" description="Compiles the .Net solution"&gt;</pre>
<pre>      &lt;!-- build the solution --&gt;</pre>
<pre>      &lt;echo message="Building ${project::get-name()} v${project.version}" /&gt;</pre>
<pre>      &lt;!-- need nant.contrib.tasks.dll for msbuild --&gt;</pre>
<pre>      &lt;loadtasks assembly="C:/Program Files/nantcontrib/bin/NAnt.Contrib.Tasks.dll" /&gt;</pre>
<pre>      &lt;msbuild project="mysolution.sln"&gt;</pre>
<pre>            &lt;arg value="/p:Configuration=${target}" /&gt;</pre>
<pre>            &lt;arg value="/p:Platform=Any CPU" /&gt;</pre>
<pre>            &lt;arg value="/t:Rebuild" /&gt;
      &lt;/msbuild&gt;</pre>
<pre>&lt;/target&gt;</pre>
<p><!-- build the solution --></p>
<p><!-- need nant.contrib.tasks.dll for msbuild --></p>
<p>By adding the  tag in there with the path to the NAnt.Contrib.Tasks.dll, I point nant to the dll to find the msbuild task and it just works.</p>
<p>The command line to run nant on the build file was as follows</p>
<p><code><span style="color:#800000;">c:\Projects\myproject&gt;"c:\program files\nant\bin\nant.exe" -buildfile:mysolution.build build</span></code></p>
<p>This tells nant.exe to find mysolution.build in the current folder and execute the &#8220;build&#8221; target in it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=123&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2010/05/17/nant-nantcontrib-how-can-i-use-msbuild-with-nant/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>
	</item>
		<item>
		<title>MooTools Request.JSON &#8220;success&#8221; event &#8211; Some Undocumented Behavior</title>
		<link>http://codeonaboat.wordpress.com/2010/03/20/mootools-request-json-success-event-some-undocumented-behavior/</link>
		<comments>http://codeonaboat.wordpress.com/2010/03/20/mootools-request-json-success-event-some-undocumented-behavior/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 04:25:33 +0000</pubDate>
		<dc:creator>floatingfrisbee</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[request.json]]></category>
		<category><![CDATA[xmlhttprequest]]></category>

		<guid isPermaLink="false">http://coab.wordpress.com/2010/03/20/mootools-request-json-success-event-some-undocumented-behavior/</guid>
		<description><![CDATA[Request.JSON is a simple extension of the Request class that MooTools provides for making HTTP request. According to the MooTools documentation for the Request.JSON class the handler for the “success” event will receive two arguments. The first one being the &#8230; <a href="http://codeonaboat.wordpress.com/2010/03/20/mootools-request-json-success-event-some-undocumented-behavior/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=114&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Request.JSON is a simple extension of the Request class that MooTools provides for making HTTP request. According to the MooTools <a href="http://mootools.net/docs/core/Request/Request">documentation</a> for the Request.JSON class the handler for the “success” event will receive two arguments. The first one being the response JSON object, and the second, the response in text form. The signature of the handler function would then be something like this:</p>
<pre>
OnSuccess(responseJSON, responseText)
</pre>
<p>Now when a request is made without any arguments, like below</p>
<pre>
var req = new Request.JSON(
{
    method: method,
    url: url
});

req.addEvent("failure", failurefn);
req.addEvent("success", successfn);
req.send();
</pre>
<p>that is indeed the case. The success function gets the responseJSON and the responseText.</p>
<p>However if the request includes arguments, like so:</p>
<pre>
var req = new Request.JSON(
{
    method: method,
    url: url
});

req.addEvent("failure", failurefn);
req.addEvent("success", successfn);
req.send(args);
</pre>
<p>the 2 arguments to the success function are first the response JSON object and second the arguments (args) that were originally passed into the request. In other words the signature of the success function is like this:</p>
<pre>
OnSuccess(responseJSON, args)
</pre>
<p>I couldn’t find any mention of this in the MooTools documentation, and I think this might be a behavior of the underlying XmlHttpRequest object itself and not something introduced by the MooTools class.</p>
<div class="wlWriterHeaderFooter" style="text-align:right;margin:0;padding:4px 0;"><a href="http://digg.com/submit?url=http%3a%2f%2fcoab.wordpress.com%2f2010%2f03%2f20%2fmootools-request-json-success-event-some-undocumented-behavior%2f&amp;title=MooTools+Request.JSON+%e2%80%9csuccess%e2%80%9d+event+%e2%80%93+Some+Undocumented+Behavior"><img style="border:0;" title="Digg This" src="http://digg.com/img/badges/100x20-digg-button.png" border="0" alt="Digg This" width="100" height="20" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeonaboat.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeonaboat.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeonaboat.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codeonaboat.wordpress.com&amp;blog=7350935&amp;post=114&amp;subd=codeonaboat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codeonaboat.wordpress.com/2010/03/20/mootools-request-json-success-event-some-undocumented-behavior/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e37c1da4d66a3df72a928ff2dfa9c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">floatingfrisbee</media:title>
		</media:content>

		<media:content url="http://digg.com/img/badges/100x20-digg-button.png" medium="image">
			<media:title type="html">Digg This</media:title>
		</media:content>
	</item>
	</channel>
</rss>
