<?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>software excogitation</title>
	<atom:link href="http://geekin.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://geekin.wordpress.com</link>
	<description>mostly software, with a little random mixed in.</description>
	<lastBuildDate>Wed, 04 Jan 2012 13:38:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='geekin.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>software excogitation</title>
		<link>http://geekin.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://geekin.wordpress.com/osd.xml" title="software excogitation" />
	<atom:link rel='hub' href='http://geekin.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Dropbox install on Fedora 14</title>
		<link>http://geekin.wordpress.com/2011/10/27/dropbox-install-on-fedora-14/</link>
		<comments>http://geekin.wordpress.com/2011/10/27/dropbox-install-on-fedora-14/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 14:29:49 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=217</guid>
		<description><![CDATA[I started using Dropbox and couldn&#8217;t get it installed on my 64 bit fedora 14 machine.  I found the solution and am just reposting here to hopefully guide someone to it quicker than I was able to find it. Here is the dropbox forum page with the information and description of the issue (the answer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=217&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I started using Dropbox and couldn&#8217;t get it installed on my 64 bit fedora 14 machine.  I found the solution and am just reposting here to hopefully guide someone to it quicker than I was able to find it.</p>
<p><a title="Forum post with the working solution" href="http://forums.dropbox.com/topic.php?id=26808&amp;replies=22#post-169211" target="_blank">Here is the dropbox forum page </a>with the information and description of the issue (the answer that worked for me is the last post, by P K.)</p>
<p><em><strong>Here is the solution in case you have dropbox installed, it is not working, and you don&#8217;t want to go through the forum post:</strong></em></p>
<p><code>execstack -c ~/.dropbox-dist/_ctypes.so</code><br />
<strong><em></em></strong></p>
<p><strong><em>If you haven&#8217;t installed it yet, here&#8217;s how I did it:</em></strong></p>
<ol>
<li>I downloaded the fedora rpm file from the dropbox site.  <a title="Dropbox linux download page." href="https://www.dropbox.com/downloading?src=index" target="_blank">Get it here</a>.</li>
<li>I installed it using <code>yum localinstall &lt;packagename&gt;.rpm</code>.  This gave me &#8220;missing public key&#8221; error.  The solution here was to edit (as superuser) the <code>/etc/yum.conf</code> file and temporarily disable gpgcheck (ie, change <code>gpgcheck=1</code> to <code>gpgcheck=0</code>).  Edit the file with something like <code>sudo gedit /etc/yum.conf</code></li>
<li><strong>You can skip this step</strong>, unless you want to see the problem.   Once installed, run dropbox &#8212; either from the command line or the from the Application Launcher, under the Internet folder.  This says you have to run a daemon, press OK.  It says it is downloading and unpacking&#8230; and never finishes.</li>
<li>Don&#8217;t forget to go back into <code>/etc/yum.conf</code> and reset <code>gpgcheck=1</code></li>
<li>In the terminal, type <code>execstack -c ~/.dropbox-dist/_ctypes.so</code> &lt;enter&gt;</li>
<li>Now, run dropbox from either from the command line or the from the Application Launcher, under the Internet folder.</li>
</ol>
<div>That&#8217;s it.  It is working for me.  I was using the Dolphin file explorer but dropbox installs into the Nautilus file explorer&#8230; so i&#8217;m using that now.  Dolphin crashed often for me anyway, so i was never really attached to it.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=217&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/10/27/dropbox-install-on-fedora-14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>Great video and post on persisting</title>
		<link>http://geekin.wordpress.com/2011/09/29/great-video-and-post-on-persisting/</link>
		<comments>http://geekin.wordpress.com/2011/09/29/great-video-and-post-on-persisting/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 12:45:21 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[life in general]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=212</guid>
		<description><![CDATA[This is not a post on database persistence&#8230; I really believe in learning from failing and persisting through problems to find solutions, whether it is fixing my house or making an HTML5 canvas scrollable.  I think it is one of my major strengths and the best way I learn. Here are two links to articles [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=212&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is not a post on database persistence&#8230;</p>
<p>I really believe in learning from failing and persisting through problems to find solutions, whether it is fixing my house or making an HTML5 canvas scrollable.  I think it is one of my major strengths and the best way I learn.</p>
<p>Here are two links to articles I just read/watched this morning that I really enjoyed.  Hope you enjoy them, the video is 5 minutes.  Summary: Whatever you do, just do it.  Keep doing it and don&#8217;t stop.  You&#8217;ll keep getting better at it.</p>
<p><a title="Video from Ira Glass on persisting in order to get better at what you do." href="http://www.heywhipple.com/2011/09/23/way-cool-video-from-ira-glass" target="_blank">Ira Glass talks about how he started</a>, and <a title="Seth Godin talks about getting past writer's block." href="http://sethgodin.typepad.com/seths_blog/2011/09/talkers-block.html" target="_blank">Seth Godin covers the topic of writer&#8217;s block</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=212&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/09/29/great-video-and-post-on-persisting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>Set up PhoneGap with Xcode 4(.0.2)</title>
		<link>http://geekin.wordpress.com/2011/08/19/set-up-phonegap-with-xcode-4-0-2/</link>
		<comments>http://geekin.wordpress.com/2011/08/19/set-up-phonegap-with-xcode-4-0-2/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 16:00:45 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=194</guid>
		<description><![CDATA[I had to set up PhoneGap on Xcode 4 yesterday and found many confusing, wrong, or just outdated pages describing how to do it.  I think they fixed some things in PhoneGap 1.0.0, so the install is much simpler than what these pages were saying.  So here is my version which worked for me: Download [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=194&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had to set up PhoneGap on Xcode 4 yesterday and found many confusing, wrong, or just outdated pages describing how to do it.  I think they fixed some things in PhoneGap 1.0.0, so the install is much simpler than what these pages were saying.  So here is my version which worked for me:</p>
<ol>
<li><strong>Download and install <a title="PhoneGap page" href="http://www.phonegap.com" target="_blank">PhoneGap</a> 1.0.0 on your mac</strong>.  Get it <a title="PhoneGap framework download" href="http://www.phonegap.com/download-thankyou" target="_blank">here</a>.  This downloads a ZIP file.  Open it up and run the DMG file installation in the iOS directory.  The instructions I saw said to have Xcode closed at this point, which I did.</li>
<li><strong>Open Xcode and create your new PhoneGap project</strong>.  This will set up everything except the www directory.
<p><div id="attachment_205" class="wp-caption aligncenter" style="width: 500px"><a href="http://geekin.files.wordpress.com/2011/08/new-phonegap-project1.png"><img class="size-full wp-image-205" title="New Phonegap Project in Xcode" src="http://geekin.files.wordpress.com/2011/08/new-phonegap-project1.png?w=490&#038;h=320" alt="New Phonegap Project in Xcode" width="490" height="320" /></a><p class="wp-caption-text">New Phonegap Project in Xcode</p></div></li>
<li>In Finder, navigate to your project (mine is in my home directory under &#8216;Xcode projects&#8217;).  <strong>Copy the www directory from &lt;Macintosh HD&gt;/Users/Shared/PhoneGap/Frameworks/PhoneGap.framework/ and paste it into your project in the same directory as the *.xcodeproj file (i.e., your project&#8217;s root directory)</strong></li>
<li>In Xcode, right click on the top-most project header (the blue-ish project header block that contains the entire project) and select &#8220;Add Files to &lt;your project name&gt;&#8221;.  <strong>Find and select the www directory that you just placed in your project, and make sure to change the &#8220;Folders&#8221; radio button to &#8220;Create folder references for any added folders&#8221;</strong>.  Press Add.  Your project should look like this:
<p><div id="attachment_202" class="wp-caption aligncenter" style="width: 332px"><a href="http://geekin.files.wordpress.com/2011/08/final-view.png"><img class="size-full wp-image-202" title="Final Project in Xcode" src="http://geekin.files.wordpress.com/2011/08/final-view.png?w=490" alt="Final Project in Xcode"   /></a><p class="wp-caption-text">Final Project in Xcode</p></div></li>
</ol>
<div>That&#8217;s it.  Select the correct simlulator or iOS device scheme at the top of the project window (next to the RUN/STOP buttons), press RUN and the project should build and start up with the &#8220;PhoneGap works!&#8221; message.  Now you can continue doing whatever you were planning in the www directory.</div>
<div>UPDATE: there is a specific page for this on phone gap that I had not seen&#8230; go to it <a title="PhoneGap Xcode 4 setup" href="http://www.phonegap.com/start#ios-x4" target="_blank">here</a>.  There are still a lot of pages out there that have bad Xcode 4 info on them though!</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=194&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/08/19/set-up-phonegap-with-xcode-4-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>

		<media:content url="http://geekin.files.wordpress.com/2011/08/new-phonegap-project1.png" medium="image">
			<media:title type="html">New Phonegap Project in Xcode</media:title>
		</media:content>

		<media:content url="http://geekin.files.wordpress.com/2011/08/final-view.png" medium="image">
			<media:title type="html">Final Project in Xcode</media:title>
		</media:content>
	</item>
		<item>
		<title>Having one iframe watch for other iframes to load.</title>
		<link>http://geekin.wordpress.com/2011/07/19/watching-for-iframe-to-load-from-another-iframe/</link>
		<comments>http://geekin.wordpress.com/2011/07/19/watching-for-iframe-to-load-from-another-iframe/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 19:16:27 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=170</guid>
		<description><![CDATA[This is an issue that I thought was going to be straight forward using the jQuery ready function, but i could not get it to work. The problem is simple: I want to watch a couple of iframes load and then do something once they are all done. The &#8220;when they are all done&#8221; part [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=170&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is an issue that I thought was going to be straight forward using the <a title="jQuery ready function documentation" href="http://api.jquery.com/ready/" target="_blank">jQuery <strong>ready</strong></a> function, but i could not get it to work.</p>
<h4><strong>The problem is simple</strong>: I want to watch a couple of iframes load and then do something once they are <span style="text-decoration:underline;">all</span> done.</h4>
<p>The &#8220;when they are <span style="text-decoration:underline;">all</span> done&#8221; part is simple with <a title="jQuery Deferred object documentation" href="http://api.jquery.com/category/deferred-object/" target="_blank">jQuery Deferred</a> objects.  A really good, quick tutorial on those is <a title="Eric Hynds jQuery Deferreds tutorial" href="http://www.erichynds.com/jquery/using-deferreds-in-jquery/" target="_blank">here</a>.  Basically, I can pass however many Deferred objects I want to the <code>jQuery.when( ... )</code>  command.  When all of them &#8220;resolve&#8221; (i.e., when the are done doing whatever they need to do), the <code>when</code> command will continue with some &#8220;success&#8221; function or functions.  There are also options for when one or more Deferred objects fail, etc.  Read the tutorial&#8230; it&#8217;s good.  I created a javascript object that encapsulates the Deferred object and my method of resolving the object.  So I just needed to create one per frame I wanted to watch and feed them into the <code>jQuery.when()</code> function.</p>
<p>So for the &#8220;watch a couple of iframes&#8221; part I want to resolve my Deferred objects, instantiated in iframe A, based on iframes B, C, and D finishing loading.  I assumed this was a simple something like:</p>
<p><code>jQuery(top.B.document).ready( function() { ... resolve my deferred object ... } );</code></p>
<p>however, this did not work!  It did not matter that I put <code>top.B.document</code> (this is a path from top down to the frame, and then referencing the frames document), the call seemed to work on my local iframe&#8217;s document (iframe A in this example). I couldn&#8217;t find any information on this online, so if anyone knows more about it i&#8217;d love to hear it.</p>
<h3>The solution:</h3>
<p>I could have gone into each iframe and placed a document ready function that set a flag, and then read that flag from the iframe that is watching, but I wanted to keep this functionality clean and encapsulated in my object that was also handling the Deferred object.  I wanted to write it once &#8212; not X number of times.  Also, I know someone will mention &#8220;why are you using iframes at all?  use Ajax and blah blah blah&#8221;  I know, but you have to work with what you&#8217;re given sometimes&#8230; so i&#8217;m using iframes.</p>
<p>The solution I came up with is this (most of the Deferred object stuff is left out):</p>
<pre>// Constructor
function MyIframeWatcherObject( contextPath ) {
...
// Get the path to the iframe we're watching.
this.contextPathToUse = contextPath || null;
...
{

MyIframeWatcherObject.prototype.resolveOnDOMloaded = function( ) {
	// Re-eval contextDocument each time because it is lost when page reloads.
	var contextDocument = document; //default
	try {
            if ( this.contextPathToUse )
		contextDocument = eval(this.contextPathToUse + '.document');
	} catch ( err ) {
		// Do nothing, use default as contextDocument as fallback for now..
                // Add error handling...
	}
	if ( contextDocument.readyState === 'complete' ) {
            deferredObject.resolve();
        } else {
            var self = this;
            setTimeout( MyIframeWatcherObject.prototype.resolveOnDOMloaded.call( self ), 100 );
        }

}</pre>
<p>First, I resolve the <code>contextPath</code> that was passed in to get its <code>document</code>.  I do this each time because if I resolve it in the constructor and store it, I lose it if the page begins to reload again (it becomes <code>undefined</code>).  Then I check the <code>readyState</code> on the <code>document</code> and determine if I should resolve the Deferred object now, or set up another timer.  The <code>setTimeout</code> function is best here so that I am only setting up one more trigger each time and don&#8217;t have to worry about tracking it like I would with <code>setInterval</code>.  John Resig has a great tutorial on timers <a title="John Resig - How javascript timers work" href="http://ejohn.org/blog/how-javascript-timers-work/" target="_blank">here</a> &#8211; definitely a good read if you are not aware of how they function.</p>
<p>I&#8217;m not completely thrilled with this solution, but it works.  Please offer another way of doing it if you know one!</p>
<p><em><strong>UPDATE</strong></em>: just an additional note.  The <code>document.readyState</code> property looked like it was a cross-browser solution based on my quick google search &#8212; otherwise I would not have considered it.  If you know differently, or know of bugs with this method, please let me know.  Also, the opposite state of <code>document.readyState == 'complete'</code> is <code>document.readyState == 'loading'</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=170&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/07/19/watching-for-iframe-to-load-from-another-iframe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>Nice, simple tutorial on REST</title>
		<link>http://geekin.wordpress.com/2011/07/14/nice-simple-tutorial-on-rest/</link>
		<comments>http://geekin.wordpress.com/2011/07/14/nice-simple-tutorial-on-rest/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 13:42:37 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=166</guid>
		<description><![CDATA[I found a nice tutorial on REST by Dr. M Elkstein so i wanted to post it here:  http://rest.elkstein.org/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=166&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found a nice tutorial on REST by Dr. M Elkstein so i wanted to post it here:  <a href="http://rest.elkstein.org/">http://rest.elkstein.org/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=166&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/07/14/nice-simple-tutorial-on-rest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>HTML5 Canvas: scrolling background and selecting/dragging shapes</title>
		<link>http://geekin.wordpress.com/2011/06/09/html5-canvas-scrolling-background-and-selectingdragging-shapes/</link>
		<comments>http://geekin.wordpress.com/2011/06/09/html5-canvas-scrolling-background-and-selectingdragging-shapes/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 19:03:41 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=134</guid>
		<description><![CDATA[I have been wanting to do this for a while and just had a chance to mess around with it this week.  I also had more motivation after spending Saturday in an &#8220;Designing (for) Interactions&#8221; workshop by Dan Mall, and hosted by RefreshPGH.  The key concepts were HTML5, CSS3, some jQuery, and generally getting some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=134&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been wanting to do this for a while and just had a chance to mess around with it this week.  I also had more motivation after spending Saturday in an &#8220;Designing (for) Interactions&#8221; workshop by <a title="Dan Mall's website" href="http://danielmall.com/" target="_blank">Dan Mall</a>, and hosted by <a title="Refresh Pittsburgh's website." href="http://www.refreshpittsburgh.org/" target="_blank">RefreshPGH</a>.  The key concepts were HTML5, CSS3, some jQuery, and generally getting some good experience on how people in the real world design web sites.  ( I really liked the <a title="HTML 5 Boilerplate" href="http://html5boilerplate.com/" target="_blank">boilerplate</a> website, <a title="Font Squirrel website" href="http://www.fontsquirrel.com/" target="_blank">font squirrel</a>, and of course <a title="A List Apart website" href="http://www.alistapart.com/" target="_blank">A List Apart</a> <a title="A List Apart: Responsive Web Design" href="http://www.alistapart.com/articles/responsive-web-design/" target="_blank">articles</a>! )</p>
<p>Anyway, the thing I have been wanting to mess around with is the canvas.  I have recently been working on some mobile application prototypes and I am getting familiar with some of the components that exist there.  I wanted to see if I could put together a canvas demo to replicate a ScrollView, as well as being able to throw stuff in and manipulate it.  So here&#8217;s my example,with a little explanation.  It is a little hacked together because I put it together pretty quickly, so don&#8217;t grade on neatness and optimization &#8212;  many of the functions and comments are still very much what <a title="Simon Sarris's Website" href="http://simonsarris.com/" target="_blank">Simon Sarris</a> wrote and I pieced things in around his code.  There are also bits and pieces of example code used from multiple places, like <a title="Paul Irish's website:  Random hex code generator" href="http://paulirish.com/2009/random-hex-color-code-snippets/" target="_blank">here</a>.</p>
<h2><em>The Details&#8230;</em></h2>
<p>I started out with the code that <a title="Simon Sarris's Website" href="http://simonsarris.com/" target="_blank">Simon Sarris</a> wrote for <a title="Moving selectable shapes on a canvas" href="http://simonsarris.com/blog/140-canvas-moving-selectable-shapes" target="_blank">selectable shapes in a canvas</a>.  After looking and understanding what he was doing, I refactored the code to be object oriented so it was more expandable.  My Goal: Understand the code well enough that I can edit it, make it expandable, and experiment with creating the &#8220;ScrollView&#8221; effect that I see on mobile devices.</p>
<p>Here is the canvas tag I used:</p>
<pre>&lt;canvas id="canvas_clickAndDragOO" width="400" height="300" style="border: 1px black solid;"&gt;
   This text is displayed if your browser does not support HTML5 Canvas.
&lt;/canvas&gt;</pre>
<p>The manipulation of the shapes is exactly how Simon wrote it, so check out <a title="Moving selectable shapes on a canvas" href="http://simonsarris.com/blog/140-canvas-moving-selectable-shapes" target="_blank">his page</a> for that explanation.  The main thing I added was the scrollable content.</p>
<p>Key Points:</p>
<ul>
<li>I have two main things in the javascript:  a <code>Canvas</code> class and <code>Shape</code>s.  The shapes are pretty basic, so the <code>Canvas</code> class is the most interesting.  It maintains two canvas elements: one for the content and one for the view.  The content canvas is never added to the view and is only maintained behind the scenes as a javascript variable.  Everything is written to that content canvas and the context <code>drawImage</code> method is used to send a section of it to the viewable canvas.</li>
<li>To make the view &#8216;scroll,&#8217; an X and Y value are maintained to specify the coordinates of the top left corner of the viewable canvas on the content canvas.  When the background of the canvas is clicked and dragged, this X and Y value are updated.  The draw method simply reacts to these new values and sends an new section of the content canvas out to the viewable canvas.  The viewable canvas is simply a window to a section of the content canvas.</li>
</ul>
<p>The &#8220;content canvas&#8221; (hidden) is automatically created twice the size of the &#8220;viewable canvas&#8221; for this demo, but this and other things are configurable if you look at the Canvas object in the code.  Just include this in a webpage via a <code>script</code> tag and it should work with the canvas above.  (<strong>UPDATE</strong>: I pasted this <a title="Link to the code on Pastie" href="http://www.pastie.org/2047449" target="_blank">here</a> so it could be read and copied easier)</p>
<p><strong><em>UPDATE 2:</em></strong>  This code doesn&#8217;t work on &lt; IE8 using the <a title="Explorer Canvas support for older IE browsers" href="http://code.google.com/p/explorercanvas/" target="_blank">excanvas.js</a> library because that library does not support the <code>getImageData</code> function!  I would have to find a way around that in order for it to be backwards compatible.  Also, older IE browsers do not support the pageX and pageY properties on the mouse events. This issue can be solved quickly by looking <a title="Code to fix the older IE mouse event issue of not having PageX" href="http://unixpapa.com/js/mouse.html" target="_blank">here</a> (search the page for &#8220;pageX&#8221;).</p>
<p><em><strong>UPDATE 3:</strong></em> I cannot run a demo on this wordpress site, so here is a <a title="zip file containing a runnable demo" href="http://www.filedropper.com/canvasdemo" target="_blank">link to a zip file demo</a>.  (There is a box half way down that says &#8220;Download this file&#8221; &#8212; I need to move to a new site.. this free wordpress site won&#8217;t let me upload ZIP files or run the demo inline)    Unzip it and open index.html in your browser.</p>
<pre>/*
 * My object oriented version of click and drag
 *
 */

function Canvas( data ) {
  data = data || {};
  var self = this;

  this.canvasID = data.canvasID || 'canvas';
  this.viewableCanvas = document.getElementById(this.canvasID);
  this.vctx = data.canvasContext || this.viewableCanvas.getContext('2d');
  // set our events. Up and down are for dragging,
  // double click is for making new boxes
  this.viewableCanvas.onmousedown = function(e){ Canvas.prototype.mouseDownAction.call( self, e ) };
  this.viewableCanvas.onmouseup = function(e){ Canvas.prototype.mouseUpAction.call( self, e ) };
  this.viewableCanvas.onmouseout = function(e){ Canvas.prototype.mouseUpAction.call( self, e ) };
  this.viewableCanvas.ondblclick = function(e){ Canvas.prototype.mouseDblClickAction.call( self, e ) };

  this.isValid = Canvas.IS_INVALID;

  this.canvasContentObjectsList = [];

  // we use a content canvas to draw individual shapes.  This is larger than the viewable canvas.  
  // only a section of this is passed to the viewable canvas
  var contentCanvasHeight = data.contentCanvasHeight || this.viewableCanvas.height * 2;
  if (contentCanvasHeight &lt; this.viewableCanvas.height) { contentCanvasHeight = this.viewableCanvas.height }
  var contentCanvasWidth = data.contentCanvasWidth || this.viewableCanvas.width * 2;
  if (contentCanvasWidth &lt; this.viewableCanvas.width) { contentCanvasWidth = this.viewableCanvas.width }
  this.contentCanvas = document.createElement('canvas');
  this.contentCanvas.height = contentCanvasHeight;
  this.contentCanvas.width = contentCanvasWidth;
  this.cctx = this.contentCanvas.getContext('2d'); // content context
  // These X and Y values are the top left corner of the "viewable window" of this content canvas
  this.ccViewX = Math.max( (contentCanvasWidth/2) - (this.viewableCanvas.width/2), 0 );
  this.ccViewY = Math.max( (contentCanvasHeight/2) - (this.viewableCanvas.height/2), 0 );

  // Max values for the ccView X and Y vals
  this.ccViewXMax = this.cctx.canvas.width - this.vctx.canvas.width;
  this.ccViewYMax = this.cctx.canvas.height - this.vctx.canvas.height;

  this.isContentObjectDragAction = false;
  this.isContentCanvasDragAction = false;

  // the X and Y coordinate for when the mousedown event is triggered
  this.contentCanvasDragStartX = 0;
  this.contentCanvasDragStartY = 0;

    //fixes a problem where double clicking causes text to get selected on the canvas
  this.viewableCanvas.onselectstart = function () { return false; }

  // fixes mouse co-ordinate problems when there's a border or padding
  // see getMouse for more detail
  this.stylePaddingLeft = 0;
  this.stylePaddingTop = 0;
  this.styleBorderLeft = 0;
  this.styleBorderTop = 0;
  if (document.defaultView &amp;&amp; document.defaultView.getComputedStyle) {
    this.stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(this.viewableCanvas, null)['paddingLeft'], 10)      || 0;
    this.stylePaddingTop  = parseInt(document.defaultView.getComputedStyle(this.viewableCanvas, null)['paddingTop'], 10)       || 0;
    this.styleBorderLeft  = parseInt(document.defaultView.getComputedStyle(this.viewableCanvas, null)['borderLeftWidth'], 10)  || 0;
    this.styleBorderTop   = parseInt(document.defaultView.getComputedStyle(this.viewableCanvas, null)['borderTopWidth'], 10)   || 0;
  }

// The selection color and width. Right now we have a red selection with a small width
  this.selectedColor = data.selectedColor || '#CC0000';
  this.selectedWidth = data.selectedwidth || 2;

  // since we can drag from anywhere in a node
  // instead of just its x/y corner, we need to save
  // the offset of the mouse when we start dragging.
  this.offsetx = this.ccViewX;
  this.offsety = this.ccViewY;

  this.currentlySelectedContentObject = null;

    // make draw() fire every INTERVAL milliseconds
  setInterval(function() { Canvas.prototype.draw.call( self ) }, 1000/(data.interval?data.interval:40) );
}
// static members
Canvas.IS_VALID = true;
Canvas.IS_INVALID = false;

// create a random number between two ints, inclusive
Canvas.randomFromTo = function( from, to ) {
  return Math.floor(Math.random() * (to - from + 1) + from);
}

//wipes the canvas context
Canvas.prototype.clear = function( ctx ) {
  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
}

// While draw is called as often as the INTERVAL variable demands,
// It only ever does something if the canvas gets invalidated by our code
Canvas.prototype.draw = function( ) {
  if ( !this.isValid &amp;&amp; this.cctx ) {
    //Canvas.prototype.clear.call( this, ctx );
    this.clear( this.cctx );

    // Add stuff you want drawn in the background all the time here
    //Draw a grid to assist in seeing the background scroll
    this.drawGrid();

    // draw all boxes
    var l = this.canvasContentObjectsList.length;
    for (var i = 0; i &lt; l; i++) {
      this.canvasContentObjectsList[i].drawshape({
        ctx: this.cctx
      });
    }

    // draw selection
    // right now this is just a stroke along the edge of the selected box
    var selectedObj = this.currentlySelectedContentObject;
    if (selectedObj != null) {
      selectedObj.highlightBorder({
        ctx: this.cctx,
        selectedColor: this.selectedColor,
        selectedWidth: this.selectedWidth
      });
    }

    // copy section of content canvas out to the viewable canvas
    try {
      this.clear( this.vctx );
      this.vctx.drawImage(
        this.cctx.canvas,
        this.ccViewX,
        this.ccViewY,
        this.viewableCanvas.width,
        this.viewableCanvas.height,
        0,
        0,
        this.viewableCanvas.width,
        this.viewableCanvas.height
      )
    } catch(e) {
      // Do nothing.  a draw error may occur because we are updating this canvas
      // before the cctx.canvas is done drawing.
    }

    // Add stuff you want drawn on top all the time here

    this.isValid = Canvas.IS_VALID;
  }
}

// draw grid lines, but only on the part visible
Canvas.prototype.drawGrid = function( data ) {

  // Draw gridlines to help with scrolling
  for (var x = (this.ccViewX + 0.5); x &lt; (this.ccViewX + this.vctx.canvas.width); x += 40) {
    this.cctx.moveTo(x, 0);
    this.cctx.lineTo(x, this.ccViewY + this.vctx.canvas.height);
  }
  for (var y = (this.ccViewY + 0.5); y &lt; (this.ccViewY + this.vctx.canvas.height); y += 40) {
    this.cctx.moveTo(0, y);
    this.cctx.lineTo(this.ccViewX + this.vctx.canvas.width, y);
  }
  this.cctx.strokeStyle = "#eee";
  this.cctx.stroke();
}

// Sets mx,my to the mouse position relative to the canvas
// unfortunately this can be tricky, we have to worry about padding and borders
Canvas.prototype.getMouseCoordinates = function(e) {
      var element = this.viewableCanvas, offsetX = 0, offsetY = 0;

      if (element.offsetParent) {
        do {
          offsetX += element.offsetLeft;
          offsetY += element.offsetTop;
        } while ((element = element.offsetParent));
      }

      // Add padding and border style widths to offset
      offsetX += this.stylePaddingLeft;
      offsetY += this.stylePaddingTop;

      offsetX += this.styleBorderLeft;
      offsetY += this.styleBorderTop;

      var mx = e.pageX - offsetX + this.ccViewX;
      var my = e.pageY - offsetY + this.ccViewY;

      // These are the mouse coordinates on the VIEWABLE CANVAS
      return {
        mouseX: mx,
        mouseY: my
      };
}

// Happens when the mouse is clicked in the canvas
Canvas.prototype.mouseDownAction = function(e){

  var self = this;
  var mouseMoveFunction = function(e){ Canvas.prototype.mouseMoveAction.call( self, e ) };

  var mouseCoords = this.getMouseCoordinates(e);
  //Canvas.prototype.clear.call( this, ctx );
  this.clear( this.cctx );
  var l = this.canvasContentObjectsList.length;
  for (var i = l-1; i &gt;= 0; i--) {
    // draw shape onto ghost context
      this.canvasContentObjectsList[i].drawshape({
        ctx: this.cctx,
        fill: 'black'
      });

    // get image data at the mouse x,y pixel
    var imageData = this.cctx.getImageData(mouseCoords.mouseX, mouseCoords.mouseY, 1, 1);
    //var index = (mouseCoords.mouseX + mouseCoords.mouseY * imageData.width) * 4;

    // if the mouse pixel exists, select and break
    if (imageData.data[3] &gt; 0) {
      this.currentlySelectedContentObject = this.canvasContentObjectsList[i];
      this.offsetx = mouseCoords.mouseX - this.currentlySelectedContentObject.x;
      this.offsety = mouseCoords.mouseY - this.currentlySelectedContentObject.y;
      this.currentlySelectedContentObject.x = mouseCoords.mouseX - this.offsetx;
      this.currentlySelectedContentObject.y = mouseCoords.mouseY - this.offsety;
      this.isContentObjectDragAction = true;
      this.viewableCanvas.onmousemove = mouseMoveFunction;
      this.isValid = Canvas.IS_INVALID;
      //Canvas.prototype.clear.call( this, ctx );
      this.clear( this.cctx );
      return;
    }
  }
  // Register a drag action for the whole canvas
  if ( !this.isContentCanvasDragAction ) {
    this.contentCanvasDragStartX = mouseCoords.mouseX;
    this.contentCanvasDragStartY = mouseCoords.mouseY;
    this.originalCCViewX = this.ccViewX;
    this.originalCCViewY = this.ccViewY;
  }
  this.isContentCanvasDragAction = true;
  this.viewableCanvas.onmousemove = mouseMoveFunction;
  // havent returned means we have selected nothing
  this.currentlySelectedContentObject = null;
  // clear the ghost canvas for next time
  //Canvas.prototype.clear.call( this, ctx );
  this.clear( this.cctx );
  // invalidate because we might need the selection border to disappear
  this.isValid = Canvas.IS_INVALID;
}

// Happens when the mouse is moving inside the canvas
Canvas.prototype.mouseMoveAction = function(e){
  var mouseCoords = null;

  if ( this.isContentObjectDragAction ){
    mouseCoords = this.getMouseCoordinates(e);

    this.currentlySelectedContentObject.x = mouseCoords.mouseX - this.offsetx;
    this.currentlySelectedContentObject.y = mouseCoords.mouseY - this.offsety;   

    // something is changing position so we better invalidate the canvas!
    this.isValid = Canvas.IS_INVALID;
  }

  if ( this.isContentCanvasDragAction ) {
    mouseCoords = this.getMouseCoordinates(e);

    xChange = (mouseCoords.mouseX - this.contentCanvasDragStartX);
    yChange = (mouseCoords.mouseY - this.contentCanvasDragStartY);

    // Must move 30 pixels before scrolling.
    if (Math.abs(xChange) &gt; 30 || Math.abs(yChange) &gt; 30) {
      var newX = this.originalCCViewX - xChange;
      newX = newX &lt; 0 ? 0 : newX;
      newX = newX &gt; this.ccViewXMax ? this.ccViewXMax : newX;
      this.ccViewX = newX;

      var newY = this.originalCCViewY - yChange;
      newY = newY &lt; 0 ? 0 : newY;
      newY = newY &gt; this.ccViewYMax ? this.ccViewYMax : newY;
      this.ccViewY = newY;

      this.isValid = Canvas.IS_INVALID;
    }
  }
}

Canvas.prototype.mouseUpAction = function(){
  this.isContentObjectDragAction = false;
  this.isContentCanvasDragAction = false;
  this.viewableCanvas.onmousemove = null;
}

Canvas.prototype.addContentObject = function( obj ) {
  // Verify that this is the correct object type so we have X and Y coordinates

  this.canvasContentObjectsList.push( obj );
  this.isValid = Canvas.IS_INVALID;
}

// adds a new node
Canvas.prototype.mouseDblClickAction = function(e) {
  var mouseCoords = this.getMouseCoordinates(e);
  var randomColor = '#'+(Math.random()*0xFFFFFF&lt;&lt;0).toString(16);

  switch( Canvas.randomFromTo( 1, 3 ) ) {
    case 1:
      this.addContentObject( new Circle({
          x: mouseCoords.mouseX,
          y: mouseCoords.mouseY,
          r: Canvas.randomFromTo( 20, 50 ),
          fill: randomColor
        })
      );
      break;
    case 2:
      this.addContentObject( new Rectangle({
          x: mouseCoords.mouseX,
          y: mouseCoords.mouseY,
          w: Canvas.randomFromTo( 20, 100 ),
          h: Canvas.randomFromTo( 20, 100 ),
          fill: randomColor
        })
      );
      break;
    case 3:
    default:
      this.addContentObject( new Triangle({
          x: mouseCoords.mouseX,
          y: mouseCoords.mouseY,
          w: Canvas.randomFromTo( 20, 100 ),
          h: Canvas.randomFromTo( 20, 100 ),
          fill: randomColor
        })
      );
      break;
  }
}

/***********************************************************
 * Shape super class
 *
 ***********************************************************/

function Shape( data ) {
  data = data || {};

  this.shape = data.shape || 'Shape';
  this.shapeID = data.id || 'Shape';

  this.fill = data.fill || '#444444';

  this.x = data.x;
  this.y = data.y;
}

// Draws a single shape to a single context
// draw() will call this with the normal canvas
// myDown will call this with the ghost canvas
Shape.prototype.drawshape = function( data ) {
    if (!data) return;

  // fill can be overridded if passed in
  data.ctx.fillStyle = data.fill || this.fill;

  // subclass specific
}

Shape.prototype.highlightBorder = function( data ) {
  // Handle the basic, standard highlight things here.
  if (!data) return;

  data.ctx.strokeStyle = data.selectedColor;
  data.ctx.lineWidth = data.selectedWidth;
}

/***********************************************************
 * Rectangle super class
 *
 ***********************************************************/

// Create subclass and reassign constructor to self.
Rectangle.prototype = new Shape();
Rectangle.prototype.constructor = Rectangle;
function Rectangle( data ) {
  data = data || {};

  Shape.call( this, data );

  this.w = data.w;
  this.h = data.h;
}

// Draws a single shape to a single context
// draw() will call this with the normal canvas
// myDown will call this with the ghost canvas
Rectangle.prototype.drawshape = function( data ) {
  Shape.prototype.drawshape.call(this, data); 

  // We can skip the drawing of elements that have moved off the screen:
  if (this.x &gt; data.ctx.canvas.width || this.y &gt; data.ctx.canvas.height) return;
  if (this.x + this.w &lt; 0 || this.y + this.h &lt; 0) return;

  data.ctx.fillRect(this.x,this.y,this.w,this.h);
}

Rectangle.prototype.highlightBorder = function( data ) {
  Shape.prototype.highlightBorder.call(this, data);
  data.ctx.strokeRect(this.x,this.y,this.w,this.h);
}

/***********************************************************
 * Circle super class
 *
 ***********************************************************/

// Create subclass and reassign constructor to self.
Circle.prototype = new Shape();
Circle.prototype.constructor = Circle;
function Circle( data ) {
  data = data || {};

  Shape.call( this, data );

  this.r = data.r; //radius
}

// Draws a single shape to a single context
// draw() will call this with the normal canvas
// myDown will call this with the ghost canvas
Circle.prototype.drawshape = function( data ) {
  Shape.prototype.drawshape.call(this, data); 

  // We can skip the drawing of elements that have moved off the screen:
  if (this.x &gt; data.ctx.canvas.width || this.y &gt; data.ctx.canvas.height) return;
  if (this.x + this.r &lt; 0 || this.y + this.r &lt; 0) return;

  this.drawCircle( data );
}

Circle.prototype.highlightBorder = function( data ) {
  Shape.prototype.highlightBorder.call(this, data); 

  data['borderOnly'] = true;
  this.drawCircle( data );
}

Circle.prototype.drawCircle = function( data ) {
    // Draw a circle using the arc function.
  data.ctx.beginPath();

  // Arguments: x, y, radius, start angle, end angle, anticlockwise
  data.ctx.arc(this.x, this.y, this.r, 0, 360, false);
  if ( !data['borderOnly'] ) {
    data.ctx.fill();
  } else {
    data.ctx.stroke();
  }

  data.ctx.closePath();
}

/***********************************************************
 * Triangle super class
 *
 ***********************************************************/

// Create subclass and reassign constructor to self.
Triangle.prototype = new Shape();
Triangle.prototype.constructor = Triangle;
function Triangle( data ) {
  data = data || {};

  Shape.call( this, data );

  this.w = data.w;
  this.h = data.h;
}

// Draws a single shape to a single context
// draw() will call this with the normal canvas
// myDown will call this with the ghost canvas
Triangle.prototype.drawshape = function( data ) {
  Shape.prototype.drawshape.call(this, data); 

  // We can skip the drawing of elements that have moved off the screen:
  if (this.x &gt; data.ctx.canvas.width || this.y &gt; data.ctx.canvas.height) return;
  if (this.x + this.w &lt; 0 || this.y + this.h &lt; 0) return;

  this.drawTriangle( data );
}

Triangle.prototype.highlightBorder = function( data ) {
  Shape.prototype.highlightBorder.call(this, data);
  data['borderOnly'] = true;
  this.drawTriangle( data );
}

Triangle.prototype.drawTriangle = function( data ) {
  data.ctx.beginPath();
  // Start from the top-left point.
  data.ctx.moveTo( this.x, this.y - (this.h / 2) ); // give the (x,y) coordinates
  data.ctx.lineTo( this.x + (this.w / 2), this.y + (this.h / 2) );
  data.ctx.lineTo( this.x - (this.w / 2), this.y + (this.h / 2) );
  data.ctx.lineTo( this.x, this.y - (this.h / 2) );

  // Done! Now fill the shape, and draw the stroke.
  // Note: your shape will not be visible until you call any of the two methods.
  if ( !data['borderOnly'] ) {
    data.ctx.fill();
  } else {
    data.ctx.stroke();
  }
  data.ctx.closePath();
}

// start it up!
window.onload = function(){
  var OO_canvas = new Canvas( { canvasID: 'canvas_clickAndDragOO' });

  var r1 = new Rectangle({
    x: 800,
    y: 700,
    w: 40,
    h: 70,
    fill: '#FFC02B'
  });
  OO_canvas.addContentObject( r1 );

  var r2 = new Rectangle({
    x: 780,
    y: 780,
    w: 70,
    h: 40,
    fill: '#2BB8FF'
  });
  OO_canvas.addContentObject( r2 );

  var t1 = new Triangle({
    x: 700,
    y: 600,
    w: 70,
    h: 40,
    fill: '#900'
  });
  OO_canvas.addContentObject( t1 );

  var t2 = new Triangle({
    x: 900,
    y: 600,
    w: 70,
    h: 40,
    fill: '#009'
  });
  OO_canvas.addContentObject( t2 );

  var c1 = new Circle({
    x: 675,
    y: 730,
    r: 30,
    fill: '#459'
  });
  OO_canvas.addContentObject( c1 );

  var c2 = new Circle({
    x: 950,
    y: 730,
    r: 30,
    fill: '#954'
  });
  OO_canvas.addContentObject( c2 );
};</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=134&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/06/09/html5-canvas-scrolling-background-and-selectingdragging-shapes/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>Apache POI &#8211; Formatting of &#8216;General&#8217; data extracted from Excel</title>
		<link>http://geekin.wordpress.com/2011/06/03/apache-poi-formatting-of-data-extracted-from-excel/</link>
		<comments>http://geekin.wordpress.com/2011/06/03/apache-poi-formatting-of-data-extracted-from-excel/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:17:24 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[java/jsp]]></category>
		<category><![CDATA[POI Framework]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=115</guid>
		<description><![CDATA[Formatting of 'General' data extracted from Excel when using the Apache POI framework.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=115&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just fixed an issue that has to do with pulling data out of excel using the <a title="Apache POI Framework" href="http://poi.apache.org/" target="_blank">Apache POI</a> framework into Java and having the data&#8217;s format change along the way. It is not a particularly difficult issue, but when researching it I found that there were a couple of other posts on it that didn&#8217;t really solve it, or solved it in a round-about way. So my solution is here:</p>
<p>The issue I ran into was that there were cells in Excel that were meant to be strings but had the default Excel cell format of &#8220;General.&#8221; If a normal string was in one of the cells in this column, then it would be correctly read into the Java code as a string. However, if a value was like &#8217;123123123,&#8217; it would be read in as an <code>HSSFCell.CELL_TYPE_NUMERIC</code> and would convert to a string in scientific notation. These needed to be read in exactly as there were seen in the spreadsheet.</p>
<p>Other solutions I saw included additional reformatting once the data was inside Java, but that seemed too dirty to me. I would have to make assumptions on what the user put into the spreadsheet. There should be a way to pull the data from the Excel file and receive a string that looks exactly like what is shown in Excel.</p>
<p>A quick solution to this would be to change the formatting of the cell in Excel to &#8216;Text&#8217; so that the fields were always designated correctly. But, in my case, I cannot always control what is in the Excel file. A user might change the formatting to whatever they want, but my system expects a String. So this was not a solution.</p>
<p>What I <em>can</em> control is the java code, of course. So after some digging I found two keys that would help me solve this issue.  If I am trying to convert a <code>HSSFCell.CELL_TYPE_NUMERIC</code> value to a string, I need to use these two things:</p>
<ol>
<li>I can get the format of the cell that is being used by Excel with <code>cell.getCellStyle( ).getDataFormat( )</code>. This returns a <code>short.</code>  The Excel format for &#8220;General&#8221; is 0 and the format for Scientific Notation is 11 (I found this through debugging, but <a title="Listing of Excel cell data formats" href="http://www.roseindia.net/java/poi/setDataFormat.shtml" target="_blank">a table exists at least here</a> in the &#8216;Value&#8217; column).  So I know if the user really wanted scientific notation, or if the value was just formatted like that when passed to me.</li>
<li>Once I know the user did not mean for the value to be in scientific notation, I can check the string for the existence of an &#8220;E,&#8221; and if it exists I will pull the string from Excel using <em>Excel&#8217;s</em> formatting instead of my own.  I do this with <code>value = new HSSFDataFormatter().<a title="Javadoc for the formatCellValue method" href="http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html#formatCellValue(org.apache.poi.ss.usermodel.Cell)" target="_blank">formatCellValue( cell )</a></code>.  This converts the cell to a string using the Excel cell format pattern instead of trying to reformat the numeric value in the <code>HSSFCell</code> in Java.</li>
</ol>
<div>I could simply use this <code>formatCellValue</code> all of the time instead of even checking I suppose, but i&#8217;m doing some other custom formatting as well so this is treated as a special case.</div>
<div>So this is the solution I ended up using.  The key is to check the format that is set up in Excel, and then use it directly if it produces a cleaner result in the Java code.  Hope that helps someone.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=115&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2011/06/03/apache-poi-formatting-of-data-extracted-from-excel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery plugin: working scrollbar on left side of div</title>
		<link>http://geekin.wordpress.com/2010/04/16/jquery-plugin-working-scrollbar-on-left-side-of-div/</link>
		<comments>http://geekin.wordpress.com/2010/04/16/jquery-plugin-working-scrollbar-on-left-side-of-div/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:13:16 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[java/jsp]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=104</guid>
		<description><![CDATA[I&#8217;ve been building JSF views and creating custom components for a while and one issue we worked on was making scrollable tables, where the header and footer stay stationary and the data scrolls. I&#8217;m still cleaning this up, but the general idea is that I wrapped the table in DIVs, which are set up to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=104&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been building JSF views and creating custom components for a while and one issue we worked on was making scrollable tables, where the header and footer stay stationary and the data scrolls.</p>
<p>I&#8217;m still cleaning this up, but the general idea is that I wrapped the table in DIVs, which are set up to scroll vertically or horizontally based on the dynamic content of the table.  This seems to be the only solution that is cross-browser, and it uses jQuery to dissect the table and move the header and footer so that the scrolling works correctly.  Once I finalize that, i&#8217;ll post it.</p>
<p>But one thing was missing: the content of the tables sometimes pushes the table off the right side of the view, and the horizontal scrollbar appears.  At this point, the vertical scrollbar is way off to the right and pretty much makes the table useless.  So I wanted to move the vertical scrollbar to the left side, and I had trouble finding a cross-browser solution &#8230; until now.</p>
<p>I just found a jQuery plugin written by Brian Reavis at his website: <a href="http://thirdroute.com/css-js-left-vertical-scrollbars/">3rd Route</a>.  I tested it out and it worked immediately.  The only thing i had to do to it was swap out all of the &#8216;$&#8217; for &#8216;jQuery&#8217; because of my use of the <code>jQuery.noConflict()</code> flag.  I originally found it via <a href="http://stackoverflow.com/questions/1455708/div-vertical-scroll-bar-on-left">stackoverflow</a>, but the version on the website looks like it was cleaned up to enable chaining.</p>
<p>I tried other things, like multiple versions of <code>style="direction:trl"</code>, but these felt messy when i read about them, and did not work when I implemented them.</p>
<p>Thanks Brian!</p>
<h3><strong>Update:</strong> I ended up doing a lot of changes because of some issues i found:</h3>
<ul>
<li>For very large tables, this code was really slow in IE.  I narrowed it down to the jQuery &#8216;append&#8217; function and refactored the plugin to not use it at all</li>
<li>The original copied all components into the poser div.  I removed all of that and the poser div is basically now just the scrollbar.  Something major was required for using the plugin with JSF, because it was causing duplicate ID issues.  I decided to get rid of all of the extra components instead of just renaming the IDs.</li>
<li>I created a second version that has the scrollbar on both sides</li>
<li>I added a unique identifier class so that multiple instances could be on the same page.</li>
<li>I changed how the scroll updating worked, but the old way wasn&#8217;t broken so it wasn&#8217;t really an improvement.</li>
</ul>
<p>So, based on Brian&#8217;s original design and implementation, here is what I am using now:<br />
<code>
<pre>
/**
 * jQuery plugin to add a scrollbar to the left side of a div.  It does this by
 * creating a false div on the left side of the table, and then having that div's scroll
 * position set on the original div every scroll event.
 *
 * @link edited from http://thirdroute.com/css-js-left-vertical-scrollbars/, but heavily changed from the original version.
 */
jQuery.fn.leftAndRightScrollBar = function(){
	var items = jQuery(this);

	var randomString = function() {
		var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
		var string_length = 8;
		var randomstring = '';
		for (var i=0; i&lt;string_length; i++) {
			var rnum = Math.floor(Math.random() * chars.length);
			randomstring += chars.substring(rnum,rnum+1);
		}
		return randomstring;
	}

	jQuery(function(){
		items.each(function(){
			// create unique classes for targeting the poser div
			var poserTargetingClass = randomString();

			var e = jQuery(this);
			var contentHeight = e.children(&#039;table:first&#039;).height();
			var content = e.html();
			var ie = !jQuery.support.boxModel;
			var w = e[ie?&#039;innerWidth&#039;:&#039;width&#039;](), h = e[ie?&#039;innerHeight&#039;:&#039;height&#039;]();

			//calculate paddings
			var pad = {};
			jQuery([&#039;top&#039;, &#039;right&#039;, &#039;bottom&#039;, &#039;left&#039;]).each(function(i, side){
				pad[side] = parseInt(e.css(&#039;padding-&#039; + side).replace(&#039;px&#039;,&#039;&#039;));
			});
			//detect scrollbar width
			var xfill = jQuery(&#039;&lt;div class=&quot;xFill&quot;&gt;&#039;).css({margin:0, padding:0, height:&#039;1px&#039;});
			e.append(xfill);
			var contentWidth = xfill.width();
			var scrollerWidth = e.innerWidth() - contentWidth - pad.left - pad.right;
			e.css(&#039;padding&#039;, &#039;0&#039;);
			e.children(&#039;.xFill&#039;).remove();

			var poserHeight = h - pad.top - pad.bottom;
			var poser = jQuery(&#039;&lt;div class=&quot;leftAndRightScrollPoser &#039;+poserTargetingClass+&#039;&quot;&gt;&#039;)
				// create a div that forces height without copying the content to do it.
				.html(&#039;&lt;div style=&quot;visibility:hidden;height:&#039;+contentHeight+&#039;px&quot;&gt;.&lt;/div&gt;&#039;)
				.css(&#039;overflow&#039;,&#039;auto&#039;)
				.height(poserHeight+(ie?pad.top+pad.bottom:0))
				.width(scrollerWidth-(ie?0:pad.left*2)) // only as wide as the scrollbar.
			;

			e
				.css({
					width: w+(ie?0:scrollerWidth)-(ie?0:pad.right+pad.left),
					height: h-(ie?0:pad.bottom+pad.top),
					marginTop: -poserHeight-pad.top*2,
					marginLeft: scrollerWidth
				})
				.css(&#039;overflow-y&#039;, &#039;auto&#039;)
				.css(&#039;overflow-x&#039;, &#039;hidden&#039;)
			;

			jQuery([&#039;top&#039;, &#039;right&#039;, &#039;bottom&#039;, &#039;left&#039;]).each(function(i, side){
				 poser.css(&#039;padding-&#039;+side, pad[side]);
				 e.css(&#039;padding-&#039;+side, pad[side]);
			});
			poser.insertBefore(e);

			var hRatio = (e.innerHeight()+pad.bottom) / poser.innerHeight();
			// Set up scrolling update events
			jQuery(&quot;.&quot; + poserTargetingClass).scroll(function(){e.scrollTop(poser.scrollTop()*hRatio)});
			e.scroll(function(){poser.scrollTop(e.scrollTop()*hRatio)});
		});
	});
	return items;
};

/**
 * jQuery plugin to move the scrollbar to the left side of a div -- no right scrollbar
 * @link http://thirdroute.com/css-js-left-vertical-scrollbars/, but heavily changed from the original version.
 */
jQuery.fn.leftScrollbar = function(){
	var items = jQuery(this);

	var randomString = function() {
		var chars = &quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz&quot;;
		var string_length = 8;
		var randomstring = &#039;&#039;;
		for (var i=0; i&lt;string_length; i++) {
			var rnum = Math.floor(Math.random() * chars.length);
			randomstring += chars.substring(rnum,rnum+1);
		}
		return randomstring;
	}

	jQuery(function(){
		items.each(function(){
			// create unique classes for targeting the poser div
			var poserTargetingClass = randomString();

			var e = jQuery(this);
			var content = e.html();
			var contentHeight = e.children(&#039;table:first&#039;).height();
			var ie = !jQuery.support.boxModel;
			var w = e[ie?&#039;innerWidth&#039;:&#039;width&#039;](), h = e[ie?&#039;innerHeight&#039;:&#039;height&#039;]();
			//calculate paddings
			var pad = {};
			jQuery([&#039;top&#039;, &#039;right&#039;, &#039;bottom&#039;, &#039;left&#039;]).each(function(i, side){
				pad[side] = parseInt(e.css(&#039;padding-&#039; + side).replace(&#039;px&#039;,&#039;&#039;));
			});
			//detect scrollbar width
			var xfill = jQuery(&#039;&lt;div&gt;&#039;).css({margin:0, padding:0, height:&#039;1px&#039;});
			e.append(xfill);
			var contentWidth = xfill.width();
			var scrollerWidth = e.innerWidth() - contentWidth - pad.left - pad.right;
			e.css(&#039;padding&#039;, &#039;0&#039;);
			e.children(&#039;.xFill&#039;).remove();

			var poserHeight = h - pad.top - pad.bottom;
			var poser = jQuery(&#039;&lt;div class=&quot;leftScrollPoser &#039;+poserTargetingClass+&#039;&quot;&gt;&#039;)
				.html(&#039;&lt;div style=&quot;visibility:hidden;height:&#039;+contentHeight+&#039;px&quot;&gt;.&lt;/div&gt;&#039;)
				.css(&#039;overflow&#039;,&#039;auto&#039;)
				.height(poserHeight+(ie?pad.top+pad.bottom:0))
				.width(scrollerWidth-(ie?0:pad.left*2)) // only as wide as the scrollbar
			;

			e
				.css({
					width: w/*-scrollerWidth*/-(ie?0:pad.right+pad.left),
					height: h-(ie?0:pad.bottom+pad.top),
					overflow: &#039;hidden&#039;,
					marginTop: -poserHeight-pad.top*2,
					marginLeft: scrollerWidth
				});

			jQuery([&#039;top&#039;, &#039;right&#039;, &#039;bottom&#039;, &#039;left&#039;]).each(function(i, side){
				 poser.css(&#039;padding-&#039;+side, pad[side]);
				 e.css(&#039;padding-&#039;+side, pad[side]);
			});
			poser.insertBefore(e);

			var hRatio = (e.innerHeight()+pad.bottom) / poser.innerHeight();
			// Set up scrolling update events
			jQuery(&quot;.&quot; + poserTargetingClass).scroll(function(){e.scrollTop(poser.scrollTop()*hRatio)});
			e.scroll(function(){poser.scrollTop(e.scrollTop()*hRatio)}); // so mouse wheel scrolls table
		});
	});
	return items;
};
</pre>
<p></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=104&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2010/04/16/jquery-plugin-working-scrollbar-on-left-side-of-div/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>Browser cache refreshing for CSS and Javascript</title>
		<link>http://geekin.wordpress.com/2010/02/04/browser-cache-refreshing-for-css-and-javascript/</link>
		<comments>http://geekin.wordpress.com/2010/02/04/browser-cache-refreshing-for-css-and-javascript/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:12:58 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=93</guid>
		<description><![CDATA[After reading an article on it, and having an issue at work concerning it, I put together a script that should keep CSS and JS files refreshed at a configured interval.  I&#8217;d like to get comments on it, or just make it available if needed: Here&#8217;s the script, I stored it in a separate JS [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=93&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After reading an <a title="Update on CSS Caching" href="http://css-tricks.com/update-on-css-caching/" target="_blank">article</a> on it, and having an issue at work concerning it, I put together a script that should keep CSS and JS files refreshed at a configured interval.  I&#8217;d like to get comments on it, or just make it available if needed:</p>
<p>Here&#8217;s the script, I stored it in a separate JS file and called it into my webpage ( a jsp page) with a script element:</p>
<pre>/**
* killCache.js
*
* Small js script that allows for appending a "code" to URLs of CSS or JS files (or
* anything that uses a LINK element) in order to force the browser to update from the
* files and not from cache.
* /

/**
* Round a value to a given interval.
*
* For example:
* (1) if the value is 4 and the interval is 10, then the result will be 0.
* (2) if the value is 755.3 and the interval is 100, the result will be 800.
*
* @param value the current value to check and round
* @param interval the interval to round the value to
* @return the rounded value
*/
function roundTo(value, interval) {
// round the value to the nearest interval
value /= interval;
value = Math.round(value);
return value * interval;
}

/**
* Create a string 'code' that changes every INTERVAL.  this code can be appended to CSS or JS files
* that change in order to make sure the user is always getting the correct version and not a cached version.
*
* @return a string code that changes every INTERVAL so that some files are not cached.
*/
function getRefreshCode() {
var currentTime = new Date();
var intervalToUse = 30; // round minutes to nearest 30 minute interval
var updateInterval = roundTo(currentTime.getMinutes(), intervalToUse);

return updateInterval + "_" + currentTime.getHours() + "_" + currentTime.getDay();
}

/**
* Create a link element in the header where the href also contains a dynamic
* string that forces a periodic update of cache
*/
function addUpdatingLinkToHead(rel, type, href, title) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');

if (rel != null) { link.rel = rel; }
link.type = type;
link.href = href + "?" + getRefreshCode(); // refresh code is added here.
if (title != null) { link.title = title; }

head.appendChild(link);
}

/**
* Create a script element in the header where the href also contains a dynamic
* string that forces a periodic update of cache
*/
function addUpdatingScriptToHead(type, src) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');

script.type = type;
script.src = src + "?" + getRefreshCode(); // refresh code is added here.

head.appendChild(script);
}</pre>
<p>and then I the script itself, and my CSS file to the web page like this:</p>
<pre>&lt;!-- Small js file that creates CSS links &amp; js scripts and forces them to update occasionally --&gt;
&lt;script src="/js/killCache.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
  addUpdatingLinkToHead("stylesheet", "text/css", "/theme/cssFile1.css", "Style");
  addUpdatingLinkToHead("stylesheet", "text/css", "/theme/cssFile2.css", "Style");
&lt;/script&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=93&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2010/02/04/browser-cache-refreshing-for-css-and-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery</title>
		<link>http://geekin.wordpress.com/2009/09/30/jquery/</link>
		<comments>http://geekin.wordpress.com/2009/09/30/jquery/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 03:04:32 +0000</pubDate>
		<dc:creator>mpickell</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://geekin.wordpress.com/?p=61</guid>
		<description><![CDATA[I picked up the book jQuery In Action, and I think I love this library!  Actually, I picked it up a while ago and I&#8217;m just getting around to writing about it.  I recently built a website for watching the building of the new arena in Pittsburgh (which is down now because the building is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=61&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I picked up the book <em><a title="jQuery In Action - Buy the Book" href="http://www.manning.com/bibeault/" target="_blank">jQuery In Action</a></em>, and I think I love this library!  Actually, I picked it up a while ago and I&#8217;m just getting around to writing about it.  I recently built a website for watching the building of the new arena in Pittsburgh (which is down now because the building is big enough to block the webcam), and I used jQuery to do some really nice fades for image thumbnails.  The only problem was, I was following pre-written instructions and did not know what was really going on.  It did, however, introduce me to the magic of jQuery!</p>
<h3>CSS consistency across browsers</h3>
<p>One of the best things about jQuery is that you can (almost always) just put a line of jQuery in my web page and it will work across all of the major browsers.  I have had some very small issues with this, but nothing major compared to the amount of code it takes in straight javascript to do the same thing.</p>
<p>There&#8217;s  also the selectors.  If you know CSS, then you can use jQuery.  jQuery works by creating a <em>wrapped set </em>of elements and performing some tasks on each element in the wrapped set.  The book i read uses the term wrapped set, but if that term is confusing you can just think of it as a group of elements that matches the selector you chose to use.</p>
<p>Any CSS selector can be used to query the page and create this wrapped set.  It even allows for CSS3 selectors and a couple of jQuery-specific extended selectors.  For example, consider the child selector <code>#formId &gt; h1</code> that would select all <code>h1</code> elements nested inside the element with the id <code>#formId</code>.  This is not supported in IE6, but with jQuery you can use it anyway:</p>
<p><code>$('#formId &gt; h1').css('color','red');</code></p>
<h3>Simplify, Simplify, Simplify</h3>
<p>jQuery is just simple.  You only need to know the CSS selectors to get the maximum power from jQuery, not which browser supports which selectors, etc.  The javascript file is much neater and more readable.  Take this example of code that was used to put focus on the first input on a webpage:</p>
<p><code>function setFocusOnFirstLocationOfInputType(type){<br />
var elementsInputs = document.getElementsByTagName("input");<br />
for (i=0; i &lt; elementsInputs.length; i++) {<br />
if(elementsInputs[i].type == type){<br />
elementsInputs[i].focus();<br />
break;<br />
}<br />
}<br />
}</code></p>
<p>and now consider the jQuery that does the same:</p>
<p><code>function setFocusOnFirstLocationOfInputType(type){<br />
$("input[type="+type+"]:first").focus();<br />
}</code></p>
<h3>Extendable!</h3>
<p>The jQuery core library does everything I&#8217;ve mentioned and a lot more, and it is small.  If you need more, there are <a title="jQuery plug-in repository" href="http://plugins.jquery.com/" target="_blank">a lot of plugins</a> available that supply very complex features (made simple!) like accordian or sliding menus (<a title="jQuery UI" href="http://jqueryui.com/" target="_blank">jQueryUI plugin</a>), or extended selectors with regular expressions.</p>
<h3>Some links to additional info on the library:</h3>
<ul>
<li><a title="jQuery docs" href="http://docs.jquery.com/Main_Page" target="_blank">jQuery documentation page</a></li>
<li>Some <a title="Tutorials @ Build Internet!" href="http://buildinternet.com/category/tutorials/" target="_self">tutorials </a>on <a title="Animation with jQuery @ Build Internet!" href="http://buildinternet.com/2009/01/how-to-make-a-smooth-animated-menu-with-jquery/" target="_self">animation </a>and other cool stuff.</li>
<li><a title="Blogs to follow on jQuery" href="http://www.webresourcesdepot.com/15-blogs-to-follow-for-jquery-lovers/" target="_blank">Blogs </a>to follow on jQuery</li>
<li>Three part jQuery intro from IBM: <a title="IBM jQuery Intro 1" href="http://www.ibm.com/developerworks/library/wa-aj-jquery4/" target="_blank">Part 1</a>, <a title="IBM jQuery Intro 2" href="http://www.ibm.com/developerworks/web/library/wa-aj-jquery5/index.html?ca=dgr-jw22JQueryUI&amp;S_TACT=105AGX59&amp;S_CMP=grsitejw22" target="_blank">Part 2</a>, <a title="IBM jQuery Intro 3" href="http://www.ibm.com/developerworks/web/library/wa-jquery3/" target="_blank">Part 3</a></li>
<li>jQuery <a title="navigation Menu Tutorials" href="http://www.developerfox.com/13-excellent-tutorials-on-creating-jquery-navigation-menu/584" target="_blank">navigation menu tutorials</a></li>
<li><a title="jQuery examples and best practices" href="http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/" target="_blank">jQuery examples and best practices</a> over at <a title="smashing magazine web site" href="http://www.smashingmagazine.com/" target="_blank">smashingMagazine.com</a></li>
<li><a title="jQuery - 25 tips" href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx" target="_blank">More tips</a> to get better at jQuery!</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/geekin.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/geekin.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/geekin.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=geekin.wordpress.com&amp;blog=5777047&amp;post=61&amp;subd=geekin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://geekin.wordpress.com/2009/09/30/jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mpickell</media:title>
		</media:content>
	</item>
	</channel>
</rss>
