<?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>Squio.blog &#187; ajax</title>
	<atom:link href="http://squio.nl/blog/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://squio.nl</link>
	<description>Creative internet development</description>
	<lastBuildDate>Thu, 03 Jun 2010 07:35:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Cakephp: isAjax weirdness</title>
		<link>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/</link>
		<comments>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 11:43:20 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/</guid>
		<description><![CDATA[Currently, I&#8217;m doing a project in CakePHP. There&#8217;s lots to say about cake, here just a quick note, for myself or for anyone in case you are running into the same problem. Situation: you are using the Ajax helper, which contains a method isAjax() &#8211; returns true if the request was an Ajax request. Typically, [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://squio.nl/blog/wp-content/2008/02/cake12b.png' alt='Cakephp 1.2' style="float:right;width:100px;height:100px" />Currently, I&#8217;m doing a project in CakePHP.</p>
<p>There&#8217;s lots to say about cake, here just a quick note, for myself or for anyone in case you are running into the same problem.</p>
<p>Situation: you are using the Ajax helper, which contains a method <code>isAjax()</code> &#8211; returns <code>true</code> if the request was an Ajax request.</p>
<p>Typically, you use this method inside a view, to conditionally render content for regular/ajax views. Example:</p>
<p><code>...<br />
if (! $ajax->isAjax()) {<br />
  // render general page stuff<br />
}<br />
  // render stuff for both regular- and ajax view<br />
...<br />
</code></p>
<p>My problem was that the <code>isAjax()</code> call never returned true, regardless of ajax/regular request method.</p>
<p>The solution appears to be really simple: you should include the <code>'RequestHandler'</code> component in your controller class. This one took me way too long to figure out! </p>
<p><code><br />
	public $components = array (<br />
		'Auth',<br />
		'Cookie',<br />
		'RequestHandler'<br />
	);<br />
</code></p>
<p><strong>Update</strong> my situation was even worse than described above; I use a redirect between controllers within an Ajax call, something which is officially supported by Cake 1.2. This worked just fine in Safari, but not in Firefox (and Opera) &#8211; these browsers would not load the Ajax view but rather the complete page, almost crashing the server by consuming huge amounts of memory.</p>
<p>Read on&#8230;<span id="more-146"></span></p>
<p>Lots and lots of troubleshooting did not help, after which I tried my last bet: update Cake to the current development build.<br />
And that appeared to be <em>the</em> solution! Not only solves this the Ajax detection problem, the whole application seems to be much more efficient too.</p>
<p>The Cake SVN repository is organised somewhat unconventional. A quick recipe for getting the last development revision&#8230;</p>
<p>The repository is rooted at <a href="https://svn.cakephp.org/repo/">https://svn.cakephp.org/repo/</a>.</p>
<p>There are the common subdirectories, amongst others:</p>
<ul>
<li>branches</li>
<li>tags</li>
<li>trunk</li>
</ul>
<p>In this case, Trunk contains the last released (beta) versions, while branches contain, well, the trunk repository.<br />
So in order to get the current HEAD release, you have to get the source from <a href="https://svn.cakephp.org/repo/branches/1.2.x.x/">/branches/1.2.x.x</a>.</p>
<p>Command line:</p>
<p><code>svn co https://svn.cakephp.org/repo/branches/1.2.x.x/</code></p>
<p>I&#8217;m working with revision 6461, highly recommended!</p>
<div class="tags"><a href="http://technorati.com/tag/cakephp" rel="tag">cakephp</a> <a href="http://technorati.com/tag/mvc" rel="tag"> mvc</a> <a href="http://technorati.com/tag/ajax" rel="tag"> ajax</a> <a href="http://technorati.com/tag/isajax" rel="tag"> isajax</a></div><br />
[ratings]</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Cakephp%3A+isAjax+weirdness+http://squio.nl/?p=146" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Cakephp%3A+isAjax+weirdness+http://squio.nl/?p=146" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/&amp;title=Cakephp%3A+isAjax+weirdness" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=146&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2008/02/14/cakephp-isajax-weirdness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greasemonkey, for the intranet!</title>
		<link>http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/</link>
		<comments>http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 13:13:46 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[fashionable web]]></category>
		<category><![CDATA[Peter Laird]]></category>
		<category><![CDATA[web builder]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/</guid>
		<description><![CDATA[Ever since I started using Greasemonkey (GM), I found more and more ways to improve aspects of public websites. What&#8217;s more, GM also proved to be invaluable for quick testing of mashups and other fashionable web 2.0 tricks.Using GM this way, it can be used as a tool for rapid prototyping of advanced user interfaces [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squio.nl/blog/wp-content/2007/08/greasemonkey_icon.gif" align="right" alt="Greasemonkey Icon" />Ever since I started using <a href="https://addons.mozilla.org/firefox/748/">Greasemonkey</a> (GM), I found more and more ways to <a href="http://www.xs4all.nl/~jlpoutre/BoT/Greasemonkey/" title="Greasemonkey scripts">improve aspects of public websites</a>. What&#8217;s more, GM also proved to be invaluable for quick testing of mashups and other fashionable web 2.0 tricks.Using GM this way, it can be used as a tool for rapid prototyping of advanced user interfaces and Ajax enhancements as well. So a web builder could write a quick and dirty user script in order to prove the viability of a concept.That would be the natural border for user scripts within the corporate world, as far as I could imagine.Wrong!  <a href="http://dev2dev.bea.com/blog/plaird/">Peter Laird</a>, Managing Architect for the WebLogic Portal engineering team at BEA, wrote a 5-part blog series about deploying Greasemonkey user scripts in the corporate environment.
<ol>
<li><a href="http://dev2dev.bea.com/blog/plaird/archive/2007/07/mashups_using_g.html">More Mashups: Using Greasemonkey to Weave New Features into Web Sites</a></li>
<li><a href="http://dev2dev.bea.com/blog/plaird/archive/2007/07/oreilly_safari.html">Building a Greasemonkey Mashup Tutorial</a></li>
<li><a href="http://dev2dev.bea.com/blog/plaird/archive/2007/08/greasemonkey_in.html">Greasemonkey in the Enterprise: When is GM the Right Tool for IT?</a></li>
<li><a href="http://dev2dev.bea.com/blog/plaird/archive/2007/08/enterprise_grea.html">Beware of Greasemonkey&#8217;s Inverted Security Model</a></li>
<li><a href="http://dev2dev.bea.com/blog/plaird/archive/2007/08/enterprise_grea_1.html">Solving the Greasemonkey Script Versioning Problem</a></li>
</ol>
<p>The first two articles are a very nice and moderate technical introduction to Greasemonkey. The next installment starts to position GM as a valuable corporate intranet addition, with a checklist to find out if it is the right tool for your situation. The last two articles focus on the important security- and deployment issues, focused on the corporate situation again.I&#8217;m really curious whether corporate IT department heads will really be convinced by these articles. The checklist (part 3) lists a number of very frequent corporate / intranet annoyances where GM will help and the author&#8217;s background (BEA) is very trustworthy, so I give it a good chance.Definitely worth a read, even if you&#8217;re not a corporate IT head!<div class="tags"><a href="http://technorati.com/tag/greasemonkey" rel="tag">greasemonkey</a> <a href="http://technorati.com/tag/firefox" rel="tag"> firefox</a> <a href="http://technorati.com/tag/mashup" rel="tag"> mashup</a> <a href="http://technorati.com/tag/corporate" rel="tag"> corporate</a> <a href="http://technorati.com/tag/enterprise" rel="tag"> enterprise</a> <a href="http://technorati.com/tag/intranet" rel="tag"> intranet</a></div>[ratings]</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Greasemonkey%2C+for+the+intranet%21+http://squio.nl/?p=131" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Greasemonkey%2C+for+the+intranet%21+http://squio.nl/?p=131" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/&amp;title=Greasemonkey%2C+for+the+intranet%21" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=131&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2007/08/20/greasemonkey-for-the-intranet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reasons for stripping down</title>
		<link>http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/</link>
		<comments>http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 09:02:07 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[webdev]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Christian Heilmann]]></category>
		<category><![CDATA[corporate software/intranet stuff]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[semanic web]]></category>
		<category><![CDATA[web techniques]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/</guid>
		<description><![CDATA[Christian Heilmann won&#8217;t go naked tomorrow. His reasons not to do so are: Most CSS naked sites are generated from templates, so what is the individual blog author&#8217;s effort? The target audience is missed, it is merely preaching for already converted style purists The target market is missed: those really crappy intranets within big corporations [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wait-till-i.com/index.php?p=422">Christian Heilmann won&#8217;t go naked</a> tomorrow.</p>
<p>His reasons not to do so are:</p>
<ul>
<li>Most CSS naked sites are generated from templates, so what is the individual blog author&#8217;s effort?</li>
<li>The target audience is missed, it is merely preaching for already converted style purists</li>
<li>The target market is missed: those really crappy intranets within big corporations</li>
</ul>
<p>My reasons for still participating with my (slightly modified) WordPress blog&#8230;</p>
<p>You definitely have a point with the generated code/templates based blogs. Last year, I adapted my site layout to have the content first and navigation and boilerplate stuff to the bottom in the HTML stream. That was fun and even sped up the apparent rendering of my site <em>with CSS enabled</em>. So I did learn something usefull in the process as well.</p>
<p>That <a href="http://www.xs4all.nl/~jlpoutre/BoT/Greasemonkey/">site structure is generated</a> from templates as well, but all handcrafted XML/XSLT stuff (in Firefox, select the alternate style <em>CSS Naked Day</em> to see how it works).</p>
<p>Now I&#8217;m using WordPress and, indeed, just installed a plugin for &#8216;Naked Day. OK, so <a href="http://squio.nl/blog/2007/04/03/upcoming-css-naked-day/">my contribution was to adapt that plugin for WP 2.1.x</a>.</p>
<p>About the corporate software/intranet stuff: you are completely right. But here I feel that bottom-up advocacy <em>does work in the longer term</em>. In my former (large) organisation, I got quite  a few corporate J2EE developers interested in standards compliant CSS web techniques, especially after they had a very bad time trying to meet the requirements from our User Interaction specialists. The advance of Ajax does the rest.</p>
<p>In just another 5 years or so, even those big vendors might have &#8220;got it&#8221; (and then go wondering what that &#8220;semanic web&#8221; stuff is all about <img src='http://squio.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
<div class="tags"><a href="http://technorati.com/tag/css" rel="tag">css</a> <a href="http://technorati.com/tag/css-naked-day" rel="tag"> css-naked-day</a> <a href="http://technorati.com/tag/standards" rel="tag"> standards</a> <a href="http://technorati.com/tag/advocacy" rel="tag"> advocacy</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Reasons+for+stripping+down+http://squio.nl/?p=79" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Reasons+for+stripping+down+http://squio.nl/?p=79" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/&amp;title=Reasons+for+stripping+down" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=79&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2007/04/04/reasons-for-stripping-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freebase: Life, the Universe, and Everything</title>
		<link>http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/</link>
		<comments>http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 14:57:59 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[semweb]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[200 OK;]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Baltimore]]></category>
		<category><![CDATA[community vigilance tools]]></category>
		<category><![CDATA[Danny Ayers]]></category>
		<category><![CDATA[Denny Vrandecic]]></category>
		<category><![CDATA[Frank Zappa]]></category>
		<category><![CDATA[front end web application]]></category>
		<category><![CDATA[Green Genes]]></category>
		<category><![CDATA[Hot Rats;]]></category>
		<category><![CDATA[Maryland]]></category>
		<category><![CDATA[Peaches;]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[semantic web terminology]]></category>
		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/</guid>
		<description><![CDATA[Just after my post Freebase as productive playground, I recieved an invite (thanks a lot, Ken!) and I have played around a little&#8230; Now, a lot of relevant things have been said around the &#8216;net (see my prevous post). And, there have been some in-depth reviews of the model of Freebase, related to the Semantic [...]]]></description>
			<content:encoded><![CDATA[<p>Just after my post <a href="http://squio.nl/blog/2007/03/26/freebase-as-productive-playgound/">Freebase as productive playground</a>, I recieved an invite (thanks a lot, Ken!) and I have played around a little&#8230;</p>
<p>Now, a lot of relevant things have been said around the &#8216;net (see my prevous post). And, there have been some in-depth reviews of the model of Freebase, related to the Semantic Web: <a href="http://semantic.nodix.net/2007/03/freebase.html">Denny Vrandecic</a>, <a href="http://dannyayers.com/2007/03/15/white-lines">Danny Ayers</a>.</p>
<p>I will not repeat these comments here, rathter give my first impressions as a curious explorer.</p>
<p>First of all, the <a href="http://www.freebase.com">Freebase website</a> is very heavy on Ajax, which seems to be almost essential for the functionality provided.<br />
As a novice user, you are launched at the &#8220;User Profile&#8221; page. While starting to fill out some profile fields, you are immediately confronted with the <a href="http://www.freebase.com/view/documentation/ch02.html">Metaweb Object Model</a> (login needed).</p>
<h2>The Freebase Object Model</h2>
<p>The model roughly consists of:</p>
<ul>
<li>Domain (the top level ontology, e.g. &#8216;<code>music</code>&#8216; or &#8216;<code>business</code>&#8216;)</li>
<li>Type (a class within a domain, e.g. <code>music/artist</code>)</li>
<li>Topic (an individual object, let&#8217;s say Frank Zappa as musical artist)</li>
<li>Property (attributes, e.g. &#8216;name&#8217; or &#8216;date of birth&#8217;, or a relation with another Topic)</li>
</ul>
<p>So when you start editing your User Profile, you are actually filling out a template of a User Type. Within this type, the attribute &#8220;Me as a Freebase Topic&#8221; links to an object of class (Type) &#8216;<code>people/person</code>&#8216;. The distinction is somewhat like the difference between a real world (verifyable) person, and personas this person might use. From the Freebase documentation:</p>
<blockquote><p>A person topic is distinct from a user in Metaweb. Users have profiles that can only be edited by the users themselves. A person topic can be edited by anyone and is intended as a factual representation of details about a person.</p></blockquote>
<p>A couple of primitive Types exist (e.g. <code>type/int</code>or <code>type/text</code>), but in most cases more complex types are used for attributes. So Place of Birth is not just a text sctring, but an object of type &#8216;<code>location/location</code>&#8216;. This ensures that all occurrences of &#8216;<em>Baltimore, Maryland</em>&#8216; refer to the same object.</p>
<p>Following the link to this location, you can zoom in further and find that the object is not only of type &#8216;<code>location/location</code>&#8216;, but also &#8216;<code>location/citytown</code>&#8216; and &#8216;<code>location/us_county</code>&#8216;.</p>
<h2>Queries and results</h2>
<p>Freebase is called a database for a reason: you can run queries against it and get results back. Now being heavily rooted in  the semantic web terminology, you might expect to use <a href="http://www.w3.org/TR/rdf-sparql-query/">SPARQL</a> as a query language, and results back in some <a href="http://www.w3.org/RDF/">RDF</a> representation. But this is not the case.</p>
<p>Both queries and results are expressed in plain JSON, which is becoming the data transport protocol of choice for most Ajax projects and frameworks.<br />
<span id="more-72"></span></p>
<p>A trivial example of using this <em>Metabase Query Language</em>.</p>
<p>Query:</p>
<pre>
{
  "qname": {
    "query":{
      "type" : "/music/artist",
      "name" : "Frank Zappa",
      "album" : {
        "name" : "Hot Rats",
        "track" : []
      }
    }
  }
}</pre>
<p>Response:</p>
<pre>
 ({
  "status": "200 OK",
  "qname": {
    "status": "/mql/status/ok",
    "result": {
      "album": {
        "track": [
          "Peaches en Regalia",
          "Willie the Pimp",
          "Son of Mr. Green Genes",
          "Little Umbrellas",
          "The Gumbo Variations",
          "It Must Be a Camel"
        ],
        "name": "Hot Rats"
      },
      "type": "/music/artist",
      "name": "Frank Zappa"
    }
  }
})</pre>
<p>This makes building a front end web application for Freebase almost trivial!</p>
<h2>API: full CRUD interface</h2>
<p>The API doesn&#8217;t stop at letting you query the existing Freebase data. You can <em>Create, Read, Update or Delete</em> objects all through the JSON API, as long as you have sufficient permissions to do so.</p>
<p>This means that you can soon start using Freebase as an alternative for you own, isolated database for your web applications. And so make the world a better place by sharing all data you and your users enter through your application. And, of course, benefit from the data which is already in Freebase. The only consideration is the license: all data in Freebase is available under the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution license</a> (CC-BY).</p>
<p>All this functionality can be vulnerable to spamming or vandalizing, just like Wikipedia content. The Freebase folks have clearly thought about this problem. They provide a granular permission mechanism, as well as community vigilance tools like &#8220;report as spam&#8221; links and &#8220;revert&#8221; operations.</p>
<h2>Conclusion</h2>
<p>So far, my first impressions are overwhelming in a good sense.<br />
The Freebase already contains quite a few models as well as a lot of content, mostly imported from compatible sources like Wikipedia.</p>
<p>The future of Freebase will depend on the adoptation by developers and users equally. Will we be able to get the <a href="http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything">Answer to Life, the Universe and Everything</a> soon, or will it become the next <a href="http://en.wikipedia.org/wiki/Dmoz#Controversy_and_criticism">Dmoz</a> project?</p>
<div class="tags"><a href="http://technorati.com/tag/freebase" rel="tag">freebase</a> <a href="http://technorati.com/tag/semweb" rel="tag"> semweb</a> <a href="http://technorati.com/tag/semanticweb" rel="tag"> semanticweb</a> <a href="http://technorati.com/tag/review" rel="tag"> review</a> <a href="http://technorati.com/tag/json" rel="tag"> json</a> <a href="http://technorati.com/tag/ajax" rel="tag"> ajax</a> <a href="http://technorati.com/tag/api" rel="tag"> api</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Freebase%3A+Life%2C+the+Universe%2C+and+Everything+http://squio.nl/?p=72" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Freebase%3A+Life%2C+the+Universe%2C+and+Everything+http://squio.nl/?p=72" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/&amp;title=Freebase%3A+Life%2C+the+Universe%2C+and+Everything" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=72&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2007/04/02/freebase-life-the-universe-and-everything/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP, Reflection and JSON: stream your objects</title>
		<link>http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/</link>
		<comments>http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/#comments</comments>
		<pubDate>Tue, 17 Oct 2006 21:18:29 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[webdev]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSON stream]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/</guid>
		<description><![CDATA[Amongst all the improvements in PHP 5 is the concept of Reflection. If you&#8217;re a Java person, you will be familiar with this concept. In just a few words, Reflection means that Objects are open to (self-) inspection, so that you can interrogate an object for all kinds of properties at runtime. Now if you [...]]]></description>
			<content:encoded><![CDATA[<p>Amongst all the improvements in PHP 5 is the concept of <a href="http://www.php.net/language.oop5.reflection">Reflection</a>. If you&#8217;re a Java person, you will be familiar with this concept.</p>
<p>In just a few words, Reflection means that Objects are open to (self-) inspection, so that you can interrogate an object for all kinds of properties at runtime.</p>
<p>Now if you have classes with getter (and setter) methods, there are some very elegant techniques with reflection. Normally, these getters and setters are used to give access to the data contained in the object. Good Object Oriented practice makes use of these <a href="http://en.wikipedia.org/wiki/Data_object">Data Objects</a> to build a clean boundary between the data and implementation details.</p>
<p>So, let&#8217;s assume that you have painfully crafted a class definition with accessors and you want to serialize the contained data as <a href="http://json.org/">JSON</a> over the wire. Of course, you can write a <em>getJsonString()</em> method for every class. But Reflection gives you a much nicer option.</p>
<p>An example of serialization into JSON, entirely based on Reflection:<br />
<span id="more-45"></span></p>
<pre>
function toDataObj($myObj) {
    $ref = new ReflectionClass($myObj);
    $data = array();
    foreach (array_values($ref-&gt;getMethods()) as $method) {
        if ((0 === strpos($method-&gt;name, "get"))
                &#038;&#038; $method-&gt;isPublic()) {
            $name = substr($method-&gt;name, 3);
            $name[0] = strtolower($name[0]);
            $value = $method-&gt;invoke($myObj);
            if ("object" === gettype($value)) {
                $value = toDataObj($value);
            }
            $data[$name] = $value;
        }
    }
    return $data;
}

print json_encode(toDataObj($myObj));
</pre>
<p><strong>What is going on here?</strong><br />
First, I have a <em>data object</em>, referenced by <em>$myObj</em>, with a couple of getter methods.<br />
Then, a new reflection object is instantiated for <em>myObj.</em> This reflection object contains a whole lot of reflection methods, of which <em>getMethods()</em> is used here.<br />
In the <em>foreach</em> loop, a every method of the <em>myObj</em> is inspected in turn. Here we look for methods whose name start with &#8220;get&#8221; (the <em>name</em> property). Then we normalize the name (getMyVariable => myVariable) and call the original method of <em>myObj</em> through <em>invoke($myObj)</em>.<br />
If the returned value is an object itself, the function <em>toDataObj</em> is recursively called with this object.<br />
Then, the name, value pair is stored in a hash list (called Array in PHP).<br />
Finally, this hash is serialized into JSON.</p>
<p>The cool thing is that this function is really universal.<br />
It will take just any object with getter methods and due-fully serialize the data, which then can be turned into a JSON stream, ready to consume in your Ajax applications.</p>
<p><strong>Reflection class</strong><br />
The Reflection class and all of its subclasses are available in PHP 5.1.x, no need to include anything.</p>
<p><strong>PHP JSON</strong><br />
If you&#8217;re running PHP 5.1.x, you most likely have <em>json_encode()</em> available, but you may need to enable the <a href="http://www.aurore.net/projects/php-json/">php_json</a> extension in php.ini.<br />
Otherwise <a href="http://www.aurore.net/projects/php-json/">download</a>, build and install the extension and add the line <em>extension=php_json.so</em> (*nix) or <em>extension=php_json.dll</em> (Win32) in php.ini and you should be up and running.</p>
<div class="tags"><a rel="tag" href="http://technorati.com/tag/php">php</a><a rel="tag" href="http://technorati.com/tag/reflection">reflection</a><a rel="tag" href="http://technorati.com/tag/json">json</a><a rel="tag" href="http://technorati.com/tag/oop">oop</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=PHP%2C+Reflection+and+JSON%3A+stream+your+objects+http://squio.nl/?p=45" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=PHP%2C+Reflection+and+JSON%3A+stream+your+objects+http://squio.nl/?p=45" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/&amp;title=PHP%2C+Reflection+and+JSON%3A+stream+your+objects" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=45&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/10/17/php-refection-and-json-stream-your-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binary Ajax: EXIF Thumbnail Fetcher</title>
		<link>http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/</link>
		<comments>http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/#comments</comments>
		<pubDate>Tue, 29 Aug 2006 15:21:55 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/</guid>
		<description><![CDATA[Just a quick note: my first Binary Ajax project is ready for release (well, testing I mean). EXIF Thumbnail Fetcher is a Greasemonkey user script, which lets you retrieve the embedded thumbnail of a digital camera image over the &#8216;net, without downloading more than strictly needed. See my previous post for some more details. And, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note: my first <em>Binary Ajax</em> project is ready for release (well, testing I mean).
</p>
<p><a href='http://www.xs4all.nl/~jlpoutre/BoT/Javascript/ExifThumbs/'>EXIF Thumbnail Fetcher</a> is a Greasemonkey user script, which lets you retrieve the embedded thumbnail of a digital camera image over the &#8216;net, without downloading more than strictly needed.
</p>
<p>See my <a href='http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/'>previous post</a> for some more details. And, please test it and let me know your experiences!
<div class="tags"><a rel="tag" href="http://technorati.com/tag/firefox">firefox</a><a rel="tag" href="http://technorati.com/tag/ajax">ajax</a><a rel="tag" href="http://technorati.com/tag/XMLHttpRequest">XMLHttpRequest</a><a rel="tag" href="http://technorati.com/tag/exif">exif</a><a rel="tag" href="http://technorati.com/tag/greasemonkey">greasemonkey</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher+http://squio.nl/?p=42" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher+http://squio.nl/?p=42" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/&amp;title=Binary+Ajax%3A+EXIF+Thumbnail+Fetcher" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=42&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/08/29/binary-ajax-exif-thumbnail-fetcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remotely extracting image thumbnails with Binary-Ajax</title>
		<link>http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/</link>
		<comments>http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/#comments</comments>
		<pubDate>Fri, 25 Aug 2006 15:33:23 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[HTTP 1.1]]></category>
		<category><![CDATA[smarter solution]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/</guid>
		<description><![CDATA[Now retrieving binary data through XHR is possible, I started working on a proof of concept: a remote Exif data loader. The idea is simple: if you have your original digicam photos online, just bulk downloaded from the camera, you only have very non-descriptive names for reference. Was that one interesting image called IMG_1234.jpg, or [...]]]></description>
			<content:encoded><![CDATA[<p>Now <a href='http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/'>retrieving binary data through XHR</a> is possible, I started working on a proof of concept: a remote Exif data loader.
</p>
<p>The idea is simple: if you have your original digicam photos online, just bulk downloaded from the camera, you only have very non-descriptive names for reference. Was that one interesting image called IMG_1234.jpg, or was that the blurry one and are you looking for IMG_2345.jpg? Your only option seems to download the whole blob, easily several MBytes per image for  contemporary multi Mega Pixel camera.
</p>
<p>Now there is hope for a smarter solution.<br />Most digicam images have embedded meta data in the <a href='http://www.exif.org/specifications.html'>Exif format</a>, often including a nice little thumbnail.
</p>
<p>Wouldn&#8217;t it be nice to retrieve this embedded data over the network to preview a photo by thumbnail?
</p>
<p>I haven been working on this problem and have a proof of concept ready, coded as <a href='http://greasemonkey.mozdev.org/'>Greasemonkey</a> user script for Firefox (1.5 and 2.0).
</p>
<p>From a very high level the working principle is:
</p>
<p><span id="more-40"></span>For each image,<br />    •    Open a binary clean XHR connection<br />    •    Retrieve the first one K of image data (using HTTP 1.1 Byte Ranges)<br />    •    Find embedded Exif data; if found<br />    •    Retrieve the rest of the Exif header<br />    •    Extract the embedded thumbnail<br />    •    Append a new image, set source to thumbnail data (hex-encoded as data:xxx/yyy URL).
</p>
<p>All in all, the savings in bandwidth are at least some 90%, as the embedded Exif data with thumbnail seldom exceed 60k, and even significantly less for older camera models.
<p>
<a class="imagelink" href="http://squio.nl/blog/wp-content/exif-dirlist.png" title="Exif directory listing"><img id="image41" src="http://squio.nl/blog/wp-content/exif-dirlist.png" alt="Exif directory listing" /></a></p>
<p>Now this works, but it is still very rough around the edges.<br />Firefox gets completely locked up during data retrieval and parsing, I suspect that this is due to the CPU intensive exif parsing and synchronous XHR data retrieval.
</p>
<p>I&#8217;ll be polishing and optimizing the script, planning a next post in a few days&#8230;.
</p>
<div class="tags"><a rel="tag" href="http://technorati.com/tag/firefox">firefox</a><a rel="tag" href="http://technorati.com/tag/ajax">ajax</a><a rel="tag" href="http://technorati.com/tag/XMLHttpRequest">XMLHttpRequest</a><a rel="tag" href="http://technorati.com/tag/exif">exif</a></div>
<p></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Remotely+extracting+image+thumbnails+with+Binary-Ajax+http://squio.nl/?p=40" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Remotely+extracting+image+thumbnails+with+Binary-Ajax+http://squio.nl/?p=40" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/&amp;title=Remotely+extracting+image+thumbnails+with+Binary-Ajax" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=40&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/08/25/remotely-extracting-image-thumbnails-with-binary-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Retrieving binary data with XMLHttpRequest, again</title>
		<link>http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/</link>
		<comments>http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 15:13:42 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Marcus Granado]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/</guid>
		<description><![CDATA[A few months ago I concluded that it is simply not possible to download binary files for Ajax purposes, at least not with Firefox (see Retrieving binary data with XMLHttpRequest). Last Monday, Marcus Granado posted &#8220;Downloading Binary Streams with Javascript XMLHttpRequest&#8220;, where he demonstrates that it is possible to get a binary clean stream through [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I concluded that it is simply not possible to download binary files for Ajax purposes, at least not with Firefox (see <a href="http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/">Retrieving binary data with XMLHttpRequest</a>).</p>
<p>Last Monday, Marcus Granado  posted &#8220;<a href="http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html">Downloading Binary Streams with Javascript XMLHttpRequest</a>&#8220;, where he demonstrates that it <em>is</em> possible to get a binary clean stream through XMLHtttpRequest.<br />
It boils down to using the right Charset in with the proprietary overrideMimeType() function. Read his post to see how.</p>
<p>In one word: <em>Wow</em>! This opens up a whole lot of new applications, for instance with Greasemonkey scripts.</p>
<p>I&#8217;m glad I have been proven wrong!</p>
<p><strong>Update:</strong> this does not work for me as is&#8230;</p>
<p>What happens is that all bytes above 127 (decimal) are returned as a really big value. The solution, however, appears to be very simple:</p>
<pre>var filestream = load_url(url);
var c = filestream.charCodeAt(x);
if (c > 255) c -= 63232;</pre>
<p>Apparently, the extra high value is not caused by extra bytes being gobbled up, but constructed on the fly. Luckily this is done in such a deterministic way.</p>
<p>I&#8217;m working with javascript in a UTF-8 page context and, although I have experimented with some other character sets for the page, this made no difference. I&#8217;m using Firefox 1.5.0.6, Mac OSX right now.</p>
<p>I&#8217;m really interested in other users&#8217; experiences. Please share them via the feedback form!</p>
<div class="tags"><a rel="tag" href="http://technorati.com/tag/firefox">firefox</a><a rel="tag" href="http://technorati.com/tag/ajax">ajax</a><a rel="tag" href="http://technorati.com/tag/XMLHttpRequest">XMLHttpRequest</a><a rel="tag" href="http://technorati.com/tag/binary">binary</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Retrieving+binary+data+with+XMLHttpRequest%2C+again+http://squio.nl/?p=39" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Retrieving+binary+data+with+XMLHttpRequest%2C+again+http://squio.nl/?p=39" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/&amp;title=Retrieving+binary+data+with+XMLHttpRequest%2C+again" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=39&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/08/24/retrieving-binary-data-with-xmlhttprequest-again/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Keeping up with change</title>
		<link>http://squio.nl/blog/2006/07/27/keeping-up-with-change/</link>
		<comments>http://squio.nl/blog/2006/07/27/keeping-up-with-change/#comments</comments>
		<pubDate>Thu, 27 Jul 2006 13:38:39 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/2006/07/27/keeping-up-with-change/</guid>
		<description><![CDATA[Greasemonkey is a great tool for changing a web page, just after it has been loaded. But this does not work for all those Ajaxified web 2.0 pages, where content is loaded on the fly. There is a solution, though: just listen for DOM events which modify the page&#8217;s content. Keep up with the DOM [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://greasemonkey.mozdev.org/'>Greasemonkey</a> is a great tool for changing a web page, just after it has been loaded. But this does not work for all those <em>Ajaxified web 2.0 pages,</em> where content is loaded on the fly.
</p>
<p>There is a solution, though: just listen for DOM events which modify the page&#8217;s content. Keep up with the DOM changes so to say!
</p>
<p><strong>Background</strong>
</p>
<p>In the days before <a href='http://flickr.com/'>Flickr</a> was acquired by Yahoo, I made a <a href='http://www.xs4all.nl/~jlpoutre/BoT/Javascript/Flickr/'>Greasemonkey user script: Flickr &#8211; Link Original Image</a> that inserts direct links to the original uploaded photos on top of thumbnails. This worked fine, by parsing the DOM just after page load and looking for every occurrence of photo thumbnails.
</p>
<p>Now, after the recent relaunch of Flickr with dynamic Ajax loading, this script fails for those dynamically inserted thumbnails. Simply because they do not exist in the DOM when the page completes loading.
</p>
<p><strong>Solution</strong>
</p>
<p>DOM level 2 specifies a couple of Mutation events. Now I register an event handler for the relevant events and take action whenever an image gets inserted, removed or moved around.
</p>
<p><span id="more-36"></span><strong>Code example</strong></p>
<pre>
// Ajax: new image
document.addEventListener("DOMNodeInserted",
	function(evt) {
		ImgLinks.insertLinks(evt.target);
	}, true);
// Ajax: remove an image
document.addEventListener("DOMNodeRemoved",
	function(evt) {
		var list = evt.target.getElementsByTagName("img");
		for (var i = 0; i < list.length; i++) {
			ImgLinks.remove(list[i]);
		}
	}, true);
// DOM manipulation, which can cause reflow
document.addEventListener("DOMAttrModified",
	function(evt) {
		ImgLinks.reshuffleSoon();
	}, true);
// catch window resize events
window.addEventListener("resize",
	function() { ImgLinks.reshuffle(); }, true);
</pre>
<p>In order to watch an Ajax page, you just have to keep up with the change, and go with the flow!
</p>
<div class="tags"><a href="http://technorati.com/tag/firefox" rel="tag">firefox</a><a href="http://technorati.com/tag/greasemonkey" rel="tag">greasemonkey</a><a href="http://technorati.com/tag/dom" rel="tag">dom</a><a href="http://technorati.com/tag/jsevents" rel="tag">jsevents</a><a href="http://technorati.com/tag/ajax" rel="tag">ajax</a></div>
</p>
<p></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Keeping+up+with+change+http://squio.nl/?p=36" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Keeping+up+with+change+http://squio.nl/?p=36" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/07/27/keeping-up-with-change/&amp;title=Keeping+up+with+change" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=36&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/07/27/keeping-up-with-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieving binary data with XMLHttpRequest</title>
		<link>http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/</link>
		<comments>http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/#comments</comments>
		<pubDate>Tue, 25 Apr 2006 10:37:00 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[firefox]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[HTTP]]></category>

		<guid isPermaLink="false">http://squio.nl/blog/?p=6</guid>
		<description><![CDATA[Using XMLHttpRequest to fetch binary data from a HTTP source is &#8220;problematic&#8221;, as you can find with a simple websearch. But what exactly means &#8220;problematic&#8221; in this context? I gave it a try with Firefox and found out that every byte above 0x7f is translated into 0xfd. In other words: Plain old ASCII is left [...]]]></description>
			<content:encoded><![CDATA[<p>Using XMLHttpRequest to fetch binary data from a HTTP source is &#8220;problematic&#8221;, as you can find with a simple websearch.</p>
<p>But what exactly means &#8220;problematic&#8221; in this context?</p>
<p>I gave it a try with Firefox and found out that every byte above 0x7f is translated into 0xfd. In other words: Plain old ASCII is left alone, everything above it results in a fixed value of 0xfd. Guess this has to do with the stream being interpreted as UTF-8 text&#8230;</p>
<p>A hex dump of a binary range [00 .. ff], retrieved through XMLHttpRequest:</p>
<pre>joe$ od -t x1 -v xhrsweep.bin
0000000    00  01  02  03  04  05  06  07  08  09  0a  0b  0c  0d  0e  0f
0000020    10  11  12  13  14  15  16  17  18  19  1a  1b  1c  1d  1e  1f
0000040    20  21  22  23  24  25  26  27  28  29  2a  2b  2c  2d  2e  2f
0000060    30  31  32  33  34  35  36  37  38  39  3a  3b  3c  3d  3e  3f
0000100    40  41  42  43  44  45  46  47  48  49  4a  4b  4c  4d  4e  4f
0000120    50  51  52  53  54  55  56  57  58  59  5a  5b  5c  5d  5e  5f
0000140    60  61  62  63  64  65  66  67  68  69  6a  6b  6c  6d  6e  6f
0000160    70  71  72  73  74  75  76  77  78  79  7a  7b  7c  7d  7e  7f
0000200    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000220    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000240    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000260    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000300    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000320    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000340    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000360    fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd  fd
0000400</pre>
<div class="tags"><a href="http://technorati.com/tag/firefox" rel="tag">firefox</a><a href="http://technorati.com/tag/ajax" rel="tag">ajax</a><a href="http://technorati.com/tag/XMLHttpRequest" rel="tag">XMLHttpRequest</a><a href="http://technorati.com/tag/test" rel="tag">test</a></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Retrieving+binary+data+with+XMLHttpRequest+http://squio.nl/?p=6" title="Post to Twitter"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-twitter3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Retrieving+binary+data+with+XMLHttpRequest+http://squio.nl/?p=6" title="Post to Twitter">Tweet This</a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to Delicious"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to Delicious">Delicious</a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to Reddit"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to Reddit">Reddit This Post</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to StumbleUpon"><img class="nothumb" src="http://squio.nl/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/&amp;title=Retrieving+binary+data+with+XMLHttpRequest" title="Post to StumbleUpon">Stumble This Post</a></p><img src="http://squio.nl/blog/?ak_action=api_record_view&id=6&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://squio.nl/blog/2006/04/25/retrieving-binary-data-with-xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
