<?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>alt-tag.com &#187; Programming</title>
	<atom:link href="http://alt-tag.com/blog/archives/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://alt-tag.com/blog</link>
	<description>Thoughts on everything from education and politics to internet usability, and programming.</description>
	<lastBuildDate>Sun, 22 Nov 2009 17:52:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Books worth their weight in gold</title>
		<link>http://alt-tag.com/blog/archives/2009/09/books-worth-their-weight-in-gold/</link>
		<comments>http://alt-tag.com/blog/archives/2009/09/books-worth-their-weight-in-gold/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 14:55:56 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Management]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://alt-tag.com/blog/?p=145</guid>
		<description><![CDATA[For years, I&#8217;ve kept a personal (and unfortunately, unwritten) list of books I think every manager, programmer, and [insert category here] should read.
A book every programmer should read
The Pragmatic Programmer: From Journeyman to Master. Every programmer I hired was required to read this book. It&#8217;s a great resource for people managing programmers too. The book [...]]]></description>
			<content:encoded><![CDATA[<p>For years, I&#8217;ve kept a personal (and unfortunately, unwritten) list of books I think every manager, programmer, and [insert category here] should read.</p>
<h3>A book every programmer should read</h3>
<p><a href="http://www.amazon.com/gp/product/020161622X?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=020161622X" style="float:left;margin-right:3px"><img src="/blog/blogimages/books/PragProg.jpg"/></a><em><a href="http://www.amazon.com/gp/product/020161622X?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=020161622X">The Pragmatic Programmer: From Journeyman to Master</a></em>. Every programmer I hired was required to read this book. It&#8217;s a great resource for people managing programmers too. The book is entirely language agnostic, and focuses on how programmers do (or should) think and work. Most programming books do an adequate job of covering syntax, but few actually address the process of programming. My collegiate programming classes typically expected me to already know the syntax and focused more on the theory of the system, but they too offered little advice on how to actually program. This book, more than any other I&#8217;ve found, fills those gaps.</p>
<p>This book was so unlike most technical books, the authors went on to start their own <a href="http://www.pragprog.com">publishing house</a> for programming books. (I was fortunate to be a technical reviewer for <a href="http://www.amazon.com/gp/product/1934356018?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1934356018">one of them</a>.) All of their books that I&#8217;ve tried thus far have been of high quality.</p>
<p>Another excellent (but less essential) read for programmers is <em><a href="http://www.amazon.com/gp/product/0596007124?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596007124">Head First Design Patterns</a></em>. The book&#8217;s example are in Java, but are easily adapted to other languages.</p>
<h3>A book every technical manager should read</h3>
<p><a href="http://www.amazon.com/gp/product/0932633439?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0932633439" style="float:left;margin-right:3px"><img src="/blog/blogimages/books/Peopleware.jpg"/></a><em><a href="http://www.amazon.com/gp/product/0932633439?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0932633439">Peopleware: Productive Projects and Teams</a></em>, by Tom DeMarco and Timothy Lister. It covers everything from productivity to working conditions and incentives, and explains why programmers are different from &#8220;regular&#8221; folk. The advice here can be easily applied to all technical and knowledge workers. Highly recommended. <em><a href="http://www.amazon.com/gp/product/0767907698?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0767907698">Slack</a></em>, also by DeMarco (which I think is a more recent rendering of some of the same concepts) is on my &#8220;to read&#8221; list&#8212;when I finally get around to finishing it, I&#8217;ll comment on it as well.</p>
<h3>Two books every manager should read</h3>
<p><a href="http://www.amazon.com/gp/product/007148499X?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=007148499X" style="float:left"><img src="/blog/blogimages/books/Influencer.jpg" style="margin-right:3px"/></a><em><a href="http://www.amazon.com/gp/product/007148499X?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=007148499X">Influencer</a></em>, by Kerry Patterson. This book changed the way I think about organizational issues. It begins with the incredible premise that social problems can be addressed by leveraging a single behavior, then delivers example after monumental example demonstrating&#8212;with step-by step instructions&#8212;how true it can be. From eliminating a parasite in remote Africa, to quelling an AIDS epidemic, to more local and mundane organizational or personal problems, <em>Influencer</em> details in easy language why so many transformation efforts fail, and what to do about it.</p>
<p><a href="http://www.amazon.com/gp/product/0066620996?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0066620996" style="float:left;margin-right:3px"><img src="/blog/blogimages/books/GoodToGreat.jpg"/></a><em><a href="http://www.amazon.com/gp/product/0066620996?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0066620996">Good to Great</a></em>, by Jim Collins. Despite criticisms I&#8217;ve heard from a couple of academic researchers calling it &#8220;junk science,&#8221; this book is used in many highly ranked MBA programs, and made rounds at several organizations I&#8217;ve worked with, including Utah state government. Collins examines the differences between companies that were extraordinarily successful year after year (as measured by stock price) and those that hovered near the industry average. It is an interesting look at  many factors that shape the success of organizations.</p>
<h3>More worthwhile books</h3>
<p><a href="http://www.amazon.com/gp/product/0316010669?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0316010669" style="float:left"><img src="/blog/blogimages/books/Blink.jpg" style="margin-right:3px"/></a><em><a href="http://www.amazon.com/gp/product/0316010669?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0316010669">Blink</a></em>, by Malcolm Galdwell. The book is an easy to read and incredibly fascinating exploration of how we think and, despite our best intentions, are affected by biases. I&#8217;m surprised at how often anecdotes and insight from this book were relevant during my MBA courses. If you like <em>Blink</em> and want a more academic and in-depth treatment, I&#8217;ve found <em><a href="http://www.amazon.com/gp/product/0470049456?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0470049456">Judgement in Managerial Decision Making</a></em> to be similarly facinating.</p>
<p><a href="http://www.amazon.com/gp/product/0060084359?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0060084359" style="float:left"><img src="/blog/blogimages/books/Once_an_Eagle.jpg" style="margin-right:3px"/></a><em><a href="http://www.amazon.com/gp/product/0060084359?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0060084359">Once an Eagle</a></em>, by Anton Myrer. A fictional account of two soldiers spanning most the greatest wars of the 20th century. Through the characters, the author explores the ethics of leadership. I&#8217;ve heard it rumored (but don&#8217;t know for certain) that this book is required reading at some of the U.S. military academies. An excellent&#8212;although lengthy&#8212;read.</p>
<p>Others I&#8217;ve found worthwhile include:</p>
<ul>
<li><em><a href="http://www.amazon.com/gp/product/0470049456?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0470049456">Judgement in Managerial Decision Making</a></em>, by  Max Bazerman and Don Moore</li>
<li><em><a href="http://www.amazon.com/gp/product/0884271781?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0884271781">The Goal: A Process of Ongoing Improvement</a></em>, by Eliyahu Goldratt and Jeff Cox</li>
<li><em><a href="http://www.amazon.com/gp/product/0787960756?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0787960756">The Five Dysfunctions of a Team</a></em>, by Patrick Lencioni</li>
<li><em><a href="http://www.amazon.com/gp/product/1576751740?ie=UTF8&#038;tag=alttag-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1576751740">Leadership and Self-Deception</a></em>, by The Arbinger Institute</li>
</ul>
<p>Is there something else that should be on the list?</p>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2009/09/books-worth-their-weight-in-gold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flaws with Utah Reporting System</title>
		<link>http://alt-tag.com/blog/archives/2008/10/flaws-with-utah-reporting-system/</link>
		<comments>http://alt-tag.com/blog/archives/2008/10/flaws-with-utah-reporting-system/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 04:47:04 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Utah Politics]]></category>

		<guid isPermaLink="false">http://alt-tag.com/blog/archives/2008/10/flaws-with-utah-reporting-system/</guid>
		<description><![CDATA[I was surfing John Gruber&#8217;s Daring Fireball, and he linked to an article on programming and journalism.
The article itself didn&#8217;t do anything for me, but the way John described the link connected some synapses for me.  (I wish I could recover what it was&#8212;something about exposing government APIs to journalists.)
Utah does pretty well with [...]]]></description>
			<content:encoded><![CDATA[<p>I was surfing John Gruber&#8217;s <a href="http://daringfireball.net/">Daring Fireball</a>, and he linked to <a href="http://www.ojr.org/ojr/stories/060605niles/">an article on programming and journalism</a>.</p>
<p>The article itself didn&#8217;t do anything for me, but the way John described the link connected some synapses for me.  (I wish I could recover what it was&#8212;something about exposing government APIs to journalists.)</p>
<p>Utah does pretty well with e-government, but one thing continues to bug me:  our <a href="https://ucrs.utah.gov/index.html">election contributions reporting system</a>.  The key point is this: <em>How much more powerful could it be if it exposed the data in a published RESTful XML format, suitable for use in mashups</em>?</p>
<p>Untapped potential aside, I think the current system is flawed for the following reasons:</p>
<ul>
<li>Contributions aren&#8217;t tagged with the date their entered (only the date of the contribution).  I&#8217;ve read of more than one instance where someone suspects a report was amended after the fact, but that information (if collected) isn&#8217;t exposed.</li>
<li>Multiple pages of contributions/expenditures reports don&#8217;t have unique links. (e.g. each &#8220;Next&#8221; link goes to the same URL.  Some magic is happening with cookies to enforce state.)</li>
<li>Multiple pages of reports aren&#8217;t numbered.</li>
<li>First/Next/Previous/Last links always appear, even for single page reports.</li>
<li>PAC/PIC searches are broken.  (Try searching for statements that &#8220;contain&#8221; some nonsense word.  You&#8217;ll get the same results as if you&#8217;d searched for your own name.)</li>
<li>Some expenditures are marked with asterisks, but there&#8217;s no explanation of what that means.</li>
</ul>
<p>Let me put it this way: there are some pretty serious usability issues on the citizen side.  Without having to go through the rigamarole of trying to remember the password I need only once a year (and it can only be set by contacting the Lt. Gov&#8217;s office directly&#8212;and no area code is provided when the phone number is first listed) let me just say that using the system as a candidate isn&#8217;t a walk in the park either.</p>
<p>Let&#8217;s be honest&#8212;it&#8217;s a simple store data/show data application.  It shouldn&#8217;t be to hard to do well, if one doesn&#8217;t pick the lowest bidder. &#8230;</p>
<div class="seeAlso">
<h3>As an aside</h3>
<p>For the curious, in my successful 2004 campaign, <a href="https://ucrs.utah.gov/ucrsppc/public.html?Target=pubAccountSummary&#038;CandidateID=2545">I collected $10, and spent $310.59</a>.  I still have a huge stack of plastic yard signs that I use for workspaces when I paint models and to do puzzles on.</div>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2008/10/flaws-with-utah-reporting-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hand-rolled gallery automation</title>
		<link>http://alt-tag.com/blog/archives/2007/07/hand-rolled-gallery-automation/</link>
		<comments>http://alt-tag.com/blog/archives/2007/07/hand-rolled-gallery-automation/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 05:59:56 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://alt-tag.com/blog/archives/2007/07/hand-rolled-gallery-automation/</guid>
		<description><![CDATA[The Senate Site  asked about a good way to quickly post a gallery of images. I&#8217;m a programmer, so I answered the query by rolling my own solution. (If your only tool is a hammer&#8230;)
I happen to like Litebox, although it requires a bit of manual setup: moving specific files to the web server. [...]]]></description>
			<content:encoded><![CDATA[<p>The Senate Site  <a href="http://senatesite.com/blog/2007/07/photo-album.html">asked about a good way to quickly post a gallery of images</a>. I&#8217;m a programmer, so I answered the query by rolling my own solution. (If your only tool is a hammer&#8230;)</p>
<p>I happen to like <a href="http://www.doknowevil.net/litebox/">Litebox</a>, although it requires a bit of manual setup: moving specific files to the web server. Don&#8217;t worry about the setup instructions on the Litebox site. We automate the file interactions below.</p>
<h3>Getting Ready</h3>
<p>The following requires OS X 10.4, and uses Automator.</p>
<p>Download the following supporting files, and put them on your web server. I put my CSS files in &#8220;/css&#8221; and my javascript files in &#8220;/js&#8221;. It&#8217;s up to you.
<ul>
<li><a href="/js/TagLoader.js">TagLoader.js</a> &#8212; Inside this file, you&#8217;ll need to change the two hard-coded file paths to match the paths to the js and css folders on your server. Change the following lines to match your setup:<code class="codeblock">&nbsp;&nbsp;BASE_JS: &#039;/js/min/&#039;,<br />
&nbsp;&nbsp;BASE_CSS: &#039;/css/&#039;,</code></li>
<li><a href="/js/litebox-1.0.js">litebox-1.0.js</a></li>
<li><a href="/js/prototype.lite.js">prototype.lite.js</a></li>
<li><a href="/js/moo.fx.js">moo.fx.js</a></li>
<li><a href="/js/lightbox.css">lightbox.css</a></li>
</ul>
<p>Add the following to your site/theme CSS file.  (Feel free to modify this CSS as you prefer. These values suited me.)<code class="codeblock">ul.thumbs {<br />
&nbsp;&nbsp;text-align:center;<br />
&nbsp;&nbsp;list-style-type: none;<br />
}<br />
ul.thumbs li {<br />
&nbsp;&nbsp;display:inline;<br />
&nbsp;&nbsp;padding: 0;<br />
&nbsp;&nbsp;margin: 0 5px;<br />
&nbsp;&nbsp;list-style-type: none;<br />
}</code></p>
<p>Build the following Automator action (or just <a href="/blog/blogdata/ThumbnailsToHtml.workflow.zip">download the complete version</a>)</p>
<ol>
<li>Finder : <strong>Get Selected Finder Items</strong></li>
<li>Preview : <strong>Create Thumbnail Images</strong> &#8212; I left the sized at 128. Leave the suffix as &#8220;_tn&#8221;; it&#8217;s important later on.</li>
<li>Automator : (For some reason, WordPress is mangling the following code&#8212;it&#8217;s not showing the escaped quotes properly.)
<pre style="overflow:auto"><code class="codeblock">JS_FOLDER=&quot;/js/&quot;
IMG_FOLDER=&quot;/images/&quot;
LB_TAG=$(date &quot;+%Y%m%d-%H%M%S&quot;)
echo &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;${JS_FOLDER}TagLoader.js\&quot;&gt;&lt;/script&gt;
&lt;script type=\&quot;text/javascript\&quot;&gt; //&lt;![CDATA[ 
TagLoader.load(&#039;litebox&#039;);//
//]]&gt;&lt;/script&gt;
&lt;ul class=\&quot;thumbs\&quot;&gt;&quot;
for tn in &quot;$@&quot;
do
&nbsp;&nbsp;#Get img base name (i.e. w/o path)
&nbsp;&nbsp;tn=${tn##*/}
&nbsp;&nbsp;#Guess at original image name
&nbsp;&nbsp;img=${tn%_tn.*}.${tn##*.}

&nbsp;&nbsp;echo &quot;&lt;li&gt;&lt;a href=\&quot;${IMG_FOLDER}${img}\&quot; rel=\&quot;lightbox[${LB_TAG}]\&quot;&gt;&lt;img src=\&quot;${IMG_FOLDER}${tn}\&quot; alt=\&quot;\&quot; /&gt;&lt;/a&gt;&lt;/li&gt;&quot;
done

echo &quot;&lt;/ul&gt;&quot;</code></pre>
</li>
<li>System : <strong>Copy Text To Clipboard</strong></li>
<li>(optional) TextEdit : <strong>New Text File</strong> &#8212; Pop down the options. Check &#8220;Show action when run&#8221; and &#8220;Show entire action&#8221;</li>
</ol>
<p>Within the Automator action you just built (and, of course, saved appropriately), you&#8217;ll need to modify some code to match your server file paths. Change JS_FOLDER and IMG_FOLDER (the top two lines of the Bash script) to match the file paths.<code class="codeblock">JS_FOLDER=&quot;/js/&quot;<br />
IMG_FOLDER=&quot;/images/&quot;</code></p>
<p>Save your Automator action to &#8220;<code>~/Library/Workflows/Applications/Finder/</code>&#8221;</p>
<p>You now have an Automator action that takes selected image files, automatically makes thumbnails, generates the HTML snippet needed to load Litebox and display the thumbnails. The HTML is copied to the clipboard for easy pasting, Nifty.</p>
<p>If you want to dig further into Automator, you get bonus points for using the &#8220;Finder : Get Folder Contents&#8221; action instead of having to select individual files.  Extra bonus points for integrating the <a href="http://www.apple.com/downloads/macosx/automator/uploadtoftp.html">Upload to FTP Automator Action</a>. (Hint: You might have to add it twice: once before the thumbnails are created, and once after.)</p>
<h3>Using our new tool</h3>
<p>To use the Automator action, select the files you wish to insert/thumbnail/etc. Right-click, pick &#8220;Automator&#8221;, and from the pop-out menu, pick your new action.  It&#8217;ll take a moment to run (depending on how many images you selected), and prompt to save the generated html file when it&#8217;s completed.</p>
<p>FTP the image files and newly created thumbnails to your web server. Paste the generated HTML into your blog. You&#8217;re done!</p>
<h3>One bug</h3>
<p>One bug I discovered when building this, is that my script assumes the original image file has the same file extension as the thumbnail.  If the initial image is a png, Automator will output the thumbnail as a jpg, so you might have to do some find/replace.</p>
<h3>The output</h3>
<p>I ran my Automator action on three images, and followed the process above.  This is the output (I had to manually fix the png file extensions, per my bug, above). Click the images to see Litebox in action!</p>
<p><script type="text/javascript" src="/js/min/TagLoader.js"></script><script type="text/javascript"> //< ![CDATA[
TagLoader.load('litebox');//
//]]&gt;</script></p>
<ul class="thumbs">
<li><a href="/blog/blogimages/Tobin_2006.png" rel="lightbox[20070712-231645]"><img src="/blog/blogimages/Tobin_2006_tn.jpg" alt="" /></a></li>
<li><a href="/blog/blogimages/TJ_2006.png" rel="lightbox[20070712-231645]"><img src="/blog/blogimages/TJ_2006_tn.jpg" alt="" /></a></li>
<li><a href="/blog/blogimages/Tyson_2006.png" rel="lightbox[20070712-231645]"><img src="/blog/blogimages/Tyson_2006_tn.jpg" alt="" /></a></li>
</ul>
<div class="seeAlso"><strong>UPDATE:</strong> I had some problems with one of my Javascripts in IE when I first posted.  It should be fixed now.</div>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2007/07/hand-rolled-gallery-automation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrating Mantis and Subversion</title>
		<link>http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/</link>
		<comments>http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/#comments</comments>
		<pubDate>Wed, 29 Nov 2006 19:08:25 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Management]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/</guid>
		<description><![CDATA[Do you want to know how to integrate Mantis and SVN?  I did, but could never manage the right Google query to return a page written for someone unfamiliar with customizing Mantis.  (I&#8217;m still learning SVN too.)  This is the documentation I wish I&#8217;d had. This process is easier if you know [...]]]></description>
			<content:encoded><![CDATA[<p>Do you want to know how to integrate Mantis and SVN?  I did, but could never manage the right Google query to return a page written for someone unfamiliar with customizing Mantis.  (I&#8217;m still learning SVN too.)  This is the documentation I wish I&#8217;d had. This process is easier if you know Bash or some other scripting language. This was accomplished using Mantis 1.0.0rc2.  An older version may not work with these instructions.</p>
<h3>Introducing Subversion (SVN) Hooks</h3>
<p>Subversion allows for <a href=http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1" title="Manual page for &quot;Hook Scripts&quot;">custom scripts</a> to be called when it performs certain actions on a repository.  Browse to your repository.  The server-side one, not your working copy. In <code>/path/to/svn/repository_name/hooks</code> you will see a list of sample scripts for the five actions subversion recognizes.</p>
<dl>
<dt><code>start-commit</code></dt>
<dd>Run before the commit transaction is created. May be used to stop the transaction and return error messages to clients.</dd>
<dt><code>pre-commit</code></dt>
<dd>Run when the transaction is complete, but before it is committed. It can be used to require comments to include a bug tracker ticket number, or enforce fine-grained access to parts of the repository. It can cause the transaction to rollback and return error messages to clients.</dd>
<dt><code>post-commit</code></dt>
<dd>Run after the transaction is committed, and a new revision is created. Often used to send notification emails or trigger repository backups. Errors from this hook are ignored Subversion comes with some scripts for common actions. Read the manual for more details.</dd>
<dt><code>pre-revprop-change</code></dt>
<dd>Revision properties such as log messages aren&#8217;t versioned. If you were to go back and change a log message, for example, the old one would be lost.  This hook, and its <code>post-</code> counterpart, offer a chance to reject or log the change.</dd>
<dt><code>post-revprop-change</code></dt>
<dd>Run after revision properties are changed.  There are some security restrictions built in, be sure to read the manual.</dd>
</dl>
<p>Well, that sounds simple.  All we have to do is write a script that will log into our bug tracking system and insert a comment on the appropriate ticket.  That sounds easy enough, but let&#8217;s not make things too complicated.  With  a few minor customizations, Mantis will do most of the work for us.</p>
<h3>Customizing Mantis</h3>
<p>The manual for Mantis has two relevant pages. One, titled <a href="http://manual.mantisbt.org/manual.configuration.source.control.integration.php" title="Mantis: Source Control Integration">&#8220;Source Control Integration&#8221;</a>, provides a list of customizable settings, but offers no directions on where these settings are most appropriately accessed.  The other, <a href="http://manual.mantisbt.org/manual.installation.cvs.integration.php" title="Mantis: CVS Integration">&#8220;CVS integration&#8221;</a>, is not terribly helpful either, but it does provide another piece of our puzzle&#8212;it tells us there is a command line PHP script included with Mantis that accepts a version control (e.g. SVN, CVS) log message via stdin, and adds comments to any tickets as appropriate.</p>
<p>First things first.  Create a new user in Mantis.  This is the account the script will use.  I called mine &#8220;svn&#8221;.  Make sure the user has permission to add comments and resolve tickets.  Don&#8217;t forget to add it to your project(s).</p>
<p>Open up <code>/path/to/mantis/config_inc.php</code>.  If it doesn&#8217;t exist, create it.  (If it doesn&#8217;t exist, you didn&#8217;t follow the installation directions.)  This file is used to override default settings.  It&#8217;s not distributed as part of Mantis, so when you upgrade, it won&#8217;t be overwritten. This is where you should have your database connection information, and where you would override the default colors, status/severity options, or any number of <a href="http://manual.mantisbt.org/manual.configuration.php" title="Mantis: Configuration Options">configurable settings</a>.</p>
<p>Add the following lines to <code>/path/to/mantis/config_inc.php</code>:</p>
<p><code class="codeblock">$g_source_control_account = 'svn';<br />
$g_source_control_regexp  = '/\b(?:bug|issue)\s*[#]{0,1}(\d+)\b/i';</code></p>
<p>What does it all mean?  (Some credit is due <a href="http://www.digitalpeer.com/id/mantis" title="Digitalpeer.com: Mantis and SVN Integration">Digitalpeer</a> for helping me through this.  I found it just as I was getting the integration working.  It would have saved some time.)</p>
<dl>
<dt><code>$g_source_control_account</code></dt>
<dd>This is the user we created in Mantis.</dd>
<dt><code>$g_source_control_regexp</code></dt>
<dd>This is the regular expression Mantis will match against the log message.  This is an optional setting; the default is <code>/\bissue [#]{0,1}(\d+)\b/i</code>.</dd>
</dl>
<h4>Using a custom RegExp</h4>
<p>You&#8217;ll notice I defined a regular expression different from the default.  I wanted to not only match the string &#8220;issue #1337&#8243;, but to be a bit more liberal, matching the phrase &#8220;bug #1337&#8243; too.  For those of you savy enough to craft your own expressions, the first capturable group <em>must</em> be the bug number, or the script won&#8217;t work.  (This is hard-coded into Mantis.)  Hence the non-capturing group <code>(?:bug|issue)</code>. </p>
<h4>Automatically closing tickets</h4>
<p>These custom settings lay the groundwork for Mantis to automatically add comments to tickets based on SVN log messages. There are additional settings we can use to get Mantis to resolve tickets automatically too, based on a different regular expression. To enable this behavior, add the following lines to <code>/path/to/mantis/config_inc.php</code>:</p>
<p><code class="codeblock">$g_source_control_set_status_to     = RESOLVED;<br />
$g_source_control_set_resolution_to = FIXED;<br />
$g_source_control_fixed_regexp  = '/\bfix(?:ed|es)\s+(?:bug|issue)?\s*[#]{0,1}(\d+)\b/i';</code></p>
<dl>
<dt><code>$g_source_control_set_status_to</code></dt>
<dd>The status to set the ticket to.  Use <code>CLOSED</code> if you prefer.</dd>
<dt><code>$g_source_control_set_resolution_to</code></dt>
<dd>The resolution attached to the ticket.  There are constants defined for each built-in resolution.  You may use a different one, but <code>FIXED</code> makes the most sense.</dd>
<dt><code>$g_source_control_fixed_regexp</code></dt>
<dd><em>This is an undocumented setting.</em> The default is to be equal to <code>$g_source_control_regexp</code>, but I only wanted certain tickets to be automatically closed, so I used a different regular expression.  My expression matches &#8220;fixes issue #1337&#8243;, &#8220;fix bug #1337&#8243;, or simply &#8220;fixed #1337&#8243;.  (Plus several iterations on those words.) The ticket number must be the first captured group. Altering the expression to also accept the words &#8220;solved&#8221; and &#8220;solves&#8221; is left as an exercise for the reader.</dd>
</dl>
<h4>Testing Mantis</h4>
<p>Before we go further, let&#8217;s make sure we implemented the Mantis settings properly.  Run the following from the command line (alter the paths, of course)<br />
<code class="codeblock"><strong>%&gt;</strong>&nbsp;/path/to/php /path/to/mantis/core/checkin.php &lt;&lt;&lt; "My web monkey fixed issue #1337 by accident."</code>
</p>
<p>If you&#8217;ve configured Mantis correctly, there should be a new comment on ticket #1337.</p>
<h3>Connecting the pieces</h3>
<p>Now that we have Mantis set to accept log messages from our version control system, we need to connect Subversion to it.  Remember the hooks from the beginning of this article? We&#8217;re going to write one.  I used Bash script.  (Be nice, I&#8217;m still learning Bash.)</p>
<p>Save the following file to <code>/path/to/svn/hooks/post-commit</code> (no file extension):</p>
<p><code class="codeblock">#!/bin/bash<br />
&nbsp;<br />
REPOS="$1"<br />
REV="$2"<br />
&nbsp;<br />
log=$(svnlook log -r $REV $REPOS)<br />
&nbsp;<br />
/usr/bin/php -q /var/bugtracker/core/checkin.php &lt;&lt;&lt; "$log"</code></p>
<h4>What is <code>svnlook</code>?</h4>
<p>The program <code>svnlook</code> is distributed as part of Subversion.  Given a revision and repository path as parameters, it will return various properties of the revision, such as the <a href="http://svnbook.red-bean.com/en/1.1/re42.html" title="Subversion Manual: svnlook author">author</a> or <a href="http://svnbook.red-bean.com/en/1.1/re44.html" title="Subversion Manual: svnlook changed">which files were changed</a>.  In this case we&#8217;re asking only for the <a href="http://svnbook.red-bean.com/en/1.1/re51.html" title="Subversion Manual: svnlook log">log message</a>.</p>
<h4>Permissions</h4>
<p>Give the file permission to executable by your repository.  This will be slightly different for each setup, but something similar to the following should do the trick:</p>
<p><code class="codeblock"><strong>%&gt;</strong>&nbsp;cd /path/to/svn/hooks<br />
<strong>%&gt;</strong>&nbsp;chmod 770 post-commit<br />
<strong>%&gt;</strong>&nbsp;chgrp svn post-commit</code></p>
<h4>More on <code>post-commit</code></h4>
<p>The <code>post-commit</code> hook takes two parameters: the repository path and the revision number. If you needed to run <code>post-commit</code> manually (testing your script!), it would look something like this for revision 746:</p>
<p><code class="codeblock"><strong>%&gt;</strong>&nbsp;/path/to/svn/hooks/post-commit /path/to/svn/repository_name 746</code></p>
<h3>SVN and Mantis in perfect harmony</h3>
<p>There you have it.  That&#8217;s how you integrate Subversion with Mantis.  If you have questions, feel free to leave a comment.</p>
<div class="seeAlso">
<p>Special thanks to the guys who spent time writing <em><a href="http://svnbook.red-bean.com/en/1.1/index.html" title="Version Control with Subversion (For Subversion 1.1)">Version Control with Subversion (For Subversion 1.1)</a></em>: Ben Collins-Sussman, Brian W. Fitzpatrick, and C. Michael Pilato. The world would be a better place if every piece of open source software was documented this well. (By contrast, the Mantis documentation is terribly out of date and rather disorganized.)</p>
<h4>A more advanced script</h4>
<p>I wasn&#8217;t content with having just a log message added to my Mantis tickets.  I wanted to know who did it, and what files were changed.  Thus, my actual script is a bit more complicated.  (Remember, I&#8217;m still learning Bash, so be nice.)<br />
<code class="codeblock">#!/bin/bash<br />
&nbsp;<br />
REPOS="$1"<br />
REV="$2"<br />
&nbsp;<br />
auth=$(svnlook author -r $REV $REPOS)<br />
dt=$(svnlook date -r $REV $REPOS)<br />
changed=$(svnlook changed -r $REV $REPOS)<br />
log=$(svnlook log -r $REV $REPOS)<br />
n=$'\n'<br />
/usr/bin/php -q /var/bugtracker/core/checkin.php &lt;&lt;&lt; "Changeset [${REV}] by $auth, $dt$n$log$n$changed"</code>
</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/feed/</wfw:commentRss>
		<slash:comments>117</slash:comments>
		</item>
		<item>
		<title>CAPTCHA the Internet</title>
		<link>http://alt-tag.com/blog/archives/2006/02/captcha-the-internet/</link>
		<comments>http://alt-tag.com/blog/archives/2006/02/captcha-the-internet/#comments</comments>
		<pubDate>Tue, 21 Feb 2006 06:04:27 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://tag-strategia.com/blog/?p=32</guid>
		<description><![CDATA[
CAPTCHA (an acronym for &#8220;Completely Automated Public Turing test to tell Computers and Humans Apart&#8221;) has been on my mind ever since Phil Windley suggested a graphical CAPTCHA would make a good web service. I thought there might be those willing to pay to use it. Well, it&#8217;s been done.
There is a need for this [...]]]></description>
			<content:encoded><![CDATA[<div style="float:right;border:2px solid black; margin: .2em .5em"><img src="/blog/blogimages/captcha_example.png" alt="CAPTCHA example" /></div>
<p><a href="http://en.wikipedia.org/wiki/CAPTCHA" title="Wikipedia: CAPTCHA">CAPTCHA</a> (an acronym for &#8220;Completely Automated Public Turing test to tell Computers and Humans Apart&#8221;) has been on my mind ever since Phil Windley suggested a graphical CAPTCHA would make a good web service. I thought there might be those willing to pay to use it. Well, <a href="http://www.google.com/search?q=captcha%20web%20service" title="Google captcha web service">it&#8217;s been done</a>.</p>
<p>There is a need for this type of test. Yahoo! and Hotmail use a CAPTCHA to stave off spammers when a user requests an email account. I suspect the most common use on other sites is an attempt block automated comment spam in blogs.</p>
<h4>CAPTCHA excludes legitimate users</h4>
<p>As the <a href="http://www.w3.org/TR/turingtest/" title="w3.org: Inaccessibility of CAPTCHA">W3C points out</a> graphical CAPTCHAs are a significant barrier to low-vision and blind users. Those with learning disabilities, such as dyslexia, may also be adversely affected. As visual CAPTCHAs become more sophisticated, busy, patterned background becomes more of an issue for color-blind users.</p>
<p>The U.S. Census Bureau <a href="http://www.census.gov/Press-Release/www/2002/cb02ff11.html" title="U.S. Census Bureau: Facts for Features, July 2002">estimated</a> that in 1997 about 7.7 million Americans had difficulty seeing the words and letters in an ordinary newspaper. The American Foundation for the blind <a href="http://www.afb.org/section.asp?SectionID=15&#038;DocumentID=1367" title="American Foundation for the Blind: Statistics and Sources for Professionals">reported</a> about 5 in 1,000 Americans are legally blind, and gives a low estimate of 1.5 million visually impaired computer users. That&#8217;s a fairly significant potential market to ignore.</p>
<p>Requiring users to interpret a visual CAPTCHA may lead to legal challenges. Earlier this month, the National Federation for the Blind <a href="http://www.dralegal.org/cases/private_business/nfb_v_target.php" title="Disability Rights Advocates: National Federation of the Blind v. Target">filed suit against Target</a>, claiming target.com discriminates by not being accessible to visually impaired users.</p>
<h4>Audio CAPTCHA</h4>
<p>Some companies are experimenting with audio CAPTCHAs, spelling out random letters with random noise in the background. However, aural disabilities are more common than visual ones, so the approach isn&#8217;t really more accessible. Speech recognition software is more advanced than character recognition, so the purported purpose of differentiating between humans and computers is not filled anyway.</p>
<h4>CAPTCHA is broken</h4>
<p>Several projects to crack common visual CAPTCHA algorithms, particularly <a href="http://www.captcha.net/" title="The CAPTCHA Project">The CAPTCHA Project</a> (by the Carnegie Mellon School of Computer Science), the <a href="http://www.cs.sfu.ca/~mori/research/gimpy/" title="Breaking a Visual CAPTCHA">UC Berkeley Computer Vision Group</a>, and <a href="http://sam.zoy.org/pwntcha/" title="PWNtcha - CAPTCHA decoder">Sam Hocevar&#8217;s PWNtcha</a>, have had good success. <a href="http://www.puremango.co.uk/cm_breaking_captcha_115.php" title="Breaking CAPTCHAs Without Using OCR">Howard Yeend</a> demonstrated a vulnerability in several public algorithms where he could reuse a solution several thousand times after manually solving it once.</p>
<p>Social engineering is often easier than fancy programming. The first widely recognized social engineering solution was &#8220;borrowing&#8221; CAPTCHAs from target sites and showing them at entry points to porn sites.  Visitors to porn sites would solve the CAPTCHAs, allowing spammers to get essentially free labor. Amazon&#8217;s <a href="http://www.mturk.com/mturk/welcome" title="Amazon Mechanical Turk">Mechanical Turk</a> (tagline: &#8220;Artificial Artificial Intelligence&#8221;), which gives micro-payments for simple tasks is an example of another way CAPTCHAs could be defeated. Even at a few cents per image, the cost may still be too high for spammers, but it is a demonstration that the process can be outsourced. After all, <a href="http://www.amazon.com/exec/obidos/redirect?link_code=as2&#038;path=ASIN/0374292884&#038;tag=tagstrategia-20&#038;camp=1789&#038;creative=9325" title="Amazon.com: The World is Flat">the world is flat</a>.</p>
<h4>What is the underlying purpose?</h4>
<p>The real reason for CAPTCHA is to screen undesirables. For low traffic sites,   it means preventing automated access. This can be accomplished in a relatively simple way: add a single required question to the comment submit form. Something like &#8220;What color was George Washington&#8217;s white horse?&#8221; or &#8220;Enter the fourth word in this sentence.&#8221; This is enough to make the form non-standard, thus unusable by generic bots. Bypassing this added security would be very easy for spammers, the advantage is the relative obscurity of most blogs. To target multiple blogs, a spammer would need to address each one individually; individual attention is unlikely, so I suggest this method is the easiest for bloggers with a knowledge of web programming, and is as accessible as a comment form without a CAPTCHA.</p>
<p>Major sites like Yahoo! and Google have a bigger problem. After all, they are targets both because of the value of their services, and their size. When it first launched Gmail, Google limited accounts to those who had been invited by other active users. Initially there was a good bit of commotion in the tech community as gmail.com addresses became a sign of prestige. The invitation system allows Google to track which users may be abusing the service, and which users invited the abusers. Google has gone a step further, and now allows potential users to have an invitation code sent to their mobile phones. The number of accounts requested per phone number can be tracked. The potential gain from a limited handful of throw-away email accounts, and the cost of mobile phones (even disposable ones) is enough to deter spammers, because less troublesome alternatives exist.</p>
<p>If you look at <a href="https://www.google.com/accounts/SmsMailSignup1" title="Create a Google Account">Google&#8217;s account request page</a>, you&#8217;ll see a CAPTCHA there. Google responsibly offers a way for users with disabilities to bypass the CAPTCHA, although it involves human-to-human interaction (and quite a bit more time) to complete&#8212;a costly alternative.</p>
<h4>Real solutions</h4>
<p>Several solutions to the problems with CAPTCHA have been <a href="http://www.w3.org/TR/turingtest/#solutions" title="w3.org: Inaccessibility of CAPTCHA (solutions)">proposed</a> and <a href="http://www.standards-schmandards.com/index.php?2005/01/01/11-captcha" title="Standards-Schmandards: Proposal for an Accessible Captcha">debated</a>. Most have major cost or accessibility problems.</p>
<p>It would seem the only good solution is some sort of federated identity system, which is really just offloading the trouble of user validation to someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2006/02/captcha-the-internet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE DOM Bugs</title>
		<link>http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/</link>
		<comments>http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/#comments</comments>
		<pubDate>Wed, 08 Feb 2006 05:40:41 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://tag-strategia.com/blog/?p=31</guid>
		<description><![CDATA[I&#8217;ve been working on a Javascript project where it&#8217;s necessary to create input elements (radio buttons and checkboxes) dynamically. With a functional DOM, it takes only a couple of lines of code, and works fine in Firefox and Safari. Too bad IE isn&#8217;t as DOM compatible as it claims to be.
After several searches, I discovered [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a Javascript project where it&#8217;s necessary to create <code>input</code> elements (radio buttons and checkboxes) dynamically. With a functional <abbr title="Document Object Model">DOM</abbr>, it takes only a couple of lines of code, and works fine in Firefox and Safari. Too bad IE isn&#8217;t as DOM compatible as it claims to be.</p>
<p>After several searches, I discovered <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/name_2.asp" title="MSDN Reference: name attribute">IE doesn&#8217;t allow the <code>name</code> attribute to be changed</a> after the element is created&#8212;and it can&#8217;t be set in a DOM compatible way during creation.</p>
<p>Bennett McElwee <a href="http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/" title="Semicolon: Setting the &quot;name&quot; attribute in Internet Explorer">suggested a solution in his blog</a> that is nicely cross-browser; anything other than IE throws an exception and gets created properly. (I suspect modifying the parent node&#8217;s <code>innerHTML</code> would work as well.)</p>
<p><code class="codeblock"><span class="keyword">function</span> <span class="function">createElement</span>(type, name) {<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">var</span> element = <span class="keyword">null</span>;<br />
<br />&nbsp;&nbsp;&nbsp;<span class="keyword">try</span> {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">// First try the IE way; if this fails then use the standard way</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;element = <span class="keyword">document</span>.<span class="function">createElement</span>(<span class="string">&#39;&lt;&#39;</span>+type+<span class="string">&#39; name=&quot;&#39;</span>+name+<span class="string">&#39;&quot;>&#39;</span>);<br />
&nbsp;&nbsp;&nbsp;} <span class="keyword">catch</span> (e) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">// Probably failed because we're not running on IE</span><br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">if</span> (!element) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;element = <span class="keyword">document</span>.<span class="function">createElement</span>(type);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;element.name = name;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">return</span> element;<br />
}</code></p>
<h3>And your <code>type</code> attribute too</h3>
<p>Another part of the project requires we transform checkboxes to radio buttons and hidden fields. This could be accomplished through a page reload, but it&#8217;s overkill for such a small change. Once again, in truly DOM-compliant browsers, this requires only a couple of lines of code:</p>
<p><code class="codeblock">element.<span class="function">setAttribute</span>(<span class="string">&quot;type&quot;</span>, <span class="string">&quot;radio&quot;</span>);</code></p>
<p>The <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/name_2.asp" title="MSDN Reference: name attribute">MSDN reference for the <code>type</code> attribute</a> says:</p>
<blockquote cite="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/name_2.asp"><p>As of Microsoft Internet Explorer 5, the <code>type</code> property is read/write-once, but only when an <code>input</code> element is created with the <code>createElement</code> method and before it is added to the document.</p></blockquote>
<p><a href="http://www.quirksmode.org/home.shtml" title="QuirksMode.org">QuirksMode</a> has a <a href="http://www.quirksmode.org/bugreports/archives/2006/01/Changing_the_type_of_an_input_field.html">bug report</a> for this, complete with <a href="http://stijn.gamerzheaven.nl/tests/JS2.htm">test page</a> and workaround submitted by Stijn Peeters.  Stijn admits the workaround needs a little bit of cleanup.</p>
<p>Essentially, his solution is to always remove the element, and recreate a modified one. (See the bug above!) Here&#8217;s my solution:</p>
<p><code class="codeblock"><span class="keyword">try</span> {<br />
&nbsp;&nbsp;&nbsp;element.<span class="function">setAttribute</span>(<span class="string">&quot;type&quot;</span>, <span class="string">&quot;radio&quot;</span>);<br />
} <span class="keyword">catch</span> (e) {<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">var</span> newElement = <span class="keyword">null</span>;<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">var</span> tempStr = element.<span class="function">getAttribute</span>(<span class="string">&quot;name&quot;</span>);<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">try</span> {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newElement = <span class="keyword">document</span>.<span class="function">createElement</span>(<span class="string">&quot;&lt;input type=\&quot;&quot;</span> +typeStr+ <span class="string">&quot;\&quot; name=\&quot;&quot;</span> +tempStr+ <span class="string">&quot;\&quot;>&quot;</span>);<br />
&nbsp;&nbsp;&nbsp;} <span class="keyword">catch</span> (e) {}<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">if</span> (!newElement) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newElement = <span class="keyword">document</span>.<span class="function">createElement</span>(<span class="string">&quot;input&quot;</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newElement.<span class="function">setAttribute</span>(<span class="string">&quot;type&quot;</span>, <span class="string">&quot;radio&quot;</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newElement.<span class="function">setAttribute</span>(<span class="string">&quot;name&quot;</span>, tempStr);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;<span class="keyword">if</span> (tempStr = element.<span class="function">getAttribute</span>(<span class="string">&quot;value&quot;</span>)) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newElement.<span class="function">setAttribute</span>(<span class="string">&quot;value&quot;</span>, tempStr);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;element.parentNode.<span class="function">replaceChild</span>(newElement, element);<br />
}</code></p>
<div class="seeAlso">
<h3>Update:</h3>
<p>Aaron over at easy-reader.net <a href="http://www.easy-reader.net/archives/2005/09/02/death-to-bad-dom-implementations/" title="easy-reader.net: Death to bad DOM implementations">encountered the same problem</a> a few months before I did. His solution is similar, and the comments there are good. If only I had found it sooner!</div>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Safari &#8220;Debug&#8221; menu</title>
		<link>http://alt-tag.com/blog/archives/2006/02/safari-debug-menu/</link>
		<comments>http://alt-tag.com/blog/archives/2006/02/safari-debug-menu/#comments</comments>
		<pubDate>Tue, 07 Feb 2006 16:56:32 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tag-strategia.com/blog/?p=30</guid>
		<description><![CDATA[While trying to track down a Javascript bug in Safari, I was lamenting the lack of a Javascript console and DOM explorer. Then I found a tip on MacOSXHints.com, explaining how to enable the Debug menu. From the terminal command line, enter the following:
% defaults write com.apple.Safari IncludeDebugMenu 1
]]></description>
			<content:encoded><![CDATA[<p>While trying to track down a Javascript bug in Safari, I was lamenting the lack of a Javascript console and DOM explorer. Then I found a tip on <a href="http://www.macosxhints.com/article.php?story=20030110063041629" title="Mac OS X Hints: Enable the Safari debug menu">MacOSXHints.com</a>, explaining how to enable the Debug menu. From the terminal command line, enter the following:</p>
<p><code class="codeblock">% defaults write com.apple.Safari IncludeDebugMenu 1</code></p>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2006/02/safari-debug-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Bugs, Headers, and Such</title>
		<link>http://alt-tag.com/blog/archives/2006/01/php-bugs-headers-and-such/</link>
		<comments>http://alt-tag.com/blog/archives/2006/01/php-bugs-headers-and-such/#comments</comments>
		<pubDate>Tue, 10 Jan 2006 17:33:06 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://tag-strategia.com/blog/?p=25</guid>
		<description><![CDATA[We just resolved a series of related bugs in the web product we&#8217;re developing. I&#8217;m hoping by documenting the symptoms and solutions it may ease someone else&#8217;s fruitless search.
The application has a &#8220;skin&#8221; feature allowing non-technical users to customize colors, font, and a handful of other things easily accomplished with CSS. Rather than edit more [...]]]></description>
			<content:encoded><![CDATA[<p>We just resolved a series of related bugs in the web product we&#8217;re developing. I&#8217;m hoping by documenting the symptoms and solutions it may ease someone else&#8217;s fruitless search.</p>
<p>The application has a &#8220;skin&#8221; feature allowing non-technical users to customize colors, font, and a handful of other things easily accomplished with <abbr title="Cascading Style Sheet">CSS</abbr>. Rather than edit more than twenty other pages to add an extra <code>&lt;link /&gt;</code> tag, we chose to add the following line to the top of our primary CSS file:</p>
<p><code class="codeblock"><span class="keyword">@import</span>(<span class="string">&quot;custom.css&quot;</span>) screen;</code></p>
<p>Notice how we defined the media type for the imported CSS file as part of the import rule, as suggested by the <a href="http://www.w3.org/TR/REC-CSS2/cascade.html#at-import" title="W3.org: CSS2 Specification - @import">CSS2 specification</a>.</p>
<p>A little  more background: using a little bit of Apache magic courtesy of <code>mod_rewrite</code> in the <code>httpd.conf</code>, requests for the file <code>custom.css</code> are redirected to <code>custom.php</code>, in the same folder.</p>
<p><code class="codeblock">&lt;Directory &quot;/www/css&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;RewriteEngine on<br />
&nbsp;&nbsp;&nbsp;RewriteRule ^custom\.css$ custom.php [nc]<br />
&lt;/Directory&gt;</code></p>
<p>It didn&#8217;t work. Firefox&#8217;s Javascript Console was pointed directly to the problem: &#8220;The stylesheet http://localhost/css/custom.css was not loaded because its <abbr title="Multipurpose Internet Mail Extensions">MIME</abbr> type, &#8216;text/html&#8217;, is not &#8216;text/css&#8217;.&#8221; (Also, <code>custom.css</code> did not show up in Firefox&#8217;s built-in <abbr title="Document Object Model">DOM</abbr> Inspector.) The error was easily fixed, by adding the following line to <code>custom.php</code>:</p>
<p><code class="codeblock"><span class="function">header</span>(<span class="string">&quot;Content-type: text/css&quot;</span>);</code></p>
<p>The styles then loaded properly in Firefox (and Safari), but not in Internet Explorer. Browsing directly to <code>custom.css</code> worked fine in Firefox, but IE behaved oddly. It first acted as if it was about to download the file (oddly, the default action for the working CSS file), but then popped up a dialog saying the URL could not be found.</p>
<p>I then examined the <abbr title="HyperText Transfer Protocol">HTTP</abbr> headers, and compared them with a working file. (It&#8217;s off-topic for this post, but I stumbled across this while Googling for solutions. If you&#8217;re a geek and want to see some fun headers in the wild, visit <a href="http://www.nextthing.org/archives/2005/08/07/fun-with-http-headers" title="Andrew Wooster’s nextthing.org: Fun With HTTP Headers">Fun With HTTP Headers</a>.)</p>
<p>Headers unique to main.css (working):</p>
<p><code class="codeblock">Last-Modified: Mon, 09 Jan 2006 22:28:54 GMT<br />
ETag: "ce134-ed8-43c2e3a6"<br />
Accept-Ranges: bytes<br />
Content-Length: 3800<br />
X-Pad: avoid browser bug</code></p>
<p>Headers unique to custom.css (not working):</p>
<p><code class="codeblock">X-Powered-By: PHP/5.0.4<br />
Set-Cookie: PHPSESSID=uah38ktr3mgq3td5j6qmcdgjf3; path=/<br />
Expires: Thu, 19 Nov 1981 08:52:00 GMT<br />
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0<br />
Pragma: no-cache</code></p>
<p>The cookie is generated automatically by PHP because of the need to use session information as part of the customization process. But, this is a CSS file, so I want it to be cached by default. Adding the following line before <code>session_start()</code> is called hid the no-cache headers, and things began to work in IE almost as they should.</p>
<p><code class="codeblock"><span class="function">session_cache_limiter</span>(<span class="string">&quot;none&quot;</span>);</code></p>
<p>I said, &#8220;Almost.&#8221; After tweaking the headers, I could now visit the file directly in IE without the &#8220;URL not found&#8221; error. (Meaning, it attempted to download it, rather than display it, but it was a step in the right direction.) However, it would still not apply the styles from the imported CSS file.  It was difficult to debug as there were no error messages, and IE&#8217;s DOM tree is not consistent with <abbr title="World Wide Web Consortium">W3C</abbr> standards. The final piece&#8212;and I could find no documentation anywhere for this&#8212;was to strip the media type from the import statement (at the top of this post), making it:</p>
<p><code class="codeblock"><span class="keyword">@import</span>(<span class="string">&quot;custom.css&quot;</span>);</code></p>
<p>It sounds easy now that I write it, but this series of bugs cost several hours of work. I hope this post will save someone else similar trouble. (If you see something I missed, or know of a faster course we could have taken to solve this problem, feel free to add your comments!)</p>
]]></content:encoded>
			<wfw:commentRss>http://alt-tag.com/blog/archives/2006/01/php-bugs-headers-and-such/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
