<?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>Cory Schires</title>
	<atom:link href="http://coryschires.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryschires.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 04 Jul 2010 23:06:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Dynamic CSS3 Buttons with LESS</title>
		<link>http://coryschires.com/dynamic-css3-buttons-with-less/</link>
		<comments>http://coryschires.com/dynamic-css3-buttons-with-less/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 20:03:39 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[LESS]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=334</guid>
		<description><![CDATA[Lean how to make your buttons dynamic using LESS - an awesome new CSS abstraction language.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a lot of buzz surrounding CSS3 buttons &#8211; including some <a href="http://www.webdesignerwall.com/tutorials/css3-gradient-buttons/">really great tutorials</a>. The concept behind a basic button, however, is pretty simple:</p>
<ol class="block_list">
<li>Apply a subtle background gradient</li>
<li>Add some rounded corners</li>
<li>Add text shadows &#8211; optionally</li>
<li>Add a thin border &#8211; optionally</li>
<li>Add a box shadow &#8211; optionally</li>
<li>Repeat this process for active and hover states</li>
</ol>
<p>For sure, making good buttons means doing these steps well. But programmatically, this is pretty damn simple. The difficultly lies in design not code.</p>
<p>With that in mind, let&#8217;s look at how we might use a CSS abstraction language, like <a href="http://fadeyev.net/2010/06/19/lessjs-will-obsolete-css/">LESS</a>, to boil these steps down and make our button code super flexible. But first, let&#8217;s take a look at CSS abstraction languages more generally.</p>
<h3>What&#8217;s a CSS abstraction language?</h3>
<p>An abstraction language is a wrapper that adds powerful functionally to the standard CSS language. Have you ever wanted to set a variable in your stylesheet or do some math? Abstraction languages make this possible.</p>
<p>Now, if you&#8217;re like me, you might be thinking: &#8220;If I need to do multiplication in a stylesheet something&#8217;s gone terribly wrong.&#8221; Keep reading. Maybe you&#8217;ll change your mind.</p>
<h3>How do I use a CSS abstraction language?</h3>
<p>Normally, abstraction languages require a supporting back-end language. This supporting language parses your abstracted code and generates normal, static stylesheets at runtime. Ruby, for example, does exactly this to turn SASS into CSS.</p>
<p>That&#8217;s cool, but for most projects we don&#8217;t need a powerful back-end framework. And there&#8217;s certainly no reason start using one just to make your stylesheets more dynamic. This means, by and large, abstraction languages just aren&#8217;t viable except in large, complicated projects.</p>
<p>But <a href="http://fadeyev.net/2010/06/19/lessjs-will-obsolete-css/">LESS</a> is about to change all that. <a href="http://cloudhead.io/">Alexis Sellier</a> has recently developed a pure JavaScript implementation. This means no back-end language is required. Just follow these simple steps:</p>
<ol class="block_list">
<li>Give your stylesheet a mime type of <span class="code_text">.less</span> rather than <span class="code_text">.css</span></li>
<li>Add an attribute of <span class="code_text">rel=&quot;stylesheet/less&quot;</span> rather than <span class="code_text">rel=&quot;stylesheet&quot;</span>
    </li>
<li>Include the <span class="code_text">less.js</span> script <span class="italic">below</span> all stylesheets in your header.</li>
</ol>
<p>With that finished, your header should include something like:</p>
<div class="code_block">
<pre class="brush: css;">
        &lt;link rel="stylesheet/less" href="buttons.less" type="text/css" charset="utf-8" &gt;
        &lt;script src="less-1.0.30.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
    </pre>
</div>
<p>And now we have access to some pretty awesome features. Like setting variables and performing operations:</p>
<div class="code_block">
<pre class="brush: css;">
        @pagewrap_width: 970px
        @accent_color: #2BBF26;        

        section {
          @pagewrap_width - 300px
          color: @accent_color - #f0f0f0;
        }
    </pre>
</div>
<p>And that&#8217;s just a few of the awesome features. I encourage you to checkout the <a href="http://fadeyev.net/2010/06/19/lessjs-will-obsolete-css/">details</a> and <a href="http://lesscss.org/">documentation</a>.</p>
<h3>How can we use this to make better buttons?</h3>
<h4><span>1</span> Get a nice looking button.</h4>
<p>Making a nice button can be tricky, so I recommend using the code posted in one of these <a href="http://www.smashingmagazine.com/2009/12/02/pushing-your-buttons-with-practical-css3/">excellent tutorials</a>. But if you&#8217;d rather roll your own, I suggest this dead simple <a href="http://css-tricks.com/examples/ButtonMaker/">button making tool</a>.</p>
<p>Whatever your method, just get some CSS and paste it into your <a href="http://fadeyev.net/2010/06/19/lessjs-will-obsolete-css/">LESS</a> equipped stylesheet. In this example, I&#8217;ll be using this code:</p>
<div class="code_block">
<pre class="brush: css;">
        /* styles for button color */
        .button {
          color: #fef4e9;
          border: solid 1px #da7c0c;
          background: #f78d1d;
          background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
          background: -moz-linear-gradient(top,  #faa51a,  #f47a20);
        }
        .button:hover {
          background: #f47c20;
          background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
          background: -moz-linear-gradient(top,  #f88e11,  #f06015);
        }
        .button:active {
          background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
          background: -moz-linear-gradient(top,  #f47a20,  #faa51a);
        }

        /* basic styles for button size, padding, etc. */
        .button {
          display: inline-block;
          outline: none;
          cursor: pointer;
          text-align: center;
          text-decoration: none;
          font-size: @font_size;
          line-height: 100%;
          font-family: Helvetica, Verdana, Arial, sans-serif;
          padding: .55em 2em .55em;
          text-shadow: 0 1px 1px rgba(0,0,0,.3);
          -webkit-border-radius: 0.5em;
          -moz-border-radius: 0.5em;
          border-radius: 0.5em;
          -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
          -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
          box-shadow: 0 1px 2px rgba(0,0,0,.2);
        }
        .button:hover {
          text-decoration: none;
        }
        .button:active {
          position: relative;
          top: 1px;
        }
    </pre>
</div>
<p>And our buttons will look like:</p>
<p><img src="http://coryschires.com/wp-content/themes/cs-simple/images/posts/dynamic_buttons/orange_buttons.png" /></p>
<h4><span>2</span> Extract the important stuff into variables.</h4>
<p>That&#8217;s a lot of CSS but let&#8217;s focus on what actually matters: font color, border radius, border color, padding, and background gradients. </p>
<p>Let&#8217;s move these values into variables. It&#8217;s a good convention to place them at the top of your stylesheet like so:</p>
<div class="code_block">
<pre class="brush: css;">
        /* basic button variables */
        @background_color: #f78d1d;
        @hover_background_color: #f47c20;
        @border_radius: 0.5em;
        @font_size: 14px;
        @font_color: #fef4e9;
        @button_padding: 0.55em 2em;
        @border_color: #da7c0c;

        /* background color gradients for each state */
        @normal_background_top: #faa51a;
        @normal_background_bottom: #f47a20; 

        @hover_background_top: #f88e11;
        @hover_background_bottom: #f06015; 

        @active_background_top: #f47a20;
        @active_background_bottom: #faa51a;

        /* ...previous css with original values substituted for variables... */
    </pre>
</div>
<p>Now, already that&#8217;s a nice improvement. We can easily make changes to our button styles without having to wade through all that CSS. Want rounder corners? Just increase <span class="code_text">@border_radius</span>.</p>
<h4><span>3</span> Make a good thing better with high school math.</h4>
<p>While we&#8217;ve made an improvement, that still feels like too many configuration options for a simple button. Wouldn&#8217;t it be nice, for example, if we didn&#8217;t have to worry with all those color variations (i.e. border color, background colors, gradients, etc). It would be much better if we could consolidate all those values into a single variable (e.g. <span class="code_text">@button_color</span>).</p>
<p>Let&#8217;s do just that. First, let&#8217;s change <span class="code_text">@background_color</span> to <span class="code_text">@button_color</span>. We&#8217;ll hold this value constant and set all of our other color-related values relative to <span class="code_text">@button_color</span>. This means we&#8217;ll be able to alter one variable &mdash; <span class="code_text">@button_color</span> &mdash; and changes will automatically cascade through related variables. </p>
<p>In case you&#8217;re confused, I&#8217;ll break it down a bit so you can see what&#8217;s going on. We&#8217;re just doing some simple math with hexcodes:</p>
<div class="code_block">
<pre class="brush: css;">
        /* we've already set these variables */
        @background_color: #f78d1d;
        @border_color: #da7c0c;

        /* if we know that: */
            @button_color - @border_color = #1D1111
        /* then high school algebra says: */
            @border_color = @button_color - #1D1111
    </pre>
</div>
<p>So we can use this concept to set all our color values relative <span class="code_text">@button_color</span>. Now our configuration options are looking much leaner:</p>
<div class="code_block">
<pre class="brush: css;">
        /* button configuration options */
        @button_color: #f78d1d;
        @border_radius: 0.5em;
        @font_size: 14px;
        @font_color: #fef4e9;
        @button_padding: 0.55em 2em;

        /* color variables set relative to @button_color.
        You probably don't need to change these. */
        @hover_background_color: @button_color - #031100;
        @border_color: @button_color - #1D1111;

        @normal_background_top: @button_color + #031800;
        @normal_background_bottom: @normal_background_top - #062B00; 

        @hover_background_top: @button_color + #010100;
        @hover_background_bottom: @hover_background_top - #082E08; 

        @active_background_top: @normal_background_bottom;
        @active_background_bottom: @normal_background_top;   

        /* ...previous css with original values substituted for variables... */
    </pre>
</div>
<p>So now we only need to concern ourselves with five clearly named variables. And we can easily change our style to suit different themes. Change the value of <span class="code_text">@button_color</span> to <span class="code_text">#ffb515</span> and you get yellow buttons complete with CCS3 gradients:</p>
<p><img src="http://coryschires.com/wp-content/themes/cs-simple/images/posts/dynamic_buttons/yellow_buttons.png" /></p>
<p>Or change <span class="code_text">@button_color</span> to <span class="code_text">#2daebf</span> and <span class="code_text">@font_size</span> to <span class="code_text">22px</span>:</p>
<p><img src="http://coryschires.com/wp-content/themes/cs-simple/images/posts/dynamic_buttons/blue_buttons.png" /></p>
<p>You get the idea. Changing styles couldn&#8217;t be easier.</p>
<h3>But this is about more than just buttons.</h3>
<p>This is just a trivial example of how <a href="http://fadeyev.net/2010/06/19/lessjs-will-obsolete-css/">LESS</a> can make our stylesheets more dynamic. Imagine, for example, WordPress themes where non-developers could alter the entire color scheme by changing a single variable. Or tweak the layout through something like <span class="code_text">@sidebar_width</span>.</p>
<p>When done well, layouts could even feel a bit like jQuery plugins. Just download the files, change a few configuration options, and you&#8217;re ready to roll. This would be especially useful for stylesheets that aren&#8217;t too application specific &mdash; like wireframe layouts or admin/cms interfaces. </p>
<p>Maybe designers will even start open-sourcing layouts the way developers share plugins? Maybe.</p>
<p><a class="download" href="http://github.com/coryschires/CSS3-Buttons-with-LESS">Download the project from GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/dynamic-css3-buttons-with-less/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery swap form value plugin.</title>
		<link>http://coryschires.com/jquery-swap-form-value-plugin/</link>
		<comments>http://coryschires.com/jquery-swap-form-value-plugin/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 06:38:06 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://coryschires.com/jquery-pwap-form-value-plugin/</guid>
		<description><![CDATA[Here's a simple, lightweight plugin to swap default values in a form field. It works with both <span class="code_text">textarea</span> and <span class="code_text">input</span> elements, and runs solidly across browsers.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple, lightweight plugin to swap default values in a form field. It works with both <span class="code_text">textarea</span> and <span class="code_text">input</span> elements, and runs solidly across browsers. For example:</p>
<div class="faux_form" id="swap_value_demo">
<input type="text" name="username" swap_value="username" />
<input type="password" name="password" swap_value="password" />
</div>
<p><!--faux_form--></p>
<h3>How to make it work.</h3>
<p>Just add a swap_value attribute to your element specifying the value you’d like shown in the field: </p>
<div class="code_block">
<pre class="brush: jscript;">
       &lt;input type="text" name="username" swap_value="username" /&gt;
    </pre>
</div>
<p>And call the plugin like this: </p>
<div class="code_block">
<pre class="brush: jscript;">
        $("input[swap_value], textarea[swap_value]").swap_value();
    </pre>
</div>
<p>You can also change the default text colors by passing arguments to the function:</p>
<div class="code_block">
<pre class="brush: jscript;">
        $("input[swap_value], textarea[swap_value]").swap_value({
			normal_color: '#3E474D',
			default_color: '#BCBCBD'
        });
    </pre>
</div>
<h3>Don&#8217;t forget about accessibility.</h3>
<p>For accessibility reasons, you should always include labels for each of your form elements. If you don&#8217;t want labels cluttering up your view, I suggest you hide them:</p>
<div class="code_block">
<pre class="brush: ruby;">
        <label for="First Name" style="display: none;">First Name</label>
        <!-- input element here... -->
    </pre>
</div>
<h3>Some more powerful alternatives.</h3>
<p>There are some similar, although much more powerful, plugins available for swapping form values. If you&#8217;re looking something more fully-featured, I suggest you checkout <a href="http://code.google.com/p/jquery-watermark/" class="new_window">jquery watermark</a>. Also the <a href="http://fuelyourcoding.com/in-field-labels/" class="new_window">in-field labels plugin</a> seems pretty awesome. </p>
<p>Of course, the right choice depends on the needs of your application. Better to go with something simple, if that&#8217;s all you need.</p>
<p><a href="http://github.com/coryschires/swap-value" class="new_window download">Download the project from GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/jquery-swap-form-value-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to shorten urls with bit.ly in Ruby on Rails.</title>
		<link>http://coryschires.com/how-to-shorten-urls-with-bit-ly-in-ruby-on-rails/</link>
		<comments>http://coryschires.com/how-to-shorten-urls-with-bit-ly-in-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 00:20:44 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bit.ly]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby-on-Rails]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=307</guid>
		<description><![CDATA[Create retweet links with shortened urls in ruby on rails. Only requires two simple helper methods which you can cut-n-paste into your application.]]></description>
			<content:encoded><![CDATA[<p>First, let&#8217;s make a simple retweet link for our application. To keep our views a little cleaner, we&#8217;ll make a helper method in <span class="code_text">app/helpers/application_helper.rb</span>:</p>
<div class="code_block">
<pre class="brush: ruby;">
        def twitter_url(resource, tweet_text="Check out this article from my-site.com:")
          tweet_url = root_url.chop + url_for(resource)
          "http://twitter.com/home?status=#{tweet_text} #{tweet_url}"
        end
    </pre>
</div>
<p>This method just builds a url to twitter and supplies some default text which you may optionally override by passing a second argument. Call it in your view like this:</p>
<div class="code_block">
<pre class="brush: ruby;">
        <%= link_to "Retweet this post!", twitter_url(@post) %>
    </pre>
</div>
<p>Now, this method works but it would be much better if we could use shortened urls. So let&#8217;s change things a bit in order to use bit.ly &mdash; twitter&#8217;s preferred url shortening service. Before we write any code&#8230; </p>
<ol>
<li>You&#8217;ll need to <a href="http://bit.ly/account/register?rd=/">sign up for bit.ly</a>.</li>
<li>And <a href="http://bit.ly/account/your_api_key">grap your api key</a>.</li>
</ol>
<p>With that info on hand, we&#8217;re ready to interface with the bit.ly api. Let&#8217;s make another helper method also located in <span class="code_text">app/helpers/application_helper.rb</span>:</p>
<div class="code_block">
<pre class="brush: ruby;">
        def shorten_with_bitly(url)
          # build url to bitly api
          user = "insert-your-username"
          apikey = "insert-your-api-key"
          version = "2.0.1"
          bitly_url = "http://api.bit.ly/shorten?version=#{version}&#038;longUrl=#{url}&#038;login=#{user}&#038;apiKey=#{apikey}"

          # parse result and return shortened url
          buffer = open(bitly_url, "UserAgent" => "Ruby-ExpandLink").read
          result = JSON.parse(buffer)
          short_url = result['results'][url]['shortUrl']
        end
    </pre>
</div>
<p>This method uses your credentials to build a url to interface with the bit.ly api. Bitly receives our request and returns a JSON object containing a shortened url. We&#8217;ll parse this object, grab the shortened url, and return it.</p>
<p>Finally, we need to change our initial <span class="code_text">twitter_url</span> method to include url shortening:</p>
<div class="code_block">
<pre class="brush: ruby;">
        def twitter_url(resource, tweet_text="Check out this article from my-site.com:")
          tweet_url = root_url.chop + url_for(resource)
          tweet_url = shorten_with_bitly(tweet_url) if Rails.env.production?

          "http://twitter.com/home?status=#{tweet_text} #{tweet_url}"
        end
    </pre>
</div>
<p>This is identical to our original method except we&#8217;ve added a new line which calls <span class="code_text">shorten_with_bitly</span>. This line overwrites the <span class="code_text">tweet_url</span> variable &mdash; replacing the long url with a shortened version. Finally, we&#8217;ll include a condition to ensure this only happens in production. This saves us from creating a bunch of useless bit.ly links that point to localhost urls.</p>
<h3>Some final points.</h3>
<ul>
<li>
        The <span class="code_text">shorten_with_bitly</span> method borrows heavily form a ruby snippet posted by <a href="http://puneetitengineer.wordpress.com/2009/07/27/minimise-url-in-ruby/">Puneet Pandey</a>. Pandey definitely deserves some credit here.
    </li>
<li>
        If you&#8217;re looking for a more robust way to interface with the bit.ly api, checkout this <a href="http://nasir.wordpress.com/2009/11/26/url-shortener-gem-bitly-api-wrapper-in-ruby/">url shortening gem</a> by Nasir Jamal. I&#8217;ve never used it but appears to be fully featured and well documented.
    </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/how-to-shorten-urls-with-bit-ly-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First few hours with processing.js.</title>
		<link>http://coryschires.com/first-few-hours-with-processing-js/</link>
		<comments>http://coryschires.com/first-few-hours-with-processing-js/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 05:57:06 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Processing.js]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=296</guid>
		<description><![CDATA[I finally had a chance to check out processing. This language seems to have a lot potential for creating things that would be difficult or impossible with plain javascript...]]></description>
			<content:encoded><![CDATA[<p>I finally had a chance to check out processing. This language seems to have a lot potential for creating things that would be difficult or impossible with plain javascript:</p>
<div class="processing_canvas">
    <canvas datasrc="http://coryschires.com/wp-content/themes/cs-simple/processing/colorful_circle.pjs"></canvas>
</div>
<h3>What is processing.js?</h3>
<p>Processing is an easy-to-learn, open-source programming language for making images, animation, and interactions. Think of it like Flash but without all the nonsense. <a href="http://ejohn.org/" class="new_window">John Resig</a> recently ported the language over to javascript for use on the web. The result &mdash; <a href="http://processingjs.org/">processing.js</a> &mdash; uses javascript to draw shapes and manipulate images on the HTML5 Canvas element.</p>
<h3>How does it work?</h3>
<h4><span>1</span> Download the latest version of processing.js.</h4>
<p>You can download the latest stable release <a href="http://processingjs.org/download">here</a>. The package will contain a few files. First, the processing library which you&#8217;ll need to include in your header like any other javascript library:</p>
<div class="code_block">
<pre class="brush: ruby;">
        &lt;script src="processing-0.4.js"&gt;&lt;/script&gt;
    </pre>
</div>
<p>Next, an example.pjs file. This is where you&#8217;ll write your actual processing code. You&#8217;ll need need to reference this file somewhere in the body of your webpage: </p>
<div class="code_block">
<pre class="brush: ruby;">
        &lt;canvas datasrc="example.pjs"&gt;&lt;/canvas&gt;
    </pre>
</div>
<h4><span>2</span> Create a setup() block to hold your basic configuration logic.</h4>
<p>A <span class="code_text">setup()</span> block holds your basic configuration logic (i.e. the stuff you want to happen one time when the file is loaded). A simple <span class="code_text">setup()</span> block might look like this:</p>
<div class="code_block">
<pre class="brush: java;">
        void setup() {
        	size(255,255);
        	background(224); // light gray
        }
    </pre>
</div>
<h4><span>3</span> And create a draw() block to manage your animation.</h4>
<p>You place your animation code inside a <span class="code_text">draw()</span> block. This code will run as a continuous loop. This means it can be response to interactions, such as mouse position. This little block, for example, will draw a thin black line based on mouse position:</p>
<div class="code_block">
<pre class="brush: java;">
        void draw() {
        	// set line color to black
        	stroke(0);
        	// draw line between previous and new mouse coordinates
        	line(pmouseX,pmouseY, mouseX,mouseY);
        }
    </pre>
</div>
<h3>Where can I learn more?</h3>
<p>There are not many processing.js specific resources. But don&#8217;t worry. Both processing.js and the standard processing language use the same java-like syntax. This means you can freely mix-n-match resources from either project.</p>
<p>With that in mind, here&#8217;s a few leads:</p>
<ul>
<li>
        The <a href="http://processingjs.org/">processing.js homepage</a> has an excellent <a href="http://processingjs.org/learning">learning section</a> as well as a fairly extensive <a href="http://processingjs.org/reference">reference library</a>.
    </li>
<li>
        Casey Reas and Ben Fry, the creators of processing were nice enough to write a book. It&#8217;s available from the MIT press: <a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&#038;tid=11251">Processing: A Programming Handbook for Visual Designers and Artists</a>
    </li>
<li>
        You might also checkout <a href="http://www.learningprocessing.com/">Learning Processing</a>. It&#8217;s a little easier to work through &mdash; especially if you&#8217;re new to programming.
    </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/first-few-hours-with-processing-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why you should deeply nest your CSS selectors.</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/</link>
		<comments>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 02:43:37 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Best-Practices]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=276</guid>
		<description><![CDATA[Most developers, even experienced developers, don't understand the value of deeply nesting CSS selectors...Your code will be better organized, easier to read, and more maintainable....]]></description>
			<content:encoded><![CDATA[<p>Most developers, even experienced developers, don&#8217;t understand the value of deeply nesting CSS selectors. Although writing the same selectors over and over might seem redundant, it&#8217;s worth the extra effort. Your code will be better organized, easier to read, and more maintainable. </p>
<h3>What do you mean by deeply nested selectors?</h3>
<p>Most of us learn to write CSS using shallow selectors. Essentially, you give an element a hook (class or id) and use it to write some style:</p>
<div class="code_block">
<pre class="brush: css;">
        #our_team { height: 230px; margin: 60px 0 0 0; }
        .employee { float: left; margin: 0 0 0 10px; }
        .name { text-decoration: underline; }
        .position { color: #add036; font-size: 10px; }
    </pre>
</div>
<p>But you can also trace each selector back to its common ancestor element:</p>
<div class="code_block">
<pre class="brush: css;">
        #our_team { height: 230px; margin: 60px 0 0 0; }
        #our_team .employee { width: 230px; height: 65px; float: left; }
        #our_team .employee a img { float: left; border: thin solid #5F6568; }
        #our_team .employee p { float: left; margin: 0 0 0 10px;  }
        #our_team .employee p span { display: block; margin: 0; }
        #our_team .employee p a span.name { line-height: 16px; font-size: 14px; }
        #our_team .employee p a:hover span.name { text-decoration: underline; }
        #our_team .employee p span.position { color: #add036; font-size: 10px; }
    </pre>
</div>
<h3>And why is this better?</h3>
<h4><span>1</span> It&#8217;s easy to quickly trace a given selector back to its parent element.</h4>
<p>In the above example, we know at a glance that <span class="code_text">.position</span> refers to an employee&#8217;s position and not something else (e.g. a utility class that adjusts an element&#8217;s position). This keeps things more explicit and thus less confusing.</p>
<h4><span>2</span> It divides your code into distinctive visual blocks.</h4>
<p>Take the above example, not only can you quickly identify all the selectors that belong to <span class="code_text">#our_team</span> but you can also see how the style cascades through the element. This is especially useful when your stylesheet grows past a few hundred lines.</p>
<h4><span>3</span> Your rules won&#8217;t inadvertently override each other.</h4>
<p>Because all selectors trace back to a unique ancestor element, you can be sure that everything nested within that selector will only effect its intended target. This means you can use common class names (e.g. <span class="code_text">.first</span>, <span class="code_text">.title</span>, <span class="code_text">.column</span>, etc.) with confidence that you won&#8217;t be breaking the styling elsewhere on your site.</p>
<h4><span>4</span> You get the benefits of cascading without the headaches.</h4>
<p>When using shallow selectors, you often rely on the order that selectors appear in your stylesheet. For example, if you have two selectors of the same value, priority will be given to whichever selector appears last in your stylesheet. That&#8217;s fine except when rules start cascading in unintended ways. Then rules become unresponsive because some other selector, four hundred lines lower, is running the show. </p>
<p>But deeply nested selectors don&#8217;t have this problem. Because everything traces back to a unique selector, you can be sure your rules will stick <span class="italic">no matter where they appear in the stylesheet</span>. And, of course, you can still enjoy the benefits of cascading within the scope of a unique ancestor.</p>
<h4><span>5</span> You can safely use @import to organize your stylesheets.</h4>
<p>Stylesheets can get really long and most of us have devised clever means of trying to keep things organized (e.g. headers, sub-sections, comments, etc.). But the best strategy is to divide your stylesheet into logical chunks, save those chunks as separate files, and include everything (as needed) into a few master stylesheets using the <span class="code_text">@import</span> directive. This is easier on your server (since you&#8217;re only linking to a few stylesheets) and on your brain (since you&#8217;re not scanning through a stylesheet that&#8217;s 3000 lines long).</p>
<p>But this strategy is problematic since all <span class="code_text">@import</span> directives must be placed at the very top of your stylesheet. And, because the normal rules of cascading still apply, you can run into inheritance problems pretty quickly if you try to do something like this: </p>
<div class="code_block">
<pre class="brush: css;">
        @import url("reset.css");
        @import url("header.css");
        @import url("footer.css");

        /* ...a bunch of selectors that will likely over-
        ride what you're trying to do in footer.css... */
    </pre>
</div>
<p>But if your selectors are deeply nested you can use <span class="code_text">@import</span> with impunity. So long as your selectors trace back to a unique ancestor the order of inclusion makes no difference. You can import <span class="code_text">footer.css</span> before <span class="code_text">reset.css</span> and it&#8217;s not going to do any harm.</p>
<p>This means you can use <span class="code_text">@import</span> the way would a php <span class="code_text">include()</span> statement or a rails <span class="code_text">:partial</span> in a template. In other words, you can really break things up and keep your stylesheets super organized:</p>
<div class="code_block">
<pre class="brush: css;">
        @import url("reset.css");
        @import url("utilities.css");
        @import url("typography.css");
        @import url("page_structure.css");
        @import url("header.css");
        @import url("main_nav.css");
        @import url("footer.css");

        /* ...the specific style for each individual page
        with all the shared styles neatly partitioned into
        separate files... */
    </pre>
</div>
<p>Hope this helps get those stylesheets under control.</p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>JQuery Quote Rotator Plugin.</title>
		<link>http://coryschires.com/jquery-quote-rotator-plugin/</link>
		<comments>http://coryschires.com/jquery-quote-rotator-plugin/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 03:58:12 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=265</guid>
		<description><![CDATA[Here’s a jQuery plugin that rotates through list items with a nice fade effect...]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a jQuery plugin that rotates through list items with a nice fade effect. You may nest any type of element you like inside a given list item.</p>
<p>Here&#8217;s an example using blockquotes and citations:</p>
<ul id="quotes">
<li>
<blockquote><p>Lorem ipsum dolor sit amet elit!</p></blockquote>
<p>            <cite>&mdash; Alabama</cite>
        </li>
<li>
<blockquote><p>Excepteur sint occaecat cupidatat non proident!</p></blockquote>
<p>            <cite>&mdash; Georgia</cite>
        </li>
<li>
<blockquote><p>Duis aute irure dolor in reprehenderit?</p></blockquote>
<p>            <cite>&mdash; Illinois</cite>
        </li>
<li>
<blockquote><p>Excepteur sint mollit anim id est laborum.</p></blockquote>
<p>            <cite>&mdash; West Virginia</cite>
        </li>
</ul>
<h3>How to make it work.</h3>
<p>Drop these scripts in your header:</p>
<div class="code_block">
<pre class="brush: ruby;">
        <script src="js/jquery-1.4.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery.quote_rotator.js" type="text/javascript" charset="utf-8"></script>
    </pre>
</div>
<p>Call the function to any list element:</p>
<div class="code_block">
<pre class="brush: jscript;">
        $(document).ready(function() {
            $('ul#quotes').quote_rotator();
        });
    </pre>
</div>
<p>And some configuration options:</p>
<div class="code_block">
<pre class="brush: jscript;">
        $('ul#quotes').quote_rotator({
             rotation_speed: 7000,    // defaults to 5000
             pause_on_hover: false   // defaults to true
        });
    </pre>
</div>
<p>I&#8217;ve also built in a default to pause rotation on mouse hover. This is nice if you&#8217;re rotating through links or other elements that you might not want fading away from the user.</p>
<p><a class="new_window download" href="http://github.com/coryschires/quote-rotator">Download the project from github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/jquery-quote-rotator-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introducing Image Mapper!</title>
		<link>http://coryschires.com/introducing-image-mapper/</link>
		<comments>http://coryschires.com/introducing-image-mapper/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 03:39:27 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=241</guid>
		<description><![CDATA[Image Mapper is a web application that makes it dead easy to create HTML image maps...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working hard on a new app for the past few days &#8211; <a href="http://image-mapper.com">Image Mapper</a>. It makes creating HTML image maps super easy.</p>
<p><a href="http://www.image-mapper.com/" class="new_window"><br />
<img class="msg_small_font" title="Click to see image mapper." src="http://coryschires.com/wp-content/themes/cs-simple/images/image_mapper_preview.png" alt="Image Mapper" /><br />
</a></p>
<p>If you&#8217;ve ever used DreamWeaver to create an image map, then you&#8217;ll be pretty familiar with image-mapper&#8217;s interface. It&#8217;s three dead simple steps:</p>
<ol>
<li>Upload your image</li>
<li>Map your image</li>
<li>Copy your code</li>
</ol>
<p>It all happens on a single page so it&#8217;s pretty hard to get confused.</p>
<p>It&#8217;s made with Ruby on Rails and jQuery. And best of all, no more having to deal with DreamWeaver! Have a look for yourself.</p>
<p>Visit <a href="http://image-mapper.com">Image Mapper</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/introducing-image-mapper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to equip rails for behavior driven development.</title>
		<link>http://coryschires.com/how-to-equip-rails-for-behavior-driven-development/</link>
		<comments>http://coryschires.com/how-to-equip-rails-for-behavior-driven-development/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 01:29:33 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Ruby-on-Rails]]></category>
		<category><![CDATA[Selenium]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=214</guid>
		<description><![CDATA[There's a lot of hype around behavior driven development. Learn how to get your application equipped for the challenge...]]></description>
			<content:encoded><![CDATA[<p>First, you&#8217;re going to need a few gems: cucumber, rspec-rails, rspec, and webrat. Although there are a number of ways you can get these running in your new rails project, the best plan is to set up gem dependencies directly in your application using the handy <span class="code_text">config.gem</span> command. </p>
<p>Just add these lines to <span class="code_text">config/environments/test.rb</span>:</p>
<div class="code_block">
<pre class="brush: ruby;">
		config.gem 'rspec-rails' , :lib => false
		config.gem 'rspec' , :lib => false
		config.gem 'cucumber'
		config.gem 'webrat'
	</pre>
</div>
<p>Next, make sure these gems are installed by typing:</p>
<div class="code_block">
<pre class="brush: plain;">
		RAILS_ENV=test sudo rake gems:install
	</pre>
</div>
<p>Finally, you&#8217;ll need to bootstrap your rails application for development with Cucumber and RSpec. Simply type:</p>
<div class="code_block">
<pre class="brush: plain;">
		script/generate rspec
		script/generate cucumber
	</pre>
</div>
<p>That&#8217;s it. Now you&#8217;re set up for behavior driven development in your rails app.</p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/how-to-equip-rails-for-behavior-driven-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery hover caption plugin.</title>
		<link>http://coryschires.com/jquery-hover-caption-plugin/</link>
		<comments>http://coryschires.com/jquery-hover-caption-plugin/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:13:42 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=202</guid>
		<description><![CDATA[Here’s a simple jQuery plugin that adds both a caption and a gray-out effect when hovering over an image...]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple jQuery plugin that adds both a caption and a gray-out effect when hovering over an image. For example:</p>
<p><img class="msg" title="This is the title attribute." alt="Flapper 1922" src="http://coryschires.com/wp-content/themes/cs-simple/images/posts/flapper_1922.jpg"/></p>
<h3>How to make it work.</h3>
<p>1. Drop these scripts in your header:</p>
<div class="code_block">
<pre class="brush: ruby;">
		<script src="js/jquery-1.4.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery.hover_caption.js" type="text/javascript" charset="utf-8"></script>
	</pre>
</div>
<p>2. Call the plugin function on your images:</p>
<div class="code_block">
<pre class="brush: jscript;">
		$(document).ready(function() {
			$('img').hover_caption();
		});
    </pre>
</div>
<p>3. Add this tiny bit of CSS somewhere:</p>
<div class="code_block">
<pre class="brush: css;">
		.hover_caption {
			background-image: url(hover_caption_bg.png);
			/* NOTE: if you're img elements have paddings
			or margins you'll need to match them here
			to get things lined up properly. */
		}
    </pre>
</div>
<p>And here&#8217;s some configuration options:</p>
<div class="code_block">
<pre class="brush: jscript;">
		$('img').hover_caption({
			caption_font_size: '18px',
			caption_color: 'white',
			caption_bold: true,
			caption_default: "Click for screenshots."
		});
	</pre>
</div>
<h3>And the captions are pretty smart.</h3>
<p>If your image has a title attribute, the plugin will use that as the caption. Otherwise it will default to <span class="code_text">Click for screenshots</span>. You can change the default if you like, of course.</p>
<h3>A few gotchas.</h3>
<ul>
<li>Be sure the path to <span class="code_text">hover_caption_bg.png</span> is correct.</li>
<li>Don&#8217;t forget to add <span class="code_text">hover_caption_bg.png</span> to your project.</li>
<li>Be sure the path to <span class="code_text">hover_caption.js</span> is correct.</li>
<li>Make sure you&#8217;ve referenced jQuery first in your header.</li>
</ul>
<p><a class="new_window download" href="http://github.com/coryschires/hover-caption">Download the project from github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/jquery-hover-caption-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A lesson in not repeating yourself.</title>
		<link>http://coryschires.com/a-lesson-in-not-repeating-yourself/</link>
		<comments>http://coryschires.com/a-lesson-in-not-repeating-yourself/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 03:34:00 +0000</pubDate>
		<dc:creator>Cory Schires</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Best-Practices]]></category>

		<guid isPermaLink="false">http://coryschires.com/?p=191</guid>
		<description><![CDATA[Not repeating yourself is a big part of writing stable code. You start writing the same code in three places and changes become a real pain...]]></description>
			<content:encoded><![CDATA[<p>Not repeating yourself is a big part of writing stable code. You start writing the same code in three places and changes become a real pain. More importantly, it&#8217;s very easy to forget something and end up with buggy programs.</p>
<p>But it&#8217;s easy to overlook a little bit of repetition. You&#8217;re in a hurry or dealing with an existing code base or whatever. But this is never a good idea as I learned&#8230;</p>
<p>We have an app where users pay a subscription fee through paypal. There are two separate actions &#8211; subscribe and renew &#8211; which send the user to paypal along with the necessary parameters (price, subscription type, etc.).</p>
<blockquote><p>
Two actions doing pretty much the same thing? Yep, that means repetition.
</p></blockquote>
<p>So, we were running some tests on the payment process and, to do so, had set the subscription fee to a penny. We got everything sorted, reset the subscription fees, and deployed our changes. Of course, we forget to reset the fees in the renew action.</p>
<p>The very next day, a customer renewed their subscription for the low, low price of one cent. So annoying. Anyway, can&#8217;t stress it enough &#8211; don&#8217;t repeat yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://coryschires.com/a-lesson-in-not-repeating-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
