<?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>Divide and Conquer</title>
	<atom:link href="http://www.divideandconquer.se/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.divideandconquer.se</link>
	<description>David's Software Development Blog</description>
	<lastBuildDate>Tue, 15 May 2012 11:12:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Incorect result from WordPress plugin_dir_url</title>
		<link>http://www.divideandconquer.se/2012/05/15/incorect-result-from-wordpress-plugin_dir_url/</link>
		<comments>http://www.divideandconquer.se/2012/05/15/incorect-result-from-wordpress-plugin_dir_url/#comments</comments>
		<pubDate>Tue, 15 May 2012 11:12:18 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=778</guid>
		<description><![CDATA[Consider this code in akismet.php from the ubiquitous Akismet plugin for WordPress: define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ )); My WordPress installation is at /usr/share/wordpress, but the Akismet plugin is installed to /var/lib/wordpress/plugins/akismet/ and there is a symlink (symbolic link) inbetween. This means that __FILE__ is /var/lib/wordpress/plugins/akismet/akismet.php but plugin_dir_url does not understand this, and will incorrectly return: /wp-content/plugins/var/lib/wordpress/plugins/akismet/ This is not [...]]]></description>
			<content:encoded><![CDATA[<p>Consider this code in akismet.php from the ubiquitous <a href="http://wordpress.org/extend/plugins/akismet/" onclick="pageTracker._trackPageview('/outgoing/wordpress.org/extend/plugins/akismet/?referer=');">Akismet plugin for WordPress</a>:</p>
<blockquote>
<pre>define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));</pre>
</blockquote>
<p>My WordPress installation is at /usr/share/wordpress, but the Akismet plugin is installed to /var/lib/wordpress/plugins/akismet/ and there is a symlink (symbolic link) inbetween. This means that __FILE__ is <em>/var/lib/wordpress/plugins/akismet/akismet.php</em> but <a href="http://codex.wordpress.org/Function_Reference/plugin_dir_url" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Function_Reference/plugin_dir_url?referer=');">plugin_dir_url</a> does not understand this, and will incorrectly return:</p>
<blockquote>
<pre>/wp-content/plugins/var/lib/wordpress/plugins/akismet/</pre>
</blockquote>
<p><em></em>This is not a proper URL for my WordPress installation!</p>
<p>I&#8217;m still on WordPress 3.0.something, but it seems like this issue is still a problem in newer versions. There are a number of bug reports for this and similar issues:</p>
<ul>
<li><a href="http://core.trac.wordpress.org/ticket/13550" onclick="pageTracker._trackPageview('/outgoing/core.trac.wordpress.org/ticket/13550?referer=');">13550</a></li>
<li><a href="http://core.trac.wordpress.org/ticket/16199" onclick="pageTracker._trackPageview('/outgoing/core.trac.wordpress.org/ticket/16199?referer=');">16199</a></li>
<li><a href="http://core.trac.wordpress.org/ticket/16953" onclick="pageTracker._trackPageview('/outgoing/core.trac.wordpress.org/ticket/16953?referer=');">16953</a></li>
</ul>
<div>I used the WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28* pair of patches attached to bug report <a href="http://core.trac.wordpress.org/ticket/16953" onclick="pageTracker._trackPageview('/outgoing/core.trac.wordpress.org/ticket/16953?referer=');">16953</a> to solve the issue on my server. It will patch the <a href="http://codex.wordpress.org/Function_Reference/plugin_basename" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Function_Reference/plugin_basename?referer=');">plugin_basename</a> implementation, which seems to contain the root cause of this issue.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/05/15/incorect-result-from-wordpress-plugin_dir_url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Inner-platform API anti-pattern</title>
		<link>http://www.divideandconquer.se/2012/03/09/the-inner-platform-api-anti-pattern/</link>
		<comments>http://www.divideandconquer.se/2012/03/09/the-inner-platform-api-anti-pattern/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 21:04:55 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[API development]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=768</guid>
		<description><![CDATA[I learned the term Inner-platform effect the other day and it perfectly describes an API that I have touched upon. First of all, what is the Inner-platform effect? It basically means that in attempt to make an application as flexible as possible it is implemented so that it creates a new platform that abstracts the original platform. I immediately [...]]]></description>
			<content:encoded><![CDATA[<p>I learned the term <em>Inner-platform effect</em> the other day and it perfectly describes an API that I have touched upon.</p>
<p>First of all, what is the <em>Inner-platform effect</em>? It basically means that in attempt to make an application as flexible as possible it is implemented so that it creates a new platform that abstracts the original platform. I immediately associated to the API described below.</p>
<p>Let&#8217;s see if you can spot the <em>Inner-platform effect</em> in this URL, heavily anonymized but if you have been exposed to it you will probably recognize it immediately.</p>
<pre>http://server/execute/clientSystemConnector
?service=createUser&amp;key=id&amp;value=97580
&amp;key=name&amp;value=David%20Eriksson&amp;key=city&amp;value=Ronneby</pre>
<p>There are actually three examples of the <em>Inner-platform effect</em> in the above URL. The first is example is the &#8220;service&#8221; parameter. Instead of having separate URLs for separate services, the service name is a parameter. This means that the server platform first figures out what to about the /execute/clientSystemConnector path component of the URL, then the Inner Platform need to figure out how to handle the different possible values of the <em>service</em> parameter. (Anyone thinking about a giant &#8220;switch&#8221; statement?)  To avoid the <em>Inner-platform effect</em>, each service should have its own path in the URL.</p>
<p>The second example is blatantly obvious: having <em>key</em> and <em>value</em> parameters that specifies the names and values of the actual parameters. The impact of this &#8220;feature&#8221; is that the platform  provides a list of keys and a list of values to the inner platform, which must extract the actual parameters for use in the application. Without the <em>Inner-platform effect</em> the application could have received the parameters directly from the original platform.</p>
<p>It is probably not so easy to spot the third example, but it concerns authentication. Authentication (if it could be called that) for the services in this API is based on using different paths for different clients. So the above URL is used by the &#8220;clientSystem&#8221;. If &#8220;anotherClientSystem&#8221; need to execute the same service, the URL would be:</p>
<pre>http://server/execute/anotherClientSystemConnector
?service=createUser&amp;key=id&amp;value=97580&amp;...</pre>
<p>So instead of using the built-in authentication mechanism (HTTP Basic Auth) in the platform, the <em>Inner platform</em> goes its own way.</p>
<p>How would I build an API to avoid the Inner platform? Except addressing the above issues I would also make it a POST (or PUT) request, as it handles the creation of a resource.</p>
<pre>POST http://server/user/create HTTP/1.1
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/x-www-form-urlencoded

id=97580&amp;name=David%20Eriksson&amp;city=Ronneby</pre>
<p>Goodbye, Inner Platform!</p>
<p>PS. The origins of the API is probably 8-10 years old by now, and maybe it was a good idea at the time.</p>
<p>PPS. See the <a href="http://en.wikipedia.org/wiki/Inner-Platform_Effect" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Inner-Platform_Effect?referer=');">Inner-platform effect article on wikipedia</a> for more examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/03/09/the-inner-platform-api-anti-pattern/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>No application without a library, no web site without an API?</title>
		<link>http://www.divideandconquer.se/2012/02/21/no-application-without-a-library-no-web-site-without-an-api/</link>
		<comments>http://www.divideandconquer.se/2012/02/21/no-application-without-a-library-no-web-site-without-an-api/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 21:12:32 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=761</guid>
		<description><![CDATA[When I wrote the first versions of Dynamite and Unshield (eight and nine years ago!) I decided from the start that each project had to be implemented in two parts: a library (hopefully reusable) and a command line tool using the library. I believe I learned this from cURL and libcurl, and I still consider [...]]]></description>
			<content:encoded><![CDATA[<p>When I wrote the first versions of <a href="https://github.com/twogood/dynamite" onclick="pageTracker._trackPageview('/outgoing/github.com/twogood/dynamite?referer=');">Dynamite</a> and <a href="https://github.com/twogood/unshield" onclick="pageTracker._trackPageview('/outgoing/github.com/twogood/unshield?referer=');">Unshield</a> (eight and nine years ago!) I decided from the start that each project had to be implemented in two parts: a library (hopefully reusable) and a command line tool using the library. I believe I learned this from <a href="http://curl.haxx.se/" onclick="pageTracker._trackPageview('/outgoing/curl.haxx.se/?referer=');">cURL and libcurl</a>, and I still consider it a best practice. For the purposes of this article, let&#8217;s call it the <em>tool-library pattern</em>.</p>
<p>I don&#8217;t do much C/C++ coding these days, even though I have been ogling <a href="http://spindly.haxx.se/" onclick="pageTracker._trackPageview('/outgoing/spindly.haxx.se/?referer=');">Spindly</a> – the C89 implementation of SPDY forked from <a href="http://libspdy.org/" onclick="pageTracker._trackPageview('/outgoing/libspdy.org/?referer=');">libspdy</a> by cURL author Daniel Stenberg.</p>
<p>For my current clients at work, I do Java coding or webMethods Integration Server development.</p>
<p>When I can spare some and energy for coding at home, it&#8217;s mostly web development in PHP, which brings me back to the tool-library pattern: Unfortunately I have not yet started using a smilar practice for my web development.</p>
<p>So what is the web site equivalence to the tool-library pattern? For a web site I mean that the &#8220;library&#8221; is a web service API that is consumed by the actual web site.  This is called <a href="http://phpadvent.org/2010/first-class-apis-by-helgi-%C3%9Eormar-%C3%9Eorbj%C3%B6rnsson" onclick="pageTracker._trackPageview('/outgoing/phpadvent.org/2010/first-class-apis-by-helgi-_C3_9Eormar-_C3_9Eorbj_C3_B6rnsson?referer=');">First-Class APIs</a> by Helgi Þormar Þorbjörnsson.</p>
<p>The API does not have to be public, but if it is, any other consumers of the API (for example a Smartphone app) will share the same API (or parts of it).</p>
<p>I&#8217;m currently rewriting my <a href="http://folkmun.se/" onclick="pageTracker._trackPageview('/outgoing/folkmun.se/?referer=');">Swedish site for colloquial words and expressions</a> from a hack (!) to a proper layered architecture. The next step will be to add new features and I hope to move these into an API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/02/21/no-application-without-a-library-no-web-site-without-an-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a new headless Ubuntu VM in VirtualBox on FreeBSD</title>
		<link>http://www.divideandconquer.se/2012/02/10/setup-a-new-headless-ubuntu-vm-in-virtualbox-on-freebsd/</link>
		<comments>http://www.divideandconquer.se/2012/02/10/setup-a-new-headless-ubuntu-vm-in-virtualbox-on-freebsd/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 21:24:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=746</guid>
		<description><![CDATA[Download from http://virtualboxes.org/images/ubuntu-server/ VBoxManage register &#8220;/storage2/virtualboxes/Ubuntu server 11.10/Ubuntu server 11.10.vbox&#8221; VBoxManage list vms &#8220;Ubuntu server 11.10&#8243; {231c28f0-19bb-48d7-9db4-ba29de37e5fd} VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;usbehci off VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;pae on VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;nic1 bridged &#8211;bridgeadapter1 em0 VBoxManage sharedfolder add &#8220;Ubuntu server 11.10&#8243; &#8211;name backup &#8211;hostpath /backup nohup VBoxHeadless &#8211;startvm &#8220;Ubuntu server 11.10&#8243; [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>Download from <a href="http://virtualboxes.org/images/ubuntu-server/" onclick="pageTracker._trackPageview('/outgoing/virtualboxes.org/images/ubuntu-server/?referer=');">http://virtualboxes.org/images/ubuntu-server/</a></li>
<li>VBoxManage register &#8220;/storage2/virtualboxes/Ubuntu server 11.10/Ubuntu server 11.10.vbox&#8221;</li>
<li>VBoxManage list vms<br />
&#8220;Ubuntu server 11.10&#8243; {231c28f0-19bb-48d7-9db4-ba29de37e5fd}</li>
<li>VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;usbehci off</li>
<li>VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;pae on</li>
<li>VBoxManage modifyvm &#8220;Ubuntu server 11.10&#8243; &#8211;nic1 bridged &#8211;bridgeadapter1 em0</li>
<li>VBoxManage sharedfolder add &#8220;Ubuntu server 11.10&#8243; &#8211;name backup &#8211;hostpath /backup</li>
<li>nohup VBoxHeadless &#8211;startvm &#8220;Ubuntu server 11.10&#8243; -n 2&gt;&amp;1 &amp;</li>
<li>Connect from desktop via VNC to configure and install guest additions (sudo apt-get install virtualbox-guest-dkms)</li>
</ol>
<div>(Note that my blog converts two dashes to a single long dash above.)</div>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/02/10/setup-a-new-headless-ubuntu-vm-in-virtualbox-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving a DokuWiki site to a new server</title>
		<link>http://www.divideandconquer.se/2012/02/07/moving-a-dokuwiki-site-to-a-new-server/</link>
		<comments>http://www.divideandconquer.se/2012/02/07/moving-a-dokuwiki-site-to-a-new-server/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 21:05:15 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=740</guid>
		<description><![CDATA[I have customized my DokuWiki installation to allow multiple wikis, similar to running multiple WordPress blogs on different domains. My /etc/dokuwiki/local.php looks like this: This means that I have multiple DokuWiki sites in my /var/lib/dokuwiki/ directory. To copy only one of them: Copy the /etc/dokuwiki/hostname directory and symbolic links Copy the /var/lib/dokuwiki/hostname directory and symbolic links Copy [...]]]></description>
			<content:encoded><![CDATA[<p>I have customized my DokuWiki installation to allow multiple wikis, similar to running multiple WordPress blogs on different domains. My <a href="https://gist.github.com/1778113" onclick="pageTracker._trackPageview('/outgoing/gist.github.com/1778113?referer=');">/etc/dokuwiki/local.php</a> looks like this:<br />
<script type="text/javascript" src="https://gist.github.com/1778113.js?file=etc-dokuwiki-local.php"></script><br />
This means that I have multiple DokuWiki sites in my /var/lib/dokuwiki/ directory. To copy only one of them:</p>
<ol>
<li>Copy the /etc/dokuwiki/<em>hostname</em> directory and symbolic links</li>
<li>Copy the /var/lib/dokuwiki/<em>hostname</em> directory and symbolic links</li>
<li>Copy the template(s) from /var/lib/dokuwiki/tpl/<em>templatename</em> or /var/lib/dokuwiki/lib/tpl/<em>templatename</em></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/02/07/moving-a-dokuwiki-site-to-a-new-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing tarsnap on a vanilla Ubuntu server</title>
		<link>http://www.divideandconquer.se/2012/02/04/installing-tarsnap-on-a-vanilla-ubuntu-server/</link>
		<comments>http://www.divideandconquer.se/2012/02/04/installing-tarsnap-on-a-vanilla-ubuntu-server/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 20:24:03 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=735</guid>
		<description><![CDATA[cd /var/tmp/ curl -O https://www.tarsnap.com/download/tarsnap-autoconf-1.0.31.tgz  (or actually the latest version from https://www.tarsnap.com/download.html) sudo apt-get install gcc e2fslibs-dev zlib1g-dev libssl-dev make cd tarsnap-autoconf-1.0.31 (directory name corresponding to the downloaded tarball) ./configure &#38;&#38; make &#38;&#38; sudo make install sudo tarsnap-keygen &#8211;keyfile /root/tarsnap.key &#8211;user username &#8211;machine machinename (note that my blog converts two dashes to a single long dash so you need to [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>cd /var/tmp/</li>
<li>curl -O https://www.tarsnap.com/download/tarsnap-autoconf-1.0.31.tgz  (or actually the latest version from <a href="https://www.tarsnap.com/download.html" onclick="pageTracker._trackPageview('/outgoing/www.tarsnap.com/download.html?referer=');">https://www.tarsnap.com/download.html</a>)</li>
<li>sudo apt-get install gcc e2fslibs-dev zlib1g-dev libssl-dev make</li>
<li>cd tarsnap-autoconf-1.0.31 (directory name corresponding to the downloaded tarball)</li>
<li>./configure &amp;&amp; make &amp;&amp; sudo make install</li>
<li>sudo tarsnap-keygen &#8211;keyfile /root/tarsnap.key &#8211;user <em>username</em> &#8211;machine <em>machinename</em> (note that my blog converts two dashes to a single long dash so you need to edit this line after cut &amp; paste)</li>
<li>sudo cp /usr/local/etc/tarsnap.conf.sample /usr/local/etc/tarsnap.conf</li>
<li>sudo vim /usr/local/etc/tarsnap.conf (if you need to edit any options)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/02/04/installing-tarsnap-on-a-vanilla-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Angående att arrangera tävlingar på Facebook</title>
		<link>http://www.divideandconquer.se/2012/01/15/angaende-att-arrangera-tavlingar-pa-facebook/</link>
		<comments>http://www.divideandconquer.se/2012/01/15/angaende-att-arrangera-tavlingar-pa-facebook/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 17:12:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[svenska]]></category>
		<category><![CDATA[Swedish]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=726</guid>
		<description><![CDATA[(I never post in Swedish on this blog, except now! :-) Jag har skrivit detta blogginlägg enbart för att kunna länka till det när jag ser tävlingar på Facebook, så att jag slipper skriva samma sak om och om igen. Ett tips när det gäller tävlingar på Facebook är att de har väldigt strikta regler [...]]]></description>
			<content:encoded><![CDATA[<p>(I never post in Swedish on this blog, except now! :-)</p>
<p>Jag har skrivit detta blogginlägg enbart för att kunna länka till det när jag ser tävlingar på Facebook, så att jag slipper skriva samma sak om och om igen.</p>
<p>Ett tips när det gäller tävlingar på Facebook är att de har väldigt strikta regler för &#8220;promotions&#8221;, som det kallas! Om ni läser på Facebooks egna sida <a href="https://www.facebook.com/promotions_guidelines.php" onclick="pageTracker._trackPageview('/outgoing/www.facebook.com/promotions_guidelines.php?referer=');">Promotions Guidelines</a> samt artikeln <a href="http://www.socialmediaexaminer.com/facebook-promotions-what-you-need-to-know/" onclick="pageTracker._trackPageview('/outgoing/www.socialmediaexaminer.com/facebook-promotions-what-you-need-to-know/?referer=');">Facebook Promotions: What You Need to Know</a> t.ex. så förstår ni nog vad jag menar.</p>
<p>Det är många som inte har koll på reglerna, men om man ska ignorera dem så är det ju bra att kunna göra en riskanalys:</p>
<blockquote><p>Hur stor är risken och följderna av att Facebook straffar er jämfört med risken och följderna av att era kunder och presumtiva kunder saknar tävlingar på er Facebook-sida?</p></blockquote>
<p>Själv så känner jag inte till något fall där Facebook straffat arrangören av en tävling som bryter mot Facebooks regler, men som sagt tycker jag det är bra att vara medveten om risken.</p>
<p>Jag vill gärna höra om andras erfarenheter kring detta. Kommentera gärna detta inlägg!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2012/01/15/angaende-att-arrangera-tavlingar-pa-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pebble &#8211; more injection and less dependencies in PHP</title>
		<link>http://www.divideandconquer.se/2011/10/05/pebble-more-injection-and-less-dependencies-in-php/</link>
		<comments>http://www.divideandconquer.se/2011/10/05/pebble-more-injection-and-less-dependencies-in-php/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 20:03:09 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Pebble]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=712</guid>
		<description><![CDATA[Dependency Injection (DI) is hardly anything new. I see it as a must for Test Driven Development (TDD). The thing I like most about DI in Java is Autowired in Spring or javax.annotation.Resource, they way member variables are set &#8220;magically&#8221; and the exact details about creation and implementation is located elsewhere. For PHP there are [...]]]></description>
			<content:encoded><![CDATA[<p>Dependency Injection (DI) is hardly anything new. I see it as a must for Test Driven Development (TDD). The thing I like most about DI in Java is <a href="http://static.springsource.org/spring/docs/2.5.5/api/org/springframework/beans/factory/annotation/Autowired.html" onclick="pageTracker._trackPageview('/outgoing/static.springsource.org/spring/docs/2.5.5/api/org/springframework/beans/factory/annotation/Autowired.html?referer=');">Autowired in Spring</a> or <a href="http://download.oracle.com/javase/6/docs/api/javax/annotation/Resource.html" onclick="pageTracker._trackPageview('/outgoing/download.oracle.com/javase/6/docs/api/javax/annotation/Resource.html?referer=');">javax.annotation.Resource</a>, they way member variables are set &#8220;magically&#8221; and the exact details about creation and implementation is located elsewhere.</p>
<p>For PHP there are at least the following implementations related to Dependency Injection:</p>
<ul>
<li><a href="http://www.potstuck.com/2010/09/09/php-dependency-a-php-dependency-injection-framework/" onclick="pageTracker._trackPageview('/outgoing/www.potstuck.com/2010/09/09/php-dependency-a-php-dependency-injection-framework/?referer=');">PHP-Dependency (Pd)</a> - A PHP Dependency Injection Framework</li>
<li><a href="http://pimple.sensiolabs.org/" onclick="pageTracker._trackPageview('/outgoing/pimple.sensiolabs.org/?referer=');">Pimple</a> &#8211; A simple Dependency InjectionContainer for PHP 5.3</li>
<li><a href="http://framework.zend.com/wiki/display/ZFDEV2/Zend+DI+QuickStart" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/wiki/display/ZFDEV2/Zend+DI+QuickStart?referer=');">Zend Framework 2 Dependency Injection</a></li>
</ul>
<p><a href="http://www.potstuck.com/2010/09/09/php-dependency-a-php-dependency-injection-framework/" onclick="pageTracker._trackPageview('/outgoing/www.potstuck.com/2010/09/09/php-dependency-a-php-dependency-injection-framework/?referer=');">PHP-Dependency (Pd)</a> works with @ annotation in the constructor comment, but why involve the constructor? And is a whole <strong>framework</strong> needed? PHP is not Java.</p>
<p><a href="http://pimple.sensiolabs.org/" onclick="pageTracker._trackPageview('/outgoing/pimple.sensiolabs.org/?referer=');">Pimple</a> is very much a Dependency Injection <strong>Container</strong>, not so much about the injection. <strong>Simple</strong>, yes.</p>
<p>When it comes to <a href="http://framework.zend.com/wiki/display/ZFDEV2/Zend+DI+QuickStart" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/wiki/display/ZFDEV2/Zend+DI+QuickStart?referer=');">Zend Framework 2 Dependency Injection</a> I just can&#8217;t grasp how it simplifies anything. It seems to require a lot of boilerplate.</p>
<p>Unsatisfied with the above and a given a dose of NIH Syndrome, I decided to create my own DI system for PHP. After a bit of coding yesterday evening and night I named it <a href="https://github.com/twogood/pebble" onclick="pageTracker._trackPageview('/outgoing/github.com/twogood/pebble?referer=');">Pebble</a> and it is already on github! :-)</p>
<p>My current requirements on Pebble are as follows:</p>
<ol>
<li>It must be possible to inject values of specific properties on class construction</li>
<li>It must work nicely in Zend Framework 1.x</li>
<li>It must not require any configuration files (and especially no XML)</li>
<li>It must be a single .php file for the core implementation</li>
<li>It must provide an open interface for extension and customization</li>
<li>It must work nicely with PHPUnit (especially with the getMock method)</li>
<li>It must work with autoloading of classes in PHP</li>
<li>It is allowed to use PHP 5.3 features</li>
<li>It is allowed to use @-based annotations in docComment, e.g. /** @something */</li>
</ol>
<p>However, I have not yet used Pebble with PHPUnit, so I don&#8217;t know yet if that requirement holds!</p>
<p>Now is a good time for you to examine <a href="https://github.com/twogood/pebble/blob/master/example1.php" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/twogood/pebble/blob/master/example1.php?referer=');">example1.php</a>! The <a href="https://github.com/twogood/pebble/blob/master/README" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/twogood/pebble/blob/master/README?referer=');">README</a> is currently plain-text, I&#8217;ll format it later!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2011/10/05/pebble-more-injection-and-less-dependencies-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Marker and polygon tooltips in Google Maps v3</title>
		<link>http://www.divideandconquer.se/2011/09/15/marker-and-polygon-tooltips-in-google-maps-v3/</link>
		<comments>http://www.divideandconquer.se/2011/09/15/marker-and-polygon-tooltips-in-google-maps-v3/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 07:05:17 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Softhouse]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=698</guid>
		<description><![CDATA[Before I get into the details, please note that this is a quick &#38; dirty solution using google.maps.InfoWindow. No demo, sorry, but please add your improvements in the comments! Marker tooltip I start with the marker, as it is the simplest implementation: function attachMarkerInfoWindow(marker, html) { marker.infoWindow = new google.maps.InfoWindow({ content: html, }); google.maps.event.addListener(marker, 'mouseover', [...]]]></description>
			<content:encoded><![CDATA[<p>Before I get into the details, please note that this is a quick &amp; dirty solution using <em>google.maps.InfoWindow</em>. No demo, sorry, but please add your improvements in the comments!</p>
<h3>Marker tooltip</h3>
<p>I start with the marker, as it is the simplest implementation:</p>
<pre id="line10">function attachMarkerInfoWindow(marker, html)
{
	marker.infoWindow = new google.maps.InfoWindow({
		content: html,
	});
	google.maps.event.addListener(marker, 'mouseover', function() {
		marker.infoWindow.open(map,marker);
	});
	google.maps.event.addListener(marker, 'mouseout', function() {
		marker.infoWindow.close();
	});
}

var marker = new google.maps.Marker({
	position: new google.maps.LatLng(56.183182,15.593239),
});

attachMarkerInfoWindow(marker, '&lt;strong&gt;Softhouse office&lt;/strong&gt;');</pre>
</pre>
<h3>Polygon tooltip</h3>
<p>A polygon does not contain a single position, so where should the tooltip show? One option is to calculate the center of the polygon using <em>getCenter()</em> on <em>google.maps.LatLngBounds</em>, but I decided to use the position of the <em>mouseover</em> event as the position of the InfoWindow. Think about it; the center of the polygon may not actually be inside the polygon!</p>
<p>As a bonus I change the fill opacity while the mouse cursor is inside the polygon.</p>
<pre id="line10">function attachPolygonInfoWindow(polygon, html)
{
	polygon.infoWindow = new google.maps.InfoWindow({
		content: html,
	});
	google.maps.event.addListener(polygon, 'mouseover', function(e) {
		var latLng = e.latLng;
		this.setOptions({fillOpacity:0.1});
		polygon.infoWindow.setPosition(latLng);
		polygon.infoWindow.open(map);
	});
	google.maps.event.addListener(polygon, 'mouseout', function() {
		this.setOptions({fillOpacity:0.35});
		polygon.infoWindow.close();
	});
}

var polygon = new google.maps.Polygon(/* omitted for brevity */);
attachPolygonInfoWindow(polygon, '&lt;strong&gt;Info about this area&lt;/strong&gt;');</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2011/09/15/marker-and-polygon-tooltips-in-google-maps-v3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Facebook Graph API limitations</title>
		<link>http://www.divideandconquer.se/2011/09/07/facebook-graph-api-limitations/</link>
		<comments>http://www.divideandconquer.se/2011/09/07/facebook-graph-api-limitations/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 20:25:21 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.divideandconquer.se/?p=692</guid>
		<description><![CDATA[I have created a Facebook app for the flea market Facebook groups in my area. (Feel free to take a look at http://loppis.blekinge.it/) To read and manage posts I use the Facebook Graph API, but there are a number of limitations: My application supports deleting posts, but Facebook does not allow applications to delete a photo [...]]]></description>
			<content:encoded><![CDATA[<p>I have created a Facebook app for the flea market Facebook groups in my area. (Feel free to take a look at <a href="http://loppis.blekinge.it/" onclick="pageTracker._trackPageview('/outgoing/loppis.blekinge.it/?referer=');">http://loppis.blekinge.it/</a>)</p>
<p>To read and manage posts I use the Facebook Graph API, but there are a number of limitations:</p>
<ul>
<li>My application supports deleting <a href="https://developers.facebook.com/docs/reference/api/post/" onclick="pageTracker._trackPageview('/outgoing/developers.facebook.com/docs/reference/api/post/?referer=');">posts</a>, but Facebook does not allow applications to delete a <a href="https://developers.facebook.com/docs/reference/api/photo/" onclick="pageTracker._trackPageview('/outgoing/developers.facebook.com/docs/reference/api/photo/?referer=');">photo</a></li>
<li><a href="https://developers.facebook.com/docs/reference/api/realtime/" onclick="pageTracker._trackPageview('/outgoing/developers.facebook.com/docs/reference/api/realtime/?referer=');">Real-time Updates</a> do not include support for groups (so I have to poll)</li>
<li>Reading the <a href="https://developers.facebook.com/docs/reference/api/group/" onclick="pageTracker._trackPageview('/outgoing/developers.facebook.com/docs/reference/api/group/?referer=');">Group</a> feed and and using the <em>since</em> and <em>until</em> parameters do not guarantee that you find all posts in a high-traffic group, not even when using the <em>previous</em> and <em>next</em> links in the feed</li>
</ul>
<p><strong>Update</strong> Maybe I should start <a href="https://developers.facebook.com/docs/reference/fql/stream/" onclick="pageTracker._trackPageview('/outgoing/developers.facebook.com/docs/reference/fql/stream/?referer=');">using FQL to query the Group feed</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.divideandconquer.se/2011/09/07/facebook-graph-api-limitations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

