<?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>James Van Dyne</title>
	<atom:link href="http://www.james-vandyne.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.james-vandyne.com</link>
	<description>The Life and Times</description>
	<lastBuildDate>Sat, 08 Oct 2011 16:11:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>3 DRY Techniques for Maintainable Ajax</title>
		<link>http://www.james-vandyne.com/3-dry-techniques-for-maintainable-ajax/</link>
		<comments>http://www.james-vandyne.com/3-dry-techniques-for-maintainable-ajax/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 16:09:21 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.james-vandyne.com/?p=196</guid>
		<description><![CDATA[Using ajax on the web is old technology. Writing a good javascript to achieve this is not difficult, but it is rarely covered in introduction to ajax tutorials. The result is a mixing of html &#8220;templates&#8221; inside your javascript code. &#8230; <a href="http://www.james-vandyne.com/3-dry-techniques-for-maintainable-ajax/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using ajax on the web is old technology. Writing a good javascript to achieve this is not difficult, but it is rarely covered in introduction to ajax tutorials. The result is a mixing of html &#8220;templates&#8221; inside your javascript code. If you change your original markup at all, you have to remember to also update your template and if you have more than a single ajax call on your website, your site becomes a fragile mess.</p>

<p>Below I will outline some techniques that I use when developing websites that help keep my Javascript to a minimum and prevent me from repeating myself.</p>

<h4>Create a convention, and stick to it</h4>

<p>Create your naming scheme for your DOM ids and CSS classes and stick to it. This will make it a lot easier to write your javascript in a generic fashion and then process requests on the server.</p>

<p>For IDs, I usually combine at minimum the action and a unique identifier ( record id or primary key ) sandwiching a hyphen. If I am doing work with multiple forms on a page, I might also include the form prefix in the identifier as well.</p>

<p>Create css class conventions for basic actions, and use them consistently. The main 2 that I use are a class named &#8220;link&#8221; and &#8220;ajaxAction&#8221;.</p>

<h4>Render responses server side</h4>

<p>You should never embed html templates into your javascript. Ever. As stated above this creates a fragile mess that is difficult to maintain. Instead take advantage of your web framework&#8217;s template rendering system ( you are using some kind of framework, right? ). Make sure it&#8217;s the same template that you also use to originally generate the page in the first place. I use Django for most of my web development, so if I am rendering a table that is ajax&#8217;ified my table template might look something like this:</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!-- table.html --&gt;
&lt;table&gt;
	{% for row in data %}
		{% if forloop.first %}
			&lt;tr&gt;
				&lt;th&gt;Date&lt;/th&gt;
				&lt;th&gt;Message&lt;/th&gt;
			&lt;/tr&gt;
		{% endif %}
		{% include 'message_row.html' %}
	{% endfor %}
&lt;/table&gt;
&nbsp;
&lt;!-- message_row.html --&gt;
&lt;tr&gt;
	&lt;td&gt;{{row.data}}&lt;/td&gt;
	&lt;td&gt;{{row.message}}&lt;/td&gt;
&lt;/tr&gt;</pre></div></div>


<p>My ajax response would then simply render message_row.html as part of its response. This insures that by ajax response and my original rendering are always the same.</p>

<h4>Use Delegates Instead of Bindings</h4>

<p>When first learning how to use jQuery, we usually bind our dom objects either directly via identifiers or by css classes. This works fine, until you try to add a new element after initial binding. You can click all that new element all you want, but it won&#8217;t respond until you rebind it. Again, unsustainable.</p>

<p>Learn to use delegates instead. The effectively automatically binds all elements on the page, no matter when they are added, by doing lazy processing of the request.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.ajaxAction'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">//BAD</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">delegate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.ajaxAction'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">//GOOD</span></pre></div></div>


<h3>Conclusion</h3>

<p>Javascript doesn&#8217;t have to be ugly and repetitive, although it is often introduced in manners that encourage this. Writing clean and concise Javascript is not difficult, but it does take some discipline and planning. Following the 3 above techniques alone will not guarantee your code is perfect, but it will greatly enhance maintainability and reduce errors in common functions on your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.james-vandyne.com/3-dry-techniques-for-maintainable-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Test File Upload Parsing in Django</title>
		<link>http://www.james-vandyne.com/how-to-test-file-upload-parsing-in-django/</link>
		<comments>http://www.james-vandyne.com/how-to-test-file-upload-parsing-in-django/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 04:04:48 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.james-vandyne.com/?p=191</guid>
		<description><![CDATA[I didn&#8217;t start testing software until recently. Of course I tested my software to make sure it works and is stable, but it was a very manual process. This was very time consuming and sometimes subtle bugs were let through &#8230; <a href="http://www.james-vandyne.com/how-to-test-file-upload-parsing-in-django/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I didn&#8217;t start testing software until recently. Of course I tested my software to make sure it works and is stable, but it was a very manual process. This was very time consuming and sometimes subtle bugs were let through or re-introduced in large codebase changes.</p>

<p>I didn&#8217;t start unit-testing for a long time because I didn&#8217;t really know where to begin. Especially with an existing codebase. I&#8217;ve been working on a project and part of the project includes a file upload that needs to be parsed. I couldn&#8217;t stomach the thought of clicking, browsing, submitting and waiting each time just to test a few changes.</p>

<h3>Problem</h3>

<p>Testing uploaded file parsing in a manual fashion is very time consuming and takes a long time. If the parsing breaks, we won&#8217;t know unless we upload each test file after every change. We can do better than this.</p>

<p>We need to utilize the testing framework in Django to help us automate this process a bit more.</p>

<h3>Solution</h3>

<p>The first thing we want to do is make an example file that a user may upload in our fixtures directory. Keeping the test upload files in our fixtures has a number of advantages. It allows us to keep them in our version control and lets all of our testing be portable.</p>

<p>For the example let&#8217;s pretend we are parsing an excel file of some kind.</p>

<p><img src="http://www.james-vandyne.com/wp-content/images/2011/fixture.png" title="Our test file in the fixtures dir"/></p>

<p>The next step is to prepare our test. While we are only testing a single file upload, you may want to add in corrupted files or perhaps expand to different versions. So, lets setup our test with a single test &#8220;runner&#8221; test that will run the tests.</p>

<p>Also note that by keeping the import statements using a localized path instead of a full package sitename.app.file, we can further improve portability.</p>

<pre code="python">
from django.test import TestCase
from utils import parse_excel_upload
import os

class ExcelParseTest(TestCase):
    
    test_upload_path = 'fixtures/test_upload.xls'
    
    def test_parse(self):
      self.parse(self.test_upload_path)
</pre>

<p>The above is straight forward, we have our excel test parse class, and a method named test_parse that will call a method named parse that takes a filename and will run all the actual tests.</p>

<p>Next, let&#8217;s setup our actual parse method:</p>

<pre code="python">
 def parse(self,file_location):
        """
        Tests that we can parse our excel files
        """
        
        #setup
        path = os.path.join(os.path.split(__file__)[0],file_location)

        elements = parse_excel_upload(path)
        
        #Assert that we have something returned as expected
        self.assertNotEqual(elements,None)
        # continue doing more specific tests here
</pre>

<p>Note that I am using self.assertNotEqual. If you are running Python 2.7 or later, you can use self.assertNotNone(elements) for the same functionality. Using assertNotEqual simply allows us to run a older versions of python as well.</p>

<p>If we wanted to test our method with more files, perhaps some corrupted files, we simply need to add another test file in our fixture and then modify our runner to include parse the new file.</p>

<h3>Conclusion</h3>

<p>Testing requires a small initial time investment to get started. If it&#8217;s your first time testing, there are a few mental gymnastics to get used to for writing code that is testable.</p>

<p>After the initial investment, which becomes less and less each time do it, we can vastly improve the reliability of our code and catch subtle bugs that may crop up during development or future releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.james-vandyne.com/how-to-test-file-upload-parsing-in-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on Xcode 4 Price</title>
		<link>http://www.james-vandyne.com/thoughts-on-xcode-4-price/</link>
		<comments>http://www.james-vandyne.com/thoughts-on-xcode-4-price/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 06:18:42 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://www.james-vandyne.com/?p=184</guid>
		<description><![CDATA[With the release of Xcode 4 came a completely unknown feature, even for developers like myself: a price tag. This is the first time that Xcode has ever had a price. Since the release of OS X, Xcode (and its &#8230; <a href="http://www.james-vandyne.com/thoughts-on-xcode-4-price/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With the release of Xcode 4 came a completely unknown feature, even for developers like myself: a price tag. This is the first time that Xcode has ever had a price. Since the release of OS X, Xcode (and its predecessor Project Builder) have been available free of charge.</p>

<p>At the time, having a full, professional grade IDE available for free was mostly unheard of. Compared with Visual Studio, who&#8217;s minimum entrance fee was in the range of $1000. Students, of course, got a discount. Since then having a free IDE on your platform has become the norm. If this is because of Xcode or not, I am not sure.</p>

<p>Suddenly, for the first time, Xcode has a price for non-paid developers: $4.99. There has been an uproar as to what open source developers and people who are interested in learning to program will do. That Apple is somehow taking away a lot from developers by adding this barrier to entry. I would argue, they aren&#8217;t.</p>

<p>Open source developers often list Xcode as a dependency for those that wanted to compile from source, not because the project required Xcode, but because it installed the requisite compilers. If having Xcode as a dependency is  not something that developers want, then the community is going to need to pick up the slack as per keeping the toolchain current and packaged.  As these tools are open source, it shouldn&#8217;t be that difficult to do (although we do know what happens when we say shouldn&#8217;t&#8230;.)</p>

<p>Ignoring the argument that if you can afford a Mac, and you&#8217;re interested in learning to program, you can afford $5 dollars for tools to develop with. More than likely, the book you pick up to learn Objective-C will cost a heck of a lot more than that.</p>

<p>At the end of the day, any serious mac developer is going to have the $99 dollar subscription to the Mac developer program. If you&#8217;re looking to learn to program for the Mac, 5 dollars is a minimal investment for access to a world class development tools. If you&#8217;re just looking to program on your Mac but don&#8217;t want to spend the $5 for Xcode or $99 for the developer subscription, learn a language different than Objective-C. There are many build in programming languages in OSX, including Python and Ruby.</p>

<p>As for me? I will keep my paid developer accounts ignore the rest of the uproar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.james-vandyne.com/thoughts-on-xcode-4-price/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Create Realistic Buttons with CSS3</title>
		<link>http://www.james-vandyne.com/creating-realistic-buttons-with-css3/</link>
		<comments>http://www.james-vandyne.com/creating-realistic-buttons-with-css3/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 04:51:42 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.james-vandyne.com/?p=168</guid>
		<description><![CDATA[In a modern web application we don&#8217;t really use buttons (ala the input tag) so much. More often than not, we use some kind of div or link that when combined with some javascript behaves as a button. I&#8217;m not &#8230; <a href="http://www.james-vandyne.com/creating-realistic-buttons-with-css3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In a modern web application we don&#8217;t really use buttons (ala the input tag) so much. More often than not, we use some kind of div or link that when combined with some javascript behaves as a button. I&#8217;m not going to cover how to hook this all up into your application, but rather just the styling of buttons.</p>

<h3>Problem</h3>

<p>Traditionally, web developers have had to create graphics for every non-standard button they used on their site. This is expensive in terms of time, money, and usability. It takes extra work for our buttons to be assessable, increases load times, and if we ever want to change the wording of our button, we have to start all over again.</p>

<p>Using various features afforded in css3, we can remove the need for images altogether, lower load times (and save bandwidth) while gaining scalability of our user interface, full accessibility, and never have something that is completely reusable throughout our site without any extra work.</p>

<p>We are going to go from the one on the left to the one on the right.</p>

<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/before-after.png"/></p>

<h3>Solution</h3>

<p>First, we need to begin with our basic markup.</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;#&quot;&gt;My Button&lt;/a&gt;</pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/no-style.png"/></p>

<p>Because we want to style it and reuse said styles more than once on a page (potentially), we&#8217;re going to want to add a css class name.</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;#&quot; class=&quot;gradient_button&quot;&gt;My Button&lt;/a&gt;</pre></div></div>


<p>That&#8217;s all the html markup we will use. From here on out, we will just be adding styles to our stylesheet. The first thing we need to do is decide which color our button needs to be. We need a minimum of 2 colors: one lighter color for the top of the button and one darker color (of the same shade) for the button of the button.</p>

<p>I used the <a href="http://gradients.glrzad.com/" target="_blank">CSS3 Gradient Generator</a> to select my colors and generate the rules. I&#8217;ve picked a grey color for this tutorial. Feel free to pick anything you like. Let&#8217;s set it as the background for our button. Let&#8217;s create our gradient_button selector and add our gradient background</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.gradient_button</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span>color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.43</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span>color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.72</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">center</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span><span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">43%</span><span style="color: #00AA00;">,</span><span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">72%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/gradient.png"/></p>

<p>It&#8217;s ugly, but we&#8217;re getting closer. Next, let&#8217;s add some padding around our button, create a border, and give it rounded corners. Add the following to the gradient_button selector.</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>
-webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
-moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span></pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/rounded.png"/></p>

<p>Already we are looking much better and more realistic. However, the text completely throws the button off. It looks like it&#8217;s just pasted on there. We want our text to be a part of the button. We can do that by insetting the text with a shadow. So, next, let&#8217;s remove the text decoration, change the color, and inset that text.</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ffe</span> <span style="color: #933;">0px</span> <span style="color: #933;">1px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#333</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span></pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/inset.png"/></p>

<p>Already, you can see our button finally looks like a button. We could stop there, but we should go the extra mile for that last bit of polish. Especially considering how much time we can save because we never have to visit photoshop to make a button again.</p>

<p>First, we need to recognize that objects are never flat. Everything casts a shadow. Our buttons are no different. Remember to try and keep a consistent light source when implementing shadows on your website, my light source is directly above, so I only want to cast a shadow below my button. Add the following to the selector:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">-moz-box-shadow<span style="color: #00AA00;">:</span>  <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
-webkit-box-shadow<span style="color: #00AA00;">:</span>  <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span></pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/shadow.png"/></p>

<p>Our button now looks great. Try clicking on it. Notice that? It maybe look like a button, but it surely doesn&#8217;t behave like a button. We can fix that by adding one more selector. We need to style the :active state of the link, which is displayed when a button is pressed.</p>

<p>When picturing a physical button pressed, what sort of changes we see? I imagine that the shadow would disappear, as the button is now becoming flat with the surface from which it protrudes. Also, I imagine that the shine of our gradient would change. I think that it would become almost a solid color, but not quite. Let&#8217;s one last style to make our button behave a lot more naturally when clicked.</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #3333ff;">:active</span><span style="color: #6666ff;">.gradient_button</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span>color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.18</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span>color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.59</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span>color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">center</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">18%</span><span style="color: #00AA00;">,</span><span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">176</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">59%</span><span style="color: #00AA00;">,</span><span style="color: #993333;">rgb</span><span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">234</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">237</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div>


<p><img src="http://www.james-vandyne.com/wp-content/uploads/2011/03/pushed.png"></p>

<p>There we have it. A completely realistic button using nothing but CSS3 and a hyperlink.</p>

<h3>Conclusion</h3>

<p>CSS3 buttons allows us to save time (and therefore money) when developing a modern web application. Moreover, we get fringe benefits such as being able to make our website more accessible and fully scalable for free.</p>

<p><a href="http://www.james-vandyne.com/wp-content/uploads/2011/03/gradient_button.html" target="_blank">View Realistic CSS3 Button</a></p>

<h3>Update:</h3>

<p>This doesn&#8217;t work in IE. If you&#8217;d like to use a similar effect for the gradient, you can use the IE filter styles. The major caveat is that IE only seems to render these with a div wrapper or an absolute position. The div wrapper really kills the elegance of being able to have any link suddenly look and behave like a regular button with a single style. I recommend a graceful-degradation in IE, and just set the background color to a be solid.</p>

<p>The css for getting the same gradient effect in IE is as follows:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">	<span style="color: #808080; font-style: italic;">/* For Internet Explorer 5.5 - 7 */</span>
	filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span>startColorstr<span style="color: #00AA00;">=</span><span style="color: #cc00cc;">#EDEAED</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #cc00cc;">#B0B0B0</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #808080; font-style: italic;">/* For Internet Explorer 8 */</span>
	-ms-filter<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;progid:DXImageTransform.Microsoft.gradient(startColorstr=#EDEAED, endColorstr=#B0B0B0)&quot;</span><span style="color: #00AA00;">;</span>
	<span style="color: #808080; font-style: italic;">/* graceful-degradation when the filter doesn't work */</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#EDEAED</span><span style="color: #00AA00;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.james-vandyne.com/creating-realistic-buttons-with-css3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bill&#8217;s in Shichirigahama</title>
		<link>http://www.james-vandyne.com/bills-in-shichirigahama/</link>
		<comments>http://www.james-vandyne.com/bills-in-shichirigahama/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 01:47:18 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Cafe]]></category>
		<category><![CDATA[Japan]]></category>
		<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://www.james-vandyne.com/?p=166</guid>
		<description><![CDATA[Sometimes you need a day off. Yesterday was that day for me. Instead of going to Sakuragicho or Minatomirai and visiting a museum, I decided to do something different. I decided to have my first meal at a restaurant belonging &#8230; <a href="http://www.james-vandyne.com/bills-in-shichirigahama/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need a day off. Yesterday was that day for me. Instead of going to Sakuragicho or Minatomirai and visiting a museum, I decided to do something different. I decided to have my first meal at a restaurant belonging to a celebrity chef, Australian Bill Granger.</p>

<p>He open his first restaurant in Japan in Shichirigahama, off of the Enoden-line. I hadn&#8217;t ridden the Eno-den yet, but was rather excited as it&#8217;s quite old, having been around since 1900.</p>

<p><a href="http://www.flickr.com/photos/hamapenguin/18803016/" title="enoden 02 by hamapenguin, on Flickr"><img src="http://farm1.static.flickr.com/12/18803016_8cb730b156.jpg" width="500" height="375" alt="enoden 02" /></a></p>

<p><small>photo courtsy of hamapenguin on Flickr</small></p>

<p>When I think of a celebrity chef, I usually think of a stiff atmosphere, and prices so high I swear I&#8217;m paying for white on the plate, not food. Bill&#8217;s is quite the opposite. While the prices are a tad higher than usual, it&#8217;s nothing out of the ordinary in Japan.</p>

<p><a href="http://www.flickr.com/photos/90515377@N00/5480656722" title="View 'http://farm6.static.flickr.com/5293/5480656722_ed17d39df8.jpg' on Flickr.com"><img border="0" style="display:block; margin-left:auto; margin-right:auto;" height="333" src="http://farm6.static.flickr.com/5293/5480656722_ed17d39df8.jpg" alt="http://farm6.static.flickr.com/5293/5480656722_ed17d39df8.jpg" width="500" title="http://farm6.static.flickr.com/5293/5480656722_ed17d39df8.jpg"/></a></p>

<p>I ordered the Ricotta Pancakes with Honey Butter and Banana. It was incredible. At first thought, one would expect a cheesy flavour, but as ricotta does not have much taste by itself, this is was not the case. They were incredibly filling (as pancakes usually are for me) and highly recommend them.</p>

<p><a href="http://www.flickr.com/photos/90515377@N00/5480655862" title="View 'http://farm6.static.flickr.com/5173/5480655862_659bf7d0c4.jpg' on Flickr.com"><img border="0" style="display:block; margin-left:auto; margin-right:auto;" height="333" src="http://farm6.static.flickr.com/5173/5480655862_659bf7d0c4.jpg" alt="http://farm6.static.flickr.com/5173/5480655862_659bf7d0c4.jpg" width="500" title="http://farm6.static.flickr.com/5173/5480655862_659bf7d0c4.jpg"/></a></p>

<p>In hindsight, I should have ordered coffee or something bitter to go with my pancakes, but how does one see an Orange Juice, Banana, Yogurt, and Berry drink? You can&#8217;t. Given the price of ¥700, I was a little disappointed in the amount received, but it encouraged me to savor the flavour that much more.</p>

<p><a href="http://www.flickr.com/photos/90515377@N00/5480053789" title="View 'http://farm6.static.flickr.com/5256/5480053789_164a9c02d0.jpg' on Flickr.com"><img border="0" style="display:block; margin-left:auto; margin-right:auto;" height="333" src="http://farm6.static.flickr.com/5256/5480053789_164a9c02d0.jpg" alt="http://farm6.static.flickr.com/5256/5480053789_164a9c02d0.jpg" width="500" title="http://farm6.static.flickr.com/5256/5480053789_164a9c02d0.jpg"/></a></p>

<h3>Conclusion</h3>

<p><a href="http://www.bills-jp.net">Bill&#8217;s</a> in Shichirigahama comes highly recommended. The food was delicious and not overly expensive. The view of the ocean makes it the perfect place to enjoy a quiet Sunday morning.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.james-vandyne.com/bills-in-shichirigahama/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

