<?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>cosminaru blog &#187; Tools</title>
	<atom:link href="http://cosminaru.ro/blog/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosminaru.ro/blog</link>
	<description>home</description>
	<lastBuildDate>Fri, 26 Aug 2011 09:56:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>More Perl  geekness: getting the .class bytecode version</title>
		<link>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/</link>
		<comments>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 08:33:26 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[GeekStyle]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://cosminaru.ro/blog/?p=107</guid>
		<description><![CDATA[I&#8217;ve been looking for a decent tool to determine the byte code version for a Java .class file. You know, the one based on the numbers after the CAFEBABE magic (you can read more about this here or here). There are some tools around for this, but most of them written in Java. I really [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a decent tool to determine the byte code version for a Java .class file. You know, the one based on the numbers after the CAFEBABE magic (you can read more about this <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#75883">here</a> or <a href="http://en.wikipedia.org/wiki/Class_(file_format)">here</a>).<br />
There <a href="http://alumnus.caltech.edu/~leif/opensource/bcver/index.html">are</a> <a href="http://www.rgagnon.com/javadetails/java-0544.html">some</a> <a href="http://www.javaworld.com/javaqa/2003-05/02-qa-0523-version.html?page=1#resources">tools</a> around for this, but most of them written in Java. I really don&#8217;t see the point in starting a JVM just to read 4 bytes from a file, so I wrote a short Perl script for this. Again, I am no Perl expert so this is probably not the best solution performance-wise and such.</p>
<h4>Usage</h4>
<p><strong>1.</strong> Running the script with no arguments &#8211; will result in scanning the current directory recursively for <em>.class</em> files. The results are grouped by directory and a total number of files is also displayed. Directories that do not contain any <em>.class</em> files will be ignored, in order to keep a clean output. Below is a short sample.</p>
<pre><code>cosmin@cosminaru:~/work/quizine$ <strong>bcversion.pl</strong>

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine (2 files)
	QuizineException.class -&gt; 1.6
	ApplicationContext.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/web (2 files)
	ErrorHandlerFilter.class -&gt; 1.6
	SessionContext.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/web/actions (1 files)
	ActionBase.class -&gt; 1.6
</code></pre>
<p><strong>2.</strong> If you provide one or more arguments, the script will only scan the content of these arguments. If the argument is a file then the byte code version is displayed for that file. If it is a directory then it will be scanned recursively, just like above.<br />
<strong>Note:</strong> The paths from the argument list should all be relative to the current directory in order for the script to work correctly.</p>
<pre><code>cosmin@cosminaru:~.../model/quiz$ <strong>bcversion.pl AbstractQuestion.class result</strong>
* AbstractQuestion.class -&gt; 1.6

* /home/cosmin/work/quizine/src/main/webroot/WEB-INF/classes/org/quizine/model/quiz/result (5 files)
	QuestionnaireResult.class -&gt; 1.6
	BooleanAnswer.class -&gt; 1.6
	AbstractAnswer.class -&gt; 1.6
	SingleChoiceAnswer.class -&gt; 1.6
	MultipleChoiceAnswer.class -&gt; 1.6
</code></pre>
<p>I&#8217;ll probably want to scan JAR files and directories containing JAR files. But the really poor Perl docs for reading ZIP buffers didn&#8217;t quite help me. If you think think you can give a hand with that, drop a note <img src='http://cosminaru.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h4>Download:</h4>
<p>You can get the script from <a href="http://cosminaru.ro/downloads/bcversion.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2009/01/28/more-perl-geekness-getting-the-class-bytecode-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Currency conversions the geek way</title>
		<link>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/</link>
		<comments>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 12:38:02 +0000</pubDate>
		<dc:creator>Cosmin Marginean</dc:creator>
				<category><![CDATA[GeekStyle]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/</guid>
		<description><![CDATA[There are many situations when I need to convert an amount of Euros to RON (Romanian Leu). There are a couple of sites that can do the conversion for you (even Google does this pretty well). However, none of them seem to be as accurate as the the National Bank of Romania, whose exchange rate [...]]]></description>
			<content:encoded><![CDATA[<p>There are many situations when I need to convert an amount of Euros to RON (Romanian Leu). There are a couple of sites that can do the conversion for you (even Google <a href="http://www.google.com/search?hl=en&amp;rlz=1B3GGGL_enRO244RO244&amp;q=100+euro+to+ron&amp;btnG=Search" target="_blank">does</a> this pretty well). However, none of them seem to be as accurate as the the <a href="http://www.bnr.ro/" target="_blank">National Bank of Romania</a>, whose exchange rate is the only one that has any relevance for me. So most of the times I have to open the calculator, go the BNR website and use the exchange rate provided <a href="http://www.bnr.ro/Ro/Info/" target="_blank">here</a>, an issue that doesn&#8217;t work very well for a lazy ass like me.</p>
<p>Fortunately, BNR also provides <a href="http://www.bnro.ro/nbrfxrates.xml" target="_blank">an XML</a> with the exchange rates for the most important currencies in a manner that is very easy to understand:<br />
<code><br />
...<br />
&lt;Rate currency="DKK"&gt;0.4926&lt;/Rate&gt;<br />
&lt;Rate currency="EGP"&gt;0.4291&lt;/Rate&gt;<br />
&lt;Rate currency="EUR"&gt;3.6747&lt;/Rate&gt;<br />
&lt;Rate currency="GBP"&gt;4.6020&lt;/Rate&gt;<br />
...</code></p>
<p>Luckily, Perl knows how to parse XMLs so we&#8217;re almost good to go. Now I am not Perl expert, nor want to become one very soon, but this sounded like something doable with a minimum amount effort.</p>
<p>What we need is to get the XML with an HTTP request, parse it and convert the given amount of money using the desired currency. So I created a tiny script <code>convert2ron.pl</code> that accepts two parameters: the currency identifier (EUR, USD, etc.) and the amount to be converted. I will not go into the details of how this script works as it&#8217;s pretty straight-forward (even for someone with a minimal understanding of Perl). So now I can convert all sorts of currencies to RON using calls like this:<br />
<code><br />
$ ./convert2ron.pl EUR 245<br />
</code></p>
<p>and get results like these:<br />
<code><br />
245 EUR = 900.30 RON</p>
<p>(rate is 3.6747)<br />
</code></p>
<p>Is this the geekiest way to do this, or what? And the geekness doesn&#8217;t stop here. Now I also have some scripts like <code>eur2ron.sh</code> and <code>usd2ron.sh</code> so I can do stuff like this all day:<br />
<code><br />
$ eur2ron 456<br />
</code><br />
So, if you want to convert international currencies to RON the geek way, here&#8217;s the download: <a href="http://cosminaru.ro/downloads/ron-convert.zip">http://cosminaru.ro/downloads/ron-convert.zip</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosminaru.ro/blog/2008/04/09/currency-conversions-the-geek-way/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

