<?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>Nani huyu? &#187; Code</title>
	<atom:link href="http://adam.kuert.net/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://adam.kuert.net</link>
	<description>That's a good question.  I don't think I have an answer yet.</description>
	<lastBuildDate>Wed, 14 Apr 2010 07:45:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google Tasks as a stand-alone desktop app</title>
		<link>http://adam.kuert.net/2009/02/23/google-tasks-as-a-stand-alone-desktop-app/</link>
		<comments>http://adam.kuert.net/2009/02/23/google-tasks-as-a-stand-alone-desktop-app/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 01:46:44 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://adam.kuert.net/?p=244</guid>
		<description><![CDATA[Contacts, calendars, and now Tasks Now that I have my contacts and calendar syncing to the cloud, the next step is a Todo list.  And I&#8217;ve finally settled on a todo list solution that works for me, my mac, and my mobile life style:  Google Tasks plus Fluid (PC users can use Google Chrome).  Google tasks is lightweight, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Contacts, calendars, and now Tasks</strong></p>
<p>Now that I have my <a href="http://adam.kuert.net/2009/02/23/google-sync-for-iphone/">contacts and calendar syncing to the cloud</a>, the next step is a Todo list.  And I&#8217;ve finally settled on a todo list solution that works for me, my mac, and my mobile life style:  <a href="http://gmailblog.blogspot.com/2008/12/new-in-labs-tasks.html">Google Tasks</a> plus <a href="http://fluidapp.com/">Fluid</a> (PC users can use <a href="http://www.google.com/chrome">Google Chrome</a>).  Google tasks is lightweight, simple, and mobile accessible.  Fluid creates stand-alone desktop apps from web site applications.</p>
<p><span id="more-244"></span></p>
<p>Here&#8217;s how some configurations will look when you&#8217;re done:</p>
<div id="attachment_252" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-252" title="google-tasks-gmail" src="http://adam.kuert.net/wp-content/uploads/2009/02/picture-3-300x130.png" alt="google-tasks-gmail" width="300" height="130" /><p class="wp-caption-text">Gmail Google Tasks</p></div>
<div id="attachment_251" class="wp-caption aligncenter" style="width: 299px"><img class="size-medium wp-image-251" title="google-tasks-iphone" src="http://adam.kuert.net/wp-content/uploads/2009/02/picture-21-289x300.png" alt="google-tasks-iphone" width="289" height="300" /><p class="wp-caption-text">iPhone Google Tasks</p></div>
<p><strong>What you&#8217;ll need</strong></p>
<ul>
<li><a href="http://gmail.com">A Gmail account</a></li>
<li><a href="http://fluidapp.com/">Fluid</a></li>
</ul>
<p><strong>How to make it work</strong></p>
<p><strong> </strong>You can create a fluid app using the following URL to mimic Google Tasks as it appears in Gmail:</p>
<blockquote><p>http://mail.google.com/tasks/ig?up_ShowTips=false&amp;lang=en&amp;country=us&amp;.lang=en&amp;.country=us&amp;synd=ig&amp;libs=I6gXJQFzsCg/lib/libcore.js,MJLTofH-Kpk/lib/libsetprefs.js&amp;extern_js=/extern_js/f/CgJlbhICdXMrMAo4ACwrMBI4ACwrMBM4ACw/UpcjQ5pVgbs.js&amp;view=home</p></blockquote>
<p>Or you can create a fluid app using the following URL to mimic Google Tasks for mobile devices:</p>
<blockquote><p><span style="text-decoration: line-through;">http://www.google.com/m#tasks</span></p>
<p>http://mail.google.com/tasks/iphone</p></blockquote>
<p>If you choose the later, you&#8217;ll need to set your User Agent to that of an iPhone, Gphone or other mobile device.  Here&#8217;s the latest iPhone User Agent string:</p>
<blockquote><p>Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11 Safari/525.20</p></blockquote>
<p><strong>What you might want</strong></p>
<p><strong> </strong>Once you&#8217;ve got a Google Tasks fluid app, you should consider the following fluid preferences:</p>
<ul>
<li>Application icon: <a href="http://www.flickr.com/photos/maxheadwound/3287800301/in/pool-fluid_icons">Google Tasks Fluid</a></li>
<li>Window Style: Chromeless (None)</li>
<li>Window Opacity: ~90%</li>
<li>Windows are draggable from anywhere: checked</li>
<li>Hide Status Bar (not a preference. see View menu)</li>
<li>Hide Tool Bar (also in the View menu)</li>
</ul>
<p>Now all I gotta do is watch Slumdog millionaire and I&#8217;ll be on my way.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kuert.net/2009/02/23/google-tasks-as-a-stand-alone-desktop-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XML examples in a WordPress blog</title>
		<link>http://adam.kuert.net/2009/02/19/xml-examples-in-a-wordpress-blog/</link>
		<comments>http://adam.kuert.net/2009/02/19/xml-examples-in-a-wordpress-blog/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 01:55:41 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://adam.kuert.net/?p=231</guid>
		<description><![CDATA[Let&#8217;s say you would like to post some XML in a blog post about, for example, XML in a Django template.  There&#8217;s a great plugin called WP-Syntax that adds syntax highlighting to code samples in your blog.  Once installed, you can use some code like this in your templates: &#60;xml&#62;Hello&#60;/xml&#62; Then switch over to HTML [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you would like to post some XML in a blog post about, for example, <a href="http://adam.kuert.net/2009/02/17/xml-in-a-django-template-using-a-custom-filters/">XML in a Django template</a>.  There&#8217;s a great plugin called <a href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a> that adds syntax highlighting to code samples in your blog.  Once installed, you can use some code like this in your templates:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hello<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Then switch over to HTML mode and wrap that code in a pre tag like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pre</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;xml&quot;</span> <span style="color: #000066;">escaped</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hello<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>But there&#8217;s a small catch</strong><br />
<span id="more-231"></span><br />
If you switch back and forth between HTML and Visual mode, you&#8217;ll lose that &#8216;escaped=&#8221;true&#8221;&#8216; attribute (probably a bug).  Then you&#8217;ll end up with double escaped code on you page like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>xml<span style="color: #ddbb00;">&amp;gt;</span>Hello<span style="color: #ddbb00;">&amp;lt;</span>/xml<span style="color: #ddbb00;">&amp;gt;</span></pre></div></div>

<p><strong>Solution?</strong></p>
<ul>
<li>Only work in HTML mode, so your code doesn&#8217;t get escaped in the first place  (Then you won&#8217;t need the escaped=&#8221;true&#8221; attribute either.  I think you can even disable Visual mode). </li>
<li>Write you post in Visual mode, then switch HTML mode, add your pre tags with escaped=&#8221;true&#8221; attribute, and then don&#8217;t switch back to Visual mode (that&#8217;s how I wrote this post).</li>
</ul>
<p>I don&#8217;t like either solution, but I prefer the second.</p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kuert.net/2009/02/19/xml-examples-in-a-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML in a Django template using a custom filters</title>
		<link>http://adam.kuert.net/2009/02/17/xml-in-a-django-template-using-a-custom-filters/</link>
		<comments>http://adam.kuert.net/2009/02/17/xml-in-a-django-template-using-a-custom-filters/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 01:56:30 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://adam.kuert.net/?p=58</guid>
		<description><![CDATA[Code should be readable. Recently, I had to make some changes to some XML that had been written in a Django template.  To avoid the xml being rendered by the browser as HTML, the code had been manually escaped, thus making the code rather unreadable. Sorry, no views The various documentation templates were being rendered [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Code should be readable.</strong></p>
<p>Recently, I had to make some changes to some XML that had been written in a <a href="http://www.djangoproject.com/">Django</a> template.  To avoid the xml being rendered by the browser as HTML, the code had been manually escaped, thus making the code rather unreadable.</p>
<p><span id="more-58"></span><br />
<strong>Sorry, no views</strong></p>
<p>The various documentation templates were being rendered using direct_to_template so I couldn&#8217;t move the XML to a view and let Django&#8217;s autoescaping take over.  Besides, the XML is legitamately part of the static content of the page and shouldn&#8217;t be in the view.</p>
<p><strong>Custom filters can be very misleading</strong></p>
<p>So I decided to write a custom filter to escape the XML as needed.  But I kept running into this error:</p>
<p>&#8216;my_filter&#8217; is not a valid tag library: Could not load template library from django.templatetags.doc_code, No module named my_filter</p>
<p>Which made me think I had a path issue, or a misplaced file, or a missing __init__.py.  But all my initial guesses checked out.  Turns out that django spits out a &#8216;No module&#8217; error when there are errors in the filter code.  Very misleading.</p>
<p><strong>Now it&#8217;s looking good</strong></p>
<p>So the final result is a django  template that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Here's some XML:<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
{% filter xmldoc %}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;children<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Koes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Chris<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/child<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/children<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
{% endfilter %}</pre></div></div>

<p>And the custom filter looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span> <span style="color: #ff7700;font-weight:bold;">import</span> Library
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span>.<span style="color: black;">defaultfilters</span> <span style="color: #ff7700;font-weight:bold;">import</span> stringfilter
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">sax</span>.<span style="color: black;">saxutils</span> <span style="color: #ff7700;font-weight:bold;">import</span> escape
&nbsp;
register = Library<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
@register.<span style="color: #008000;">filter</span>
@stringfilter
<span style="color: #ff7700;font-weight:bold;">def</span> xmldoc<span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> escape<span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
xmldoc.<span style="color: black;">is_safe</span> = <span style="color: #008000;">True</span></pre></div></div>

<p>Now the XML is readable to the users and the developers.</p>
<p><strong>My sources</strong></p>
<ul>
<li><a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters">Django custom filters</a></li>
<li><a href="http://forum.webfaction.com/viewtopic.php?pid=3604">I was missing an import in my filter</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://adam.kuert.net/2009/02/17/xml-in-a-django-template-using-a-custom-filters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tulsa Downtown Food</title>
		<link>http://adam.kuert.net/2008/08/08/tulsa-food-downtown/</link>
		<comments>http://adam.kuert.net/2008/08/08/tulsa-food-downtown/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 16:55:00 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://adam.kuert.net/?p=32</guid>
		<description><![CDATA[It has come to my attention that people in Tulsa who work downtown are not aware of many of the great places to eat downtown for lunch.  So I created a map of all the places I know about.  Please let me know if I missed anything. Tulsa Downtown Food Map I built the site using Django [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>It has come to my attention that people in Tulsa who work downtown are not aware of many of the great places to eat downtown for lunch.  So I created a map of all the places I know about.  Please let me know if I missed anything.</p>
<p><a title="Tula Downtown Food Map" href="http://www.tulsafoodmaps.com/" target="_blank">Tulsa Downtown Food Map</a></div>
<p>I built the site using <a href="http://www.djangoproject.com">Django</a> and <a href="http://code.google.com/apis/maps/">Google Maps API</a></p>
]]></content:encoded>
			<wfw:commentRss>http://adam.kuert.net/2008/08/08/tulsa-food-downtown/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
