
<?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>PugetWorks.com</title>
	<atom:link href="http://pugetworks.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://pugetworks.com/blog</link>
	<description>Software development in Seattle</description>
	<lastBuildDate>Fri, 27 Apr 2012 02:00:37 +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>Resources from Mobile Boilerplate</title>
		<link>http://pugetworks.com/blog/2012/04/960/</link>
		<comments>http://pugetworks.com/blog/2012/04/960/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 04:59:28 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://pugetworks.com/blog/?p=960</guid>
		<description><![CDATA[I&#8217;ve been playing around with Mobile Boilerplate, because the HTML5 Boilerplate project has been an excellent resource and I&#8217;m always looking for ways to make developing mobile websites easier on myself (The next redesign of the Pugetworks site is going to have to reflect a mobile-first approach, but I want... <a class="more" href="http://pugetworks.com/blog/2012/04/960/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[I&#8217;ve been playing around with <a href="http://html5boilerplate.com/mobile">Mobile Boilerplate</a>, because the HTML5 Boilerplate project has been an excellent resource and I&#8217;m always looking for ways to make developing mobile websites easier on myself

(The next redesign of the Pugetworks site is going to have to reflect a mobile-first approach, but I want to give our fancy portfolio a short stay of execution, given all the work involved in setting it up. Have you tried it yet?)

Overall, Mobile Boilerplate is a good setup, and I&#8217;ve decided I&#8217;ll use it on an upcoming personal project. In the meantime, their <a href="https://github.com/h5bp/mobile-boilerplate/wiki">wiki</a> pointed me to a couple of excellent resources I wanted to turn around and recommend to you:
<ul>
	<li><a href="https://docs.google.com/present/view?id=dkx3qtm_22dxsrgcf4"> The Idiot&#8217;s Guide to viewport and pixel</a> is an excellent, no-nonsense explanation of the challenges presented by mobile viewport and media queries, and the current working solutions to them. It explains why MB is set up to the way it is, but it&#8217;s 100% generalizable to your web site whether you&#8217;re using the templates or not.</li>
	<li><a href="http://www.webkit.org/blog/1620/webkit-remote-debugging/"> Webkit Remote Debugging</a> is something I have not tried yet, but it promises to allow you to run the Web Inspector tool from Safari on web pages displayed on another browser, even on another computer. This includes mobile devices like the iPhone, if you do a couple tweaks in xcode. Given the difficulty of developing mobile apps without a good built-in debugger, this could change everything.</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2012/04/960/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Gradients Along a Path in Photoshop and Illustrator</title>
		<link>http://pugetworks.com/blog/2012/04/making-gradients-along-a-path-in-photoshop-and-illustrator/</link>
		<comments>http://pugetworks.com/blog/2012/04/making-gradients-along-a-path-in-photoshop-and-illustrator/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 04:23:26 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://pugetworks.com/blog/?p=910</guid>
		<description><![CDATA[In Photoshop It&#8217;s easy enough to apply a simple gradient to a shape or vector path in Photoshop. You can use the gradient tool, or apply a blending layer. You can apply linear gradients, radial gradients, simple gradients and more complicated ones. You can also apply a gradient to the... <a class="more" href="http://pugetworks.com/blog/2012/04/making-gradients-along-a-path-in-photoshop-and-illustrator/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<h2>In Photoshop</h2>
It&#8217;s easy enough to apply a simple gradient to a shape or vector path in Photoshop. You can use the gradient tool, or apply a blending layer. You can apply linear gradients, radial gradients, simple gradients and more complicated ones. You can also apply a gradient to the interior of a shape, but it&#8217;s slightly less obvious how to do this. Here&#8217;s the easiest way I know of.

<img style="margin:20px 0" class="aligncenter size-full wp-image-957" title="photoshop-gradient-path" src="http://pugetworks.com/blog/wp-content/uploads/2012/04/photoshop-gradient-path.png" alt="Tutorial Image" width="580" height="344" />
<ol>
	<li>Begin with your shape, in its own layer. Select that layer in the <em>layers</em> panel.</li>
	<li>Apply a stroke: Right click on the layer, select <em>Blending Options&#8230; </em>then <em>Stroke. </em>Another way to do this: in the file menu, select Layer ►Layer Style ►Stroke&#8230;</li>
	<li>In the <em>Stroke</em> dialog, apply the gradient by selecting <em>Position: Inside</em>, <em>Fill Type: Gradient</em>, and (the most important part) <em>Style: Shape Burst</em>. Choose your own gradient, and adjust the size of the stroke to suit your needs.</li>
</ol>
<h2>In Illustrator</h2>
<img style="margin:20px 0" class="aligncenter size-full wp-image-954" title="illustrator-gradient-path" src="http://pugetworks.com/blog/wp-content/uploads/2012/04/illustrator-gradient-path1.png" alt="" width="580" height="188" />

The process for making these path gradients in Illustrator is more complicated, but also more versatile. It involves making the gradient out of a blend, turning that blend into a brush, and applying the brush to just about anything you want.
<ol>
	<li>Make a blend. The blend will be your gradient, so adjust it accordingly. Also, the width of the blend will become the width of the stroke when you&#8217;re done.</li>
	<li>Select your blend, and drag it into the <em>Brushes </em>palette. When you do, the <em>New Brush</em> dialog pops up.</li>
<ol>
	<li>Select &#8220;Art Brush&#8221; then click OK.</li>
	<li>In the next dialog, make sure &#8220;Stretch to Fit Stroke Length&#8221; is selected, then click OK. A new brush has been created.</li>
</ol>
	<li>Now, whenever you select a stroke you want your gradient applied to, just click the new brush you created and it will be made for you.</li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2012/04/making-gradients-along-a-path-in-photoshop-and-illustrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Skeuomorphic Design and When to Use It</title>
		<link>http://pugetworks.com/blog/2012/04/what-is-skeuomorphic-design-and-when-to-use-it/</link>
		<comments>http://pugetworks.com/blog/2012/04/what-is-skeuomorphic-design-and-when-to-use-it/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 00:48:51 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://pugetworks.com/blog/?p=899</guid>
		<description><![CDATA[Design is full of trends and rebellions against those trends. Some technique, element or outlook becomes fashionable, then a backlash forms seemingly out of nowhere proscribing it. I find it difficult to keep up on trends, and I try to base my process on my own experience rather than the... <a class="more" href="http://pugetworks.com/blog/2012/04/what-is-skeuomorphic-design-and-when-to-use-it/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
.leftImg img,.rightImg img{
    border: 20px solid rgba(0, 0, 0, 0.2);
    margin: 20px 20px 20px 0;}
.leftImg img:hover,.rightImg img:hover{border:20px solid rgba(0,0,0,.4)}
</style>

<p>Design is full of trends and rebellions against those trends. Some technique, element or outlook becomes fashionable, then a backlash forms seemingly out of nowhere proscribing it. I find it difficult to keep up on trends, and I try to base my process on my own experience rather than the mode of the times. It&#8217;s hard enough coming up with the best design for your requirements without ruling anything out <em>ex facie</em> . However, there are some popular design trends that just don&#8217;t suit the needs they&#8217;re commonly applied to, and skeuomorphs are a good example of this.</p>

<h3>What are Skeuomorphs?</h3>
<p><a href="http://en.wikipedia.org/wiki/Skeuomorph">Skeuomorphs</a> are design elements that serve no purpose, but stick around because they used to be useful. Software products that do something analogous to an older physical product often contain skeuomorphs: for example, circular knobs to change the volume in a music player, or pages that have to be flipped in a document reader. You don&#8217;t need to flip knobs or turn pages in a digital world, and it&#8217;s quite a bit of extra effort to implement these special controls.</p>

<p>While cute, these elements transfer the limitations of the analog world to the digital one, where they&#8217;re unnecessary and sometimes even counterproductive.  Don&#8217;t make me turn pages for no reason!</p>

<a class="leftImg" href="http://pugetworks.com/blog/wp-content/uploads/2012/03/photo.png"><img class=" wp-image-921 " title="Skeuomorphic Page Flip in iBooks" src="http://pugetworks.com/blog/wp-content/uploads/2012/03/photo-225x300.png" alt="Skeuomorphic Page Flip in iBooks" width="225" height="300" /></a>

<a class="rightImg" href="http://pugetworks.com/blog/wp-content/uploads/2012/03/photo1.png"><img src="http://pugetworks.com/blog/wp-content/uploads/2012/03/photo1-225x300.png" alt="Skeuomorphic keyboard bumps on iPad" title="Skeuomorphic keyboard bumps on iPad" width="225" height="300" class="size-medium wp-image-922" /></a>

<h3>Why use them?</h3>
<p>So why use them? Apple uses skeuomorphs in apps like iCal, Find My Friends, even on their standard virtual keyboard. They claim these artifacts evoke an emotional response in users and immediately orients them to how to use a product.</p>

<p>While it is usually difficult to argue with Apple&#8217;s design rationale, I&#8217;m suspicious of this argument simply because I see no research to support it, and the history of user interface design provides plenty of anecdotal examples to the contrary<sup>1</sup>.</p>

<p>I suppose the real reason for skeuomorphism on first-party iOS applications is simply that they look really, really cool, and even if they don&#8217;t actually make an application more intuitive to use, they make it more approachable. These elements don&#8217;t contribute to usability, they contribute to marketability. In other words, they help inform you about an app does rather than how to do it.</p>

<p>But I can think of at least one case when the use of skeuomorphism adds genuine value to a user&#8217;s experience: aiding in the transition between a physical process and an analogous digital process.</p>

<p>For example, a fine artist used to blending colors on a palette may not at first understand the discrete &#8221; RGB color picker&#8221; model that is the standard in graphic applications like Photoshop. Instead, they may want to select primary colors (or a set of predefined colors mapping to common paints) and mix them together to get the hue they&#8217;re looking for. This works at first, but it&#8217;s inefficient and unnecessary, and as they become familiar with the application they&#8217;ll probably outgrow it. So, why not let them blend colors together on a palette, but also let them select that color, browse through variations of it (a slightly warmer tone, a slightly brighter one, etc.) and then save the color for later use. In other words, use skeuomorphs to help the user approach the application, but do not limit functionality according to any artificial constraints.</p>

<p>Note that the transition between analog and digital processes could go both ways. You could also use skeuomorphic design to help people on a computer to understand how to use physical tools. For example, on a GPS-enabled phone, you can easily locate North with (or even without) the push of a button. On a manual compass, it&#8217;s slightly more involved &#8212; let the magnetic arrow settle, align directions on the housing to the arrow, and change your orientation relative to the compass. But how about a GPS-enabled application that teaches you how to use a manual compass by retaining the artificial limitations and forcing them into the interface?</p>

<p>I&#8217;m skeptical of the use of skeuomorphic design when it is claimed to benefit the usability of a design. I generally believe skeuomorphs serve a mostly decorative purpose and while that&#8217;s not necessarily an argument against them, form should always follow function rather than dictate it.</p>

<p><sup>1</sup><em>I&#8217;d even wager to guess that the trend towards skeuomorphism is cyclical, rising in prominence as new platforms emerge, and waning as these platforms become more familiar. See for example early desktop computer interfaces, which ultimately resolved into the WIMP model, then early web site designs, from which emerged the standard web site interface we&#8217;re all pretty familiar with. No doubt the standard interface for touch-based mobile applications is still being shaken out.</em></p>]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2012/04/what-is-skeuomorphic-design-and-when-to-use-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minimum touchable area on mobile devices</title>
		<link>http://pugetworks.com/blog/2012/02/minimum-touchable-area-on-mobile-devices/</link>
		<comments>http://pugetworks.com/blog/2012/02/minimum-touchable-area-on-mobile-devices/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 22:44:00 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=712</guid>
		<description><![CDATA[A recent article on Smashing Magazine discussed the challenge of fitting buttons on mobile devices to the size of a user&#8217;s fingertip. It&#8217;s a useful article, and I don&#8217;t take issue with its overall message, but it did remind me of something I&#8217;d been meaning to write about for some... <a class="more" href="http://pugetworks.com/blog/2012/02/minimum-touchable-area-on-mobile-devices/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#phones {
    width: 330px;
    margin:0;
}
#phones td:nth-child(2) {
    width: 50px;
}
#phones th{padding-left:5px;}

#phoneList {
    float: left;
    width: 200px;
    margin:0px 20px 20px 0;
}

#phoneList h3 {
    font-size: 123.1%;
    line-height: 1.3;
}

#phoneList ul {
    margin: 0;
    padding: 0;
}
#phoneList span {
    background: none repeat scroll 0 0 rgba(255, 255, 255, 0.4);
    border-radius: 100px 100px 100px 100px;
    display: block;
    float: left;
    margin-right: 10px;
    text-align: center;
    font-size: 143%;
}
#phoneList li {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.1);
    clear: left;
    float: left;
    list-style: none outside none;
    margin-bottom: 3px;
    padding: 10px;
    text-align: right;
    width: 180px !important;
}
.htcInspire span {
    height: 60px;
    width: 60px;
    line-height: 60px;
}
.htcInspire {
}
.googleNexusOne span {
    height: 71px;
    width: 71px;
    line-height: 71px;
}
.googleNexusOne {
}
.iPhone3G span {
    height: 45px;
    width: 45px;
    line-height: 45px;
}
.iPhone3G {
}
.iPhone4G span {
    height: 91px;
    width: 91px;
    line-height: 91px;
}
.iPhone4G {
}
.iPad span {
    height: 37px;
    width: 37px;
    line-height: 37px;
}
.iPad {
}
.motorolaDroid span {
    height: 74px;
    width: 74px;
    line-height: 74px;
}
.motorolaDroid {
}
.samsungInfuse span {
    height: 58px;
    width: 58px;
    line-height: 58px;
}
.samsungInfuse {
}
.samsungGalaxyS span {
    height: 65px;
    width: 65px;
    line-height: 65px;
}
#phones td {
    padding: 11px 8px;
}
.samsungGalaxyS {
}
#phones tr:nth-child(odd) {
    background: rgba(0,0,0,.15);
}
</style>

