<?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>xterm.it &#187; programming</title>
	<atom:link href="http://www.xterm.it/blog/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xterm.it/blog</link>
	<description>time to think -  by Marco Campana</description>
	<lastBuildDate>Sun, 18 Oct 2009 20:59:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Install mysql gem on Ruby1.9</title>
		<link>http://www.xterm.it/blog/2009/06/install-mysql-gem-on-ruby19/</link>
		<comments>http://www.xterm.it/blog/2009/06/install-mysql-gem-on-ruby19/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 10:00:38 +0000</pubDate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xterm.it/blog/?p=133</guid>
		<description><![CDATA[If you want to install the mysql gem with Ruby1.9 try this: sudo gem1.9 install kwatch-mysql-ruby  Where in the --with-mysql-config option you have to specify the path to mysql_config in the bin directory in your mysql installation path. ]]></description>
			<content:encoded><![CDATA[<p>This should sound like a very easy task, but it took me a while to sort this out, so I thought I&#8217;d share it. If you want to install the mysql gem with Ruby1.9 try this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">sudo gem1.9 install kwatch<span style="color:#006600; font-weight:bold;">-</span>mysql<span style="color:#006600; font-weight:bold;">-</span>ruby 
              <span style="color:#006600; font-weight:bold;">--</span>source=http:<span style="color:#006600; font-weight:bold;">//</span>gems.<span style="color:#9900CC;">github</span>.<span style="color:#9900CC;">com</span><span style="color:#006600; font-weight:bold;">/</span> 
              <span style="color:#006600; font-weight:bold;">--</span> with<span style="color:#006600; font-weight:bold;">-</span>mysql<span style="color:#006600; font-weight:bold;">-</span>config=<span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>mysql<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>mysql_config</pre></div></div>

<p>Where in the &#8211;with-mysql-config option you have to specify the path to mysql_config in the bin directory in your mysql installation path.</p>
<p>In <a href="http://www.mit-can.com/">Mobile Interactive Technology</a> we are trying to make our new applications compatible with Rails 2.3 and Ruby1.9. Not an easy task though. An invaluable source of info on compatibility of gems with Ruby1.9 is <a href="http://isitruby19.com/">isitruby19.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xterm.it/blog/2009/06/install-mysql-gem-on-ruby19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Yahoo! Hack day is gone. Good stuff guys!</title>
		<link>http://www.xterm.it/blog/2009/05/the-yahoo-hack-day-is-gone-good-stuff-guys/</link>
		<comments>http://www.xterm.it/blog/2009/05/the-yahoo-hack-day-is-gone-good-stuff-guys/#comments</comments>
		<pubDate>Tue, 12 May 2009 21:38:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://www.xterm.it/blog/?p=116</guid>
		<description><![CDATA[I went to the Yahoo Open Hack day London last Saturday A big number of Yahoo enthusiasts (and a guy with a Google T-shirt) arrived at the Congress Center early in the morning for a 24h session of hacking and fun events. ]]></description>
			<content:encoded><![CDATA[<p>I went to the Yahoo! Open Hack day London last Saturday. I waited for quite a long time this event, and I&#8217;m pleased to say that all my expectations were fully met. A big number of Yahoo enthusiasts (and a guy with a Google T-shirt) arrived at the Congress Center early in the morning for a 24h session of hacking and fun events.<br />
I was very happy to meet my ex Yahoo colleagues, seeing that they&#8217;re doing great even during hard times for the company.<br />
I enjoyed mostly the talks about <a href="http://developer.yahoo.com/geo/">geo technologies</a> and <a href="http://developer.yahoo.com/yql/">yql</a>. I got so many ideas to implement in my iphone application:)<br />
In particular YQL is a very interesting technology that allows an application to query a number of Yahoo and external databases by means of restful requests.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://openhacklondon.pbworks.com/f/1238690369/logo_horizontal_250px.jpg" alt="" /></p>
<p>Check some <a href="http://www.flickr.com/search/?q=openhackday%20london&#038;w=all&#038;s=int">pictures on Flickr</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.xterm.it/blog/2009/05/the-yahoo-hack-day-is-gone-good-stuff-guys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A sample Java test runner using annotations</title>
		<link>http://www.xterm.it/blog/2009/04/a-sample-java-test-runner-using-annotations/</link>
		<comments>http://www.xterm.it/blog/2009/04/a-sample-java-test-runner-using-annotations/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 19:23:00 +0000</pubDate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xterm.it/blog/?p=106</guid>
		<description><![CDATA[public class RunTests {      int passed = 0, failed = 0;      for (Method m : Class.forName(args[0]).getMethods()) {               passed++;                 "Test %s failed: %s %n",                  m,                failed++; ]]></description>
			<content:encoded><![CDATA[<p>I have found this toy code on <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html">java.sun.com</a> that describes how Java annotations could be used to write a simple Test runner. This script gets as argument the name of a class and tries to execute all the methods of that class that are annotated as @Test.<br />
The interesting aspect of this code is that is shows clearly how annotations can be used to execute/manipulate source code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RunTests <span style="color: #009900;">&#123;</span>
  <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><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">int</span> passed <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span>, failed <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Method</span> m <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><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: #006633;">getMethods</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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>m.<span style="color: #006633;">isAnnotationPresent</span><span style="color: #009900;">&#40;</span>Test.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
              m.<span style="color: #006633;">invoke</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              passed<span style="color: #339933;">++;</span>
           <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Throwable</span> ex<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;">printf</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">&quot;Test %s failed: %s %n&quot;</span>,
                m,
                ex.<span style="color: #006633;">getCause</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
              <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              failed<span style="color: #339933;">++;</span>
           <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Passed: %d, Failed %d%n&quot;</span>, passed, failed<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.xterm.it/blog/2009/04/a-sample-java-test-runner-using-annotations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding attribute accessors to a Perl class &#8211; rubifying perl</title>
		<link>http://www.xterm.it/blog/2009/02/adding-attribute-accessors-to-a-perl-class-rubifying-perl/</link>
		<comments>http://www.xterm.it/blog/2009/02/adding-attribute-accessors-to-a-perl-class-rubifying-perl/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 22:19:03 +0000</pubDate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xterm.it/blog/?p=73</guid>
		<description><![CDATA[I can't help it, even when I'm working with Perl I always think of Ruby The idea is to add to a Perl package behavior similar to a Ruby class, when you can specify attribute accessors (getters and setters) like this:   my $class = shift;   bless {}, $class; ATT ]]></description>
			<content:encoded><![CDATA[<p>This small hack adds attribute accessors to a Perl class. The idea is to add to a Perl package behavior similar to a Ruby class, when you can specify attribute accessors (getters and setters) like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">attr_accessor <span style="color:#ff3333; font-weight:bold;">:attr_name</span></pre></div></div>

<p>Here is the code we have written. Basically all you need to do is add the sub attr_accessor to your Perl class, and then call this method with the attribute you want the getter and setter for.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">package</span> MyPackage<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$class</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">bless</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$class</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> attr_accessor <span style="color: #009900;">&#123;</span>
  <span style="color: #0000ff;">$attr</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">eval</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;ATT;
  sub $attr {
    my \$self = shift;
    my \$value = shift;
    if( \$value ) {
      my \$old_value = \$self-&gt;{ $attr };
      \$self-&gt;{ $attr } = \$value;
      return \$old_value;
      } else {
        return \$self-&gt;{ $attr };
      }
    }
ATT</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
attr_accessor <span style="color: #ff0000;">'name'</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the code above we have added accessors methods for the attribute &#8216;name&#8217;. We can then set and get the &#8216;name&#8217; attribute as in the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyPackage<span style="color: #339933;">;</span>
<span style="color: #0000ff;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">name</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'marco'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># setter method</span>
<span style="color: #000066;">print</span> <span style="color: #0000ff;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">name</span> <span style="color: #666666; font-style: italic;"># this will get and print 'marco'</span></pre></div></div>

<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xterm.it/blog/2009/02/adding-attribute-accessors-to-a-perl-class-rubifying-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
