<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sameer Ahuja &#187; Code</title>
	<atom:link href="http://sameerahuja.com/blog/tags/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://sameerahuja.com</link>
	<description></description>
	<lastBuildDate>Wed, 09 Jun 2010 21:34:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Editing WordPress pages using blogging tools</title>
		<link>http://sameerahuja.com/blog/editing-wordpress-pages/</link>
		<comments>http://sameerahuja.com/blog/editing-wordpress-pages/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 21:44:31 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://sameerahuja.com/?p=56</guid>
		<description><![CDATA[I&#8217;m a heavy user of TextMate, and use the blogging bundle to create and edit posts. I&#8217;m also a heavy user of WordPress Pages that enable wordpress to be used as a CMS. The one issue that always bugs me with any new WordPress installation is that you cannot edit pages from XML-RPC blogging tools [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a heavy user of TextMate, and use the <a href="http://blog.macromates.com/2006/blogging-from-textmate/">blogging bundle</a> to create and edit posts. I&#8217;m also a heavy user of WordPress Pages that enable wordpress to be used as a CMS. The one issue that always bugs me with any new WordPress installation is that you cannot edit pages from XML-RPC blogging tools like TextMate, Ecto, Windows Live Writer and such. The only working solution I&#8217;ve found to the same is a <em>little</em> ugly: You&#8217;ll need to edit one of the core wordpress files. I wouldn&#8217;t do it if I didn&#8217;t love TextMate so much.</p>

<p><a href="http://maisonbisson.com/blog/post/10834/editing-wordpress-pages-via-xml-rpc/">This post</a> from Maison Bisson described the process of editing the files for a previous version. The good news is, for the latest WordPress releases (I&#8217;ve checked 2.7.0 and 2.7.1), the data model has been changed to remove the &#8220;static&#8221; post status for pages (They now have the same status codes as posts), which means that no changes are required to the update fundtion; and a field called post_type now stores information about the kind of post (blog post, page, attachment).</p>

<p>So, essentially, here&#8217;s all you need to do to magically get the list of latest posts AND pages on your blogging client:</p>

<p>Modify this query in <code>wp_includes/post.php</code>:
<pre class="brush: php;"> $sql = &amp;quot;SELECT * FROM $wpdb-&amp;gt;posts WHERE post_type = 'post' ORDER BY post_date DESC $limit&amp;quot;;</pre></p>

<p>to this:</p>

<p><pre class="brush: php;"> $sql = &amp;quot;SELECT * FROM $wpdb-&amp;gt;posts WHERE post_type = 'post' OR post_type = 'page' ORDER BY post_date DESC $limit&amp;quot;;</pre></p>

<p>This is a scotch-tape solution that&#8217;s worked well for me so far. Try it at your own risk. Also, remember that when you update your WordPress installation, these changes might get overwritten.</p>

<p><strong>UPDATE</strong>: This works for 2.9.1 too, see comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://sameerahuja.com/blog/editing-wordpress-pages/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Experiments with publishing application activity</title>
		<link>http://sameerahuja.com/blog/experiments-with-publishing-application-activity/</link>
		<comments>http://sameerahuja.com/blog/experiments-with-publishing-application-activity/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 15:29:57 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Play]]></category>

		<guid isPermaLink="false">http://sameerahuja.com/2008/02/experiments-with-publishing-activity/</guid>
		<description><![CDATA[For a couple of weeks now I&#8217;ve been monitoring what I do on my Mac using two tracker tools: Wakoopa and RescueTime. Both have unique approaches to the theme of tracking. Wakoopa builds a social network around the applications that you use. It lets you build &#8216;teams&#8217; of people and see what your friends have [...]]]></description>
			<content:encoded><![CDATA[<p>For a couple of weeks now I&#8217;ve been monitoring what I do on my Mac using two tracker tools: <a href="http://www.wakoopa.com">Wakoopa</a> and <a href="http://www.rescuetime.com">RescueTime</a>. Both have unique approaches to the theme of tracking. Wakoopa builds a social network around the applications that you use. It lets you build &#8216;teams&#8217; of people and see what your friends have been using. The other two significant things that it does are statistical visualizations, and recommendations of apps based on what you&#8217;ve been using. So if you&#8217;ve been using a lot of TextEdit lately, it might recommend TextMate as a &#8216;similar&#8217; application. This, according to my guesswork, they do by matching application tags.</p>

<p><img style="float: none;" src="http://sameer.dreamhosters.com/wp-content/uploads/2008/02/wakoopa-recommendations.jpg" alt="Wakoopa Recommendations" /></p>

<p>The other way to do these recommendations could be to match people based on their application sets (or better still, their activity sets. If app = Microsoft Word, then Activity = word processing); and then provide recommendations based on what other people who have similar appication/activity sets are using, that the current user isn&#8217;t.</p>

<p>Anyways, Wakoopa does provide a simple API to accessing its data, and that is a great thing to do. That&#8217;s something that RescueTime hasn&#8217;t done yet, but they promise to do the same soon on their site. RescueTime has a unique approach to this whole domain. They aren&#8217;t building a social network (at least till yet), and this is how they track your apps: If you are using a standard application, the RescueTime tracker records its usage as any other tracker. If, however, you are on a browser, the tracker records the website that you&#8217;re visiting as an &#8216;application&#8217;, which makes some sense in this era of online applications. You can then go to the website and assign &#8216;tags&#8217; to applications. These can later be visualized to see how much time, for example, you spend &#8216;Watching Videos Online&#8217;.</p>

<p><img style="float:none; margin: 3px 3px 3px 3px;" src="http://sameer.dreamhosters.com/wp-content/uploads/2008/02/rescue-time-dashboard.jpg" alt="Rescue Time Dashboard" /></p>

<p>So anyways, I&#8217;ve been itching to use the incredibly simple to use <a href="http://code.google.com/apis/chart/">GChart APIs</a> with an interesting enough data-set, and Wakoopa stats are sortof interesting (at least for me&#8230;), so last weekend I cooked up a script to make a pie chart of my recent application usage. Its available <a href="http://sameerahuja.com/playground/visualize-this/">here</a>, and at the point of writing this post, this is how my stats looked:</p>

<p><img style="border-width: 2px; float:none; margin: 3px 3px 3px 3px;" src="http://sameer.dreamhosters.com/wp-content/uploads/2008/02/application-use-chart.jpg" alt="Application usage chart" /></p>

<p>Which, I suppose, is a pretty reasonable graph. Half of what we do on our computers these days is more or less on the web (50% of which is on YouTube, which is, IMHO, the greatest time sink ever invented). Mail takes about 20%, and the actual work takes the rest. (Source after the jump)</p>

<p><span id="more-34"></span></p>

<p>The source code for the vis is pretty simple. All it does is load the XML API URL, parse through to generate a Google Chart compatible format, and call the image URL for Pie Charts:</p>

<p><pre class="brush: php;">
$request_url = &amp;quot;http://api.wakoopa.com/sameer/most_used.xml&amp;quot;;&lt;/p&gt;

&lt;p&gt;//App names
$names = &amp;quot;&amp;quot;;
//Usage values
$values = &amp;quot;&amp;quot;;
//For calculations
$total = 0;&lt;/p&gt;

&lt;p&gt;$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);&lt;/p&gt;

&lt;p&gt;$xml = new SimpleXMLElement($data);&lt;/p&gt;

&lt;p&gt;//Computing total
foreach($xml-&amp;gt;software as $sw){
   $total += intval($sw-&amp;gt;{'active-seconds'});
}
//Computing values in GChart-compatible format. Have a look at this: http://code.google.com/apis/chart/#pie_charts
foreach($xml-&amp;gt;software as $sw){
       $names = $names.&amp;quot;|&amp;quot;.$sw-&amp;gt;name;
       $values = $values.&amp;quot;,&amp;quot;.(round(intval($sw-&amp;gt;{'active-seconds'})*100/$total, 1));
    }&lt;/p&gt;

&lt;p&gt;//That's it! Load the image.
echo '&amp;lt;br&amp;gt;&amp;lt;img src=&amp;quot;http://chart.apis.google.com/chart?
cht=p&amp;amp;chco=3587DCFF,99E142FF,993C99FF,90A4E5FF,DAD52EFF,C95854FF,AE4496FF&amp;amp;
chd=t:'.trim($values, &amp;quot;,&amp;quot;).'&amp;amp;chs=450x300&amp;amp;chl='.trim($names,&amp;quot;|&amp;quot;).'&amp;quot;&amp;gt;';
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://sameerahuja.com/blog/experiments-with-publishing-application-activity/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Dear WordPress: Why not an XML-RPC for commenting?</title>
		<link>http://sameerahuja.com/blog/dear-wordpress-why-not-an-xml-rpc-for-commenting/</link>
		<comments>http://sameerahuja.com/blog/dear-wordpress-why-not-an-xml-rpc-for-commenting/#comments</comments>
		<pubDate>Sun, 29 Apr 2007 21:40:50 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://sameerahuja.com/blog/2007/04/dear-wordpress-why-not-an-xml-rpc-for-commenting/</guid>
		<description><![CDATA[We&#8217;re very much in the middle of the Syndication revolution &#8211; Everything out there on the web can be syndicated&#160; &#8211; Be it the latest news, your friends&#8217; photos and videos, your favorite TV Show episodes, and so on. Even sites lacking any technological platform for publishing can be subscribed to using online tools. Now [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re very much in the middle of the Syndication revolution &#8211; Everything out there on the web can be syndicated&nbsp; &#8211; Be it the latest news, your friends&#8217; photos and videos, your favorite TV Show episodes, and so on. Even sites lacking any technological platform for publishing can be subscribed to using online tools. </p>

<p>Now in all this &#8211; perhaps the most&nbsp;popular type of feeds that we syndicate to are blog posts. And typically, they support commenting. In fact, commenting is an integral part of the blogging experience. The discussion adds mass to the content of the original post, sometimes even surpassing it in meaningful content. Or, it can go completely haywire and spread out into several branches of context. Either ways, it&#8217;s something without which blogging won&#8217;t be blogging.</p>

<p>So my rue is this &#8211; I would like to participate in the discussions on a blog post right from my <a href="http://google.com/reader">newsreader</a>. That implies two things-</p>

<ul> <li>I want to view the stream of comments along with the post. This isn&#8217;t hard to achieve, given that almost all blogging platforms provide RSS feeds for comments to posts, and a couple of <a href="http://www.sharpreader.net/">newsreaders</a> that support the display of those comments.  <li>I want to be able to comment right from my newsreader.&nbsp;This is important because&nbsp;it makes the whole process of &#8216;participating&#8217; with the said blog or news site much more intuitive for me, <strong>and,</strong> the newsreader can then keep&nbsp;track of my comments and conversations in a more organized way than I do currently through <a href="http://www.cocomment.com">coComment</a> or <a href="http://commentful.blogflux.com">commentful</a>. They&#8217;re really good tools, both of them, but they sporadically don&#8217;t work. coComment, for instance, is a very nice tool that integrates with a lot of social sites apart from just blogging platforms, but somehow for me it isn&#8217;t able to update the latest comments on a lot of them.</li></ul>

<p>The second feature requires the website to publish an XML-RPC API (<a href="http://www.xmlrpc.com/">Here&#8217;s what XML-RPC means</a>)&nbsp;similar to the ones that allow people to be able to post to their blog from desktop applications. WordPress is the only blogging platform that I&#8217;ve worked with, and I&#8217;ve checked &#8211; it doesn&#8217;t have one. There is an XMLRPC for traceback, but nothing for commenting.</p>

<p>Is this something that just hasn&#8217;t been implemented because no one thought of it, or is it just that no one wants to have this &#8211; for fear for people not coming to the blog&#8217;s website for commenting? Or is the concern related to additional spam?</p>

<p>I think lack of visitors is a self-countering argument &#8211; While there may be lesser people visiting to comment on the site&#8217;s interface, there would actually be more people commenting and being active on the site &#8211; and the positive effect of that should balance out the concerns. I&#8217;m not sure if spam is a factor either &#8211; sure, the spammer now has one URL to attack &#8211; but the post id (That I suppose would be a parameter in the call to such a service) is still dynamic. And in any case, the interface just as secure as the rest of the site is to spammers. I&#8217;m not sure how captchas can be implemented in such a service &#8211; but I&#8217;m sure they can be.</p>

<p>Reading this on a newsreader? Click the post title, wait for the page to load, scroll to the bottom for my cute little commenting interface, and fill in your thoughts!</p>
]]></content:encoded>
			<wfw:commentRss>http://sameerahuja.com/blog/dear-wordpress-why-not-an-xml-rpc-for-commenting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP and AJAX: First pitstop</title>
		<link>http://sameerahuja.com/blog/cakephp-and-ajax-first-pitstop/</link>
		<comments>http://sameerahuja.com/blog/cakephp-and-ajax-first-pitstop/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 08:35:59 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://sameerahuja.com/blog/2007/04/cakephp-and-ajax-first-pitstop/</guid>
		<description><![CDATA[I started out with the Cake framework for PHP some time back, and it&#8217;s been a mixed ride so far. Cake is a very powerful, but still somewhat incipient framework built on the MVC pattern of Ruby on Rails. Among it&#8217;s several cool features is inbuilt support for AJAX based applications. A good starter tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>I started out with the Cake framework for PHP some time back, and it&#8217;s been a mixed ride so far. Cake is a very powerful, but still somewhat incipient framework built on the MVC pattern of Ruby on Rails. Among it&#8217;s several cool features is inbuilt support for AJAX based applications.</p>

<p>A good starter tutorial in that direction lies <a href="http://grahambird.co.uk/cake/tutorials/ajax.php">here</a>. And another one, a <a href="http://rossoft.wordpress.com/2006/06/04/tutorial-web-based-search-engine-for-flickr/">Flickr Gallery</a>.<br /><br />However, if you&nbsp;belong to the population of web developers who are <strong>not </strong>psychic <strong>or </strong>lucky, you would probably have&nbsp;something like this staring your face when you try the above tutorials -</p>

<blockquote> <p>Fatal error: Call to a member function on a non-object in [...]/cake/app/views/layouts/default.thtml on line 8</p></blockquote>

<p>That&#8217;s because both the tutorials do not explicitly mention that you need to declare the AJAX helper in the controller file if you are going to use AJAX features. The best way to do that is to copy the app_controller.php file from your cake/ directory, put it in your app/ directory and add the following piece of code to it:</p>

<p><pre class="brush: php;">var $helpers = array('Html', 'Ajax', 'Javascript');</pre>This declares the Helpers in the parent class of all the controllers, so that you don&#8217;t need to re-declare them later. If you do that, though, make sure to have all the helpers declared again.</p>
]]></content:encoded>
			<wfw:commentRss>http://sameerahuja.com/blog/cakephp-and-ajax-first-pitstop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