<!--
	$("#ppi").keyup(function(){
		var ppi = $('#ppi').val();
		if((parseFloat(ppi) == parseInt(ppi)) &#038;&#038; !isNaN(ppi)){
			var squareSize = Math.round((ppi / 1.414213562) / 2.54);  
			$("#output").html(squareSize + 'px');
		} else if(ppi == ''"){
			$("#output").html('');
		} else {
			$("#output").html("Please enter a number")
		}
	});
-->
	<div id="ppi-post">

<p>A recent article on Smashing Magazine discussed the challenge of <a href="http://uxdesign.smashingmagazine.com/2012/02/21/finger-friendly-design-ideal-mobile-touchscreen-target-sizes/">fitting buttons on mobile devices to the size of a user&#8217;s fingertip</a>. It&#8217;s a useful article, and I don&#8217;t take issue with its overall message, but it did remind me of something I&#8217;d been meaning to write about for some time.</p>

<p>A lot of guides for mobile app design quote the minimum touchable area (which you may read as &#8220;button size&#8221;) as 44px. This number comes from the original iPhone Human Interface Guidelines document from the 1st generation iPhone. The Smashing Magazine article also quotes sizes given by Microsoft and Nokia in their own guidelines (34px and 28px, respectively), then goes on to dismiss them as &#8220;not consistent with each other, nor &#8230; consistent with the actual size of the human finger.&#8221;</p>

<p>The thing is, listing different minimum pixel sizes doesn&#8217;t necessarily mean the guidelines are inconsistent. <em>On different devices, the minimum touchable area will be different, and should be</em>. When deciding on a minimal button size, the important thing to consider is the pixel density of the device&#8217;s screen in Dots Per Inch (DPI) or Pixels Per Inch (PPI), which are the same thing as far as I&#8217;m aware. The pixel density is the number of pixels over a linear diagonal inch (yes, on the diagonal, rather than on a side). So, on devices that crowd more pixels into an inch, the density will be higher, and the fingertip will touch more pixels when it presses the screen.</p>

<p>For example, older iPhones have a minimum touchable area of 44px, and a resolution of 320&#215;480 pixels. iPhones with the Retina display have twice the resolution (640&#215;960 pixels) but the same physical screen size, thus they have twice the pixel density. As you would expect, the minimum touchable area on Retina displays is twice that of older displays, or 88px.</p>

<p>The message here is that if you develop applications for multiple mobile devices (as many of us increasingly do), you can&#8217;t just memorize a single &#8220;best&#8221; button size and use that for every screen. You&#8217;ve got to base it off the density of the screen in order to keep it consistent with what actually matters, which is the size of the fingertip.</p>

<h2>How to figure out the minimum button size on any mobile device</h2>

<p>We assume an average fingertip of 1cm. This is a the width of a hefty finger, or about the size of an <a href="http://hcil.cs.umd.edu/trs/2006-11/2006-11.htm">average thumb</a>.</p>

<p>If you know the resolution (in DPI or PPI) of your screen (which should be available on the manufacturer&#8217;s website) you can easily estimate the size of that fingertip on your screen with this equation:</p>
<pre class="brush: jscript; title: ; notranslate">
Radius of minimum touchable pixel area = (PPI / 1.414) / 2.54)
</pre>

<p>If you don&#8217;t know the DPI/PPI of your device, <a href="http://en.wikipedia.org/wiki/Pixel_density#Calculation_of_monitor_PPI">you can easily figure it</a> out using the Pythagorean Theorum.</p>

<p>I took the liberty of figuring out the minimum button size for a number of popular mobile devices. This list is already a bit out of date, and will certainly be even moreso by the time you&#8217;re reading this, but the methodology should still apply even in your futuristic era, dear reader.</p>

<h3>Common fingertip sizes on different devices (in px)</h3>
<div id="phoneList" class="mBottom20">
	<ul>
		<li class="iPhone4G"><span>45</span>iPhone 4G</li>
		<li class="motorolaDroid"><span>74</span>Motorola Droid</li>
		<li class="googleNexusOne"><span>71</span>Google Nexus One</li>
		<li class="samsungGalaxyS"><span>65</span>Samsung Galaxy S</li>
		<li class="htcInspire"><span>60</span>HTC Inspire</li>
		<li class="samsungInfuse"><span>58</span>Samsung Infuse</li>
		<li class="iPhone3G"><span>45</span>iPhone 3G</li>
		<li class="iPad"><span>37</span>iPad</li>
	</ul>
</div>

<table id="phones" class="mBottom20">
<thead>
<th>Phone</th>
<th>DPI</th>
<th>Size of
</thead>
	<tr><td>HTC Arrive</td><td>259 </td><td>72px</td></tr>
	<tr><td>HTC Desire</td><td>252 </td><td>70px x 70px</td></tr>
	<tr><td>HTC Evo</td><td>217 </td><td>60px x 60px</td></tr>
	<tr><td>HTC Inspire</td><td>216 </td><td>60px x 60px</td></tr>
	<tr><td>HTC Sensation</td><td>256 </td><td>71px x 71px</td></tr>
	<tr><td>HTC Thunderbolt</td><td>217 </td><td>60px x 60px</td></tr>
	<tr><td>Google Nexus One</td><td>254 </td><td>71px x 71px</td></tr>
	<tr><td>iPhone 3G </td><td>163 </td><td>45px x 45px</td></tr>
	<tr><td>iPhone 4G</td><td>326 </td><td>91px x 91px</td></tr>
	<tr><td>iPad</td><td>132 </td><td>37px x 37px</td></tr>
	<tr><td>Motorola Defy</td><td>264 </td><td>73px x 73px</td></tr>
	<tr><td>Motorola Droid</td><td>265 </td><td>74px x 74px</td></tr>
	<tr><td>Motorola Droid Incredible</td><td>252 </td><td>70px x 70px</td></tr>
	<tr><td>Samsung Infuse</td><td>207 </td><td>58px x 58px</td></tr>
	<tr><td>Samsung Galaxy S</td><td>233 </td><td>65px x 65px</td></tr>
	<tr><td>Samsung Galaxy S II</td><td>219 </td><td>61px x 61px</td></tr>
</table>

<div class="cb"></div>
</div>

<p>

<!-- Hey, if you can read this, this code is for a widget that will calculate finger size on any DPI. I'm still working on how to get it to work properly in a WordPress post. Take this code if you want it, otherwise ignore my mess - Adam 
	$("#ppi").keyup(function(){ // You should make a text input called 'ppi' first.
		var ppi = $('#ppi').val();
		if((parseFloat(ppi) == parseInt(ppi)) &#038;&#038; !isNaN(ppi)){
			var squareSize = Math.round((ppi / 1.414213562) / 2.54);  
			$("#output").html(squareSize + 'px');
		} else if(ppi == ''"){
			$("#output").html('');
		} else {
			$("#output").html("Please enter a number")
		}
	});
-->
]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2012/02/minimum-touchable-area-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django Tips: FileField and uploadto</title>
		<link>http://pugetworks.com/blog/2012/02/django-tips-filefield-and-uploadto/</link>
		<comments>http://pugetworks.com/blog/2012/02/django-tips-filefield-and-uploadto/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 23:18:14 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://pugetworks.com/blog/?p=860</guid>
		<description><![CDATA[The following tip, should help in understanding how the FileField handles the path and url for a file referenced in the database. The Model Object The FileField model in Django is used to store files in Django. The file itself is not stored in the database but on the filesystem,... <a class="more" href="http://pugetworks.com/blog/2012/02/django-tips-filefield-and-uploadto/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[The following tip, should help in understanding how the FileField handles the path and url for a file referenced in the database.

<h2>The Model Object</h2>
The FileField model in Django is used to store files in Django. The file itself is not stored in the database but on the filesystem, with a reference to the file location saved in the database. Once saved, the file can be easily accessed with 2 functions:
 <ul>
 	<li>document.path &#8211; returns the absolute location to the file in relation to the filesystem</li>
	<li>document.url &#8211; returns the absolute location to the file to be used in a web browser</li>
</ul>

<h2>Settings</h2>
The Django docs reference 2 settings variables that should be set:
<ul>
<li>MEDIA_ROOT &#8211; <i>Absolute path to the directory that holds media&#8230;</i></li>
<li>MEDIA_URL &#8211; <i>URL that handles the media served from MEDIA_ROOT</i></li>
</ul>

Now, I don&#8217;t like to expose my filesystem structure to the internet, so I set <i>MEDIA_URL</i> to a specific directory. Then use apache (or a dedicated url configuration) to serve the files. For example:
<pre class="brush: python; title: ; notranslate">MEDIA_URL='/media'</pre>

I also like to isolate my media so that there can be no conflicts, so I use 2 settings variable to store the media root:
<pre class="brush: python; title: ; notranslate">MEDIA_ROOT = os.path.join( os.path.dirname(__file__), 'media/').replace('\\','/')
MODEL_DOC_ROOT = os.path.join( 'model', 'documents' ).replace('\\','/')</pre>

<i>The url configuration is:</i>
    <pre class="brush: python; title: ; notranslate">( r'^model/documents/(?P&lt;path&gt;.*)$', 'django.views.static.serve',
        { 'document_root': '%s/%s' % ( settings.MEDIA_ROOT, settings.MODEL_DOC_ROOT ) } ),</pre>

<h2>uploadto</h2>
<h3>Default</h3>
The Django docs for FileField say:
<blockquote><i>A local filesystem path that will be appended to your <i>MEDIA_ROOT</i> setting to determine the value of the url attribute.</i></blockquote>
This is important, because if you include the complete path, then <i>document.path</i> will be correct, but <i>document.url</i> will have the complete filesystem path in the url&#8230;ack!<br />

<h3>As a function</h3>
The Django docs also say:
<blockquote><i>This may also be a callable, such as a function, which will be called to obtain the upload path, including the filename. This callable must be able to accept two arguments, and return a Unix-style path (with forward slashes) to be passed along to the storage system.</i></blockquote>

If I expect many files to be uploaded, it is cleaner to split them into subdirectories.
My function turned out like the following:
<pre class="brush: python; title: ; notranslate">
def doc_location( instance, filename ):
    root_path = path.join( settings.MODEL_DOC_ROOT, instance.name.slug ).replace('\\','/')
    full_path = settings.MEDIA_ROOT + path.join( '/', root_path ).replace('\\','/')
    
    if not path.exists( full_path ):
        mkdir( full_path )

    return path.join( root_path, filename ).replace('\\','/')
</pre>

<h2>Obscure Pitfalls</h2>
The above works quite well&#8230;. but what the docs don&#8217;t say is:
<ul>
<li>If <i>MODEL_DOC_ROOT</i> starts with &#8216;/&#8217; then <em>MEDIA_ROOT</em> is NOT appended as indicated the docs!</li>
<li>In the <i>doc_location</i> function, if <i>settings.MEDIA_ROOT</i> is included in <i>path.join</i> it doesn&#8217;t get added!?</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2012/02/django-tips-filefield-and-uploadto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Thread Handling</title>
		<link>http://pugetworks.com/blog/2011/10/android-thread-handling/</link>
		<comments>http://pugetworks.com/blog/2011/10/android-thread-handling/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 14:39:01 +0000</pubDate>
		<dc:creator>Paulin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=815</guid>
		<description><![CDATA[Almost every Android application has two parts.  On one side is the user interface that the user controls and views the information with.  On the other side is a network component for talking to a server or updating its information.  When you write an Android application you are always given... <a class="more" href="http://pugetworks.com/blog/2011/10/android-thread-handling/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[Almost every Android application has two parts.  On one side is the user interface that the user controls and views the information with.  On the other side is a network component for talking to a server or updating its information.  When you write an Android application you are always given control of the thread that lets you change the user interface.  But, this bit of software processing is only for updating the user interface.  Sure you can use it to make network calls but, this is a big &#8220;no no&#8221;.  The problem is that the Android application needs to be able to use the UI Thread to make updates, so if you send it off on an errand to retrieve some data from a server, then the application has no way to update the controls.  So essentially the party stops and waits until the network call is complete.  From a users perspective this is awful.  They pushed a button, and now&#8230; nothing.  Then suddenly everything is back.
</p>
In my experience its find to start creating the application this way but, before you can release it you will need to split the network calls into a separate thread.
</p>
This article is about doing just that.
</p>
<h3>Step 1.  Isolate your network calls with a thread call.</h3>
Its assumed at this point that you already have an Android app that is making network calls.  So first go through your code and surround all of them with a block of code that looks like this.
</p>
Essentially change this


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">makeNetworkCall<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



</p>
into this


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Thread</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Runnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      makeNetworkCall<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



</p>
When you do this, what you are is spinning off a new thread to run out and do the waiting work.  The new problem is, what happens when this new thread is done?
</p>
<h3>Step 2. The Handler</h3>
Behind the scenes is a Java class call the <a href="http://developer.android.com/reference/android/os/Handler.html">Handler</a>.
</p>
This little class can be used build a sort of callback in your main UI Thread so the new threads will have some way to notify it when they are done.  To use it add this bit of code to your Activity class.
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> Handler handler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleMessage<span style="color: #009900;">&#40;</span>Message msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      updateTheUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//This method is for whatever needs to happen after the network call is complete</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>



</p>
Now anytime you want to actually make a call back to your UI Thread you will simply have to make this call.
</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">handler.<span style="color: #006633;">sendEmptyMessage</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



That is the basics but, it leaves a big question.  What if I want to send more information than just update?
</p>
<h3>Step 3. Smarter Messages</h3>
If you want to send a better message than just update, you need to figure out how many types of messages you want and what they should be.  They have to be integer values so it would make the most sense to create a bunch of constants in the class to represent these calls.  For instance&#8230;


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> REDRAW <span style="color: #339933;">=</span> <span style="color: #cc66cc;">42</span><span style="color: #339933;">;</span></pre></div></div>



</p>
You will then need to modify your handler to look for this particular code.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> Handler handler <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleMessage<span style="color: #009900;">&#40;</span>Message msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">what</span> <span style="color: #339933;">==</span> REDRAW<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         updateTheUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//This method is for whatever needs to happen after the network call is         	</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>



</p>
Finally, to call this special method you will need to modify your handler calling code to look like this.


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">handler.<span style="color: #006633;">sendEmptyMessage</span><span style="color: #009900;">&#40;</span>REDRAW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



</p>
<h3>In conclusion</h3>
Use a handler when you want to spin off new threads too keep the UI Experience responsive.  If you have lots of threads going, then create some custom callback messages.  This will make all of your apps feel instantly responsive.]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2011/10/android-thread-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part One: Compass and Sass</title>
		<link>http://pugetworks.com/blog/2011/10/part-one-compass-and-sass/</link>
		<comments>http://pugetworks.com/blog/2011/10/part-one-compass-and-sass/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 17:39:13 +0000</pubDate>
		<dc:creator>Jolovic</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=747</guid>
		<description><![CDATA[Problem As a Ruby on Rails developer, you have a lots of choices for creating visually wonderful websites. And with the introduction of Sass in Rails 3.1, CSS has become easier to code then ever. But, say, your Rails app grows and with it so does Sass and CSS. With... <a class="more" href="http://pugetworks.com/blog/2011/10/part-one-compass-and-sass/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>As a Ruby on Rails developer, you have a lots of choices for creating visually wonderful websites. And with the introduction of Sass in Rails 3.1, CSS has become easier to code then ever. But, say, your Rails app grows and with it so does Sass and CSS. With such growth, your files expand. You begin distributing Sass and CSS code to different files, files such as header, footer, content, but, all this becomes a messy business. Get the picture? What if you could consolidate each file to, say, just a file or two? Well, with Compass and Sass, you can!
</p>
<h4>This article deals with the introduction and installation of Compass and Sass and their basic features.</h4>
<h1>Solution with Compass and Sass</h1>
<p>Compass is a generic-framework that heavily uses Sass to generate CSS output. Sass, on the other hand, is a metalanguage that implements programming functions such as “nested rules, variables, mixins, selector inheritance, and more”. Compass and Sass are tightly coupled and are marriage in heaven for web designers: the two eliminate redundancy if you were to code everything in CSS. And, if you are currently implementing CSS3, then you’ll love Compass and Sass. Compass has many great CSS3 functions, such as box-shadow, that saves you so much time typing vendor prefixes.
</p>
<h1>Compass and Sass Features</h1>
<ol>
	<li>Top Level
<ol>
	<li>CSS Rest</li>
	<li>Basic Element Styling</li>
	<li>Basic Structural Rules</li>
	<li>Rules for Browser Inconsistencies</li>
</ol>
</li>
	<li>Form and Table Styling</li>
	<li>Typography</li>
	<li>CSS Grid</li>
</ol>
<h1>Installing</h1>
<h3>For this example, I am using iMac and its Terminal to generate necessary files and move around file structure. My Ruby and Rails are run on RVM.</h3>
<p>With the RVM installed on your computer (and I hope you have RVM installed on your system, if not, take a look at <a href="http://beginrescueend.com/">the RVM site </a>for the installation guid), initiate the following command;</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">gem install compass</pre></div></div>



<p>However if you are not using RVM, initiate the following command;</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">sudo gem install compass</pre></div></div>



<p>Now make sure compass is installed:</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">compass version</pre></div></div>



<p>If all went well, you should see compass&#8217;s version number as well as its credits.</p>
<h1>Creating a Compass Project</h1>
<p>To create a Compass project, it&#8217;s very simple.</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">compass create /path/to/project --using blueprint</pre></div></div>



<p>Notice at the end of the command, I am using the option flag <code>--using</code> and <code>blueprint</code> as the CSS framework for the project. I could have left out both of these and would have ended with the project itself. But I like blueprint, so I am going to leave it the way it is. Oh, and if you wish to have something other then the blueprint, you can. Just make sure you have the right type of framework compatible with Compass. <a href="https://github.com/chriseppstein/compass/wiki/compass-plugins">Here are a few for your creative juices</a>. However, it isn&#8217;t necessary to have any frameworks. Compass has it&#8217;s own CSS library too!
</p>
<p>
This command also spits out initial file structure Compass has created for you, and it also tell you to place the last part of this message, which is the stylesheets location, in your index.html page. Do that and you are ready to move on to a final step before getting into the application itself. Here is my stylesheets code:
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">   href=&quot;/stylesheets/screen.css&quot; media=&quot;screen, projection&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;
   href=&quot;/stylesheets/print.css&quot; media=&quot;print&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;
   href=&quot;/stylesheets/ie.css&quot; media=&quot;screen, projection&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;</pre></div></div>




<p>
During this final step is make sure that Compass watches for any changes in your files. In this case, files that end with .scss or .sass. These files will then be converted to CSS (generated into CSS) as the final output! Wow. That&#8217;s going to be a lot of CSS! Yes, but it will be a compressed CSS that&#8217;s much faster for browser rendering. To do so, issue the following:
</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">compass watch /path/to/project</pre></div></div>



<p>That&#8217;s it! From here onwards, all we need to do is get into one of those .sass or .scss files and start coding.</p>
<h1>Next Article Coming Soon</h1>]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2011/10/part-one-compass-and-sass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Application Pills</title>
		<link>http://pugetworks.com/blog/2011/09/software-application-pills/</link>
		<comments>http://pugetworks.com/blog/2011/09/software-application-pills/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 21:13:39 +0000</pubDate>
		<dc:creator>Paulin</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=823</guid>
		<description><![CDATA[A friend of mine once pointed out that when you are creating software, a very good way to look at it is &#8220;how dependent will your users be on your software?&#8221;.  Then in his usual clever way, he related it to pills.  Well, not pills so much but, pill like... <a class="more" href="http://pugetworks.com/blog/2011/09/software-application-pills/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<div>A friend of mine once pointed out that when you are creating software, a very good way to look at it is &#8220;how dependent will your users be on your software?&#8221;.  Then in his usual clever way, he related it to pills.  Well, not pills so much but, pill like items.   In this regards how do you want to package the software for easy consumption?  How often do you want people to use it?  How hard do you want it to be for your clients to walk away?
</p>
It turns out that his metaphor splits nicely into 4 categories; candy, vitamins, medicine and heart meds.
<h3 >Candy</h3>
At the candy level you are talking about fun software.  You are looking to have a huge base of people that might try this out on an impulse.  It&#8217;s right there at the check out stand.  You don’t really need it, you could walk away.  But, somehow candy keeps on selling.  It&#8217;s a treat, it&#8217;s fun, it&#8217;s colorful, playful, and something new.  There are lots of apps like this.  The whole game industry is built around candy apps.  In no way, shape, or form do I need to be playing; minecraft, angry birds, or any of these other huge distractions.  But, it is great amusement and enjoyable.  Thus&#8230; candy.
</p>
Do notice that the price point and volume have to reflect this.  I don’t buy designer candy.  I’m not even sure if that exist.  Candy is cheap, but it makes up for that in volume.   Also think about the life cycle of your relationship with candy.  It&#8217;s short, maybe you come back for that brand of candy but, it isn’t something you half to have.
</p>
<h3 >Vitamins</h3>
Next come the vitamins.  These are like nuggets of hope and prevention all wrapped into one easy to consume package.  At the root, why do you take vitamins?  It&#8217;s a type of insurance right?  It keeps you from getting sick, or helps you get stronger.  These are your anti-virus software, your backup software.  They are a little investment of time now for a lot less problems later.
</p>
Now also think about the volume of these sales.  People take vitamins regularly.  Well&#8230; sort of. They don’t have to take them so sometimes you skip, or you come back to it later.  But, the point is to do something regularly.  It is more expensive than candy but, you don’t eat a bunch of vitamins like you would candy.  The same goes for software.  You only need a couple of these apps.  You probably don’t try out anti-virus software packages like you would games.  You pick one and stick with it.  Same sort of mentality.
</p>
<h3 >Medicine</h3>
You are even more dependent on medicines than vitamins.  You might choose to not take a vitamin but you feel foolish not taking your medicine.  There is software like this as well.  Its core to your business.  Software that keeps things moving.  You could get rid of it but, it would be a bad idea and you would need to find an equivalent.  This is software you don’t want to ignore.
</p>
<h3>Heart Meds</h3>
Finally there are heart meds.  These are a type of medicine you have to take every day or you might die.  That makes them very important to you.  These are expensive, you plan around them, you budget for them, you make sure that at all cost this is available.  Some software is like this as well.  In many industries there is that one vendor or programmer that the entire venture hinges on.  This is what is most important to you.  This isn’t the same as an off the shelf equivalent, but more like a custom software package that is integrated into the company.  The point is dependency.  With a heart med type software your users must have it.  Usually these are older pieces of software that are well wedged into the system. Think about salesforce applications or business process applications.
</p>
<h3>Conclusion</h3>
So when you are thinking about creating software, it might help to think about how dependent you want your users to be.  Do you want the high volume transient sales of candy, or the low volume pricey heart meds.  You need to price and plan for this accordingly.  People don’t buy super expensive candy.  So why would you make a game to sell for $100?
</p>
Also consider that with this comes the development cost and the cost to get these introduced to new customers.  For instance, I bet it is much easier to make and sell candy than it is to sell designer drugs.  It&#8217;s just a hunch.
]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2011/09/software-application-pills/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMWare and Ubuntu High Load issues</title>
		<link>http://pugetworks.com/blog/2011/07/vmware-and-ubuntu-high-load-issues/</link>
		<comments>http://pugetworks.com/blog/2011/07/vmware-and-ubuntu-high-load-issues/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 05:46:18 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[I/O]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=638</guid>
		<description><![CDATA[Intro Recently I was involved in moving a large website from Slicehost to an ASP (Application Service Provider) closer to the client. Everything went well, until DNS was updated. Load on the server was high all the time and would increase to a point where web pages wouldn&#8217;t be served... <a class="more" href="http://pugetworks.com/blog/2011/07/vmware-and-ubuntu-high-load-issues/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<h1>Intro</h1>
<p>Recently I was involved in moving a large website from Slicehost to an ASP (Application Service Provider) closer to the client. Everything went well, until DNS was updated. Load on the server was high all the time and would increase to a point where web pages wouldn&#8217;t be served any more.</p>

<h1>Comparison</h1>
<p>Slicehost and the ASP provided essentially the same server setup, as per our request:
<table width="300px" border="1px">
<tbody>
<tr>
<td width="30%" align="center"></td>
<td width="30%" align="center">Slicehost</td>
<td width="30%" align="center">ASP</td>
</tr>
<tr>
<td align="center"># CPUs</td>
<td align="center">4</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">Ram</td>
<td align="center">3 gig</td>
<td align="center">3 gig</td>
</tr>
<tr>
<td align="center">OS</td>
<td align="center">Ubuntu Lucid</td>
<td align="center">Debian 6.0</td>
</tr>
<tr>
<td align="center">VM</td>
<td align="center">Xen</td>
<td align="center">VMWare ESX</td>
</tr>
</tbody>
</table></p>
<p>The website contains over 50 gig of images with sizes up to 1.5 meg. All the pages are dynamically created with PHP connected to mySQL. There is a lightly used Ruby app also running via mod_passenger. On an hourly basis a php script is run to fetch an XML file which is then parsed and imported into the database. None of this is very complicated, and there are numerous points of optimization that could be done.</p>

<h1>Statistics</h1>
<p>After the move, the server load would range between 6 and 25. Once the server hit 15, the websites would become start to become unavailable. But &#8216;top&#8217; was only showing around 20% overall CPU usage!</p>

<p>So I started toying with the standard stat programs:

<p><font size="-1"><pre># mpstat 1 20
Linux 2.6.32-5-686 (pmm) 	07/13/2011 	_i686_	(4 CPU)
01:21:45 PM  CPU  %usr %nice  %sys %iowait %irq %soft %steal %guest %idle
01:21:46 PM  all  0.27  0.00  0.53  72.27  0.00  0.00  0.00   0.00  26.93
01:21:47 PM  all  0.73  0.00  0.49  72.37  0.00  0.00  0.00   0.00  26.41
01:21:48 PM  all  4.49  0.00  0.47  31.68  0.00  0.00  0.00   0.00  63.36
01:21:49 PM  all  8.15  0.00  0.99  42.22  0.00  0.25  0.00   0.00  48.40
01:21:50 PM  all 11.86  0.00  0.77  41.49  0.00  0.26  0.00   0.00  45.62
01:21:51 PM  all  7.07  0.00  0.25  38.38  0.00  0.00  0.00   0.00  54.29
01:21:52 PM  all  6.93  0.00  0.80  51.20  0.00  0.00  0.00   0.00  41.07
01:21:53 PM  all  6.83  0.00  0.68  35.54  0.00  0.00  0.00   0.00  56.95
Average:     all  8.94  0.00  0.57  41.86  0.01  0.04  0.00   0.00  48.57

#w
13:22:05 up 48 days, 12:43,  2 users,  load average: 12.00, 11.50, 10.10</pre></font></p>
<p>CPU %usage from mpstat matched what top was indicating, but the %iowait was very high. To me, this means the processors are waiting for data to work on.</p>
</br>

<p><font size="-4"><pre># iostat <i>(edited)</i>
Device: rrqm/s    wrqm/s     r/s       w/s     rsec/s    wsec/s  avgrq-sz  avgqu-sz     await     svctm     %util
sda      0.00     25.00      0.00     10.00      0.00    280.00     28.00      0.04      4.40      1.20      1.20
sda      0.00      0.00      1.00      0.00      8.00      0.00      8.00      0.00      4.00      4.00      0.40
sda      0.00     20.00      3.00      9.00     72.00    232.00     25.33      0.06      5.33      2.00      2.40
sda      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
sda      0.00      0.00      1.00      0.00      8.00      0.00      8.00      0.01      8.00      8.00      0.80
--- import starts ---
sda      1.00   1216.00     11.00    135.00    984.00  10808.00     80.77     20.06    137.37      2.93     42.80
sda      0.00    137.00     65.00    973.00   1168.00   8880.00      9.68      0.95      0.92      0.76     79.20
sda      0.00    148.00     81.00   1414.00    704.00  12496.00      8.83      0.93      0.62      0.55     82.00
sda      1.00    165.00     42.00   1468.00    432.00  13064.00      8.94      1.04      0.69      0.55     83.20
sda      0.00    160.00     24.00   1125.00    192.00  13136.00     11.60      0.84      0.73      0.69     78.80
sda      0.00    148.00     56.00   1571.00    448.00  13752.00      8.73      0.71      0.44      0.44     70.80
sda      0.00    172.00     43.00   1327.00    376.00  11992.00      9.03      0.79      0.58      0.56     76.80
sda      0.00    142.00     55.00   1306.00    464.00  11584.00      8.85      0.82      0.61      0.53     72.00
</pre></font></p>

<p>Wow! There appears to be a lot of disk I/O going on here. What it really means, I&#8217;m not sure.</p>

<p><font size="-1"><pre># iotop <i>(recreated since I don't have a historical version)</i>
Total DISK READ: 267.11 K/s | Total DISK WRITE: 0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                           
20876 be/4 mysql       0.00 B/s   15.71 K/s  0.00 %  68.00 % mysqld --basedir=/usr --da~ld/mysqld.sock --port=3306
28051 be/4 www-data  129.63 K/s    0.00 B/s  0.00 %  40.44 % apache2 -k start
28061 be/4 www-data  137.48 K/s    0.00 B/s  0.00 %  31.12 % apache2 -k start
28059 be/4 www-data    0.00 B/s    3.93 K/s  0.00 %  23.00 % apache2 -k start
</pre></font></p>

<p>Once again, lots of I/O going on. It is interesting that apache requires so much I/O for reading. I expected mySQL to require much more I/O since it is reading AND writing to the database.</p>

<p><font size="-1"><pre># apache2ctl status <i>(edited)</i>
                       Apache Server Status for localhost
   --------------------------------------------------------------------------
   CPU Usage: u319.69 s97.34 cu.05 cs0 - 4.88% CPU load
   36 requests currently being processed, 14 idle workers

 _WWC_W_W_WWWW_WLW_CWCW_W_WW______WC.............................
 ................................................................
 ................................................................
 ................................................................

   Scoreboard Key:
   "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
   "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
   "C" Closing connection, "L" Logging, "G" Gracefully finishing,
   "I" Idle cleanup of worker, "." Open slot with no current process
</pre></font></p>

<p>Apache doesn&#8217;t think it is using much load, but there are a lot of open connections.</p>

<p>Watching &#8216;top&#8217; over time, I noted that the import process was consuming 99% of one of the 4 cpus. The other cpus were generally 98% idle, but apache requests would occasionally use between 5-12% of each cpu. I knew the import acted this way beforehand, and it wasn&#8217;t a problem on the Slicehost server. So that wasn&#8217;t the root of the problem.</p>

<h1>Actions Taken</h1>
<h2>Apache</h2>
<p>I turned &#8216;KeepAlive off&#8217; thinking each &#8216;client browser&#8217; was hogging an apache process, and eventually all the available forked processes would become blocked. My thinking was that the high I/O was being caused because the images couldn&#8217;t be read from disk and passed out fast enough. So open apache processes were constantly waiting for data to be sent.</p>

<p>I set a specific number of apache processes to run according to the available memory left over from mySQL. This has the effect that once memory is assigned to the apache forked process it doesn&#8217;t go away. I also set the number of Ruby threads to a very low number to also help control memory usage.</p>

<p>These changes gave a little breathing room when load increased above 15, but the problem was by no means solved.</p>

<h2>mySQL</h2>
<p>I tweaked mySQL to better utilize all the remaining memory, thinking the import process was making mySQL work harder than the default settings could handle. I switched the db engine from myisam to innodb. That appeared to make the webpages appear faster, but the import was taking 20% longer!</p>

<p>I ran some benchmark tests that I found on the document titled <a href="http://www.vmware.com/resources/techresources/10007">Virtualization for MySQL on VMware</a></p>

<p>This document uses sysbench to run a test using mySQL and a temporary database. I didn&#8217;t delve into the details, but wanted to see a rudimentary comparison of the engines and how the test would affect server load.</p>

<p>An example command-line usage:
<pre># ./sysbench  
--num-threads=4  
--max-time=900  
--max-requests=50000  
--test=oltp  
--mysql-user=root  
–mysql-host=localhost 
--mysql-port=3306  
--mysql-table-engine=innodb  
--oltp-test-mode=complex –oltp-table-size=8000000 run > 
MYRESULTS.txt </pre></p>

<p>I tested myisam and innodb. The test results were interesting by themselves. When I ran the tests, each of which took 5 minutes, the load was around 2-4, but the load did NOT increase while the tests were running!</p>

<p>Even though the tests indicated that innodb is faster by almost a factor of 2, it was slowing down the import process, so we switched back to myisam.</p>

<h2>System</h2>
<p>Someone pointed out that a 32-bit OS was installed. Ugh, not much can be done about that, and I don&#8217;t believe it would cause problems of this proportion.</p>

<p>Then someone found the following <a href="http://forums.cpanel.net/f5/extreme-load-peaks-vmware-server-158233.html">Article</a> that suggests changing the IO Scheduler from cfq to noop. Huh?</p>

<p>It turns out to be very easy. All you have to do is run the following command:
<pre># echo noop > /sys/block/sda/queue/scheduler</pre></p>

<p>And&#8230; load has stabilized and been where we expect it to be.</p>

<p>To make this persist after a reboot in Debian, just modify the &#8216;GRUB_CMDLINE_LINUX&#8217; line in /etc/default/grub.cfg to be:
<p><pre>GRUB_CMDLINE_LINUX="elevator=noop"</pre></p>

Then run:
<pre># update-grub</pre></p>

<p>To make this persist after a reboot with RedHat/CentOS just add &#8220;elevator=noop&#8221; to the end of your kernel line in /boot/grub/menu.lst:
<p><pre>title CentOS (2.6.18-238.12.1.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-238.12.1.el5 dom0_mem=256M elevator=noop
        module /vmlinuz-2.6.18-238.12.1.el5xen ro root=/dev/VolGroup00/LogVol00
        module /initrd-2.6.18-238.12.1.el5xen.img</pre></p>

<h1>Resolution</h1>
<p>It turns out the OS has a scheduler that manages low level I/O operations. The default scheduler, Completely Fair Queuing (CFQ), tries to distribute the available I/O bandwidth equally among all I/O requests. This is great if all those requests are being sent to one piece of hardware in the local machine that handles all I/O. In our case this server is using a Network Appliance connected via FiberChannel, which should be fast enough to handle anything we throw at it. I didn&#8217;t find this out until late into the troubleshooting phase.</p>

<p>The NOOP scheduler assumes whatever data is sent to the I/O device will be handled by that device in the most efficient manner. Most of the links I&#8217;ve found reference NOOP with SSD drives, but it also makes complete sense once you factor in our particular setup, because the Network Appliance is much faster than any local drive could be.</p>

<h1>Conclusion</h1>
<p>The statistics pointed to an I/O issue, and that was in fact the root of the problem. As for knowing about such a setting, I can only say that is something that you just learn from experience. In the troubleshooting process, we also found other things that needed be tweaked and pointed out things to consider as this site grows.</p>

]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2011/07/vmware-and-ubuntu-high-load-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s better for web design, Photoshop or Illustrator?</title>
		<link>http://pugetworks.com/blog/2011/07/whats-better-for-web-design-photoshop-or-illustrator/</link>
		<comments>http://pugetworks.com/blog/2011/07/whats-better-for-web-design-photoshop-or-illustrator/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 20:20:37 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://pugetworks.com/?p=631</guid>
		<description><![CDATA[A lot of people ask whether Photoshop is better than Illustrator for web design. This is really a misleading question, because they&#8217;re both useful in different ways. Personally, I use them both, usually drawing shapes in Illustrator and then sending them to Photoshop to be colored and textured. It&#8217;s a... <a class="more" href="http://pugetworks.com/blog/2011/07/whats-better-for-web-design-photoshop-or-illustrator/"> read the rest of the article</a>]]></description>
			<content:encoded><![CDATA[<p>A lot of people ask whether Photoshop is better than Illustrator for web design. This is really a misleading question, because they&#8217;re both useful in different ways. Personally, I use them both, usually drawing shapes in Illustrator and then sending them to Photoshop to be colored and textured. </p>

<p>It&#8217;s a bit like an assembly line for cars, where they&#8217;ve built robots for very specific purposes. There&#8217;s a robot that puts together door panels, and a robot that paints door panels. Which robot is better? Well, neither! It&#8217;s best to use both to make a single product that neither could do as well on its own.</p>

<p>Now, Photoshop is a raster-based drawing program, and Illustrator is vector based. To some degree, each of these programs do a little bit of both, but it&#8217;s still a pretty fundamental difference between them, and one that Adobe has every incentive to sustain in order to keep selling both programs separately. In other words, there&#8217;s probably never going to be a single, clear, unequivocal &#8216;best&#8217; program so long as there&#8217;s a market for two different ones.</p>

<p>To be fair, Photoshop works well enough for vectors, and it does a lot of other raster stuff that Illustrator wasn&#8217;t ever meant to do. It&#8217;s got the basic components; a pen tool that works pretty much the way it should, and a direct selection tool that behaves a lot like the one in Illustrator. If you HAD to, you could certainly get away with only using Photoshop, and skipping Illustrator altogether. Many designers do.</p>

<p>However, if you have access to both, I think it&#8217;s worth it to include Illustrator in your design workflow in many cases. Particularly when you need to draw complicated polygonal shapes and then manipulate the heck out of them.</p>

<p>With that in mind, here are just a few advantages Illustrator has over Photoshop for vector drawing.</p>

<ul>
<li>
<h3>Selecting shapes</h3>
<p>In Illustrator, the interface for selecting vectors within a document is highly streamlined. You can group a collection of shapes, or even a collection of groups, and then grab any combination of them using the group selection tool. In Photoshop, you&#8217;d use a combination of selection tools, the Layers palette and the Paths palette to do the same thing.</p>
</li>

<li>
<h3>Pathfinder</h3>
<p>The pathfinder toolbar lets you modify shapes using other shapes. Photoshop includes the basic shape modes (add, subtract, intersect, exclude) but Illustrator adds more complicated methods like divide, trim, merge, and crop. I use these frequently to turn combinations of simple shapes into (for example) geometrically-inspired logos.</p>
</li>

<li>
<h3>Changing colors</h3>
<p>Photoshop has pretty sophisticated coloring tools, many of which Illustrator doesn&#8217;t even try to mimic, but one thing it doesn&#8217;t let you do is easily change the color of an entire shape or set of shapes. In Illustrator, you can either drag a swatch onto a shape, or select a shape and click the color you want it to be. You can even select all shapes by their color and change every blue in your document to a red.</p>
</li>

<li><h3>Warp</h3>
<p>Illustrator&#8217;s Warp filter lets you non-destructively change the shape of a vector. Usually this means turning a box or a circle into a shape it would be difficult to draw by hand (say, a flag or a teardrop). I use this a lot for logo design, and I&#8217;m not sure if there&#8217;s a Photoshop equivalent &#8212; there certainly isn&#8217;t one that&#8217;s as easy to use.</p>
</li>

<li>
<h3>Pixel Preview / Pixel align</h3>
<p>Traditionally, you&#8217;re used to seeing pixels in Photoshop and smooth vectors in Illustrator. As of CS5, Illustrator allows you to view and edit your vectors in Pixel Preview mode, to see how they will look on the Web. This lets you spot where your fractional pixel widths might cause fuzzy edges and distortion so that you can fix them on the fly. Plus, there&#8217;s the Align to Pixel option that shuffles your vector around to make the edges smooth (not an exact science, unfortunately). I use this feature when making iOS tab bar icons, and it&#8217;s probably saved me days of work all by itself.</p>
</li>

<li>
<h3>Perspective grid</h3>
<p>Another new CS5 feature, the perspective grid is a tremendous aid to drawing images with depth. You get to set up a grid in 2-or 3-point perspective, and then draw shapes as usual. Illustrator will force a perspective on what you draw: rectangles elongated toward the horizon, right-angles become obtuse, evenly-spaced objects foreshorten, all for free.</p>
</li>

<li>
<h3>Color Guide</h3>
<p>Lets you adjust all the selected colors in your document at once. For example, you could make all your blues slightly greener, or less saturated, or exchange one color for its counterpart on the color wheel. It does a lot of other stuff too, but this alone is worth the price of admission. Photoshop does this as well (for example the Selective Color or H/S/B tools), but not as elegantly or precisely, and not as quickly.</p>
</li>

<li>
<h3>Offset Path</h3>
<p>Creates a similar version of a shape that fits neatly over another shape such that the space between their edges is always the same. Huh? It&#8217;s hard to explain, but very useful, trust me. In Photoshop, I suppose you&#8217;d do this by selecting your shape, contracting the selection, and converting the selection back to a vector, but in Illustrator it&#8217;s a 1-step process.</p>
</li>

<li>
<h3>Extrude / Bevel</h3>
<p>Lets you make simple 3d representations of a shape. Turns a square into a cube, and lets you rotate it and apply some simple lighting effects. Photoshop may have some equivalent feature, but all of its 3D features require a dedicated graphics card, which is probably overkill for most users.</p>
</li>

<li>
<h3>The canvas</h3>
<p>Imagine a tabletop with a piece of paper on it. In Illustrator, the piece of paper is your Artboard, the document you&#8217;ll give to clients, and the tabletop is your Canvas. Since the canvas isn&#8217;t part of the final illustration (it doesn&#8217;t need to be printed or exported by default) you can use it to keep reference images and alternate versions of the shapes on your artboard. Does that make sense? It&#8217;s like a scratchpad. This is a great way to work, and something Photoshop doesn&#8217;t support at all.</p>
</li>

<li>
<h3>Live Trace</h3>
<p>Automagicaly converts raster images (like photographs) into an approximation of the same image in a vector version. It&#8217;s not perfect, but it&#8217;s a very slick feature that a lot of people were asking for before it was included in Illustrator CS2. There&#8217;s nothing even close to this in Photoshop. I think Photoshop would be scared to even try something this crazy.</p>
</li>
</ul>
<h2>Conclusion</h2>
<p>Photoshop is a Swiss Army knife, good for doing a lot of things pretty well, and Illustrator is an X-Acto knife, good for precisely cutting out shapes, and not much else. Yeah, you could carve out your masterpiece with a blunt instrument, but why would you want to? For Web and Mobile design, Illustrator is an elegant supplement to Photoshop that every serious designer should be familiar with.</p>

<p>Personally, I like to draw flat, undecorated shapes in Illustrator, then import them into Photoshop to add colors, lighting and textures. This means I have a lot of layers that look like the silhouettes of buttons, panels and icons, with blending effects and layer masks on top of them. It&#8217;s a nice way to work, using the best tools for each aspect of the job and combining them in a non-destructive, easily reusable way.</p>

]]></content:encoded>
			<wfw:commentRss>http://pugetworks.com/blog/2011/07/whats-better-for-web-design-photoshop-or-illustrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

