<?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"
	>

<channel>
	<title>Vanderbrew &#187; Code</title>
	<atom:link href="http://vanderbrew.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://vanderbrew.com/blog</link>
	<description>Beer, Food, Code, Writing, Creativity, Life</description>
	<pubDate>Thu, 16 Oct 2008 07:10:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Marking Duplicate Web Archive Items in Yojimbo</title>
		<link>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/</link>
		<comments>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 22:15:50 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/</guid>
		<description><![CDATA[I saw Archive Flagged Items from NetNewsWire into Yojimbo (via) and found it a really neat tool. I've started using it to keep a more permanent record of interesting new articles.
I have lots of news articles flagged and I've had the import crash on me before for various reasons which has resulted in some duplicate [...]]]></description>
			<content:encoded><![CDATA[<p>I saw <a href="http://snippets.dzone.com/posts/show/5001">Archive Flagged Items from NetNewsWire into Yojimbo</a> (<a href="http://ranchero.com/?comments=1&#038;postid=1801">via</a>) and found it a really neat tool. I've started using it to keep a more permanent record of interesting new articles.</p>
<p>I have lots of news articles flagged and I've had the import crash on me before for various reasons which has resulted in some duplicate web archives being created. The reason for the duplicates is usually because there was a redirect to the actual article that Yojimbo followed, so the URL in NetNewsWire doesn't match the Yojimbo URL and checking for existing items on load doesn't work.</p>
<p>This was a great opportunity for me to explore <a href="http://rubyosa.rubyforge.org/" title="RubyOSA: Ruby/AppleEvent Bridge">RubyOSA</a> and continue learning <a href="http://www.ruby-lang.org/" title="Ruby Programming Language">Ruby</a> so I wrote a script to detect duplicate web archives based on name and mark them with a "Duplicate" label.</p>
<div class="igBar"><span id="lruby-2"><a href="#" onclick="javascript:showCodeTxt('ruby-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-2">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#!/usr/local/bin/ruby</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'rubygems'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'rbosa'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">yojimbo = OSA.<span style="color:#9900CC;">app</span><span style="color:#006600; font-weight:bold;">&#40;</span>'Yojimbo'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">seen = Hash.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># Duplicate label details</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">duplicateLabelName = 'Duplicate'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># An almost painful red</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">duplicateLabelColor = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;color:#800000;">65535</span>, <span style="color:#006666;color:#800000;">1536</span>, <span style="color:#006666;color:#800000;">4628</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">duplicateLabel = <span style="color:#0000FF; font-weight:bold;">nil</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># See if we already have a label named 'Duplicate' and save it</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">yojimbo.<span style="color:#9900CC;">labels</span>.<span style="color:#9900CC;">map</span>&nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span> |l| l.<span style="color:#9900CC;">name</span> == duplicateLabelName &amp;&amp; duplicateLabel = l <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># Make a label if we don't have it already</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>duplicateLabel.<span style="color:#0000FF; font-weight:bold;">nil</span>?<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; duplicateLabel = yojimbo.<span style="color:#9900CC;">make</span><span style="color:#006600; font-weight:bold;">&#40;</span>OSA::Yojimbo::Label,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">nil</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :color =&gt; duplicateLabelColor,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :name =&gt; duplicateLabelName<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">yojimbo.<span style="color:#9900CC;">web_archive_items</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |f|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>seen.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>f.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Found a duplicate: #{f.name}"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; f.<span style="color:#9900CC;">label</span>= duplicateLabel</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; seen<span style="color:#006600; font-weight:bold;">&#91;</span>f.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">label</span>= duplicateLabel</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; seen<span style="color:#006600; font-weight:bold;">&#91;</span>f.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#93;</span> = f</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Testing Syntax Highlighting</title>
		<link>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/</link>
		<comments>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 14:31:24 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/</guid>
		<description><![CDATA[I'd like to start posting code on my blog so I'm testing out a syntax highlighter plugin. This post will likely go through several iterations as I see what it can do and how to do it.
Here's some ruby:
PLAIN TEXT
RUBY:




def addPages&#40;urls&#41;


&#160; &#160; return false unless urls


&#160; &#160; urls.each&#123; &#124;u&#124; @queue &#60;&#60;PageFactory.newPage&#40;u&#41; &#125;


&#160; &#160; @queue.uniq! # [...]]]></description>
			<content:encoded><![CDATA[<p>I'd like to start posting code on my blog so I'm testing out a syntax highlighter plugin. This post will likely go through several iterations as I see what it can do and how to do it.</p>
<p>Here's some ruby:</p>
<div class="igBar"><span id="lruby-7"><a href="#" onclick="javascript:showCodeTxt('ruby-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-7">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> addPages<span style="color:#006600; font-weight:bold;">&#40;</span>urls<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#9966CC; font-weight:bold;">unless</span> urls</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urls.<span style="color:#9900CC;">each</span><span style="color:#006600; font-weight:bold;">&#123;</span> |u| @queue &lt;&lt;PageFactory.<span style="color:#9900CC;">newPage</span><span style="color:#006600; font-weight:bold;">&#40;</span>u<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @queue.<span style="color:#9900CC;">uniq</span>! <span style="color:#008000; font-style:italic;"># Get rid of dupes.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here's some Perl:</p>
<div class="igBar"><span id="lperl-8"><a href="#" onclick="javascript:showCodeTxt('perl-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PERL:</span>
<div id="perl-8">
<div class="perl">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@text</span> = <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'here'</span>, <span style="color: #ff0000;">'are'</span>, <span style="color: #ff0000;">'some'</span>, <span style="color: #ff0000;">'words'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$offset</span> = <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span style="color: #000066;">print</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/join.html"><span style="color: #000066;">join</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">' '</span>, <a href="http://www.perldoc.com/perl5.6/pod/func/map.html"><span style="color: #000066;">map</span></a> <span style="color: #66cc66;">&#123;</span> choppedCase<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #0000ff;">@text</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Convert a string to &quot;ChOpPeD cAsE&quot;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">sub</span> choppedCase</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$word</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span style="color: #000066;">shift</span></a>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@chars</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span style="color: #000066;">split</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$word</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$char_count</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/scalar.html"><span style="color: #000066;">scalar</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">@chars</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span> = <span style="color: #0000ff;">$offset</span>; <span style="color: #0000ff;">$i</span> &lt;<span style="color: #0000ff;">$char_count</span>; <span style="color: #0000ff;">$i</span>+=<span style="color: #cc66cc;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">$chars</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/uc.html"><span style="color: #000066;">uc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$chars</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Track odd length words so we constantly alternate in a string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$char_count</span> % <span style="color: #cc66cc;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$offset</span> = <span style="color: #0000ff;">$offset</span> == <span style="color: #cc66cc;color:#800000;">0</span> ? <span style="color: #cc66cc;color:#800000;">1</span> : <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/return.html"><span style="color: #000066;">return</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/join.html"><span style="color: #000066;">join</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">@chars</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here's some PHP</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showCodeTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Pattern to match the directory path that a file is in</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$dir_pattern</span> = <span style="color:#FF0000;">"@(/.*)/[^/]*$@"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Take a path that's (possibly) relative to the directory that the script is executing in</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// and convert it to an absolute path.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> absolutize<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/global"><span style="color:#000066;">global</span></a> <span style="color:#0000FF;">$dir_pattern</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Only operate on paths that are relative</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/substr"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#FF0000;">'.'</span> &amp;&amp; <a href="http://www.php.net/preg_match"><span style="color:#000066;">preg_match</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$dir_pattern</span>, <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'PHP_SELF'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0000FF;">$matches</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$path</span> = <a href="http://www.php.net/implode"><span style="color:#000066;">implode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">''</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$matches</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$path</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$path_bits</span> = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$path</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$elms</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path_bits</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$bit</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$bit</span> == <span style="color:#FF0000;">''</span> || <span style="color:#0000FF;">$bit</span> == <span style="color:#FF0000;">'.'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">continue</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$bit</span> == <span style="color:#FF0000;">'..'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/array_pop"><span style="color:#000066;">array_pop</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$elms</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">continue</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$elms</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>= <span style="color:#0000FF;">$bit</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Push an empty string on top so that we get a leading / when we implode</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array_unshift"><span style="color:#000066;">array_unshift</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$elms</span>, <span style="color:#FF0000;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <a href="http://www.php.net/implode"><span style="color:#000066;">implode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$elms</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I just realized that I've coded in all three of these languages this week - plus JavaScript (can't find a good sample to post).</p>
<p><b>Update</b><br />
JavaScript</p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showCodeTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// Add commas to a long number to make it more readable.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// Currently only supports whole numbers.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> addCommas = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>aNumber<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">// Convert our number to an array and reverse it so that</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">// we can easily work from most significant digits down</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">// to least significant</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> bitsR = <span style="color: #66cc66;">&#40;</span>aNumber.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">reverse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = bitsR.<span style="color: #006600;">length</span> - <span style="color: #CC0000;color:#800000;">1</span>; i&gt;<span style="color: #CC0000;color:#800000;">2</span>; i--<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>i % <span style="color: #CC0000;color:#800000;">3</span> == <span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; bitsR.<span style="color: #006600;">splice</span><span style="color: #66cc66;">&#40;</span>i, <span style="color: #CC0000;color:#800000;">0</span>, <span style="color: #3366CC;">','</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">// Return our array with commas added back to the proper order</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">// for display on the screen.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> bitsR.<span style="color: #006600;">reverse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Body classes for page specific CSS</title>
		<link>http://vanderbrew.com/blog/2007/06/12/body-classes-for-page-specific-css/</link>
		<comments>http://vanderbrew.com/blog/2007/06/12/body-classes-for-page-specific-css/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 04:35:30 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2007/06/12/body-classes-for-page-specific-css/</guid>
		<description><![CDATA[I generally write common CSS that applies to all pages and handle special overrides for a particular page or section by setting a class on the body tag

&#60;body class="pressRelease"&#62;

Then if you usually style h2's on the site with a border-bottom, you can easily make press release h2's not have a border-bottom

h2 { border-bottom: 1px solid [...]]]></description>
			<content:encoded><![CDATA[<p>I generally write common CSS that applies to all pages and handle special overrides for a particular page or section by setting a class on the body tag</p>
<p><code><br />
&lt;body class="pressRelease"&gt;<br />
</code></p>
<p>Then if you usually style h2's on the site with a border-bottom, you can easily make press release h2's not have a border-bottom</p>
<p><code><br />
h2 { border-bottom: 1px solid #666; }<br/><br />
body.pressRelease h2 { border-bottom: none; }<br />
</code></p>
<p>This lets you easily group page or section specific overrides together and identify them in a contextual way.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2007/06/12/body-classes-for-page-specific-css/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CSS/JS Grabbag</title>
		<link>http://vanderbrew.com/blog/2007/02/07/cssjs-grabbag/</link>
		<comments>http://vanderbrew.com/blog/2007/02/07/cssjs-grabbag/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 05:57:36 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2007/02/07/cssjs-grabbag/</guid>
		<description><![CDATA[I've been doing some HTML/CSS/JS work for various clients at work recently and I've come across some very useful articles/tips for doing stuff. I'm sure none of this is new but if I only encountered it recently, maybe others haven't yet.
Selfclearing Elements - Don't you hate it when you float an element and the container [...]]]></description>
			<content:encoded><![CDATA[<p>I've been doing some HTML/CSS/JS work for various clients at work recently and I've come across some very useful articles/tips for doing stuff. I'm sure none of this is new but if I only encountered it recently, maybe others haven't yet.</p>
<p><b>Selfclearing Elements</b> - Don't you hate it when you float an element and the container doesn't get the height correctly. Then, maybe you float the container, but that causes problems with other things. Then you try adding an element just to hang a clear on to fix it and now you're cluttering up your pristine markup with garbage... There is a <a href="http://positioniseverything.net/easyclearing.html">solution</a> and it's even elegant.</p>
<p><b>z-index/stacking</b> - So, if you want something to appear above something else on a page, you just give it a higher z-index, right? That's what I've always thought but I was never really satisfied with that because it didn't always work the way I expected it to. I didn't totally understand it so, when I had to fix something with z-indexes, I tended to just try different values in different places until I found something that works. No more. I found <a href="http://css-discuss.incutio.com/?page=OverlappingAndZIndex">Overlapping and Z index</a> and now it all makes sense.</p>
<p><b>JavaScript the JSON way</b> - It's pretty amazing how far the JavaScript language has come in the last few years. One of the coolest things I've seen recently is the technique for organizing your code with JSON to prevent function name collision and make things generally cleaner. Dustin Diaz has a great <a href="http://www.dustindiaz.com/json-for-the-masses/">introduction</a> to the method that will get you rolling with the JSON goodness.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2007/02/07/cssjs-grabbag/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Douglas Crockford - JavaScript Lecture Videos</title>
		<link>http://vanderbrew.com/blog/2007/02/07/douglas-crockford-javascript-lecture-videos/</link>
		<comments>http://vanderbrew.com/blog/2007/02/07/douglas-crockford-javascript-lecture-videos/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 05:36:57 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Internet]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2007/02/07/douglas-crockford-javascript-lecture-videos/</guid>
		<description><![CDATA[I've been doing JavaScript programming off and on for a number of years and I feel pretty competent. I know I don't have a super deep grasp of the fundamentals but I understand how AJAX works, the benefits of sandboxing your code with JSON and some of how libraries such as jQuery and prototype work. [...]]]></description>
			<content:encoded><![CDATA[<p>I've been doing JavaScript programming off and on for a number of years and I feel pretty competent. I know I don't have a super deep grasp of the fundamentals but I understand how AJAX works, the benefits of sandboxing your code with JSON and some of how libraries such as <a href="http://www.jquery.com">jQuery</a> and <a href="http://www.prototypejs.org/">prototype</a> work. I knew that there were gaps and that I didn't have the real grounding necessary to totally understand how everything works but I never thought much about how to go about filling in the blanks.</p>
<p>Then I came across this <a href="http://yuiblog.com/blog/2007/01/24/video-crockford-tjpl/">blog post</a> yesterday. I've watched parts 1 and 2 and I'm really impressed by how Douglas Crockford clearly and succinctly presents very basic info on the language and is laying the groundwork for a much better understanding of it. I know feel like I've got a really good grasp on concepts that before I sort of understood.</p>
<p>The lectures are very watchable and I really encourage anyone who's interested in learning JavaScript or getting a better understanding of the fundamentals to watch them.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2007/02/07/douglas-crockford-javascript-lecture-videos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails Plugin - JavaScriptFunction - Updated!</title>
		<link>http://vanderbrew.com/blog/2006/07/16/rails-plugin-javascriptfunction-updated/</link>
		<comments>http://vanderbrew.com/blog/2006/07/16/rails-plugin-javascriptfunction-updated/#comments</comments>
		<pubDate>Sun, 16 Jul 2006 20:53:58 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/16/rails-plugin-javascriptfunction-updated/</guid>
		<description><![CDATA[So, while I was doing some work with my plugin, I realized that there were a couple things that could be improved.

You had to specify parameters as an array, even if there was only one parameter.
You had to specify the body as a string - making it cumbersome to create multi-statement functions.

Well, both of those [...]]]></description>
			<content:encoded><![CDATA[<p>So, while I was doing some work with my <a href="/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/">plugin</a>, I realized that there were a couple things that could be improved.</p>
<ol>
<li>You had to specify parameters as an array, even if there was only one parameter.</li>
<li>You had to specify the body as a string - making it cumbersome to create multi-statement functions.</li>
</ol>
<p>Well, both of those issues are in the past. You can still use an array for parameters and string for body, but you can also use an array for body and a string for a (single) parameter - or any combination of such.</p>
<p>So, grab <a href="http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/">version 0.2</a> and have at it.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/16/rails-plugin-javascriptfunction-updated/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My First Rails Plugin - JavaScriptFunction</title>
		<link>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/</link>
		<comments>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/#comments</comments>
		<pubDate>Sat, 15 Jul 2006 20:33:53 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/</guid>
		<description><![CDATA[I'm working on a Rails app using RJS and Prototype Window Class. I needed to be able to return an anonymous JavaScript function in my RJS template but when passing it in a string to page.call it kept getting quoted and didn't work right (as you would expect).
I solved it by creating a JavaScriptFunction class [...]]]></description>
			<content:encoded><![CDATA[<p>I'm working on a Rails app using RJS and <a href="http://prototype-window.xilinus.com/">Prototype Window Class</a>. I needed to be able to return an anonymous JavaScript function in my RJS template but when passing it in a string to <code>page.call</code> it kept getting quoted and didn't work right (as you would expect).</p>
<p>I solved it by creating a JavaScriptFunction class and helpers so that it's easily usable in an RJS template. Browse the <a href="http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/">plugin</a> or install it:</p>
<p><code>
<pre>
# With subversion
./script/plugin install -x http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/

# Without subversion
./script/plugin install http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/
</pre>
<p></code></p>
<p>To use it, just do:<br />
<code>
<pre>
page.call 'Dialog.confirm', "New Thing - do you want to add it?",
            { :windowParameters => { :width => 300 },
              :sokLabel => 'Yes',
              :cancelLabel => 'No',
              :buttonClass => 'myButtonClass',
              :id => 'myDialogId',
              :cancel => anonymous_javascript_function(:parameters => ["win"],
                         :body => "$('#{@element_id}').innerHTML = '#{escape_javascript @thing.name}'"),
              :sok => anonymous_javascript_function(:parameters => ["win"],
                         :body => "return true;")
            }
</pre>
<p></code></p>
<p>It's my first plugin so I'm open to any feedback you have about it. Please use the <a href="/blog/contact/">Contact form</a> to reach me.</p>
<p>Note - the keys <code>:sokLabel</code> and <code>:sok</code> shouldn't have an 's' in the front for real implementation with the JS library - I did that to prevent an emoticon from appearing thanks to WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creative Writing vs Coding</title>
		<link>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/</link>
		<comments>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/#comments</comments>
		<pubDate>Sat, 15 Jul 2006 06:59:48 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Creativity]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Writing]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/</guid>
		<description><![CDATA[So, as you probably noticed, my creative writing on the site has fallen off quite a bit lately. It seems that I can focus on creative writing or I can focus on coding, but I'm not so good at doing both at the same time.
I'm going to be focusing on coding for the foreseeable future [...]]]></description>
			<content:encoded><![CDATA[<p>So, as you probably noticed, my creative writing on the site has fallen off quite a bit lately. It seems that I can focus on creative writing or I can focus on coding, but I'm not so good at doing both at the same time.</p>
<p>I'm going to be focusing on coding for the foreseeable future because that's where I want to allocate my time right now. I've got a big unfinished project in that arena and it's time to make some progress on it, hopefully contributing back to the community as I go.</p>
<p>I hope to return to more consistent writing in the future and I'm sure that I'll have the occasional line here and there but I don't think that there will be very many for a few months. I've created a <a href="/blog/category/creativity/feed/">Creativity feed</a> and if you're just visiting for the writing I encourage you to simply track that with your feed aggregator.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails - Edit In Place with Local Autocomplete</title>
		<link>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/</link>
		<comments>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/#comments</comments>
		<pubDate>Mon, 10 Jul 2006 00:12:40 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/</guid>
		<description><![CDATA[I purchased a copy of Chad Fowler's excellent Rails Recipes recently. He's got a few recipes dealing with edit in place and one about building local autocomplete. I pulled these recipes together into a single solution that gives me an edit in place with local autocomplete functionality.
Rails Helper
I created a couple Rails helper functions to [...]]]></description>
			<content:encoded><![CDATA[<p>I purchased a copy of Chad Fowler's excellent <a href="http://www.pragmaticprogrammer.com/titles/fr_rr/index.html">Rails Recipes</a> recently. He's got a few recipes dealing with edit in place and one about building local autocomplete. I pulled these recipes together into a single solution that gives me an edit in place with local autocomplete functionality.</p>
<p><b>Rails Helper</b><br />
I created a couple Rails helper functions to encapsulate the functionality so I can call it with one function in my view. View the <a href="/Projects/InPlaceEditorWithAutocomplete/ruby/application_helper.rb">source</a>, with <a href="/Projects/InPlaceEditorWithAutocomplete/docs/application_helper_rb.html">syntax highlighting</a>.</p>
<p><b>JavaScript</b><br />
I had to extend the existing Scriptaculous code to support my specific functionality. View the <a href="/Projects/InPlaceEditorWithAutocomplete/javascript/in_place_editor_with_local_autocomplete.js">source</a>, with <a href="/Projects/InPlaceEditorWithAutocomplete/docs/in_place_editor_with_local_autocomplete_js.html">syntax highlighting</a>.</p>
<p><b>Implementation</b><br />
Now, you just include the JS in your page and use the new helper to build the UI component.</p>
<p><code>
<pre>
<%= in_place_editor_field_with_local_autocomplete :recipe,
                                                  :cookbook_title,
                                                  {},
                                                  {},
                                                  {
                                                    :catalog => 'cookbooks',
                                                    :fullSearch => true,
                                                    :frequency => 0,
                                                    :minChars => 2
                                                  }
%>
</pre>
<p></code></p>
<p><b>Update</b><br />
Ola Bini has developed an <a href="http://opensource.ki.se/inplacecompleter.html">InPlaceEditor with Autocomplete</a> <a href="http://svn.ki.se/rails/plugins/in_place_completer/">plugin</a> for Rails. Definitely worth a look.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;We found no matches for phil&apos;s phalse bottom. Below are results for pool.&#8221;</title>
		<link>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/</link>
		<comments>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/#comments</comments>
		<pubDate>Wed, 18 Jan 2006 03:45:03 +0000</pubDate>
		<dc:creator>matt</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/</guid>
		<description><![CDATA[So, I was on Amazon yesterday, looking for a false bottom for making a lauter tun. I was awfully surprised to see that result. I'm guessing that it's a perfect example of what can happen when suggestion code goes wrong, probably due to the combination of specific and uncommon search terms.
Even more interesting is the [...]]]></description>
			<content:encoded><![CDATA[<p>So, I was on Amazon yesterday, looking for a false bottom for making a <a href="http://www.northernbrewer.com/docs/html/sparging.html#id2847835">lauter tun</a>. I was awfully surprised to see that result. I'm guessing that it's a perfect example of what can happen when suggestion code goes wrong, probably due to the combination of specific and uncommon search terms.</p>
<p>Even more interesting is the fact that I get this result when searching in the <a href="http://www.amazon.com/gp/browse.html/102-8458530-1577765?node=286168">Outdoor Living</a> area of Amazon's site, but not when searching from the "homepage". I guess that it's just a testament to the complexity of the site and how segragated the functionality of different stores is.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
