<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.2" -->
<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/"
	>

<channel>
	<title>Bogle's Blog</title>
	<link>http://thebogles.com/blog</link>
	<description>Things I care about</description>
	<pubDate>Mon, 08 Feb 2010 18:45:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>
	<language>en</language>
			<item>
		<title>Section Headers for Android ListViews</title>
		<link>http://thebogles.com/blog/2010/02/section-headers-for-android-listviews/</link>
		<comments>http://thebogles.com/blog/2010/02/section-headers-for-android-listviews/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 07:38:48 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2010/02/section-headers-for-android-listviews/</guid>
		<description><![CDATA[When building the Android version of the iLike Concert app, I wanted to have day headers for the concert list. 
This was easy on the iPhone; sections are built into the oUITableView class.   
Surprisingly, the ListView class in Android doesn't provide any corresponding functionality, as of Android 2.1. 
Jeff Sharkey's SeparatedListAdapter provides one [...]]]></description>
			<content:encoded><![CDATA[<p>When building the Android version of the <a href="http://www.ilike.com/mobile/concerts">iLike Concert app</a>, I wanted to have day headers for the concert list. </p>
<p>This was easy on the iPhone; sections are built into the o<a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html">UITableView</a> class.   </p>
<p>Surprisingly, the ListView class in Android doesn't provide any corresponding functionality, as of Android 2.1. </p>
<p>Jeff Sharkey's <a href="http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/">SeparatedListAdapter</a> provides one way to get this functionality; it glues together a number of individual adapters for each section into an overall list.</p>
<p>In my case, I had one SimpleCursorAdapter for the whole list, so I didn't want to break it into individual adapters just to display sections.</p>
<p>Instead, I made the header a part of the list cell layout, and hid the header on the rows where I didn't want to display it.  The headers look as follows:</p>
<p><img src="http://content.screencast.com/users/PhilBo/folders/Jing/media/c7fc8923-7197-45d2-ac6e-3c1a091166e4/00000057.png"/></p>
<p>My layout was like as follows; note the use of the explicit background color and textColorHighlight in the date header to prevent it from appearing as selected.</p>
<div class="igBar"><span id="lxml-3"><a href="#" onclick="javascript:showPlainTxt('xml-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-3">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></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;"><span style="font-weight: bold; color: black;">&lt;LinearLayout</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; xmlns:<span style="color: #000066;">android</span>=<span style="color: #ff0000;">"http://schemas.android.com/apk/res/android"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"wrap_content"</span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; android:<span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">"vertical"</span><span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;TextView</span> android:<span style="color: #000066;">id</span>=<span style="color: #ff0000;">"@+id/date_header"</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; android:<span style="color: #000066;">textSize</span>=<span style="color: #ff0000;">"20px"</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; android:<span style="color: #000066;">textStyle</span>=<span style="color: #ff0000;">"bold"</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; android:<span style="color: #000066;">textColor</span>=<span style="color: #ff0000;">"#000"</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; android:<span style="color: #000066;">textColorHighlight</span>=<span style="color: #ff0000;">"#000"</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; android:<span style="color: #000066;">background</span>=<span style="color: #ff0000;">"#DDD"</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; android:<span style="color: #000066;">visibility</span>=<span style="color: #ff0000;">"gone"</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; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"wrap_content"</span><span style="font-weight: bold; color: black;">/&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;LinearLayout</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; xmlns:<span style="color: #000066;">android</span>=<span style="color: #ff0000;">"http://schemas.android.com/apk/res/android"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"77px"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; android:<span style="color: #000066;">gravity</span>=<span style="color: #ff0000;">"center_vertical"</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; android:<span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">"horizontal"</span><span style="font-weight: bold; color: black;">&gt;</span></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;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;LinearLayout</span> xmlns:<span style="color: #000066;">android</span>=<span style="color: #ff0000;">"http://schemas.android.com/apk/res/android"</span> android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100px"</span> android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"75px"</span> android:<span style="color: #000066;">gravity</span>=<span style="color: #ff0000;">"center_vertical|center_horizontal"</span> android:<span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">"horizontal"</span><span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ImageView</span> android:<span style="color: #000066;">id</span>=<span style="color: #ff0000;">"@+id/image"</span> android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"75px"</span> android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"75px"</span><span style="font-weight: bold; color: black;">/&gt;</span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;/LinearLayout<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &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: #009900;"><span style="font-weight: bold; color: black;">&lt;LinearLayout</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; xmlns:<span style="color: #000066;">android</span>=<span style="color: #ff0000;">"http://schemas.android.com/apk/res/android"</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; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"wrap_content"</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; android:<span style="color: #000066;">gravity</span>=<span style="color: #ff0000;">"center_vertical"</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; android:<span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">"vertical"</span><span style="font-weight: bold; color: black;">&gt;</span></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; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;TextView</span> android:<span style="color: #000066;">id</span>=<span style="color: #ff0000;">"@+id/title"</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; android:<span style="color: #000066;">textSize</span>=<span style="color: #ff0000;">"20px"</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; &nbsp; &nbsp; android:<span style="color: #000066;">textStyle</span>=<span style="color: #ff0000;">"bold"</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; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; &nbsp; &nbsp; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"wrap_content"</span><span style="font-weight: bold; color: black;">/&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;TextView</span> android:<span style="color: #000066;">id</span>=<span style="color: #ff0000;">"@+id/description"</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; &nbsp; &nbsp; android:<span style="color: #000066;">textSize</span>=<span style="color: #ff0000;">"14px"</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; android:layout_<span style="color: #000066;">width</span>=<span style="color: #ff0000;">"fill_parent"</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; &nbsp; &nbsp; android:layout_<span style="color: #000066;">height</span>=<span style="color: #ff0000;">"wrap_content"</span><span style="font-weight: bold; color: black;">/&gt;</span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;/LinearLayout<span style="font-weight: bold; color: black;">&gt;</span></span></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;"><span style="font-weight: bold; color: black;">&lt;/LinearLayout<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;/LinearLayout<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The view binder assumes a function called isHeaderVisible to decide whether the header should be visible for the current row in the cursor; implement as appropriate for your application.  (For example, our application displays a header whenever the date of the current row is different from the previous row.)</p>
<div class="igBar"><span id="ljava-4"><a href="#" onclick="javascript:showPlainTxt('java-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span><br />
<div id="java-4">
<div class="java">
<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;">SimpleCursorAdapter listAdapter = <span style="color: #000000; font-weight: bold;">new</span> SimpleCursorAdapter<span style="color: #66cc66;">&#40;</span>mContext,</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; R.<span style="color: #006600;">layout</span>.<span style="color: #006600;">list_item</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; mEventsCursor, </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; <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">"artist_75x75_image_url"</span>, <span style="color: #ff0000;">"artist_name"</span>, <span style="color: #ff0000;">"venue_name"</span>, <span style="color: #ff0000;">"event_date_string"</span> <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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#123;</span>R.<span style="color: #006600;">id</span>.<span style="color: #006600;">image</span>, R.<span style="color: #006600;">id</span>.<span style="color: #006600;">title</span>, R.<span style="color: #006600;">id</span>.<span style="color: #006600;">description</span>, R.<span style="color: #006600;">id</span>.<span style="color: #006600;">date_header</span> <span style="color: #66cc66;">&#125;</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: #000000; font-weight: bold;">final</span> <span style="color: #993333;">int</span> nDateIndex = mEventsCursor.<span style="color: #006600;">getColumnIndex</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"event_date_string"</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &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;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; listAdapter.<span style="color: #006600;">setViewBinder</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleCursorAdapter.<span style="color: #006600;">ViewBinder</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; &nbsp; &nbsp; &nbsp; <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; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> setViewValue<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AView+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">View</span></a> view, <a href="http://www.google.com/search?q=allinurl%3ACursor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Cursor</span></a> cursor, <span style="color: #993333;">int</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;">columnIndex<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; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>columnIndex == nDateIndex<span style="color: #66cc66;">&#41;</span> <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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>isHeaderVisible<span style="color: #66cc66;">&#40;</span>cursor<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006600;">setVisibility</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AView+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">View</span></a>.<span style="color: #006600;">VISIBLE</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prevDate = dateString;</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; <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>TextView<span style="color: #66cc66;">&#41;</span> view<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span>dateString<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>TextView<span style="color: #66cc66;">&#41;</span> view<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">""</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006600;">setVisibility</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AView+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">View</span></a>.<span style="color: #006600;">GONE</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</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; <span style="color: #66cc66;">&#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; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</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: #66cc66;">&#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: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2010/02/section-headers-for-android-listviews/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Beyond 411 for the iPhone is now available in the App store</title>
		<link>http://thebogles.com/blog/2009/12/beyond-411-for-the-iphone-is-now-available-in-the-app-store/</link>
		<comments>http://thebogles.com/blog/2009/12/beyond-411-for-the-iphone-is-now-available-in-the-app-store/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 06:49:37 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/12/beyond-411-for-the-iphone-is-now-available-in-the-app-store/</guid>
		<description><![CDATA[The local search app Beyond411 (aka Berry411) is now available as a free download for the iPhone in the app store, just search for the abbreviation "b411".   This is just an initial version and doesn't have all of the features of the Blackberry version.  Be forgiving of it's faults, and please pass [...]]]></description>
			<content:encoded><![CDATA[<p>The local search app Beyond411 (aka Berry411) is now available as a free download for the iPhone in the app store, just search for the abbreviation "b411".   This is just an initial version and doesn't have all of the features of the Blackberry version.  Be forgiving of it's faults, and please pass on your bug reports and suggestions for improvement.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/12/beyond-411-for-the-iphone-is-now-available-in-the-app-store/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Stock Prediction, Web Sentiment, and Search Engines: a privacy thought experiment</title>
		<link>http://thebogles.com/blog/2009/12/stock-prediction-web-sentiment-and-search-engines-a-privacy-thought-experiment/</link>
		<comments>http://thebogles.com/blog/2009/12/stock-prediction-web-sentiment-and-search-engines-a-privacy-thought-experiment/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 06:40:54 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/12/stock-prediction-web-sentiment-and-search-engines-a-privacy-thought-experiment/</guid>
		<description><![CDATA[If Microsoft or Google found a way to predict and profit in the stock market by mining search logs, would it be a violation of their privacy policy?  
This is not an outlandish scenario. The research paper Stock Prediction using Web Sentiment describes "a novel way to do stock prediction using web sentiment".  [...]]]></description>
			<content:encoded><![CDATA[<p>If Microsoft or Google found a way to predict and profit in the stock market by mining search logs, would it be a violation of their privacy policy?  </p>
<p>This is not an outlandish scenario. The research paper <a href="http://www.scribd.com/doc/8450060/Stock-Prediction">Stock Prediction using Web Sentiment</a> describes "a novel way to do stock prediction using web sentiment".  The authors do textual analysis of financial message boards to extract how people are feeling about different stocks, correlate past sentiments with actual stock performance, and predict future stock values based on current sentiments.  </p>
<p>The authors claim a strong correlation between web sentiment and future stock prices. Suppose for the sake of argument that you could actually predict and profit in the stock market with this strategy.</p>
<p>In principle, it seems that your ability to predict the stock market might be even better if you had access to the web search logs-- users would presumably reveal things in their private searches they wouldn't state publically.  (To venture into even murkier privacy waters, consider also mining private emails.)</p>
<p>Google and Microsoft, of course, do have access to this data via their various web properties, and are growing increasingly sophisticated in their ability to mine this data.  </p>
<p>They already analyze and expose aggregate search trends, for example at this moment <a href="http://www.google.com/trends">Google Trends</a>.  At this instant Google Trends tells us that Copenhagen, Christmas Music, and Tiger Woods updates are on people's minds.   </p>
<p><img src="http://content.screencast.com/users/PhilBo/folders/Jing/media/02c6736a-b96e-489e-acee-0ebe83782578/00000056.png" width="450" border="1"/></p>
<p>Suppose a talented Google engineer decided to create "Google Stock Trends" as a 20% project.  I can't find anything in the <a href="http://www.google.com/privacypolicy.html">Google privacy policy</a> that would prevent that kind of aggregation-- it doesn't reveal any personally identifiable information.  </p>
<p>Stock trend analysis seems to be included in the allowed purposes that Google makes use of personal information, including the vague "development of new services".</p>
<p> At the same time, it seems a violation of trust to think that others might profit from my revealing personal stock knowledge via a search engine query. I might not even know they were doing this mining, if Google Stock Trends was for internal use only.</p>
<p>Presumably a reputable company would actually never create such a tool.  Should their privacy policies be more explicit that this kind of value extraction and data mining isn't allowed from searches that we think are private?</p>
<p><a title="View Stock Prediction on Scribd" href="http://www.scribd.com/doc/8450060/Stock-Prediction" style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block; text-decoration: underline;">Stock Prediction</a> <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_409492890734763" name="doc_409492890734763" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle"	height="300" width="450" ><br />
<param name="movie"	value="http://d1.scribdassets.com/ScribdViewer.swf?document_id=8450060&#038;access_key=key-26uehvopv8wjjw8ppwtm&#038;page=1&#038;version=1&#038;viewMode=list">
<param name="quality" value="high">
<param name="play" value="true">
<param name="loop" value="true">
<param name="scale" value="showall">
<param name="wmode" value="opaque">
<param name="devicefont" value="false">
<param name="bgcolor" value="#ffffff">
<param name="menu" value="true">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<param name="salign" value="">
<param name="mode" value="list">	    		<embed src="http://d1.scribdassets.com/ScribdViewer.swf?document_id=8450060&#038;access_key=key-26uehvopv8wjjw8ppwtm&#038;page=1&#038;version=1&#038;viewMode=list" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_409492890734763_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" mode="list" height="300" width="450"></embed>	</object>	</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/12/stock-prediction-web-sentiment-and-search-engines-a-privacy-thought-experiment/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Skinny controllers, fat models and Cocoa</title>
		<link>http://thebogles.com/blog/2009/11/skinny-controllers-fat-models-and-cocoa/</link>
		<comments>http://thebogles.com/blog/2009/11/skinny-controllers-fat-models-and-cocoa/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 20:50:03 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/11/skinny-controllers-fat-models-and-cocoa/</guid>
		<description><![CDATA[Skinny controller, fat model is a good design principle not just for Rails, but for client apps in MVC frameworks like Cocoa.
I think it's not uncommon, though, for client apps to have fairly anemic models, to the detriment of reusability. For example, I recently worked with an open source module that was in general very [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">Skinny controller, fat model</a> is a good design principle not just for Rails, but for client apps in MVC frameworks like <a href="http://developer.apple.com/cocoa/">Cocoa</a>.</p>
<p>I think it's not uncommon, though, for client apps to have fairly anemic models, to the detriment of reusability. For example, I recently worked with an open source module that was in general very well written, but which made it challenging to reuse to underlying parsing logic.</p>
<p>Why this tendency for skinny models? In part, this might because client apps are UI-centric and this ends up being reflected in the design of the code.  Even Apple's naming conventions (e.g. DetailViewController) emphasize the controller and view at the expense of the model.  </p>
<p>The lack of a full-fledged read-eval-print loop in Objective C (akin to the Rails console) also makes it inconvenient for developers to exercise fat models.  <a href="http://www.macruby.org/">MacRuby</a> has potential to provide an interactive console for Objective C models, and could perhaps be integrated with Xcode to allow me to bring up a console on any app.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/11/skinny-controllers-fat-models-and-cocoa/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Browsing iPhoto from a Blu-Ray player using iPhotoFS</title>
		<link>http://thebogles.com/blog/2009/11/browsing-iphoto-from-a-blu-ray-player-using-iphotofs/</link>
		<comments>http://thebogles.com/blog/2009/11/browsing-iphoto-from-a-blu-ray-player-using-iphotofs/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 20:25:46 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/11/browsing-iphoto-from-a-blu-ray-player-using-iphotofs/</guid>
		<description><![CDATA[Below are some (terribly blurry) pictures of me browsing my iPhoto albums on a network Blu-Ray player. 
I just installed and ran the latest version of iPhotoFS, clicked the "Shared folder" checkbox on the Get Info box for the iPhotoFS device, and browsed to the shared folder on the Blu-Ray player.  There are top [...]]]></description>
			<content:encoded><![CDATA[<p>Below are some (terribly blurry) pictures of me browsing my iPhoto albums on a network Blu-Ray player. </p>
<p>I just installed and ran the latest version of <a href="http://code.google.com/p/iphotofs/">iPhotoFS</a>, clicked the "Shared folder" checkbox on the Get Info box for the iPhotoFS device, and browsed to the shared folder on the Blu-Ray player.  There are top level folders to browse by album, roll, or date.</p>
<p><img src="http://thebogles.com/images/iphotofs2.jpg" width="300"/></p>
<p><img src="http://thebogles.com/images/iphotofs1.jpg" width="300"/></p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/11/browsing-iphoto-from-a-blu-ray-player-using-iphotofs/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>iPhotoFS alpha on Google Code</title>
		<link>http://thebogles.com/blog/2009/11/iphotofs-alpha-on-google-code/</link>
		<comments>http://thebogles.com/blog/2009/11/iphotofs-alpha-on-google-code/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 08:41:02 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/11/iphotofs-alpha-on-google-code/</guid>
		<description><![CDATA[iPhotoFS is a read-only filesystem for iPhoto collections, built on top of MacFUSE. I wrote iPhotoFS to let me easily copy my iPhoto Library to my PC while retaining its structure.  There are subfolders for photos organized by roll, album, or month.
 It allows you to easily interfact with your iPhoto collection using the [...]]]></description>
			<content:encoded><![CDATA[<p>iPhotoFS is a read-only filesystem for iPhoto collections, built on top of <a href="http://code.google.com/p/macfuse/">MacFUSE</a>. I wrote iPhotoFS to let me easily copy my iPhoto Library to my PC while retaining its structure.  There are subfolders for photos organized by roll, album, or month.</p>
<p> It allows you to easily interfact with your iPhoto collection using the Finder and command line utilities like `find` and `rsync`.  You can even browse collections on other machines by viewing the share volume.</p>
<p><a href="http://code.google.com/p/iphotofs/">Download iPhotoFS on Google Code</a>, it's open source under an Apache license.</p>
<p><img src="http://thebogles.com/images/iPhotoFS.png" width="400"/></p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/11/iphotofs-alpha-on-google-code/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Berry 411 for the iPhone submitted to the app store</title>
		<link>http://thebogles.com/blog/2009/10/berry-411-for-the-iphone-submitted-to-the-app-store/</link>
		<comments>http://thebogles.com/blog/2009/10/berry-411-for-the-iphone-submitted-to-the-app-store/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 23:00:39 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/10/berry-411-for-the-iphone-submitted-to-the-app-store/</guid>
		<description><![CDATA[I've submitted Berry 411 for the iPhone to the App Store and am hoping for quick approval.   It will be free.
(See a screencast here.)
I have many ideas for future improvements but I'm pretty happy with how it turned out.  Being able to get driving directions, reviews, and web pages for a business [...]]]></description>
			<content:encoded><![CDATA[<p>I've submitted Berry 411 for the iPhone to the App Store and am hoping for quick approval.   It will be free.</p>
<p>(See a screencast <a href="http://thebogles.com/blog/2009/09/iphone-411-screencast/">here</a>.)</p>
<p>I have many ideas for future improvements but I'm pretty happy with how it turned out.  Being able to get driving directions, reviews, and web pages for a business without leaving the app is handy indeed.  </p>
<p>I'm looking for a small number of beta testers to try it out while i wait for approval.  Please email your device ID using the  <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=285691333&#038;mt=8">Ad-Hoc Helper</a> if interested.  (Apologies if I don't have time to send beta copies to everyone who replies, but hopefully it will be in the App Store soon in any event.)
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/10/berry-411-for-the-iphone-submitted-to-the-app-store/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>iPhone 411 screencast</title>
		<link>http://thebogles.com/blog/2009/09/iphone-411-screencast/</link>
		<comments>http://thebogles.com/blog/2009/09/iphone-411-screencast/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 07:05:53 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/09/iphone-411-screencast/</guid>
		<description><![CDATA[I'm just about done recreating Beyond411 on the iPhone.  I created this brief screencast to get your feedback on the app before I submit it the iTunes stores.
The key features are as follows:
* Find nearby local business information by name or category
  - 20,000 word autocomplete dictionary
  - 500 item directory of [...]]]></description>
			<content:encoded><![CDATA[<p>I'm just about done recreating Beyond411 on the iPhone.  I created this brief screencast to get your feedback on the app before I submit it the iTunes stores.</p>
<p>The key features are as follows:</p>
<p>* Find nearby local business information by name or category<br />
  - 20,000 word autocomplete dictionary<br />
  - 500 item directory of popular businesses<br />
  - Fast list interface</p>
<p>* Everything you need to know without leaving the app<br />
  - Driving directions<br />
  - Reviews, Images, Web Links with inline browser<br />
  - Call Business<br />
  - Show directions in  Google maps</p>
<p>Please let me know what you think and what I can improved!</p>
<p><object width="376" height="742"><br />
<param name="movie" value="http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/jingswfplayer.swf"></param>
<param name="quality" value="high"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="flashVars" value="thumb=http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/FirstFrame.jpg&#038;containerwidth=376&#038;containerheight=742&#038;loaderstyle=jing&#038;content=http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/00000054.swf"></param>
<param name="allowFullScreen" value="true"></param>
<param name="scale" value="showall"></param>
<param name="allowScriptAccess" value="always"></param>
<param name="base" value="http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/"></param> <embed src="http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/jingswfplayer.swf" quality="high" bgcolor="#FFFFFF" width="376" height="742" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/FirstFrame.jpg&#038;containerwidth=376&#038;containerheight=742&#038;loaderstyle=jing&#038;content=http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/00000054.swf" allowFullScreen="true" base="http://content.screencast.com/users/PhilBo/folders/Jing/media/521ce3d1-eb7c-4194-969f-7670930e5f07/" scale="showall"></embed> </object>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/09/iphone-411-screencast/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>xml_grep cookbook</title>
		<link>http://thebogles.com/blog/2009/08/xml_grep-cookbook/</link>
		<comments>http://thebogles.com/blog/2009/08/xml_grep-cookbook/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 18:44:11 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/08/xml_grep-cookbook/</guid>
		<description><![CDATA[iLike frequently receives large XML files from our partners that we need to analyze.
For ad-hoc analysis of XML from command line, xml_grep is a really valuable tool.  Instead of extracting lines that match regular expressions, xml_grep extracts xml nodes that match xpath expressions.
However, it took me a bit of trial and error to figure [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ilike.com">iLike</a> frequently receives large XML files from our partners that we need to analyze.</p>
<p>For ad-hoc analysis of XML from command line, <a href="http://linux.die.net/man/1/xml_grep"><tt>xml_grep</tt></a> is a really valuable tool.  Instead of extracting lines that match regular expressions, xml_grep extracts xml nodes that match xpath expressions.</p>
<p>However, it took me a bit of trial and error to figure out how install and use it successfully.  Here's a quick cookbook of how I did it; I'll update this post with additional useful examples as I encounter them.</p>
<h3> Installation </h3>
<p>In most *nix distributions, you can install by simple typing  </p>
<pre>sudo cpan -i "XML::Twig"</pre>
<p>Answer 'y' when Cpan asks you if you want to install other packages that xml_grep depends on.  </p>
<p>(xml_grep is included as a part of the <a href="http://xmltwig.com/xmltwig/">XML::Twig </a> package in CPAN.   XML::Twig also provides a rich Perl API; however the command line examples here do not require any Perl knowledge.)</p>
<h3> Usage examples </h3>
<p>Suppose you have the following xml:</p>
<div class="igBar"><span id="lxml-6"><a href="#" onclick="javascript:showPlainTxt('xml-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-6">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> ?<span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Events<span style="font-weight: bold; color: black;">&gt;</span></span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Event</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">"0E0042D2CF2E9E44"</span><span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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: #009900;"><span style="font-weight: bold; color: black;">&lt;ArtistIDs<span style="font-weight: bold; color: black;">&gt;</span></span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ArtistID</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">"806533"</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">"Primary"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ArtistID</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">"1134688"</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;">"Secondary"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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: #009900;"><span style="font-weight: bold; color: black;">&lt;/ArtistIDs<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;EventDate<span style="font-weight: bold; color: black;">&gt;</span></span></span>2009-07-25<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/EventDate<span style="font-weight: bold; color: black;">&gt;</span></span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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: #009900;"><span style="font-weight: bold; color: black;">&lt;PerformanceName<span style="font-weight: bold; color: black;">&gt;</span></span></span>Summer Splash 2009<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/PerformanceName<span style="font-weight: bold; color: black;">&gt;</span></span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</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;"><span style="font-weight: bold; color: black;">&lt;/Event<span style="font-weight: bold; color: black;">&gt;</span></span></span>&nbsp; &nbsp; &nbsp; &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: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- etc --&gt;</span></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;"><span style="font-weight: bold; color: black;">&lt;/Events<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>xml_grep allows you to specify both --root (the node to match and print out) and --cond (an xpath expression relative to root that filters the results.)  If more than one root is provided, the results are combined using OR; likewise with cond.</p>
<p>1. Here's the simplest possible example.  --root is an xpath expression specifying which nodes will be printed. -p causes the results to be pretty printed:</p>
<p><b>Print all events </b>:  <tt>xml_grep -p --root="Event" foo.xml</tt></p>
<p>2. The next example shows how we can use --cond to filter the results based on an attribute of a subnode of the root.</p>
<p><b>Print all events for a given artist</b>:  <tt>xml_grep -p --root="Event" --cond='ArtistID[@ID='806533']' foo.xml </tt></p>
<p>3. Here's how we can match against the text contents of a subelements:</p>
<p><b>Print all events on a given date</b>:  <tt>xml_grep -p --root="Event" --cond='EventDate[string()="2009-07-25"]' foo.xml </tt></p>
<p>Multiple cond flags are combined using OR.  To print nodes matching one of several artists:</p>
<p>4.<b>Print all events for a given artist</b>:  <tt>xml_grep -p --root="Event" --cond='ArtistID[@ID='806533']' --cond='ArtistID[@ID='806532']'  foo.xml </tt></p>
<p>5. The result of xml_grep is itself an XML document and can be piped into another xml_grep to do additional extraction.</p>
<p><b>Extract the time and performance name of events on a given date</b>: <tt>xml_grep -p --root="Event" --cond='EventDate[string()="2009-07-25"]' foo.xml | xml_grep --root='EventTime' --root='PerformanceName'</tt></p>
<p>5. The result of xml_grep is itself an XML document and can be piped into another xml_grep to do additional extraction.</p>
<p>6. <b>Match a regular expression</b>: <tt>xml_grep --root="EventName[string() =~ /Bil.* El.*/]" foo.xml </tt>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/08/xml_grep-cookbook/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Tutorial: Opensocial Data Pipelining and Templates in the iLike Profile view on Orkut</title>
		<link>http://thebogles.com/blog/2009/08/tutorial-opensocial-data-pipelining-and-templates-in-the-orkut-profile/</link>
		<comments>http://thebogles.com/blog/2009/08/tutorial-opensocial-data-pipelining-and-templates-in-the-orkut-profile/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 18:02:00 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/08/tutorial-opensocial-data-pipelining-and-templates-in-the-orkut-profile/</guid>
		<description><![CDATA[Early this year, the Orkut team became aware that "a small subset of OpenSocial applications [were] being used to spread phishing attacks to Orkut users."
To solve this, the Orkut team phased out support for Flash and Javascript in profile views and ]]></description>
			<content:encoded><![CDATA[<p>Early this year, the Orkut team became aware that "a small subset of <a href="<br />
http://code.google.com/apis/opensocial/">OpenSocial</a> applications [were] being used to spread phishing attacks to Orkut users."</p>
<p>To solve this, the Orkut team phased out support for Flash and Javascript in profile views and <a href="<a href="http://orkutdeveloper.blogspot.com/2009/03/using-templates-and-data-pipelining-for.html"">required</a>  that app developers use <a href="http://wiki.opensocial.org/index.php?title=Data_Pipelining">Opensocial data pipelining</a> and <a href="http://opensocial-resources.googlecode.com/svn/spec/draft/OpenSocial-Templating.xml">templates</a> to specify profile markup.</p>
<p>Data pipelining is declarative way to specify a set of REST calls to fetch the JSON data for a page, these include both OpenSocial and arbitrary REST calls.  Templates are an HTML markup language (akin to JSTL or RHTML) that is interpreted on the Opensocial servers to generate the page markup.  It includes simple expressions, conditional, and looping constructs, bound against the JSON data from data pipelining.</p>
<p>Orkut is currently the only container that has implemented these features, which are are expected to be part of the Opensocial 0.9 spec.  </p>
<p>The specs for these features are still evolving and some of the online tutorials and wiki entries are inconsistent and no longer work.  I thought it might be helpful to document an working example (as of August 2009) based on the <a href="http://www.ilike.com">iLike</a> profile view.</p>
<p>The first step is to require the opensocial-data and opensocial-templates features in the ModulePrefs. </p>
<div class="igBar"><span id="lxml-12"><a href="#" onclick="javascript:showPlainTxt('xml-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-12">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;Module<span style="font-weight: bold; color: black;">&gt;</span></span></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;"><span style="font-weight: bold; color: black;">&lt;ModulePrefs<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;Require</span> <span style="color: #000066;">feature</span>=<span style="color: #ff0000;">"opensocial-data"</span><span style="font-weight: bold; color: black;">/&gt;</span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;Require</span> <span style="color: #000066;">feature</span>=<span style="color: #ff0000;">"opensocial-templates"</span><span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;Param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"process-on-server"</span><span style="font-weight: bold; color: black;">&gt;</span></span>true<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/Param<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;/Require<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Next we declare the profile content...</p>
<div class="igBar"><span id="lxml-13"><a href="#" onclick="javascript:showPlainTxt('xml-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-13">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;Content</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"html"</span> <span style="color: #000066;">view</span>=<span style="color: #ff0000;">"profile"</span><span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>      </p>
<p>...and specify the JSON requests required by the profile view using the os:HttpRequest declaration:  </p>
<div class="igBar"><span id="lxml-14"><a href="#" onclick="javascript:showPlainTxt('xml-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-14">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/os-data"</span> xmlns:<span style="color: #000066;">os</span>=<span style="color: #ff0000;">"http://ns.opensocial.org/2008/markup"</span><span style="font-weight: bold; color: black;">&gt;</span></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;"><span style="font-weight: bold; color: black;">&lt;os</span>:HttpRequest <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"cache"</span> <span style="color: #000066;">authz</span>=<span style="color: #ff0000;">"signed"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://philbo.dev.ilike.com/gadget/ilike_async_get_cache_key"</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">"json"</span> <span style="color: #000066;">signViewer</span>=<span style="color: #ff0000;">"false"</span> <span style="color: #000066;">params</span>=<span style="color: #ff0000;">"orkut_profile=true"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>&nbsp; &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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;os</span>:HttpRequest <span style="color: #000066;">key</span>=<span style="color: #ff0000;">"profile"</span> <span style="color: #000066;">authz</span>=<span style="color: #ff0000;">"signed"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://philbo.dev.ilike.com/gadget/profile_tracks_json"</span> <span style="color: #000066;">params</span>=<span style="color: #ff0000;">"synd=orkut&amp;key=${cache.content.key}"</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">"json"</span> <span style="color: #000066;">signViewer</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">/&gt;</span></span>&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/script<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>The <tt>ilike_async_get_cache_key</tt> request returns JSON like this: <tt>{"key": 139222}</tt>.  </p>
<p>The <tt>profile_tracks_json</tt> request returns JSON like this:<br />
<tt>{"tracks":[{,"artist_name":"Bouncing Souls","name":"The Pizza Song"}, {"artist_name":"The Aquabats","name":"Pizza Day"}],"track_count":2}}</tt>.</p>
<p>Note how the second request includes query string parameters (<b>${cache.content.key}</b>) derived from the JSON data in the first request.  In this case, the profile_tracks_json is set to have a very long cache lifetime;  the key is a profile timestamp use to force a fresh version of the profile to be fetched when the profile changes.  (The timestamp is maintained in memached and can be returned very quickly by the server.)</p>
<p>It is poorly documented that Orkut's os:HttpRequest wraps this content in a "content" hash wrapper, which is why we have to say "cache.content.key".  </p>
<p>Now that we have the data, we declare the template that binds to the json data to generate the markup.  Note the use of "if" and "repeat" attributes for conditionals and loops and the "${}" expressions; also note the required use of osx:NavigateToApp to link to canvas pages.</p>
<div class="igBar"><span id="lxml-15"><a href="#" onclick="javascript:showPlainTxt('xml-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-15">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/os-template"</span> xmlns:<span style="color: #000066;">os</span>=<span style="color: #ff0000;">"http://ns.opensocial.org/2008/markup"</span> xmlns:<span style="color: #000066;">osx</span>= <span style="color: #ff0000;">"http://ns.opensocial.org/2009/extensions"</span><span style="font-weight: bold; color: black;">&gt;</span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"profile_songs"</span><span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"gadget_profile_header"</span><span style="font-weight: bold; color: black;">&gt;</span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;osx</span>:NavigateToApp <span style="color: #000066;">params</span>=<span style="color: #ff0000;">"{path:&amp;quot;songs_ilike&amp;quot;}"</span><span style="font-weight: bold; color: black;">&gt;</span></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; See All</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: #009900;"><span style="font-weight: bold; color: black;">&lt;/osx</span>:NavigateToApp<span style="font-weight: bold; color: black;">&gt;</span></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; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;b<span style="font-weight: bold; color: black;">&gt;</span></span></span>Songs iLike<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/b<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;/div<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;div</span> <span style="color: #000066;">if</span>=<span style="color: #ff0000;">"${profile.content.track_count == 0}"</span><span style="font-weight: bold; color: black;">&gt;</span></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; No songs</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: #009900;"><span style="font-weight: bold; color: black;">&lt;/div<span style="font-weight: bold; color: black;">&gt;</span></span></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: #009900;"><span style="font-weight: bold; color: black;">&lt;div</span>&nbsp; <span style="color: #000066;">if</span>=<span style="color: #ff0000;">"${profile.content.track_count&gt;</span> 0}&quot; &gt;</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; <span style="color: #009900;">&lt;ul&gt;</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: #009900;">&lt;li repeat="</span>$<span style="color: #66cc66;">&#123;</span>profile.content.tracks<span style="color: #66cc66;">&#125;</span><span style="color: #ff0000;">" var="</span>track<span style="color: #ff0000;">"&gt;</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: #009900;">&lt;osx:NavigateToApp params="</span><span style="color: #66cc66;">&#123;</span>&amp;quot;track_name&amp;quot;:&amp;quot;$<span style="color: #66cc66;">&#123;</span>track.name<span style="color: #66cc66;">&#125;</span>&amp;quot;,&amp;quot;artist_name&amp;quot;:&amp;quot;$<span style="color: #66cc66;">&#123;</span>track.artist_name<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span><span style="color: #ff0000;">"&gt;</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; &nbsp; <span style="color: #009900;">&lt;span class="</span>song_title<span style="color: #ff0000;">"&gt;</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; ${track.name}</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; <span style="color: #009900;">&lt;/span&gt;</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: #009900;">&lt;/osx:NavigateToApp&gt;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </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: #009900;">&lt;/li&gt;</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; <span style="color: #009900;">&lt;/ul&gt;</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: #009900;">&lt;/div&gt;</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: #009900;">&lt;/div&gt;</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;">&lt;/script&gt;</span> </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In our case, the template is itself generated using an RHTML template in the Rails framework.  We can use Ruby expressions to help simplify generation of the static template, but not, of course, any of the dynamic content or conditionals that depend upon the JSON data.</p>
<p>For example, the grungy escaped NavigateToApp parameters are actually generated by this more readable RHTML code:</p>
<div class="igBar"><span id="lxml-16"><a href="#" onclick="javascript:showPlainTxt('xml-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span><br />
<div id="xml-16">
<div class="xml">
<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;"><span style="font-weight: bold; color: black;">&lt;osx</span>:NavigateToApp <span style="color: #000066;">params</span>=<span style="color: #ff0000;">"&lt;%= escape_json('path' =&gt;</span> 'track_page', 'autoplay' =&gt; true, 'artist_name' =&gt; '${track.artist_name}', 'track_name' =&gt; '${track.name}') %&gt;&quot;&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p></Content></p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/08/tutorial-opensocial-data-pipelining-and-templates-in-the-orkut-profile/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Seattle Travel Times Web Service</title>
		<link>http://thebogles.com/blog/2009/07/seattle-travel-times-web-service/</link>
		<comments>http://thebogles.com/blog/2009/07/seattle-travel-times-web-service/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 05:06:50 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/07/seattle-travel-times-web-service/</guid>
		<description><![CDATA[With the closure of a number of I90 bridge lanes, I spent a lot of time waiting in and thinking about traffic.
The WSDOT has a Seattle Travel Times page that lists commute times between various cities in the Seattle area given the current traffic conditions.  Unfortunately there wasn't any web service version of the [...]]]></description>
			<content:encoded><![CDATA[<p>With the closure of a number of I90 bridge lanes, I spent a lot of time waiting in and thinking about traffic.</p>
<p>The WSDOT has a <a href="http://www.wsdot.wa.gov/traffic/seattle/traveltimes/">Seattle Travel Times</a> page that lists commute times between various cities in the Seattle area given the current traffic conditions.  Unfortunately there wasn't any web service version of the data.</p>
<p>For the benefit of those wishing to build apps that use this data, I whipped up a REST web service that scrapes the data using <a href="http://wiki.github.com/why/hpricot">Hpricot</a> and formats it as JSON.</p>
<p><a href="http://thebogles.com/berry/traffic/seattle/traveltimes.json">http://thebogles.com/berry/traffic/seattle/traveltimes.json</a> gives all of the available travel times, formatted as JSON.  </p>
<p>You can also specify optional "from" and "to" parameters to restrict the cities returned. An example: <a href="http://thebogles.com/berry/traffic/seattle/traveltimes.json?from=bellevue&#038;to=seattle">http://thebogles.com/berry/traffic/seattle/traveltimes.json?from=bellevue&#038;to=seattle</a>.</p>
<p>Implementation note: to make the JSON look pretty, I wanted an ordered hash.  I'm still on Ruby 1.8, so I used the <a href="http://facets.rubyforge.org/">Ruby Facets</a> class.  The Dictionary class doesn't come with a to_json method, but it's easy to add one:</p>
<div class="igBar"><span id="lruby-18"><a href="#" onclick="javascript:showPlainTxt('ruby-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span><br />
<div id="ruby-18">
<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:#CC0066; font-weight:bold;">require</span> 'facets/dictionary'</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:#9966CC; font-weight:bold;">class</span> Dictionary</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;">def</span> to_json<span style="color:#006600; font-weight:bold;">&#40;</span>ignored=<span style="color:#0000FF; font-weight:bold;">nil</span>,ignored2=<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; &nbsp; <span style="color:#996600;">"{ "</span> + <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |k,v| <span style="color:#996600;">"#{k}: #{v.to_json}"</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>', '<span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#996600;">"}"</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:#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://thebogles.com/blog/2009/07/seattle-travel-times-web-service/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Using the Picnik API from Rails</title>
		<link>http://thebogles.com/blog/2009/07/using-the-picnik-api-from-rails/</link>
		<comments>http://thebogles.com/blog/2009/07/using-the-picnik-api-from-rails/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 15:23:41 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/07/using-the-picnik-api-from-rails/</guid>
		<description><![CDATA[The Picnik API makes it easy to add online image editing to any site that hosts images.  
For the benefit of those coding in Rails, here's a summary of how I integrated Picnik with iLike to allow our users to touch up photos after upload.
I used the "pull version" of the API, which for [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.picnik.com/info/api">Picnik API</a> makes it easy to add online image editing to any site that hosts images.  </p>
<p>For the benefit of those coding in Rails, here's a summary of how I integrated Picnik with <a href="http://iLike.com">iLike</a> to allow our users to touch up photos after upload.</p>
<p>I used the "pull version" of the API, which for our purposes was simplest and provided the most control.  In a nutshell, you just need to link the user to the Piknik site with URL of the image to edit and some configuration parameters.  When the user is done, Picnik links the user back to your site and passes the URL of the edited image back on the query string.  Very simple!</p>
<p>(1) First, I constructed a helper to link the user to Picnik with the appropriate parameters.</p>
<p>In the code below,  "image_url" is the URL of the image to edit on our site. "export_url" is the URL that Picnik links back to when the user is done editing.  "export_parameter" is the parameter to use for passing back the edited URL.  (Note the gotcha about encoding spaces as '%20' and not '+')<br />
<style><br />
#ruby-1 {font-size: 8pt !important }<br />
</style></p>
<div class="igBar"><span id="lruby-22"><a href="#" onclick="javascript:showPlainTxt('ruby-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span><br />
<div id="ruby-22">
<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;">module</span> ApplicationHelper</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;">def</span> picnik_edit_url<span style="color:#006600; font-weight:bold;">&#40;</span>image_url, export_param, export_url<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; host_name = 'YOURSITE'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; params = <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; :import =&gt; image_url,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :export =&gt; export_url,</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; :export_field =&gt; export_param,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :apikey =&gt; 'YOURAPIKEY',</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; :close_target =&gt; export_url,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :export_agent =&gt; 'browser',</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; :out_format =&gt; 'png',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :export_title =&gt; <span style="color:#996600;">"Save and return to #{host_name}"</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; :exclude =&gt; '<span style="color:#9966CC; font-weight:bold;">in</span>,create',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :host_name =&gt; host_name</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:#996600;">"http://www.picnik.com/service/?#{escape_picnik_params(params)}"</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:#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; <span style="color:#9966CC; font-weight:bold;">def</span> escape_picnik_params<span style="color:#006600; font-weight:bold;">&#40;</span>params<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; params.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |k,v|&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#996600;">"_#{strict_escape(k)}=#{strict_escape(v)}"</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>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"&amp;"</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; <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;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> strict_escape<span style="color:#006600; font-weight:bold;">&#40;</span>s<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:#008000; font-style:italic;"># escape spaces as %20; picnik won't accept +</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; CGI.<span style="color:#9900CC;">escape</span><span style="color:#006600; font-weight:bold;">&#40;</span>s.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"+"</span>, <span style="color:#996600;">"%20"</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; <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>
<p>2. Next I added links to edit images to our RHTML templates.</p>
<div class="igBar"><span id="lruby-23"><a href="#" onclick="javascript:showPlainTxt('ruby-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span><br />
<div id="ruby-23">
<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;">&lt;%= link_to <span style="color:#996600;">"Edit image"</span>, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; picnik_edit_url<span style="color:#006600; font-weight:bold;">&#40;</span>logo_url, 'logo_file', url_for<span style="color:#006600; font-weight:bold;">&#40;</span>:only_path =&gt; <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>3. Finally I customized our controller action to handle an edited image parameter:</p>
<div class="igBar"><span id="lruby-24"><a href="#" onclick="javascript:showPlainTxt('ruby-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span><br />
<div id="ruby-24">
<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:#CC0066; font-weight:bold;">require</span> 'open-uri' </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;">def</span> settings_bannerphoto</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:#9966CC; font-weight:bold;">if</span> !params<span style="color:#006600; font-weight:bold;">&#91;</span>:banner_file<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">blank</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; image_file = <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span>:banner_file<span style="color:#006600; font-weight:bold;">&#93;</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; <span style="color:#008000; font-style:italic;"># do what you want with the image file (e.g. save it)</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:#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;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>Quite simple, and we just repeat steps 2 and 3 to make additional images on our site editable.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/07/using-the-picnik-api-from-rails/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Google Voice on the iPhone</title>
		<link>http://thebogles.com/blog/2009/06/google-voice-on-the-iphone/</link>
		<comments>http://thebogles.com/blog/2009/06/google-voice-on-the-iphone/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 05:42:50 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
	<category>Mobile</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/06/google-voice-on-the-iphone/</guid>
		<description><![CDATA[I wrote an earlier post on how to replace you're cellphone's voice mail with Google Voice.  That was for generic GSM phones; happily those instructions work without change on the iPhone.
I use Google Voice for my voice mail because it forwards text transcript of messages to my email, and because I can listen to [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote an earlier post on <a href="http://thebogles.com/blog/2009/04/how-to-replace-your-cellphones-voice-mail-with-google-voice/">how to replace you're cellphone's voice mail with Google Voice</a>.  That was for generic GSM phones; happily those instructions work without change on the iPhone.</p>
<p>I use Google Voice for my voice mail because it forwards text transcript of messages to my email, and because I can listen to the messages from any computer.</p>
<p>What if you don't have Google Voice? According to the New York Times, <a href="http://bits.blogs.nytimes.com/2009/06/25/google-starts-welcoming-new-users-to-voice-service/?ref=technology">Google is sending out new Google Voice invites to some of the users who requested them </a>.</p>
<p>iPhone freak mentions the imminent arrival of <a href="http://www.iphonefreak.com/2009/03/google-voice-iphone-app-submitted-for-approval-hopefully-coming-soon.html">GV Mobile</a>, an iPhone app that </p>
<blockquote><p>
“will allow you to dial via Google Voice (like the old GrandDialer), retrieve your call log (received, missed, made), retrieve your voicemail (an issue with the old GrandCentral), access to iPhone address book, and update account settings (phones to dial when someone calls and other misc. settings).”
</p></blockquote>
<p>  It was submitted for approval a month ago so hopefully we'll see it soon.</p>
<p><object width="560" height="340"><br />
<param name="movie" value="http://www.youtube.com/v/9IlvfEBJGx4&#038;hl=en&#038;fs=1&#038;"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9IlvfEBJGx4&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/06/google-voice-on-the-iphone/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Why I ditched my Blackberry Curve for an iPhone 3GS</title>
		<link>http://thebogles.com/blog/2009/06/why-i-ditched-my-blackberry-curve-for-an-iphone-3gs/</link>
		<comments>http://thebogles.com/blog/2009/06/why-i-ditched-my-blackberry-curve-for-an-iphone-3gs/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 21:38:23 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
	<category>Mobile</category>
	<category>Berry 411</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/06/why-i-ditched-my-blackberry-curve-for-an-iphone-3gs/</guid>
		<description><![CDATA[I have been a long time Blackberry fan, and even wrote Beyond411, a popular local search application for the Blackberry.  But with the release of the iPhone 3GS, I finally reach my personal tipping point and bought an iPhone.
My story is a common one; AppleInseder reports that 12% of early iPhone 3GS buyers are [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a long time Blackberry fan, and even wrote Beyond411, a popular local search application for the Blackberry.  But with the release of the iPhone 3GS, I finally reach my personal tipping point and bought an iPhone.</p>
<p>My story is a common one; AppleInseder reports that <a href="http://www.appleinsider.com/articles/09/06/22/12_of_early_iphone_3g_buyers_report_ditching_their_blackberry.html">12% of early iPhone 3GS buyers are Blackberry owners</a></p>
<p>Here are some the factors that pushed me to get an iPhone.</p>
<p>- <strong>The overwhelming momentum of Apple's app store</strong>: Apple's position in mobile apps is similar to what Microsoft enjoyed with Windows; I don't believe RIM or any one else can catch up even if they match or exceed Apple's features.  There are a number of iPhone apps that I (and my kids) find fun and compelling.</p>
<p>- <strong>Poor developer support from RIM</strong>: My primary interaction with Blackberry developer support was when they forced me to change the name of Berry411 to Beyond411, part of their trademark enforcement of anything related to Black or Berry.  Other than their friendly trademark police, I was disappointed at how little RIM had to offer to third party developers. They wanted a $2000 fee just to join their developer program, offered limited promotional opportunities, and seemed to subservient to the wishes of their carrier partners.  </p>
<p>- <strong>OS Bugs and uncompetitive feature set</strong>:  The Storm is no iPhone in terms of features or usability.  Plus the OS has hanging bugs that don't reproduce in the simulator; this makes my life as a developer miserable. </p>
<p>- <strong>Declining build quality</strong>: I can't tell you how many Blackberry's I've gone through. Gone are the tanks of old: as RIM has chased the consumer market, their phones have gotten cheaper and more fragile.  The Curve I just replaced rebooted randomly; the two previous curves had broken USB connections, as did the 8800 before that.  The Pearl style trackball is much more prone to gumming up than the jog wheel it replace.  Recent keyboards are smaller and harder to type on than the older ones, again because of RIM's wish to appeal to a broad audience.  </p>
<p>In short, RIM is watering down the features that made it special, failing to keep up with the unique features of Apple and Palm, and losing the battle for the hearts and minds of developers.</p>
<p>I won't pretend that there aren't  features I miss in the Blackberry. A virtual keyboard is no replacement a real one. Reading mail is definitely slower on the iPhone than the Blackberry-- I have to wait several seconds the mail app to pull down new messages every time I launch it.  For now I'm willing to live with these limitations in exchange for the other advantages. Blackberry could win me back, but it's not easy to divide your loyalties between two phones.</p>
<p>Some Blackberry converts to the iPhone have asked me if I plan to create an iPhone version of Beyond411.  Now that I've got one myself, that's looking a lot more likely.</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/06/why-i-ditched-my-blackberry-curve-for-an-iphone-3gs/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>How to replace your cellphone&#8217;s voice mail with Google Voice</title>
		<link>http://thebogles.com/blog/2009/04/how-to-replace-your-cellphones-voice-mail-with-google-voice/</link>
		<comments>http://thebogles.com/blog/2009/04/how-to-replace-your-cellphones-voice-mail-with-google-voice/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 22:56:14 +0000</pubDate>
		<dc:creator>philbo</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://thebogles.com/blog/2009/04/how-to-replace-your-cellphones-voice-mail-with-google-voice/</guid>
		<description><![CDATA[
Google Voice offers a really compelling set of voicemail features, much better than what US cellphone carriers offer.  
You can view, search, and listen to your voicemails from any phone or web browser, with textual transcripts generated using automatic speech recognition.  
Assuming you're lucky enough to be on in the Google Voice beta, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.google.com/voice/resources/1513485571-GoogleVoice_02.gif"/></p>
<p><a href="http://www.google.com/voice/about">Google Voice</a> offers a really compelling set of voicemail features, much better than what US cellphone carriers offer.  </p>
<p>You can view, search, and listen to your voicemails from any phone or web browser, with textual transcripts generated using automatic speech recognition.  </p>
<p>Assuming you're lucky enough to be on in the Google Voice beta, and have a GSM phone, here's how you can replace your regular voicemail service with Google voicemai.  (The <a href="http://en.wikipedia.org/wiki/Call_forwarding">Call forwarding</a> entry in Wikipedia has a helpful list of GSM call forwarding codes.)</p>
<p>1. First, call <b>*#67#</b> and write down the resulting number, which is your current voicemail call forwarding number.  This will let you go back to your old service later if you want to.</p>
<p>2. Next call the following numbers, where [phone number] is your Google voice phone number.  (I'm assuming that you have your Google Voice account set up to go directly to voice mail.)</p>
<p><b>*67*[phone number]#</b>     (forward if busy)<br />
<b>*61*[phone number]#</b>     (forward if not answered)<br />
<b>*62*[phone number]#</b>     (forward if out of reach)</p>
<p>3. That's it, your carrier will automatically forward calls to Google Voice when you can't be reached.  To undo the forwarding, just redo these steps, replacing phone number with your original voicemail number.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://thebogles.com/blog/2009/04/how-to-replace-your-cellphones-voice-mail-with-google-voice/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
