<?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>Jabbering Giraffe &#187; google</title>
	<atom:link href="http://happygiraffe.net/blog/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Wed, 19 Oct 2011 10:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Google Analytics in XHTML</title>
		<link>http://happygiraffe.net/blog/2009/06/06/google-analytics-in-xhtml/</link>
		<comments>http://happygiraffe.net/blog/2009/06/06/google-analytics-in-xhtml/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 18:58:39 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1530</guid>
		<description><![CDATA[I&#8217;e been attempting to get Google Analytics to work correctly in both FireFox and IE6 for a site at $WORK. This is not normally a problem, apart from the fact that we&#8217;re serving up pages to firefox as application/xhtml+xml in &#8230; <a href="http://happygiraffe.net/blog/2009/06/06/google-analytics-in-xhtml/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;e been attempting to get Google Analytics to work correctly in both FireFox and IE6 for a site at $WORK.  This is not normally a problem, apart from the fact that we&#8217;re serving up pages to firefox as <code>application/xhtml+xml</code> in order to get <a href="http://en.wikipedia.org/wiki/MathML">MathML</a> support.</p>
<p>Now, the sample code from Google is pretty gnarly.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src='&quot; + gaJsHost + &quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&quot;));
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
try{
var pageTracker = _gat._getTracker(&quot;UA-xxxxxx-x&quot;);
pageTracker._trackPageview();
} catch(err) {}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>This fails in XHTML as <a href="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite">document.write() isn&#8217;t there</a>.</p>
<p>I tried a number of ways to get this to work.</p>
<ul>
<li>Replace <code>document.write()</code> with some jQuery code to insert a script tag.
<ul>
<li>This didn&#8217;t work in IE6 &#8212; as the second script block ended up getting called before newly inserted script tag had loaded.</li>
<li> But I did find out that jQuery will replace script tags with Ajax calls for you.  Which means you don&#8217;t end up with a script tag in the DOM tree, which is highly confusing when you&#8217;re looking for it in firebug.</li>
</ul>
</li>
<li>Replace <code>document.write()</code> with native DOM calls to insert a script tag.
<ul>
<li>I did find the neat idea of adding an id to the script tag you&#8217;re currently in, so you know where to insert new DOM elements.</li>
<li>But it still failed, and for the same reason as above.</li>
</ul>
</li>
</ul>
<p>I was just about to start implementing something <em>evil</em> involving <code>setInterval()</code>, when I realised…</p>
<p>… this site will never use SSL!</p>
<p>So I replaced the code to generate a script tag <em>with the script tag</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'http://www.google-analytics.com/ga.js'</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
try{
var pageTracker = _gat._getTracker(&quot;UA-xxxxxx-x&quot;);
pageTracker._trackPageview();
} catch(err) {}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Tada!  If only I&#8217;d thought of this a few hours earlier…  The moral is to be more aware of the context in which you&#8217;re doing something.  Keep an eye on the &#8220;big picture&#8221; to use a particularly horrible metaphor.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/06/06/google-analytics-in-xhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dependency complexity</title>
		<link>http://happygiraffe.net/blog/2009/06/01/dependency-complexity/</link>
		<comments>http://happygiraffe.net/blog/2009/06/01/dependency-complexity/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:52:04 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1521</guid>
		<description><![CDATA[I love the google-collections library. It&#8217;s got some really nice features. But, it’s not stable yet. They&#8217;ve explicitly stated that until they hit 1.0 it’s not going to be a stable API. So there are changes each release. Nothing major, &#8230; <a href="http://happygiraffe.net/blog/2009/06/01/dependency-complexity/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I love the <a href="http://code.google.com/p/google-collections/">google-collections</a> library. It&#8217;s got some <a href="http://happygiraffe.net/blog/2008/07/22/google-collections-to-the-rescue/">really nice features</a>. But, it’s not stable yet. They&#8217;ve explicitly stated that until they hit 1.0 it’s not going to be a stable API. So there are changes each release. Nothing major, but changes.</p>
<p>As an example, in the jump from <a href="http://code.google.com/p/google-collections/wiki/Releases#Release_0.9_(snapshot_20090211)">0.9</a> to <a href="http://code.google.com/p/google-collections/wiki/Releases#Release_1.0_(RC1_-_20090406)">1.0rc1</a>, the static methods on the Join class became the fluent API on the <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Joiner.html">Joiner</a> class.</p>
<p>(as an aside, could we have some <a href="http://google-collections.googlecode.com/svn/tags/">tags</a>, please?)</p>
<p>Following this change is simple.</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;"><span style="color: #440088;">@@ -310,7 +310,7 @@</span>
         <span style="">&#125;</span> catch <span style="">&#40;</span>KeyStoreException e<span style="">&#41;</span> <span style="">&#123;</span>
             throw new RuntimeException<span style="">&#40;</span>e<span style="">&#41;</span>;
         <span style="">&#125;</span>
<span style="color: #991111;">-        return Join.join<span style="">&#40;</span>&quot; | &quot;, principals<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        return Joiner.on<span style="">&#40;</span>&quot; | &quot;<span style="">&#41;</span>.join<span style="">&#40;</span>principals<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>
&nbsp;
     /**</pre></div></div>

<p>But the knock-on effect comes when you start getting lots of things which have google-collections dependencies.  At <code>$WORK</code>, I&#8217;ve got a project whose dependencies look like this.</p>
<div style="text-align:center;"><img src="http://happygiraffe.net/blog/wp-content/uploads/2009/06/dc2-deps-before.png" alt="dc2-deps-before.png" border="0" width="264" height="380" /></div>
<p>I wanted to extract a part of DC2 into its own library, <code>commslib</code>.  This was pretty easy as the code was self contained.  Naturally, I wanted it to use the latest version of everything, so I upgraded google-collections to 1.0rc1.  Again, fairly simple.</p>
<p>This is what I ended up with.</p>
<div style="text-align:center;"><img src="http://happygiraffe.net/blog/wp-content/uploads/2009/06/dc2-deps-after.png" alt="dc2-deps-after.png" border="0" width="293" height="380" /></div>
<p>Except that now there&#8217;s a problem.</p>
<ul>
<li>commslib uses <code>Joiner</code>, so it&#8217;ll blow up unless it upgrade <code>DC2</code>&#8216;s google-collections to 1.0rc1.</li>
<li>GSK uses <code>Join</code>, so it&#8217;ll blow up if I upgrade <code>DC2</code>&#8216;s google-collections to 1.0rc1.</li>
</ul>
<p>And thus have I painted myself into a corner.  <img src='http://happygiraffe.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As it happens, <code>DC2</code> had a <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management">dependencyManagement</a> section forcing everything to use google-collections 0.8.  &rarr; Instant <em>BOOM</em>.</p>
<p>The solution is to upgrade all my dependencies to use google-collections 1.0rc1.  But this turns out to be a much larger change than I had originally envisaged, as now I have to create releases for two dependent projects.  This isn&#8217;t too much of a hassle in this case (yay for the <a href="http://maven.apache.org/plugins/maven-release-plugin/">maven-release-plugin</a>), but it could be a large undertaking if either of those projects is not presently in a releasable state.</p>
<p>I&#8217;m not trying to pick on google-collections (I still love it).  I&#8217;m just marvelling at how quickly complexity can blossom from something so simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/06/01/dependency-complexity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Collections to the rescue</title>
		<link>http://happygiraffe.net/blog/2008/07/22/google-collections-to-the-rescue/</link>
		<comments>http://happygiraffe.net/blog/2008/07/22/google-collections-to-the-rescue/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 14:36:02 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2008/07/22/google-collections-to-the-rescue/</guid>
		<description><![CDATA[A few days ago, I was writing a piece of code that turned a line at a time into an Object. And it was using iterators. I had a RecordStream, which wrapped a LineStream (just a thin veneer over LineNumberReader). &#8230; <a href="http://happygiraffe.net/blog/2008/07/22/google-collections-to-the-rescue/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few days ago, I was writing a piece of code that turned a line at a time into an Object.  And it was using iterators.  I had a RecordStream, which wrapped a LineStream (just a thin veneer over <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/LineNumberReader.html">LineNumberReader</a>).</p>
<p>Then I discovered that there was a terminating record at the end of each file.  And it was in a completely different format to all the other lines.  Bother.</p>
<p>Ok, I know, I&#8217;ll insert <em>another</em> iterator in the middle, which specifically ignores that record.  Well, easier said than done as it turns out.  I spent the best part of a day trying to create an Iterator which reads the next value and pretends that it&#8217;s not there.  It turns out to have an awful lot of state.</p>
<p>Eventually I managed the task, and it worked.  But boy, was it ugly.  And it was long&#8212;about two pages of code.</p>
<p>Then the light bulb went off.  I remembered that <a href="http://code.google.com/p/google-collections/">google collections</a> had some tools for dealing with <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Iterators.html">Iterators</a>.  In particular, there&#8217;s a function <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Iterators.html#filter(java.util.Iterator,%20com.google.common.base.Predicate)">filter()</a>, which takes a <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Predicate.html">Predicate</a>.  And look!  The <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Predicates.html">Predicates</a> class contains some handy builtins!</p>
<p>After about 5 minutes work, my two pages of code boiled down to three lines of code.</p>
<pre>
    import static com.google.common.base.Predicates.*;

    private static final String END_RECORD = "END RECORD,END RECORD,END RECORD";

    public Iterator&lt;T&gt; iterator() {
        // Produce an iterator that returns one line at a time.
        Iterator&lt;String&gt; lines = new LineStream(reader).iterator();
        // A predicate to return all records which are not the end record.
        Predicate&lt;String&gt; notEndRecord = not(isEqualTo(END_RECORD));
        // Apply the predicate to the iterator.
        final Iterator&lt;String&gt; it = Iterators.filter(lines, notEndRecord);
        return new Iterator&lt;T&gt;() { … };
    }
</pre>
<p>Marvellous and powerful stuff.  It&#8217;s seriously worth checking out in case you haven&#8217;t played with it before.  My favourite is the static factory methods.  e.g.</p>
<pre>
  // Before
  Map&lt;String, String&gt; myMap = new HashMap&lt;String,String&gt;();

  // After
  Map&lt;String, String&gt; myMap = Maps.newHashMap();
</pre>
<p>Isn&#8217;t it lovely how the compiler just figures it all out for you?  Anything that can save space like that has to be a Good Thing™.</p>
<p>There are a whole bunch of other useful things in there.</p>
<ul>
<li><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Preconditions.html#checkNotNull(T)">Preconditions.checkNotNull()</a> is a compact way of validity checking your arguments.</li>
<li><a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Join.html">Join.join()</a>&#8212;I don&#8217;t know how many times I&#8217;ve written this by hand (usually badly).  Much better to have somebody else do it for me.</li>
</ul>
<p>Do yourself a favour and go check them out.  You won&#8217;t regret it.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2008/07/22/google-collections-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Google Code Hosting &#8211; svn import</title>
		<link>http://happygiraffe.net/blog/2007/07/16/google-code-hosting-svn-import/</link>
		<comments>http://happygiraffe.net/blog/2007/07/16/google-code-hosting-svn-import/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 13:52:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2007/07/16/google-code-hosting-svn-import/</guid>
		<description><![CDATA[I&#8217;ve just started a new project on Google Code Hosting (of which more later). I&#8217;ve been developing it in a local svn repository, and I&#8217;d like to transfer it up to the google svn server. This isn&#8217;t easy. Google help &#8230; <a href="http://happygiraffe.net/blog/2007/07/16/google-code-hosting-svn-import/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just started a new project on <a href="http://code.google.com/hosting/">Google Code Hosting</a> (of which more later).  I&#8217;ve been developing it in a local svn repository, and I&#8217;d like to transfer it up to the google svn server.</p>
<p>This isn&#8217;t easy.  Google help has <a href="http://code.google.com/support/bin/answer.py?answer=56673&#38;topic=10386">How do I import an existing Subversion repository?</a>, but that&#8217;s only half the answer.  The problem is that I develop many projects in one single repository (I find it easier to manage).  So I wanted to export a <em>subset</em> of my repository to google.</p>
<p>Sadly, <a href="http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt">svnsync</a> doesn&#8217;t support that.</p>
<p>The workaround is simple (yet tiresome).  You have to create a mini-repository containing just the subset of the original repository you want, then send <em>that</em> to google.  This is what I came up with to export just <code>/project</code>.</p>
<pre>
  % svnadmin create /tmp/project-repos
  % svnadmin dump -q /home/svn/public |
  &gt; svndumpfilter include /project --renumber-revs -drop-empty-revs |
  &gt; svnadmin load -q /tmp/project-repos
</pre>
<p>Of course, now that I have the subset isolated, the path structure is wrong.  Everything is living under <code>/project/trunk</code> instead of <code>/trunk</code>.  So, we have to fix that.</p>
<pre>
  % svn mv file:///tmp/project-repos/project/trunk file:///tmp/project-repos/
  % svn rm file:///tmp/project-repos/project -m 'No longer needed.'
</pre>
<p>Finally, I can use svnsync to send the changes to google:</p>
<pre>
  % svnsync init --username happygiraffe.net https://project.googlecode.com/svn file:///tmp/project-repos
  % svnsync sync --username happygiraffe.net https://project.googlecode.com/svn file:///tmp/project-repos
</pre>
<p>Phew.  What a palaver.  It would have been nice if they could accept a file containing the output of <code>svnadmin dump</code> instead&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2007/07/16/google-code-hosting-svn-import/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Reader</title>
		<link>http://happygiraffe.net/blog/2005/10/13/google-reader/</link>
		<comments>http://happygiraffe.net/blog/2005/10/13/google-reader/#comments</comments>
		<pubDate>Thu, 13 Oct 2005 06:48:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aggregator]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2005/10/13/google-reader/</guid>
		<description><![CDATA[Like many other people in the blogosphere, I&#8217;ve been playing with Google Reader, and I&#8217;ve found it to be a pretty good aggregator. But it&#8217;s lacking one big, important feature: The &#8220;catchup&#8221; button. I want to be able to mark &#8230; <a href="http://happygiraffe.net/blog/2005/10/13/google-reader/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Like many other people in the blogosphere, I&#8217;ve been playing with <a href="http://www.google.com/reader/lens/">Google Reader</a>, and I&#8217;ve found it to be a pretty good aggregator.  But it&#8217;s lacking one big, important feature: The &#8220;catchup&#8221; button.  I want to be able to mark all my feeds read with a single keystroke.</p>
<p>What would be really nice would be the ability to mark all articles from a selected feed read.  But I think that&#8217;s difficult in the current interface because it seems to melt all articles into the same pot.</p>
<p>Before I sound too critical, I have to point out that what Google Reader does, it does very well.  I found it quick, responsive and easy on the eyes.  Good work, chaps!</p>
<p>Oh, and there&#8217;s one really, really important innovation: It brings vi-style keystrokes to the people.  Yay Google!</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2005/10/13/google-reader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

