<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>daniel&#039;s devel blog</title>
	<atom:link href="http://danielkaes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielkaes.wordpress.com</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Mon, 22 Apr 2013 05:40:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='danielkaes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>daniel&#039;s devel blog</title>
		<link>http://danielkaes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://danielkaes.wordpress.com/osd.xml" title="daniel&#039;s devel blog" />
	<atom:link rel='hub' href='http://danielkaes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Functional Programming Principles in Scala</title>
		<link>http://danielkaes.wordpress.com/2013/03/03/functional-programming-principles-in-scala/</link>
		<comments>http://danielkaes.wordpress.com/2013/03/03/functional-programming-principles-in-scala/#comments</comments>
		<pubDate>Sun, 03 Mar 2013 12:44:58 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=354</guid>
		<description><![CDATA[For everyone who is interested in having a closer look at Scala and functional programming: Martin Odersky, the author of this programming language, is giving an introduction into the Scala on coursera. It will be a seven week long, free online class with weekly home-work assignments and a certificate at the end. You can signup [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=354&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>For everyone who is interested in having a closer look at Scala and functional programming:</p>
<p>Martin Odersky, the author of this programming language, is giving an introduction into the Scala on coursera. It will be a seven week long, free online class with weekly home-work assignments and a certificate at the end.</p>
<p>You can signup <a href="https://www.coursera.org/course/progfun">here</a>.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='560' height='315' src='http://www.youtube.com/embed/_NVySmdAH4c?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=354&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2013/03/03/functional-programming-principles-in-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Authentication Provider in Spring</title>
		<link>http://danielkaes.wordpress.com/2013/02/20/custom-authentication-provider-in-spring/</link>
		<comments>http://danielkaes.wordpress.com/2013/02/20/custom-authentication-provider-in-spring/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 23:05:47 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=343</guid>
		<description><![CDATA[The Spring Security module supports by default some standard ways to retrieve user information for authentication from databases, LDAP or other commonly used storages. But unfortunately the Spring documentation does not say much about creating connections to custom data sources. There are actually several different ways to do it. But let&#8217;s say we have a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=343&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The Spring Security module supports by default some standard ways to retrieve user information for authentication from databases, LDAP or other commonly used storages. But unfortunately the Spring documentation does not say much about creating connections to custom data sources. There are actually <a href="http://static.springsource.org/spring-security/site/docs/3.2.x/reference/ns-config.html#ns-auth-providers">several different ways</a> to do it.</p>
<p>But let&#8217;s say we have a Spring MVC application with a login form which contains a user name and password field, but the application does not use any of the supported methods to store the user data. How can we authenticate the user anyway?</p>
<p>The easiest way in my opinion is to create a new authentication provider. So we simply need to implement the <em>AuthenticationProvider</em> interface.</p>
<p>The <em>authenticate()</em> function of the class must return an <em>UsernamePasswordAuthenticationToken</em> instance if the authentication is successful or null otherwise. You can choose another token, simple check the classes implementing <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/AbstractAuthenticationToken.html">AbstractAuthenticationToken</a>. But for our scenario this should be enough.</p>
<p>It is important to populate the list of authorities we grant the user. I used the standard user role (&#8220;ROLE_USER&#8221;).</p>
<p>In the real-world you might want to add a member variable to the authentication provider pointing to a bean which contains the code for authenticating an user, here I just hard-coded it (name must be &#8220;admin&#8221;, password &#8220;system&#8221;).</p>
<pre class="brush: java; title: ; notranslate">
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {

	@Override
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
		String name = authentication.getName();
		String password = authentication.getCredentials().toString();
		if (name.equals(&quot;admin&quot;) &amp;&amp; password.equals(&quot;system&quot;)) {
			List&lt;GrantedAuthority&gt; grantedAuths = new ArrayList&lt;&gt;();
			grantedAuths.add(new SimpleGrantedAuthority(&quot;ROLE_USER&quot;));
			Authentication auth = new UsernamePasswordAuthenticationToken(name, password, grantedAuths);
			return auth;
		} else {
			return null;
		}
	}

	@Override
	public boolean supports(Class&lt;?&gt; authentication) {
		return authentication.equals(UsernamePasswordAuthenticationToken.class);
	}
}
</pre>
<p>Now we need to declare the new authentication provider in our configuration:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;authentication-manager&gt;
	&lt;authentication-provider ref=&quot;customAuthenticationProvider&quot;/&gt;
&lt;/authentication-manager&gt;
</pre>
<p>And that&#8217;s it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=343&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2013/02/20/custom-authentication-provider-in-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Free MongoDB developer online class</title>
		<link>http://danielkaes.wordpress.com/2013/02/14/free-mongodb-developer-online-class/</link>
		<comments>http://danielkaes.wordpress.com/2013/02/14/free-mongodb-developer-online-class/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 21:23:52 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=270</guid>
		<description><![CDATA[During the past few years we saw a steady rise of NoSQL databases. While most of them are for very specialized scenarios there are a few multi-talents which can be a good replacement for a more traditional storage solution. One of the more well-known is MongoDB, a document-oriented, schemaless database, which I started to like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=270&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>During the past few years we saw a steady rise of NoSQL databases. While most of them are for very specialized scenarios there are a few multi-talents which can be a good replacement for a more traditional storage solution.</p>
<p>One of the more well-known is MongoDB, a document-oriented, schemaless database, which I started to like very much. MongoDB is easy to set up and allows me to store objects into the database right away, without thinking about table layout and hacking SQL installation scripts. Of course it also has its downsides, but later more on it.</p>
<p>Currently I take an online class on MongoDB for developers, which is provided by the makers of the database at 10gen.com for free. The online class consists of a couple of video lectures and regular home work assignments. After seven weeks the class will end with a final programming project and of course a 10gen MongoDB developer certificate.</p>
<p>The homework is easy and the course is progressing with a slow pace which is ideal if you cannot or don&#8217;t want to spend to much time on it.</p>
<p>I don&#8217;t think you can join the current class, but at the end of February (25th) a new course starts:</p>
<p><a href="https://education.10gen.com/courses" target="_blank">&#8220;M101J MongoDB for Java Developers&#8221;</a></p>
<p>So if you are interested in taking a closer look, then join the course. So far I like it. It gives a good introduction, talks not just about the programming API, but also about best practices in document design and performance tips. You will not be a professional mongo developer after the course, but I think it provides everything you need to start using MongoDB and is also a good starting point to dive deeper into the issue.</p>
<p> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/270/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=270&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2013/02/14/free-mongodb-developer-online-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>This blog is not dead &#8230;</title>
		<link>http://danielkaes.wordpress.com/2013/02/13/this-blog-is-not-dead/</link>
		<comments>http://danielkaes.wordpress.com/2013/02/13/this-blog-is-not-dead/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 23:48:42 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=263</guid>
		<description><![CDATA[&#8230; it just slept for a long while. But I am about to resurrect it. So stay tuned. I started this blog for making notes for myself, share code snippets and help fellow programmers who got stuck with similar problems. But the internet moved on during the past two years and there seem to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=263&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>&#8230; it just slept for a long while. But I am about to resurrect it. So stay tuned.</p>
<p>I started this blog for making notes for myself, share code snippets and help fellow programmers who got stuck with similar problems. But the internet moved on during the past two years and there seem to be dozens of web sites now which are probably better suited for doing all these tasks. Nevertheless I like blogs, they are much more personal than tweets and Gist code dumps. So I decided to continue sharing code, ideas and opinions &#8230; just don&#8217;t expect me to be as frequent as two years ago ;-)</p>
<p>Before this post becomes completely useless, here is a small brain teaser for our Javascript ninjas out there:</p>
<p>What is the following expression evaluating to?</p>
<pre class="brush: jscript; title: ; notranslate">
&quot;3&quot; -+-+-+ &quot;1&quot; + &quot;1&quot; / &quot;3&quot; * &quot;6&quot; + &quot;2&quot;
</pre>
<p>The answer and in depth explanation can be found on <a href="http://wtfjs.com/2011/11/11/the-universe-answers-and-JavaScript-still-makes-us-wtf" target="_blank">wtfjs.com</a> which makes me regularly laugh and cry.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=263&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2013/02/13/this-blog-is-not-dead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Multi-Threaded Application in Haskell</title>
		<link>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/</link>
		<comments>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 21:42:01 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=247</guid>
		<description><![CDATA[Haskell has a powerful concurrency library which is surprisingly easy to use. The Control.Concurrent library is shipped with the standard installation of ghc and provides everything needed to get started. As a small test I want to write a programme which reads numbers from stdin, spawns a new process to calculate the Fibonacci number for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=247&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Haskell has a powerful concurrency library which is surprisingly easy to use. The <a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent.html">Control.Concurrent</a> library is shipped with the standard installation of ghc and provides everything needed to get started.</p>
<p>As a small test I want to write a programme which reads numbers from stdin, spawns a new process to calculate the Fibonacci number for each input on a different CPU and prints the result to stdout.</p>
<p>First we need a function which is called when spawning a new process, which should calculate the result and print it to the console. In my case this is a simple IO Monad, which gets a MVar as it&#8217;s first argument. The function will wait for input from the MVar and then call the Fibonacci function.</p>
<p>This <a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent-MVar.html">MVar</a> can be thought of as a synchronised box where a thread can store a value and another thread can read from it. So MVars are just the poor men&#8217;s message channel which can hold one value at the time only. Of course there are also real channels in Haskell which act like the message queues in Scala or Erlang, see Control.Concurrent.Chan for more informations.</p>
<pre class="brush: plain; title: ; notranslate">
printResult mvar =  do
	value &lt;- takeMVar mvar
	print $ &quot;fib(&quot; ++ show value ++ &quot;)=&quot; ++ show (fib value)

fib 0 = 0
fib 1 = 1
fib n =  fib (n - 1) + fib (n - 2)
</pre>
<p>Now we need to read the input from stdin, create a MVar object and invoke the printResult function. The cool thing about Haskell is the forkIO function which is really convenient. It takes an arbitrary IO expr and invokes it in a new thread:</p>
<pre class="brush: plain; title: ; notranslate">
import Control.Monad -- needed for &quot;forever&quot;
import System.Exit     -- needed for exitSuccess

main = forever $ do
	line &lt;- getLine
	when (line == &quot;quit&quot;) exitSuccess
	mvar &lt;- newEmptyMVar
	forkIO $ printResult mvar
	putMVar mvar (read line :: Integer)
</pre>
<p>Now we have to compile our programme with the &#8220;-threaded&#8221; flag:</p>
<pre class="brush: bash; title: ; notranslate">ghc -threaded fib.hs -o fib</pre>
<p>The RTS allows us now to define the number of processors the application runs on with the -N<em>num</em> flag. If I want to use three processors for parallelisation I can run the programme simply with: </p>
<pre class="brush: bash; title: ; notranslate">./fib +RTS -N4</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=247&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing A Synthesizer With Brainfuck</title>
		<link>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/</link>
		<comments>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 20:57:57 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[brainfuck]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=244</guid>
		<description><![CDATA[Brainfuck is a small esoteric programming language which comes with just eight commands and Turing completeness (given enough time or memory). And that is just enough to write a small synthesizer in it. Some people have definitely too much time ;-)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=244&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a> is a small esoteric programming language which comes with just eight commands and Turing completeness (given enough time or memory). And that is just enough <a href="http://probablyprogramming.com/2009/08/06/a-brainfuck-synthesizer/">to write a small synthesizer in it</a>. Some people have definitely too much time ;-)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/244/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=244&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Easter Eggs in Open Source Software</title>
		<link>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/</link>
		<comments>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 11:52:49 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=240</guid>
		<description><![CDATA[Some programmers definitely have to much time, see this link to an arstechnica article: Cracking open five of the best open source easter eggs<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=240&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Some programmers definitely have to much time, see this link to an arstechnica article:</p>
<p><a href="http://arstechnica.com/open-source/news/2010/03/cracking-open-five-of-the-best-open-source-easter-eggs.ars">Cracking open five of the best open source easter eggs</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=240&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Reinventing Human-Computer Interaction</title>
		<link>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/</link>
		<comments>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 19:29:07 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=233</guid>
		<description><![CDATA[Many of you probably remember &#8220;Minority Report&#8221;, a mediocre science fiction film inspired by a short story of good old Philip K. Dick. The only thing I really remember well about this movie is the huge multi-touch computer used by the police force (or something). Although such sci-fi devices look great they are a total [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=233&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Many of you probably remember &#8220;Minority Report&#8221;, a mediocre science fiction film inspired by a short story of good old Philip K. Dick. The only thing I really remember well about this movie is the huge multi-touch computer used by the police force (or something). Although such sci-fi devices look great they are a total nightmare for every day use. Just imagine you have to lift your arms every time you try to switch to another tab page of your browser. That is not really a solution. But how can we use awesome looking multi-touch devices in combination with our other hardware? Here is a small video which came up with some cool and fresh ideas:</p>
<p><a href='http://vimeo.com/6712657'>reinventing desktop human-computer interaction: <strong>10/GUI</strong></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=233&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Java &amp; Multicore</title>
		<link>http://danielkaes.wordpress.com/2010/02/15/java-multicore/</link>
		<comments>http://danielkaes.wordpress.com/2010/02/15/java-multicore/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 21:54:47 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=220</guid>
		<description><![CDATA[Recently I needed to run some very CPU intensive calculations in Java. In order to harvest the full power of my multicore machine I took a look at Java&#8217;s concurrent package. I never used this package before. Either I had some convenient third party library functions at my hand which successfully were able to hide [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=220&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently I needed to run some very CPU intensive calculations in Java. In order to harvest the full power of my multicore machine I took a look at Java&#8217;s concurrent package. I never used this package before. Either I had some convenient third party library functions at my hand which successfully were able to hide all the multithreading stuff from me, sometimes I struggled with Thread, Runnable and synchronized statements or &#8230; I just used another language :P</p>
<p>So here are my results from a short trip into the adventurous realm of multicore programming in Java. To make things a little bit simpler in this post I will demonstrate to run several functions calculating a high Fibonacci number instead of using a more complicated real world example. The calculations will be distributed via a thread pool and all classes used in this example belong to the Java standard library, so there won&#8217;t be a need to install any extra packages.</p>
<p><span id="more-220"></span></p>
<p>The first thing we will need is a class implementing the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Callable.html">java.util.concurrent.Callable</a> interface in which <em>fib(int n)</em> will be a static function returning an integer:</p>
<pre class="brush: java; title: ; notranslate">
class FibTask implements Callable&lt;Integer&gt; {
  private int n;
  public FibTask(int n) {
    this.n = n;
  }

  @Override
  public Integer call() throws Exception {
    return fib(this.n);
  }
}
</pre>
<p>Before we start to build our thread pool we can retrieve the amount of CPUs/cores of our system from the Java runtime:</p>
<pre class="brush: java; title: ; notranslate">
int cpus = Runtime.getRuntime().availableProcessors();
</pre>
<p>OK, so the next step is building a thread pool. If you are looking for a pool with specific parameters and behaviour you can build one by using the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html">ThreadPoolExecutor</a> class. But luckily the concurrent package already offers a nice short cut to create a pool with a fixed size:</p>
<pre class="brush: java; title: ; notranslate">
ExecutorService pool = Executors.newFixedThreadPool(cpus);
</pre>
<p>To execute functions in the pool you can either use it&#8217;s <em>execute</em> method or even more convenient: <em>invokeAll</em>. This method takes a list of tasks which have to implement the <em>Callable</em> interface executes them and returns a list of <em>Future</em> objects which hold the results of the <em>Callable</em> objects. The cool thing about <em>invokeAll</em> is it makes sure all tasks are executed before returning anything. So for all elements in the returned list <em>Future.isDone()</em> will be true:</p>
<pre class="brush: java; title: ; notranslate">
List&lt;FibTask&gt; tasks = new ArrayList&lt;FibTask&gt;();			
for (int i = 0; i &lt; cpus; i++) {
  tasks.add(new FibTask(45));
}			
List&lt;Future&lt;Integer&gt;&gt; results = pool.invokeAll(tasks);
</pre>
<p>The results list holds the <em>Future</em> values now. If the pool is no longer needed, it should be closed properly by calling it&#8217;s <em>shutdown()</em> method. Before we can retrieve and print out the results we need to check for any errors occurred during the calculation:</p>
<pre class="brush: java; title: ; notranslate">
for (Future&lt;Integer&gt; result : results) {
  if (result.isCancelled()) {
    System.err.println(&quot;Life is a bitch&quot;);
  } else {
    try {
      System.out.println(&quot;result: &quot; + result.get());
    } catch (ExecutionException e) {
      System.out.println(e.getCause());
    }
  }
}
</pre>
<p>And this is all you need to run your code on multiple cores. Couldn&#8217;t be easier!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=220&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/02/15/java-multicore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Struggling with HTML or How To Use Vertical And Horizontal Alignment In CSS</title>
		<link>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/</link>
		<comments>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 19:08:39 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=197</guid>
		<description><![CDATA[HTML wasn&#8217;t invented to write interactive, application-like web pages, it just offers a convenient way to create really simple documents containing links. Maybe that&#8217;s why programming web pages nowadays feels a little bit like writing a GUI in LaTeX. But maybe I am just complaining because I am not used to it &#8230; I am [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=197&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>HTML wasn&#8217;t invented to write interactive, application-like web pages, it just offers a convenient way to create really simple documents containing links. Maybe that&#8217;s why programming web pages nowadays feels a little bit like writing a GUI in LaTeX. But maybe I am just complaining because I am not used to it &#8230; I am a software developer, not a web designer.</p>
<p><span id="more-197"></span></p>
<p>Hopefully HTML5 will make everything a little bit simpler. Anyway &#8230; I just want to create a simple box containing text centred in the middle of it. This box will be used as a button on a website. So what I need is to specify vertical and horizontal alignments. The horizontal alignment attribute is called &#8220;text-align&#8221; which I guess is a relict from the good old days when people where used to browse hyper<strong>text</strong> documents. But to put the text in the centre of the box I had to shoot myself into the foot &#8230; twice!</p>
<p>First I needed to create a table with one row and one entry and then I was able to <del datetime="2010-01-28T18:26:39+00:00">use</del> misuse the table alignment options to centre the text vertically with an attribute called &#8220;vertical-align&#8221;. Why is there no &#8220;horizontal-align&#8221;? I don&#8217;t know. Why do I have to use a table? I don&#8217;t know. Don&#8217;t ask questions when writing CSS/HTML code. Never!</p>
<p>Here is the result:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;

&lt;div style=&quot;background-color:grey;width:10%;height:10%;position:absolute;top:10%;left:40%&quot;&gt;
  &lt;table style=&quot;width:100%;height:100%&quot;&gt;
    &lt;tr&gt;&lt;td style=&quot;vertical-align:middle;text-align:center&quot;&gt;
      This is a test
    &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
&lt;/div&gt;

&lt;/body&gt;&lt;/html&gt;
</pre>
<p>Hooray! Please don&#8217;t ask me how long I needed to figure this out :/<br />
I wonder if there is a more elegant solution &#8230; </p>
<p>The style of the div element can be used to define the box, Mozilla&#8217;s Gecko engine supports some really cool CSS features like round edges, shadows and gradients (in the case of Firefox 3.6). But of course it won&#8217;t work with other browsers, it would be to easy if just everyone could write CSS/HTML code without studying computer science first. However, if you have Firefox just look and be amazed of my mighty text box:</p>
<div style="background-color:rgb(230,230,230);width:100px;height:100px;-moz-border-radius:3px;-moz-box-shadow:grey 5px 2px 2px;">
<table style="width:100%;height:100%;">
<tr>
<td style="vertical-align:middle;text-align:center;">
      This is a test
    </td>
</tr>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&#038;blog=6944510&#038;post=197&#038;subd=danielkaes&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
	</channel>
</rss>
