<?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>Maurice&#039;s Blog - Mo Knowledge, Mo problems...</title>
	<atom:link href="http://mauricebutler.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mauricebutler.wordpress.com</link>
	<description>My views on technology, software development and any other random topics that come up</description>
	<lastBuildDate>Tue, 21 May 2013 05:19:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mauricebutler.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Maurice&#039;s Blog - Mo Knowledge, Mo problems...</title>
		<link>http://mauricebutler.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mauricebutler.wordpress.com/osd.xml" title="Maurice&#039;s Blog - Mo Knowledge, Mo problems..." />
	<atom:link rel='hub' href='http://mauricebutler.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Node.js is a toy &#8211; for big boys.</title>
		<link>http://mauricebutler.wordpress.com/2013/05/16/signforms-going-paperless-just-got-easy/</link>
		<comments>http://mauricebutler.wordpress.com/2013/05/16/signforms-going-paperless-just-got-easy/#comments</comments>
		<pubDate>Thu, 16 May 2013 00:48:41 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[digital signature sign forms]]></category>
		<category><![CDATA[documents]]></category>
		<category><![CDATA[esign]]></category>
		<category><![CDATA[signforms]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=283</guid>
		<description><![CDATA[&#160; Node.js is not a toy. Checkout the new large scale web application I helped build. signforms.com &#160; TLDR: We produced a very complex, solid, secure, fast and scalable server solution using node.js in a very short timeframe with amazing results. We used a number of different modules and server side tools to achieve our goal. &#160; What got me [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=283&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Node.js is not a toy. Checkout the new large scale web application I helped build. <a title="SignForms" href="https://signforms.com/" target="_blank">signforms.com</a></p>
<div id="attachment_297" class="wp-caption aligncenter" style="width: 573px"><a href="http://mauricebutler.files.wordpress.com/2013/05/signforms.png"><img class=" wp-image-297    " alt="SignForms" src="http://mauricebutler.files.wordpress.com/2013/05/signforms.png?w=563&#038;h=273" width="563" height="273" /></a><p class="wp-caption-text">SignForms</p></div>
<p>&nbsp;</p>
<p><b>TLDR:</b></p>
<p><i>We produced a very complex, solid, secure, fast and scalable server solution using <a href="http://nodejs.org/">node.js</a> in a very short timeframe with amazing results. We used a number of different modules and server side tools to achieve our goal.</i></p>
<p>&nbsp;</p>
<p>What got me excited about this project was the fact that we were tasked with building it in 2 weeks, and had complete technical control over the project.</p>
<p>After looking into what was going to be required for the project, including security, scalability and complex document processing, we decided to use <a href="http://nodejs.org/">node.js</a> for the server side and a very powerful client side rendering and binding system named <a title="gaffa-js" href="https://github.com/gaffa-tape/gaffa-js" target="_blank">gaffa-js</a> on the client side. My colleague has written a blog post about the front end development if you are interested in reading more about that <a href="http://korynunn.wordpress.com/2013/05/20/deploying-a-web-app-in-14-days-no-html/">Deploying a web app in 14 days no html</a></p>
<p>&nbsp;</p>
<p><b>Node.js as a server</b></p>
<p>I am a big fan of JavaScript and have used it as my primary programing language for some time now. The reason this is even possible is the introduction of <a href="http://nodejs.org/">node.js</a>.</p>
<p>Node is a JavaScript runtime which allows server-side applications to be written in JavaScript. It excels at delivering fast, efficient data processing with a minimal CPU and Memory footprint. This makes it perfect for what we were trying to achieve with <a href="https://signforms.com/">SignForms</a>.</p>
<p>&nbsp;</p>
<p><b>Modules</b></p>
<p>I am not a fan of the “<i>web application frameworks”</i> such as <a href="http://expressjs.com/">express.js</a> being widely used without thinking about what is really required. I find them bloated, and unnecessary in most situations (kinda like jQuery…) and personally I much prefer to use a number of smaller modules to build my own solution.</p>
<p><a href="https://github.com/xavi-/beeline">Beeline &#8211; A laughably simplistic router for node.js</a></p>
<p>I have been using Beeline for a lot of my projects lately. As it says on the box, it is laughably simple router which takes seconds to setup. It supports everything from simple catch all routes to very powerful regex matching.</p>
<p><a href="https://github.com/jed/cookies">Cookies</a> and <a href="https://github.com/jed/keygrip">Keygrip</a></p>
<p>Cookies and Keygrip are 2 modules from <a href="http://jed.is/">Jed Schmidt</a> that again I have been using in many, if not all of my projects of late. Cookies provides a simple wrapper around the getting and setting HTTP(S) cookie headers, and can be used in conjunction with Keygrip to provide additional security by signing the cookie to prevent tampering.</p>
<p><a href="https://github.com/ncb000gt/node.bcrypt.js">Bcrypt – The only way to store passwords</a></p>
<p>If you are doing anything with passwords or any other sensitive data, and you are not using bcrypt, please, please, please get educated. Here is a good place to start. <a href="http://codahale.com/how-to-safely-store-a-password/">How to Safely Store A Password</a></p>
<p><a href="https://github.com/MauriceButler/Cryptr">Cryptr</a></p>
<p>Cryptr is a simple encrypt and decrypt module for node.js that I have written myself for doing simple obfuscation / aes256 encryption on values that need to be decrypted at a later time</p>
<p>I currently use this for a number of items which are encrypted for obscurity rather than any real security.</p>
<p><a href="https://github.com/felixge/node-formidable">Formidable</a></p>
<p>Formidable is a module for parsing form data, but comes into its own when processing file uploads.</p>
<p>I had not used Formidable before this project but after doing a lot of research and doing a lot of testing, it came out on top as the simplest, fastest and most secure way of handling multiple file uploads.</p>
<p>&nbsp;</p>
<p><strong>Database Selection</strong></p>
<p>A lot of time was spent to determine the correct database platform to use for SignForms. In house there was already precedence and knowledge in <a href="http://www.orientdb.org/">OrientDB</a>, <a href="http://couchdb.apache.org/">CouchDB</a> and <a href="http://www.mongodb.org/">MongoDB</a> so the decision was around what platform would best suit the type of data we are going to have to store.</p>
<p>While there was a lot of research done and a lot of points considered, a lot of comparisons such as <a href="http://blog.nahurst.com/visual-guide-to-nosql-systems">Visual Guide to NoSQL Systems</a> were used as references and eventually we decided on MongoDB. The key decision points for use were:</p>
<ul>
<li>Dynamic Queries</li>
<li>Most likely gain benefit from indexes vs map reduce (although we do have some map reduce requirements)</li>
<li>Database size will most likely grow large thus distributed partitions maybe be required in the future.</li>
<li>Performance of large datasets.</li>
<li>Storing a large amount of volatile data, at least until documents are finalised.</li>
</ul>
<p>Additionally, <a href="http://mongoosejs.com/">Mongoose</a> the node.js wrapper for MongoDB was a breeze to setup and work with making database access simple and fast from our chosen server platform.</p>
<p>&nbsp;</p>
<p><b>Document Processing</b></p>
<p>Here in lies the challenge. When looking into the requirements for this project the only thing that really scared me was how the hell was going to process and manipulate the pdf files. I spent days working with different tools and approaches to the problem. I hit many a brick wall but also came across a number of insightful discoveries of things I didn&#8217;t even know existed.</p>
<p>This was a challenging journey and probably deserves its own post about how these problems were solved. I will aim to have that post up in a few days.</p>
<p>&nbsp;</p>
<p>I am very proud of what we have achieved in a short amount of time and owe it all to the speed and power of JavaScript! So go check it out. <a title="Sign Forms" href="http://signforms.com" target="_blank">signforms.com</a></p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/283/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=283&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2013/05/16/signforms-going-paperless-just-got-easy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2013/05/signforms.png" medium="image">
			<media:title type="html">SignForms</media:title>
		</media:content>
	</item>
		<item>
		<title>Sooo jQueries, How do they work?</title>
		<link>http://mauricebutler.wordpress.com/2012/05/09/sooo-jqueries-how-do-they-work/</link>
		<comments>http://mauricebutler.wordpress.com/2012/05/09/sooo-jqueries-how-do-they-work/#comments</comments>
		<pubDate>Tue, 08 May 2012 22:35:37 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=271</guid>
		<description><![CDATA[Last night I have a talk at BrisJS, attempting to remove some of the magic and mystery around jQuery and its selection API. I hope for those that attended it will help you to realise that it is not so scary and is quite readable. The slides can be found here. Again, credit to Jared Wyles [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=271&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Last night I have a talk at <a title="BrisJS" href="http://www.meetup.com/BrisJS/" target="_blank">BrisJS</a>, attempting to remove some of the magic and mystery around jQuery and its selection API.</p>
<p>I hope for those that attended it will help you to realise that it is not so scary and is quite readable.</p>
<p>The slides can be found <a title="Slides" href="http://mauricebutler.github.com/jQuery-How-does-it-work/" target="_blank">here</a>.</p>
<p>Again, credit to Jared Wyles (<a href="https://twitter.com/rioter" target="blank">@rioter</a>) whos talk at <a title="DDD Brisbane" href="http://www.dddbrisbane.com/" target="_blank">DDDBrisbane</a> last year is where the idea was <del>blatantly stolen</del> &#8221;borrowed&#8221;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=271&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2012/05/09/sooo-jqueries-how-do-they-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>
	</item>
		<item>
		<title>Duck Punching</title>
		<link>http://mauricebutler.wordpress.com/2012/03/06/duck-punching/</link>
		<comments>http://mauricebutler.wordpress.com/2012/03/06/duck-punching/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 23:35:43 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[BrisJS]]></category>
		<category><![CDATA[Duckies]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=247</guid>
		<description><![CDATA[&#8230; if it walks like a duck and talks like a duck, it’s a duck, right? So if this duck is not giving you the noise that you want, you’ve got to just punch that duck until it returns what you expect. &#160; Last night at BrisJS I gave an impromptu lightning talk on the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=247&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://mauricebutler.files.wordpress.com/2012/03/duck-punch.png"><img src="http://mauricebutler.files.wordpress.com/2012/03/duck-punch.png?w=300&#038;h=258" alt="duck punch" title="duck-punch" width="300" height="258" class="aligncenter size-medium wp-image-252" /></a></p>
<blockquote><p>&#8230; if it walks like a duck and talks like a duck, it’s a duck, right? So if this duck is not giving you the noise that you want, you’ve got to just punch that duck until it returns what you expect.</p></blockquote>
<p>&#160;</p>
<p>Last night at <a href="http://www.meetup.com/BrisJS/" target="_blank">BrisJS</a> I gave an impromptu lightning talk on the concept of Duck Punching.</p>
<p>And no, I am not going around beating up poor little duckies&#8230;</p>
<p>&#160;</p>
<p><a href="http://mauricebutler.files.wordpress.com/2012/03/runducksrun.png"><img src="http://mauricebutler.files.wordpress.com/2012/03/runducksrun.png?w=901" alt="Run Ducks Run" title="RunDucksRun"   class="aligncenter size-full wp-image-253" /></a></p>
<p>&#160;</p>
<p>I&#8217;ll show here the brief example I spoke about last night, as I did a very quick overview without explaining it much, but for some better examples and some more info check out <a href="http://paulirish.com/2010/duck-punching-with-jquery/" target="_blank">this post</a> from <a href="https://twitter.com/paul_irish" target="_blank">Paul Irish</a>.</p>
<p>&#160;</p>
<p>Duck punching also know as <a href="http://en.wikipedia.org/wiki/Monkey_patch" target="_blank">Monkey Patching</a>. is an approach to extend or modify the runtime code of dynamic languages (such as JavaScript) without altering the original source code.</p>
<p>So for example I am sure everyone is aware of the jQuery function &#8220;toDuck()&#8221; and the current bug where the duck says the wrong thing&#8230;</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.fn.toDuck= function(){
        this.text(&quot;The duck says: Moo!&quot;)
    };
</pre>
<p>On our site we want to use this function to show some ducks.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div&gt;Hello World&lt;/div&gt;
&lt;button&gt;Make it a duck!&lt;/button&gt;​
</pre>
<pre class="brush: jscript; title: ; notranslate">
$('button').on('click', function() {
    
    $('div').toDuck();
    
});
</pre>
<p>Result:</p>
<pre> The duck says: Moo! </pre>
<p>&#160;</p>
<p>OK so we want to change the functionality / fix this bug but we don&#8217;t want to go edit the original source as its minified, will make it harder to take upgrades, etc. To achieve this then we can use duck punching to &#8220;enhance&#8221; this functionality.</p>
<p>&#160;</p>
<pre class="brush: jscript; title: ; notranslate">
(function($) {

    // store original reference to the method
    var orig = $.fn.toDuck;

    $.fn.toDuck = function() {
   
        // Do original function
        orig.apply(this,arguments);
            
        if (this.text() === 'The duck says: Moo!') {
            this.append(&quot;  *Punch*  Woof!  *Punch* *Punch*  Quack?... *Gives Ducky bread*&quot;);
        }
        
    };
}(jQuery));
</pre>
<p>&#160;</p>
<p>And our new result:</p>
<pre> The duck says: Moo! *Punch* Woof! *Punch* *Punch* Quack?... *Gives Ducky bread* </pre>
<p>&#160;</p>
<p>As you can see the original functionality remains untouched but we get our desired quack.</p>
<p>Should the original method be fixed down the track our condition will fail and the additional functionally will not be run. </p>
<p>This very strange and contrived example can be on jsFiddle <a href="http://jsfiddle.net/maurice_butler/hHkHp/" target="_blank">here</a>.</p>
<p>&#160;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=247&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2012/03/06/duck-punching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2012/03/duck-punch.png?w=300" medium="image">
			<media:title type="html">duck-punch</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2012/03/runducksrun.png" medium="image">
			<media:title type="html">RunDucksRun</media:title>
		</media:content>
	</item>
		<item>
		<title>Promote JS</title>
		<link>http://mauricebutler.wordpress.com/2012/02/07/promote-js/</link>
		<comments>http://mauricebutler.wordpress.com/2012/02/07/promote-js/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 01:21:26 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[PromoteJS]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=214</guid>
		<description><![CDATA[&#160; Documentation of the JavaScript API sucks&#8230; Well it did. &#160; I would assume everyone has as some stage come across the scourge that is w3schools. &#60;- see not linked. Also please don&#039;t Google them&#8230; These guys are bad, crap shocking and in many cases just plain old wrong. Unfortunately they take out the top [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=214&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>Documentation of the JavaScript API sucks&#8230;  Well it did.</p>
<p>&#160;</p>
<p>I would assume everyone has as some stage come across the scourge that is w3schools. &lt;- see not linked. Also please don&#039;t Google them&#8230;</p>
<p>These guys are bad, crap shocking and in many cases just plain old wrong. Unfortunately they take out the top few results in a Google search for most JavaScript methods.</p>
<p>&#160;</p>
<p><a href="http://mauricebutler.files.wordpress.com/2012/02/replaceresults.png"><img src="http://mauricebutler.files.wordpress.com/2012/02/replaceresults.png?w=445&#038;h=300" alt="Replace Results" title="Replace Results" width="445" height="300" class="size-medium wp-image-230" /></a><a href="http://mauricebutler.files.wordpress.com/2012/02/indexofresults.png"><img src="http://mauricebutler.files.wordpress.com/2012/02/indexofresults.png?w=445&#038;h=300" alt="IndexOf Results" title="IndexOf Results" width="445" height="300" class="alignnone size-medium wp-image-229" /></a></p>
<p>&#160;</p>
<p>This has been a problem for some time and even <a href="http://www.impressivewebs.com/web-development-search-results-manipulated/" target="_blank">blocking them from your search results is not easy</a>.</p>
<p>Fortunately someone has done something about this.</p>
<p>Enter the <a href="https://developer.mozilla.org/en/JavaScript/Reference" target="_blank">MDN JavaScript Reference</a>. This has been around for a while and I know a number of informed people go here directly and use it.</p>
<p>Unfortunately it is not high in the search rankings however thus non informed / beginners are not seeing the gold mine of information.</p>
<p>This is something I thought I don&#039;t have much control over and just needed to do my best to tell people not to use w3schools.</p>
<p>&#160;</p>
<p>Last night I attended and spoke at the first <a href="http://www.meetup.com/BrisJS/events/46911112/" target="_blank">BrisJS Meetup for 2012</a></p>
<p>One of the other speakers <a href="https://twitter.com/secoif/" target="_blank">Tim Oxely</a> pointed out something which I was not aware of but am very excited about. <a href="http://promotejs.com/" target="_blank">promotejs.com</a></p>
<p>&#160;</p>
<p><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String' title='JavaScript String .slice'><img src='http://static.jsconf.us/promotejsv.gif' height='280' width='160' alt='JavaScript String .slice' /></a><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String' title='JS String .substring'><img src='http://static.jsconf.us/promotejsh.gif' height='150' width='180' alt='JS String .substring' /></a><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String' title='JavaScript String .length'><img src='http://static.jsconf.us/promotejsh.gif' height='150' width='180' alt='JavaScript String .length' /></a><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String' title='JS String search'><img src='http://static.jsconf.us/promotejsh.gif' height='150' width='180' alt='JS String search' /></a><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array' title='JS Array map'><img src='http://static.jsconf.us/promotejsv.gif' height='280' width='160' alt='JS Array map' /></a></p>
<p>&#160;</p>
<p>This is great! I get a simple, easy way to promote a far superior reference site and also assist in the SEO for MDN to hopefully one day knock w3schools off the top.</p>
<p>It might not be time to spam F5 at <a href="http://arewefirstyet.com/" target="_blank">arewefirstyet.com</a> yet but the day will come!</p>
<p>&#160;</p>
<p><img src="http://www.reactiongifs.com/wp-content/uploads/2011/05/dwayne-the-rock-johnson_likes_it.gif" title="He Likes It!" alt="He Likes It!" /></p>
<p>&#160;</p>
<p>So I implore you. Every chance you get. Add a <a href="http://promotejs.com/" target="_blank">promotejs.com</a> link on your site, page, blog or anywhere you can get away with it&#8230;</p>
<p>&#160;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/214/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=214&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2012/02/07/promote-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2012/02/replaceresults.png?w=300" medium="image">
			<media:title type="html">Replace Results</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2012/02/indexofresults.png?w=300" medium="image">
			<media:title type="html">IndexOf Results</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsv.gif" medium="image">
			<media:title type="html">JavaScript String .slice</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsh.gif" medium="image">
			<media:title type="html">JS String .substring</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsh.gif" medium="image">
			<media:title type="html">JavaScript String .length</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsh.gif" medium="image">
			<media:title type="html">JS String search</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsv.gif" medium="image">
			<media:title type="html">JS Array map</media:title>
		</media:content>

		<media:content url="http://www.reactiongifs.com/wp-content/uploads/2011/05/dwayne-the-rock-johnson_likes_it.gif" medium="image">
			<media:title type="html">He Likes It!</media:title>
		</media:content>
	</item>
		<item>
		<title>Unreadable JavaScript performance tricks you will never use.</title>
		<link>http://mauricebutler.wordpress.com/2012/02/07/unreadable-javascript-performance-tricks-you-will-never-use/</link>
		<comments>http://mauricebutler.wordpress.com/2012/02/07/unreadable-javascript-performance-tricks-you-will-never-use/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 00:04:43 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=216</guid>
		<description><![CDATA[&#160; Last night I spoke at the first BrisJS Meetup for 2012 The title of the presentation was &#8220;Confusing &#38; completely unreadable JavaScript performance tricks that you will most probably never use.&#8221; &#160; For those interested the slides for the presentation can be found here. (Please feel free to send me a pull request to [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=216&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>Last night I spoke at the first <a href="http://www.meetup.com/BrisJS/events/46911112/" target="_blank">BrisJS Meetup for 2012</a></p>
<p>The title of the presentation was <strong>&#8220;Confusing &amp; completely unreadable JavaScript performance tricks that you will most probably never use.&#8221;</strong></p>
<p>&#160;</p>
<p>For those interested the slides for the presentation can be found <a href="http://mauricebutler.github.com/Unreadable-JavaScript-performance-tricks/" target="_blank">here</a>.</p>
<p>(Please feel free to send me a <a href="https://github.com/MauriceButler/Unreadable-JavaScript-performance-tricks" target="_blank">pull request</a> to fix my atrocious spelling&#8230;)</p>
<p>As this is an <a href="https://github.com/bartaz/impress.js" target="_blank">impress.js</a> presentation a decent browser is required to view the correctly but the fall back should work if you are still forced to use a trojan&#8230;</p>
<p>&#160;</p>
<p>Also as was pointed out by <a href="https://twitter.com/secoif/" target="_blank">Tim Oxely</a> every chance you get link to these guys&#8230; <a href="http://promotejs.com/" target="_blank">promotejs.com</a></p>
<p><a href='https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String' title='JS String .substring'><img src='http://static.jsconf.us/promotejsh.gif' height='150' width='180' alt='JS String .substring' /></a></p>
<p>&#160;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=216&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2012/02/07/unreadable-javascript-performance-tricks-you-will-never-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://static.jsconf.us/promotejsh.gif" medium="image">
			<media:title type="html">JS String .substring</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting started with JavaScript with a C# background</title>
		<link>http://mauricebutler.wordpress.com/2011/11/07/getting-started-with-javascript-with-a-c-background/</link>
		<comments>http://mauricebutler.wordpress.com/2011/11/07/getting-started-with-javascript-with-a-c-background/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 08:35:20 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[c# javaScript]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=134</guid>
		<description><![CDATA[Over the past few years, I have worked with a number of developers new to Web Development and JavaScript and I have noticed that most people seam to stumble at the same places and make the same mistakes that I did when first moving into JavaScript development. I believe most of the confusion comes from [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=134&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Over the past few years, I have worked with a number of developers new to Web Development and JavaScript and I have noticed that most people seam to stumble at the same places and make the same mistakes that I did when first moving into JavaScript development. I believe most of the confusion comes from moving from a strongly typed language such as VB.NET or C# to the flexibility of a dynamic language such as JavaScript.</p>
<p>In this post I will try to explain some of the basic concepts and approaches used in JavaScript development that may not seam as obvious to someone first starting out.</p>
<p>For a quick easy way to follow the examples in this post I recommend <a title="Jsfiddle.net" href="http://jsfiddle.net" target="_blank">jsfiddle.net</a>.</p>
<p>&#160;</p>
<p><strong>1. Scope</strong></p>
<p>I can say without a doubt, the most commonly misunderstood concept of JavaScript by new developers is Scope. Scope in JavaScript works very different than scope in C#. Unfortunately to explain how JavaScript Scope works I first need to cover a few other items. We will revisit Scope a little later.</p>
<p>&#160;</p>
<p><strong>2. Types</strong>     <br />JavaScript there are only 5 primitive types: boolean, string, number, null and undefined. Anything else we come across is an object. (including functions but we will get to that later&#8230;)</p>
<p>The JavaScript boolean and string types behave very similarly to their C# counter parts. There are some minor differences, but I wont go into those here.</p>
<p>The other types however are a little bit more interesting.</p>
<p>The JavaScript number type for instance represents a 64-bit floating-point double. JavaScript has no float, int, double or any other types to represent numbers. The other interesting point is the 2 valid number values NaN and Infinity. The value NaN (stands for Not a Number) occurs when a value is returned as a number type, but the value is not parseable as a number. This is usually when trying to parse a non numeric string value (such as &quot;abc&quot;) to a number. The value infinity occurs when a number exceeds the upper limit of the floating point numbers, which is 1.7976931348623157E+10308.</p>
<p>The JavaScript null type is similar to the C# Null however it does have one gotcha. When applying the typeof operator to a null value, it will return &quot;object&quot;. This is actually completely wrong, and is a mistake that was made very early in the language&#8217;s standardisation.</p>
<p>The JavaScript undefined type is similar to null, however while null means a variable or property has no value, undefined means that the variable or property does not exist. For a variable it can also mean that the variable was declared but never assigned a value. This concept may be strange when first starting to work with JavaScript as usually a compiler would complain if a variable or property used when it didn&#8217;t exist. Because JavaScript is a dynamic language and the differences between different browsers, these cases are common and a defensive approach needs to be taken when you are not sure a variable or property is going to exist at runtime. (see the Truthy and Falsey section for how to check for the existence of a variable or property)</p>
<pre class="brush: jscript; title: ; notranslate">
var foo;
console.log(typeof foo); // undefined

foo = 123;
console.log(typeof foo); // number

foo = &quot;abc&quot;;
console.log(typeof foo); // string

foo = true;
console.log(typeof foo); // boolean

foo = null;
console.log(typeof foo); // object

foo = {};
console.log(typeof foo); // object
</pre>
<p>As you can see the variable foo was declared without assigning a value. At this point in time the type of foo is undefined. The same variable foo is then reused and assigned multiple values. As each value is assigned, the type of the variable changed to the type of its value.</p>
<p>
<b>Update:</b><br />
For completeness I will also add the function type. While not a primitive type, performing a typeof on a function object will return the sting &#8216;function&#8217;. Function objects are explained further in the Functions are objects section.</p>
<pre class="brush: jscript; title: ; notranslate">
foo = function() {};
console.log(typeof foo); // function
</pre>
</p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>&#160;</strong></p>
<p><strong>3. Truthy and Falsey</strong></p>
<p>While JavaScript has a bool type, due to the magic or coercion we just saw in the types section, these are not the only types that can be evaluated in a true or false manner. Enter Truthy and Falsey.</p>
<p>In JavaScript any object can be automatically coerced into a boolean representation (i.e. true or false). I had a number of goes at simplifying my explanation of this and eventual got it down to one sentence:</p>
<p>Anything that exists and has a value will evaluate as true unless the value is false, null, undefined, 0, NaN or an empty string.</p>
<pre class="brush: jscript; title: ; notranslate">
var foo;

if(foo) // exists but is undefined -&gt; evaluate as false
{
    console.log(foo); // will not execute
}

foo = &quot;Hello World&quot;;

if(foo) // exists and has a value -&gt; evaluate as true
{
    console.log(foo); // will execute    
}
</pre>
<p>In this example, If the variable is undefined, the condition evaluates as false. If the variable exists, but has a value of 0, the condition again evaluates as false. It&#8217;s only if the variable has been declared and assigned a truthy value that the if block would be entered.</p>
<p>We can now use these concepts to write defensive JavaScript, by ensuring variables or properties exist before using them. This is also a common approach for feature detection.</p>
<pre class="brush: jscript; title: ; notranslate">
if (someObject &amp;&amp; !someObject.foo){
    someObject.foo = 'foo';
}

console.log(someObject.foo); 
</pre>
<p>The above code checks if someObject is truthy (not null etc) and if someObject.foo has been defined. If someObject.foo has not been defined it will set it to the string value &#8216;foo&#8217; before continuing to log it out.</p>
<p>&#160;</p>
<p><strong>4. Functions are objects</strong></p>
<p>Now this is the tricky one. A function in JavaScript is an object just like any other object. While this concept might not be as huge a deal for someone familiar with Generics and Lambda expressions, it is still a big difference between C# and JavaScript.</p>
<p>You can create anonymous functions, assign a function to a variable, pass that variable to another function, change the function object to do other things, parse it as a string and many more weird and wonderful things.</p>
<p>This should look familiar. Define a function called foo and then call the named function.</p>
<pre class="brush: jscript; title: ; notranslate">
function foo(){ 
    console.log('bar');
}

foo();  // bar
</pre>
<p>But how about this?    </p>
<pre class="brush: jscript; title: ; notranslate">
var foo = function (){ 
    console.log('bar');
}

foo();  // bar
</pre>
<p>In the second example, we defined an anonymous function and assigned to to the variable foo.</p>
<p>We now have a variable foo which we can do what we please with.    </p>
<pre class="brush: jscript; title: ; notranslate">
console.log(foo); // function (){ 
                  //     console.log('bar');
                  // }

foo.randomProperty = &quot;We just added a property to an object&quot;;

console.log(foo.randomProperty); // We just added a property to an object
</pre>
<p>These few things are but a scratch on the surface of what can be done, so you can see a function object is very flexible.</p>
<p>&#160;</p>
<p><strong>5. Hoisting</strong></p>
<p>When JavaScript is executed, the interpreter moves or &#8220;hoists&#8221; all variable declarations to the top of their containing function / scope boundary, regardless of where they occur. Take the below code for example.</p>
<pre class="brush: jscript; title: ; notranslate">
var foo = 'global foo';

function myFunction() {
    console.log(foo);
}

myFunction();
</pre>
<p>This code defines a global variable foo and sets its value to &#8216;global foo&#8217;. We then call my function that logs the value of foo. Now lets change this function so that it logs the global variable and then logs a local version of foo;</p>
<pre class="brush: jscript; title: ; notranslate">
var foo = 'global foo';

function myFunction() {
    console.log(foo); // undefined
    var foo = 'local foo';
    console.log(foo); // local foo
}

myFunction();
</pre>
<p>Why does the first console.log return undefined? What has happened is the redefinition of foo has been hoisted to the sounding scope boundary. The code that is actually being executed after hoisting has occurred looks like this.</p>
<pre class="brush: jscript; title: ; notranslate">
var foo = 'global foo';

function myFunction() {
    var foo;
    console.log(foo); // undefined
    foo = 'local foo';
    console.log(foo); // local foo
}

myFunction();
</pre>
<p>As you can see, at runtime the re-declaration of foo has been defined but not assigned, thus the first console.log is correctly logging undefined.</p>
<p>&#160;</p>
<p><strong>6. Scope Revisited</strong></p>
<p>OK. Time to talk about Scope.    </p>
<p>In C#, scope is introduced by braces or are &quot;Block Scoped&quot;. A variable declared inside a class, function, loop, condition block, etc are available to all members within the blocks braces. That being the case we should all agree that the below C# code will write 0 1 2 3 4 5</p>
<pre class="brush: csharp; title: ; notranslate">
 public void Method1()
 {
  var elements = new int[] { 0, 1, 2, 3, 4, 5 }; // available everywhere in the function

  for (var i = 0; i &lt; elements.Length; i++)
     {
        var element = elements[i]; // available only within this for loop
          Console.Write(element);
     }
 }
</pre>
<p>In JavaScript however, functions define scope. A variable declared outside of a function is in the global namespace. As in any language, you should try to avoid polluting the global namespace. A variable declared in a function is visible anywhere inside that function, and because of hoisting this is the case regardless of where it is defined. Variables defined within a function are not visible outside the function. This sounds a lot simpler than it is and the best way to explain is with examples.</p>
<p>Here is the JavaScript version of the above code.    </p>
<pre class="brush: jscript; title: ; notranslate">
function Method1(){
var elements = [0, 1, 2, 3, 4, 5]; // available everywhere in the function
         

for(var i = 0; i &lt; elements.length; i++) {
  var element = elements[i]; // remember Hoisting? will be available everywhere, even though it was originally declared inside the for loop
  console.log(element);
}
}
</pre>
<p>Again executing the code will produce 0 1 2 3 4 5.</p>
<p>As we covered in the Functions section, a function can be treated like any other object, including being added to an array. We will now take the the array of values and create an array of functions that return the original values.</p>
<pre class="brush: jscript; title: ; notranslate">

function Method1(){
var elements = [0, 1, 2, 3, 4, 5],
    functions= [];

for(var i = 0; i &lt; elements.length; i++) {
  var element = elements[i]; // remember Hoisting?
  functions.push(function() {
      console.log(element);
    });
}

functions[3]();
}

</pre>
<p>The above code again iterates through the elements array, but this time adds an element to the functions array which is an anonymous function to log the corresponding value from the elements array. The last line of the above snippet addresses the object in the 3rd position of the functions array (<em>functions[3]</em>) and then executes it as a function (<em>();</em>).</p>
<p>Still with me?</p>
<p><a href="http://mauricebutler.files.wordpress.com/2011/10/achievementunlockedjavascriptpadawan.png"><img class="alignnone size-medium wp-image-167" title="AchievementUnlockedJavaScriptPadawan" alt="Achievement Unlocked JavaScript Padawan" src="http://mauricebutler.files.wordpress.com/2011/10/achievementunlockedjavascriptpadawan.png?w=300&#038;h=60" width="300" height="60" /></a></p>
<p>&#160;</p>
<p>If you have got your mind around that, now take a guess at what value would be logged by the execution of this function. The C# developer in you will be thinking it should log 3. If that is the case, the C# developer in you would be wrong. Its actually 5&#8230;</p>
<p>As discussed before, JavaScript does not have &quot;Block Scope&quot; thus the for loop has not introduced new scope. This means that each time the element variable is accessed, the same memory location is updated, rather than a loop iteration specific variable as one would expect in C#. So when the loop has finished, the variable &#8216;element&#8217; has the value of 5.</p>
<p>To correct this we need to introduce a function to create scope around our variable reference. For ease of explanation we will first just wrap our for block in an anonymous, auto executing function, (often referred to a closure) and pass the element parameter into this function.</p>
<pre class="brush: jscript; title: ; notranslate">

function Method1(){
var elements = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    i,
    functions= [];

for (i = 0; i &lt; elements.length; i++) {

    (function (element) {                    // start of closure

        functions.push(
            function() {
                console.log(element);
            });
        
    }(elements[i]));                         // end of closure
}

functions[3]();
}
</pre>
<p>We now log 3 as originally expected.The code is now similar to the C# example as the element variable is declared, assigned used and destroyed within the for loop. This is because Hoisting moves variables to the top of a function, the closure stops it bubbling up to the same location as the other variable declarations.</p>
<p>&#160;</p>
<p><strong>7. Namespacing Patterns</strong></p>
<p>In C# we rely heavily on namespacing to group together like functionality and avoid collisions with other objects or variables in the global namespace.</p>
<p>As JavaScript has no concept of a class, there is also no concept of namespacing in the form you are used to. We can however use what we have just learned by using objects, functions and closure scope to achieve a similar effect.</p>
<p>I am not going to go into details on the different approaches to namespacing within JavaScript, because I stumbled across this post by Addy Osmani (<a title="@addyosmani" href="http://twitter.com/#!/addyosmani" target="_blank">@addyosmani</a>) that covers it much better and in more detail than I ever could. <a title="Essential JavaScript Namespacing Patterns" href="http://addyosmani.com/blog/essential-js-namespacing/" target="_blank">http://addyosmani.com/blog/essential-js-namespacing/</a></p>
<p>&#160;</p>
<p><strong>8. Conclusion</strong></p>
<p>There is a whole lot more to the language than what I have described here but I hope this post will help some people making the transition to JavaScript avoid some of the common misunderstands that can cause frustrations in the early days.</p>
<p>&#160;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=134&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2011/11/07/getting-started-with-javascript-with-a-c-background/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/10/achievementunlockedjavascriptpadawan.png?w=300" medium="image">
			<media:title type="html">AchievementUnlockedJavaScriptPadawan</media:title>
		</media:content>
	</item>
		<item>
		<title>Signing Executable error SignTimeStamp (-2147467259/0&#215;80004005)</title>
		<link>http://mauricebutler.wordpress.com/2011/10/17/signing-executable-error/</link>
		<comments>http://mauricebutler.wordpress.com/2011/10/17/signing-executable-error/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 23:24:59 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[General Tech]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=189</guid>
		<description><![CDATA[Just a quick note on a cryptic error I came across the other day. I was working on a remote server, trying to determine why our build system was failing trying to sign our executables. The command being run was: signtool.exe sign /SHA1 [thumbprint] /t http://timestamp.verisign.com/scripts/timstamp.dll /d [Executable Name] [Executable Path] And the error I [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=189&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Just a quick note on a cryptic error I came across the other day.</p>
<p>I was working on a remote server, trying to determine why our build system was failing trying to sign our executables.</p>
<p>The command being run was: </p>
<pre>signtool.exe sign /SHA1 [thumbprint] /t http://timestamp.verisign.com/scripts/timstamp.dll /d [Executable Name] [Executable Path] </pre>
<p>And the error I was receiving was </p>
<pre>SignTimeStamp (-2147467259/0x80004005)</pre>
<p>As far as I could tell (-2147467259/0&#215;80004005) appeared to be a very generic COM exception and was not very helpful.</p>
<p>The problem actual turned out to be very simple.</p>
<p>While I did know this, I had forgotten that the server in question had no access to the internet. This meant the call to the time server via the -t switch was failing and producing this lovely, and informative error.</p>
<p>The short term workaround for me was to completely remove the -t switch until this group of machines is given internet access. This allows the executable to be signed, and the build and deploy succeed, while we continue to setup this environment. This is however a temporary environment. </p>
<p>Be aware that by not using a time stamp when you sign your executable means the signature is only valid until the certificate expires and thus is most likely not a valid work around in a production system..</p>
<p>With any luck this will stop someone else wasting their time trying to track down the cause of this lovely error message.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=189&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2011/10/17/signing-executable-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>
	</item>
		<item>
		<title>Strange errors in generated file DataServiceImplementation.cs in LightSwitch</title>
		<link>http://mauricebutler.wordpress.com/2011/09/02/strange-errors-in-generated-file-dataserviceimplementation-cs-in-lightswitch/</link>
		<comments>http://mauricebutler.wordpress.com/2011/09/02/strange-errors-in-generated-file-dataserviceimplementation-cs-in-lightswitch/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 00:12:51 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[LightSwitch]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=115</guid>
		<description><![CDATA[Over the past week or so I have been playing with LightSwitch and have been very impressed with what I have found. That being said, while I know this problem was my fault for being lazy, I have come across my first batch of strange code generation errors. While simple to solve I assume I [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=115&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Over the past week or so I have been playing with <a href="http://www.microsoft.com/visualstudio/en-us/lightswitch" title="LightSwitch" target="_blank">LightSwitch </a>and have been very impressed with what I have found.</p>
<p>That being said, while I know this problem was my fault for being lazy, I have come across my first batch of strange code generation errors.  While simple to solve I assume I am probably not the only person to make this mistake so thought I would share my findings.</p>
<p>As part of learning about LightSwitch, I have been going through and following a number of tutorials on the various aspects. </p>
<p>Currently I am looking at using RIA services as a data source and have been following the <a href="http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/34/Creating-a-Simple-LightSwitch-RIA-Service-using-POCO.aspx" title="Creating a Simple LightSwitch RIA Service (using POCO)" target="_blank">Creating a Simple LightSwitch RIA Service (using POCO)</a> tutorial from <a href="http://lightswitchhelpwebsite.com" title="LightSwitch Help Website" target="_blank">LightSwitch Help Website</a>.</p>
<p>Rather than download the code sample, I was rewriting the code step by step. However once I added my data source to the LightSwitch application and tried to compile I received these errors in DataServiceImplementation.cs within the ServerGenerated project.</p>
<pre>
Error	1	) expected
Error	2	Invalid expression term ')'
Error	3	; expected
Error	4	; expected
Error	5	A new expression requires (), [], or {} after type
Error	6	; expected
</pre>
<p><a href="http://mauricebutler.files.wordpress.com/2011/09/errorlist.png"><img src="http://mauricebutler.files.wordpress.com/2011/09/errorlist.png?w=600&#038;h=172" alt="ErrorList" title="ErrorList" width="600" height="172" class="size-medium wp-image-118" /></a></p>
<p>Of course I thought generation errors probably mean I have done something wrong. I looked over the code I had written and it all roughly matched what was provided in the tutorial. I then downloaded the tutorial source and saw that it compiled and worked correctly.</p>
<p>Puzzled I took a closer look at my code and decided to clean it up as I had been lazy and just dumped everything in the same file while I was working. Upon doing so I noticed that when I created the CustomerRecord model class, I accidentaly created it as a nested class of the domain service class.</p>
<p>i.e.</p>
<pre class="brush: csharp; title: ; notranslate">
public class DomainService
{
    public class CustomerRecord
    {           
    }
}
</pre>
<p>instead of </p>
<pre class="brush: csharp; title: ; notranslate">

public class DomainService
{
}

public class CustomerRecord
{
}

</pre>
<p>After refactoring this class into its own file as I should have done in the first place, and updating the data source the solution copiled correctly.</p>
<p>With any luck this will help someone else that makes the same stupid mistake as me.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=115&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2011/09/02/strange-errors-in-generated-file-dataserviceimplementation-cs-in-lightswitch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/09/errorlist.png?w=300" medium="image">
			<media:title type="html">ErrorList</media:title>
		</media:content>
	</item>
		<item>
		<title>First Impressions of Microsoft Visual Studio LightSwitch</title>
		<link>http://mauricebutler.wordpress.com/2011/09/01/first-impressions-of-microsoft-visual-studio-lightswitch/</link>
		<comments>http://mauricebutler.wordpress.com/2011/09/01/first-impressions-of-microsoft-visual-studio-lightswitch/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 08:27:28 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Tech]]></category>
		<category><![CDATA[LightSwitch]]></category>
		<category><![CDATA[TechEd]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=106</guid>
		<description><![CDATA[A couple of weeks ago I attended the Tech Ed Australia 2011 Brisbane Preview breakfast session. As I am not actually attending Tech Ed this year, this was a chance for me to see some short and sweet versions of a few of the sessions being presented. One of the sessions that took my fancey [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=106&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A couple of weeks ago I attended the <a href="http://blogs.msdn.com/b/ausdev/archive/2011/08/11/tech-ed-australia-2011-brisbane-preview.aspx" title="Tech Ed Australia 2011 Brisbane Preview breakfast session" target="_blank">Tech Ed Australia 2011 Brisbane Preview breakfast session</a>. As I am not actually attending Tech Ed this year, this was a chance for me to see some short and sweet versions of a few of the sessions being presented.</p>
<p>One of the sessions that took my fancey was the Introduction of Visual Studio LightSwitch by Andrew Coates (<a href="http://twitter.com/#!/coatsy" title="@coatsy" target="_blank">@coatsy</a>).</p>
<p>As a result, over the past week or so I have been playing with <a href="http://www.microsoft.com/visualstudio/en-us/lightswitch" target="_blank">LightSwitch</a> and have been very impressed with what I have found. </p>
<p>For those of you who have not seen or heard of it yet, LightSwitch is a self-service development tool that enables non developers to build business applications quickly and easily. While it lends itself well to forms over data type systems, with a SilverLight client it is not limited to such applications.</p>
<p>In my eyes it is a replacement tool for building the equivalent of all of the old archaic MS Access and Excel &#8220;programs&#8221; out there that have been built by non developers out of necessity for something simple right then and there.</p>
<p>It is also very powerful for prototyping and initial requirements gathering for a bespoke system, as real working software can be shown rather than just wire frames and mock ups.</p>
<p>What I see as the added bonus however is that LightSwitch is also a very extensible, customisable and flexible, opening it up to mid and high level developers as well. This along with the built in 3 tier architecture and simple deployment scenarios, I see this filling a lot of holes, and increase speed of delivery in the SME (Small and medium enterprise) market.</p>
<p>This also means that these &#8220;necessity&#8221; applications can later be taken over by a professional development team without the usual screams of pain&#8230;</p>
<p>If you are getting started I would suggest you run through the <a href="http://msdn.microsoft.com/en-gb/lightswitch/gg604823" title="Lightswitch How Do I? Videos" target="_blank">Lightswitch How Do I? Videos</a> and download the <a href="http://blogs.msdn.com/b/acoat/archive/2011/08/30/lightswitch-decks-from-teched-nz.aspx" target="_blank">slides from @coatsy&#8217;s Tech Ed sessions</a>.</p>
<p>The other resource I have found very helpful is the <a href="http://lightswitchhelpwebsite.com/" title="LightSwitch Help Website" target="_blank">LightSwitch Help Website</a> and another large list is available from Glenn Wilson&#8217;s (<a href="http://twitter.com/#!/Mykre" title="@Mykre" target="_blank">@Mykre</a>) blog post <a href="http://www.virtualrealm.com.au/Blog/tabid/62/EntryId/674/LightSwitch-Links-and-Resources-for-May-2011.aspx" target="_blank">here</a>.</p>
<p>I am still learning this stuff myself but if you have any questions leave me a comment and I will see what I can do.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=106&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2011/09/01/first-impressions-of-microsoft-visual-studio-lightswitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>
	</item>
		<item>
		<title>Sharp Launcher for DreamCheeky USB Rocket Launcher working on Windows 7 x64</title>
		<link>http://mauricebutler.wordpress.com/2011/07/12/sharp-launcher-for-dreamcheeky-usb-rocket-launcher-working-on-windows-7-x64/</link>
		<comments>http://mauricebutler.wordpress.com/2011/07/12/sharp-launcher-for-dreamcheeky-usb-rocket-launcher-working-on-windows-7-x64/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 08:03:55 +0000</pubDate>
		<dc:creator>mauricebutler</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Tech]]></category>
		<category><![CDATA[DreamCheeky]]></category>
		<category><![CDATA[Rocket Launcher]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://mauricebutler.wordpress.com/?p=5</guid>
		<description><![CDATA[I have been sitting on this solution for a while and have finally got around to posting about it and sharing the solution with others who might find it handy. For those of you not really interested in my explanations of the changes I made and just want the software download links are at the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=5&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been sitting on this solution for a while and have finally got around to posting about it and sharing the solution with others who might find it handy.</p>
<p>For those of you not really interested in my explanations of the changes I made and just want the software download links are at the bottom of the post.</p>
<p><a href="http://mauricebutler.files.wordpress.com/2011/06/dream-cheeky-missile-launcher.jpg"><img src="http://mauricebutler.files.wordpress.com/2011/06/dream-cheeky-missile-launcher.jpg?w=901" alt="DreamCheeky rocket launcher" title="DreamCheeky rocket launcher"   class="size-full wp-image-71" /></a></p>
<p>I currently have one of these DreamCheeky USB Rocket Launchers setup on my desk at work. At the time I purchased this device, the best .NET open source project for controlling the DreamCheeky rocket launcher was a project called Sharp Launcher. <a href="http://code.google.com/p/sharplauncher/" title="http://code.google.com/p/sharplauncher/" target="_blank">http://code.google.com/p/sharplauncher/</a> </p>
<p>However, once my work machine was upgraded to Windows 7 64 bit, I had not been able to enjoy the device as the latest version of Sharp Launcher (1.3), does not work under a 64 bit operating system.</p>
<p>After some Googling and finding no solution, only a number of people asking the same questions, I decided to jump in and fix it.</p>
<p>Now I want to point out that I have tried to get in contact with the original developer to supply him with the changes and have got no response. I have also looked at contributing to the code.google project but it is not actually setup as a source repository, just has a zip of the code for download.</p>
<p>My alternative is to post both the binaries and the source here and hopefully someone stumbles across it who knows how to contact this guy.</p>
<p>I take no credit for the original code just the few minor tweaks I have made to make it work in a 64 bit environment. I have also not made any attempt to clean up the code, remove any warnings, test it on more than 1 or 2 systems, or anything else as this was purely an effort to get this existing software to work under 64 bit.</p>
<p>After downloading the source code for version 1.3 from here <a href="http://code.google.com/p/sharplauncher/downloads/list" title="http://code.google.com/p/sharplauncher/downloads/list" target="_blank"></a> and converting the solution to VS 2010, I found the straight away the code did not compile.<br />
<a href="http://mauricebutler.files.wordpress.com/2011/06/errorlist1.png"><img src="http://mauricebutler.files.wordpress.com/2011/06/errorlist1.png?w=700&#038;h=54" alt="Error List 1" title="Error List 1" width="700" height="54" class="size-medium wp-image-74" /></a></p>
<p>Error number 3 is the issue so I change the code from </p>
<pre class="brush: csharp; title: ; notranslate">
public bool UnregisterHandle()
{
    if (this.handle != null)
    {
        return Win32Usb.UnregisterForUsbEvents(this.handle);
    }
}
</pre>
<p>to</p>
<pre class="brush: csharp; title: ; notranslate">
public bool UnregisterHandle()
{
    return this.handle != null &amp;amp;&amp;amp; Win32Usb.UnregisterForUsbEvents(this.handle);
}
</pre>
<p>This allows us to compile and run the software, however as expected my device is not found.<br />
<a href="http://mauricebutler.files.wordpress.com/2011/06/nousblaunchersfound.png"><img src="http://mauricebutler.files.wordpress.com/2011/06/nousblaunchersfound.png?w=234&#038;h=300" alt="No USB Launchers Found" title="No USB Launchers Found" width="234" height="300" class="size-medium wp-image-75" /></a></p>
<p>By debugging in I found that the call to SetupDiEnumDeviceInterfaces on line 266 of LibHid/HIDDevice.cs was returning false. Now this next bit took me a hell of a long time to work out. Looking back it should have been pretty obvious but I began my search in completely the wrong direction. Long story short, I worked out this was due the type of the Reserved property of the DeviceInterfaceData struct in LibHid/Win32Usb.cs.<br />
This needs to be changed from int </p>
<pre class="brush: csharp; title: ; notranslate">public int Reserved;</pre>
<p>to ulong</p>
<pre class="brush: csharp; title: ; notranslate">public ulong Reserved;</pre>
<p>This is due to the fact that the returned SP_DEVICE_INTERFACE_DATA Structure returns the reserved property as a ULONG_PTR. <a href="http://msdn.microsoft.com/en-us/library/ff552342(v=vs.85).aspx" title="http://msdn.microsoft.com/en-us/library/ff552342(v=vs.85).aspx" target="_blank"></a><br />
This of course works in a 32 bit environment but the 64 bit data does not fit into a standard 32 bit int.</p>
<p>Once this change was made I continued to debug the process and came across this gem at line 234 in LibHid/HIDDevice.cs.</p>
<pre class="brush: csharp; title: ; notranslate">oDetail.Size = 5;	// hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to 
                           the struct sizeof failed miserably. If you manage to sort it, mail me! Thx</pre>
<p>To rectify this we need to declare a dll import and define the IsWow64Process</p>
<pre class="brush: csharp; title: ; notranslate">
[DllImport(&quot;kernel32.dll&quot;, SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
</pre>
<p>And then change that offending line to</p>
<pre class="brush: csharp; title: ; notranslate">
 bool is64BitProcess;
 IsWow64Process(Process.GetCurrentProcess().Handle, out is64BitProcess);
 oDetail.Size = (IntPtr.Size == 8 || (IntPtr.Size == 4 &amp;amp;&amp;amp; is64BitProcess)) ? 8 : 5;
</pre>
<p>I know at least 1 reader of this will say the IsWow64Process method wont exist in earlier version of kernel32 such as under Windows 2000 or XP &lt; SP1 but for what I&#039;m trying to achieve here I am assuming if you are on those older versions you will be using the already released version of Sharp launcher and wont need this Windows 7 x64 version. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So now we can compile and run the application and this time we will see the device has been detected correctly and we now have control of our cube defense system.<br />
<a href="http://mauricebutler.files.wordpress.com/2011/06/usblauncherfound.png"><img src="http://mauricebutler.files.wordpress.com/2011/06/usblauncherfound.png?w=234&#038;h=300" alt="USB Launcher Found" title="USB Launcher Found" width="234" height="300" class="alignnone size-medium wp-image-85" /></a></p>
<p>I hope this has provided some insight to a few people and also provided an opportunity to enjoy your USB rocket launcher again.</p>
<p>Now to hook this up to the build failure notifications&#8230;   Muhahaha&#8230;</p>
<p><code><br /></code></p>
<p><b>UPDATE:</b> I have uploaded the source to GitHub</p>
<p>Updated source can be found here: <a href="https://github.com/MauriceButler/SharpLauncher" title="https://github.com/MauriceButler/SharpLauncher" target="_blank">SharpLauncher 1.3.0.1 on GitHub</a></p>
<p>Binaries can be found here: <a href="https://github.com/downloads/MauriceButler/SharpLauncher/SharpLauncher%201.3.0.1.zip" title="https://github.com/downloads/MauriceButler/SharpLauncher/SharpLauncher%201.3.0.1.zip" target="_blank">SharpLauncher 1.3.0.1 Binaries</a><br />
<code><br /></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mauricebutler.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mauricebutler.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mauricebutler.wordpress.com&#038;blog=13230097&#038;post=5&#038;subd=mauricebutler&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mauricebutler.wordpress.com/2011/07/12/sharp-launcher-for-dreamcheeky-usb-rocket-launcher-working-on-windows-7-x64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde1b0d8793bd4b8e2a99f15452c906c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">mauricebutler</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/06/dream-cheeky-missile-launcher.jpg" medium="image">
			<media:title type="html">DreamCheeky rocket launcher</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/06/errorlist1.png?w=300" medium="image">
			<media:title type="html">Error List 1</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/06/nousblaunchersfound.png?w=234" medium="image">
			<media:title type="html">No USB Launchers Found</media:title>
		</media:content>

		<media:content url="http://mauricebutler.files.wordpress.com/2011/06/usblauncherfound.png?w=234" medium="image">
			<media:title type="html">USB Launcher Found</media:title>
		</media:content>
	</item>
	</channel>
</rss>
