<?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>Alchemy Computer Solutions</title>
	<atom:link href="http://alchemycs.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://alchemycs.com</link>
	<description>Transforming your web presence into the best it can be</description>
	<lastBuildDate>Mon, 18 Mar 2013 00:44:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Wrangle Apache&#8217;s PHP handler to secure against serving malicious PHP files</title>
		<link>http://alchemycs.com/2013/02/wrangle-apaches-php-handler-to-secure-against-serving-malicious-php-files/</link>
		<comments>http://alchemycs.com/2013/02/wrangle-apaches-php-handler-to-secure-against-serving-malicious-php-files/#comments</comments>
		<pubDate>Tue, 12 Feb 2013 20:11:05 +0000</pubDate>
		<dc:creator>jpk</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php-shell]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">https://alchemycs.com/?p=1128</guid>
		<description><![CDATA[Apache + PHP is such a standard part of the vast majority of the Internet that most people don&#8217;t think twice about installing apache, php &#38; running their favorite application on top of it (e.g., forum or blogging software). However, &#8230; <a href="http://alchemycs.com/2013/02/wrangle-apaches-php-handler-to-secure-against-serving-malicious-php-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Apache + PHP is such a standard part of the vast majority of the Internet that most people don&#8217;t think twice about installing apache, php &amp; running their favorite application on top of it (e.g., forum or blogging software).</p>
<p>However, if random users can log in from the internet &amp; upload files and then access those uploaded files, you may be vulnerable to what are known as &lt;a href=&#8221;https://en.wikipedia.org/wiki/Backdoor_Shell&#8221;&gt;PHP-Shell&lt;/a&gt; attacks.</p>
<p>For that reason, you should not allow .php files to be uploaded to your server!</p>
<p>What about images though? Surely Apache&#8217;s MIME types will keep you in the clear if someone uploads a php file as <strong>picture.jpg</strong>, right?</p>
<p>Well, yes it will, but in its default configuration on CentOS, it will not protect you from a file named <strong>evil-pic.php.jpg</strong>.</p>
<p>Why is that?</p>
<p>Well, the default configuration in /etc/httpd/conf.d/php.conf is:</p>
<p><pre><code>AddHandler php5-script .php
AddType text/html .php</code></pre></p>
<p>Which (basically) just checks to see if there is a .php in the filename.</p>
<p>You can however, force apache to only hand files over to PHP if they <strong>end</strong> in .php with the following configuration instead:<pre><code>
SetHandler application/x-httpd-php
</code></pre></p>
<p>This makes rendering <strong>evil-pic.php.jpg</strong> resulting in an error.</p>
<p><img class="alignleft size-full wp-image-1131" title="evil-pic" src="http://alchemycs.com/wp-content/uploads/2013/02/evil-pic.png" alt="" width="651" height="157" /></p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2013/02/wrangle-apaches-php-handler-to-secure-against-serving-malicious-php-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New website launched: Fremont.com</title>
		<link>http://alchemycs.com/2012/04/new-website-launched-fremont-com/</link>
		<comments>http://alchemycs.com/2012/04/new-website-launched-fremont-com/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 21:38:26 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[responsive]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=936</guid>
		<description><![CDATA[I am very excited to announce the launch of a major website redesign: Fremont, the Center of the Universe. Fremont is a quirky little neighborhood next door to us.  The site is maintained by the Fremont Chamber of Commerce, with &#8230; <a href="http://alchemycs.com/2012/04/new-website-launched-fremont-com/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fremont.com"><img class="alignleft size-medium wp-image-939" title="screenshot" src="http://alchemycs.com/wp-content/uploads/2012/04/screenshot-300x261.png" alt="Screenshot of Fremont.com" width="300" height="261" /></a>I am very excited to announce the launch of a major website redesign: <a title="Fremont, Seattle, the center of the universe" href="http://fremont.com" target="_blank">Fremont, the Center of the Universe</a>.</p>
<p>Fremont is a quirky little neighborhood next door to us.  The site is maintained by the Fremont Chamber of Commerce, with the delightful Jessica Vets as executive director.  Their old site looked really nifty, but was totally impossible to navigate and was starting to show its age.  So it was time for a new site, and I thought WordPress would be an ideal solution for them: we could make the site in WordPress for a smaller budget than anything else, and Jessica will be able to maintain the site herself.</p>
<p>I had a lot of fun working on the site: Jessica recruited <a href="http://michelesavelle.com/" target="_blank">Michele Savelle</a>, a graphic designer in Fremont, to do the design, and the three of us worked really well together.  Our meetings were not only productive, but lots of fun.</p>
<p>The site is fully <a href="http://en.wikipedia.org/wiki/Responsive_Web_Design" target="_blank">responsive</a>: it should look good on any screen of any size.</p>
<p>Most of the site&#8217;s functionality is fairly standard, except for the business directory.  This was the most challenging part of the site, mostly because I had trouble finding a plugin that could do what I wanted.  Jessica maintains a business directory in Filemaker Pro, and she needed to be able to import data from that directory into WordPress.  I finally found a plugin that pretty much does what I want, although it does have some bugs: the <a href="http://www.digitalquill.co.uk/blog/2010/11/15/datafeed-import-plugin-for-wordpress/" target="_blank">DigitalQuill Data Import Plugin</a>.  This plugin allows Jessica to export her Filemaker Pro database as a CSV, and then import it into WordPress.  Now all of the businesses in Fremont appear on the website, nicely arranged in categories.</p>
<p>Thanks to Jessica and Michele for being awesome to work with!</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2012/04/new-website-launched-fremont-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A fully responsive site</title>
		<link>http://alchemycs.com/2012/01/a-fully-responsive-site/</link>
		<comments>http://alchemycs.com/2012/01/a-fully-responsive-site/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 20:08:16 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[responsive]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=858</guid>
		<description><![CDATA[Responsive is the big buzzword in web design these days &#8211; now that people view websites on so many different sizes of devices, web designs have to be able to respond accordingly and render gracefully in lots of different configurations. &#8230; <a href="http://alchemycs.com/2012/01/a-fully-responsive-site/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://alchemycs.com/wp-content/uploads/2012/01/answers.png" rel="lightbox[858]"><img class="alignleft size-medium wp-image-859" title="answers" src="http://alchemycs.com/wp-content/uploads/2012/01/answers-300x268.png" alt="" width="300" height="268" /></a><a href="http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/">Responsive</a> is the big buzzword in web design these days &#8211; now that people view websites on so many different sizes of devices, web designs have to be able to respond accordingly and render gracefully in lots of different configurations.  This is one of the things I have always loved about web development: the need to be flexible, to think about how the site is going to look and work on different screens.  Now that <a href="http://www.abookapart.com/products/responsive-web-design">responsive web design</a> has arrived, I&#8217;m having lots of fun with media queries and percentages and ems.</p>
<p>I have several responsive sites in progress at the moment, but this week marks the official launch of the first fully-responsive design I have coded, and I&#8217;m absolutely delighted with how it turned out.  It&#8217;s for a new company called <a href="http://answersinhand.com">Answers in Hand</a>, which facilitates providing information to cell phones via NFC and QR codes.  The fantastic graphic design is by <a href="http://warp-graphics.com/">George Guy of Warp Graphics</a>.</p>
<p>So go visit Answers in Hand, and then resize your browser &#8211; as it gets bigger and smaller, the hand holding the phone changes orientation so that it always fits on the screen.  Once you get down to mobile phone size, the hand holding the phone disappears (since you&#8217;re already looking at it on a phone in your hand).</p>
<p>I&#8217;m not usually a fan of <a href="http://onepagelove.com/">one-page websites</a>, but this is a case where I think it works really well.</p>
<p>From now on, I&#8217;m making sure that all of my sites are at least a little bit responsive, and you&#8217;ll see some more fully responsive sites from me soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2012/01/a-fully-responsive-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>301 redirects for URL typos for domains that have multiple sub-domains</title>
		<link>http://alchemycs.com/2012/01/301-redirects-for-url-typos-for-domains-that-have-multiple-sub-domains/</link>
		<comments>http://alchemycs.com/2012/01/301-redirects-for-url-typos-for-domains-that-have-multiple-sub-domains/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 01:23:39 +0000</pubDate>
		<dc:creator>jpk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=833</guid>
		<description><![CDATA[Anyone who has tried to brand themselves or their company with a domain name knows that they should buy multiple domain names that are similar (e.g. .com, .net, .org) but they should also buy misspelled/mistyped variants of their domain names &#8230; <a href="http://alchemycs.com/2012/01/301-redirects-for-url-typos-for-domains-that-have-multiple-sub-domains/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Anyone who has tried to brand themselves or their company with a domain name knows that they should buy multiple domain names that are similar (e.g. .com, .net, .org) but they should also buy misspelled/mistyped variants of their domain names (e.g. example.com might also consider buying exampe.com and exampl.com).  Just buying the domains means others can&#8217;t pretend to be you and catch surfers who perhaps aren&#8217;t the best typists, but what if you want to actually have them go to your main web site?</p>
<p>It is fairly easy to just set them up on the same virtual host as your main site, but that (likely) means you will have two sites with duplicate content, which Google really doesn&#8217;t like.  So you want to provide a 301 redirect for the mis-typed domain to the correct one.  You could create a whole bunch of 301 redirects for each individual page, but if you&#8217;re dealing with dynamically generated content, that really doesn&#8217;t work. Luckily, the Apache web server has the RewriteRule, which can be used to redirect everything that comes after the domain name to the new domain name.<br />
<span id="more-833"></span></p>
<p>I typically just do all the re-directs from within Apache&#8217;s VirtualHost directive&#8211;this way I don&#8217;t have to create anything else or worry about dealing with .htaccess files.  An example is shown here that redirects the extra domain example.net to the real site, example.com completely within an Apache VirtualHost:<br />
<pre><pre>&lt;NameVirtualHost *:80&gt;
&lt;VirtualHost *:80&gt;
ServerName example.net
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.net
RewriteRule (.*) http://example.com/$1 [R=301,L]
&lt;/VirtualHost&gt;
</pre></pre></p>
<p>This 301 redirects anyone who goes to http://example.net/ to http://example.com/ . It also preserves anything they may have typed after the / , so http://example.net/page1.html is redirected to http://example.com/page1.html .<br />
But, if a visitor types in www.example.net, the above won&#8217;t work. We could fix it by adding <strong>.*</strong> in front of the example\.net in the RewriteCond, but it gets further complicated if you have multiple sub-domains, and you want to redirect to their corresponding sub-domains on your main site.</p>
<p>Say you have www.example.com, pics.example.com, wiki.example.com and blog.example.com, each on it&#8217;s own separate server; you would need to set up each sub-domain separately with a 301 redirect.  If you have multiple domains you are redirecting for, you would have to set up each of the sub-domains each time for each additional domain. </p>
<p>Luckily, Apache RewriteRule does support parsing the hostname, but it took me a little effort (as by default the RewriteRules work on everything after the hostname) to find the correct method. Now, RewriteRules can be used to redirect for any number of sub-domains. The following VirtualHost below does just that for all sub-domains for example.net:</p>
<p><pre><pre>&lt;NameVirtualHost *:80&gt;
&lt;VirtualHost *:80&gt;
ServerName example.net
ServerAlias *.example.net
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} [^.]*example\.net$
RewriteRule ^(.+)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%{HTTP_HOST}$1&nbsp;&nbsp; [C]
RewriteRule ^(.*)example\.net/(.*)$ http://$1example.com/$2 [L,R=301]
&lt;/VirtualHost&gt;
</pre></pre></p>
<p>Unfortunately, I haven&#8217;t been able to get a single RewriteRule to work for all domain names, so you would need to create a virtual host for each additional domain you wish you redirect (though you only need one NameVirtualHost for all the VirtualHosts).</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2012/01/301-redirects-for-url-typos-for-domains-that-have-multiple-sub-domains/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shane White website: challenging and fun</title>
		<link>http://alchemycs.com/2011/12/shane-white-website-challenging-and-fun/</link>
		<comments>http://alchemycs.com/2011/12/shane-white-website-challenging-and-fun/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 21:19:07 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=639</guid>
		<description><![CDATA[This week I finished a website that I have been working on for over 2 months.  It was a surprisingly challenging website, but I had lots of fun coding it.  The site is for Shane White, a comic artist here &#8230; <a href="http://alchemycs.com/2011/12/shane-white-website-challenging-and-fun/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://shanewhite.com"><img class="alignleft size-medium wp-image-758" title="screenshot" src="http://alchemycs.com/wp-content/uploads/2011/08/screenshot-300x225.jpg" alt="" width="300" height="225" /></a>This week I finished a website that I have been working on for over 2 months.  It was a surprisingly challenging website, but I had lots of fun coding it.  The site is for <a href="http://shanewhite.com">Shane White</a>, a comic artist here in Seattle.  Shane did all of the graphic design, and then asked me to turn his designs into a WordPress website.</p>
<p>Shane isn&#8217;t a programmer, so he didn&#8217;t realize that a lot of what he was asking for on his website can get very complicated: e-commerce, <a href="http://comicpress.org/">ComicPress</a>, different layouts and navigation for different kinds of content, different headers on different pages, and a very different look for the webcomic pages.  Any one or two of these things wouldn&#8217;t have been very complicated by themselves, but added all together, it made for a very complex site.</p>
<p>So here are some technical details about the site requirements and what I did to create this site to Shane&#8217;s specifications.<span id="more-639"></span></p>
<p>First of all, the biggest requirement for the site was <a href="http://comicpress.org/">ComicPress</a>, a WordPress theme for webcomics.  ComicPress actually feels more like a plugin than a theme: it adds all sorts of extra functionality, like the ability to bulk upload comics and instantly create posts for them.  ComicPress does some impressive stuff, but it also has some limitations: for instance, if you have a blog on the home page, it can either show posts in the comic category, or posts in all other categories: if you have a bunch of categories and only want to show one of them on the home page, you&#8217;re out of luck.</p>
<p>I created a ComicPress child theme, based on the comicpress-blank child theme (I guess that makes mine a grandchild theme).  This meant that I could add files to overwrite any of ComicPress&#8217;s theme files, but I was very cautious about doing this &#8211; I didn&#8217;t want to completely rewrite ComicPress, and I wanted to make sure that Shane can still update ComicPress the next time an update is released.  The biggest changes I made were to the layout of the site.  Another of ComicPress&#8217;s limitations is that you can pick one site-wide layout (and there are lots to choose from), but you can&#8217;t have different layouts on different pages.  Shane needed different layouts, so I hacked a few of the files <a href="http://alchemycs.com/2011/08/different-layouts-on-different-pages-in-comicpress/">to get different layouts on different pages in ComicPress</a>.</p>
<p>The site has several different sections, and each one has a slightly different layout and navigation.   I considered several different ways of doing this, but finally decided it was best to just make <a href="http://codex.wordpress.org/Post_Types">custom post types</a>.  This is good because I can make them work the way I want without any hacking/kludging, but unfortunately from the user&#8217;s point of view it means there is another procedure to follow: each section of the site requires a slightly different procedure for uploading media.  There are two custom post types: &#8220;Portfolio,&#8221; which takes care of <a href="http://shanewhite.com/genre/comics/">Comics</a>, <a href="http://shanewhite.com/genre/illustration/">Illustration</a>, and <a href="http://shanewhite.com/genre/fine-art/">Fine Art</a>, and &#8220;Video,&#8221; which takes care of the <a href="http://shanewhite.com/media/">Media</a> section.  The Portfolios also have a <a href="http://codex.wordpress.org/Taxonomies">custom taxonomy</a>, &#8220;Genre.&#8221;</p>
<p>I also wanted to add a custom meta box to make updating the Portfolio custom post type easier.  I followed <a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">these instructions</a>, and couldn&#8217;t get it to work (the same code works on other blogs, but not this one).  I think this is just a bug in ComicPress &#8211; the action hook that adds the meta box to the editing page never gets called.  Once I realized that action hook wasn&#8217;t getting called, I decided that I had already wasted a ton of time on it, so I should to just make hay and use the &#8220;add custom field&#8221; box, which is less graceful, but less expensive for the customer in the long run.</p>
<p>Shane&#8217;s site also requires e-commerce, so that he can <a href="http://shanewhite.com/store/">sell</a> comic books, art prints, t-shirts, custom art, and other nifty stuff.  I used <a href="http://jigoshop.com/">Jigoshop</a>: of all of the e-commerce plugins I have used, Jigoshop is definitely my favorite, although it isn&#8217;t without its quirks.</p>
<p>In addition to the main site at shanewhite.com, Shane also wanted the ability to easily create sites for his webcomics (such as <a href="http://shanewhite.com/2011/12/000-coming-soon/">Braun</a>), so that he can add new webcomics whenever he wants.  So I wrote another theme, fairly similar to shanewhite.com, that he can use on all of his webcomics sites: with changes to colors and logos, he can make each site look unique.</p>
<p>Of course, all of this complicated stuff gets complicated for Shane too: in addition to WordPress&#8217;s normal posts and pages, Shane has 3 custom post types (portfolio, video, product) and comic blog posts that are different from normal blog posts.  That&#8217;s a lot of different procedures for one person to keep track of!  Not to mention the number of widget areas &#8211; I lost count of the number of widgets the site uses.  So I wrote extensive instructions, thanks to the <a href="http://wordpress.org/extend/plugins/wp-help/">WP Help</a> plugin.  Fortunately, Shane is clever, so he has had no trouble figuring all of this out.</p>
<p>Shane was a delightful client to work with through this whole long process.  Naturally it was fun looking at his artwork as I was working, and he was one of those clients for whom I can use <a href="http://slipsum.com">Samuel L. Lipsum</a> and know that I&#8217;ll get a laugh instead of a disapproving look (it was hilarious when he realized what it was).  He was very patient with me when we ran into problems, which happened frequently &#8211; this seemed to be one of those sites where every little step turned into a big complication, and things that should have been relatively easy turned out to be quite time-consuming.  For instance, there were some things in the header that we couldn&#8217;t get in the correct position: it turned into a comedy of errors, sending screenshots back and forth showing how even though we have the same operating system and the same version of the same browser, the search box was in a completely different place on our screens.  And, of course, since Shane is a graphic artist, he wanted everything to be pixel perfect.  He was quite shocked when I sent him to <a href="http://browsershots.org/">Browser Shots</a> to demonstrate how differently browsers render the same site.  I think we managed to get it pixel-perfect in most browsers.</p>
<p>This was a really fun challenge, and I&#8217;m happy with what we produced.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/12/shane-white-website-challenging-and-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing WordPress themes for usability</title>
		<link>http://alchemycs.com/2011/09/writing-wordpress-themes-for-usability/</link>
		<comments>http://alchemycs.com/2011/09/writing-wordpress-themes-for-usability/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 21:50:11 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=696</guid>
		<description><![CDATA[One of the biggest reasons I create almost all of my websites in WordPress is that it&#8217;s user interface makes it very easy for my clients to update and maintain their sites on their own, without having to rely on &#8230; <a href="http://alchemycs.com/2011/09/writing-wordpress-themes-for-usability/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>One of the biggest reasons I create almost all of my websites in WordPress is that it&#8217;s user interface makes it very easy for my clients to update and maintain their sites on their own, without having to rely on me to make changes.  However, as a developer, there are some things I can do to make it easier for my clients to maintain their sites.</p>
<p>When I decide how to code a site, I think constantly about whether someone might want to change what I am coding, and if so, how easy will it be for them to change it?  <span id="more-696"></span>For instance, most websites have contact information in the footer &#8211; phone number, address, etc.  It would be quick and easy for me to just hard-code this into footer.php.  But what if the client moves and needs to change their address?  What if they decide they want to format their phone number with periods instead of dashes?  Instead of hard-coding this information, I create a widget area in the footer so that the client has access to the information in the site&#8217;s widgets.  This takes a little more time and effort from me up front, but makes it easier for the client in the long run.</p>
<p>When I code the site layout, I also think about how things might need to shrink or grow.  If a client decides they want to add or remove a link from a navigation menu, will the menu still look okay?  Sometimes this is dictated by the graphic design, but I try to code as much flexibility as possible into the layout.</p>
<p>I also use a lot of plugins and widgets to make things easier for my clients.  I wouldn&#8217;t need a lot of these if I weren&#8217;t concerned with usability, but they make life a lot easier for clients who aren&#8217;t comfortable with HTML.  Some of the plugins I use most frequently are:</p>
<ul>
<li><a href="http://contactform7.com/">Contact Form 7</a>: This is an easy-to-use contact form, and their website has excellent documentation and tutorials</li>
<li><a href="http://wordpress.org/extend/plugins/image-widget/">Image widget</a>: This widget makes it really easy to upload an image into a sidebar or other widget area, and link the image to any URL</li>
<li><a href="http://wordpress.org/extend/plugins/rich-text-widget/">Rich Text Widget</a>: This widget lets you use the WordPress WYSIWYG editor to edit widgets: very handy if you want to put a link or formatted text into a sidebar</li>
<li><a href="http://wordpress.org/extend/plugins/tinymce-advanced/">TinyMCE Advanced</a>: TinyMCE is WordPress&#8217;s WYSIWYG editor, and this plugin adds a few more features to it to make it a little more user-friendly</li>
<li><a href="http://wordpress.org/extend/plugins/wp-help/">WP Help</a>: With this plugin, I can write documentation and instructions for my clients, and it will show up in their dashboard.</li>
</ul>
<p>All of this effort at making things easy to edit is for naught if I don&#8217;t tell my clients how to edit their site.  I provide a customized manual for each site, explaining how to edit anything the client might want to edit.  I also provide an in-person training session for any client that wants it.</p>
<p>This all takes some extra time on my part, but it is worth it in the long run if my clients can be self-reliant.  They have the ability to take care of their own sites without worrying about my availability, and that&#8217;s good peace of mind for all of us.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/09/writing-wordpress-themes-for-usability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I like coding for graphic designers</title>
		<link>http://alchemycs.com/2011/08/why-i-like-coding-for-graphic-designers/</link>
		<comments>http://alchemycs.com/2011/08/why-i-like-coding-for-graphic-designers/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 17:52:36 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=677</guid>
		<description><![CDATA[I collaborate with several graphic designers &#8211; most frequently Danny McEnerney of workin&#8217; man creative and George Guy of Warp Graphics &#8211; to turn their graphic designs into WordPress websites.  They send me Photoshop files of their designs, and I &#8230; <a href="http://alchemycs.com/2011/08/why-i-like-coding-for-graphic-designers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I collaborate with several graphic designers &#8211; most frequently Danny McEnerney of <a href="http://www.workinmancreative.com/">workin&#8217; man creative</a> and George Guy of <a href="http://warp-graphics.com/">Warp Graphics</a> &#8211; to turn their graphic designs into WordPress websites.  They send me Photoshop files of their designs, and I turn them into functional websites that match their graphics pixel for pixel.  I really love this aspect of my work.</p>
<p>It gives me something fresh and new to work on.  When I code my own designs, I find my own work predictable, since, of course, it comes from my own head.  When I can code someone else&#8217;s design, I have something new and interesting to work with, and other designers end up doing things that I never would have thought to do.</p>
<p>It might seem that once the graphic design is done, the creative part of the process is over and writing the code is just busywork.  On the contrary, I actually find that writing code requires a great deal of creativity, especially when it is someone else&#8217;s design.  I have to figure out how to write a bunch of text that the computer will translate into the images I see.  Not only that, but I always try to write websites so that they will be easy for the site&#8217;s owner to update themselves, so sometimes that requires a little bit of extra creative thinking.  It&#8217;s a fun problem-solving exercise, and it often requires thinking outside of the proverbial box or approaching the problem from several directions at once.</p>
<p>Coding for graphic designers has also made me a much better designer myself.  I have to examine the work of several different designers in minutia, and looking at how they put their designs together has taught me a lot about what I need to do when I create websites.</p>
<p>It might seem like writing WordPress themes over and over based on someone else&#8217;s designs would get boring, but I really enjoy it. I find it to be creative and stimulating work.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/08/why-i-like-coding-for-graphic-designers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X Lion, Terminal and ssh: how to start ssh-agent at login</title>
		<link>http://alchemycs.com/2011/08/mac-os-x-lion-terminal-and-ssh-how-to-start-ssh-agent-at-login/</link>
		<comments>http://alchemycs.com/2011/08/mac-os-x-lion-terminal-and-ssh-how-to-start-ssh-agent-at-login/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 17:38:56 +0000</pubDate>
		<dc:creator>jpk</dc:creator>
				<category><![CDATA[OSX]]></category>
		<category><![CDATA[Secure Shell]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=610</guid>
		<description><![CDATA[As a freelance sysadmin, I use Mac OS X&#8217;s Terminal.app to connect to a lot of different Unix and Linux servers&#8211;I will frequently have a dozen or two (or sometimes three) terminals open to different machines.  This is one of &#8230; <a href="http://alchemycs.com/2011/08/mac-os-x-lion-terminal-and-ssh-how-to-start-ssh-agent-at-login/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As a freelance sysadmin, I use Mac OS X&#8217;s Terminal.app to connect to a lot of different Unix and Linux servers&#8211;I will frequently have a dozen or two (or sometimes three) terminals open to different machines.  This is one of the reasons I hate rebooting&#8211;I lose all my connections &amp; pretty much have to start over from scratch.</p>
<p>I recently upgraded to Mac OS X Lion, and things have been mostly positive.  I really love the option to &#8220;Reopen windows when logging back in.&#8221;  In terminal, that means I get all my windows back! I do still have to reconnect to all the machines, but at least I can see where I was connected, and pretty much what I was doing.  I use <a href="http://gnu.org/software/screen/">screen</a> extensively on  the servers I connect to, so I frequently don&#8217;t even lose what I was doing.</p>
<p><a href="http://alchemycs.com/wp-content/uploads/2011/07/restart1.png" rel="lightbox[610]"><img class="alignnone size-full wp-image-613" title="restart" src="http://alchemycs.com/wp-content/uploads/2011/07/restart1.png" alt="" width="423" height="201" /></a></p>
<p>The only problem is that when Mac OS X boots back up and starts Terminal.app at login, <cite></cite><a href="en.wikipedia.org/wiki/Ssh-agent">ssh-agent</a> is not started before Terminal.app starts, meaning I can&#8217;t log into servers using my <a href="http://alchemycs.com/2011/04/ssh-public-keys-or-how-not-to-expose-a-password/">SSH public keys</a>.  Further, if you quit Terminal.app, and re-open it, it won&#8217;t reliably open ssh-agent (I&#8217;ve had it happen a couple times out of the many times I&#8217;ve tested).  The only surefire way to get ssh-agent to start is to close all your windows and then quit &amp; restart Terminal.app with a completely blank slate.</p>
<p>That is a problem as it undoes all the good that saving all my windows did.  I wanted to find a way to get ssh-agent started before Terminal.app opened.  I added it to my Login Items without any success, and even adding a LoginHook to /etc/ttys did not make it start before Terminal loaded.</p>
<p>But, there is a workaround  in that if I have ssh-agent start at login, I can quit &amp; restart Terminal.app and it always connects, so that is what I have done.  The probably more correct place to do is to add it to my Login Items.  To do that, I opened a Terminal window &amp; created a symbolic link from ssh-agent to my home directory.</p>
<p><code>ln -s /usr/bin/ssh-agent .</code></p>
<p>Then I added it to my Login Items by pressing the + button and selecting it from my home dir.  I can then remove the symbolic link I created, as Login Items is smart enough to link to the actual ssh-agent program.</p>
<p>So now after bootup and login, if I quit Terminal.app and restart it, it always connects to the ssh-agent and I can go about my passwordless logging in to all my servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/08/mac-os-x-lion-terminal-and-ssh-how-to-start-ssh-agent-at-login/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Different layouts on different pages in ComicPress</title>
		<link>http://alchemycs.com/2011/08/different-layouts-on-different-pages-in-comicpress/</link>
		<comments>http://alchemycs.com/2011/08/different-layouts-on-different-pages-in-comicpress/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 00:07:18 +0000</pubDate>
		<dc:creator>Morgan</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=646</guid>
		<description><![CDATA[I&#8217;m currently writing a theme for a website using ComicPress, a WordPress plugin/theme designed for publishing comics.  ComicPress is powerful, complex, and impressive.  It makes life a lot easier for writers and readers of webcomics.  I&#8217;ve been poking through the &#8230; <a href="http://alchemycs.com/2011/08/different-layouts-on-different-pages-in-comicpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m currently writing a theme for a website using <a href="http://comicpress.org/">ComicPress</a>, a WordPress plugin/theme designed for publishing comics.  ComicPress is powerful, complex, and impressive.  It makes life a lot easier for writers and readers of webcomics.  I&#8217;ve been poking through the code a lot, and I have been impressed with what I see.</p>
<p>However, I did run into a weakness of ComicPress pretty quickly.  The comic artist for whom I am writing this theme wants different pages to have different layouts.  This is a pretty standard feature of WordPress sites: sometimes you want one page to have sidebars and another none, or some pages with sidebars on the left and some with sidebars on the right.  In ComicPress, on the other hand, you can&#8217;t do this.  ComicPress comes with several choices of layout, but once you make your choice in the ComicPress admin area, you&#8217;re stuck with that layout on every page.</p>
<p>Fortunately, I found that it is actually pretty easy to make different layouts for different pages with ComicPress, if you don&#8217;t mind tinkering with the code.  I&#8217;ll show you how I did it.</p>
<p>First of all, make sure that you are working with a ComicPress child theme, and do not edit the ComicPress files themselves: if you do, all your changes will be lost when you upgrade ComicPress.</p>
<p>The files that control the layout of the site are called layout-head.php and layout-foot.php.  Copy those two files into your child theme directory: now you can update them and they will override the original files.</p>
<p>Here is the original layout-head.php that comes with ComicPress:<br />
<pre><pre>
&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;content-wrapper-head&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&lt;div id=&quot;content-wrapper&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cr,2cl,3c,3c2l,3c2r&#039;)) do_action(&#039;comic-area&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;subcontent-wrapper-head&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;subcontent-wrapper&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cl,2cvl,3c,3c2l,v3c,v3cl,lgn&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;left&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;3c2l,v3cl&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;right&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn&#039;)) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;section-wrap&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php do_action(&#039;comic-area&#039;);?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;rgn&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;left&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_active_sidebar(&#039;over-blog&#039;)) get_sidebar(&#039;overblog&#039;); ?&gt;
</pre></pre></p>
<p>The section of code that interests us is after <code>&lt;div id=&quot;subcontent-wrapper&quot;&gt;</code>. You can see that there are short names for each layout option, and the code is full of conditional clauses for each layout. So the code says that all layouts show the left sidebar, unless the sidebars have been disabled. The three-column layouts also show the right sidebar. All layouts show the comic area.</p>
<p>I rewrote the conditional logic, as you can see here:<br />
<pre><pre>
&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;content-wrapper-head&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&lt;div id=&quot;content-wrapper&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cr,2cl,3c,3c2l,3c2r&#039;)) do_action(&#039;comic-area&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;subcontent-wrapper-head&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;subcontent-wrapper&quot;&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (is_page()) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt; &lt;?php ;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif (is_home()) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt; &lt;?php ;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif (is_single()) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt; &lt;?php ;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;content&quot; class=&quot;widecolumn&quot;&gt; &lt;?php ;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn&#039;)) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php do_action(&#039;comic-area&#039;);?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php } ?&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_active_sidebar(&#039;over-blog&#039;)) get_sidebar(&#039;overblog&#039;); ?&gt;
</pre></pre></p>
<p>Instead of my conditions being based on what layout was chosen in the ComicPress admin options, I wrote conditions based on what kind of page is being rendered, using WordPress&#8217;s <a href="http://codex.wordpress.org/Conditional_Tags">conditional tags</a>. For pages where I don&#8217;t want sidebars, I made a div with class &#8220;widecolumn&#8221;; for pages where I do want sidebars, the div&#8217;s class is &#8220;narrowcolumn.&#8221;  I moved all references to the sidebars to the footer.</p>
<p>I made very similar changes to layout-foot.php. Here is ComicPress&#8217;s code:</p>
<p><pre><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn&#039;)) { ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;lgn&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;right&#039;);&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;3c2r,v3cr&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;left&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_cp_theme_layout(&#039;2cr,2cvr,3c,3c2r,v3c,v3cr,rgn&#039;) &amp;&amp; !comicpress_disable_sidebars()) get_sidebar(&#039;right&#039;);&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;subcontent-wrapper-foot&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;content-wrapper-foot&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
</pre></pre></p>
<p>And here is my version:</p>
<p><pre><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_page()) get_sidebar(&#039;right&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_home()) get_sidebar(&#039;right&#039;); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (is_single()) get_sidebar(&#039;right&#039;); ?&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;subcontent-wrapper-foot&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;?php if (comicpress_themeinfo(&#039;enable_caps&#039;)) { ?&gt;&lt;div id=&quot;content-wrapper-foot&quot;&gt;&lt;/div&gt;&lt;?php } ?&gt;
</pre></pre></p>
<p>Just like in the header layout, I use conditional tags to render the sidebars only on pages where I want sidebars.</p>
<p>This is a simple hack, and enables you to have different layouts on different pages. Conditional tags can work for just about any conditions you can think of, so this is a great way to make your ComicPress theme more flexible.</p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/08/different-layouts-on-different-pages-in-comicpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>shell scripting pitfall: string/number conversions</title>
		<link>http://alchemycs.com/2011/07/shell-scripting-pitfall-stringnumber-conversions/</link>
		<comments>http://alchemycs.com/2011/07/shell-scripting-pitfall-stringnumber-conversions/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 22:24:35 +0000</pubDate>
		<dc:creator>jpk</dc:creator>
				<category><![CDATA[awk]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell scripting]]></category>

		<guid isPermaLink="false">http://alchemycs.com/?p=617</guid>
		<description><![CDATA[I create quite a few WordPress installs for my partner, Morgan, to develop from, and we have a non-trivial number of changes we implement for each new WordPress install.  I wrote a simple install script that does everything so that &#8230; <a href="http://alchemycs.com/2011/07/shell-scripting-pitfall-stringnumber-conversions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I create quite a few WordPress installs for my partner, Morgan, to develop from, and we have a non-trivial number of changes we implement for each new WordPress install.  I wrote a simple install script that does everything so that Morgan can easily create a new WP install whenever she needs one.</p>
<p>One of the things I do in the script is add a new DNS record to a zone file in <a href="http://isc.org/software/bind">BIND</a> and update the named server.  (Tiny bit of a background: DNS updating works by having serial numbers be larger that the previous update&#8217;s serial&#8211;these serials are typically a 10-digit numeric form of date+version (eg, the serial 2011072602 is July 26th, 2011 (20110726) &amp; the (02) 2nd revision for today).) If my shell script needed to update the serial number which was already changed today, it would need to increment the version, which gets read in as a string.  That isn&#8217;t a big deal, as you can easily cast a string to be a number by doing $((variable)).  But it needs to be replaced by a 2-digit version again, so I used awk to make sure it was<br />
<pre><pre>ver=&quot;02&quot;
echo $ver+1
02+1
echo $((ver+1))
03</pre></pre><br />
That works fine, but what if you&#8217;re on the 08th revision for the day?<br />
<pre><pre>ver=&quot;08&quot;
echo $ver+1
08+1
echo $((ver+1))
08: value too great for base (error token is &quot;08&quot;)</pre></pre><br />
Why is that happening?</p>
<p>Well, the shell is trying to be clever: it knows that numbers that start with 0x are going to be in hex, and numbers that start with 1-9 are going to be decimals, and it thinks that numbers that start with 0 are octal (that is, base 8, or 01234567) so it doesn&#8217;t know what the heck an &#8217;8&#8242; is (its like trying to add 3+a in decimal&#8211;it just doesn&#8217;t compute).  To get around this, I need to force my variable &#8220;ver&#8221; to be numeric without the leading 0.</p>
<p>I use awk&#8217;s printf to do this as it seemed like the easiest thing (I really like awk).<br />
<pre><pre>ver=&quot;08&quot;
ver2=`echo $ver | awk &#039;{printf( &quot;%d&quot;, $1 )}&#039;`
echo $((ver2+1))
9</pre></pre><br />
I then have to ensure that I have a 2-digit number to put back together with today&#8217;s date to ensure that my serial number is complete.  I again use awk&#8217;s printf:<br />
<pre><pre>ver3=`echo $((ver2+1)) | awk &#039;{printf( &quot;%02d&quot;, $1 )}&#039;`
echo ver3
09</pre></pre><br />
While converting from 08 to 8 to 9 and back to the 2-digit 09 is a little convoluted, being able to do different common base (eg hex, octal) in the shell is handy (after all, Real Men code in the shell, right?).</p>
<p><small>Feel free to <a href="/contact">contact</a> me if you&#8217;d like a copy of the script.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://alchemycs.com/2011/07/shell-scripting-pitfall-stringnumber-conversions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
