<?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>Calyx blog</title>
	<atom:link href="http://blog.calyx.hr/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.calyx.hr</link>
	<description>Za razvoj softvera i zajebanciju</description>
	<lastBuildDate>Tue, 11 Oct 2011 11:23:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Professionalism in the Croatian National Bank</title>
		<link>http://blog.calyx.hr/?p=231</link>
		<comments>http://blog.calyx.hr/?p=231#comments</comments>
		<pubDate>Tue, 11 Oct 2011 11:21:20 +0000</pubDate>
		<dc:creator>asparagus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.calyx.hr/?p=231</guid>
		<description><![CDATA[Long time no rant So here we go, this time it&#8217;s about a &#8220;web application&#8221; used by the Croatian National Bank to collect balance of payments data. I won&#8217;t bother you with too many details, although there is a million details done wrong. The purpose of the &#8220;application&#8221; is to collect quarterly information about import&#38;export [...]]]></description>
			<content:encoded><![CDATA[<p>Long time no rant <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So here we go, this time it&#8217;s about a &#8220;web application&#8221; used by the Croatian National Bank to collect balance of payments data. I won&#8217;t bother you with too many details, although there is a million details done wrong.</p>
<p>The purpose of the &#8220;application&#8221; is to collect quarterly information about import&amp;export transactions. In a senseful environment, it would probably be implemented by a regular web application where companies would log in, enter some simple data (all the data is essentially key-value pairs like this: country,export/import) and hit the &#8220;submit&#8221; button. And probably get an email reminder when the report is due.</p>
<p>Now back to Croatian reality <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Upon registration, you get the username/password to access the portal. Then you download one XLS file (in the beginning, they supported Microsoft Excel only, of course). When all the relevant sheets of the XLS are filled in with transaction data, you press the big &#8220;generate TXT file&#8221; button.</p>
<p><a href="http://blog.calyx.hr/wp-content/uploads/2011/10/XLS_glavna.png"><img class="alignnone size-thumbnail wp-image-233" title="XLS main sheet" src="http://blog.calyx.hr/wp-content/uploads/2011/10/XLS_glavna-150x150.png" alt="" width="150" height="150" /></a></p>
<p>The magic starts in this moment. A macro command iterates all sheets, collects the data and /:drumroll:/ GENERATES A TXT FILE <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  At least it&#8217;s polite enough to point you where the file has been generated.</p>
<p>Then you go back to the web portal. Upload the TXT file, and hope for the best.</p>
<p>Besides the whole concept being broken, the actual implementation of the system is so amateurish you can hardly believe it comes from an institution so important. Have look at the official <a href="http://www.hnb.hr/propisi/odluke-platna-bilanca/usluge_u_platnoj_bilanci-uputa_za_rad_s_aplikacijom_za_dostavu_datoteka.pdf">User Guide</a>, and judge for yourself how serious this looks.</p>
<p>Anyway, if anyone from the Croatian National Bank gets to read this &#8211; Calyx would gladly do this for free, just to stop using this abomination.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=231</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PlivaZdravlje Android application</title>
		<link>http://blog.calyx.hr/?p=212</link>
		<comments>http://blog.calyx.hr/?p=212#comments</comments>
		<pubDate>Mon, 16 May 2011 07:50:18 +0000</pubDate>
		<dc:creator>igavran</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.calyx.hr/?p=212</guid>
		<description><![CDATA[We published our first application to the Android Market. The application has been developed for Pliva Hrvatska d.o.o. It is a fancy RSS reader that displays content available on the PlivaZdravlje web portal and lets the user browse it through categories. Both the application and the portal are in the Croatian language. Check it out]]></description>
			<content:encoded><![CDATA[<div><a href="http://blog.calyx.hr/wp-content/uploads/2011/05/RSS_PLIVAzdravlje.png"><img class="size-medium wp-image-213 alignleft" style="margin-left: 10px; margin-right: 10px;" title="PLIVAzdravlje" src="http://blog.calyx.hr/wp-content/uploads/2011/05/RSS_PLIVAzdravlje-300x300.png" alt="" width="108" height="108" /></a></div>
<div>We published our first application to the Android Market. The application has been developed for Pliva Hrvatska d.o.o. It is a fancy RSS reader that displays content available on the <a href="http://www.plivazdravlje.hr/">PlivaZdravlje</a> web portal and lets the user browse it through categories. Both the application and the portal are in the Croatian language.</div>
<div><a href="https://market.android.com/details?id=hr.calyx.plivazdravlje">Check it out</a></div>
<div style="text-align: center;"><a href="http://blog.calyx.hr/wp-content/uploads/2011/05/chart.png"><img class="size-full wp-image-214 aligncenter" title="chart" src="http://blog.calyx.hr/wp-content/uploads/2011/05/chart.png" alt="" width="230" height="230" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=212</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The pains of switching to Mercurial</title>
		<link>http://blog.calyx.hr/?p=167</link>
		<comments>http://blog.calyx.hr/?p=167#comments</comments>
		<pubDate>Thu, 16 Dec 2010 16:27:32 +0000</pubDate>
		<dc:creator>fressner</dc:creator>
				<category><![CDATA[Calyx]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[source control]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=167</guid>
		<description><![CDATA[Quite some time ago now, we started switching our projects from Subversion to Mercurial. Why you may ask? After reading Joel Spolsky&#8217;s introduction to Mercurial (http://hginit.com/), being the hipsters that we are, we simply had to try it out This post won&#8217;t be about the advantages and disadvantages of distributed source control systems. It will [...]]]></description>
			<content:encoded><![CDATA[<p>Quite some time ago now, we started switching our projects from Subversion to Mercurial. Why you may ask? After reading Joel Spolsky&#8217;s introduction to Mercurial (<a href="http://hginit.com/" target="_blank">http://hginit.com/</a>), being the hipsters that we are, we simply had to try it out <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This post won&#8217;t be about the advantages and disadvantages of distributed source control systems. It will be about setting up a source control environment based on Mercurial.</p>
<p>We wanted two things &#8211; integration with Eclipse and a simple method of creating/using remote Mercurial repositories which would be considered central repositories for our projects. The integration with Eclipse part wasn&#8217;t a problem &#8211; we use <a href="http://www.javaforge.com/project/HGE" target="_blank">MercurialEclipse</a> which works fine. Since the plug-in doesn&#8217;t enable you to do everything Mercurial-related we use it together with the standard Mercurial command-line utility.</p>
<p>The other thing we wanted was a practical way of creating remote Mercurial repositories and managing access rights. Since we have an online Ubuntu server we chose to use <a href="http://www.lshift.net/mercurial-server.html" target="_blank">mercurial-server</a>. Mercurial-server is a set of scripts which enables using and creating remote repositories, SSH public key authentication and fine grained per-user-per-repository access control. All communication goes through SSH.</p>
<p>Since we mainly use Windows for development, the first thought was to use PuTTY (actually Plink) for the communication between Mercurial and mercurial-server. The instructions on how to configure mercurial to use PuTTY can be found on the <a href="http://mercurial.selenic.com/wiki/AccessingSshRepositoriesFromWindows" target="_blank">official site</a>. After trying everything we couldn&#8217;t get it to work. After quite a lot of hours of fiddling &#8211; we found the problem. <strong>PuTTY&#8217;s saved sessions.</strong> If you&#8217;re like me, you save the connection setting for myserver.com under the session name myserver.com <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Big mistake, my friend&#8230; It turns out the saved sessions are known throughout the PuTTY suite, Plink included. This is normally a very convenient thing &#8211; you can type &#8216;<em>plink sessionname</em>&#8216; and plink will use all the connection parameters from PuTTY&#8217;s saved session &#8211; no need to specify everything again. The problem with mercurial-server is that you have to connect via SSH as &#8216;hg&#8217;. If the server name is the same as the session name, Plink will override the connection parameters provided by Mercurial and will use those from the saved session (which is probably configured to use another username for connection and thus mercurial-server won&#8217;t respond). Having sorted this out &#8211; Mercurial worked fine.</p>
<p>And by fine I mean really slow <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The initial cloning of a 60-something megabyte repository took more than 20 minutes. The problem turned out to be the SSH client &#8211; PuTTY in particular. We switched to cygwin + OpenSSH and the initial cloning time went down to 5 or 6 minutes which is much better. Of course this is nowhere near as fast as cloning the repository on a Linux system &#8211; it takes about a minute there <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you have some ideas on how to increase the communication speed on a Windows machine further, I would love to hear.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=167</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Confirming the network key</title>
		<link>http://blog.calyx.hr/?p=166</link>
		<comments>http://blog.calyx.hr/?p=166#comments</comments>
		<pubDate>Sun, 12 Dec 2010 20:32:11 +0000</pubDate>
		<dc:creator>asparagus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[usability windows xp]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=166</guid>
		<description><![CDATA[Does anybody see the reason why users have to confirm the network key? Besides making it hard for non-intruders to type something like &#8220;BAC34DAAAB56B7CADA336B23DA&#8221; twice, correctly]]></description>
			<content:encoded><![CDATA[<p>Does anybody see the reason why users have to confirm the network key?</p>
<p>Besides making it hard for non-intruders to type something like &#8220;BAC34DAAAB56B7CADA336B23DA&#8221; twice, correctly <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img class="aligncenter" src="http://imgur.com/xsvfG.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=166</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calyx text-to-speech system for the Croatian language</title>
		<link>http://blog.calyx.hr/?p=165</link>
		<comments>http://blog.calyx.hr/?p=165#comments</comments>
		<pubDate>Mon, 20 Sep 2010 08:28:52 +0000</pubDate>
		<dc:creator>fressner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[croatian]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[text to speech]]></category>
		<category><![CDATA[tts]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=165</guid>
		<description><![CDATA[Calyx has been working on a text-to-speech system for the Croatian language for some time now. We presented it at this year&#8217;s ELMAR conference in Zadar for which we submitted a paper. The TTS system was built on the Festival framework and is still updated. It already provides a satisfying synthesis &#8211; the intelligibility of [...]]]></description>
			<content:encoded><![CDATA[<p>Calyx has been working on a text-to-speech system for the Croatian language for some time now. We presented it at this year&#8217;s <a href="http://www.elmar-zadar.org/2010/">ELMAR</a> conference in Zadar for which we submitted a paper.</p>
<p>The TTS system was built on the Festival framework and is still updated. It already provides a satisfying synthesis &#8211; the intelligibility of the synthesis is quite high though we aim to improve the naturalness of the produced speech (which right now sounds quite robotic and non-enthusiastic <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). We aim to release the synthesizer as free for personal use.</p>
<p>You can try out the synthesizer <a href="http://tts.calyx.hr">here</a>. This blog post and the synthesizer web page will probably be updated in the following couple of days with more information. For more info you can send an e-mail to <a href="mailto:vladimir.prenner@calyx.hr">vladimir.prenner@calyx.hr</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=165</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memory leak problem in Java</title>
		<link>http://blog.calyx.hr/?p=164</link>
		<comments>http://blog.calyx.hr/?p=164#comments</comments>
		<pubDate>Thu, 29 Apr 2010 14:41:35 +0000</pubDate>
		<dc:creator>klax</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=164</guid>
		<description><![CDATA[I think that more-less everybody have by now been burned at least once by some memory leaks in Java. Although it sounds impossible (it is a managed language after all, isn&#8217;t it?), that actually happens quite often. The problem is usually with leaky abstractions &#8211; we, the developers are lead to belive that we don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I think that more-less everybody have by now been burned at least once by some memory leaks in Java. Although it sounds impossible (it is a managed language after all, isn&#8217;t it?), that actually happens quite often. The problem is usually with leaky abstractions &#8211; we, the developers are lead to belive that we don&#8217;t really have to worry about memory &#8211; GC is taking care of that stuff, isn&#8217;t it? In reality, you actually do have to worry about memory. Even though the garbage collector will free all unreferenced memory chunks, you as a developer have to make sure that no chunks end up being referenced.
</p>
<p>
Usually, the culprits are either some action listeners that are left hanging, or some references in some long forgotten collections (Singletons really are evil sometimes!).
</p>
<p>
In our case, it was neither. Here are the symptoms: the application does a whole lot of calculation and uses some tree-like data structures to do the math. We feed it with a lot of data and the memory footprint at one moment in time is ~ 700megs (we&#8217;ve got ~ 1G of heap). Then we&#8217;re done. And it&#8217;s not yet freed. But that&#8217;s OK, since GC tends to be lazy. The problem occurs when you want to do the same operation twice &#8211; the second time time, JVM runs out of memory.
</p>
<p>
So, after a couple of days of tracing the leak (my first suspicion was that we had some sort of a leak in our tree-like structure), it can all boil down to this small code snippet:
</p>
<pre>
public class MemoryLeakTest {
    public static void main(String[] args) {
        for (int i = 0; i &lt; 1000; i++) {
            JDialog dialog = new JDialog() {
                int[] take4Megs = new int[1000000];
            };
           dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
           dialog.setVisible(true);
           dialog.setVisible(false);
        }
    }
}
</pre>
<p>Here, we create a JDialog instance that has one neat attachment to it &#8211; a 4meg worth of empty integer. Set up -Xmx64m for this test case and only after a few runs, you&#8217;ll run out of memory. How is it possible that I run out of memory here? There are no collections, all variables are locally scoped &#8211; GC should be picking JDialog up after each loop iteration (or at least after a few). However, it seems that this does not occur. The only thing that seems to fix the issue is calling dispose manually like this:</p>
<pre>
public class MemoryLeakTest {
    public static void main(String[] args) {
        for (int i = 0; i &lt; 1000; i++) {
            JDialog dialog = new JDialog() {
                int[] take4Megs = new int[1000000];
            };
           dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
           dialog.setVisible(true);
           dialog.setVisible(false);
           dialog.dispose();
        }
    }
}
</pre>
<p>Please note that the tested platform is JVM 1.6.0_19, Windows7 Ultimate (it also happens on XP). Here is what the Java documentation says about dispose:</p>
<blockquote><p>
&#8220;Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.&#8221;
</p></blockquote>
<p>Inspecting heap dumps of both cases revealed that if we don&#8217;t explicitly call dispose(), that JDialog (actually, MemoryLeakTest$1 instances) instances remain in memory (I guess Swing has some references to them &#8211; we obviously don&#8217;t have them) and are not garbage collected. However, doing dispose() seems to have cleaned up the system resources and removed those references in Swing because we can&#8217;t see a single dialog instance on the heap anymore. The worst thing here is that it seems that this behaviour is not documented in the documentation (dispose() docs don&#8217;t say anything about this &#8211; see http://java.sun.com/javase/6/docs/api/java/awt/Window.html#dispose() ).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=164</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ctrl+shift+t</title>
		<link>http://blog.calyx.hr/?p=160</link>
		<comments>http://blog.calyx.hr/?p=160#comments</comments>
		<pubDate>Sun, 06 Sep 2009 09:04:16 +0000</pubDate>
		<dc:creator>fressner</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[shortcuts]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=160</guid>
		<description><![CDATA[I&#8217;m amazed at how little we know about the tools we use for our everyday work/leisure. For the past 3/4 days I&#8217;ve been amazed with the discovery of the ctrl+shift+T shortcut in Firefox. I&#8217;m not aware of when they added it to Firefox, but now I use it all the time! The shortcut does a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m amazed at how little we know about the tools we use for our everyday work/leisure. For the past 3/4 days I&#8217;ve been amazed with the discovery of the <em>ctrl+shift+T</em> shortcut in Firefox. I&#8217;m not aware of when they added it to Firefox, but now I use it all the time!</p>
<p>The shortcut does a simple thing &#8211; it reopens the last closed tab. If you press it more than once it will reopen the tab you closed before the last one etc. Since I&#8217;m quite a tab juggler while browsing the web (meaning I usually open 7 tabs at once, reorder them, then read them and close them) I often close a tab prematurely. Also, sometimes I realize there&#8217;s something I wanted to check on a tab that I just closed.</p>
<p>Before I used to go through the recently closed tabs menu option, or even the history one if I couldn&#8217;t find it in the recently closed tabs (and it could happen). Now all I need to do is click 3 buttons and the magic happens! Things like these really make me happy <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>While the previously mentioned shortcut might not be revolutionary and not be considered &#8220;important&#8221; for one&#8217;s daily work, there&#8217;s another example &#8211; the Eclipse IDE. I&#8217;ve been using Eclipse on a daily basis for almost 3 years now. And only a few months ago I became aware of the beautiful shortcuts <em>ctrl+shift+R</em> and <em>ctrl+O</em>. For those of you who aren&#8217;t aware of them &#8211; <em>ctrl+shif+R</em> opens a wildcard-search window for finding any resource (for example a class file) in your workspace. Similarly <em>ctrl+O</em> opens a wildcard search for the members/fields of the currently open class.</p>
<p>Finding a class in a project was a frustrating task before &#8211; I&#8217;d wildly scroll through the project tree trying to remember which package the class belongs to. Finding a method inside a class was usually easier, but frustrating nonetheless. Now I feel happy each time I use those shortcuts (which is probably a few hundred times a day). Happy and stupid because I didn&#8217;t use them before. I wonder how much time I&#8217;ve wasted on searching for classes manually &#8211; time which could have been spent in a more productive way. Nowadays I spend a few seconds on what took me a minute or more before &#8211; the most basic task during software development &#8211; finding the code you&#8217;re working at.</p>
<p>The unawareness of the capabilities of the tools we use daily is truly an amazing thing. I recall I tried to find such a functionality in Eclipse, but couldn&#8217;t find it in the menus so I assumed it wasn&#8217;t there. I even considered writing my own Eclipse plugin to help me find classes. I failed to realize, at the time, that <strong>I&#8217;m not the only one with that problem and that someone else probably already solved it</strong> &#8211; what&#8217;s more, the solution was already there.</p>
<p>The bottom line would be, I guess, that learning about software development doesn&#8217;t start with learning the programming language we use. It starts with learning about the tools we use for coding it &#8211; something we can forget and lose valuable time. For starters &#8211; try pressing <em>ctrl+shift+L</em> in Eclipse. I&#8217;m sure you&#8217;ll find something you didn&#8217;t know <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=160</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix &lt;3</title>
		<link>http://blog.calyx.hr/?p=159</link>
		<comments>http://blog.calyx.hr/?p=159#comments</comments>
		<pubDate>Wed, 22 Apr 2009 12:45:21 +0000</pubDate>
		<dc:creator>klax</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=159</guid>
		<description><![CDATA[Everybody already knows how great file-handling tools *NIX operating systems have. I&#8217;m just constantly amazed with how much you can get done in a single command line. For example, imagine a process that does some data processing on a remote machine and logs all the communication between the client and the server machine in one [...]]]></description>
			<content:encoded><![CDATA[<p>Everybody already knows how great file-handling tools *NIX operating systems have. I&#8217;m just constantly amazed with how much you can get done in a single command line. For example, imagine a process that does some data processing on a remote machine and logs all the communication between the client and the server machine in one file. Now, imagine this process running for 30+ hours, producing a 220+ Mb log file.</p>
<p>After the process is done, your boss wants some kind of reporting &#8211; how many entries were processed, how many were processed sucessful, how many errors were there and which errors they were. Not much of a problem when working on a UNIX machine:</p>
<p><code>A:    cat out.txt | grep 'COMMAND SUCCESS' | wc -l<br />
B:    cat out.txt | grep 'COMMAND FAILED' | wc -l</code></p>
<p>&#8230; and just to make sure, lets check if A+B = C:</p>
<p><code>C:    cat in.txt | wc -l</code></p>
<p>Now, lets report on errors:</p>
<p><code>cat out.txt | grep 'ERROR_CODE:' | sort | uniq</code></p>
<p>returns a list of errors:</p>
<p><code>ERROR_CODE: 10065<br />
ERROR_CODE: 11245<br />
ERROR_CODE: 19543<br />
</code></p>
<p>and now just lets find out how many of each we got:</p>
<p><code>cat out.txt | grep 'ERROR_CODE: 10065' | wc -l<br />
cat out.txt | grep 'ERROR_CODE: 11245' | wc -l<br />
cat out.txt | grep 'ERROR_CODE: 19543' | wc -l<br />
</code></p>
<p>Email to the boss, and we&#8217;re done. All good? Great. But, another email comes in: &#8220;Could you please send me a list of all the IDs that caused an error #11245&#8243;. Sure, no problem:</p>
<p><code>cat out.txt | grep -B 7 'ERROR_CODE: 11245' | grep 'REQUEST_ID' | awk '{ print $2; }' | sed 's/REQUEST_ID:\([0-9*]\)/\1/g' &gt; ids.txt</code></p>
<p>Lets explain this one a bit:</p>
<ul>
<li>the initial request that was sent to the system was logged 7 lines before the ERROR_CODE (therefore the &#8220;-B 7&#8243;)</li>
<li>the line with the request had the following format:<br />
<code>START    REQUEST_ID:XXXXX    SOME_OTHER_STUFF</code><br />
(therefore the awk part)</li>
<li>with sed we just extracted the number from the request_id column</li>
</ul>
<p>Can it get any more powerful than this?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=159</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Guest author: Monitoring from afar</title>
		<link>http://blog.calyx.hr/?p=158</link>
		<comments>http://blog.calyx.hr/?p=158#comments</comments>
		<pubDate>Fri, 03 Apr 2009 21:42:58 +0000</pubDate>
		<dc:creator>mbudisic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[guest]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[serverside]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=158</guid>
		<description><![CDATA[Let&#8217;s just assume that you have some important stuff being done on your server. A computation running, like I do, something getting compiled for a long time, or whatever else you might need. You don&#8217;t want to be sitting all the time, sshed in and running tail -f dump.log So you think to yourself: &#8220;If [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sven.calyx.hr/wp-content/uploads/2009/04/remotespyfly.png"><img class="alignleft size-medium wp-image-157" style="2px;" src="http://sven.calyx.hr/wp-content/uploads/2009/04/remotespyfly-300x232.png" alt="Remotespy sample output" width="300" height="232" /></a> Let&#8217;s just assume that you have some important stuff being done on your server. A computation running, like I do, something getting compiled for a long time, or whatever else you might need. You don&#8217;t want to be sitting all the time, sshed in and running <code>tail -f dump.log</code> So you think to yourself: &#8220;If only I could have this file posted to a website so I could just check it here and there from my cellphone&#8221;. That&#8217;s your wish (believe me &#8212; I can read minds). Well, I had the same wish a while back and this little script came out of it.</p>
<p>Of course, I like to at least try to code stuff up, instead of just writing to Santa. However, I usually go and try to generalize a bit. Let&#8217;s say that I want to monitor a few files or outputs of various commands at the same time. Moreover, let&#8217;s say I want to add these things as I go. Enter <a href="http://bitbucket.org/mbudisic/cl-goodies/src/tip/remotespy"><br />
remotespy</a>.</p>
<p>Remotespy is a script that parses a list of commands to run and compiles their output into a HTML webpage. The page is then saved to a local folder, e.g. public_html. Additionally, it can be scp-ed to a destination of your choice. This is useful if your &#8220;workhorse&#8221; server doesn&#8217;t have a http server setup, but you do have some other place to post your output to.</p>
<p>The syntax is simple:<br />
<code>remotespy COMMANDFILE HTMLFILE"</code><br />
The spirit of the command file is similar to the one of crontab scripts: every line represents a command that is run. Syntax of every<br />
line is:<br />
<code>TITLE ## COMMAND ## COMMENT</code></p>
<p>A sample script looks like this:<br />
<code>Hostname ## hostname<br />
OS ## uname -orpi ## OS version<br />
Disk ## df -h ## Free disk space<br />
Top ## top -b -n 1 -i ## Process state<br />
Vmstat ## vmstat ## Memory state</code></p>
<p>Every command is run as-is and its output captured and formatted into HTML. The HTML code is hardcoded in the script, but, script being a script, it can be easily edited. To make remotespy into a tool satisfying the initial desire of remote monitoring, it can be paired with cron and ssh to periodically run commands from the script and send the files to a (remote) public_html folder which is available to the internets. For the SCP upload to be useful, you should set up a ssh key pair between the source server (one running remotespy) and destination http server. These two articles can help if you don&#8217;t know how to do it yet:</p>
<ul>
<li><a href="http://www.linuxjournal.com/article/8600">http://www.linuxjournal.com/article/8600</a></li>
<li><a href="http://mindspill.net/computing/linux-notes/ssh-or-scp-without-password.html">http://mindspill.net/computing/linux-notes/ssh-or-scp-without-password.html</a></li>
</ul>
<p>The refresh meta tag is also set for the page so you don&#8217;t have to refresh the page manually to check if cron ran the command.</p>
<p>Remotespy was written in Python and tested on versions 2.4 &#8211; 2.6. I don&#8217;t know how far back the compatibility actually extends. I like to use it as it allows me to edit the command script without having to reinsert anything into cron. The HTML output is simple enough to be quickly read from mobile devices so I can check on my simulations state whenever I feel like it. You can find it in my Mercurial repository among other scripts I&#8217;ve written:<a href="http://bitbucket.org/mbudisic/cl-goodies/src/tip/remotespy"></p>
<p>http://bitbucket.org/mbudisic/cl-goodies/src/tip/remotespy</a></p>
<p>(The repo name was taken from el-goodies collection for Emacs).</p>
<p>Let me know if you have suggestions for improvements. Future versions should probably migrate from &#8220;commands&#8221; to &#8220;subprocess&#8221; Python module. Also, I might make remotespy into a daemon to make it cron-independent, but that&#8217;s a low-priority for me. This does the job well. If you would like to extend remotespy, please let me know, I&#8217;d love to hear from you. If once wasn&#8217;t enough, you can read this post at <a href="http://mbudisic.wordpress.com/2009/04/03/monitoring-from-afar/"><span>http://mbudisic.wordpress.com/2009/04/03/<span title="Click to edit this part of the permalink">monitoring-from-afar</span>/</span></a> too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=158</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Happy birthday, Calyx!</title>
		<link>http://blog.calyx.hr/?p=156</link>
		<comments>http://blog.calyx.hr/?p=156#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:37:11 +0000</pubDate>
		<dc:creator>klax</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sven.calyx.hr/?p=156</guid>
		<description><![CDATA[Exactly two years ago, a couple of geeks from Croatia decided to make a living off of being geeks. Calyx was born exactly two years ago. Actually, it was born a bit before that, but this is the legal birthday, so we celebrate it as the real one. Anyway, they say that your company has [...]]]></description>
			<content:encoded><![CDATA[<p>Exactly two years ago, a couple of geeks from Croatia decided to make a living off of being geeks. Calyx was born exactly two years ago. Actually, it was born a bit before that, but this is the legal birthday, so we celebrate it as the real one. Anyway, they say that your company has to survive for three years to be a &#8220;real&#8221; company, so I guess we just have one more to go <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  If we look at what we did in the last two years, I would say that a lot has been accomplished, but there is still much of the road ahead of us. We&#8217;re getting a bit stronger these days, so a new member should join the lot, but more on that in the days to come.</p>
<p>BTW, did you know that the next two suggestions for the company name were InCumulo and FooBar? Whoever can guess the explanation for those two names has a beer <img src='http://blog.calyx.hr/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calyx.hr/?feed=rss2&#038;p=156</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

