<?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>funky code &#187; Jan Schulz-Hofen</title>
	<atom:link href="http://fun.kyco.de/author/yeah/feed/" rel="self" type="application/rss+xml" />
	<link>http://fun.kyco.de</link>
	<description>this is all there is.</description>
	<lastBuildDate>Tue, 11 Dec 2012 23:00:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Send E-Mail attachments to Dropbox</title>
		<link>http://fun.kyco.de/2012/12/11/send-e-mail-attachments-to-dropbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=send-e-mail-attachments-to-dropbox</link>
		<comments>http://fun.kyco.de/2012/12/11/send-e-mail-attachments-to-dropbox/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 20:07:48 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[e-mail]]></category>
		<category><![CDATA[uberspace]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=385</guid>
		<description><![CDATA[At Planio and LAUNCH/CO, we receive a lot of PDF receipts for things we purchase online or services we use regularly. I want all those files to go directly into a designated folder in my Dropbox and I don&#8217;t want to look at them until the end of the month when I zip everything together [...]]]></description>
				<content:encoded><![CDATA[<p>At <a href="http://plan.io" title="Planio Project Management">Planio</a> and <a href="http://launchco.com">LAUNCH/CO</a>, we receive a lot of PDF receipts for things we purchase online or services we use regularly. I want all those files to go directly into a designated folder in my <a href="http://dropbox.com">Dropbox</a> and I don&#8217;t want to look at them until the end of the month when I zip everything together and send it to our accountant. </p>
<p>For this purpose, I have been using a service called <a href="http://sendtodropbox.com/">send to dropbox</a> for a while until it started getting unreliable. Soon it didn&#8217;t upload any of the e-mails anymore without even supplying an error message and I ended up fiddling with my e-mail attachments by hand again. Not very funny.</p>
<p>So, I hacked together something that &#8220;works for me&#8221; (TM) and doesn&#8217;t rely on an external service. Well, in fact, I am still relying on <a href="http://uberspace.de">Uberspace</a> to host this, but (a) I could easily do this everywhere else and (b) it&#8217;s a huge improvement over <strong>send to dropbox</strong> which felt more like a blackbox.</p>
<p>This is how it&#8217;s done on Uberspace, but really the instructions are very much applicable to any Linux based setup.</p>
<h3>Download and Setup Dropbox Uploader</h3>
<p><a href="https://github.com/yeah/Dropbox-Uploader">Dropbox Uploader</a> is an awesome little shell script written by <a href="https://github.com/andreafabrizi">Andrea Fabrizi</a> which can be used to upload files to Dropbox from the command line. It is very handy since it has no dependencies except for curl. For my purpose, it needed a little tweaking since it would not accept files from standard input, so I forked it and am currently waiting if my pull request is being merged. I will update this article as soon as it does, since I have no interest in maintaining the fork. Andrea seems to be doing an awesome job with this.</p>
<p>So open a shell on your Uberspace and do the following:</p>
<pre>mkdir -p ~/opt
cd ~/opt
git clone git://github.com/yeah/Dropbox-Uploader.git
mkdir ~/bin
ln -s ~/opt/Dropbox-Uploader/dropbox_uploader.sh ~/bin/</pre>
<p>This installs the latest version of Dropbox Uploader in <code>~/opt/Dropbox-Uploader</code> and creates a handy symlink to it in <code>~/bin</code> which should be in your <code>PATH</code> already.</p>
<p>To verify if that last assumption is true (and to authenticate Dropbox Uploader), simply run</p>
<pre>dropbox_uploader.sh</pre>
<p>It should lead you through the process of creating your own Dropbox App and authenticating your copy of Dropbox Uploader against it. If asked for the <em>Access Level</em> I&#8217;d opt for <em>App folder</em> since this won&#8217;t give the app access to your entire Dropbox. Your credentials are stored in <code>~/.dropbox_uploader</code> which is 600 by default, but if you&#8217;re a bit paranoid like me, <em>App folder</em> is still the safer bet.</p>
<p>If you&#8217;d like to test Dropbox Uploader, perform a simple upload like this:</p>
<pre>echo "hello dropbox world?" | dropbox_uploader.sh upload - hello_world.txt</pre>
<p>A file called <code>hello_world.txt</code> should magically appear in your Dropbox. Does it work? Yay! Then here comes the fun part&#8230;</p>
<h3>Configuring qmail and reformime</h3>
<p>Again, it should not be hard to adapt this to other MTAs, but since Uberspace uses qmail (or <a href="http://uberspace.de/dokuwiki/mail:netqmail">netqmail</a> to be more specific) this tutorial is written for that.</p>
<p>At Uberspace, you get an unlimited number of e-mail addresses out of the box. Your primary is composed like this:</p>
<pre>username@hostname.uberspace.de</pre>
<p>Where <code>username</code> is your Uberspace username and <code>hostname</code> is the host your account is hosted on. What happens to e-mails coming this way is governed by a small file named <code>~/.qmail</code>. In much the same way, you can use any e-mail address that follows this format:</p>
<pre>username-foo@hostname.uberspace.de</pre>
<p>Where <code>foo</code> can be anything you like. To specify what should happen with e-mails coming in via this address, you can create a file called <code>~/.qmail-foo</code>.</p>
<p>So, for instance, if you want all e-mail PDF attachments sent to <code>peter-dropbox@phoenix.uberspace.de</code> to appear in your Dropbox, create a <code>~/.qmail-dropbox</code> file with the following content:</p>
<pre>| /usr/bin/reformime -X /bin/sh -c "if [ "\${FILENAME#*.}" == "pdf" ]; then ~/bin/dropbox_uploader.sh upload - \"\$FILENAME\";fi"</pre>
<p>Yep. That&#8217;s one single line. It uses <code>reformime</code> to extract all file attachments and then uploads those that end in <code>.pdf</code> to your Dropbox using Dropbox Uploader.</p>
<p>Try it out. It should already work. There&#8217;s nothing else to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2012/12/11/send-e-mail-attachments-to-dropbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VPN (IPsec) tunnel between a pfSense 2.0 router and a FRITZ!Box</title>
		<link>http://fun.kyco.de/2011/12/04/vpn-ipsec-tunnel-between-a-pfsense-2-0-router-and-a-fritzbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vpn-ipsec-tunnel-between-a-pfsense-2-0-router-and-a-fritzbox</link>
		<comments>http://fun.kyco.de/2011/12/04/vpn-ipsec-tunnel-between-a-pfsense-2-0-router-and-a-fritzbox/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 11:38:29 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[avm]]></category>
		<category><![CDATA[fritzbox]]></category>
		<category><![CDATA[ipsec]]></category>
		<category><![CDATA[pfsense]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=305</guid>
		<description><![CDATA[We have a pfSense 2.0 router at our coworking space which is hooked up to a pretty fast VDSL line so I thought it would be a fun idea to connect my home network (where I&#8217;m using a FRITZ!Box 7390) to the work LAN using a secure and permenent VPN tunnel. Doing a quick Google [...]]]></description>
				<content:encoded><![CDATA[<p>We have a <a href="http://shop.varia-store.com/product_info.php?info=p886_pfSense-Komplettsystem-mit-ALIX-2D13-und-Zubehoer.html">pfSense 2.0 router</a> at our <a title="Coworking Berlin-Friedrichshain" href="https://launchco.com/etc/#coworking">coworking space</a> which is hooked up to a pretty fast VDSL line so I thought it would be a fun idea to connect my home network (where I&#8217;m using a <a href="http://www.avm.de/de/Produkte/FRITZBox/FRITZ_Box_Fon_WLAN_7390/index.php">FRITZ!Box 7390</a>) to the work LAN using a secure and permenent VPN tunnel.</p>
<p>Doing a quick <a href="http://www.google.de/search?q=vpn+fritz+box+pfsense">Google search</a> <a href="http://forum.pfsense.org/index.php?topic=30621.0">yields results for the 1.2 version of pfSense</a> which is outdated and does not use DynDNS hostnames for both ends, so I did a quick writeup of my own.</p>
<h3>Prerequisites</h3>
<p>First things first, create permanent hostnames for your pfSense and your FRITZ!Box. If your DSL provider has assigned permanent IP addresses, that&#8217;s fine. If they didn&#8217;t you&#8217;ll probably need something like <a href="http://dyn.com/dns/dyndns-pro/">DynDNS</a>. Last time I checked, you could still get free accounts, otherwise it&#8217;s just a few bucks a year &#8211; probably a good investment. You&#8217;ll need to configure both the pfSense and the FRITZ!Box to update your DynDNS hosts whenever their IP address changes, but that&#8217;s pretty straight forward so I won&#8217;t cover it here. Fun fact: you can add CNAME records to your company domain pointing to your DynDNS host, so it looks even more professional. We use <code>vpn.launchco.com</code> for instance &#8211; how cool is that?</p>
<p>You&#8217;ll also need two different primary subnets for your networks, i.e. if your home network lives in <code>192.168.178.0/24</code>, which is the standard network a FRITZ!Box uses, your work network has to use something else, like <code>192.168.1.0/24</code>, which is by the way the standard that pfSense uses &#8211; so you should be safe if you&#8217;re like me a big fan of sticking with sensible vendor defaults.</p>
<p>Now, with the permanent hostnames and subnets in place, let&#8217;s get down to business.</p>
<h3>Setting up pfSense</h3>
<p>We&#8217;re using <a href="http://en.wikipedia.org/wiki/IPsec">IPsec</a>, so let&#8217;s head to <code>VPN</code> -> <code>IPsec</code> first and click the <code>[+]</code> icon on the bottom right to add a new phase 1 entry.</p>
<p>Fill the form in accordance to what you see on the following screenshot:</p>
<p><a href="http://fun.kyco.de/wp-content/uploads/2011/12/pfsense-vpn-phase1.png"><img src="http://fun.kyco.de/wp-content/uploads/2011/12/pfsense-vpn-phase1-205x300.png" alt="Screenshot of pfSense configuration phase 1 entry" title="Screenshot of pfSense configuration phase 1 entry" width="205" height="300" class="aligncenter size-medium wp-image-316" /></a></p>
<p>Obviously, replace <code>your-fritz.dyndns.org</code> with the permanent hostname assigned to your FRITZ!Box as well as <code>your-pfsense.dyndns.org</code> with the one on your pfSense box. The <code>Pre-Shared Key</code> should be a long random string. Don&#8217;t worry, you won&#8217;t have to remember it. You&#8217;ll just save that in the FRITZ!Box later and then you can forget about it.</p>
<p>Next up, we need a phase 2 entry. For that, click the <code>[+]</code> icon next to a label that says <code>Show 0 Phase-2 entries</code> and fill the form like below:</p>
<p><a href="http://fun.kyco.de/wp-content/uploads/2011/12/pfsense-vpn-phase2.png"><img src="http://fun.kyco.de/wp-content/uploads/2011/12/pfsense-vpn-phase2-291x300.png" alt="Screenshot of pfSense configuration phase 2 entry" title="Screenshot of pfSense configuration phase 2 entry" width="291" height="300" class="aligncenter size-medium wp-image-315" /></a></p>
<p>Here, you just need to make sure that you replace <code>192.168.178.0</code> with the actual subnet your FRITZ!Box uses. Again, if you&#8217;ve sticked with the default when setting up the box, this setting should be right for you.</p>
<p>That should be it for the pfSense. After saving it&#8217;ll probably ask you to apply or reload the configuration. This is safe to do now.</p>
<h3>Setting up the FRITZ!Box</h3>
<p>Now, let&#8217;s finish this by configuring a VPN entry in your FRITZ!Box. From my perspective, this part is much easier, because I&#8217;m just pasting code instead of fiddling with screenshots &#8211; yay!</p>
<p>Fire up your favorite text editor and paste the following code:</p>
<p><script src="https://gist.github.com/1429945.js"> </script></p>
<p>Make the necessary modifications according to the comments in the file. Then, open the FRITZ!Box configuration interface in your browser and head to <code>Internet</code> -> <code>Freigaben</code> -> <code>VPN</code>, use the browse button to select the file you just created and click on <code>VPN-Einstellungen importieren</code>.</p>
<p>That&#8217;s it &#8211; you&#8217;re done. In my first trials I had to go back to the pfSense interface and navigate to <code>Status</code> -> <code>IPsec</code> to click on a small <code>[>]</code> (&#8220;play&#8221;) button to get things rolling. Maybe you need this, maybe it just works without it.</p>
<p>Getting the connection up after a restart of either of the two routers sometimes fails which is most probably due to the fact that DynDNS updates have not yet propagated when the VPN tries to connect. In this case, just be patient; both boxes will keep retrying to open VPN connections and you can always stop/start on both ends yourself. Once a connection is made, the tunnels are usually stable and rock-solid. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2011/12/04/vpn-ipsec-tunnel-between-a-pfsense-2-0-router-and-a-fritzbox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Remove diacritics (Umlauts, Accents, Special characters) in JavaScript</title>
		<link>http://fun.kyco.de/2011/09/21/remove-diacritics-umlauts-accents-special-characters-in-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remove-diacritics-umlauts-accents-special-characters-in-javascript</link>
		<comments>http://fun.kyco.de/2011/09/21/remove-diacritics-umlauts-accents-special-characters-in-javascript/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 10:37:12 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[webapps]]></category>
		<category><![CDATA[diacritics]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[remove accents]]></category>
		<category><![CDATA[remove special characters]]></category>
		<category><![CDATA[remove umlauts]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=279</guid>
		<description><![CDATA[So I recently found myself generating permalinks in JavaScript again which can be fun and painful. It seems to be less painful if you just ignore anything that&#8217;s not [a-zA-Z0-9] and replace it with a hyphen -. However, this starts looking ugly rather quickly if you&#8217;re from Germany or France for instance, where use of [...]]]></description>
				<content:encoded><![CDATA[<p>So I recently found myself <a href="http://www.redmine.org/issues/9225">generating permalinks in JavaScript</a> again which can be fun and painful. It seems to be less painful if you just ignore anything that&#8217;s not <code>[a-zA-Z0-9]</code> and replace it with a hyphen <code>-</code>.</p>
<p>However, this starts looking ugly rather quickly if you&#8217;re from Germany or France for instance, where use of umlauts and accents is very common. Something really nice like<br />
<code>J'ai montré les éléphants à ma sœur</code><br />
becomes something really ugly like<br />
<code>j-ai-montr-les-l-phants-ma-s-ur</code>.</p>
<p>So as <a href="http://meine-er.de/" title="Holger">Holger</a> pointed out, I needed a diacritics table which <a href="http://lehelk.com/2011/05/06/script-to-remove-diacritics/">I found here</a>. After some modifications for the German language (e.g. ä -> ae, ß -> ss), I came up with this.</p>
<p><script src="https://gist.github.com/1283961.js"> </script></p>
<p>It&#8217;s still heavily based on what lehel built, so thank him, not me. I just wanted to put my improved version here, so I don&#8217;t forget it.</p>
<p><strong>Update:</strong> I have created a <a href="https://gist.github.com/1283961">Gist</a> for this over at Github so we can continue to update it there&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2011/09/21/remove-diacritics-umlauts-accents-special-characters-in-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to build an 8 TB RAID5 encrypted time capsule for 500 Euros</title>
		<link>http://fun.kyco.de/2011/07/03/how-to-build-a-8-tb-raid5-encrypted-time-capsule-for-500-euros/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-build-a-8-tb-raid5-encrypted-time-capsule-for-500-euros</link>
		<comments>http://fun.kyco.de/2011/07/03/how-to-build-a-8-tb-raid5-encrypted-time-capsule-for-500-euros/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 14:49:07 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[file sharing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[operating systems]]></category>
		<category><![CDATA[time machine]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=206</guid>
		<description><![CDATA[So I wanted to buy a NAS that can act as a time capsule for Apple computers and run a proper Linux at the same time. I also wanted to be able to run the occasional Windows or Linux VM and I wanted to have a lot of storage. As I knew the thing was [...]]]></description>
				<content:encoded><![CDATA[<p>So I wanted to buy a NAS that can act as a <a href="http://www.apple.com/timecapsule/">time capsule</a> for Apple computers and run a proper Linux at the same time. I also wanted to be able to run the occasional Windows or Linux VM and I wanted to have <strong>a lot of storage</strong>. As I knew the thing was going to be in our <a href="http://launchco.com/coworking">coworking space</a>, it also needed to have disk encryption.</p>
<p>Here&#8217;s how I built this for just under €500.00 using standard components and free open source software.</p>
<h3>Selecting the hardware components</h3>
<p>I found the <a href="http://h10010.www1.hp.com/wwpc/us/en/sm/WF05a/15351-15351-4237916-4237918-4237917-4248009.html">HP ProLiant MicroServer</a> (see <a href="http://blog.samat.org/2010/12/10/Hardware-review-of-the-Hewlett-Packard-ProLiant-N36L-Microserver">Review</a> and more <a href="http://www.flickr.com/photos/tamasrepus/5204520585/in/set-72157625461896900">Picures</a>) to deliver great value for the price. At the time of writing, you can <a href="http://geizhals.at/deutschland/a622865.html">buy it for €209.90</a> if you&#8217;re in Germany like me.</p>
<p><a href="http://fun.kyco.de/wp-content/uploads/2011/07/Bild0-1943191503-22G_400.jpeg"><img class="aligncenter size-medium wp-image-214" title="Bild0-1943191503-22G_400" src="http://fun.kyco.de/wp-content/uploads/2011/07/Bild0-1943191503-22G_400-300x300.jpg" alt="" width="300" height="300" /></a></p>
<p>The N36L (which I bought) comes with a single 250GB hard drive which obviously did not meet my &#8220;a lot of storage&#8221; requirement. So I bought 4 identical <a href="http://www.seagate.com/www/en-us/products/desktops/green-drive-barracuda/">Seagate Barracuda Green 2000GB SATA</a> drives which would add another <a href="http://geizhals.at/deutschland/a588865.html">€229.92 to the bill</a> if you bought them today. I am not an expert in hard drives, but the Seagate Barracuda brand was familiar and &#8220;Green&#8221; sounds good as well.</p>
<p><a href="http://fun.kyco.de/wp-content/uploads/2011/07/barracuda_lp_320x340.png"><img class="aligncenter size-medium wp-image-217" title="barracuda_lp_320x340" src="http://fun.kyco.de/wp-content/uploads/2011/07/barracuda_lp_320x340-282x300.png" alt="" width="282" height="300" /></a></p>
<p>If you don&#8217;t want your new server to host virtual machines at some point, you can probably get out your credit card and check out right now. If you&#8217;re like me though, you&#8217;d add another 2 bars of <a href="http://www.valueram.com/desktop/memory.asp">4GB Kingston ValueRAM PC3-10667U CL9 (DDR3-1333)</a> to your cart. The two of them together <a href="http://geizhals.at/deutschland/a448854.html">are just €44.24</a>, so it&#8217;s no big deal anyways.</p>
<p><a href="http://fun.kyco.de/wp-content/uploads/2011/07/624370_0__8268121.jpg"><img class="aligncenter size-medium wp-image-219" title="624370_0__8268121" src="http://fun.kyco.de/wp-content/uploads/2011/07/624370_0__8268121-300x300.jpg" alt="" width="300" height="300" /></a></p>
<p>All components together will set you off €484.06. The rest is based on open source software (Debian mostly) which is free as in beer. More about that after the break.</p>
<p><span id="more-206"></span></p>
<p>I won&#8217;t explain how to actually assemble the components. Please read the manuals if you&#8217;ve never installed RAM or a hard drive. It&#8217;s pretty easy anyways. The HP even comes with screws and a sort of screw driver which can both be found in the inner side of the hard drive door.</p>
<h3>Installing the base system</h3>
<p>Now, I want my servers to run a proper operating system, so I went for Debian. You can most probably use Ubuntu or CentOS and get the same results. It&#8217;s just a matter of taste, I guess. To get things going, I downloaded <a href="http://www.debian.org/distrib/netinst#smallcd">a small image from debian.org</a>, put it on a USB drive and booted up the HP.</p>
<h4>Considerations</h4>
<p>For the most part, the installation is pretty straight forward. You can set up everything from within the Debian installer. There are a couple of small gotchas to consider though:</p>
<ul>
<li>You&#8217;re going to need a very small (1MB should be largely enough) primary partition at the beginning of all disks. In order to handle the large 2TB disks, Debian is going to use <a href="http://en.wikipedia.org/wiki/GUID_Partition_Table">GPT</a> which in turn relies on that tiny partition.</li>
<li>We&#8217;re going to encrypt the entire drive in order for your box to be really secure. As far as I know, Debian cannot boot from an encrypted partition, so you&#8217;ll need a small partition for the <code>/boot</code> filesystem. Personally, I&#8217;ve put that one on a RAID1 array, so I don&#8217;t need to worry about rebooting the machine in case of a disk failure.</li>
<li>I remember having had a hard time booting from disk for the first time. For some reason, I had to set the proper boot device in the BIOS to make things work. Your mileage may vary.</li>
<li>The HP has an on-board RAID controller. Usually, I am more comfortable with things I can fully control, so I went for software RAID which is built-in in Debian. Things might be a bit more performant using the hardware controller and you might still get the same level of robustness and security. I just didn&#8217;t use it, so keep that in mind when reading my instructions.</li>
</ul>
<h4>Step by Step</h4>
<p>So, basically, here&#8217;s what you need to do to get your Debian up and running on your new box:</p>
<ul>
<li>On each drive, create the small (~ 1MB) GPT partition and flag it <code>bios_grub</code>.</li>
<li>Again on each drive, create another slightly larger (~100MB) partition and flag it <code>raid</code>.</li>
<li>Then, still on each drive, create a large (~2TB) partition taking up all the remaining space and flag it <code>raid</code>.</li>
<li>Now, set up a RAID1 using the four smaller 100MB partitions, should be called <code>/dev/md0</code>.</li>
<li>Then, set up a RAID5 using the four large 2TB partitions, should be called <code>/dev/md1</code>.</li>
<li>Next, set up a crypted partition on top of the RAID5 (<code>/dev/md1</code>), should be called <code>md1_crypt</code></li>
<li>I recommend using LVM, so next, set up a physical volume on the crypted partition (<code>md1_crypt</code>) using up all its space.</li>
<li>Now, create a number of logical volumes. I&#8217;d recommend to set up one each for the usual suspects <code>/</code>, <code>/home</code>, <code>/var</code>, and <code>/opt</code> at least, but again, your mileage may vary. The nice thing about LVM is that you can add and change logical volumes at any time.</li>
<li>Finally set the moint point of <code>/boot</code> to your RAID1 (<code>/dev/md0</code>) and continue the installation. I&#8217;ll leave the package selection entirely up to you. Usually, I like to install a bare minimum during setup and get more stuff as I need it later on.</li>
<li>If everything went well, your new HP should boot up a couple of minutes later, asking for the password for your crypted disk and present you with the initial login prompt.</li>
<li>I usually start by installing <code>ssh</code> and <code>sudo</code> which enables me to do everything else from my own workstation. But you can continue the setup in your closet or wherever your HP sits, no problem.</li>
</ul>
<h3><a name="afp"></a>AFP and Apple Time Machine</h3>
<p><em>Disclaimer: The following is based on a great <a href="http://www.bootc.net/archives/2010/11/07/apple-time-machine-and-netatalk/">article by Chris Boot</a>. I read it there first.</em></p>
<p>Enabling Time Machine support is actually much easier than I first thought and it doesn&#8217;t even require serious hacking, compiling or even using non-standard repositories if you&#8217;re on Debian. Here&#8217;s what you have to do:</p>
<ul>
<li>If you plan on using Time Machine with Lion, you&#8217;ll need a newer version of <code>netatalk</code> than is currently available in Debian Squeeze, so you&#8217;ll have to add Wheezy to your <code>/etc/apt/sources.list</code>. Edit the file and add the following lines at the bottom:
<pre># testing
deb http://ftp2.de.debian.org/debian/ wheezy main
deb-src http://ftp2.de.debian.org/debian/ wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main</pre>
</li>
<li>Also create a file called <code>/etc/apt/preferences.d/00pinning</code> and add the following lines:
<pre>Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=testing
Pin-Priority: 650</pre>
</li>
<li>Get Netatalk and Avahi using apt: <code>apt-get update ; apt-get install -t wheezy netatalk avahi-daemon</code></li>
<li>In order to export a share using Netatalk, edit <code>/etc/netatalk/AppleVolumes.default</code> and add a line that reads <code>/srv/timemachine "Time Machine" options:tm</code> and be sure to create <code>/srv/timemachine</code> or change it to something you want to use as a location for your shared folder.</li>
<li>Next, edit the file <code>/etc/netatalk/afpd.conf</code> and add <code>- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2.so -savepassword -nodebug -icon</code> at the bottom. It will configure netatalk to use the authentication methods required by Lion and some other stuff I found useful.</li>
<li>Now, doing a <code>/etc/init.d/netatalk restart</code> is actually already enough to export the folder using AFP ready for Time Machine goodness.</li>
<li>However, if you&#8217;re an Apple user you probably want to see your new server in the finder instead of just accessing it via its IP address. Enter Avahi. Create the file <code>/etc/avahi/services/afpd.service</code> and paste the following code:
<pre>&lt;?xml version="1.0" standalone='no'?&gt;&lt;!--*-nxml-*--&gt;
&lt;!DOCTYPE service-group SYSTEM "avahi-service.dtd"&gt;
&lt;service-group&gt;
&lt;name replace-wildcards="yes"&gt;%h&lt;/name&gt;

&lt;service&gt;
 &lt;type&gt;_afpovertcp._tcp&lt;/type&gt;
 &lt;port&gt;548&lt;/port&gt;
&lt;/service&gt;

&lt;service&gt;
 &lt;type&gt;_device-info._tcp&lt;/type&gt;
 &lt;port&gt;0&lt;/port&gt;
 &lt;txt-record&gt;model=Xserve&lt;/txt-record&gt;
&lt;/service&gt;

&lt;service&gt;
 &lt;type&gt;_adisk._tcp&lt;/type&gt;
 &lt;port&gt;9&lt;/port&gt;
 &lt;txt-record&gt;sys=waMA=YOUR-MAC-ADDRESS,adVF=0x100&lt;/txt-record&gt;
 &lt;txt-record&gt;dk0=adVF=0x83,adVN=Time Machine&lt;/txt-record&gt;
&lt;/service&gt;

&lt;/service-group&gt;</pre>
<p>Be sure to replace <code>YOUR-MAC-ADDRESS</code> with the actual MAC address of your HP box and to use the same string for <code>Time Machine</code> as you used in <code>AppleVolumes.default</code>.</li>
</ul>
<p>And that&#8217;s it. Your Mac computers should start seeing your HP box and you should be able to use it as a time capsule for your wireless backups.</p>
<p><em>Please note: I wrote this guide a couple of weeks after I set this up at the <a href="http://launchco.com">LAUNCH/CO</a> office. So most stuff is from memory. If you find any mistakes or happen to get stuck somewhere in the process, please leave a comment and I&#8217;ll try to help.</em></p>
<p><strike><strong>Update:</strong> You may have noticed that your shiny new DIY time capsule has stopped working since you upgraded your Macs to Lion. <a href="http://www.tristanwaddington.com/2011/07/debian-time-machine-server-os-x-lion/">This blog post looks promising</a> &#8211; I will check it out and update this post as soon as I find the time.</strike></p>
<p><strong>Update 2:</strong> If you have set up your N36L using these instructions before August 13th, 2011, your box won&#8217;t work with OS X Lion. I have just upgraded the instructions to use the latest version of <code>netatalk</code>. You should be able to make Time Machine support work again by following the new <a href="#afp">AFP and Apple Time Machine</a> instructions adapting your existing config.</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2011/07/03/how-to-build-a-8-tb-raid5-encrypted-time-capsule-for-500-euros/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Are you stuck in Debian/MySQL/Charset/Collation hell?</title>
		<link>http://fun.kyco.de/2011/03/26/are-you-stuck-in-debian-mysql-charset-collation-hell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=are-you-stuck-in-debian-mysql-charset-collation-hell</link>
		<comments>http://fun.kyco.de/2011/03/26/are-you-stuck-in-debian-mysql-charset-collation-hell/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 13:23:17 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[character set]]></category>
		<category><![CDATA[collation]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[UTF8]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=184</guid>
		<description><![CDATA[So while Debian still hasn&#8217;t changed the MySQL default caracter set and collation to utf8, we all know that the first thing to do on a vanilla Debian MySQL installation is to add the following utf8.cnf file to /etc/mysql/conf.d/: [mysqld] default-character-set=utf8 default-collation=utf8_unicode_ci However, if for some reason you didn&#8217;t do that and have used software [...]]]></description>
				<content:encoded><![CDATA[<p>So while Debian <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=438970">still hasn&#8217;t changed the MySQL default caracter set and collation to utf8</a>, we all know that the first thing to do on a vanilla Debian MySQL installation is to add the following <code>utf8.cnf</code> file to <code>/etc/mysql/conf.d/</code>:</p>
<pre>
[mysqld]
default-character-set=utf8
default-collation=utf8_unicode_ci
</pre>
<p>However, if for some reason you didn&#8217;t do that and have used software which hasn&#8217;t been consistently explicit about character sets and collations, you end up with a nice mess of character sets and collations.</p>
<p>There is a great <a href="http://serverfault.com/questions/65043/alter-charset-and-collation-in-all-columns-in-all-tables-in-mysql">post on serverfault</a> which helps you out. It comes down to one command which will take some time based on the size of your database:</p>
<pre>
mysql -B -N --user=user --password=secret -e "SELECT DISTINCT \
CONCAT( 'ALTER TABLE \`', TABLE_SCHEMA, '\`.\`', TABLE_NAME, '\` CONVERT \
TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;' ) FROM \
information_schema.COLUMNS WHERE TABLE_SCHEMA != 'information_schema';" \
| mysql --user=user --password=secret
</pre>
<p><strong>Update:</strong></p>
<p>And of course you need to alter the defaults for existing databases as well:</p>
<pre>
mysql -B -N --user=user --password=secret -e "SELECT DISTINCT \
CONCAT( 'ALTER SCHEMA \`', SCHEMA_NAME, '\` CHARACTER SET utf8 COLLATE \
utf8_unicode_ci;' ) FROM information_schema.SCHEMATA where SCHEMA_NAME \
!= 'information_schema';" | mysql --user=user --password=secret
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2011/03/26/are-you-stuck-in-debian-mysql-charset-collation-hell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>First steps with Chef</title>
		<link>http://fun.kyco.de/2011/03/22/first-steps-with-chef/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=first-steps-with-chef</link>
		<comments>http://fun.kyco.de/2011/03/22/first-steps-with-chef/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 00:00:13 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[admin]]></category>
		<category><![CDATA[chef]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[fai]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=168</guid>
		<description><![CDATA[Today, Jens and I got to play with Chef which supposedly is the hot sh$&#038;!t when it comes to infrastructure automation and such. Installing your own Chef server seems hard at first but will work in the end. If you&#8217;re using Debian, the APT sources will save you some headaches. Just add deb http://apt.opscode.com/ squeeze [...]]]></description>
				<content:encoded><![CDATA[<p>Today, <a href="http://twitter.com/2spacesnotabs">Jens</a> and I got to play with <a href="http://www.opscode.com/chef/">Chef</a> which supposedly is the hot sh$&#038;!t when it comes to infrastructure automation and such. <a href="http://wiki.opscode.com/display/chef/Bootstrap+Chef+RubyGems+Installation">Installing your own Chef server</a> seems hard at first but will work in the end.</p>
<p>If you&#8217;re using Debian, the APT sources will save you some headaches. Just add</p>
<pre>
deb http://apt.opscode.com/ squeeze main
</pre>
<p>to your <code>/etc/apt/sources.list</code> and do something like </p>
<pre>
wget -qO - http://apt.opscode.com/packages@opscode.com.gpg.key | sudo apt-key add -
sudo apt-get update
</pre>
<p>to be sure to be getting what you asked for. Then, a little <code>sudo apt-get install chef</code> will do the trick to set up a client and <code>sudo apt-get install chef-server</code> will supercharge your node with a fully blown chef server, including but not limited to CouchDB, Solr, RabbitMQ and other fancy stuff. (You&#8217;ll want to do this on two different nodes, so use Virtual Box or something.)</p>
<p>After you&#8217;ve set up two nodes like that, try following the rest of the instructions in <a href="http://wiki.opscode.com/display/chef/Package+Installation+on+Debian+and+Ubuntu">this tutorial</a> and do the first <a href="http://wiki.opscode.com/display/chef/Cookbook+Quick+Start">cookbook example</a>, then you&#8217;ll have come as far as we have today.</p>
<p>I will update this post as we dig deeper &#8211; hopefully later this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2011/03/22/first-steps-with-chef/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SEO-friendly Affiliate Cookies powered by mod_rewrite</title>
		<link>http://fun.kyco.de/2010/04/29/seo-friendly-affiliate-cookies-powered-by-mod_rewrite/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=seo-friendly-affiliate-cookies-powered-by-mod_rewrite</link>
		<comments>http://fun.kyco.de/2010/04/29/seo-friendly-affiliate-cookies-powered-by-mod_rewrite/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 09:29:23 +0000</pubDate>
		<dc:creator>Jan Schulz-Hofen</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://fun.kyco.de/?p=30</guid>
		<description><![CDATA[So you want to run an affiliate or partner program, like for example the Planio Partner Program. Good idea. Happy customers who recommend your service to their friends are the best marketing you can get. Why not reward your customers and make them even happier? From a technical point of view, an affiliate program is [...]]]></description>
				<content:encoded><![CDATA[<p>So you want to run an affiliate or partner program, like for example the <a href="http://plan.io/partner-program" target="_blank">Planio Partner Program</a>. Good idea. Happy customers who recommend your service to their friends are the best marketing you can get. Why not reward your customers and make them even happier?</p>
<p>From a technical point of view, an affiliate program is nothing fancy at first glance:</p>
<ol>
<li>give your customer a link with a unique token</li>
<li>once a visitor signs up, check if a token is present and look up the respective customer</li>
<li>reward them!</li>
</ol>
<p>However! There&#8217;s some technical pitfalls.</p>
<h3>Keep track of the token</h3>
<p>This is a rather easy one: of course, you have to remember the token throughout entire visits. You can&#8217;t expect a visitor to turn into a paying customer right on the first page. They will check out your site, visit a couple of pages, and maybe even come back another day to buy your product. You still want to reward your affiliate, so cookies will be your single option.</p>
<h3>Don&#8217;t mess with Google</h3>
<p>We&#8217;ve learned this the hard way with <a href="http://be-a-magpie.com" target="_blank">Magpie</a> and it took us quite some time to recover our page rank, so be sure to read this! Google does not like <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=66359" target="_blank">duplicate content</a>. If you&#8217;re copying what others write on the Web or if you have a lot of pages with similar or even identical content, Google&#8217;s algorithms will classify your site as spam. What does this have to do with your affiliate program? Well, all those referral links are different because of the token, yet they will most certainly render the same content.</p>
<p>So what can you do? Redirect. Don&#8217;t let your app render a page if the request URI contains an affiliate token. Redirect to the actual page using <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2" target="_blank">status code 301</a> (moved permanently). This way, Google will know that the link is still valid (and thus you will get <a href="http://www.seerinteractive.com/blog/301-redirect-test-how-much-link-juice-are-you-losing/2010/04/09/" target="_blank">most of the link juice</a> from referring sites), but that its location has changed.</p>
<h3>How to implement?</h3>
<p>For a long time, we did this within in our application. Rails makes it really easy using <a href="http://apidock.com/rails/ActionController/Filters/ClassMethods/before_filter" target="_blank">before_filter</a>, so it&#8217;s no big deal. However, your setup may be more complex. Maybe you have multiple apps on subdomains or sub-URIs and maybe they run on different frameworks. Just think of your corporate blog, most of the time it&#8217;s a WordPress. But you&#8217;d still want to reward your affiliates if they send you traffic via a link to a great blog post you&#8217;ve written, right?</p>
<p>For Planio, we moved the redirection and cookie part to the Web server. Below is a short and sweet Apache config snippet which works really well for us:</p>
<pre># affiliate cookie
RewriteCond %{QUERY_STRING} (.*)ref=([a-zA-Z0-9]{6})(&amp;(.*))?
RewriteRule ^(.*)$ $1?%1%4 [CO=affiliate:%2:.plan.io:43200,R=301,L]</pre>
<p>It does everything for us, so our apps don&#8217;t have to worry:</p>
<ul>
<li>detect a token in a request URI (we use a ref= query param with a 6 character token)</li>
<li>set a cookie named affiliate using the token value which is valid for all our subdomains and for 30 days</li>
<li>redirect to the same page using 301, removing the ref parameter and keeping all other query parameters intact (this is great for other tracking stuff, like the params you can generate for <a href="http://google.com/support/analytics/bin/answer.py?hl=en&amp;answer=55578" target="_blank">Google Analytics</a>)</li>
</ul>
<p>In the end, we just need a one-liner in our signup code that reads the cookie, finds the affiliate and associates the affiliate with the newly created account.</p>
<p><strong>Update:</strong> Thomas points out that you could tell Google to <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=147959" target="_blank">ignore certain query params</a> and avoid 301 redirects using <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html" target="_blank">canonicals</a>. He also <a href="http://twitter.com/tomayac/status/13060213112" target="_blank">claims</a> that Google would be my friend. Not so sure about the last one, though <img src='http://fun.kyco.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I hope this was useful to you. Do you run affiliate programs for your products? What are your experiences? How did you implement them? I look forward to your thoughts in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://fun.kyco.de/2010/04/29/seo-friendly-affiliate-cookies-powered-by-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
