<?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>TommyBlue.it &#187; ruby</title>
	<atom:link href="http://www.tommyblue.it/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tommyblue.it</link>
	<description>Bombardare per la pace è un po' come trombare per la verginità...</description>
	<lastBuildDate>Tue, 24 Jan 2012 09:34:19 +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>Notifiche SMS gratis con Nagios/Icinga e Skebby</title>
		<link>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/</link>
		<comments>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 11:26:25 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Skebby]]></category>
		<category><![CDATA[SMS]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1291</guid>
		<description><![CDATA[Ho scritto un po&#8217; di codice Ruby in grado di mandare SMS gratis con Skebby utilizzando due account per privati (funziona anche con uno soltanto sia come mittente che destinatario). L&#8217;account Skebby deve essere attivo attivo e dovete aver abilitato username e password (dal pannello di gestione utente). Lo script è questo: #!/usr/bin/env ruby # [...]]]></description>
			<content:encoded><![CDATA[<p>Ho scritto un po&#8217; di codice Ruby in grado di mandare SMS gratis con <a href="http://smsgratis.skebby.it/" target="_blank">Skebby</a> utilizzando due account per privati (funziona anche con uno soltanto sia come mittente che destinatario).<br />
L&#8217;account Skebby deve essere attivo attivo e dovete aver abilitato username e password (dal pannello di gestione utente).</p>
<p>Lo script è questo:</p>
<div class="codecolorer-container ruby railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span><br />
<span style="color:#008000; font-style:italic;"># Copyright 2012 by Tommaso Visconti</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># This code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License</span><br />
<span style="color:#008000; font-style:italic;"># as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty</span><br />
<span style="color:#008000; font-style:italic;"># of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># The full text of the GNU General Public License can be found here: http://www.gnu.org/licenses/gpl.txt</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'uri'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span><br />
<span style="color:#ff6633; font-weight:bold;">$SENDER</span> = <span style="color:#996600;">'393XXXXXXXXX'</span><br />
<span style="color:#ff6633; font-weight:bold;">$RECIPIENT</span> = <span style="color:#996600;">'393XXXXXXXXY'</span><br />
<span style="color:#ff6633; font-weight:bold;">$USERNAME</span> = <span style="color:#996600;">'my_username'</span><br />
<span style="color:#ff6633; font-weight:bold;">$PASSWORD</span> = <span style="color:#996600;">'my_password'</span><br />
<span style="color:#008000; font-style:italic;"># The class sends free SMS using the Skebby API</span><br />
<span style="color:#008000; font-style:italic;"># @author Tommaso Visconti</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> SkebbyGatewaySendSMS<br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Initializes the object</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param username [String] The Skebby username</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param text [String] The text of the SMS</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param recipients [Array] The recipients of the message</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param sender [String] The SMS sender</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>username = <span style="color:#996600;">''</span>, text = <span style="color:#996600;">''</span>, recipient = <span style="color:#996600;">''</span>, sender = <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@url</span> = <span style="color:#996600;">'http://gateway.skebby.it/api/send/smsskebby/advanced/http.php'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sms_method = <span style="color:#996600;">'send_sms'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#@recipients = getRecipients(recipients) &nbsp; &nbsp; &nbsp; </span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@parameters</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'method'</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> sms_method,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'username'</span> &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> username,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'password'</span> &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">getPassword</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'text'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> text,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'recipients[]'</span> &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> recipient,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'sender_number'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> sender<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Sends the HTTP request</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Boolean] The result of the HTTP request</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @note It returns the result of the HTTP request, not the result of the sending. Use getResponse() or printResponse() to check that!</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> sendSMS<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@response</span> = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">post_form</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">URI</span><span style="color:#006600; font-weight:bold;">&#40;</span>@url<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0066ff; font-weight:bold;">@parameters</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@response</span>.<span style="color:#9900CC;">message</span> == <span style="color:#996600;">&quot;OK&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Return the response from the server</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Hash] The hash containing the result of the sending</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getResponse<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@response</span>.<span style="color:#9900CC;">body</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'&amp;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>res<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> res != <span style="color:#996600;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = res.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'='</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> temp.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color:#006600; font-weight:bold;">&#91;</span>temp<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = temp<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> result<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Prints the response in human-readable format</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [Boolean] The result of the SMS sending</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> printResponse<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">getResponse</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> result.<span style="color:#9900CC;">has_key</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'status'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'status'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">'success'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;SMS sent successfully&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Error sending the SMS, printing the full trace:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>key,value<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>#{key} =&gt; #{CGI::unescape(value)}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Encodes the recipients in the correct format</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @param recipients [Array] The Array containing the recipients as String in the format 3912345678 (without + or 00 at the beginning)</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return [String] The String in the format accepted by the server</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @note This method uses CGI::escape to escape the recipients</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getRecipients<span style="color:#006600; font-weight:bold;">&#40;</span>recipients<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; recipients.<span style="color:#9900CC;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>result, number<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#996600;">'&amp;'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> number == recipients.<span style="color:#9900CC;">first</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;recipients[]=#{CGI::escape(number)}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Obtains the password from the command line hiding the input</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># @return (String) The given password</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> getPassword<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#ff6633; font-weight:bold;">$PASSWORD</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; password = <span style="color:#ff6633; font-weight:bold;">$PASSWORD</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Password:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;stty -echo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; password = <span style="color:#ff6633; font-weight:bold;">$stdin</span>.<span style="color:#CC0066; font-weight:bold;">gets</span>.<span style="color:#CC0066; font-weight:bold;">chomp</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;stty echo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; password<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Example method to send SMS fast</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> send_my_sms<span style="color:#006600; font-weight:bold;">&#40;</span>text = <span style="color:#996600;">'Empty'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; gw = SkebbyGatewaySendSMS.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>$USERNAME, text, <span style="color:#ff6633; font-weight:bold;">$RECIPIENT</span>, <span style="color:#ff6633; font-weight:bold;">$SENDER</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> gw.<span style="color:#9900CC;">sendSMS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; gw.<span style="color:#9900CC;">printResponse</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Error in the HTTP request&quot;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Send SMS with Icinga/Nagios</span><br />
<span style="color:#9966CC; font-weight:bold;">if</span> ARGV.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span><br />
&nbsp; &nbsp; text = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; send_my_sms<span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Il programma può essere usato da linea di comando passandogli il messaggio come primo argomento oppure potete includerlo in un altro script ruby e usare la classe <em>SkebbyGatewaySendSMS</em>.<br />
Se invece salvate questo script, ad esempio, in <em>/usr/local/icinga/libexec/sms_gateway</em> e lo rendete eseguibile, potete usarlo per far mandare SMS a Icinga. Bisogna intanto definire due comandi in <em>etc/objects/commands.cfg</em>:</p>
<pre># 'notify-service-by-sms' command definition
define command{
        command_name    notify-service-by-sms
        command_line      /usr/local/icinga/libexec/sms_gateway "--Nagios Service Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$ Service $SERVICEDESC$ Description: $SERVICESTATE$ Time: $LONGDATETIME$"
}
# 'notify-host-by-sms' command definition
define command{
        command_name    notify-host-by-sms
        command_line      /usr/local/icinga/libexec/sms_gateway "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
}</pre>
<p>Quindi in <em>etc/objects/contacts.cfg</em> aggiungere all&#8217;utente icingaadmin (o chi per lui) le notifiche via SMS:</p>
<pre>define contact{
        contact_name                    icingaadmin
        use                             generic-contact
        alias                           Icinga Admin
        email                           my_email@domain.com
        host_notification_commands      notify-host-by-sms,notify-host-by-email
        service_notification_commands      notify-service-by-sms,notify-service-by-email
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2012/01/18/notifiche-sms-gratis-con-nagiosicinga-e-skebby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix redmine-mylyn-connector &#8220;Server Error: undefined method `visible_by&#8217;&#8221;</title>
		<link>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/</link>
		<comments>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 13:11:08 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Mylyn]]></category>
		<category><![CDATA[Redmine]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1266</guid>
		<description><![CDATA[With version 5324 the method Project.visible_by has been deprecated in favor of Project.visible_condition and redmine-mylyn-connector plugin stopped working with error: Server Error: undefined by `visible_by&#8217;. Here&#8217;s the patch you need to fix the plugin: diff -r redmine-mylyn-connector-2.7.5/app/controllers/mylyn_connector/issues_controller.rb redmine-mylyn-connector-2.7.5-patched/app/controllers/mylyn_connector/issues_controller.rb 63c63 &#60; :conditions =&#62; &#91;&#34;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &#62;= ? and &#34; &#60; &#60; Project.visible_by, issues, [...]]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://www.redmine.org/projects/redmine/repository/revisions/5324" target="_blank">version 5324</a> the method <strong>Project.visible_by</strong> has been <a href="http://www.redmine.org/projects/redmine/repository/revisions/5324/diff/trunk/app/models/project.rb" target="_blank">deprecated in favor of <strong>Project.visible_condition</strong></a> and <a href="http://sourceforge.net/apps/wordpress/redmin-mylyncon/" target="_blank">redmine-mylyn-connector</a> plugin stopped working with error:<strong><em> Server Error: undefined by `visible_by&#8217;</em></strong>.</p>
<p>Here&#8217;s the patch you need to fix the plugin:</p>
<pre>
<div class="codecolorer-container ruby railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>issues_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>issues_controller.<span style="color:#9900CC;">rb</span><br />
63c63<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &gt;= ? and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span>, issues, cond<span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and #{Issue.table_name}.updated_on &gt;= ? and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span>, issues, cond<span style="color:#006600; font-weight:bold;">&#93;</span><br />
79c79<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span>, issues<span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{Issue.table_name}.id in (?) and &quot;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span>, issues<span style="color:#006600; font-weight:bold;">&#93;</span><br />
diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>projects_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>projects_controller.<span style="color:#9900CC;">rb</span><br />
16c16<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;enabled_modules.name = 'issue_tracking' AND #{Project.visible_by}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;enabled_modules.name = 'issue_tracking' AND #{Project.visible_condition(User.current)}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
diff <span style="color:#006600; font-weight:bold;">-</span>r redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>queries_controller.<span style="color:#9900CC;">rb</span> redmine<span style="color:#006600; font-weight:bold;">-</span>mylyn<span style="color:#006600; font-weight:bold;">-</span>connector<span style="color:#006600; font-weight:bold;">-</span>2.7.5<span style="color:#006600; font-weight:bold;">-</span>patched<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>controllers<span style="color:#006600; font-weight:bold;">/</span>mylyn_connector<span style="color:#006600; font-weight:bold;">/</span>queries_controller.<span style="color:#9900CC;">rb</span><br />
18c18<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;(#{Query.table_name}.is_public = ? OR #{Query.table_name}.user_id = ?) AND (project_id IS NULL OR &quot;</span> &nbsp;<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_by</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;)&quot;</span>, <span style="color:#0000FF; font-weight:bold;">true</span>, User.<span style="color:#9900CC;">current</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
<span style="color:#006600; font-weight:bold;">---</span><br />
<span style="color:#006600; font-weight:bold;">&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;(#{Query.table_name}.is_public = ? OR #{Query.table_name}.user_id = ?) AND (project_id IS NULL OR &quot;</span> &nbsp;<span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006600; font-weight:bold;">&lt;</span> Project.<span style="color:#9900CC;">visible_condition</span><span style="color:#006600; font-weight:bold;">&#40;</span>User.<span style="color:#9900CC;">current</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;)&quot;</span>, <span style="color:#0000FF; font-weight:bold;">true</span>, User.<span style="color:#9900CC;">current</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div></div>
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/12/14/how-to-fix-redmine-mylyn-connector-server-error-undefined-method-visible_by/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SASS facile con Compass.app</title>
		<link>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/</link>
		<comments>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 19:56:29 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[SASS]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1205</guid>
		<description><![CDATA[Compass.app è un&#8217;applicazione per MacOSX che aiuta nella compilazione dei file SASS. Una volta configurata tiene sotto controllo i file SASS e li compila al volo in CSS. Il progetto, scritto in Ruby, è open-source e ospitato su GitHub. Viene venduta l&#8217;applicazione compilata a 7$, ma dato che compilarlo è piuttosto semplice (e sono tirchio) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1206" title="Compass.App" src="http://www.tommyblue.it/wp-content/uploads/2011/08/128.png" alt="" width="128" height="128" /><a title="Compass.app" href="http://compass.handlino.com/" target="_blank">Compass.app</a> è un&#8217;applicazione per MacOSX che aiuta nella compilazione dei file <a title="SASS" href="http://sass-lang.com/" target="_blank">SASS</a>. Una volta configurata tiene sotto controllo i file SASS e li compila al volo in CSS.</p>
<p>Il progetto, scritto in Ruby, è open-source e <a href="https://github.com/handlino/CompassApp" target="_blank">ospitato su GitHub</a>. Viene venduta l&#8217;applicazione compilata a 7$, ma dato che compilarlo è piuttosto semplice (e sono tirchio) me lo sono compilato.</p>
<p>Ecco come ho fatto:</p>
<p>Il primo passo è installare <a title="JRuby" href="http://www.jruby.org/" target="_blank">JRuby</a>, che con <a href="http://www.tommyblue.it/?s=rvm">RVM</a> si limita ad un semplice:</p>
<pre>rvm install jruby</pre>
<p>Una volta installato creiamo un gemset e installiamo l&#8217;unica gemma necessaria: <a title="Rawr" href="http://rawr.rubyforge.org/" target="_blank">rawr</a></p>
<pre>rvm use jruby
rvm gemset create compassapp
rvm gemset use compassapp
gem install rawr</pre>
<p>Fatto questo bisogna clonare il repository git e lanciare qualche rake:</p>
<pre>git clone https://github.com/handlino/CompassApp.git
cd CompassApp
rake rawr:compile
rake rawr:bundle:app</pre>
<p>Ecco fatto, adesso spostiamo l&#8217;app dalla cartella <em>package/osx</em> a <em>Applicazioni</em> e il gioco è fatto :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/08/02/sass-facile-con-compass-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installazione di Gitorious su Ubuntu server 10.04</title>
		<link>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/</link>
		<comments>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 14:17:14 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[gitorious]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1160</guid>
		<description><![CDATA[Oggi ho bestemmiato un paio d&#8217;ore per installare Gitorious, progetto che mi ha incuriosito e di cui volevo capirne le potenzialità (in ottica di fargli sostituire l&#8217;ottimo Redmine). Dato che alla fine sono riuscito a farlo funzionare e non ho trovato una guida fatta a modo, ho deciso di mettere nero su bianco ciò che [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1161" title="Gitorious" src="http://www.tommyblue.it/wp-content/uploads/2011/06/Gitorious.png" alt="" width="95" height="95" />Oggi ho bestemmiato un paio d&#8217;ore per installare <a title="Gitorious" href="http://www.gitorious.org/" target="_blank">Gitorious</a>, progetto che mi ha incuriosito e di cui volevo capirne le potenzialità (in ottica di fargli sostituire l&#8217;ottimo <a title="Remine" href="http://www.redmine.org/" target="_blank">Redmine</a>). Dato che alla fine sono riuscito a farlo funzionare e non ho trovato una guida fatta a modo, ho deciso di mettere nero su bianco ciò che ho fatto.</p>
<p>L&#8217;installazione è stata effettuata su un server virtuale pulito Ubuntu server 10.04 x86_64. Ho provato ad utilizzare <a title="RVM" href="https://rvm.beginrescueend.com/" target="_blank">RVM</a> e ruby 1.9.2 ma non ci sono riuscito&#8230; Ho quindi utilizzato <a title="Ruby Enterprise Edition" href="http://www.rubyenterpriseedition.com/" target="_blank">Ruby Enterprise Edition</a> 1.8.7<span id="more-1160"></span></p>
<p>Per cominciare ho installato un po&#8217; di pacchetti:</p>
<pre>apt-get install build-essential zlib1g-dev tcl-dev libexpat-dev libcurl4-openssl-dev postfix apache2 mysql-server mysql-client apg geoip-bin libgeoip1 libgeoip-dev libaspell-dev aspell sqlite3 libsqlite3-dev imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev libmysqlclient15-dev apache2-dev libonig-dev libmagick++-dev zip unzip memcached git-core git-svn git-doc git-cvs irb sphinxsearch uuid uuid-dev openjdk-6-jre</pre>
<p>Ho scaricato e installato <a title="ActiveMQ" href="http://activemq.apache.org/" target="_blank">ActiveMQ</a> 5.5.0:</p>
<pre>wget http://www.powertech.no/apache/dist/activemq/apache-activemq/5.5.0/apache-activemq-5.5.0-bin.tar.gz
sudo -s
tar xzvf apache-activemq-5.5.0-bin.tar.gz -C /usr/local/
echo "export ACTIVEMQ_HOME=/usr/local/apache-activemq-5.5.0" &gt;&gt; /etc/activemq.conf﻿
echo "export JAVA_HOME=/usr/" &gt;&gt; /etc/activemq.conf
dduser --system --no-create-home activemq
chown -R activemq /usr/local/apache-activemq-5.5.0/data</pre>
<p>Per lanciare ActiveMQ ho utilizzato <a href="http://www.tommyblue.it/wp-content/uploads/2011/06/activemq.txt" target="_blank">questo</a> file, copiato in <em>/etc/init.d</em>:</p>
<pre>wget http://www.tommyblue.it/wp-content/uploads/2011/06/activemq.txt
sudo mv activemq.txt /etc/init.d/activemq
sudo chmod +x /atc/init.d/activemq
sudo update-rc.d activemq defaults
sudo service activemq start</pre>
<p>A questo punto ho scaricato da <a title="REE" href="http://www.rubyenterpriseedition.com/download.html" target="_blank">qui</a> REE e l&#8217;ho installato:</p>
<pre>sudo dpkg -i ﻿﻿ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb</pre>
<p>dopodichè ho installato <a title="RubyGems" href="http://rubygems.org/" target="_blank">RubyGems</a>. Come dicevo prima non sono riuscito ad utilizzare RVM proprio a causa di problemi con le gemme. Per far funzionare il tutto ho dovuto installare tutte le gemme da root:</p>
<pre>wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.5.tgz
tar xzf  ﻿rubygems-1.8.5.tgz
cd rubygems-1.8.5/
sudo ruby setup.rb
echo "gem: --no-ri --no-rdoc" &gt; ~/.gemrc</pre>
<p>Installato RubyGems bisogna installare le gemme. <strong>ATTENZIONE</strong>: se fin qui ho più o meno seguito le guide che trovate nella webografia, per le gemme ho fatto tutt&#8217;altro. Infatti per far funzionare Gitorious, che è scritto con Rails 2.3.x, non è possibile installare le gemme <em>as is</em> dato che molte sono ormai incompatibili con Rails 2. Meglio far fare tutto a Bundler o specificare gemma per gemma la versione da installare. Quindi prima cloniamo il repository di Gitorious:</p>
<pre>sudo -s
git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious
cd /var/www/gitorious
gem install bundler
bundle install
gem install -b -v 1.1 stomp
gem install rmagick passenger stompserver raspell
gem install -v=0.8.7 rake
passenger-install-apache2-module</pre>
<p>Al termine dell&#8217;ultimo passaggio creare il file <em>/etc/apache2/mods-available/passenger.load</em> con quanto suggerito dallo script precedente. Nel mio caso:</p>
<pre>LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby</pre>
<p>Per attivare il modulo:</p>
<pre>a2enmod passenger
a2enmod rewrite
a2enmod ssl
a2enmod expires
service apache2 restart</pre>
<p>Ok, adesso ho copiato i necessari script di avvio:</p>
<pre>cp /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d/
cp /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d/</pre>
<p>In <em>/etc/init.d/git-daemon</em> modificare GIT_DAEMON come segue:</p>
<pre>GIT_DAEMON="/usr/bin/local/ruby /var/www/gitorious/script/git-daemon -d"</pre>
<p>Creare anche <em>/etc/init.d/stomp</em>:</p>
<pre>#!/bin/sh
# Start/stop the stompserver
#
### BEGIN INIT INFO
# Provides:          stomp
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Stomp
# Description:       Stomp
### END INIT INFO   

test -f /usr/local/bin/stompserver || exit 0    

. /lib/lsb/init-functions    

case "$1" in
start)  log_daemon_msg "Starting stompserver" "stompserver"
    start-stop-daemon --start --name stompserver --startas /usr/local/bin/stompserver --background --user git
    log_end_msg $?
    ;;
stop)  log_daemon_msg "Stopping stompserver" "stompserver"
    start-stop-daemon --stop --name stompserver
    log_end_msg $?
    ;;
restart) log_daemon_msg "Restarting stompserver" "stompserver"
    start-stop-daemon --stop --retry 5 --name stompserver
    start-stop-daemon --start --name stompserver --startas /usr/local/bin/stompserver --background --user git
    log_end_msg $?
    ;;
status)
    status_of_proc /usr/local/bin/stompserver stompserver &amp;&amp; exit 0 || exit $?
    ;;
*)      log_action_msg "Usage: /etc/init.d/stomp {start|stop|restart|status}"
    exit 2
    ;;
esac
exit 0</pre>
<p>e <em>/etc/init.d/git-poller</em>:</p>
<pre>#!/bin/sh
# Start/stop the git poller
#
### BEGIN INIT INFO
# Provides:          git-poller
# Required-Start:    stomp
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Gitorious poller
# Description:       Gitorious poller
### END INIT INFO    

/bin/su - git -c "cd /var/www/gitorious;RAILS_ENV=production script/poller $@"</pre>
<p>Si possono quindi aggiungere tutti all&#8217;avvio:</p>
<pre>chmod 755 /etc/init.d/git-ultrasphinx /etc/init.d/git-daemon /etc/init.d/stomp /etc/init.d/git-poller
update-rc.d stomp defaults
update-rc.d git-daemon defaults
update-rc.d git-ultrasphinx defaults
update-rc.d git-poller defaults</pre>
<p>Bisogna creare la configurazione di apache. Gitorious utilizza SSL per il login, quindi i VirtualHost sono 2, io ho creato il file <em>/etc/apache2/sites-available/gitorious</em>:</p>
<pre>&lt;VirtualHost *:80&gt;
  ServerName MIODOMINIO
  DocumentRoot /var/www/gitorious/public
&lt;/VirtualHost&gt;
&lt;IfModule mod_ssl.c&gt;
  &lt;VirtualHost _default_:443&gt;
    ServerName MIODOMINIO
    DocumentRoot /var/www/gitorious/public
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
  &lt;/VirtualHost&gt;
&lt;/IfModule&gt;</pre>
<p>e quindi l&#8217;ho attivato:</p>
<pre>a2dissite default
a2ensite gitorious</pre>
<p>Torniamo a Gitorious che abbiamo un po&#8217; lasciato indietro. Serve un utente git che sarà il proprietario dell&#8217;applicazione:</p>
<pre>adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git
chown -R git:git /var/www/gitorious
su - git
cd /var/www/gitorious
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
mkdir -p tmp/pids repositories tarballs
cp config/database.sample.yml config/database.yml
cp config/gitorious.sample.yml config/gitorious.yml
cp config/broker.yml.example config/broker.yml</pre>
<p>Modificare <em>config/database.yml</em> lasciando soltanto la sezione production e le sue configurazioni. Inserire un utente MySQL con permessi sul database <em>gitorious_production</em> (se non volete creare a mano questo db utilizzate un utente in grado di creare database). Nel file <em>config/gitorious.yml</em> inserite:</p>
<pre>production:
  cookie_secret: "FRASESEGRETISSIMAELUNGHISSIMA"
  repository_base_path: "/var/www/gitorious/repositories"
  gitorious_client_port: 80
  gitorious_client_host: gitorious.dw
  gitorious_host: gitorious.dw
  archive_cache_dir: "/var/www/gitorious/tarballs"
  archive_work_dir: "/tmp/tarballs-work"
  hide_http_clone_urls: true
  is_gitorious_dot_org: false</pre>
<p>Per il valore di <em>cookie_secret</em> utilizzate l&#8217;output del comando <em>apg -m 64</em>.<br />
Ho avuto dei problemi con ActiveSupport, del tipo:</p>
<pre>uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)</pre>
<p>come suggerito <a href="http://makandra.com/notes/1051-fixing-uninitialized-constant-activesupport-dependencies-mutex-nameerror" target="_blank">qui</a> li ho superati inserendo <em>require &#8216;thread&#8217;</em> in <em>config/boot.rb</em> dopo RAILS_ROOT.</p>
<p>A questo punto si può procedere con la migrazione:</p>
<pre>su - git
cd /var/www/gitorious
export RAILS_ENV=production
rake db:create
rake db:migrate
rake ultrasphinx:bootstrap</pre>
<p>L&#8217;ultimo comando dovrebbe restituire un errore ma comunque crea il file di configurazione, che va editato per evitare l&#8217;errore. Il file è  <em>config/ultrasphinx/production.conf</em> in cui va sostituito <em>base_tags</em> con <em>tags</em>. Effettuata la sostituizione su può lanciare Sphinx con:</p>
<pre>rake ultrasphinx:index RAILS_ENV=production
rake ultrasphinx:daemon:start RAILS_ENV=production</pre>
<p>Per l&#8217;aggiornamento degli indici ho creato il file<em> /etc/cron.d/ultrasphinx</em>:</p>
<pre>* */1 * * *       git     cd /var/www/gitorious &amp;&amp; /usr/local/bin/rake ultrasphinx:index RAILS_ENV=production</pre>
<p>Prima di accedere a Gitorious bisogna creare l&#8217;utente admin lanciando, come <em>git</em>, il comando:</p>
<pre>env RAILS_ENV=production ruby script/create_admin</pre>
<p>Riavviamo i servizi (ed eventualmente il server per essere sicuri che al riavvio Gitorious funzioni correttamente):</p>
<pre>service git-daemon start
service apache2 restart</pre>
<p>Colleghiamoci al sito e, se tutto è andato bene, iniziamo ad utilizzare Gitorious!</p>
<p>Resta un&#8217;ultima cosa da fare per poter pushare correttamente, ovvero creare un link simbolico al file <em>/var/www/gitorious/script/gitorious</em> in una cartella presente nella PATH dell&#8217;utente git, io l&#8217;ho creato in<em> /usr/local/bin</em>:</p>
<pre>﻿﻿﻿ln -s /var/www/gitorious/script/gitorious /usr/local/bin/</pre>
<p>Senza questo passaggio al momento del push ottenevo un singolare quanto criptico errore da git:</p>
<pre>bash: gitorious: comando non trovato</pre>
<h3>﻿Webografia</h3>
<ul>
<li><a href="http://www.silly-science.co.uk/2010/12/12/installing-gitorious-on-ubuntu-10-04-howto/">http://www.silly-science.co.uk/2010/12/12/installing-gitorious-on-ubuntu-10-04-howto/</a></li>
<li><a href="http://www.gitorious.org/gitorious/pages/UbuntuInstallation">http://www.gitorious.org/gitorious/pages/UbuntuInstallation</a></li>
<li><a href="http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server">http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/06/01/installazione-di-gitorious-su-ubuntu-server-10-04/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to build a website with Locomotive CMS from scratch</title>
		<link>http://www.tommyblue.it/2011/02/28/how-to-build-a-website-with-locomotive-cms-from-scratch/</link>
		<comments>http://www.tommyblue.it/2011/02/28/how-to-build-a-website-with-locomotive-cms-from-scratch/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 00:01:12 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[LocomotiveCMS]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1075</guid>
		<description><![CDATA[A few weeks ago I&#8217;ve found Locomotive CMS, an open source CMS for Ruby on Rails written by the french guys from NoCoffee. The project is still in beta but after some nights spent on it seemed to me a good piece of code and I decided to use it to serve my portfolio site [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I&#8217;ve found <a title="Locomotive CMS" href="http://www.locomotivecms.com/" target="_blank">Locomotive CMS</a>, an open source CMS for Ruby on Rails written by the french guys from <a title="NoCoffee" href="http://www.nocoffee.fr/" target="_blank">NoCoffee</a>. The project is still in beta but after some nights spent on it seemed to me a good piece of code and I decided to use it to serve my portfolio site <a title="Kreations Collective" href="http://www.kreations.it" target="_blank">http://www.kreations.it</a>. In this how-to I&#8217;ll explain my experience while building it, you can follow these steps to build your own site.</p>
<p><strong>For italian readers:</strong> questa guida è stata scritta in inglese affinchè possa contribuire alla scarsa documentazione presente.</p>
<h2>Requirements</h2>
<p>For a basic installation follow the <em>official</em> guide: <a href="http://www.locomotivecms.com/support/installation/engine" target="_blank">http://www.locomotivecms.com/support/installation/engine</a></p>
<p>If you want to use it in production you can follow my <a href="http://www.tommyblue.it/2009/11/14/deploy-di-applicazioni-rails-con-unicorn-e-nginx/" target="_blank">old guide to use Nginx+Unicorn</a> (italian language). However this how-to refers to a local development installation (<em>Engine installation</em> method) because i&#8217;m having a lot of problems with the deployment. I&#8217;ll add a new paragraph when i&#8217;ll succeed in it :-)</p>
<p>To install MongoDB on Debian-based distribution take a look <a href="http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages" target="_blank">here</a>.</p>
<p>Choose or create a web template (HTML, CSS, Javascripts).</p>
<p>I suggest to install Locomotive on your pc with a theme proposed <a href="http://www.locomotivecms.com/support/themes" target="_blank">here</a>.  Browse pages, templates and models and try to understand how Locomotive  works. I think it&#8217;s not so easy to understand it if you, like me, are  coming from a long experience with WordPress, Drupal or Joomla. When you fell just a bit comfortable with it, go on with this how-to. If you need help you can look in the <a href="http://locomotive.vanillaforums.com/" target="_blank">support forum</a> or the <a href="https://github.com/locomotivecms/engine/issues" target="_blank">Github page</a>.</p>
<h2>Pages and Templates</h2>
<p>The main work in the backend while building the website will be done in the <em>Page</em> panel. From there, click the <em>Pages</em> badge and you can see existing pages or add a new page.<br />
Every page except the first inherits from the <em>Home page</em> or one of its children (and so do their templates). This means that we&#8217;ll write a template in the <em>Home page</em>&#8216;s <em>Template</em> section and the other pages will inherit their templates from it. This means that, except for local content, there&#8217;s only a place where to modify the HTML template. Obviously if you need you can prevent a page to inherit the template and write a new one.</p>
<p>Go back to the <em>Page</em> panel and open the <em>Home Page</em>. There are two sections: <em>General information</em> and  <em>Template</em>.<br />
The <em>General information</em> section&#8217;s content is well inline-explained, just dwell on <em>Templatized</em>: you can choose if that page is a template. If you activate this option, the page will be a template for a model, ie it can be used to create new content of that model type  (see the <em>Contact page</em> paragraph below for an example).<br />
The <em>Template</em> section is the more important: you can write the HTML template of your site using the <a href="http://www.liquidmarkup.org/">Liquid Templating Language</a> and if you define editable sections, a useful WYSIWYG will appear after the update.<br />
Templates are really a great feature because you can create a complex template and then give the control of the contents to a not-technician who can fill the editable sections with a powerful editor.</p>
<p>So, let&#8217;s start uploading the needed files: css, javascripts and images. Do it from <em>Settings &gt; Theme files</em>, if you use the <em> images</em>, <em>javascripts</em> and <em>stylesheets</em> folder they will be put in the right place and you can get it with liquid&#8217;s tags (I&#8217;m getting big errors while uploading in production, but everyting works fine in the development environment).<br />
Then copy your HTML template and paste it in the <em>Template</em> section inside the <em>Home page</em>. Before saving it, let&#8217;s edit it.</p>
<p>Css and javascripts tags must be replaced with the <em>liquid</em> ones. In my case:</p>
<pre>{{ 'reset-min' | stylesheet_tag }}
{{ '960grid' | stylesheet_tag }}
{{ 'style' | stylesheet_tag }}
{{ 'nivo-slider' | stylesheet_tag }}

{{ 'jquery.min.js' | javascript_tag }}
{{ 'jquery.nivo.slider.pack' | javascript_tag }}</pre>
<p>As you can see, if you have used the right folders while uploading, now it&#8217;s really easy to add them to the template.</p>
<p>The site title can be get from the Locomotive site, do it with:</p>
<pre>&lt;title&gt;{{ site.name }}&lt;/title&gt;</pre>
<p>My template has a side menu listing. I can create it using liquid:</p>
<pre>&lt;nav id="main_menu"&gt;
  &lt;ul&gt;
    &lt;li class="{% if page.fullpath == 'index' %}on{% endif %}"&gt;&lt;a href="/"&gt;Home Page&lt;/a&gt;&lt;/li&gt;
    {% nav site, no_wrapper: true %}
  &lt;/ul&gt;
&lt;/nav&gt;</pre>
<p>This will generate a list with every page with the <em>Listed</em> option set as on. The active page will automatically get the <em>on</em> class, so remember to use it.</p>
<p>Before saving the template let&#8217;s add a <em>block</em>: a block is a part of the template which can be overwritten from the pages which inherits from that template. I&#8217;ll call it <em>main_content</em> and it will contain the section of the page which changes between the various pages.</p>
<pre>{% block main_content %}
  ...
{% endblock %}</pre>
<h2>Models</h2>
<p>After this basic introduction to liquid templates, let&#8217;s jump to the models: a model is a custom content type where you can define the fields the content type must have. Are you puzzled? Ok, let&#8217;s do an example..</p>
<p>I want to create a simple blog section in the site and I want to show the last 3 entries in the footer. So i need to create a <em>blog</em> page to show the posts (with pagination) and in the footer I must show only the last 3 posts&#8217; summary.</p>
<p>The first step is to create the model. Go to the <em>Page</em> panel and click on the <em>New model</em> link on the top-right of that page. Insert the model&#8217;s <em>title</em> and <em>slug</em> (if empty) then choose your custom fields. For my posts I choosed a title (<em>Simple Input</em>), a summary (<em>Text</em>), a content (<em>Text</em>) and a thumbnail (<em>File</em>). Save the model then add a few posts. Jump back to the <em>Home page</em> template and add this into the footer:</p>
<pre>{% for post in contents.posts limit:3 %}
  &lt;article&gt;
    &lt;h2&gt;{{ post.title }}&lt;/h2&gt;
    {{ post.summary }}
    &lt;a href="/blog/{{ post._permalink }}"&gt;Continue reading &amp;raquo;&lt;/a&gt;
  &lt;/article&gt;
{% endfor %}</pre>
<p>The <em>for</em> cycle gets the content of the posts (<em>contents.posts</em>) and show its summary with a link to the full article.  To let the <em>post._permalink</em> work we must create a new page (<em>blog</em>) which will show the posts and a templatized page to contain a single post.</p>
<p>The <em>blog</em> page template will contain:</p>
<pre>{% extends 'parent' %}

{% block main_content %}
 {% paginate contents.posts by 10 %}
   {% for post in paginate.collection %}
     &lt;article&gt;
       &lt;h4&gt;&lt;a href="/blog/{{ post._permalink }}"&gt;{{ post.title }}&lt;/a&gt;&lt;/h4&gt;
       &lt;summary&gt;
         {{ post.summary }} &lt;a href="/blog/{{ post._permalink }}"&gt;Continua &amp;raquo;&lt;/a&gt;
       &lt;/summary&gt;
     &lt;/article&gt;
   {% endfor %}
   {{ paginate | default_pagination: 'previous_label:Recent', 'next_label:Older' }}
 {% endpaginate %}
{% endblock %}</pre>
<p>This will show the last 10 entries and the links to go backward and forward. The order can be changed from the post model, <em>Edit model &gt; Advanced options &gt; Order by</em> select menu.</p>
<p>For a single post let&#8217;s create a new templatized page with the <em>blog</em> page as parent and with <em>posts</em> as <em>Content type</em>. The template will be:</p>
<pre>{% extends 'parent' %}

{% block main %}
 &lt;article&gt;
   &lt;h2&gt;{{ post.title }}&lt;/h2&gt;
   {{ post.body }}
 &lt;/article&gt;
{% endblock %}</pre>
<h2>Editable content</h2>
<p>As mentioned above it&#8217;s possible to declare editable content: this will give you the possibility to edit part of a page with a handy editor. As usual let&#8217;s make an example.<br />
Add a new page and use this code as template:</p>
<pre>{% extends 'parent' %}

{% block main_content %}
 {% editable_long_text 'page_content' %}
 blabla
 {% endeditable_long_text %}
{% endblock %}</pre>
<p>Save the page and, et voilà, you&#8217;ll see the WYSIWIG appear under the <em>Main content </em>tab. Edit the page content directly from there.</p>
<h2>Contact page and API</h2>
<p>I want to add a page from which I can be contacted by visitors. This is pretty simple: add a new <em>messages</em> model with the custom field you need (in my case: <em>Name, Email</em> and <em>Message</em>) then activate the <em>Advanced options &gt; API enabled</em> option. Choose the accounts to be notified and save.<br />
This will create a model which can be populated from inside a page and an email message will be sent to the selected accounts when this message is posted.</p>
<p>To finish, let&#8217;s put this code into the contact page template:</p>
<pre>{% extends 'parent' %}

{% block main_content %}
&lt;div class="text"&gt;
 {% editable_long_text 'main_content' %}
   bla bla
 {% endeditable_long_text %}
&lt;/div&gt;

&lt;form id="contactform" name="contact" action="{{ contents.messages.api.create }}" method="post"&gt;
 &lt;p&gt;
  &lt;label for="name"&gt;Nome&lt;/label&gt;
  &lt;input type="text" id=name name="content[name]" placeholder="First and last name" required tabindex="1" /&gt;
 &lt;/p&gt;
 &lt;p&gt;
  &lt;label for="email"&gt;Email&lt;/label&gt;
  &lt;input type="text" id=email name="content[email]" placeholder="example@domain.com" required tabindex="2" /&gt;
 &lt;/p&gt;
 &lt;p&gt;
  &lt;label for="comment"&gt;Il tuo messaggio&lt;/label&gt;
  &lt;textarea name="content[message]" id="comment" tabindex="3" required&gt;&lt;/textarea&gt;
 &lt;/p&gt;
 &lt;p class="action"&gt;
  &lt;input name="submit" type="submit" id="submit" tabindex="4" value="Send Message" /&gt;
 &lt;/p&gt;
&lt;/form&gt;

&lt;script type="text/javascript"&gt;
 $(document).ready(function() {
  var form = $('form[name=contact]');

  form.submit(function(e) {
   e.stopPropagation();
   e.preventDefault();

   $.post(form.attr('action'),
   form.serializeArray(),
   function(data) {
    if (data.errors == null) {
     alert("Thank you ! Your message have been received");
     form[0].reset();
    } else
     alert("We are sorry but we were unable to treat your message. Please try later.");
    }, "json");
  });
 });
&lt;/script&gt;
{% endblock %}</pre>
<p>Eventually you can write some javascript checks.</p>
<h2>Conclusions</h2>
<p>With this little guide I&#8217;ve covered the few things you should know to set up a basic portfolio. There&#8217;re a lot of other arguments to cover, surely I&#8217;ll write again when I&#8217;ll be more prepared.<br />
Currently all this guide is about self-teaching, so please insert a comment to this post if I made a mistake or if exists a better way to do something. As an example I admit i havo no idea what the <em>Assests</em> panel and the <em>Settings &gt; Theme files &gt; Snippets</em> are&#8230;. Or how to edit images while uploading, I don&#8217;t know if this is possible, but ImageMagick is a requisite so it should&#8230; :-)</p>
<p>As mentioned before, you can see the result of my work here: <a title="Kreations" href="http://www.kreations.it" target="_blank">http://www.kreations.it</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/02/28/how-to-build-a-website-with-locomotive-cms-from-scratch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rsnapshot Nagios plugin</title>
		<link>http://www.tommyblue.it/2011/01/31/rsnapshot-nagios-plugin/</link>
		<comments>http://www.tommyblue.it/2011/01/31/rsnapshot-nagios-plugin/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 17:21:45 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Software Libero]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Rsnapshot]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1055</guid>
		<description><![CDATA[Ho pubblicato oggi su GitHub la prima versione di un plugin per Nagios 3 (ma dovrebbe funzionare anche con la versione 2) che controlla lo stato dei backup di rsnapshot. Si tratta di uno script ruby pensato per controllare lo stato dei backup giornalieri, non è quindi utilissimo per chi usa anche i backup orari [...]]]></description>
			<content:encoded><![CDATA[<p>Ho pubblicato oggi su <a title="GitHub" href="https://github.com/" target="_blank">GitHub</a> la prima versione di un plugin per Nagios 3 (ma dovrebbe funzionare anche con la versione 2) che controlla lo stato dei backup di <a href="http://rsnapshot.org/" target="_blank">rsnapshot</a>. Si tratta di uno script ruby pensato per controllare lo stato dei backup giornalieri, non è quindi utilissimo per chi usa anche i backup orari (ma con poche modifiche si può adattare).</p>
<p>È sufficiente configurare rsnapshot per salvare i log in <em>/var/log/rsnapshot.log</em> e lanciare lo script. Se ci sono backup multipli (ad esempio la domenica quando c&#8217;è sia il giornaliero che il settimanale) lo script avvisa con lo stato di <em>WARNING</em> o <em>ERROR</em> se uno dei backup è in quello stato.</p>
<p>Per scaricare lo script potete utilizzare la <a href="https://github.com/tommyblue/Rsnapshot-Nagios-Plugin" target="_blank">pagina su GitHub</a> o su su <a href="http://exchange.nagios.org/directory/Plugins/Backup-and-Recovery/rsnapshot" target="_blank">Nagios Exchange</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2011/01/31/rsnapshot-nagios-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Day 2010 Arezzo</title>
		<link>http://www.tommyblue.it/2010/10/24/linux-day-2010-arezzo/</link>
		<comments>http://www.tommyblue.it/2010/10/24/linux-day-2010-arezzo/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 23:18:11 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Software Libero]]></category>
		<category><![CDATA[Linux Day]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1038</guid>
		<description><![CDATA[Oggi ho partecipato al Linux Day ad Arezzo con il talk &#8220;Sviluppo di applicazioni web con Ruby On Rails 3&#8243;. Distribuisco qui le slides proiettate durante il talk: download]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-1039" title="Linux Day 2010" src="http://www.tommyblue.it/wp-content/uploads/2010/10/log0ld2k10-185x300.gif" alt="" width="185" height="300" />Oggi ho partecipato al <a href="http://www.linuxdayarezzo.it">Linux Day ad Arezzo</a> con il talk <em><strong>&#8220;Sviluppo di applicazioni web con Ruby On Rails 3&#8243;</strong></em>.</p>
<p>Distribuisco qui le slides proiettate durante il talk: <a href="http://www.tommyblue.it/wp-content/uploads/2010/10/LD2010.pdf">download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2010/10/24/linux-day-2010-arezzo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Le magie di RVM</title>
		<link>http://www.tommyblue.it/2010/09/22/le-magie-di-rvm/</link>
		<comments>http://www.tommyblue.it/2010/09/22/le-magie-di-rvm/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 01:43:34 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Memoria usiliaria]]></category>
		<category><![CDATA[Rails 3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RVM]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=1007</guid>
		<description><![CDATA[Come avevo scritto un po&#8217; di tempo fa, RVM, ovvero Ruby Version Manager, è un&#8217;applicazione che permette di avere più versioni di Ruby nello stesso sistema. Beh, in verità non ho detto tutto, anzi, ho detto molto poco&#8230; Con RVM è infatti possibile gestire automagicamente non solo più versioni di Ruby nel sistema, ma anche [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1017" title="RVM" src="http://www.tommyblue.it/wp-content/uploads/2010/09/rvm-logo.png" alt="" width="230" height="220" />Come <a href="http://www.tommyblue.it/2010/05/07/utilizzare-piu-versioni-di-ruby-con-rvm/">avevo scritto un po&#8217; di tempo fa</a>, <strong>RVM</strong>, ovvero <em>Ruby Version Manager</em>, è un&#8217;applicazione che permette di avere più versioni di Ruby nello stesso sistema.<br />
Beh, in verità non ho detto tutto, anzi, ho detto molto poco&#8230;</p>
<p>Con RVM è infatti possibile gestire <em>automagicamente</em> non solo più versioni di Ruby nel sistema, ma anche versioni e ambienti diversi per ogni applicazione!</p>
<p><em>NB: gran parte di quello che descriverò lo potete trovare <a href="http://sirupsen.com/get-started-right-with-rvm/">qui</a>, lo riprendo per ampliare un po&#8217; il discorso e per avere, come al solito, un memoria ausiliaria a portata di mano.</em></p>
<p>L&#8217;eccezionale strumento che RVM mette a disposizione sono le <strong>gemset</strong>, ovvero degli ambienti personalizzabili che è non solo possibile usare in ogni momento, ma è anche possibile associarle ad uno specifico progetto utilizzando l&#8217;apposito file <em>.rvmrc</em></p>
<p>Entriamo nel pratico. Una gemset, in questo caso <em>MyProject</em>, si crea con:</p>
<pre>rvm gemset create MyProject</pre>
<p>e si utilizza con:</p>
<pre>rvm use 1.9.2@MyProject</pre>
<p>o, in breve:</p>
<pre>rvm 1.9.2@MyProject</pre>
<p>In questo caso ho creato la gemset avendo prima selezionato ruby 1.9.2 (anch&#8217;esso installato con RVM). Si noti che la gemset di default si chiama <em>global</em> e sarà quindi possibile riutilizzarla con:</p>
<pre>rvm 1.9.2@global</pre>
<p>In questo nuovo ambiente non vi sono gemme installate e si può quindi installarci soltanto quelle necessarie al progetto in questione. La lista di tali gemme potrà poi essere esportata e reimportata:</p>
<pre>rvm gemset export MyProject.gems
rvm gemset import MyProject.gems</pre>
<p>La procedura è comoda anche per creare un set standard di gemme e importarlo in ogni nuovo progetto creato. Se fosse necessario è possibile eliminare tutte le gemme di un ambiente con:</p>
<pre>rvm gemset empty</pre>
<p>Esiste anche un comando per creare e usare immediatamente una nuova gemset:</p>
<pre>rvm use 1.9.2@MyProject --create</pre>
<p>Può essere anche definita la gemset <em>globale</em> e di <em>default</em>. La prima verrà applicata ad ogni nuova versione di ruby installata, la seconda in ogni nuova gemset. I file in questione sono, rispettivamente, <em>~/.rvm/gemsets/global.gems</em> e <em>~/.rvm/gemsets/default.gems</em>.</p>
<p>Per finire arriva la vera perla: il file <em>rvmrc</em>.<br />
Ve ne sono tre versioni: quello globale, quello dell&#8217;utente e quello del progetto.<br />
Mentre le prime due possono essere utili per la gestione delle opzioni di compilazione di ruby e delle gemme (date un occhio <a href="http://rvm.beginrescueend.com/workflow/rvmrc/">qui</a> per maggiori dettagli), il terzo è sicuramente il più interessante e consiste in un file <em>.rvmrc</em> contenente, ad esempio:</p>
<pre>rvm 1.8.6@project</pre>
<p>Ogni volta che si entrerà nella cartella contenente il file (con <em>cd </em>da terminale) verrà impostata la gemset selezionata nel file! Vien da sè che si può inserire in un eventuale <a href="http://en.wikipedia.org/wiki/Source_Code_Management">SCM</a> associato al progetto i file <em>.rvmrc</em> e <em>MyProject.gems</em> per avere la certezza che tutti i collaboratori abbiano lo stesso ambiente di sviluppo.</p>
<p>Esiste anche uno shortcut che crea il file <em>.rvmrc</em> al momento della creazione della gemset:</p>
<pre>rvm --create --rvmrc 1.8.6@project</pre>
<p>Un&#8217;ultima &#8220;chicca&#8221; è l&#8217;autocompletamento del comando RVM, che è attivabile inserendo nel file dell&#8217;ambiente di bash (ad esempio <em>.bashrc</em> o <em>.bash_profile</em>):</p>
<pre>[[ -r $rvm_path/scripts/completion ]] &amp;&amp; . $rvm_path/scripts/completion</pre>
<p>ovviamente adeguando <em>$rvm_path</em> alle vostre esigienze. Una spiegazione più accurata la trovate qui: <a href="http://rvm.beginrescueend.com/workflow/completion/">http://rvm.beginrescueend.com/workflow/completion/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2010/09/22/le-magie-di-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utilizzare più versioni di Ruby con RVM</title>
		<link>http://www.tommyblue.it/2010/05/07/utilizzare-piu-versioni-di-ruby-con-rvm/</link>
		<comments>http://www.tommyblue.it/2010/05/07/utilizzare-piu-versioni-di-ruby-con-rvm/#comments</comments>
		<pubDate>Fri, 07 May 2010 14:04:43 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Rails 3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[RubyOnRails]]></category>
		<category><![CDATA[RVM]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=922</guid>
		<description><![CDATA[Con Ruby Version Manager è possibile avere più versioni (o addirittura patchlevel) di Ruby installate ed effettuare velocemente lo switch tra una e l&#8217;altra. Supponendo che abbiate già installato Rubygems, installare RVM è praticamente immediato: ~# gem install rvm ~# rvm-install A questo punto si può installare una qualsiasi versione di Ruby con: ~# rvm [...]]]></description>
			<content:encoded><![CDATA[<p>Con Ruby Version Manager è possibile avere più versioni (o addirittura <em>patchlevel</em>) di Ruby installate ed effettuare velocemente lo switch tra una e l&#8217;altra.</p>
<p>Supponendo che abbiate già installato Rubygems, installare RVM è praticamente immediato:</p>
<pre>~# gem install rvm
~# rvm-install</pre>
<p>A questo punto si può installare una qualsiasi versione di Ruby con:</p>
<pre>~# rvm install 1.9.2-head</pre>
<p>e switchare tra le versioni con:</p>
<pre>~# rvm use 1.9.2-head
~# ruby -v
ruby 1.9.2dev (2010-05-07 trunk 27656) [x86_64-darwin10.3.0]
~# rvm use default
~# ruby -v
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]</pre>
<p>Attenzione che ogni nuova installazione ha le sue gemme, quindi sarà necessario installare quelle richieste, nel mio caso, volendo utilizzare Ruby 1.9.2 per provare Rails 3:</p>
<pre>~# rvm use 1.9.2-head
~# gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
~# gem install rails --pre</pre>
<p><strong>Leggi anche:</strong> <a href="http://www.tommyblue.it/2010/09/22/le-magie-di-rvm/"><em>Le magie di RVM</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2010/05/07/utilizzare-piu-versioni-di-ruby-con-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interrogare un servizio SOAP con Ruby, Python e PHP</title>
		<link>http://www.tommyblue.it/2009/07/11/interrogare-un-servizio-soap-con-ruby-python-e-php/</link>
		<comments>http://www.tommyblue.it/2009/07/11/interrogare-un-servizio-soap-con-ruby-python-e-php/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 13:34:10 +0000</pubDate>
		<dc:creator>TommyBlue</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://www.tommyblue.it/?p=539</guid>
		<description><![CDATA[Sempre in tema di SOAP, ho avuto la necessità di interrogare un server SOAP con Ruby,Python e PHP. In tutti e tre i casi la faccenda è stata piuttosto semplice, bastano 3/4 righe di codice. Vi propongo questo breve paragone. RUBY require 'soap/wsdlDriver' @SOAPUrl = "http://HOST_URL/ws/ws208913.asmx?WSDL" @service = SOAP::WSDLDriverFactory.new(@SOAPUrl).create_rpc_driver @service.function2call(param1, param2) PYTHON from SOAPpy import [...]]]></description>
			<content:encoded><![CDATA[<p>Sempre<a href="http://www.tommyblue.it/2009/06/15/interrogare-un-servizio-soap-con-ruby/"> in tema di SOAP</a>, ho avuto la necessità di interrogare un server SOAP con Ruby,Python e PHP. In tutti e tre i casi la faccenda è stata piuttosto semplice, bastano 3/4 righe di codice. Vi propongo questo breve paragone.</p>
<h3>RUBY</h3>
<pre>require 'soap/wsdlDriver'
@SOAPUrl = "http://HOST_URL/ws/ws208913.asmx?WSDL"
@service = SOAP::WSDLDriverFactory.new(@SOAPUrl).create_rpc_driver
@service.function2call(param1, param2)</pre>
<h3>PYTHON</h3>
<pre>from SOAPpy import WSDL
server =  WSDL.Proxy('http://myurl/ws.asmx?WSDL')
result  = server.function2call(param1, param2)</pre>
<h3>PHP</h3>
<pre>$url = "http://myurl/ws.asmx?WSDL";
$client  = new SoapClient($url);
$client-&gt;function2call($param1, $param2);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tommyblue.it/2009/07/11/interrogare-un-servizio-soap-con-ruby-python-e-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

