<?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>Simone Tellini &#187; Tips&#8217;n&#8217;Tricks</title>
	<atom:link href="http://tellini.info/category/5-TipsnTricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://tellini.info</link>
	<description>To strive, to seek, to find, and not to yield</description>
	<lastBuildDate>Mon, 06 Feb 2012 10:42:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Keeping script kiddies at bay with mod_evasive and iptables</title>
		<link>http://tellini.info/2011/11/keeping-script-kiddies-at-bay-with-mod_evasive-and-iptables/</link>
		<comments>http://tellini.info/2011/11/keeping-script-kiddies-at-bay-with-mod_evasive-and-iptables/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 17:52:55 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tips'n'Tricks]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_evasive]]></category>
		<guid isPermaLink="false">http://tellini.info/?p=147</guid>
		<description><![CDATA[mod_evasive is a nice Apache module that helps to protect your server against DoS attacks. However, when a client is blocked, it will keep on using resources on your server. Even if the request will result in a 403 error, &#8230; <a href="http://tellini.info/2011/11/keeping-script-kiddies-at-bay-with-mod_evasive-and-iptables/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.zdziarski.com/blog/?page_id=442">mod_evasive</a> is a nice Apache module that helps to protect your server against DoS attacks.</p>
<p>However, when a client is blocked, it will keep on using resources on your server. Even if the request will result in a 403 error, it&#8217;s still a connection that needs to be handled. In some cases, it might require spawning a new process for no good reason.</p>
<p>It&#8217;s quite easy to configure mod_evasive so that the evil IPs are blocked via the machine firewall, though:</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_evasive20.c&gt;<br />
<span style="color: #adadad; font-style: italic;"># ...your other settings...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DOSSystemCommand <span style="color: #7f007f;">&quot;sudo /root/scripts/ban_ip.sh %s&quot;</span><br />
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;</div></div>
<p>You could put an iptables command there, but I prefer to use a small script because it&#8217;s easier to maintain. Also I don&#8217;t want to block the IP until the end of time <img src='http://tellini.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  So, I use this:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #007800;">IP</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">IPTABLES</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables<br />
<br />
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> banned <span style="color: #660033;">-s</span> <span style="color: #007800;">$IP</span> <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> DROP<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$IPTABLES</span> -D banned -s <span style="color: #007800;">$IP</span> -p TCP --dport 80 -j DROP&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> at now + <span style="color: #000000;">2</span> hours</div></div>
<p>Don&#8217;t forget to grant the permission to run the script to the account used by apache. My sudoers config contains:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">www-data ALL=(ALL) NOPASSWD: /root/scripts/ban_ip.sh</div></div>
<p>And here&#8217;s the result, on a busy server victim of some abuse:</p>
<p><a href="http://tellini.info/wp-content/uploads/2011/11/mod_evasive.png"><img src="http://tellini.info/wp-content/uploads/2011/11/mod_evasive.png" alt="" title="CPU usage before and after iptables integration" width="380" height="116" class="aligncenter size-full wp-image-148" /></a></p>
<p>Red means &#8220;system time&#8221;, blue is &#8220;user time&#8221;. The green arrow marks the time when I configured it to use iptables.</p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2011/11/keeping-script-kiddies-at-bay-with-mod_evasive-and-iptables/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Lion, the Witch and the Xcode</title>
		<link>http://tellini.info/2011/07/the-lion-the-witch-and-the-xcode/</link>
		<comments>http://tellini.info/2011/07/the-lion-the-witch-and-the-xcode/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 20:03:40 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips'n'Tricks]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[xcode]]></category>
		<guid isPermaLink="false">http://tellini.info/?p=141</guid>
		<description><![CDATA[&#8230;or maybe it was &#8220;The Lion, the Bug and the Xcode&#8220;? Anyway, if you just upgraded your system to Lion, then downloaded the new Xcode from the App Store, tried to run it just to get welcomed by a sparkling &#8230; <a href="http://tellini.info/2011/07/the-lion-the-witch-and-the-xcode/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&#8230;or maybe it was &#8220;<em>The Lion, the Bug and the Xcode</em>&#8220;?</p>
<p>Anyway, if you just upgraded your system to <a href="http://www.apple.com/macosx/" target="_blank">Lion</a>, then downloaded the new <a href="http://itunes.apple.com/us/app/xcode/id448457090?mt=12" target="_blank">Xcode</a> from the App Store, tried to run it just to get welcomed by a sparkling crash along the lines of</p>
<blockquote><p>UNCAUGHT EXCEPTION (NSInternalInconsistencyException): Couldn&#8217;t load plug-in &#8216;com.apple.dt.IDE.IDEiPhoneSupport&#8217; while firing fault for extension &#8216;Xcode.Device.iPhoneSimulator&#8217;</p></blockquote>
<p>Don&#8217;t panic!</p>
<p>Simply go to your Applications folder and re-run the Xcode installer. The second time it&#8217;ll get it right, or at least it did for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2011/07/the-lion-the-witch-and-the-xcode/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>A cure for Firefox freezing on download.cnet.com</title>
		<link>http://tellini.info/2009/10/a-cure-for-firefox-freezing-on-download-cnet-com/</link>
		<comments>http://tellini.info/2009/10/a-cure-for-firefox-freezing-on-download-cnet-com/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 16:02:00 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Tips'n'Tricks]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tips'n'tricks]]></category>
		<guid isPermaLink="false">http://wp.cr.tellini.org/?p=95</guid>
		<description><![CDATA[It&#8217;s been a loooong time since I&#8217;ve been able to browse download.cnet.com without having Firefox freeze on article pages. Something&#8217;s very nasty on that site (or Firefox/one of the plugins I use is very bugged). Some guy on mozillazine suggests &#8230; <a href="http://tellini.info/2009/10/a-cure-for-firefox-freezing-on-download-cnet-com/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a loooong time since I&#8217;ve been able to browse download.cnet.com without having Firefox freeze on article pages. Something&#8217;s very nasty on that site (or Firefox/one of the plugins I use is very bugged). Some guy on <a href="http://forums.mozillazine.org/viewtopic.php?f=38&amp;t=1551645">mozillazine</a> suggests to enable cookies from cnet.com, but I&#8217;d rather not: there must be another way <img src='http://tellini.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Anyway, <a href="https://addons.mozilla.org/it/firefox/addon/1865">AdBlock</a> comes to rescue. Just add a filter blocking <strong>http://*.i.com.com/*.js</strong> and the problem vanishes. <img src='http://tellini.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2009/10/a-cure-for-firefox-freezing-on-download-cnet-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Attributes, reflection and PHP</title>
		<link>http://tellini.info/2008/01/attributes-reflection-and-php/</link>
		<comments>http://tellini.info/2008/01/attributes-reflection-and-php/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 11:16:00 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips'n'Tricks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[tips'n'tricks]]></category>
		<guid isPermaLink="false">http://wp.cr.tellini.org/?p=53</guid>
		<description><![CDATA[After a long exposure to .NET, when I get back to PHP I sometimes find myself missing some cool functionality (and a good IDE too&#8230; none of those I&#8217;ve tried so far can compete with the comfort of VisualStudio + &#8230; <a href="http://tellini.info/2008/01/attributes-reflection-and-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After a long exposure to .NET, when I get back to PHP I sometimes find myself missing some cool functionality (and a good IDE too&#8230; none of those I&#8217;ve tried so far can compete with the comfort of VisualStudio + ReSharper).</p>
<p>Among these missing features, <a href="http://msdn2.microsoft.com/en-us/library/xtwkdas5.aspx" title="Attributes Overview">attributes</a> are what I needed in order to solve a certain problem in an elegant way.</p>
<p>Looking at what the <a href="http://www.php.net/oop5.reflection">reflection API</a> was offering, I came up with a simple way to decorate my properties/methods/classes with attributes: through the documentation comments!</p>
<p>Let&#8217;s see an example:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;pre&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> A<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* @attr<br />
&nbsp; &nbsp; &nbsp;* @attr2 &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> GetPropAttrs<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$property</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$class</span> &nbsp; <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReflectionClass<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/get_class"><span style="color: #990000;">get_class</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$prop</span> &nbsp; &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProperty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$property</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$doc</span> &nbsp; &nbsp; <span style="color: #339933;">=</span> <span style="color: #000088;">$prop</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDocComment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$attrs</span> &nbsp; <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$matches</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'/@([a-zA-Z_][a-zA-Z_0-9]*)s/m'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$doc</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$m</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$attrs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$m</span><span style="color: #009900;">&#91;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attrs</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$attrs</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">GetPropAttrs</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'foo'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attrs</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> B<br />
<span style="color: #000000; font-weight: bold;">extends</span> A<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* @attr3 &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> A<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Test A:&lt;br&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">test</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> B<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;p&gt;Test B:&lt;br&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">test</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/pre&gt;</div></td></tr></tbody></table></div>
<p>Running the above script you&#8217;ll see the following output, confirming that everything works as desired:</p>
<pre>
Test A:
Array
(
    [0] => attr
    [1] => attr2
)
Test B:
Array ( [0] => attr3 )
</pre>
<p>If you&#8217;re using the /** */ comments for real documentation, you might want to use another escape character rather than @, to avoid problems.</p>
<p>Happy coding <img src='http://tellini.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2008/01/attributes-reflection-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Note to self: what to do when the hard disk fails (Linux)</title>
		<link>http://tellini.info/2007/08/note-to-self-what-to-do-when-the-hard-disk-fails-linux/</link>
		<comments>http://tellini.info/2007/08/note-to-self-what-to-do-when-the-hard-disk-fails-linux/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 19:53:54 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Tips'n'Tricks]]></category>
		<guid isPermaLink="false">http://wp.cr.tellini.org/?p=40</guid>
		<description><![CDATA[It&#8217;s been a bad day. One of my Linux box hard drives decided to fail this morning. Luckily, it&#8217;s not totally failed, but the superblock is gone AWOL. Let&#8217;s recap what I did to revive it until a replacement can &#8230; <a href="http://tellini.info/2007/08/note-to-self-what-to-do-when-the-hard-disk-fails-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a bad day.</p>
<p>One of my Linux box hard drives decided to fail this morning. Luckily, it&#8217;s not totally failed, but the superblock is gone AWOL. Let&#8217;s recap what I did to revive it until a replacement can be mounted.</p>
<ol>
<li> The first thing I&#8217;ve noticed was that my /storage partition had been re-mounted as read-only when the kernel intercepted an error. So I simply umount&#8217;ed it and tried a <strong>fsck.ext3 /dev/hda1</strong>. Too bad it couldn&#8217;t read the superblock, thus it failed&#8230;</li>
<li> So I ran <strong>mke2fs -n /dev/hda1</strong>: the <em>-n</em> switch means &#8220;don&#8217;t create a filesystem, just tell me where the superblock backups will be stored&#8221;. As long as the other parameters are the same as those used when creating the filesystem, this will correctly locate the superblock backups. The first one reported in my case was at block 32768. </li>
<li> At this point I&#8217;ve been able to repair the filesystem using <strong>fsck.ext3 -b 32768 /dev/hda1</strong>. </li>
<li> Finally, I tried to remount the partition with <strong>mount /storage</strong>, but obviously it would have been too easy&#8230; the first superblock is currently sitting on a Really Dead Sector (TM) <img src='http://tellini.info/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  </li>
<li> Knowing that the backup at block 32768 was working, I&#8217;ve finally been able to finish the job with <strong>mount -t ext3 -o sb=131072 /dev/hda1 /storage</strong> (where 131072 is 32768 * 4, as the filesystem uses 4k blocks, while mount uses 1k units) </li>
</ol>
<p>Phew! Everything looked good at this point. Good enough to backup a lot of data, anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2007/08/note-to-self-what-to-do-when-the-hard-disk-fails-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resizing your Parallels 3.0 disk image</title>
		<link>http://tellini.info/2007/06/resizing-your-parallels-3-0-disk-image/</link>
		<comments>http://tellini.info/2007/06/resizing-your-parallels-3-0-disk-image/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 18:27:37 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Tips'n'Tricks]]></category>
		<guid isPermaLink="false">http://wp.cr.tellini.org/?p=37</guid>
		<description><![CDATA[You&#8217;ve just upgraded to Parallels 3.0 but you realize that your virtual HD is almost full. Well, no problem: luckily there&#8217;s this ImageTool that allows you to resize disk images&#8230; uhm&#8230; no, wait&#8230; can&#8217;t find it&#8230; but&#8230; but&#8230; I was &#8230; <a href="http://tellini.info/2007/06/resizing-your-parallels-3-0-disk-image/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve just upgraded to Parallels 3.0 but you realize that your virtual HD is almost full. Well, no problem: luckily there&#8217;s this ImageTool that allows you to resize disk images&#8230; uhm&#8230; no, wait&#8230; can&#8217;t find it&#8230; but&#8230; but&#8230; I was 100%25 sure it was here! :-O</p>
<p>Know the feeling? <img src='http://tellini.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Sadly, in version 3.0 they removed this useful tool. Too bad that the disk image format has changed as well since v2.5, thus you can&#8217;t even downgrade just to do the resizing if you started your virtual OS with the new version.</p>
<p>Well, yesterday a certain Randyp posted <a href="http://forum.parallels.com/thread13738.html" >an easy solution to this problem</a>, which does the trick while the Parallels team works on the next update (which should provide a new ImageTool). Even if it requires a lot of space, it works flawlessly.</p>
<p>Kudos to Randyp! <img src='http://tellini.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2007/06/resizing-your-parallels-3-0-disk-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating your website using rsync</title>
		<link>http://tellini.info/2007/01/updating-your-website-using-rsync/</link>
		<comments>http://tellini.info/2007/01/updating-your-website-using-rsync/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 14:31:52 +0000</pubDate>
		<dc:creator>Simone</dc:creator>
				<category><![CDATA[Tips'n'Tricks]]></category>
		<guid isPermaLink="false">http://wp.cr.tellini.org/?p=13</guid>
		<description><![CDATA[Since I&#8217;ve moved my website to a new hosting, I&#8217;ve begun to use rsync instead of ftp to maintain it. There are a couple of major gains in doing so: it&#8217;s more secure: rsync is tunnelled through an SSH connection. &#8230; <a href="http://tellini.info/2007/01/updating-your-website-using-rsync/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve moved my website to a new hosting, I&#8217;ve begun to use <strong>rsync</strong> instead of ftp to maintain it. There are a couple of major gains in doing so:</p>
<ul>
<li>it&#8217;s more secure: rsync is tunnelled through an SSH connection. My previous hoster only supported plain FTP, meaning that everything was in cleartext, including username and password.</li>
<li>it&#8217;s <em>waaay</em> more comfortable: I can do any change I wish on my local copy of the site and when everything is ready I can just launch a mini-script to go live. I don&#8217;t have to worry about forgetting something anymore <img src='http://tellini.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p>So how do I do it?</p>
<p>I&#8217;ve created a simple <em>sync_my_site.sh</em> script like this:</p>
<blockquote>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/bin/sh<br />
<br />
rsync -rltuO \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--progress \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--delay-updates \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--delete --delete-after \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-e 'ssh -i /home/wiz/.ssh/my_hosting_id' \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--exclude-from=/www/site/.rsyncignore \n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/www/site/ user@host:/home/user/site/<br />
<br />
ssh -i /home/wiz/.ssh/my_hosting_id user@host 'chmod -R o+r site'</div></td></tr></tbody></table></div>
</blockquote>
<p>The first parameters (<em>rltuO</em>) tell rsync to recursively update the site, preserving file times and symbolic links and skipping files newer than the local copy.</p>
<p><em>&#8211;delay-updates</em> is useful to replace all the files when the upload is complete, to minimize the probabilities of breaking the site while some users are browsing on it <img src='http://tellini.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><em>&#8211;delete</em> tells rsync to remove files on the remote host that are not present on your local system</p>
<p><em>-e</em> is needed in my case to specify the identity I wish to use for the SSH connection.</p>
<p><em>&#8211;exclude-from</em> points to a text file which contains a list of files that rsync should not consider. It&#8217;s useful to avoid it from uploading your local configuration files overwriting the production values <img src='http://tellini.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Finally, after rsync completes its job, I launch another command on the remote server to fix the file permissions so that the webserver can read all the files. If your production and development servers have the same configuration, you can also skip that line and add <em>-p</em> on rsync&#8217;s command line, so that it will preserve the file permissions as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://tellini.info/2007/01/updating-your-website-using-rsync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

