<?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>MacLovin &#187; web</title>
	<atom:link href="http://www.maclovin.de/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maclovin.de</link>
	<description>An Apple a day keeps the Windows away</description>
	<lastBuildDate>Tue, 17 Aug 2010 21:45:50 +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>Robust HTML parsing the Groovy way</title>
		<link>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/</link>
		<comments>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 19:50:06 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=445</guid>
		<description><![CDATA[With Groovy, it&#8217;s very easy to parse XML data and extract arbitrary information. This works great as long as the input data is well-formed, but you can&#8217;t always guarantee that in real-world scenarios. Think of extracting data from HTML pages. They are very often a...]]></description>
			<content:encoded><![CDATA[<p>With Groovy, it&#8217;s very easy to parse XML data and extract arbitrary information. This works great as long as the input data is well-formed, but you can&#8217;t always guarantee that in real-world scenarios. Think of extracting data from HTML pages. They are very often a mess when it comes to XML validity and that&#8217;s where the <a title="TagSoup" href="http://home.ccil.org/~cowan/XML/tagsoup/" target="_blank">TagSoup library</a> comes to the rescue.</p>
<p><span id="more-445"></span></p>
<p>There are two major problems with HTML input:</p>
<ul>
<li>DTD resolution</li>
<li>Missing closing tags</li>
</ul>
<p>We are going to build a simple Groovy script that prints the list of questions on StackOverflow&#8217;s start page. The straight forward solution looks something like that</p>
<pre class="brush: groovy">def slurper = new XmlSlurper()
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
<p>We parse <a href="http://stackoverflow.com" target="_blank">http://stackoverflow.com</a> with XMLSlurper, loop over all tags with the class attribute &#8216;question-hyperlink&#8217; and print it. But when running the script we get the following exception:</p>
<blockquote>
<div id="_mcePaste">Caught: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/html4/strict.dtd at html_parser.run(html_parser.groovy:7)</div>
</blockquote>
<div>XMLSlurper has problems with HTML DTDs. By using the information in <a title="Groovy XmlSlurper and HTTP 503 Response Code" href="http://stevefinck.blogspot.com/2009/12/groovy-xmlslurper.html" target="_blank">this post</a>, we get rid of the exception.</div>
<div>
<pre class="brush: groovy;highlight: 2">def slurper = new XmlSlurper()
slurper.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
</div>
<div>So next try. The DTD exception is gone, but we get another one saying the closing link-tag is missing. And here comes TagSoup. It&#8217;s a library that tries to transform invalid HTML data into well-formed XML. And best of all, it works great together with XMLSlurper. Here is the final Script:</div>
<div>
<pre class="brush: groovy">@Grab(group='org.ccil.cowan.tagsoup',
      module='tagsoup', version='1.2' )
def tagsoupParser = new org.ccil.cowan.tagsoup.Parser()
def slurper = new XmlSlurper(tagsoupParser)
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
</div>
<div>The first command uses the @Grab-annotation to load the TagSoup library. Next we create a TagSoup-Parser instance and pass it as constructor-parameter to XMLSlurper. That&#8217;s all and we even got rid of the <em>setFeature</em> workaround.</div>
<div>You know other tricks to make HTML parsing more robust? Then please leave them in the comments.</div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using WordPress as URL redirection service</title>
		<link>http://www.maclovin.de/2009/08/using-wordpress-as-url-redirection-service/</link>
		<comments>http://www.maclovin.de/2009/08/using-wordpress-as-url-redirection-service/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 09:28:18 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=359</guid>
		<description><![CDATA[Redirection is a WordPress plugin that let&#8217;s you add URL redirections to your blog. This is very useful if the addess of some or even all of your blog posts changed. The setup is straight forward: just enter source and target URL and the redirection is...]]></description>
			<content:encoded><![CDATA[<p><a title="Redirection" href="http://urbangiraffe.com/plugins/redirection/" target="_blank">Redirection</a> is a WordPress plugin that let&#8217;s you add URL redirections to your blog. This is very useful if the addess of some or even all of your blog posts changed. The setup is straight forward: just enter source and target URL and the redirection is set up. The more advanced users can even add redirections based on regular expressions.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2009/08/redirection.png" rel="lightbox[359]" title="Redirection for WordPress"><img class="aligncenter size-medium wp-image-368" title="Redirection for WordPress" src="http://www.maclovin.de/wp-content/uploads/2009/08/redirection-500x131.png" alt="Redirection for WordPress" width="500" height="131" /></a></p>
<p>I (mis)used this plugin to setup short URLs to my profiles on social networks. I own the domain <a title="Frommknecht.net" href="http://www.frommknecht.net" target="_blank">frommknecht.net</a>, which happens to be my surname followed by the .net extension. So I thought it would be a great idea to forward <a title="Facebook" href="http://frommknecht.net/fb" target="_blank">frommknecht.net/fb</a> to my Facebook profile, <a title="Twitter" href="http://frommknecht.net/twitter" target="_blank">frommknecht.net/twitter</a> to my Twitter page and so on. With Redirection, that&#8217;s very easy. Just go to the Redirection-settings, enter e.g. <em>/twitter</em> as &#8220;Source URL&#8221; and the link to your Twitter page as target. That&#8217;s all. After adding the redirection, your Twitter page will be available via <em>http://&lt;your-blog-url&gt;/twitter</em>.</p>
<p>This way, you could even use WordPress as your private short-URL service ala <a title="Bit.ly" href="http://bit.ly" target="_blank">bit.ly</a>.</p>
<p>You have other cool tipps for Redirection? Then please leave a comment.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/08/using-wordpress-as-url-redirection-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GMail as one and only Inbox</title>
		<link>http://www.maclovin.de/2009/04/using-gmail-as-one-and-only-inbox/</link>
		<comments>http://www.maclovin.de/2009/04/using-gmail-as-one-and-only-inbox/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 20:20:55 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=139</guid>
		<description><![CDATA[If you&#8217;re like me, then you&#8217;ve got lots of different mail accounts. As nice as this may be to reduce spam and to always have the right address for any opportunity, as annoying it is when it comes to checking your mail &#8220;on the road&#8221;....]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me, then you&#8217;ve got lots of different mail accounts. As nice as this may be to reduce spam and to always have the right address for any opportunity, as annoying it is when it comes to checking your mail &#8220;on the road&#8221;. It results in visiting several webmail sites which is really time consuming, especially if you check your mail regulary.</p>
<p>To solve this problem, I decided to use GMail as my one and only mail inbox. In this post, I show you how I set it up.</p>
<p><span id="more-139"></span></p>
<h5>Previous setup</h5>
<p>So far, I used Apple&#8217;s Mail.app with one account for every mail address I own. This was working fine as long as I went online with my Macbook Pro. But if I would like to check mail at work for example, I would have to visit 6 webmail sites for full processing of my mail inboxes. In practice, I just checked mail of my main account. Then I decided to read all my mail via just one webmail site, GMail.</p>
<h5>Why GMail</h5>
<p>Most of the setup I describe in this post can be used with any webmail, but I chose GMail for these reasons:</p>
<ul>
<li>Very good web interface</li>
<li>IMAP support</li>
<li>Use of various sender addresses</li>
<li>20MB as maximum attachment size</li>
</ul>
<p>With these features present, an almost perfect setup is possible.</p>
<h5>Import your mail to GMail</h5>
<p>First of all, we need a way to import the mail of all other accounts into GMail. There are actually two ways</p>
<ul>
<li>GMail can fetch mail from POP3 servers</li>
<li>Forward mails from all the other accounts to the GMail address</li>
</ul>
<p>I first tried using POP3, but the result was not really satisfying, GMail decided to look for new mail only once a hour or even less. Sometimes I even had to trigger it manually. So I&#8217;m using the second method and forward any incoming mail to my GMail account.</p>
<h5>Sending mail</h5>
<p>When you send mail, you usually don&#8217;t want to use your GMail address as sender. If you reply to a mail, you want to use the address that the mail was addressed to. In GMail, you can use various sender addresses, not only your GMail address. The mail is still send via Google&#8217;s mail server, but the sender is different. This is not perfect, but acceptable if I have to send a mail via the web interface.</p>
<p>It would be much nicer if GMail would support a SMTP server per sender address and send the mail via this server. That&#8217;s exactly what mail clients would do.</p>
<h5>Desktop integration</h5>
<p>So far, all the mail we get shows up in our GMail inbox and we can send mail via Google&#8217;s mail server using any of our mail addresses. There is only one more thing to do, a proper desktop integration. The web interface is really nice and works great for anything it is supposed to, but there is no integration with your operating system. Using Mac OS X, you can for example send a photo via mail directly from iPhoto or attaching a file by dragging the file from the finder to the mail icon. That&#8217;s something I often use and don&#8217;t want to miss. </p>
<p>Luckily, GMail offers IMAP access. This means, you can read your mail with any Mail application, but the mail stays on the server. So when you log in the web inerface the next time, all your mail is still there and all changes made in your mail application are reflected as well. So just set up your GMail account in your favorite mail application and make sure to use IMAP, not POP3. Many mail applications support to specify IMAP folders for Trash, Drafts, Send mails etc. Make sure to map them properly to your GMail folders. For outgoing mail, use the SMTP servers of your various mail providers. That way, the mail is no longer send via Google, but via the proper server, which looks much more professional especially for business mails.</p>
<h5>Conclusion</h5>
<p>In this article, I showed you how to set up GMail as your one and only mail inbox. Even sending mail with proper sender address works. All these features can be used without loosing any comfort of a proper desktop integration by using a mail client and the IMAP server. The only improvement would be support for SMTP servers in GMail.</p>
<p>You&#8217;re using a similar setup and have suggestions for me? Or you need some more details of my setup? Just leave a comment.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/04/using-gmail-as-one-and-only-inbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create RSS feeds with PHP</title>
		<link>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/</link>
		<comments>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 21:24:05 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=138</guid>
		<description><![CDATA[RSS is a format for publishing frequently changing content like news, a list of blog posts or directories. Using RSS readers like Google Reader or Apple Mail, you can read all your daily information at one place, offering a much better overview and faster processing...]]></description>
			<content:encoded><![CDATA[<p>RSS is a format for publishing frequently changing content like news, a list of blog posts or directories. Using RSS readers like Google Reader or Apple Mail, you can read all your daily information at one place, offering a much better overview and faster processing than visiting every single website.</p>
<p>An RSS feed from the technical point of view is nothing more than a specially formatted XML document. It contains a general feed description as well as a headline, a link to the source and the content or an excerpt for every item. In this arcticle, I will show you how to create your own feed using PHP.</p>
<p><span id="more-138"></span></p>
<p>First of all, we set up the <strong>header information</strong> to specify that it is an XML document.</p>
<pre class="brush: php">&lt;?
header("Content-Type: text/xml; charset=utf-8");
print "&lt;?xml version=\"1.0\" ?&gt;\n";
?&gt;</pre>
<p>Then we add <strong>general feed information</strong> like the feed&#8217;s name, its description and the source URL.</p>
<pre class="brush: xml;first-line: 5">&lt;rss version="2.0"&gt;
&lt;channel&gt;

&lt;title&gt;Feed's title&lt;/title&gt;
&lt;description&gt;My site's cool feed&lt;/description&gt;
&lt;link&gt;http://www.my-site.com&lt;/link&gt;</pre>
<p>Now the real work begins. We need to get the necessary information for every item to be published. This could mean simply selecting information from a database, but also parsing XML or HTML files and gathering the information we need. It all depends on the datasource. When looping over every single item of our information, I assume we fill the variables <em>$item</em>, <em>$content</em> and <em>$link</em>, containing what the name suggests. We print the following block for every step of the loop.</p>
<pre class="brush: php;first-line: 35">&lt;item&gt;
  &lt;title&gt;&lt;?= $title ?&gt;&lt;/title&gt;
  &lt;description&gt;&lt;?= $content ?&gt;&lt;/description&gt;
  &lt;link&gt;&lt;?= $link ?&gt;&lt;/link&gt;
&lt;/item&gt;</pre>
<p>Finally, we close the opened tags.</p>
<pre class="brush: xml;first-line: 46">&lt;/channel&gt;
&lt;/rss&gt;</pre>
<p>That&#8217;s pretty much all you need to set up your own feed. But there are some pitfalls I discovered when creating my first feed. Because we&#8217;re working with XML documents, we have to convert special characters like &lt; and &gt; to &amp;lt; and &amp;gt;. This can be archieved by using PHP&#8217;s  <strong>htmlspecialchars</strong> funtion. However, I had to use it <em>twice</em> for a proper display in Google Reader. I would have expected Google to escape the content properly, but looks like they just pass the output to the frontend.</p>
<p>Now I wish you a lot of fun creating your own feed. If you need some information on how to parse HTML files with PHP and create  an RSS feed from almost any website, just leave a comment and I will provide some examples.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easy file sharing using dropbox</title>
		<link>http://www.maclovin.de/2009/03/easy-file-sharing-using-dropbox/</link>
		<comments>http://www.maclovin.de/2009/03/easy-file-sharing-using-dropbox/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 10:50:40 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=89</guid>
		<description><![CDATA[Dropbox is an easy way to synchronise your files across computers. First of all, it offers a web based interface where you upload files and store them in your account. Additionally you can install client software on Mac OS X, Linux or Windows, that creates a...]]></description>
			<content:encoded><![CDATA[<p><a title="Dropbox" href="http://getdropbox.com" target="_blank">Dropbox</a> is an easy way to synchronise your files across computers. First of all, it offers a web based interface where you upload files and store them in your account. Additionally you can install client software on Mac OS X, Linux or Windows, that creates a special dropbox folder on your computer. As soon as you copy a file into that folder, it gets automatically synced with your web account or if you upload something from another PC (other PC or OS, but same account) or via web, it magically appears in your local dropbox folder.</p>
<p style="text-align: center;"><a href="http://www.maclovin.de/wp-content/uploads/2009/03/dropbox_folder.png" rel="lightbox[89]" title="Dropbox folder"><img class="size-medium wp-image-96 aligncenter" title="Dropbox folder" src="http://www.maclovin.de/wp-content/uploads/2009/03/dropbox_folder-300x236.png" alt="Dropbox folder" width="300" height="236" /></a></p>
<p>Imagine you&#8217;re at work an realise that you need some files at home. No problem at all, just log in at dropbox&#8217;s web interface, upload the data. At home, dropbox automatically downloads it to your local folder. Could it be any easier? </p>
<p>You might say now, you don&#8217;t need it at all because you always keep an USB stick in your pocket just in case of emergency. And that&#8217;s not only faster but also does not need an Internet connection. Well, keep reading! It gets even better.</p>
<p><span id="more-89"></span></p>
<p>Using dropbox, you can easily share files with other people like friends or family. There are 2 prossibilities. Your dropbox folder has a special folder named <em>Public</em>. Anything that goes in there can be shared with other people. Just right-click on the file and select <em>Dropbox - </em><em>Copy public link</em>. As the name suggests, <em> </em>a link is copied to your clipboard heading to the file. Anybody can access the file via that link, even without being a dropbox user at all.</p>
<p>If you often share file with the same people, always copying public link is annoying. Luckily, there&#8217;s a second possibility. Just create a new directory somewhere in you local dropbox folder, right-click on it an select <em>Dropbox &#8211; Share</em>. You&#8217;re headed to a website where you enter mail addresses of other dropbox users. After accepting your invitation, the folder appears in their dopbox as well. Anybody in that group can add or remove content and changes are immediately reflected in all the other user&#8217;s dropboxes. How cool is that.</p>
<p>People quite often ask me for help with their computer problems. Dropbox in combination with <a title="Skitch" href="http://plasq.com/skitch" target="_blank">Sktich</a> makes this a lot easier. If you want them to have a screenshot, just fire up skitch, take the screenshot and drag it in the shared dropbox folder.</p>
<p>If you&#8217;re not yet a dropbox user, create an account right now! It&#8217;s easy and it&#8217;s free. It would be very nice if you would use <a title="Get dropbox" href="https://www.getdropbox.com/referrals/NTI2NDAzNDk" target="_blank">this link</a> for registration, containing a referral that offers extra 250MB for both of us. Now happy dropboxing.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/03/easy-file-sharing-using-dropbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add book price comparison to Amazon</title>
		<link>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/</link>
		<comments>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 21:27:02 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=17</guid>
		<description><![CDATA[I wrote a small Greasemonkey-Script, that adds links to the most famous German book price comparisons to the Amazon website. Greasemonkey is a Firefox-Addon providing the possibility to customize web-pages using Javascript and DOM. The script I wrote is based on the Amazon Linky script...]]></description>
			<content:encoded><![CDATA[<p>I wrote a small Greasemonkey-Script, that adds links to the most famous German book price comparisons to the Amazon website.</p>
<p style="text-align: center;"><a rel="lightbox" href="http://www.maclovin.de/wp-content/uploads/2008/08/buchpreis.png" title="Amazon bookprice comparison"><img class="size-medium wp-image-27 aligncenter" title="Amazon bookprice comparison" src="http://www.maclovin.de/wp-content/uploads/2008/08/buchpreis-300x182.png" alt="" width="300" height="182" /></a></p>
<p><a title="Greasemonkey" href="http://www.greasespot.net/"><span id="more-17"></span>Greasemonkey</a> is a Firefox-Addon providing the possibility to customize web-pages using Javascript and DOM. The script I wrote is based on the <a title="Amazon Linky" href="http://userscripts.org/scripts/show/1058">Amazon Linky script</a> and performs the following tasks on every page at amazon (tested on amazon.de, but should work with other TLDs as well):</p>
<ol>
<li>Parse the page and try to find the ISBN number</li>
<li>Abort processing if none was found. That&#8217;s the case if you are not looking at product details but e.g. search results or the product shown is not a book.</li>
<li>Search for the tag at the position where links should be added (under the &#8220;used &amp; new&#8221; link)</li>
<li>Create the links to the search engines</li>
<li>Insert the new tags into the page</li>
</ol>
<p>Most of the steps should be quite self-explanatory when looking at the script&#8217;s source code. The most difficult part is setting up the URLs to the search engines. I got them by visiting the book price comparison and performing a search for the ISBN number of an arbitrary book. Then on the result page, I had a closer look at the address bar. If you&#8217;re lucky then the ISBN number entered appears somewhere in the URL. Just try to search for another book by exchanging the ISBN in the URL with another one. If that works (and it does most of the time), you&#8217;re ready to go.</p>
<p>Edit the script&#8217;s source and use one of the already existing engines as template. Paste your URL as href-attribute in it and adjust it to read the ISBN number from the variable &#8220;isbn&#8221;.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2008/08/amazon_buchpreis.user.js">amazon_buchpreis.user.js</a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
