<?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>Wanderwort</title>
	<atom:link href="http://wanderwort.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://wanderwort.de</link>
	<description>Interkulturelle Wortkolletionen in Ruby, PHP, XHTML, CSS nah am Strom der Gesellschaft</description>
	<lastBuildDate>Tue, 13 Jul 2010 11:58:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Iterate over Associative Arrays in Bash</title>
		<link>http://wanderwort.de/2010/06/24/iterate-over-assoziative-arrays-in-bash/</link>
		<comments>http://wanderwort.de/2010/06/24/iterate-over-assoziative-arrays-in-bash/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 19:59:23 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Mac OS]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=299</guid>
		<description><![CDATA[Probably because many people think Bash is outdated it&#8217;s that hard to find proper resources digging into this Shell. Now we&#8217;ll have a look at an associative array and use each key to rename a file defined in value one got via wget. Beware: Take a look at the OS X issues at the end [...]]]></description>
			<content:encoded><![CDATA[<p>Probably because many people think Bash is outdated it&#8217;s that hard to find proper resources digging into this Shell. Now we&#8217;ll have a look at an <a href="http://en.wikipedia.org/wiki/Associative_array">associative array</a> and use each <em>key</em> to rename a file defined in <em>value</em> one got via <a href="http://en.wikipedia.org/wiki/Wget">wget</a>.</p>
<p><b style="color: red">Beware</b>: Take a look at the OS X issues at the end of this article if working on a Mac!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">unset</span> array; <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-A</span> array <span style="color: #666666; font-style: italic;"># the -A attributes stands for associative</span>
&nbsp;
array<span style="color: #7a0874; font-weight: bold;">&#91;</span>foo<span style="color: #7a0874; font-weight: bold;">&#93;</span>=bar
array<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;spaced string&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;foo bar&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${!array[@]}</span>
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #666666; font-style: italic;"># do something</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>This is how an iteration could look like. Have a look at <a href="http://wiki.bash-hackers.org/syntax/arrays">bash-hackers.org</a> to get more information. Thanks to <a href="http://blog.denniswilliamson.us/">Dennis Williamson</a> solving <a href="http://stackoverflow.com/questions/3112687/how-to-iterate-over-assoziative-array-in-bash">this topic</a>.</p>
<p>To get a file from the given URL perform the following command in the loop:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${array[$i]}</span>&quot;</span> <span style="color: #660033;">-O</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${i}</span>.jpg&quot;</span></pre></div></div>

<p>The attribute <em>-O</em> renames the file.</p>
<p>Using variables outside Strings obviate the need for curly brackets so that $i would work as well.<br />
<b>Go on reading if you&#8217;re using a Mac:</b><br />
<span id="more-299"></span><br />
<b>Mac OS X Issues</b><br />
The given example and associative arrays in bash require a Bash version greater than 4.0. OS X (Leopard) gets shipped with version 3.2.48(1). So we either have to install a newer Bash Version manually <a href="http://concisionandconcinnity.blogspot.com/2009/03/upgrade-bash-to-40-in-mac-os-x.html">as described by Ian McCracken</a> or use a package installer like <a href="http://www.finkproject.org/">Fink</a>, <a href="http://www.macports.org/">MacPorts</a> or <a href="http://mxcl.github.com/homebrew/">Homebrew</a>. As I am a Homebrew fanboy, here&#8217;s how to brew it:</p>
<p><b>Installing Bash > 4.0 with Homebrew</b></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ brew <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #666666; font-style: italic;"># definitely gets a newer version than 4.0:</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash &gt;&gt; /private/etc/shells&quot;</span> <span style="color: #666666; font-style: italic;"># register the new Bash as a valid Shell</span>
$ <span style="color: #c20cb9; font-weight: bold;">chsh</span> <span style="color: #666666; font-style: italic;"># use the new Shell for your user</span></pre></div></div>

<p>In the chsh file you simply enter the path you&#8217;ve installed and registered the shell to.</p>
<p>You might also have to install wget because Mac OS comes without this handy tool as well:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ brew <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">wget</span></pre></div></div>

<p><b style="color: red">IMPORTANT:</b><br />
In your scripts you also have to define the new path of Bash! E.g:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash</span>
&nbsp;
some_bash_code</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/06/24/iterate-over-assoziative-arrays-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-Domain with Sinatra / Rack and JSONP</title>
		<link>http://wanderwort.de/2010/03/25/sinatra-rack-with-jsonp/</link>
		<comments>http://wanderwort.de/2010/03/25/sinatra-rack-with-jsonp/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 00:45:35 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Rack]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=284</guid>
		<description><![CDATA[There are several situations one might want to do cross-domain (/cross-site) AJAX-requests. Probably you experience the security borders of modern browsers very fast. JSONP is a hack for JSON that provides a great workaround. It means sending a callback with the URL (eg. ?callback=sampleFunction). Server-sided we setup our application to respond with a JSON body [...]]]></description>
			<content:encoded><![CDATA[<p>There are several situations one might want to do cross-domain (/cross-site) <a href="http://de.wikipedia.org/wiki/Ajax_(Programmierung)">AJAX</a>-requests. Probably you experience the security borders of modern browsers very fast.<br />
<a href="http://en.wikipedia.org/wiki/JSONP#JSONP">JSONP</a> is a hack for <a href="http://www.json.org/">JSON</a> that provides a great workaround. It means sending a callback with the URL (eg. ?callback=sampleFunction). Server-sided we setup our application to respond with a JSON body wrapped in a function named like our callback function. In this case</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sampleFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;ourData&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;is an array&quot;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>   
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h3>What we have to do (Sample)</h3>
<p><b>Frontend</b><br />
JS-Frameworks like <a href="http://jquery.com/">jQuery</a> are smart enough to send such requests with ease. Lets write a simple function with jQuery:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'get'</span><span style="color: #339933;">,</span>
  url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'file.json'</span><span style="color: #339933;">,</span>
  dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'jsonp'</span><span style="color: #339933;">,</span>
  success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doSomethingWith<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><b>Let&#8217;s see how to setup the server:</b><br />
Using <a href="http://www.ruby-lang.org/en/">Ruby</a> and <a href="http://rack.rubyforge.org/">Rack</a> it becomes very simple to beautifully provide regular JSON for non-JSONP clients and JSONP for jQuery &#038; Co.<br />
Simply use the rack middleware <a href="http://github.com/rack/rack-contrib/">rack-contrib by Ryan Tomayko</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rack-rack-contrib <span style="color: #660033;">--source</span>=http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>If you&#8217;re using pure rack, put this in your config.ru</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rack/contrib/jsonp'</span>
use <span style="color:#6666ff; font-weight:bold;">Rack::JSONP</span></pre></div></div>

<p>Using <a href="http://www.sinatrarb.com/">Sinatra</a>, I&#8217;d put it somewhere with my config files.<br />
Let&#8217;s see how a sample <a href="http://www.sinatrarb.com/">Sinatra</a> application could look like:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rack/contrib/jsonp'</span>
&nbsp;
use <span style="color:#6666ff; font-weight:bold;">Rack::JSONP</span>
&nbsp;
before <span style="color:#9966CC; font-weight:bold;">do</span>
  content_type <span style="color:#ff3333; font-weight:bold;">:json</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
get <span style="color:#996600;">'/posts'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  Posts.<span style="color:#9900CC;">find</span>.<span style="color:#9900CC;">to_a</span>.<span style="color:#9900CC;">to_json</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>That simple, this powerful.</p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/03/25/sinatra-rack-with-jsonp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>InDesign: Sprache für ganzes Dokument ändern</title>
		<link>http://wanderwort.de/2010/03/08/indesign-sprache-fur-ganzes-dokument-andern/</link>
		<comments>http://wanderwort.de/2010/03/08/indesign-sprache-fur-ganzes-dokument-andern/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 14:37:57 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[InDesign]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=262</guid>
		<description><![CDATA[Es gibt zwei Möglichkeiten die Sprache für das Text- und Absatzformat in InDesign zu ändern. Wenn wir allerdings nicht für jedes Textfeld die Sprache ändern wollen, müssen wir uns eines Workarounds bedienen. Schließlich gibt es kein &#8220;Sprache für Dokument ändern&#8221;. Dann wollen wir mal: Wir gehen in unser Menü: Bearbeiten -> Suchen/Ersetzen (bzw. MacOS: ⌘+F, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/2010/03/08/indesign-sprache-fur-ganzes-dokument-andern/"><img src="http://www.adobe.com/accessibility/products/indesign/images/indesign_cs4_150x150.jpg" alt="InDesign" style="float: left;margin: 0 10px 10px 0"/></a> Es gibt zwei Möglichkeiten die Sprache für das Text- und Absatzformat in InDesign zu ändern. Wenn wir allerdings nicht für jedes Textfeld die Sprache ändern wollen, müssen wir uns eines Workarounds bedienen. Schließlich gibt es kein &#8220;Sprache für Dokument ändern&#8221;. Dann wollen wir mal:<br />
<span id="more-262"></span>Wir gehen in unser Menü: Bearbeiten -> Suchen/Ersetzen<br />
(bzw. MacOS: ⌘+F, Windows: CTRL+F)</p>
<p><img src="http://wanderwort.de/wp-content/uploads/2010/03/4erweiterte-optionen.png" alt="" title="4erweiterte-optionen" width="569" height="448" class="alignnone size-full wp-image-263" /></p>
<p>Man bediene sich der erweiterten Suchoptionen und kommt so zur nächsten Ansicht:</p>
<p><img src="http://wanderwort.de/wp-content/uploads/2010/03/5sprache-auswaehlen2.png" alt="" title="5sprache-auswaehlen" width="600" height="343" class="alignnone size-full wp-image-271" /></p>
<p>Nun wählen wir für die Suchoption unsere zu ersetzende Sprache aus, die im Dokument geführt wird. Die Auswahl wird mit OK bestätigt und im nächsten Schritt geben wir für das Ersetzen die Zielsprache auf die gleiche Weise ein. Wenn alles richtig lief, sieht das Suchen/Ersetzen-Fenster nun so aus:</p>
<p><img src="http://wanderwort.de/wp-content/uploads/2010/03/6optionen-ausgefuellt.png" alt="" title="6optionen-ausgefuellt" width="569" height="448" class="alignnone size-full wp-image-265" /></p>
<p>Wunderbar. Um das ganze Dokument zu ändern, muss bei &#8220;Durchsuchen&#8221; auch &#8220;Dokument&#8221; eingestellt sein!<br />
Mit &#8220;Alle ändern&#8221; stellen wir nun unser Dokument auf die neue Sprache um. </p>
<p>In allen Textfelder sollte nun, wenn wir das Textwerkzeug (T) benutzen, in den Optionen die neue Sprache erscheinen:</p>
<p><img src="http://wanderwort.de/wp-content/uploads/2010/03/2sprachauswahl.png" alt="" title="2sprachauswahl" width="600" height="45" class="alignnone size-full wp-image-275" /></p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/03/08/indesign-sprache-fur-ganzes-dokument-andern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erfolg im Leben</title>
		<link>http://wanderwort.de/2010/02/09/erfolg-im-leben/</link>
		<comments>http://wanderwort.de/2010/02/09/erfolg-im-leben/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 20:50:54 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemischtes]]></category>
		<category><![CDATA[Absurd]]></category>
		<category><![CDATA[Hamburg]]></category>
		<category><![CDATA[Verrückt]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=248</guid>
		<description><![CDATA[Es kann so einfach sein.. Werbung von Morgen. Aufgenommen: Bf Hamburg Altona (neben Mc Donalds) &#8211; &#8220;Werbekasten&#8221; Update via @MrRaffnix &#8211; so macht man&#8217;s richtig:]]></description>
			<content:encoded><![CDATA[<p>Es kann so einfach sein.. Werbung von Morgen.</p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/02/erfolg_small.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/02/erfolg_small.jpg" alt="Erfolg im Leben" title="erfolg_small" width="600" height="474" class="alignnone size-full wp-image-249" /></a></p>
<div style="text-align: right">Aufgenommen: Bf Hamburg Altona (neben Mc Donalds) &#8211; &#8220;Werbekasten&#8221;</div>
<p><ins datetime="2010-02-11T16:10:30+00:00"><br />
Update via <a href="http://twitter.com/MrRaffnix">@MrRaffnix</a> &#8211; so macht man&#8217;s richtig:</p>
<p></ins><span id="more-248"></span><ins datetime="2010-02-11T16:10:30+00:00"><img src="http://wanderwort.de/wp-content/uploads/2010/02/guerilla-marketing-hochsicherheitsglas.jpeg" alt="" title="guerilla-marketing-hochsicherheitsglas" width="475" height="592" class="alignnone size-full wp-image-259" /><br />
</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/02/09/erfolg-im-leben/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Brief an einen Freund</title>
		<link>http://wanderwort.de/2010/02/08/brief-an-einen-freund/</link>
		<comments>http://wanderwort.de/2010/02/08/brief-an-einen-freund/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 13:18:56 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gedachtes]]></category>
		<category><![CDATA[Freunde]]></category>
		<category><![CDATA[Menschen]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=233</guid>
		<description><![CDATA[Um herauszufinden, was du willst, musst du bewusster leben &#8211; nicht danach suchen. Denn erst Erlebtes lässt sich reflektieren. Leben ist permanent in Bewegung zu bleiben. Studien haben ergeben, dass sportliche Menschen, denen man mehrere Wochen lang Faulenzen verordnet hat, schon nach kürzester Zeit schwere physische Mängelerscheinungen aufwiesen. Ich bin mir trotz fehlenden Studien sicher, [...]]]></description>
			<content:encoded><![CDATA[<p>Um herauszufinden, was du willst, musst du bewusster leben &#8211; nicht danach suchen. Denn erst Erlebtes lässt sich reflektieren. Leben ist permanent in Bewegung zu bleiben.<br />
Studien haben ergeben, dass sportliche Menschen, denen man mehrere Wochen lang Faulenzen verordnet hat, schon nach kürzester Zeit schwere physische Mängelerscheinungen aufwiesen. Ich bin mir trotz fehlenden Studien sicher, dass genau dies auch mit deiner Psyche passiert wenn du deinen Geist zu Bette trägst. Am leichtesten passiert dies, wenn du dich auf erreichtem ausruhst. Was dein Körper dir mit schwammigen Polstern verbucht, endet für dein Wesen in einer erträglichen, unbewussten Einfalt. Die Seligkeit scheint omnipräsent &#8211; ist aber zerbrechlich wie Porzellan. Es ist einfacher.</p>
<p>Reflektierst du diese Hypothese auf deine Beziehungen, wirst du ganz ähnliche Zusammenhänge erkennen. Insbesondere partnerschaftliche Beziehungen können unter der enormen Last der Unbedarftheit bersten. Die Schlichtheit einer Beziehung ist bester Nährboden für Glückseligkeit. Wenn sich Lebensbedingungen und Beziehungen ändern kann es aber sein, dass dieser Boden nicht mehr trägt. Was man also bis hierher aufgebaut hat, kann sich geradewegs entrüsten. Du bist entmutigt und enttäuscht von dir selbst. An dieser Stelle bist du gerade. Du musst nun beantworten ob du dir zutraust mit den gleichen Steinen, mit der Annahme die Architektur besser zu verstehen, das Fundament neu zu verlegen. Wenn, denke daran, dass du entweder die Ruinen des alten Baus &#8211; so weit möglich &#8211; wegräumst oder ein, in seiner Stabilität gefährdetes, Neues darauf setzt. Oder du sogar neue Gründe erforscht und auf neuem Raum mit neuem Material baust.<br />
In jedem Fall ist es maßgebend, dass du die ständige Anpassung und Auseinandersetzung wahrst. Lass dies dein oberster Grundsatz sein.</p>
<p>Vielleicht konnte ich dir ein wenig helfen. Viel Erfolg und Glück!</p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/02/08/brief-an-einen-freund/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cheatsheet: moving data from one server to another</title>
		<link>http://wanderwort.de/2010/01/20/moving-data-from-one-server-to-another/</link>
		<comments>http://wanderwort.de/2010/01/20/moving-data-from-one-server-to-another/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 06:00:11 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=217</guid>
		<description><![CDATA[This article is about moving a running web-environment along with it&#8217;s MySQL database from one server to another via SSH. Compress files Let&#8217;s compress the directory we&#8217;re going to move using gzip: tar cfvz backup.tar.gz /path/ Dump MySQL database content mysqldump -uUser -p -hlocalhost database_name &#62; dump.sql You can also dump several databases with mysqldump [...]]]></description>
			<content:encoded><![CDATA[<p>This article is about moving a running web-environment along with it&#8217;s <a href="http://en.wikipedia.org/wiki/MySQL">MySQL</a> database from one server to another via <a href="http://en.wikipedia.org/wiki/Secure_Shell">SSH</a>.</p>
<h3>Compress files</h3>
<p>Let&#8217;s compress the directory we&#8217;re going to move using <a href="http://en.wikipedia.org/wiki/Gzip">gzip</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> cfvz backup.tar.gz <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</p>
<h3>Dump MySQL database content</h3>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-uUser</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-hlocalhost</span> database_name <span style="color: #000000; font-weight: bold;">&gt;</span> dump.sql</pre></div></div>

<p>You can also dump several databases with <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html">mysqldump</a> by addind the <code>--databases</code> or <code>--all-databases</code> parameter.</p>
<h3>Moving files</h3>
<p>Now we use <a href="http://en.wikipedia.org/wiki/Secure_Copy">SCP</a> to move files to our new machine. The following example copies from the old machine:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> user<span style="color: #000000; font-weight: bold;">@</span>host:<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>backup.tar.gz .</pre></div></div>

<p>The other way round, copying the file to the new machine from the old one would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> backup.tar.gz user<span style="color: #000000; font-weight: bold;">@</span>host:<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>backup.tar.gz</pre></div></div>

<p>Do the same with your database dump.
</p>
<h3>Uncompress files</h3>
<p>Simply type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xfvz backup.tar.gz</pre></div></div>

<p>Now we should have the same directory structure we had on our old machine.</p>
<h3>Import MySQL database</h3>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-uUser</span> <span style="color: #660033;">--default-character-set</span>=utf8 <span style="color: #660033;">-hlocalhost</span> <span style="color: #660033;">-p</span> database_name <span style="color: #000000; font-weight: bold;">&lt;</span> dump.sql</pre></div></div>

<p>If you have international content and an utf-8 environment running don&#8217;t forget to pass the charset-parameter!</p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/01/20/moving-data-from-one-server-to-another/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hamburger Hafen im Winter</title>
		<link>http://wanderwort.de/2010/01/12/204/</link>
		<comments>http://wanderwort.de/2010/01/12/204/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 16:42:36 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Hafen]]></category>
		<category><![CDATA[Hamburg]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=204</guid>
		<description><![CDATA[Passend zum Schneechaos in Norddeutschland ein paar Eindrücke aus dem Hamburger Hafen im Winter. Ich habe noch nichts nachbearbeitet &#8211; also seht ihr Rohmaterial aus der Kamera.]]></description>
			<content:encoded><![CDATA[<p>Passend zum Schneechaos in Norddeutschland ein paar Eindrücke aus dem Hamburger Hafen im Winter. Ich habe noch nichts nachbearbeitet &#8211; also seht ihr Rohmaterial aus der Kamera.</p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0158.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0158-1024x680.jpg" alt="Eisbrecher Hamburg" title="Eisbrecher Hamburg" width="450" height="298" class="aligncenter size-large wp-image-200" /></a></p>
<p><span id="more-204"></span><br />
<a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0142.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0142-1024x680.jpg" alt="Eisbrecher Elbe" title="Eisbrecher Elbe" width="450" height="298" class="aligncenter size-large wp-image-199" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0135.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0135-1024x680.jpg" alt="Eisbrecher Elbe" title="Eisbrecher Elbe" width="450" height="298" class="aligncenter size-large wp-image-198" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0175.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0175-1024x680.jpg" alt="Eisbrecher Bugsier" title="Eisbrecher Bugsier" width="450" height="298" class="aligncenter size-large wp-image-201" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0219.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0219-1024x680.jpg" alt="Hamburg Hafenfähre" title="Hamburg Hafenfähre" width="450" height="298" class="aligncenter size-large wp-image-203" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0128.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0128-1024x680.jpg" alt="Hafen Hamburg" title="Hafen Hamburg" width="450" height="298" class="aligncenter size-large wp-image-197" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0110.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0110-1024x680.jpg" alt="Wir sind geboren um frei zu sein" title="Wir sind geboren um frei zu sein" width="450" height="298" class=" aligncenter size-large wp-image-196" /></a></p>
<p><a href="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0186.jpg"><img src="http://wanderwort.de/wp-content/uploads/2010/01/DSC_0186-1024x680.jpg" alt="im Hafen" title="im Hafen" width="450" height="298" class="aligncenter size-large wp-image-202" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2010/01/12/204/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>select any HTML text in element with jQuery</title>
		<link>http://wanderwort.de/2009/11/19/select-any-html-text-in-element-with-jquery/</link>
		<comments>http://wanderwort.de/2009/11/19/select-any-html-text-in-element-with-jquery/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 15:25:44 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=170</guid>
		<description><![CDATA[The following script jQuery extension selects any text from a given jQuery selector. Tested with Firefox and Safari &#8211; should work in IE6+ as well. jQuery.fn.extend&#40;&#123; selectText: function&#40;&#41; &#123; var text = $&#40;this&#41;&#91;0&#93;; if &#40;$.browser.msie&#41; &#123; var range = document.body.createTextRange&#40;&#41;; range.moveToElementText&#40;text&#41;; range.select&#40;&#41;; &#125; else if &#40;$.browser.mozilla &#124;&#124; $.browser.opera&#41; &#123; var selection = window.getSelection&#40;&#41;; var range [...]]]></description>
			<content:encoded><![CDATA[<p>The following <del datetime="2009-11-19T15:26:12+00:00">script</del> <ins datetime="2009-11-19T15:26:37+00:00">jQuery extension</ins> selects any text from a given jQuery selector. Tested with Firefox and Safari &#8211; should work in IE6+ as well.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  selectText<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> range <span style="color: #339933;">=</span> document.<span style="color: #660066;">body</span>.<span style="color: #660066;">createTextRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      range.<span style="color: #660066;">moveToElementText</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      range.<span style="color: #660066;">select</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">mozilla</span> <span style="color: #339933;">||</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">opera</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> selection <span style="color: #339933;">=</span> window.<span style="color: #660066;">getSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> range <span style="color: #339933;">=</span> document.<span style="color: #660066;">createRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      range.<span style="color: #660066;">selectNodeContents</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      selection.<span style="color: #660066;">removeAllRanges</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      selection.<span style="color: #660066;">addRange</span><span style="color: #009900;">&#40;</span>range<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">safari</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> selection <span style="color: #339933;">=</span> window.<span style="color: #660066;">getSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      selection.<span style="color: #660066;">setBaseAndExtent</span><span style="color: #009900;">&#40;</span>text<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> text<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>To use it simly do:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> shortSelector <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#name'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">selectText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> longSelector <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul#names li:contains(&quot;Hampel&quot;)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">selectText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>written on top of <a href="http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse">Source</a> and <a href="http://www.codingforums.com/archive/index.php/t-105808.html">Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2009/11/19/select-any-html-text-in-element-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-Mobile Hotspot einrichten</title>
		<link>http://wanderwort.de/2009/08/13/t-mobile-hotspot-einrichten/</link>
		<comments>http://wanderwort.de/2009/08/13/t-mobile-hotspot-einrichten/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 20:13:55 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemischtes]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[T-Mobile]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=157</guid>
		<description><![CDATA[Wer einen Complete Tarif mit iPhone hat, hat &#8220;eigentlich&#8221; auch eine HotSpot Flat für die über 8000 Hotspots vom rosa Riesen. Da aber die komplette Benutzerverwaltung auf mein.t-mobile.de absoluter Schrott ist und von Integrität nicht die Rede sein kann, muss man erraten wie man nun an seine Zugangsdaten kommt. Wenn man es weiss, ist es [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/2009/08/13/t-mobile-hotspot-einrichten/" style="float:left;margin: 10px 10px 5px 0;"><img src="http://wanderwort.de/wp-content/uploads/2009/08/t-mobile-hotspot300x2401.gif" alt="T-Mobile Hotspot" title="T-Mobile Hotspot" width="200" height="80" class="alignnone size-full wp-image-168" /></a> Wer einen Complete Tarif mit iPhone hat, hat &#8220;eigentlich&#8221; auch eine HotSpot Flat für die über 8000 Hotspots vom rosa Riesen. Da aber die komplette Benutzerverwaltung auf <a href="http://mein.t-mobile.de">mein.t-mobile.de</a> absoluter Schrott ist und von Integrität nicht die Rede sein kann, muss man erraten wie man nun an seine Zugangsdaten kommt. Wenn man es weiss, ist es einfach: <span id="more-157"></span></p>
<p>Über <a href="http://myhotspot.t-mobile.net">myhotspot.t-mobile.net</a> kommt man auf eine Seite, die so viel Aussagekraft hat wie eine Raufasertapete. Hier geben wir unseren Benutzernamen ein. Natürlich nicht der, den wir für den Login auf dem eigentlichen Portal verwenden! Klar. Folgendes Muster: #LandVorwahlRufnummer#@t-mobile.de. Wäre meine Rufnummer 0170 8787 300, wäre es zB 491708787300@t-mobile.de. Kann man auch selbst drauf kommen, wa?</p>
<p>Das Passwort &#8211; sage ich gleich &#8211; kann man nicht wissen. Entweder ihr sendet eine SMS mit &#8220;Passwort&#8221; von eurem iPhone an die 9526 oder klickt unten auf &#8220;Passwort Erinnerung&#8221;. Damit könnt ihr euch einloggen und eure Daten für den Login eingeben. Fertig.</p>
<p>Wer es &#8220;einfach&#8221; &#8211; also kompliziert wissen will, wie man sich über die URL im Portal anmelden kann findet Infos hier: <a href="http://www.macbug.de/2007/11/26/anmeldung-am-t-mobile-hotspot-leicht-gemacht/">Anmeldung am T-Mobile Hotspot</a></p>
<p>Für die, die auch <a href="http://mein.t-mobile.de">mein.t-mobile.de</a> zum ersten Mal entdecken: Dieser haufen Schrott bietet für alle iPhone-Kunden eine kostenlose Homezone Nummer, die erst aktiviert werden muss. Ferner: Für jede Bank- oder Adressänderung gibt&#8217;s Geld gutgeschrieben. Also ruhig mal den Stock ändern, in dem ihr wohnt <img src='http://wanderwort.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Ich finde es übrigens wirklich erbärmlich, wie sich dieses riesige Unternehmen einen solchen Ranz erlauben kann. 30% der verlinkten Seiten im Portal enden mit einem 404, Preisangaben variieren je nachdem von wo man kommt, Buttons sind nicht klickbar, die Scrollbalken verschwinden beim Scrollen. Erinnert mich irgendwie an ein Surferlebnis 1997 mit dem IE6. Nichts ist da wo man es erwartet und nie passiert etwas, das man erwartet. Toll.</p>
]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2009/08/13/t-mobile-hotspot-einrichten/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>HTML to PDF Library for PHP 5</title>
		<link>http://wanderwort.de/2009/07/08/html-to-pdf-library-for-php-5/</link>
		<comments>http://wanderwort.de/2009/07/08/html-to-pdf-library-for-php-5/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:06:14 +0000</pubDate>
		<dc:creator>pex</dc:creator>
				<category><![CDATA[Gemachtes]]></category>
		<category><![CDATA[Arbeit]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://wanderwort.de/?p=138</guid>
		<description><![CDATA[As I had to build a simple html to pdf converting for a client using php, I found a beautiful library called DOMPDF written by Benj Carson. It seemed to be very lightweight and uncomplicated, which turned out to be true. In a standard case it really is as simple as $pdf-&#62;load_html&#40;$html&#41;; I am going [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wanderwort.de/2009/07/08/html-to-pdf-library-for-php-5/"><img src="http://wanderwort.de/wp-content/uploads/2009/07/dompdf_simple.png" alt="DomPDF HTML to PDF" title="dompdf_simple" width="200" height="76" class="size-full wp-image-146" style="float: left; margin: 0 15px 5px 0" /></a> As I had to build a simple html to pdf converting for a client using php, I found a <a href="http://www.digitaljunkies.ca/dompdf/">beautiful library called DOMPDF</a> written by Benj Carson.</p>
<p>It seemed to be very lightweight and uncomplicated, which turned out to be true. In a standard case it really is as simple as</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load_html</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I am going to talk about the basic usage and problems I had to solve, specially with umlauts / non latin characters.<br />
<span id="more-138"></span></p>
<h3>Basic Usage</h3>
<p>To initiate an environment you just create a new instance of the given class.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#path-to-your-installation#/dompdf/dompdf_config.inc.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load_html</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#some-html#'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">stream</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'some-file.pdf'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Further information about the basic usage of the class can be found on the <a href="http://www.digitaljunkies.ca/dompdf/usage.php">project page</a>. I am only using it inline PHP.</p>
<h3>Convert your CSS styled HTML</h3>
<p>Now you have to feed the method load_html with some html. Therefore we build a whole, simple page including as stylesheet (css). One of the most important things about this class is, that you simply link to a css file and dompdf parses and uses it to style your pdf.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;some-css.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Your Content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Please notice that dompdf neither supports absolute positioning nor floating. Therefor we have to use backgound-image-position to position images. Remember not to use the short-form &#8220;background&#8221; as this isn&#8217;t supported neither.</p>
<h3>Fixing White-Spaces</h3>
<p>I had the problem of wrong white-spaces respectively line-breaks because I had to convert a german document. tommylacroix found <a href="http://www.dashinteractive.net/dompdf/index.php?v=3153736">a solution</a> that worked perfectly for me.<br />
You have to go into your text_frame_decorator.cls.php around line 127 and replace</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">function</span> split_text<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$split</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_frame<span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">splitText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$deco</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$split</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>by</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">function</span> split_text<span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_frame<span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$split</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_frame<span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">splitText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_frame<span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$split</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$deco</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$split</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Using inline PHP embedded in HTML</h3>
<p>Last but not least there are several more options to manipulate the rendered pdf file. By adding some inline php code in your html we can manage to display page numbers, a header or footer, watermarks, etc.</p>
<p>To add page numbers to your pdf, we add the following code to our html:<br/> (I explained the usage in comments)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/php&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pdf</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">## Setup a tiny configuration ##
</span>      <span style="color: #000088;">$text_height</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">17</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$text_size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$font</span> <span style="color: #339933;">=</span> Font_Metrics<span style="color: #339933;">::</span><span style="color: #004000;">get_font</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;helvetica&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;normal&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">## Get the dimensions of our pdf-file ##
</span>      <span style="color: #000088;">$dimensions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;width&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;height&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">## The Counter-Text with variables: ##
</span>      <span style="color: #000088;">$pageCounterText</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Page: {PAGE_NUM} of {PAGE_COUNT}&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">## If you want to position the Counter on the right, you need the text-width: ##
</span>      <span style="color: #000088;">$pageCounterWidth</span> <span style="color: #339933;">=</span> Font_Metrics<span style="color: #339933;">::</span><span style="color: #004000;">get_text_width</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageCounterText</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">## Not we can add this to our pdf:
</span>      <span style="color: #000088;">$pdf</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">page_text</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dimensions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;height&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #000088;">$text_height</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pageCounterText</span><span style="color: #339933;">,</span> <span style="color: #000088;">$font</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text_size</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></pre></div></div>

<p>The page_text method works like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  page_text<span style="color: #009900;">&#40;</span>float <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> float <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> string <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> string <span style="color: #000088;">$font</span><span style="color: #339933;">,</span> float <span style="color: #000088;">$size</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">## Explanation: ##
</span>    <span style="color: #000088;">$x</span><span style="color: #339933;">:</span> Position from the top
    <span style="color: #000088;">$y</span><span style="color: #339933;">:</span> Position from the left
    <span style="color: #000088;">$size</span><span style="color: #339933;">:</span> Font<span style="color: #339933;">-</span>Size
    <span style="color: #000088;">$color</span><span style="color: #339933;">:</span> an rgb<span style="color: #339933;">-</span><span style="color: #990000;">array</span> <span style="color: #339933;">-&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>R<span style="color: #339933;">,</span> G<span style="color: #339933;">,</span> B<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>optional<span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://wanderwort.de/2009/07/08/html-to-pdf-library-for-php-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
