<?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>A day in the life of...</title>
	<atom:link href="http://www.adayinthelifeof.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adayinthelifeof.nl</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 21:17:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Setting up a development environment</title>
		<link>http://www.adayinthelifeof.nl/2012/02/04/setting-up-a-development-environment/</link>
		<comments>http://www.adayinthelifeof.nl/2012/02/04/setting-up-a-development-environment/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 20:08:19 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1637</guid>
		<description><![CDATA[Doing development on multiple projects can be a burden from time to time. One project would be running on PHP 5.3, while another still needs 5.1. Sometimes you need a MySQL server, while on other occasions, you need a NoSQL solution like couchDB or MongoDB together with all kind of gearman functionality. This article shows [...]]]></description>
			<content:encoded><![CDATA[<p>Doing development on multiple projects can be a burden from time to time. One project would be running on PHP 5.3, while another still needs 5.1. Sometimes you need a MySQL server, while on other occasions, you need a NoSQL solution like couchDB or MongoDB together with all kind of gearman functionality. This article shows you how I&#8217;ve setup such a development platform that allows you to quickly create new projects, and still maintain flexibility when you need it.<span id="more-1637"></span></p>
<h2>Step 1: VirtualBox</h2>
<p>Do you have a MacBook? Great. Do you use Ubuntu? Perfect. Are you running on windows? Super!  But just DO NOT USE your own distribution&#8217;s PHP / packages. There are actually good reasons for this:</p>
<ol>
<li>You can easily work with multiple versions of the components (PHP, Apache, Nginx, MySQL etc) without affecting the rest of your (base) system. Especially when you are working with 3rd party systems like Zend Server, things can go downhill really fast if you need to switch from project A to project B since it might involve downgrading packages on your system (which is annoying at best)</li>
<li>9 out of 10 times you are not running on the same OS as your production server will be. Now this isn&#8217;t necessarily a problem, but the closer you can mimic such an environment, the better since it will result in less problems during testing and acceptance.</li>
</ol>
<p>Leave your system as-is, and run through virtualBox. If you don&#8217;t like it, try it anyway as I will explain later why. VMWare Fusion might also do the trick, but has some downsides.</p>
<p>The way I&#8217;ve setup my box is like this:</p>
<p>I have 2 different base templates: a Debian 6.0 template and a CentOS 6.0 template. Besides those templates, I&#8217;ve got a single Debian 6.0 server running which is my &#8220;global&#8221; project machine. Every project that doesn&#8217;t need their own VirtualBox (because it&#8217;s a simple project, or a project that doesn&#8217;t need any 3rd  party components), I create that project on my global machine. Otherwise, I either clone the CentOS 6.0 or Debian 6.0 template. Now here is why you should use VirtualBox instead of VMWare: you can actually create such machines from scratch with the help of Vagrant, which allows you to automatically create and setup virtualboxes from standard templates already available on the internet. Check out http://vagrantup.com/ and http://virtualbox.es for more information, but for now, let&#8217;s just assume you use the standard templates like I have, which are nothing more than simple netinstalls of the distribution, with some of some standard tools installed while doing development like ssh/strace/mc/systools etc.</p>
<p>So: need a quick project: use the global development machine, otherwise, clone a new machine and use that one. They are not killing your performance, they are not eating away precious resources and you can have multiple open at any single moment. I run most virtual machines with 512MB of memory (sometimes more when I need to do stuff with data), and I can still have 5+ machines open at any single time on my MacBook without noticing any downside or any lag.</p>
<p>Using this will isolate everything perfectly: you need to work on a PHP4 legacy application? No prob: just fire up a virtualbox with a PHP4 installation and start developing (assuming you are about to port it to the latest PHP version, right?). You can even work on several projects at the same time. Your boss will love it!</p>
<p>&nbsp;</p>
<h2>Step 2: Virtualhosting &amp; DNS</h2>
<p>Now, we have our virtualboxes which all have a connection to the outside world through the &#8220;Bridge mode&#8221; network adapters. One annoying fact of virtualbox is that you need to connect your Vbox adapter to a physical adapter in your computer. For instance, on my macbook I have to connect adapter 1 to my ethernet adapter. But when I&#8217;m connected to a WiFi system, the virtualboxes cannot use the internet. That&#8217;s why I have two bridged adapters: adapter 1 for ethernet, and adapter 2 for WiFi. No matter how my MacBook is connected, the virtualboxes still have connectivity to the outside world (although it might require a restart of the network interfaces sometimes).</p>
<p>The other adapter  I have is the Host-Only adapter. This allows me to communicate with my virtualboxes on a private subnet (192.168.56.x in my case). I use this for remote debugging and file sharing which we come to later. Normally, the bridged adapters get their IP addresses from a DHCP server you are running at home or at your company network, but you can also opt for some static IP&#8217;s if that makes your life easier. I normally do not care since I do most of my work through the private subnet.</p>
<p>VirtualBox also runs a DHCP server for its host-only (192.168.56.x) network. I don&#8217;t think (never actually checked though) if there is a way to bind IP&#8217;s to your virtualbox MAC addresses, so I normally use static addresses. My global development server is running on 192.168.56.101, all other machines have different IP&#8217;s.</p>
<p>Now that we have network connectivity, we can talk about HTTP. On project-specific boxes I just use standard vhosts and everything, but on my global box this is a pain to work with. I don&#8217;t want to spend time setting up new vhosts, or create some tools that generate vhosts for me or such.. And I don&#8217;t want to place EVERYTHING in one big vhost / documentroot. Apache actually had got a nice feature called &#8220;virtualDocumentRoot&#8221; that allows you to create virtualhosts on the fly, so to speak.</p>
<pre class="brush: plain">&lt;VirtualHost *:80&gt;
  UseCanonicalName Off
  VirtualDocumentRoot     /wwwroot/%1/public

  php_value suhosin.srand.ignore 0·

  &lt;Directory /wwwroot&gt;
    AllowOverride All
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<p>To use the virtualDocumentRoot directive, you must enable the mod_vhost_alias module. For more information, take a look at the documentation at: http://httpd.apache.org/docs/2.3/mod/mod_vhost_alias.html.</p>
<p>So what this does is setup dynamically virtualhost. It will take the first part (%1) of the URL (for instance: the &#8220;projecta&#8221; for the url http://projecta.example.org), and use /wwwroot/projecta/public as the document root. In essence I can create a directory /wwwroot/&lt;myproject&gt; and it will automatically be up and running. However, I use the /public as an extra directory so that would be my public webroot. This means that my framework and other components I don&#8217;t want to be inside my documentroot to be at /www/myproject, while my index.php, css, images and js files live in /www/myproject/public.</p>
<p>With this setup, creating new projects has become literally a five-second job.</p>
<p><strong>Setting up DNS</strong></p>
<p>Because we didn&#8217;t specify a server-name inside our virtualhost, and this actually is the only virtualhost available, everything that points to port 80 on the global development virtualbox IP (192.168.56.101, if you have kept track), will automatically use this virtualhost. So what I&#8217;ve done is setup a development DNS (which actually is a live domain), and let a wildcard point to this IP. This means that outside my notebook, it isn&#8217;t much use for others, so I prepend it with a subdomain.</p>
<p>This means that I&#8217;ve created an A-record:  *.dev.mydomain.com A 192.168.56.101.</p>
<p>At this point, if I go to http://projecta.dev.mydomain.com, it will resolve in 192.168.56.101, it will be picked up by the virtualhost and use the virtualdocumentroot /wwwroot/projecta/public. If I go to http://whatever.dev.mydomain.com, it will go to /wwwroot/whatever/public. Sweet!</p>
<p>If you need separate project boxes, just create another A-record (or update your /etc/hosts file) and point to the corresponding 192.168.56.x IP).</p>
<p>&nbsp;</p>
<h2>Step 3: Setup your tools</h2>
<p>Now that we are able to connect, we need to start developping. Some will try to use the &#8220;shared folders&#8221; option that VirtualBox is able to. I don&#8217;t. I never really liked it, and for all my purposes, I just use a global samba share pointing to /wwwroot for doing all work. This means I don&#8217;t need to fuss around with strange FTP-uploads everything I modify a file, and my IDE is perfectly happy as treating it as a local filesystem since it doesn&#8217;t know any better. If you use VIM or another editor, you can work directly from the box through SSH (I always have Iterm2 open to the boxes). Samba is fast enough when using locally on your system. Even things like searching through your projects isn&#8217;t a real problem. Especially when you are running from an SSD, but even with a normal SATA drive, I didn&#8217;t notice any problems, even on large projects with the Zend of Symfony frameworks.</p>
<p>So connect your samba share to /wwwroot, mount it to your local /wwwroot, create a W:\ drive, whatever. At this point, creating a directory automatically creates a new project.</p>
<p><strong>xdebug</strong></p>
<p>Please, pretty please with sugar on top, if you don&#8217;t use XDebug, install it and try to use it. It will make your life easier and development / debugging faster. I know it will be hard to not use print_r() and var_dumps &amp; die(), but really, don&#8217;t do that anymore. XDebug is so much better in doing a debugging job than you ever can with print_r.</p>
<p>Installing XDebug is a breeze and most distributions come with a pre-compiled XDebug package, so an &#8220;apt-get install php5-xdebug&#8221; or &#8220;yum install php53-xdebug&#8221; should be more than enough to get it up and running. Note however, that you have to change some settings in XDebug to get it up and running for remote debugging:</p>
<pre class="brush: plain">xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.idekey = "PhpStorm1"
xdebug.remote_port = 9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1</pre>
<p>It basically tells XDebug that whenever it has been started, it must connect to the debugger that is running on the machine that is requesting the page (basically, it connects back to $_SERVER[REMOTE_ADDR]:9000). We talk about connecting XDebug in the next section, for now it&#8217;s enough to realize that XDebug will *always* try to connect to a remote debugger because we have configured &#8220;xdebug.remote_autostart = 1&#8243;. Some might not like this, and want to manually start XDebug. This would mean you have to set the option to 0, and issue a XDEBUG_SESSION_START=&lt;idekey&gt; to start the system automatically. Most browsers have extensions that actually makes it easier for you to do this. For instance, the FireFox extension &#8220;easy-debug&#8221;. But on the whole I really like the autostart feature, since I don&#8217;t have to worry about browsers. Every call, even from curl or standard telnet, will trigger XDebug.</p>
<h2>Step 4: Set up your IDE</h2>
<p>Now, we should setup our IDE. I personally like PHPStorm, but any other would probably work too (netbeans, eclipse, aptana etc). Since we have connected our /wwwroot directly into our main machine, we can just create new projects inside this directory by creating a subdirectory. PhpStorm saves all project information inside a hidden &#8220;.idea&#8221; directory inside the project root, but I normally let my version control system (git normally) ignore this by adding the directory to the .gitignore file. For SVN users you can issue a propset svn:ignore to ignore the directory (if you don&#8217;t use a VCS, shame on you!).</p>
<p>Now, the only thing really left to do is setting up remote debugging. With PhpStorm, this is a breeze: just hit the menu &#8220;Run | Start listening for PHP Debug Connections&#8221; and you are good to go! There is a shortcut on the toolbar (the red phone), that turns green when remote debug listening is enabled. What it does is opening a port (9000) on your local system. Since we have ordered xdebug to create a remote connection back to the requesting client, it means that when we start listening for connections, and we hit refresh in our browser, xdebug will automatically connect to phpstorm. You can set a breakpoint at the beginning of your index.php (or other entrypoint) to see  xdebug in action.</p>
<p>The only thing that you need to make sure that you setup your path mapping correctly. Sometimes it cannot find the correct source-file to debug. For instance: your PHP file does a &#8220;include(&#8220;../test.php&#8221;)&#8221;, it only knows that you want the file /wwwroot/yourproject/test.php (assuming that you called the include file from /wwwroot/yourproject/public/index.php). XDebug will &#8220;tell&#8221; your IDE that it needs the file /wwwroot/yourproject/test.php.</p>
<p>Now, your IDE doesn&#8217;t know anything about /wwwroot/yourproject, since that is the directory on the REMOTE filesystem, which may or may not be mapped differently. On a windows machine, your IDE might know this file as W:\yourproject\test.php, or on your ubuntu machine, /mnt/wwwroot/yourproject/test.php, or on your macbook /Volumes/wwwroot/test.php. So you must tell PHPStorm to map the file to the correct directory. Luckily, PHPSTorm will tell you that it cannot find the file, and gives you the opportunity to map the file. What I normally do is not map that file directly, but map the root-directory. So I will tell phpstorm that the remote &#8220;/wwroot/yourproject&#8221; directory is locally mapped to &#8220;/Volumes/wwwroot/yourproject&#8221;. From that mapping, it can deduce where all other files inside your project are so you would only need to do the mapping once (I don&#8217;t know if you can create a global mapping in phpstorm: /wwwroot to /Volumes/wwwroot, because that would mean that phpstorm would always find the files, regardless of project.</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>That&#8217;s it, really. There are all kind of nifty things you can add yourself, like using VCS through the IDE, but I prefer command line so I always have a iTerm open to do the git-stuff. And I&#8217;ve got a global alias for /phpmyadmin, so I can always directly goto my phpmyadmin screen (yeah, sue me) and some other nifty stuff. On the whole, it&#8217;s a very easy setup that works pretty well. I can do symfony2, zend framework side by side without problem. I have a simple setup of memcache, mysql, and other components on my global machine to test stuff and when doing more powerful jobs, I clone a new machine and work from there. It&#8217;s easy, fast, and really isolate your work. And I truly work on two or three projects at once, on different PHP versions as well, so isolation like this is perfect, although I assume you all have other ways of setting up your development environment. Do you use this kind of isolation? Do you have another way of setting up projects? Do you use vagrant and/or puppet to maintain your machines? I&#8217;m curious on how to improve my system, and how yours work, so do leave a comment :)</p>
<p>&nbsp;</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2012%2F02%2F04%2Fsetting-up-a-development-environment%2F&amp;title=Setting%20up%20a%20development%20environment" id="wpa2a_2"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2012/02/04/setting-up-a-development-environment/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Pragmatic investment plan 2011-2012 : The update</title>
		<link>http://www.adayinthelifeof.nl/2012/02/02/pragmatic-investment-plan-2011-2012-the-update/</link>
		<comments>http://www.adayinthelifeof.nl/2012/02/02/pragmatic-investment-plan-2011-2012-the-update/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 07:55:25 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1630</guid>
		<description><![CDATA[A little bit less than one year ago (actually, 9 months ago), I&#8217;ve created a blogpost about creating a Pragmatic Investment Plan. Even though the year is not finished for me yet, I still like to share my experiences with such a plan and what actually has come from it.First off, I must confess that [...]]]></description>
			<content:encoded><![CDATA[<p>A little bit less than one year ago (actually, 9 months ago), I&#8217;ve created a <a href="http://www.adayinthelifeof.nl/2011/04/21/pragmatic-investment-plan-may-2011-2012/" target="_blank">blogpost</a> about creating a Pragmatic Investment Plan. Even though the year is not finished for me yet, I still like to share my experiences with such a plan and what actually has come from it.<span id="more-1630"></span>First off, I must confess that the plan didn&#8217;t play a very big role in the last year. As always, things won&#8217;t work out the way you think they would, and last year wasn&#8217;t any different. First of all, I&#8217;ve started freelancing which I may or may pursue for the next year. There are other (personal) reasons on whether or not continue, so I&#8217;m can&#8217;t say I will be in the same situation next year. However, I will try to make the new &#8217;12-&#8217;13 plan to be more of a guideline for the coming year.</p>
<p>Nevertheless, looking back at the plan, a lot of it has been achieved, even though some not quite as I planned. Let&#8217;s go over the list:</p>
<h2>Broad Goals</h2>
<p><strong>Certify for LPI 301 &#8211; and at least 2 (30x) specialties.</strong><br />
Status: did not succeed.<br />
Reason: I&#8217;ve actually scheduled these exams and had to reschedule three times before I decided to cancel them. There wasn&#8217;t enough time for me to actually do some studying (since I don&#8217;t know everything (yet) there is to know about LDAP).</p>
<p><strong>Certify for MySQL Clustering.<br />
</strong>Status: did not succeed.<br />
Reason: Again, I&#8217;ve scheduled this together with the LPI-301. But afterwards found out that the exam materials (the book itself) isn&#8217;t available anymore. I find it strange that the exam itself is still given, but after looking at the syllabus, I&#8217;ve decided I would drop this exam on the grounds that it&#8217;s worthless. <strong><br />
</strong></p>
<p><strong>Trying NOT to be part of everything (hard to do).<br />
</strong>Status: did not succeed.<br />
Reason: There are many nice things, and I like them all. Writing a patch here, submitting a pull request there. Writing program A, B AND C at the same time.. It&#8217;s horrible! I really need to focus less projects.</p>
<p><strong>Getting more articles published.</strong><br />
Status: success!<br />
Reason: More articles have been published in PHP|architect magazine. And once in a while, when I feel up to it, and they want some articles, I&#8217;m happy to write an article about &#8211; something.</p>
<p><strong>Finding out if ANYONE is interested in co-writing a book about Operating Systems programming.</strong><br />
Status: success!<br />
Outcome: nobody is interested :-). However, writing a book is something that is currently in progress, and I&#8217;ll probably can tell you a bit more about it very soon&#8230; (secretsesss)<strong></strong></p>
<p><strong>Writing more blog posts on CybOS.<br />
</strong>Status: did not succeed<br />
Reason: I haven&#8217;t spend much time on CybOS, but I&#8217;ve managed to finish up enough to place it online on github. So it&#8217;s out there for everybody to take a look at the internals of an OS. However, more stuff should be written about it.</p>
<p><strong>Attend FOSDEM 12</strong><br />
Status: will not succeed<br />
Reason: personal plans interfere for me to come over.</p>
<p><strong>Attend Confoo 12 (as a speaker preferably)</strong><br />
Status: did not succeed<br />
Reason: I blame Anna Fillina for this (no, just joking). However, seeing the schedule makes me even more sad I won&#8217;t be attending. But there is always hope for next year.</p>
<p><strong>Attend Tek12 (as a speaker preferably)<br />
</strong>Status<strong>: </strong>will succeed<br />
Reason: I&#8217;ve been selected as a speaker and will be talking about three very neat subjects.<strong><br />
</strong></p>
<p><strong>Attend Loadays 12<br />
</strong>Status: no clue<br />
Reason: It might interfere with another conference.</p>
<p><strong>If I read books, at least review them on my blog.<br />
</strong>Status: succes!<strong></strong><br />
Reason: On occasion I do read some (marvelous) books. So I&#8217;ve tried to do some blogging about it. Truth be told that I don&#8217;t really know much about reviewing books, and most of the time it&#8217;s not a long post about the actual book. Somehow, reviewing books isn&#8217;t my forte so I&#8217;m not sure if more will follow.. sorry :)</p>
<p>&nbsp;</p>
<h2>Read up on the following (new) techniques</h2>
<p><strong>Read up, and do more work on some interesting Apache TLP projects like:</strong><br />
Apache Couchdb &#8211; very done.<br />
Apache Hadoop &#8211; done.<br />
Apache Mahout &#8211; haven&#8217;t done, except for some basic reading up and fiddling around with it.</p>
<p>&nbsp;</p>
<h2>Areas to investigate</h2>
<p><strong>Write more blog posts about different subjects in both development and system administration.</strong><br />
Status: Meh<br />
Reason: I think I could make more time blogging about the things I do a bit more..</p>
<p><strong>Find out more about devops in general.</strong><br />
Status: done<br />
Outcome: fascinating stuff and probably the way to go.<strong></strong></p>
<p><strong>Learn more about puppet.<br />
</strong>Status: done<strong><br />
</strong>Outcome: spend the last year knowing a lot about puppet and being able to teach to others (which is the only way to know for sure you get it as well). Love the system and we WILL see more of this in the coming years in the PHP-scene as well.</p>
<p><strong> </strong><br />
<strong>Grasp (not only program) the stackbased context switching system.<br />
</strong>Status: success!<br />
Outcome: I get it know.. And yes.. there should be a blogpost about it&#8230;<strong></strong></p>
<p><strong>Knowing git</strong><br />
I&#8217;ve read the git internals twice, and so did I with the pro-git book. Last year was actually the first year I&#8217;ve started to use git for work, and loving it! I don&#8217;t think that A) I like spending time in SVN and B) have anything that is not .git&#8217;ed (even my book is currently versioned by git). After reading the internals for the second time, things actually made much more sense than the first time I&#8217;ve read it :)</p>
<p><strong>Do more with iSCSI.</strong><br />
Status: did not succeed<br />
Reason: mostly because iSCSI didn&#8217;t really crossed my path last year. There was some preliminary stuff I did with vsphere and some SAN setups, but not enough.</p>
<h2>Development</h2>
<p><strong> Get newlib compiled and run userapps in CybOS.</strong><br />
Status: succes!<br />
Reason: did a few attempts but finally managed to get it running thanks to <a href="https://github.com/xomboverlord">xomboverlord toolchain</a><br />
<strong>    </strong></p>
<p><strong>Redesign the Joind.in Android app. Make it a bit more workable, even with the current API.<br />
</strong>Status: did not succeed<br />
Reason: not enough time / bugreports.  So apparently it&#8217;s still working. I do have heard others where thinking about writing a new one for Lorna&#8217;s v2 api.</p>
<p><strong>Redesign EZShopping &#8211; Merge all the stuff still in progress. And deploy a 3.0 version.</strong><br />
Status: meh<br />
Reason: still in progress  <strong></strong></p>
<p><strong>Do some more work on joind.in itself. I tend to do a lot, and move on to the next interesting project. Stop doing that :)</strong><br />
Status: succes<br />
Reason: did (lots more) bug-fixing and features for joind.in, and still find it a nice project to work on. It&#8217;s strange, because the codebase &#8211; well &#8211; isn&#8217;t the best one you&#8217;ll ever meet, but it&#8217;s nice to take your mind of your daily work and just work on these things once in a while. There are times I fix 10 bugs a week, other times I don&#8217;t touch it for months. It&#8217;s just an on-off project so it seems.</p>
<p><strong> Get my Arduino to do something useful.</strong><br />
Status: did not succeed<br />
Reason: can&#8217;t think of anything.. :/</p>
<h2></h2>
<h2>Language of the year</h2>
<p>It was RUBY. Did some work in ruby to try to get the hang of it. I really like the language so I&#8217;ll try to do more things in ruby just for the fun of it.. Also, makes it easier to checkout puppet and even see if we can contribute to it..</p>
<h2>Vanity</h2>
<p><strong>Meet more, and keep in touch with many interesting people.</strong><br />
Status: big success!<br />
Outcome: oh boy. Did I meet interesting people. I don&#8217;t even know if I can name them all, so if I forgot you &#8211; i&#8217;m terribly sorry :)   So hi to Jeroen Keppens &#8211; Wim Godden &#8211; Matthew Weier O&#8217;Phinney &#8211; Zeev Suraski &#8211; Stephan Hochdoerfer &#8211; Anna Fillina &#8211; Juozas (utf8) Kaziukenas &#8211; Rowan Merewood &#8211; Sebastian Marek &#8211; Dean Wilson &#8211; Kris Buytaert &#8211; Karanbir Singh &#8211; and many many others I&#8217;ve talked or got drunk with the last year&#8230; You know what the cool thing is this year? I will meet even more!!!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2012%2F02%2F02%2Fpragmatic-investment-plan-2011-2012-the-update%2F&amp;title=Pragmatic%20investment%20plan%202011-2012%20%3A%20The%20update" id="wpa2a_4"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2012/02/02/pragmatic-investment-plan-2011-2012-the-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX: also useful for writing your documentation</title>
		<link>http://www.adayinthelifeof.nl/2012/01/22/latex-also-useful-for-writing-your-documentation/</link>
		<comments>http://www.adayinthelifeof.nl/2012/01/22/latex-also-useful-for-writing-your-documentation/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 13:54:15 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1583</guid>
		<description><![CDATA[Sometimes you hear about programs but you never really know how awesome they are until you actually use them. Unfortunately, at this point in life I wished I&#8217;ve discovered LaTeX around 15 years ago, when I first heard of it. That would have made the way I would have written documentation the last years massively [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you hear about programs but you never really know how awesome they are until you actually use them. Unfortunately, at this point in life I wished I&#8217;ve discovered LaTeX around 15 years ago, when I first heard of it. That would have made the way I would have written documentation the last years massively different. So hopefully I will get you hooked on LaTeX  with this post.<span id="more-1583"></span>I started to take a look at LaTeX because of a PHP book I&#8217;m currently writing (more news on that very soon!). Before I could start writing, the publisher needed to know how many pages the book would contain. So after I made an initial overview, I started to estimate the number of pages. As you might have guessed, estimations are hard to begin with, especially  because I have no idea how the final markup would look like. Writing a A4 page with text on a 10pt font is take many more words than filling a US Letter with 12pt font.</p>
<p>Now probably the first rule of writing a book is: do not worry about the layout. So obviously &#8211; the thing that worried my was &#8211; in fact &#8211; the layout :). Since I started writing the book in NeoOffice, I tried to mimic the publishers layout as close as possible based on other books to see if my page-estimates were still correct. But trying to create a decent layout in such applications would even make Chuck Norris cry. So that was when I started to look for other ways..</p>
<p>I started to look at LaTeX because I was yahoo&#8217;ing on how to write books in a decent markup and LaTeX popped up a lot. My understanding used to be that LaTeX was a kind of language that makes it easy to create all kind of mathematical formulas. Which is correct, since it makes this very very easy, but LaTeX is much more than that. It&#8217;s an environment where you can focus on writing instead of struggling with markup, while still being able to have full control over it.</p>
<p>I&#8217;ve downloaded the LaTeX package (don&#8217;t get fooled, it takes around 1.5 GIGABYTE of software you need to download) and a front end application (Latexian in my case). This just makes your life easier because LaTeX source files (.tex files, the things you type) needs to be compiled and takes a while to get this all right as a beginner. But about one hour later, I was absolutely stunned on how cool my book was already looking!</p>
<p>Also, when you look at many (technical) books, the layout looks remarkably similar to the standard LaTeX layouts :-) I found that this made estimations on page sizes much easier in the end.</p>
<p>Not only is it possible to create really cool looking books and documents out of the box, but you can also split your documents in smaller files which you just include from your main document. Since my book is around 170 pages, I have one main .TEX file in which I set some default parameters (for instance, I don&#8217;t want my chapters to have numbers, I use code-snippets that are formatted in a certain way etc). This is called a preamble (maybe comparable to a &lt;HEAD&gt;&lt;/HEAD&gt; part of a HTML file). Every chapter itself is a subdirectory in which I have every section broken down in separate files (with large sections, I even have another sub-directory with each subsection as a file). My main .TEX file only includes all the chapter files so I can easily change the chapters by moving them up or down. Everything else gets automatically adjusted.</p>
<p>I&#8217;ve created a simple <a href="https://gist.github.com/1657004#file_intro.tex">LaTeX document</a> to show you how a document would look like:</p>
<p><a href="/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-14.02.10.png"><img class="aligncenter size-medium wp-image-1587" title="Screen Shot 2012-01-22 at 14.02.10" src="/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-14.02.10-300x201.png" alt="" width="300" height="201" /></a></p>
<p>and off course I&#8217;ve compiled the result as an <a href="http://www.adayinthelifeof.nl/wp-content/uploads/2012/01/LatexianExport.pdf">exported PDF file</a>.</p>
<p>As you can see, there is some markup here and there in your sources. To make your life even easier, there are packages you can include in your book which can change literally every aspect of your document. For instance, in my book I&#8217;ve included a package to automatically create an index, a package to wrap text around images and a package to create fancy chapter headers. Even though on occasion I found myself stuck, I just added a small TODO comment (you can comment stuff, how cool!) and looked up the answer later. Most of the problems I experienced was just a lack of knowledge and the answer was found quite quickly.</p>
<p>&nbsp;</p>
<p>Besides being a cool guy for using LaTeX and automatically create very professional documents, LaTeX has some other advantages:</p>
<p><strong>It makes it possible to version control your documents easily.</strong></p>
<p>Since we are not dealing with binary documents but with just text-files. We can use any version control system to version your documents. My book is actually &#8211; together with all examples &#8211; hosted on a private repository on GitHub. I can find out where I was a month ago, others can see its progress and even possible to collaborate easily while working on the same book (if needed).</p>
<p><strong>U</strong><strong>se the editor you want</strong></p>
<p>I&#8217;m currently using <a href="http://tacosw.com/latexian/">Latexian</a>, which is a commercial product (but not expensive), textmate and vim. All of them have LaTeX syntax highlighting and spell-check so again, you only need to deal with the markup.</p>
<p><strong>It&#8217;s still possible to see what you are doing real-time (only, it&#8217;s not really that important anymore)</strong></p>
<p>Latexian has the possibility to automatically compile your .tex-file and display it. There are others that might have the same functionality and it makes it easy when you really need to focus on layout (I had some tables that needed some TLC).</p>
<p><strong>It&#8217;s not only for documents.</strong></p>
<p>Lorna Mitchel uses LaTeX primarily for creating presentations. This is something that LaTeX can do easily as well. For more info, read up on <a href="http://www.lornajane.net/posts/2011/slide-markup-with-latex-first-steps">Lorna&#8217;s blog</a>.</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>Even though I&#8217;m still learning LaTeX true power and discovering more every day, writing (my) documents will be primarily done in LaTeX. It&#8217;s easy, it looks good and it has got loads of advantages over most wysiwyg-editors. And there is absolutely no reason not to do it. Even writing things like functional and technical specification files can easily be done with LaTeX (probably even better, since versioning is a very important aspect for those type of documents).</p>
<p>Give it a try for yourself. You will absolutely love it!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2012%2F01%2F22%2Flatex-also-useful-for-writing-your-documentation%2F&amp;title=LaTeX%3A%20also%20useful%20for%20writing%20your%20documentation" id="wpa2a_6"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2012/01/22/latex-also-useful-for-writing-your-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache&#8217;s fallbackresource: your new .htaccess command</title>
		<link>http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/</link>
		<comments>http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 09:22:59 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Server & Admin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1580</guid>
		<description><![CDATA[So probably you are aware I&#8217;m currently exploring the deeps on the Apache source internals. One of the discoveries I&#8217;ve made was a (for me unknown) command in mod_dir that will make your life a little bit easier: fallbackresource.  One of the things that most frameworks do nowadays is to rewrite all URL&#8217;s to a [...]]]></description>
			<content:encoded><![CDATA[<p>So probably you are aware I&#8217;m currently exploring the deeps on the <a href="http://www.adayinthelifeof.nl/2011/12/22/php-5-4-htrouter-your-personal-apache-2-2-compatible-server/">Apache source internals</a>. One of the discoveries I&#8217;ve made was a (for me unknown) command in mod_dir that will make your life a little bit easier: fallbackresource.  <span id="more-1580"></span></p>
<p>One of the things that most frameworks do nowadays is to rewrite all URL&#8217;s to a single entry point. This entry-point (sometimes called the front-controller), will decide how the request is handled (which controller gets called, if it needs authorization first etc). However, some files, like images, css or javascript files can be fetched directly. It is a bit pointless to rewrite those URL&#8217;s to the front-controller.</p>
<p>Now, normally this would mean you need Apache to configure to rewrite &#8220;non-existing&#8221; URL&#8217;s to the front controller. This is done with a .htaccess:</p>
<pre class="brush: plain; toolbar: false">RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]</pre>
<p>This will check if the requested filename either exists or is a directory, if that is NOT the case, it will call the file index.php (the [L] means this is the last match that needs to be made, if there are my rewrite-rules present, they will be skipped).</p>
<p>Now this is all nice, but a little fragile. It&#8217;s easy to mess things up (as I do on occasion) but there is another command that does the same thing with only one command:</p>
<pre class="brush: plain; toolbar: false">FallbackResource /index.php</pre>
<p>This would be exactely the same as the rewriting seen above, but with less time to create typo&#8217;s. Funny enough, it&#8217;s not part of mod_rewrite, but of mod_dir and is available from Apache 2.2.16 and above.</p>
<p>If you want to do a little bit more exotic stuff, like if you need to use rewriteBase, or maybe have different rewrite conditions, you must stick with the mod_rewrite rules, but most of the time, the fallbackresource will suffice.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2012%2F01%2F21%2Fapaches-fallbackresource-your-new-htaccess-command%2F&amp;title=Apache%26%238217%3Bs%20fallbackresource%3A%20your%20new%20.htaccess%20command" id="wpa2a_8"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I don&#8217;t accept PayPal anymore for payments</title>
		<link>http://www.adayinthelifeof.nl/2012/01/05/why-i-dont-accept-paypal-anymore-for-payments/</link>
		<comments>http://www.adayinthelifeof.nl/2012/01/05/why-i-dont-accept-paypal-anymore-for-payments/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 08:38:48 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1559</guid>
		<description><![CDATA[I think everyone has heard at least 5 five horror-stories when it comes to PayPal. And every time people will be upset, will tweet about it but then go on with their lives. I get it, I do the same thing. But just a few days ago I came acros the gazillionth message about PayPal. [...]]]></description>
			<content:encoded><![CDATA[<p>I think everyone has heard at least 5 five horror-stories when it comes to PayPal. And every time people will be upset, will tweet about it but then go on with their lives. I get it, I do the same thing. But just a few days ago I came acros the gazillionth message about PayPal. <a href="http://www.torontosun.com/2012/01/04/paypal-ordered-canadian-to-smash-antique-violin-woman-alleges">Short story</a>: guy sells violin for 2500$, buyer says it&#8217;s fake, PayPal orders buyer to destroy the violin in order to get money back. In the end: seller looses violin AND 2500$, without ever being able to defend his claim. As LeoMcGarry could have said: The last straw has just been placed on the camel&#8217;s back.. and then PayPal drove over it with a tank..<span id="more-1559"></span></p>
<p><strong>17-01-2012 Update: and yet another conference bites the dust thanks to PayPal. Thanks for proving my point.</strong></p>
<p>Since I am also in the business of e-commerce, I always have strongly suggest not to accept PayPal as a method for payment. Sure, it WILL lose you some clients, but when (not if, but WHEN), things go wrong between you and PayPal, you would have wished you never have accepted those payments. Most people, especially in the Netherlands, are more accustomed to other ways of payment like iDEAL, which is the most common way of dealing with payments. I can convince most of my clients so I see this as a personal win.</p>
<p>During the last 10 years, I&#8217;ve used PayPal, let&#8217;s say around 5 times for receiving payments. This is mainly because I would have been dealing with customers/clients that are living inside the United States and Canada. Those countries prefer to write cheques, but unfortunately, cashing cheques is very expensive in the Netherlands. It&#8217;s not uncommon to pay up to 40 euro to your bank to cash a cheque that is worth 100 euro&#8217;s. On such occasions, I prefer PayPal for automatic bank transfers, since those are still pricy, but less than me cashing cheques.</p>
<p>However, I&#8217;ve decided I will never use PayPal again for either paying or accepting payments, both personally and in my company. If somebody wants to pay me through PayPal, I&#8217;ll ask them to make a bank-transfer. It&#8217;s quite easy, even for Americans to do this as well. All you need to have is the IBAN number, which every bank account automatically has (some countries uses the IBAN numbers as their bank accounts). It&#8217;s very safe, doesn&#8217;t cost much and is way better than dealing with a man-in-the-middle that let&#8217;s face it: behaves even bad on its good days.</p>
<p>I know I&#8217;m just one person who refuses PayPal. But we all have to start somewhere and one person is enough to get the ball rolling. I know it&#8217;s easy to pay things by a simple click here and there, and even if you are not willing to stop using PayPal, please take a look at other options: iDEAL, creditcards, bank transfers and yes, in the end we have the choice between a company that destroyed a violin and a company that destroyed the economy, but we have to start somewhere. Reducing fraud is important, but too many people get victimized by PayPal&#8217;s way of dealing with this problem.</p>
<p>&nbsp;</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2012%2F01%2F05%2Fwhy-i-dont-accept-paypal-anymore-for-payments%2F&amp;title=Why%20I%20don%26%238217%3Bt%20accept%20PayPal%20anymore%20for%20payments" id="wpa2a_10"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2012/01/05/why-i-dont-accept-paypal-anymore-for-payments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android: PuzzleChess game</title>
		<link>http://www.adayinthelifeof.nl/2011/12/29/android-puzzlechess-game/</link>
		<comments>http://www.adayinthelifeof.nl/2011/12/29/android-puzzlechess-game/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 09:47:40 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1547</guid>
		<description><![CDATA[I like to play with unfamiliar stuff. Not that I&#8217;ve never written an Android or java application, but this one is a bit different. It&#8217;s a simple game I&#8217;ve made while I was looking at (real life) puzzle game where you have to switch knights from a chess-game from one position to another. Not really [...]]]></description>
			<content:encoded><![CDATA[<p>I like to play with unfamiliar stuff. Not that I&#8217;ve never written an Android or java application, but this one is a bit different. It&#8217;s a simple game I&#8217;ve made while I was looking at (real life) puzzle game where you have to switch knights from a chess-game from one position to another. Not really hard, but not very simple either. I knew there are plenty of puzzle games like this out there, so I decided to create a simple game-engine that allows to create those games easily. The result: a 90% finished game called PuzzleChess. This blog-post is trying to find the last 10% of the game :)</p>
<p><span id="more-1547"></span></p>
<p>First of all, the source: <a href="https://github.com/jaytaph/PuzzleChess">https://github.com/jaytaph/PuzzleChess</a></p>
<p>The basic idea is simple: it&#8217;s an engine where you can define a chessboard, add some initial pieces onto it, have some kind of rule-set and let the user figure out how to win. Every one of these puzzles gets added to the main index, so you can see which puzzles are done, which are still left open etc:</p>
<p><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-001.png"><img class="aligncenter size-medium wp-image-1548" title="screenshot-001" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-001-180x300.png" alt="" width="180" height="300" /></a></p>
<p>Each puzzle has a name, a small caption, an icon and a difficulty. When the puzzle has been solved, a check mark will appear (saved inside a small database).</p>
<p>Now, the actual engine is very simple: a board that can have their cells either active or inactive. Inactive cells makes it possible to create a smaller board. For instance, in the knights-game:</p>
<p><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-003.png"><img class="aligncenter size-medium wp-image-1549" title="screenshot-003" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-003-180x300.png" alt="" width="180" height="300" /></a></p>
<p>You can only place move pieces to active cells. Note that for this game, I needed to have some &#8220;dots&#8221; on the cells as well to mark the places of the black and white knights. It&#8217;s possible to add some extra stuff to a cell.</p>
<table>
<tbody>
<tr>
<td><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-0031.png"><img class="size-medium wp-image-1550 aligncenter" title="screenshot-003" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-0031-180x300.png" alt="" width="180" height="300" /></a></td>
<td><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-004.png"><img class="aligncenter size-medium wp-image-1551" title="screenshot-004" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-004-180x300.png" alt="" width="180" height="300" /></a></td>
</tr>
</tbody>
</table>
<p>Another nice thing: there are themes as well! These themes are available from the menu. It basically does nothing more than change which graphics need to be plotted on every frame. This includes the pieces and the board (the dark and light cells).</p>
<p>Every piece have their own special way of moving: a rook can only move straight, while a bishop can only move diagonally. All pieces extend the &#8220;piece&#8221; class which defines how a piece can move.</p>
<p><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-006.png"><img class="aligncenter size-medium wp-image-1553" title="screenshot-006" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/screenshot-006-180x300.png" alt="" width="180" height="300" /></a></p>
<h2>Creating a new game</h2>
<p>It&#8217;s quite easy to create a new game:</p>
<ul>
<li>Add a game class that extends &#8220;game&#8221; to the game-directory.</li>
<li>Define the board (all fields visible, or only some)</li>
<li>Add pieces to the board</li>
<li>Add optional decoration to the board (in case of the dots at the knights-game)</li>
<li>Define the objective in getObjective(). This is shown to the user to figure out what he/she needs to do</li>
<li>Define a hasWon() and an optional hasLost() to let the engine know when the game is won/lost.</li>
<li>Define a init() in which you define the engine parameters. The game can have an unlimited amount of moves, or only a select number. Unlimited time, or you need to figure the game out in a certain amount of time. You can define if you need to show the trace of moves, so every piece leaves a mark on where it has been (handy in games where you need to travel a knight over every cell of the board once), or maybe you can &#8220;take&#8221; pieces from the enemy.  These are all defined by the GAMEOPTION_* constants.</li>
</ul>
<h2>Background info</h2>
<p>The application itself is quite easy in setup. It has 2 activities: the main menu and the puzzlechess activity. The main menu does nothing more than select a game that is passed to the puzzleChess activity (main.java:onCreate -&gt; the setOnItemClickListener).</p>
<h3>puzzleChess.java</h3>
<p>The actual meat of the application starts with the puzzleChess activity. It has a timer-thread to keep track of the time by sending a MESSAGE_DURATION message. This will allow the updateHandler to update the current time (either increase or decrease the timer). Another thread is started for updating the screen itself. This timer runs every 10ms and sends a MESSAGE_UPDATE message to the handler. This will redraw the panel (chessboard) and checks if the game has been won or lost. This update is needed because when we move a piece to another screen, it&#8217;s done through a simple animation that moves the piece from cell A to cell B. This is taken care of by the ChessPanelView.java class.</p>
<h3>ChessPanelView.java</h3>
<p>The chesspanelview is nothing more than a simple view that draws the screen. It will draw the background, will allow the board to be drawn (this is done by the Board.java class itself), and displays the status like Moves Left, Moves Done and Duration of the game. When the panel is touched (onTouchEvent), it will figure out which cell has been touched, and directs it to the game class that will handle the onClick(X, Y), where X and Y are the row/col of the cell, not the actual coordinates (because that is not needed for the board/game).</p>
<h3>Board.java</h3>
<p>The Board has got a lot of logic to deal with cells and pieces on those cells. It&#8217;s draw() method will create a cache of the board (without any pieces) so we don&#8217;t have to regenerate this on every update. Then it will draw that cached background onto the canvas (which is the panelview). Then it will draw all pieces on the board, but when a piece is animated, it means it&#8217;s in progress of moving from one cell to the next. In that case, the piece must not be drawn in a cell, but somewhere between cell A and cell B. The piece itself will interpolate the route between the two cells and returns the correct position. When we have arrived, the animate() method of the piece will return false, so the board will draw the piece correctly onto the cell (so it&#8217;s an active piece again).</p>
<p>More stuff will then be printed, like the tracemoves of traveled cells (if the game needs this), and border colors, which are the colors that are shown when you have clicked on a piece and will show you where the piece can move to.</p>
<p>The rest of the methods in this class are pretty straight-forward and takes care of handling the board, cells, and pieces on the board.</p>
<h3>Piece.java</h3>
<p>The piece.java class is an abstract class that defines a piece. Every piece has got an identifier (a tag, for instance: white rook 1, black knight etc). A color (black or white) and a boolean if the piece can be moved or not. It has got some methods to deal with animation, in case we travel from one cell to another.</p>
<p>This class defines &#8220;move&#8221;-methods like singleDiagonalMoves(), diagonalMoves() etc, which returns the available moves that can be made into that direction for the piece. It&#8217;s quite simple: if we are in a corner, a bishop can only move in one direction: away from that corner. When the bishop is in the center square of the board, if can move in all four directions, unless there is another piece in the way. These functions takes care of these conditions (together with the fact if the actual fields are enabled on the board or not), and returns an array with all available moves that can be done.</p>
<p>These move-functions will call the isValidAvailableField() method, which checks if field X, Y is available. Off course, it will take everything in account (disabled fields, traced fields, fields with pieces that we cannot take etc).</p>
<p>There is not much more going on for pieces. They are simple elements that can be moved and which can define their paths by themselves. The rest is taken care of by the board-class.</p>
<p>Every type of piece (rook, king, queen) etc, have their own class, in which we define the name (getName), the resource (the image of the piece) and a list of available moves. This list is created by calling the move-methods from the abstract class. A queen will check Piece::straightMoves() and Piece::diagonalMoves(), but not Piece::knightMoves(), a king will check Piece::singleDiagonalMoves, Piece::singleLeftRightMoves and Piece::singleUpDownMoves() etc..</p>
<h3>Game.java</h3>
<p>The game class by itself is also an abstract class. It holds all information about the game and takes care of moving the pieces. The onClick handler, which is passed from the PanelView, will check if we already selected a piece. If not and we clicked on a piece, that piece will become active so we can show all the possible paths for that piece (_onClickNoSelection). It will check if there is a piece, if we are allowed to move it, and if so, adds &#8220;bordercolors&#8221; to the board: when the piece can overtake another piece on it&#8217;s path, it will have a red bordercolor, otherwise a green.</p>
<p>When we have clicked on the same piece that we activated, it means we need to deactivate it and remove all the border colors again. This is done by _onClickSelectionSameField.</p>
<p>When we have clicked on another field while a piece has been activated AND we are allowed to move to that field, we will move the piece. The board-class will start this move, and stores the information (animated) into the piece so on the next update, we will see this piece actually moving from cell to cell.</p>
<p>The game class itself has basic functionality for the game itself: hasLost, hasWon etc to check if we have won or lost the game.</p>
<p>Every game must extend this game class but is really easy to setup as you have read in the &#8220;creating a new game&#8221; chapter.</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>There are still some issues with the application. And there is still a big issue I need to figure out: we use a canvas defined by pixels so it doesn&#8217;t work quite well on every tablet or phone. I use a 480 (was 320) large panel so we have 60&#215;60 pixel cells. We should be able to scale everything: the cells, the background, the pieces etc.</p>
<p>Another issue that the game isn&#8217;t finished yet. There are still some issues here and there (crashes, actually) and we need to check all the current games to see if they actually work. But on the whole, it&#8217;s almost ready..  Now just find the time to create the finish 10 percent. If you like to contribute: <a href="https://github.com/jaytaph/PuzzleChess">https://github.com/jaytaph/PuzzleChess</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2011%2F12%2F29%2Fandroid-puzzlechess-game%2F&amp;title=Android%3A%20PuzzleChess%20game" id="wpa2a_12"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2011/12/29/android-puzzlechess-game/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Facter: ZendServer</title>
		<link>http://www.adayinthelifeof.nl/2011/12/28/facter-zendserver/</link>
		<comments>http://www.adayinthelifeof.nl/2011/12/28/facter-zendserver/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 13:00:03 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1544</guid>
		<description><![CDATA[When you are dealing with Zend Server on a puppetized machine you can run into trouble: Zend Server uses it&#8217;s own packages for maintaining things like PHP etc so when you are installing PHP, you might end up with the PHP version of your distribution instead of the ZendServer. WE actually run into trouble once [...]]]></description>
			<content:encoded><![CDATA[<p>When you are dealing with Zend Server on a puppetized machine you can run into trouble: Zend Server uses it&#8217;s own packages for maintaining things like PHP etc so when you are installing PHP, you might end up with the PHP version of your distribution instead of the ZendServer. WE actually run into trouble once where we have 3(!) different PHP versions installed on the same server. What could possible go wrong!</p>
<p>This means you should not install the default PHP package for your distribution when the distribution also runs on Zend Server. This Facter plugin will allow you to use the $zendserver fact inside your own manifests to check if Zend server is installed, so you can take measures against installing stuff that is taken care of by ZendServer itself.</p>
<p>Note: it&#8217;s a VERY crude check, nothing more a check to see if a directory exists, and we don&#8217;t return the Zend Server version (Zend Platform is not supported). However, these things can be changed quite easily.</p>
<ul>
<li>Download from: https://github.com/jaytaph/puppet-facter-zendserver</li>
<li>Installation: through puppet off course! :-)</li>
</ul>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2011%2F12%2F28%2Ffacter-zendserver%2F&amp;title=Facter%3A%20ZendServer" id="wpa2a_14"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2011/12/28/facter-zendserver/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>php 5.4 + htrouter: Your personal Apache 2.2 compatible server</title>
		<link>http://www.adayinthelifeof.nl/2011/12/22/php-5-4-htrouter-your-personal-apache-2-2-compatible-server/</link>
		<comments>http://www.adayinthelifeof.nl/2011/12/22/php-5-4-htrouter-your-personal-apache-2-2-compatible-server/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 15:42:26 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Server & Admin]]></category>
		<category><![CDATA[htrouter]]></category>
		<category><![CDATA[php5.4]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1534</guid>
		<description><![CDATA[Version 5.4 is soon to be launched as the next new stable release of PHP. Granted, there will not be major changes like we saw in version 5.3, but it will still have some nifty new features. Two of the most important ones: traits and the internal web server. This post is about the latter [...]]]></description>
			<content:encoded><![CDATA[<p>Version 5.4 is soon to be launched as the next new stable release of PHP. Granted, there will not be major changes like we saw in version 5.3, but it will still have some nifty new features. Two of the most important ones: traits and the internal web server. This post is about the latter one. The new web-server makes it possible to run your PHP code through your browser even when you don&#8217;t have your own web-server like Apache or nginx installed. It has got some advantages, but this of course has raised some serious discussions: should PHP even be distributed with a web-server and if so, how can we make sure that it won&#8217;t be misused as a production server? Well, we really can&#8217;t forbid people to (mis)use this, but we hope most of us will use common sense.. The project in this blog-post however, can be considered as &#8220;The Enabler&#8221;. It can be a powerful tool for developers, but makes it easier for people to misuse the web-server. Time of course, will tell if this will be the case, but I think I&#8217;ve created a (simple) tool that will create the new Dr Jeckyl web-server into a Mr Hyde&#8230; What could possibly go wrong? :-)<span id="more-1534"></span></p>
<h2>Introducing: the .htaccess</h2>
<p>Most frameworks, CMS systems and projects are being run on an Apache web-server platform. One of the benefits is that this platform is not only very stable, but also got a lot of extra functionality that can be implemented through modules. These modules can be configured through Apache&#8217;s main configuration or through user-defined configurations &#8211; mostly known as .htaccess files.</p>
<p>Most .htaccess files are used for 2 things: rewriting url&#8217;s and authentication/authorization. The authentication comes in handy in combination with a .htpasswd file, where you can store a user/password combination for the persons that can log into your website. We all have seen it, and most of you have &#8220;secured&#8221; at least a portion of a website (it&#8217;s also a good way to secure a preview website for instance). Apache accepts even more advanced ways of authentication, for instance through LDAP.</p>
<p>Second common feature of .htaccess files: the URL rewriting. Sometimes it&#8217;s just nicer to go to: http://www.example.org/this/is/my/page, instead of http://www.example.org/index.php?page=this&amp;article=is_my_blog. With the help of URL-rewriting, it&#8217;s easy to achieve this, and create permalinks and such. Most frameworks have a so-called front-controller where all urls will be redirected to (in symfony&#8217;s case, this would be app_dev.php or app.php, and Zend Framework uses the more standard index.php for this).</p>
<p>The problem with the new PHP 5.4 internal web-server is that it isn&#8217;t Apache. Thus it does not know anything about .htaccess. Even when you have defined your .htaccess to do authentication, the internal PHP web-server will ignore it, while in production, the authentication will be needed (if you will be running Apache, of course). Also, you need to reroute everything manually through your app_dev.php, so your URL&#8217;s don&#8217;t really match the way they will be on your production.</p>
<p>&nbsp;</p>
<h2>Introducing: the php 5.4 webserver</h2>
<p>The PHP internal web-server has the opportunity to route all requests it receives through a single PHP file.</p>
<pre>$ php -S 127.0.0.1:80 router.php</pre>
<p>The router.php itself can be a simple program that parses the request, and checks if it&#8217;s something that needs to be passed onto your normal PHP code (for instance, your index.php) or maybe it will be something that can be served directly from disk. A simple router.php doesn&#8217;t have to be very complex:</p>
<div><code> &lt;?php </code></div>
<div><code>if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) { </code></div>
<div><code>  return false; </code></div>
<div><code>} else { </code></div>
<div><code>  include "index.php"; </code></div>
<div><code>} </code></div>
<div><code>?&gt; </code></div>
<p>This is one of the most basic router.php scripts that are available: if it&#8217;s in image file, it will load directly the image from disk (by returning false). Otherwise, it will include the main index.php file, so everything gets rerouted through that file. You get automatically some very crude URL-rewrite functionality: everything will be rerouted through index.php, so when you go to : http://server:8080/my/url, it will redirect to index.php with the request-uri being:</p>
<pre>  [REQUEST_URI] =&gt; /my/url</pre>
<p>But of course, it is in no way compatible with a regular .htaccess file. That is where this project comes into play:</p>
<h2>Introducing: the HTRouter project</h2>
<p>The code itself is pretty simple: it just loads all available &#8220;modules&#8221;, parses a .htaccess file found in the main directory and executes the things that normally Apache would do for you. In the end, it will pass control to your application (if needed). So in essence, it&#8217;s the Apache module-functionality completely rewritten in PHP.</p>
<p>All the modules that can be loaded, will mimic the actual modules as found in Apache itself. So there is a mod_rewrite module, a mod_auth module for authentication, a mod_authn_file module that will authenticate by reading users from a .htpasswd file etc.</p>
<p>Of course, the code is on github:https://github.com/jaytaph/htrouter</p>
<p>Note: the code is not finished! There are still lots of things that needs to be implemented:</p>
<ul>
<li>mod_rewrite, so we can rewrite url&#8217;s (pretty important)</li>
<li>mod_alias, so we can alias url&#8217;s (not so important, but nifty enough)</li>
<li>Package everything through PHAR</li>
</ul>
<p>So there is still some work left. However, the basics are beginning to show, and the standard basic authentication through htpasswd files are functional. I&#8217;m really hoping this will be a good way to help developers that will use the standard web-server but still crave .htaccess functionality.</p>
<p>&nbsp;</p>
<p>Again, I&#8217;m terribly sorry for all developers who now will get the idea it might be a good idea to use this in production. <strong>Please don&#8217;t.</strong> It will probably never will be a good idea, HOWEVER, and this is still something I truly think can and will happen: it will be a perfect system for backend-maintenance or as an admin-panel web interface. Normally, you don&#8217;t need threading and serve many requests but sometimes you want the simple .htaccess handling. I&#8217;m sure the PHP internal web-server will evolve over time into something more robust, and hopefully, this project will be part of generalize the usage of .htaccess.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2011%2F12%2F22%2Fphp-5-4-htrouter-your-personal-apache-2-2-compatible-server%2F&amp;title=php%205.4%20%2B%20htrouter%3A%20Your%20personal%20Apache%202.2%20compatible%20server" id="wpa2a_16"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2011/12/22/php-5-4-htrouter-your-personal-apache-2-2-compatible-server/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>New company website is online</title>
		<link>http://www.adayinthelifeof.nl/2011/12/13/new-company-website-is-online/</link>
		<comments>http://www.adayinthelifeof.nl/2011/12/13/new-company-website-is-online/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 12:56:21 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1527</guid>
		<description><![CDATA[Ok, so it&#8217;s not he most beautiful website you will ever see. Nor will it be the one with the most content. But it&#8217;s my company website, and I&#8217;m proud of it. Even if it was only a matter of installing WordPress, finding a theme, do a little bit of tweaking and adding some content. [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so it&#8217;s not he most beautiful website you will ever see. Nor will it be the one with the most content. But it&#8217;s my company website, and I&#8217;m proud of it. Even if it was only a matter of installing WordPress, finding a theme, do a little bit of tweaking and adding some content. However, I&#8217;m happy to say that at least I have a point where (future) customers can find information about me and the things I can do for them on a freelance base. There will be updates, maybe I can invest some money in someone to create a decent theme, but in the meantime, here it is: <a href="http://www.noxlogic.nl" target="_blank">http://www.noxlogic.nl</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2011%2F12%2F13%2Fnew-company-website-is-online%2F&amp;title=New%20company%20website%20is%20online" id="wpa2a_18"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2011/12/13/new-company-website-is-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book review: Confessions of a public speaker</title>
		<link>http://www.adayinthelifeof.nl/2011/12/12/book-review-confessions-of-a-public-speaker/</link>
		<comments>http://www.adayinthelifeof.nl/2011/12/12/book-review-confessions-of-a-public-speaker/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 19:46:25 +0000</pubDate>
		<dc:creator>Joshua Thijssen</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.adayinthelifeof.nl/?p=1515</guid>
		<description><![CDATA[I&#8217;m not exactly sure where I got the link to this book. It was probably a tweet or IRC-posting from somebody, but it actually was because of Amazon&#8217;s take-a-look-inside that made me buy the book. The few parts of the chapters I read where not only funny, but had lots of interesting tips &#38; tricks [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not exactly sure where I got the link to this book. It was probably a tweet or IRC-posting from somebody, but it actually was because of Amazon&#8217;s take-a-look-inside that made me buy the book. The few parts of the chapters I read where not only funny, but had lots of interesting tips &amp; tricks for me as a (wannabe) speaker. <span id="more-1515"></span><a href="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/cat.gif"><img class="alignleft size-full wp-image-1516" style="margin: 15px;" title="cat" src="http://www.adayinthelifeof.nl/wp-content/uploads/2011/12/cat.gif" alt="" width="180" height="278" /></a></p>
<p>So the preview was good, but don&#8217;t you just hate it when you are watching a movie-preview and they use the best pieces of the film for it (which means, the average movie has about 30 seconds of good parts in it.. which sounds about right for the average Hollywood movie nowadays). Luckily, the rest of this book is just as funny and interesting as its preview.</p>
<p>Not only is the book about Scott&#8217;s story on the pros (and cons) of being a public speaker, but he will tell you how to become one yourself. Not only will he talk about the psychology of lecturing, but also how you as a speaker can easily make or break a talk just by the way you bring it to your room (yes, it&#8217;s YOUR room). He talks about why most speaker evaluations are useless (sorry, most of them, except joind.in off course :)). What to do when you are facing a difficult crowd, or even how to act when a SWAT-team comes busting into the room and take away one of the attendees (seriously, there is a anecdote on exactly this in the book!) or how to deal with the annoying know-it-all guy in the room.</p>
<p>This book is also a lot about common sense but which we all forget once we enter the stage. It truly is a must-have when you are &#8211; or want to become &#8211; a public speaker! What&#8217;s left to say? Nothing really, you should just buy it and read it, even if you don&#8217;t ambition a public speaker role, it will be a quite funny and interesting book nevertheless!</p>
<h2>Info</h2>
<p>Confessions of a public speaker</p>
<p>Scott Berkun</p>
<p>ISBN: 978-1-449-40195-8</p>
<p><a href="http://shop.oreilly.com/product/9780596802004.do" target="_blank">http://shop.oreilly.com/product/9780596802004.do</a></p>
<p><a href="http://www.scottberkun.com/" target="_blank">http://www.scottberkun.com/</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.adayinthelifeof.nl%2F2011%2F12%2F12%2Fbook-review-confessions-of-a-public-speaker%2F&amp;title=Book%20review%3A%20Confessions%20of%20a%20public%20speaker" id="wpa2a_20"><img src="http://www.adayinthelifeof.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.adayinthelifeof.nl/2011/12/12/book-review-confessions-of-a-public-speaker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

