<?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>ITworks &#187; fun</title>
	<atom:link href="http://itworks.hu/tag/fun/feed/" rel="self" type="application/rss+xml" />
	<link>http://itworks.hu</link>
	<description>Random musings in IT</description>
	<lastBuildDate>Mon, 09 Jan 2012 08:01:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Regexp fun</title>
		<link>http://itworks.hu/2009/11/25/regexp-fun/</link>
		<comments>http://itworks.hu/2009/11/25/regexp-fun/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 21:57:31 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=95</guid>
		<description><![CDATA[Reading the post about useful regular expressions,  remembered what my favourite solution is to one of  the questions of the test we give to junior Java developers. The task is to write a method that takes a string as a &#8230; <a href="http://itworks.hu/2009/11/25/regexp-fun/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Reading the post about<a href="http://www.mkyong.com/regular-expressions/10-java-regular-expression-examples-you-should-know/"> useful regular expressions</a>,  remembered what my favourite solution is to one of  the questions of the test we give to junior Java developers.</p>
<p>The task is to write a method that takes a string as a parameter and returns the acronym of the string in uppercase made up of the first letters of the words in the string. The acronym must ignore the words &#8220;the&#8221;, &#8220;of&#8221; and &#8220;and&#8221;.</p>
<p>The usual solutions are either to sequentially step through the string (Yuck!) or split it up or use a StringTokenizer class. The people usually overlook the fact, that the input strings can be padded with whitespace, or contain multiple spaces, and they usually ignore, that the keywords that are to be omitted might be found on the begining of a valid word. Thus my test &#8221; United   States of Andorra&#8221; string breaks most of the methods.  The ones who have time to write the answer down, usually forget to return the value from the method, or to change it to uppercase and sometimes even ignore that it should be a method to start with! This is my favourite question, as it can really show how the applicant can handle stressful situations.</p>
<p>I was tired after several interviews one day and tried to come up with the  shortest possible solution. Naturally it contains regular expressions.</p>
<p>My solution looked  something like this (OK I just reproduced it for the sake of the article, using nano and javac, so it might have overlooked flaws in it):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Acronym <span style="color: #009900;">&#123;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> toAcronym<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> str.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.
                        <span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(THE|OF|AND)(<span style="color: #000099; font-weight: bold;">\\</span>W+|$)&quot;</span>,<span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.
                        <span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(<span style="color: #000099; font-weight: bold;">\\</span>w)<span style="color: #000099; font-weight: bold;">\\</span>w*<span style="color: #000099; font-weight: bold;">\\</span>W*&quot;</span>,<span style="color: #0000ff;">&quot;$1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">length</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>toAcronym<span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</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: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/11/25/regexp-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Worst way to apply for a job.</title>
		<link>http://itworks.hu/2007/09/24/worst-way-to-apply-for-a-job/</link>
		<comments>http://itworks.hu/2007/09/24/worst-way-to-apply-for-a-job/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 11:21:12 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[annoyance]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=20</guid>
		<description><![CDATA[We are continously looking for Java developers for our company. We&#8217;ve recently received a job application which is even more ridiculous thant the others. Tisztelt HR Manager! Láttam állásajánlatukat, elolvastam a reklámszövegüket weblapon. 6 éve J2SE alkalmazásokat fejlesztek és egy &#8230; <a href="http://itworks.hu/2007/09/24/worst-way-to-apply-for-a-job/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We are continously looking for Java developers for our company. We&#8217;ve recently received a job application which is even more ridiculous thant the others.</p>
<p><span id="more-20"></span></p>
<blockquote><p>Tisztelt HR Manager!</p>
<p>Láttam állásajánlatukat, elolvastam a reklámszövegüket  weblapon.<br />
6 éve J2SE alkalmazásokat fejlesztek és egy kicsit unom, ezért a tavasszal J2EE be is belekóstoltam, pont a Websphere-el.</p>
<p>CV-t nem küldenék egyelőre, mivel önöknek is van elég CV -jük mástól én meg küldtem eleget másova.</p>
<p>Arra lennék kíváncsi,  hogy egy  ledolgozott  hónap után mennyit  tudnék én hazavinni, ha az önök cégénél dolgoznék. kezdetben mennyi lenne és 1 év után mennyi lenne? Mennyi időközönként igazítják a fizetést a nyújtott teljesítményhez?</p>
<p>Tisztelettel:<br />
MXXXé SXXXXXXs</p></blockquote>
<blockquote><p>Dear HR Manager!</p>
<p>I&#8217;ve seen your job ad and read your banner on the   website.<br />
I&#8217;m developing J2SE applications for over 6 years and a bit bored with it, so I&#8217;ve gave J2EE a try, with Websphere.</p>
<p>I would not send my CV for now, as I&#8217;m sure you have enough CVs from other people and I&#8217;ve sent enough of mine to others.</p>
<p>I would be interested in how much I could take home after a month of work if I worked at your company. how much in the begining and how much after a year. What periodicity do you use to match the wage to the actual performance?</p>
<p>Best regards:<br />
MXXXé SXXXXXXs</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/09/24/worst-way-to-apply-for-a-job/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Parable of the Object Oriented Programmer and Breakfast</title>
		<link>http://itworks.hu/2007/06/15/the-parable-of-the-object-oriented-programmer-and-breakfast/</link>
		<comments>http://itworks.hu/2007/06/15/the-parable-of-the-object-oriented-programmer-and-breakfast/#comments</comments>
		<pubDate>Fri, 15 Jun 2007 11:00:12 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=16</guid>
		<description><![CDATA[This is the English version of a tale I&#8217;ve recently found in my archive mailbox from 2001. Looking at ongoing projects, I think it still has a point. Once upon a time, in a kingdom not far from here, a &#8230; <a href="http://itworks.hu/2007/06/15/the-parable-of-the-object-oriented-programmer-and-breakfast/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is the English version of a tale I&#8217;ve recently found in my archive mailbox from 2001. Looking at ongoing projects, I think it still has a point.</p>
<blockquote><p>Once upon a time, in a kingdom not far from here, a king summoned two of his advisors for a test. He showed them both a shiny metal box with two slots in the top, a control knob, and a lever. &#8220;<em>What do you think this is?</em>&#8221;<br />
<span id="more-16"></span></p>
<p>One advisor, an engineer, answered first. &#8220;<em>It is a toaster,</em>&#8221; he said. The king asked, &#8220;<em>How would you design an embedded computer for it?</em>&#8221; The engineer replied, &#8220;<em>Using a four-bit microcontroller, I would write a simple program that reads the darkness knob and quantizes its position to one of 16 shades of darkness, from snow white to coal black. The program would use that darkness level as the index to a 16-element table of initial timer values. Then it would turn on the heating elements and start the timer with the initial value selected from the table. At the end of the time delay, it would turn off the heat and pop up the toast. Come back next week, and I&#8217;ll show you a working prototype.</em>&#8221;</p>
<p>The second advisor, a Java developer, highly skilled in object oriented design, immediately recognized the danger of such short-sighted thinking. He said, &#8220;<em>Toasters don&#8217;t just turn bread into toast, they are also used to warm frozen waffles. What you see before you is really a breakfast food cooker. As the subjects of your kingdom become more sophisticated, they will demand more capabilities. They will need a breakfast food cooker that can also cook sausage, fry bacon, and make scrambled eggs. A toaster that only makes toast will soon be obsolete. If we don&#8217;t look to the future, we will have to completely redesign the toaster in just a few years.</em>&#8221;</p>
<p>&#8220;<em>With this in mind, we can formulate a more intelligent solution to the problem. First, create a class of breakfast foods. Specialize this class into subclasses: grains, pork, and poultry. The specialization process should be repeated with grains divided into toast, muffins, pancakes, and waffles; pork divided into sausage, links, and bacon; and poultry divided into scrambled eggs, hard-boiled eggs, poached eggs, fried eggs, and various omelet classes.</em>&#8221;</p>
<p>&#8220;<em>The ham and cheese omelet class is worth special attention because it must inherit characteristics from the pork, dairy, and poultry classes. Thus, we see that the problem cannot be properly solved without multiple inheritance. At run time, the program must create the proper object and send a message to the object that says, &#8220;<code>Cook yourself.</code>&#8221; The semantics of this message depend, of course, on the kind of object, so they have a different meaning to a piece of toast than to scrambled eggs.</em>&#8221;</p>
<p>&#8220;<em>Reviewing the process so far, we see that the analysis phase has revealed that the primary requirement is to cook any kind of breakfast food. In the design phase, we have discovered some derived requirements. Specifically, we need an object-oriented language with multiple inheritance. Of course, users don&#8217;t want the eggs to get cold while the bacon is frying, so concurrent processing is required, too.</em>&#8221;</p>
<p>&#8220;<em>We must not forget the user interface. The lever that lowers the food lacks versatility, and the darkness knob is confusing. Users won&#8217;t buy the product unless it has a user-friendly, graphical interface. When the breakfast cooker is plugged in, users should see a cowboy boot on the screen. Users click on it, and the message &#8220;<code>Booting Application Breakfast v1.2</code>&#8221; appears on the screen. (Breakfast v1.2 should be out by the time the product gets to the market.) Users can pull down a menu and click on the foods they want to cook.</em>&#8221;</p>
<p>&#8220;<em>Having made the wise decision of specifying the software first in the design phase, all that remains is to pick an adequate hardware platform for the implementation phase. An Intel Pentium 1.86GHz with 1.2GB of memory, a 220GB hard disk, and a TFT monitor should be sufficient. Selecting a multitasking, object oriented language that supports multiple inheritance and has a built-in GUI, means writing the program will be a snap. (Imagine the difficulty we would have had if we had foolishly allowed a hardware-first design strategy to lock us into a four-bit microcontroller!).</em>&#8221;</p>
<p>The king had the computer scientist thrown in the moat, and they all lived happily ever after.</p></blockquote>
<p>NB. The story mentions a Java developer and thus provides a valuable insight: Java coders are lazy and provide specs they don&#8217;t have to develop when possible. This is why the multiple inheritance was suggested, instead of AOP.<br />
Actually the story is way older than Java, and in those times developers actually knew languages and didn&#8217;t try to design everything so it can be solved in their language of choice. <img src='http://itworks.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/06/15/the-parable-of-the-object-oriented-programmer-and-breakfast/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How not to use Java key stores</title>
		<link>http://itworks.hu/2007/05/23/how-not-to-use-java-key-stores/</link>
		<comments>http://itworks.hu/2007/05/23/how-not-to-use-java-key-stores/#comments</comments>
		<pubDate>Wed, 23 May 2007 12:23:03 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=13</guid>
		<description><![CDATA[I spent half a day today trying to see why a the web start application created and deployed using a simple build script didn&#8217;t work after I&#8217;ve created a new certificate as our previous was about to expire. First I &#8230; <a href="http://itworks.hu/2007/05/23/how-not-to-use-java-key-stores/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I spent half a day today trying to see why a the web start application created and deployed using a simple build script didn&#8217;t work after I&#8217;ve created a new certificate as our previous was about to expire.</p>
<p>First I suspected it was because I signed the application using SUN JDK 1.6, and it might have some compatibility issues (as if) then I suspected it was the IBM JDK 1.5&#8242;s ikeytool I used to create the key (NB. I&#8217;m lazy to learn the keytool paramers, so I prefer to use a GUI for creating keys)</p>
<p>It turned out I was presuming the keys use UTF internally, like most Java applications should, so when entering the locality I used &#8220;Vác&#8221; with accented characters. Neither ikeytool, neither keytool warned me about this. Once creating a new key without the accent the application started working straight away.</p>
<p>Since &#8220;Budapest&#8221; doesn&#8217;t have any special characters, I never noticed this, but I think it deserves to be mentioned, so others won&#8217;t run into this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/05/23/how-not-to-use-java-key-stores/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIY Push-puppet toy</title>
		<link>http://itworks.hu/2007/05/10/diy-push-puppet-toy/</link>
		<comments>http://itworks.hu/2007/05/10/diy-push-puppet-toy/#comments</comments>
		<pubDate>Thu, 10 May 2007 07:39:09 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[toys]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=11</guid>
		<description><![CDATA[Remember the push-puppets you had when you were a kid? These little puppets collapse instantly when you push the button on the base they stand, providing hours of quality entertainment to kids like myself. Now it has returned from exile &#8230; <a href="http://itworks.hu/2007/05/10/diy-push-puppet-toy/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Remember the push-puppets you had when you were a kid? These little puppets collapse instantly when you push the button on the base they stand, providing hours of quality entertainment to kids like myself. Now it has returned from exile and is back grouped up with new technology to provide hours of entertainment to IT people like myself.<br />
<a href="http://itworks.hu/wp-content/uploads/2007/05/puppet_up.jpg" title="Puppet"><img src="http://itworks.hu/wp-content/uploads/2007/05/puppet_up.thumbnail.jpg" alt="Puppet" align="right" /></a></p>
<p>For the original concept see:<a href="http://schulzeandwebb.com/2006/availabot/">Availabot</a></p>
<p>For the cuter Linux version visit <a href="http://users.skynet.be/ppc/push_puppet_toy/">Push puppet toy</a></p>
<p>I can imagine my desk full of these puppets each representing a friend I usually talk to, these puppets would dance up and down all day depending on who&#8217;s leaving for lunch.</p>
<p>Also it would be great to have this extended to have an intermediary stage, ie. when the button is half pushed these puppets usually start letting their head down. So when the contact is not offline, but only away they could show how said they are to be away from their computer, and when they are offline they are completely splattered.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/05/10/diy-push-puppet-toy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The story behind a name..</title>
		<link>http://itworks.hu/2007/05/03/the-story-behind-a-name/</link>
		<comments>http://itworks.hu/2007/05/03/the-story-behind-a-name/#comments</comments>
		<pubDate>Thu, 03 May 2007 11:13:05 +0000</pubDate>
		<dc:creator>dyn</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[IT]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=7</guid>
		<description><![CDATA[I just came around the Winstone servlet container (related to the Hudson CI server). The project itself is fairly interesting, but it&#8217;s the naming choice which got me completely amazed.. Winstone is the name of a rather large Jamaican man &#8230; <a href="http://itworks.hu/2007/05/03/the-story-behind-a-name/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just came around the <a href="http://winstone.sourceforge.net/">Winstone</a> servlet container (related to the <a href="http://hudson.dev.java.net/">Hudson</a> CI server). The project itself is fairly interesting, but it&#8217;s the naming choice which got me completely amazed..</p>
<blockquote><p> Winstone is the name of a rather large Jamaican man a friend of mine met one night, while he was out clubbing in the Roppongi area of Tokyo. He (my friend) was a little liquored up at the time, and when Winstone suggested they head to &#8220;this really cool club&#8221; he knew, he didn&#8217;t think anything was wrong. It wasn&#8217;t until Winstone led him down a dark stairwell and dropped his trousers that my friend clued in and ran like hell.</p>
<p>It was too good a story to let die, so I named this project Winstone so that said friend will continue to be reminded of it.</p></blockquote>
<p>Now who claims java devs should get a life? <img src='http://itworks.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/05/03/the-story-behind-a-name/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

