<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathon Bolster &#187; Programming</title>
	<atom:link href="http://www.bolsterweb.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bolsterweb.com</link>
	<description>Programming, drawing, random, life.</description>
	<lastBuildDate>Mon, 03 Oct 2011 17:30:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Finding and dropping a constraint using a table and column name</title>
		<link>http://www.bolsterweb.com/2011/10/finding-and-dropping-a-constraint-using-a-table-and-column-name/</link>
		<comments>http://www.bolsterweb.com/2011/10/finding-and-dropping-a-constraint-using-a-table-and-column-name/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 17:30:56 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=324</guid>
		<description><![CDATA[I had a bit of a problem in work. I had to write some SQL to drop a uniqueness constraint on a column but was unsure of the constraint name (since it was auto generated with a GUID on the end). Looking at the MSDN &#8216;Alter table&#8217; documentation, it seems that you need the constraint [...]]]></description>
			<content:encoded><![CDATA[<p>I had a bit of a problem in work. I had to write some SQL to drop a uniqueness constraint on a column but was unsure of the constraint name (since it was auto generated with a GUID on the end). Looking at the <a href="http://msdn.microsoft.com/en-us/library/aa275462(v=sql.80).aspx" title="Alter Table documentation on MSDN" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/aa275462_v=sql.80_.aspx?referer=');">MSDN &#8216;Alter table&#8217; documentation</a>, it seems that you need the constraint name to drop it (please correct me if I&#8217;m wrong). I knew the table and the column names, so this is what I needed to work with.</p>
<p>So here&#8217;s what I came up with and this did the job:</p>
<pre class="brush: sql; title: ; notranslate">
            DECLARE @constraintName VARCHAR(50)

            select @constraintName = CONSTRAINT_NAME
            from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
            WHERE TABLE_NAME = '[YOUR_TABLENAME]' AND COLUMN_NAME = '[YOUR_COLUMNNAME]'

            IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[YOUR_TABLENAME]') AND name = @constraintName)
                EXEC('ALTER TABLE [YOUR_TABLENAME] DROP CONSTRAINT ' + @constraintName)
</pre>
<p>This worked for me since I know that the column will only have one constraint. Presumable the CONSTRAINT_COLUMN_USAGE will return multiple rows if there are multiple constraints. I also did the EXEC to get past the limitation that the DROP CONSTRAINT call doesn&#8217;t accept a variable.</p>
<p>If anyone has any comments/improvements on the above, I&#8217;d appreciate if you let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/10/finding-and-dropping-a-constraint-using-a-table-and-column-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How clean is your window (object)?</title>
		<link>http://www.bolsterweb.com/2011/10/how-clean-is-your-window-object/</link>
		<comments>http://www.bolsterweb.com/2011/10/how-clean-is-your-window-object/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 17:30:32 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=316</guid>
		<description><![CDATA[I recently wanted to see how polluted the global namespace of our web application was. By that, I mean I wanted to see how many unnecessary objects we were assigning to the window object. To do this, I wanted to compare against a clean window object. A quick look on Google and I found this [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wanted to see how polluted the global namespace of our web application was. By that, I mean I wanted to see how many unnecessary objects we were assigning to the window object.</p>
<p>To do this, I wanted to compare against a clean window object. A quick look on Google and I found this article: <a href="http://darcyclarke.me/development/getting-a-clean-document-or-window-object-in-javascript/" title="Getting a clean document or window Object in JavaScript" onclick="pageTracker._trackPageview('/outgoing/darcyclarke.me/development/getting-a-clean-document-or-window-object-in-javascript/?referer=');">Getting a clean document or window Object in JavaScript</a>. The basic idea is that you create a new iframe element, and you can use the contentWindow property of that to give you a nice clean window object. As the author states, you might want to do this to prevent the remapping of native methods but I just want it for a quick (i.e. hacky) way to see what objects have being put into my own &#8216;clean&#8217; window.</p>
<p>What I do is create the iframe to get my clean window. Set up an object to copy across the objects from the main window object, then remove any that appear in the clean window.</p>
<p>Here it is in glorious, unminified code:</p>
<pre class="brush: jscript; title: ; notranslate">
(function(window){
	var keys = {},
	cleanWindow,
	iframe = document.createElement(&quot;iframe&quot;);

	iframe.style.display =&quot;none&quot;;
	iframe = document.body.appendChild(iframe);

	cleanWindow = iframe.contentWindow;
	document.body.removeChild(iframe);

	for(var keyName in window){
		keys[keyName] = window[keyName];
	}

	for(var keyName in cleanWindow) {
		delete keys[keyName]
	}

	return keys;
}(window))
</pre>
<p>And here&#8217;s a version that I&#8217;ve minified down:</p>
<pre class="brush: jscript; title: ; notranslate">
(function($){var k={},w,d=document,b=d.body,i=d.createElement(&quot;iframe&quot;);i.style.display=&quot;none&quot;;i=b.appendChild(i);w=i.contentWindow;b.removeChild(i);for(var s in $){k[s]=$[s]}for(var s in w){delete k[s]}return k}(window))
</pre>
<p>This is written as <a href="http://stackoverflow.com/questions/592396/what-is-the-purpose-of-a-self-executing-function-in-javascript" title="What is the purpose of a self executing function in javascript? on StackOverflow" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/592396/what-is-the-purpose-of-a-self-executing-function-in-javascript?referer=');">self executing JavaScript</a> and will return an object containing the objects that we worked out were added to the window.</p>
<p>Note: This is a very quick and dirty piece of code. Mostly it was an experiment for myself, to use the &#8216;clean window&#8217; object. It won&#8217;t tell you if a native window property was changed or anything, it only compares the keys. Just remember that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/10/how-clean-is-your-window-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking at the animations on Google&#8217;s Jim Henson doodle</title>
		<link>http://www.bolsterweb.com/2011/09/looking-at-the-animations-on-googles-jim-henson-doodle/</link>
		<comments>http://www.bolsterweb.com/2011/09/looking-at-the-animations-on-googles-jim-henson-doodle/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 10:56:27 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Random Musings]]></category>
		<category><![CDATA[googledoodle]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jsfiddle]]></category>
		<category><![CDATA[sprite]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=297</guid>
		<description><![CDATA[On opening Google today, I&#8217;m shown a couple of muppets I can control (well, I can open their mouths and spin their heads around). This is to celebrate Jim Henson&#8217;s 75th birthday, but I&#8217;m interested in what makes it tick since there are a few little animations in there and I want to see what [...]]]></description>
			<content:encoded><![CDATA[<p>On opening Google today, I&#8217;m shown a couple of muppets I can control (well, I can open their mouths and spin their heads around). This is to celebrate Jim Henson&#8217;s 75th birthday, but I&#8217;m interested in what makes it tick since there are a few little animations in there and I want to see what Google does.</p>
<p><img src="http://www.bolsterweb.com/wp-content/uploads/2011/09/google-doodle-24-sep-2011.jpg" alt="Google Doodle for Jim Henson&#039;s 75th Birthday" title="Google Doodle for Jim Henson&#039;s 75th Birthday" width="371" height="183" class="size-full wp-image-307 aligncenter" /></p>
<p>Looking at the images that are loaded, they seem to be PNG sprite images. So then I went on a little (short lived) mission on how to recreate the animations myself. Honestly, there are muppet animations you can play with soon.</p>
<p>There is a handy little jQuery plugin called <a href="http://spritely.net/" title="Spritely" onclick="pageTracker._trackPageview('/outgoing/spritely.net/?referer=');">Spritely</a>. This will take a jQuery selector object and manipulate the background image position to generate the animation. Nicely, all you have to do is supply the number of frames and it will do the rest for you.</p>
<p>So I open up a new <a href="http://jsfiddle.net/jonathon/5GSah/" title="jsFiddle" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net/jonathon/5GSah/?referer=');">jsFiddle</a>, fill in my HTML and CSS with the containers and background images I want and then put in this little beauty:</p>
<pre class="brush: jscript; title: ; notranslate">
$('div').click(function() {
    var $this = $(this);
    $this.sprite({
        fps: 9,
        no_of_frames: $this.data(&quot;num&quot;),
        on_last_frame: function(obj) {
            obj.destroy();
        }
    });
});
</pre>
<p>Now, what I&#8217;ve done here is make it so that every div object will generate a sprite animation on click. This probably isn&#8217;t the prettiest way to do it, but I have *only* just discovered Spritely so I&#8217;ll look at the docs and improve. If you want to let me know in the comments, that&#8217;d be appreciated.</p>
<p>(Also, for the eagle eyed of you, I&#8217;m using a data attribute to store the number of frames in the animation. This was painstakingly done by opening the PNG files and counting the muppet heads. I bet I will find Spritely would do it for me after reviewing the documentation).</p>
<p>You&#8217;ve waited long enough. Go to the jsFiddle to play with the <a href="http://jsfiddle.net/jonathon/5GSah/" title="Muppet animations for Google Doodle on jsFiddle" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net/jonathon/5GSah/?referer=');">Muppet animations</a>.</p>
<p>Alternatively, here are links to the sprite images I&#8217;ve seen. Haven&#8217;t found anything for the blue guy on the left though! If you have, let me know and I&#8217;ll add it.</p>
<ul>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-2oa.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-2oa.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-2oa.png</a></li>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-3oa.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-3oa.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-3oa.png</a></li>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-4ga.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-4ga.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-4ga.png</a></li>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-6ea-lr.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-6ea-lr.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-6ea-lr.png</a></li>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-6ea-er.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-6ea-er.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-6ea-er.png</a></li>
<li><a href="http://www.google.co.uk/logos/2011/henson11-hp-6ea.png" onclick="pageTracker._trackPageview('/outgoing/www.google.co.uk/logos/2011/henson11-hp-6ea.png?referer=');">http://www.google.co.uk/logos/2011/henson11-hp-6ea.png</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/09/looking-at-the-animations-on-googles-jim-henson-doodle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IEnumerable extension to create a delimited string from a string list</title>
		<link>http://www.bolsterweb.com/2011/08/ienumerable-extension-to-create-a-delimited-string-from-a-string-list/</link>
		<comments>http://www.bolsterweb.com/2011/08/ienumerable-extension-to-create-a-delimited-string-from-a-string-list/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 09:33:56 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[ienumerable]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=255</guid>
		<description><![CDATA[With string lists, one thing that I find myself doing a lot is combining the list by some delimiter. In C#, this is a fairly easy thing to do but (today especially) I&#8217;ve seen a lot of places where people suggest using a string builder and appending a formatted string (then getting a substring to [...]]]></description>
			<content:encoded><![CDATA[<p>With string lists, one thing that I find myself doing a lot is combining the list by some delimiter. In C#, this is a fairly easy thing to do but (today especially) I&#8217;ve seen a lot of places where people suggest using a string builder and appending a formatted string (then getting a substring to remove the last delimiter) or something similar. I&#8217;m not completely against this, I just think this method is neater:</p>
<pre class="brush: csharp; title: ; notranslate">
        public static string ToString&lt;T&gt;(this IEnumerable&lt;T&gt; source, string delimiter)
        {
            return string.Join(delimiter, source);
        }
</pre>
<p>That will throw up an exception if &#8216;source&#8217; is null. That&#8217;s fine for me, since I don&#8217;t want that extension from hiding something that might be wrong elsewhere (i.e. why am I trying to join a null list). If you want to make this work fine and dandy for a null source, you can just use the <a title="Null Coalescing Operator" href="http://msdn.microsoft.com/en-US/library/ms173224(v=VS.80).aspx" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-US/library/ms173224_v=VS.80_.aspx?referer=');">null coalescing operator</a> and provide an empty source:</p>
<pre class="brush: csharp; title: ; notranslate">
        public static string ToString&lt;T&gt;(this IEnumerable&lt;T&gt; source, string delimiter)
        {
            return string.Join(delimiter, source ?? Enumerable.Empty&lt;T&gt;());
        }
</pre>
<p>Now why do I think this is a better solution that the string builder option? Well, if you whack open <a title="Redgate's Reflector" href="http://reflector.red-gate.com" onclick="pageTracker._trackPageview('/outgoing/reflector.red-gate.com?referer=');">Reflector</a>, you&#8217;ll notice that the <a title="String.Join on MSDN" href="http://msdn.microsoft.com/en-us/library/57a79xd0.aspx" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/57a79xd0.aspx?referer=');">Join</a> method uses a StringBuilder object and builds up from there. So since it&#8217;s already built straight into the framework, why reinvent the wheel? Of course, the Join method with an IEnumerable as an argument is only available on .NET 4.0. Anything prior to .NET 4.0 and you&#8217;ll have to pass in a string array (at which point the string builder method would be useful).</p>
<p>Another point to notice from the documentation is that the Join method will set the separator to String.Empty, if you pass it a null. The same applies to any element in the list that is null &#8211; it is simply replaced by another empty string.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/08/ienumerable-extension-to-create-a-delimited-string-from-a-string-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stack Fiddle &#8211; Now across all the Stack Exchange sites</title>
		<link>http://www.bolsterweb.com/2011/02/stack-fiddle-now-across-all-the-stack-exchange-sites/</link>
		<comments>http://www.bolsterweb.com/2011/02/stack-fiddle-now-across-all-the-stack-exchange-sites/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 00:09:05 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[StackFiddle]]></category>
		<category><![CDATA[chrome-extension]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=237</guid>
		<description><![CDATA[Today was Stack Fiddle&#8217;s first day in the wild and it seems to have been received incredibly well. Thanks to everyone who sent me suggestions and comments about it. So now it&#8217;s up to version 1.0.4. 1.0.5 Yeay! (I messed up the manifest) Today has been a busy day: I posted it on StackApps Created [...]]]></description>
			<content:encoded><![CDATA[<p>Today was Stack Fiddle&#8217;s first day in the wild and it seems to have been received incredibly well. Thanks to everyone who sent me suggestions and comments about it.</p>
<p><strong>So now it&#8217;s up to version <del>1.0.4.</del> 1.0.5 Yeay!</strong> (I messed up the manifest)</p>
<p>Today has been a busy day:</p>
<ul>
<li>I posted it on <a href="http://stackapps.com/questions/2114/stack-fiddle-easily-create-a-jsfiddle-from-stack-overflow" onclick="pageTracker._trackPageview('/outgoing/stackapps.com/questions/2114/stack-fiddle-easily-create-a-jsfiddle-from-stack-overflow?referer=');">StackApps</a></li>
<li>Created the <a href="https://github.com/jbolster/Stack-Fiddle" onclick="pageTracker._trackPageview('/outgoing/github.com/jbolster/Stack-Fiddle?referer=');">github project</a></li>
<li>Added two features that were requested:
<ul>
<li>Enable/Disable the context menu (it now only appears on StackExchange sites)</li>
<li>Enable Stack Fiddle on all the Stack Exchange sites</li>
</ul>
</li>
<li>Only display on pages with certain (customisable) tags</li>
<li>Tidied up the code to make it a bit</li>
</ul>
<p>So yeah, if you have any suggestions for Stack Fiddle &#8211; just get in touch! I&#8217;m interested in hearing everything &#8211; comments, suggestions, bug reports or anything that you think would just be fun to know.</p>
<p>Download the updated version for free on the <a href="https://chrome.google.com/webstore/detail/loemajeogfdlphofpdfncpbbeoenmbpm" onclick="pageTracker._trackPageview('/outgoing/chrome.google.com/webstore/detail/loemajeogfdlphofpdfncpbbeoenmbpm?referer=');">Google Web Store</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/02/stack-fiddle-now-across-all-the-stack-exchange-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stack Fiddle &#8211; Now up on github</title>
		<link>http://www.bolsterweb.com/2011/02/stack-fiddle-now-up-on-github/</link>
		<comments>http://www.bolsterweb.com/2011/02/stack-fiddle-now-up-on-github/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 14:10:47 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[StackFiddle]]></category>
		<category><![CDATA[chrome-extension]]></category>
		<category><![CDATA[jsfiddle]]></category>
		<category><![CDATA[stack-fiddle]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=219</guid>
		<description><![CDATA[Having published Stack Fiddle last night at about 3:00am (GMT), I figured that it would have been a good time to go to bed. I wrote the blog post and posted it on Twitter for the whole world to see. Then it was bed time. Now I&#8217;ve just created a Stack Fiddle project on github* [...]]]></description>
			<content:encoded><![CDATA[<p>Having published Stack Fiddle last night at about 3:00am (GMT), I figured that it would have been a good time to go to bed. I wrote <a href="http://www.bolsterweb.com/2011/02/i-made-a-google-chrome-extension-stack-fiddle/">the blog post</a> and posted it <a href="http://twitter.com/jbolster/status/40232535984316416" onclick="pageTracker._trackPageview('/outgoing/twitter.com/jbolster/status/40232535984316416?referer=');">on Twitter</a> for the whole world to see. Then it was bed time.</p>
<p>Now I&#8217;ve just created a <a href="https://github.com/jbolster/Stack-Fiddle" onclick="pageTracker._trackPageview('/outgoing/github.com/jbolster/Stack-Fiddle?referer=');">Stack Fiddle project on github</a>* with the source for all to see and play (and report issues). I&#8217;m new to git and github so if you know of anything that I could be doing better then let me know. I had a quick look at licences to try and allow something that gave the most flexibility &#8211; finally choosing the <a href="http://creativecommons.org/licenses/by-sa/2.5/" onclick="pageTracker._trackPageview('/outgoing/creativecommons.org/licenses/by-sa/2.5/?referer=');">Creative Commons Attribution-ShareAlike 2.5</a> licence. Again, if anyone has any points to make about it then let me know.</p>
<p>Some of you keen eyed people will probably notice that Stack Fiddle is up to v1.0.3 from v1.0.0 last night. What&#8217;s all that about? Well, I was eager to get in some ideas that I had overnight and I just couldn&#8217;t wait. The main thing is that Stack Fiddle will now only work on a list of tags rather than every code block on the site. I&#8217;ve put in a default list for JavaScript related ones but this is customisable through the options page. So far, my mini releases have been:</p>
<ul>
<li><strong>1.0.3</strong>: Added license and readme</li>
<li><strong>1.0.2</strong>: Tag restrictions &#8211; StackFiddle will only work for given tags (customisable!).</li>
<li><strong>1.0.1</strong>: Initial commit into git. Changed the main script to be non minified in preparation for github</li>
</ul>
<p>So go! Play. Tell your friends about it. Tell me about it. Tell me about your holiday plans. I don&#8217;t mind. Remember to let me know of any features you want &#8211; or just fork the git repository if you think you have anything cool that can be added.</p>
<p>* <strong>Note:</strong> Please remember that I did say this was posted up at 3am. I wrote it and tested it and thought it was good enough to publish. The 3am time does mean a possibility of inefficient and uncommented code (we can&#8217;t be perfect all the time!). This will be tidied &#8211; I promise <img src='http://www.bolsterweb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/02/stack-fiddle-now-up-on-github/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I made a Google Chrome Extension &#8211; Stack Fiddle!</title>
		<link>http://www.bolsterweb.com/2011/02/i-made-a-google-chrome-extension-stack-fiddle/</link>
		<comments>http://www.bolsterweb.com/2011/02/i-made-a-google-chrome-extension-stack-fiddle/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 02:10:48 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[chrome-extension]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=201</guid>
		<description><![CDATA[That&#8217;s right! Today I decided to make my own Google Chrome extension &#8211; and I call it Stack Fiddle. It&#8217;s pretty simple, really. I like answering questions on Stack Overflow &#8211; I mostly like the jQuery / JavaScript questions. One tool that I absolutely love is jsFiddle. You have three boxes (JavaScript, CSS, HTML) that [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right! Today I decided to make my own Google Chrome extension &#8211; and I call it <a href="https://chrome.google.com/extensions/detail/loemajeogfdlphofpdfncpbbeoenmbpm" onclick="pageTracker._trackPageview('/outgoing/chrome.google.com/extensions/detail/loemajeogfdlphofpdfncpbbeoenmbpm?referer=');">Stack Fiddle</a>.</p>
<p>It&#8217;s pretty simple, really. I like answering questions on <a href="http://stackoverflow.com" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com?referer=');">Stack Overflow</a> &#8211; I mostly like the jQuery / JavaScript questions. One tool that I absolutely love is <a href="http://jsfiddle.net" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net?referer=');">jsFiddle</a>. You have three boxes (JavaScript, CSS, HTML) that you can put your code and the result appears. No faffing around with having to set up any scaffolding to get simple tests done.</p>
<p>So what have I done then? I&#8217;ve combined the two! A lot of helpful people put their CSS, JavaScript and HTML in separate code blocks which is great &#8211; but then I have to copy and paste them individually into jsFiddle and change the framework to jQuery. My extension gives all the code blocks a handy little header like this one:<a href="http://www.bolsterweb.com/wp-content/uploads/2011/02/doc-21.png"><img class="aligncenter size-full wp-image-205" title="Stack Fiddle" src="http://www.bolsterweb.com/wp-content/uploads/2011/02/doc-21.png" alt="The header that StackFiddle adds to the Stack Fiddle page." width="680" height="75" /></a><a href="http://www.bolsterweb.com/wp-content/uploads/2011/02/doc-2.png"></a></p>
<p>Click the HTML / JavaScript / CSS to choose the ones that you want to fiddle with and then press the &#8216;Send to jsFiddle&#8217; link. Everything is sent off to jsFiddle and it&#8217;s ready to go.</p>
<p>This is just the first version so the feature list is pretty short:</p>
<ul>
<li>Easily select code blocks to send to jsFiddle</li>
<li>Choose your default framework and version</li>
<li>Detect all the jsFiddle links and create links to display the embedded fiddle in the page</li>
</ul>
<p>Since posting it to the Chrome extensions gallery I&#8217;ve come up with a few ideas on how to make it better (including prettifying it a little &#8211; as the logo I tried making is rubbish) <strong>but</strong> if you have any ideas then leave me a comment or send me a message on <a href="http://twitter.com/jbolster" onclick="pageTracker._trackPageview('/outgoing/twitter.com/jbolster?referer=');">Twitter (@jbolster)</a>.</p>
<p>Give it a whirl and let me know if it&#8217;s useful for you <img src='http://www.bolsterweb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Download it at: <a href="https://chrome.google.com/extensions/detail/loemajeogfdlphofpdfncpbbeoenmbpm" onclick="pageTracker._trackPageview('/outgoing/chrome.google.com/extensions/detail/loemajeogfdlphofpdfncpbbeoenmbpm?referer=');">https://chrome.google.com/extensions/detail/loemajeogfdlphofpdfncpbbeoenmbpm</a></p>
<p>Some future features that I&#8217;m thinking of:</p>
<ul>
<li>Giving it a better design/logo</li>
<li>Possibly extending to other stack exchange sites (suggestions!)</li>
<li>Displaying the Stack Fiddle header only on questions that have certain tags</li>
<li>Enabling appending of multiple code blocks</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/02/i-made-a-google-chrome-extension-stack-fiddle/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JavaScript &#8211; e.preventDefault() is NOT return false</title>
		<link>http://www.bolsterweb.com/2011/01/javascript-e-preventdefault-is-not-return-false/</link>
		<comments>http://www.bolsterweb.com/2011/01/javascript-e-preventdefault-is-not-return-false/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 11:57:18 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=194</guid>
		<description><![CDATA[I&#8217;ve seen a lot of people use return false in place of e.preventDefault. This is usually when dealing with setting the click event on a hyperlink. I can only think that this comes from the original JavaScript snippets of running code on a click by setting onclick="alert('hi'); return false". This is wrong Well &#8211; it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen a lot of people use <code>return false</code> in place of <code>e.preventDefault</code>. This is usually when dealing with setting the click event on a hyperlink. I can only think that this comes from the original JavaScript snippets of running code on a click by setting <code>onclick="alert('hi'); return false"</code>.</p>
<p><strong>This is wrong</strong></p>
<p>Well &#8211; it might be wrong. It all depends on your application. As long as you know the differences in them, you should be fine:</p>
<ul>
<li><strong>e.preventDefault</strong>: this (aptly) prevents the default event from happening. In the case of a hyperlink that you want to assign JavaScript to, this will stop the link from going to the location of the link</li>
<li><strong>e.stopPropagation</strong>: this stops the event from bubbling up. If you click on something that had a click event then using this will stop the event bubbling up and any click event that the parent containers might have.</li>
<li><strong>return false</strong>: this is the same as calling both of the methods above.</li>
</ul>
<p>I&#8217;ve done two examples for this:</p>
<ol>
<li><a href="http://jsfiddle.net/jonathon/XTY5c/" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net/jonathon/XTY5c/?referer=');">Showing the difference in e.preventDefault() and return false</a>: This example works on the click event and shows that preventDefault and return false are actually different.
</li>
<li><a href="http://jsfiddle.net/jonathon/JLMaR/" onclick="pageTracker._trackPageview('/outgoing/jsfiddle.net/jonathon/JLMaR/?referer=');">Example of e.stopPropagation</a>: This example shows a practical example of when you&#8217;d want to stop an event bubbling up. It uses event handlers on the mouseover event to show this.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2011/01/javascript-e-preventdefault-is-not-return-false/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Preventing accidental double clicks on links using jQuery</title>
		<link>http://www.bolsterweb.com/2010/12/preventing-accidental-double-clicks-on-links-using-jquery/</link>
		<comments>http://www.bolsterweb.com/2010/12/preventing-accidental-double-clicks-on-links-using-jquery/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 18:31:18 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=190</guid>
		<description><![CDATA[I recently answered this question on StackOverflow asking how to prevent someone from clicking a link multiple times. This is the solution I came up with: You can use jQuery&#8217;s data storage methods to assign arbitrary bits of data to specific DOM elements. In this case, when the user clicks a link I assign a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently answered <a href="http://stackoverflow.com/questions/4410282/how-can-i-prevent-button-mashing-when-using-anchors-instead-of-buttons/" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/4410282/how-can-i-prevent-button-mashing-when-using-anchors-instead-of-buttons/?referer=');">this question on StackOverflow</a> asking how to prevent someone from clicking a link multiple times.</p>
<p>This is the solution I came up with:</p>
<pre class="brush: jscript; title: ; notranslate">$(&quot;a&quot;).click(function(e) {
    e.preventDefault();

    if (!$(this).data('isClicked')) {
        var link = $(this);

        // Your code on successful click

        // Set the isClicked value and set a timer to reset in 3s
        link.data('isClicked', true);
        setTimeout(function() {
            link.removeData('isClicked')
        }, 3000);
    } else {
        // Anything you want to say 'Bad user!'
    }
});</pre>
<p>You can use <a href="http://api.jquery.com/category/miscellaneous/data-storage/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/category/miscellaneous/data-storage/?referer=');">jQuery&#8217;s data storage</a> methods to assign arbitrary bits of data to specific DOM elements. In this case, when the user clicks a link I assign a property to the element as well as setting a timer to remove it 3 seconds later. This lets me know if the specific element has already been clicked by just calling the <code>data</code> method.</p>
<p>It&#8217;s not a bullet proof solution since it&#8217;s incredibly easy to get around if you&#8217;re determined enough. However, it is a simple example of how you can use those methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2010/12/preventing-accidental-double-clicks-on-links-using-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shortcut for JavaScript timestamp</title>
		<link>http://www.bolsterweb.com/2010/11/shortcut-for-javascript-timestamp/</link>
		<comments>http://www.bolsterweb.com/2010/11/shortcut-for-javascript-timestamp/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 11:28:25 +0000</pubDate>
		<dc:creator>Jonathon Bolster</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.bolsterweb.com/?p=179</guid>
		<description><![CDATA[JavaScript&#8217;s Date object provides a function for getting the milliseconds from the UNIX epoch &#8211; getTime(): However, there is a handy shortcut that gets the same thing: It makes me wonder if the +new shortcut can work for any other JavaScript object but I haven&#8217;t had a chance to look yet. Update: Apparently it&#8217;s just [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript&#8217;s Date object provides a function for getting the milliseconds from the UNIX epoch &#8211; <a href="http://www.w3schools.com/jsref/jsref_getTime.asp" onclick="pageTracker._trackPageview('/outgoing/www.w3schools.com/jsref/jsref_getTime.asp?referer=');">getTime()</a>:</p>
<pre class="brush: jscript; title: ; notranslate">
var timeStamp = new Date().getTime();
</pre>
<p>However, there is a handy shortcut that gets the same thing:</p>
<pre class="brush: jscript; title: ; notranslate">
var timeStamp = +new Date();
</pre>
<p>It makes me wonder if the <code>+new</code> shortcut can work for any other JavaScript object but I haven&#8217;t had a chance to look yet.</p>
<p><strong>Update</strong>: Apparently it&#8217;s just the unary operator (<a href="http://xkr.us/articles/javascript/unary-add/" onclick="pageTracker._trackPageview('/outgoing/xkr.us/articles/javascript/unary-add/?referer=');">http://xkr.us/articles/javascript/unary-add/</a>). From the article:</p>
<blockquote><p>The unary + operator, when used on types other than string, will internally attempt to call valueOf() or toString() (in that order) and then attempt to convert the result to a number. Thusly, the unary + operator can successfully convert many of the native JS types with certain restrictions.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.bolsterweb.com/2010/11/shortcut-for-javascript-timestamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

