<?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/"
	>

<channel>
	<title>celsobarriga-dot-com</title>
	<atom:link href="http://www.celsobarriga.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.celsobarriga.com</link>
	<description>Wasting bandwidth in style!</description>
	<pubDate>Fri, 29 May 2009 15:58:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Base64 Encoding and Decoding</title>
		<link>http://www.celsobarriga.com/2009/05/28/base64-encoding-and-decoding/</link>
		<comments>http://www.celsobarriga.com/2009/05/28/base64-encoding-and-decoding/#comments</comments>
		<pubDate>Thu, 28 May 2009 18:10:31 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.celsobarriga.com/?p=131</guid>
		<description><![CDATA[At one time, I needed to encode and decode strings in Base64 but I was on a very old Perl version that does not include the MIME::Base64 core module, nor am I able to install the said module. So, here&#8217;s the source for encoding and decoding Base64 ripped from the MIME::Base64 module:
sub EncodeBase64
{
   [...]]]></description>
			<content:encoded><![CDATA[<p>At one time, I needed to encode and decode strings in Base64 but I was on a very old Perl version that does not include the MIME::Base64 core module, nor am I able to install the said module. So, here&#8217;s the source for encoding and decoding Base64 ripped from the MIME::Base64 module:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#800000; font-weight:bold; '>sub </span>EncodeBase6<span style='color:#008c00; '>4</span>
<span style='color:#800080; '>{</span>
    <span style='color:#800000; font-weight:bold; '>my</span> $s <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>shift</span> <span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>my</span> $r <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>''</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>while</span><span style='color:#808030; '>(</span> $s <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#0000e6; '> </span><span style='color:#800000; '>/</span><span style='color:#808030; '>(</span><span style='color:#808030; '>.</span><span style='color:#0000e6; '>{1,45}</span><span style='color:#808030; '>)</span><span style='color:#800000; '>/</span><span style='color:#800000; font-weight:bold; '>gs</span> <span style='color:#808030; '>)</span><span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>chop</span><span style='color:#808030; '>(</span> $r <span style='color:#808030; '>.</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>substr</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>pack</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>"u"</span><span style='color:#808030; '>,</span>$1<span style='color:#808030; '>)</span><span style='color:#808030; '>,</span><span style='color:#008c00; '>1</span><span style='color:#808030; '>)</span> <span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>my</span> $pad<span style='color:#808030; '>=</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>3</span><span style='color:#808030; '>-</span><span style='color:#800000; font-weight:bold; '>length</span><span style='color:#808030; '>(</span>$s<span style='color:#808030; '>)</span><span style='color:#808030; '>%</span><span style='color:#008c00; '>3</span><span style='color:#808030; '>)</span><span style='color:#808030; '>%</span><span style='color:#008c00; '>3</span><span style='color:#800080; '>;</span>
    $r <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span> <span style='color:#800000; font-weight:bold; '>tr</span><span style='color:#800000; '>|</span><span style='color:#0000e6; '>` </span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>_</span><span style='color:#800000; '>|</span><span style='color:#0000e6; '>AA</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>Za</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>z0</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>9+/</span><span style='color:#800000; '>|</span><span style='color:#800080; '>;</span>
    $r<span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#800000; '>/</span><span style='color:#808030; '>.</span><span style='color:#0000e6; '>{</span><span style='color:#0000e6; '>$pad</span><span style='color:#0000e6; '>}</span><span style='color:#808030; '>$</span><span style='color:#800000; '>/</span><span style='color:#0000e6; '>"="x</span><span style='color:#0000e6; '>$pad</span><span style='color:#800000; '>/</span><span style='color:#800000; font-weight:bold; '>e</span> <span style='color:#800000; font-weight:bold; '>if</span> $pad<span style='color:#800080; '>;</span>
    $r<span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#800000; font-weight:bold; '>s</span><span style='color:#800000; '>/</span><span style='color:#808030; '>(</span><span style='color:#808030; '>.</span><span style='color:#0000e6; '>{1,72}</span><span style='color:#808030; '>)</span><span style='color:#800000; '>/</span><span style='color:#0000e6; '>$1</span><span style='color:#0f69ff; '>\n</span><span style='color:#800000; '>/</span><span style='color:#800000; font-weight:bold; '>g</span><span style='color:#800080; '>;</span>
    $r<span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span> 

<span style='color:#800000; font-weight:bold; '>sub </span>DecodeBase6<span style='color:#008c00; '>4</span>
<span style='color:#800080; '>{</span>
    <span style='color:#800000; font-weight:bold; '>my</span> $d <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>shift</span><span style='color:#800080; '>;</span>
    $d <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span> <span style='color:#800000; font-weight:bold; '>tr</span><span style='color:#800000; '>!</span><span style='color:#0000e6; '>A</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>Za</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>z0</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>9+/</span><span style='color:#800000; '>!</span><span style='color:#800000; '>!</span><span style='color:#800000; font-weight:bold; '>cd</span><span style='color:#800080; '>;</span>
    $d <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span> <span style='color:#800000; font-weight:bold; '>s</span><span style='color:#800000; '>/</span><span style='color:#0000e6; '>=</span><span style='color:#808030; '>+</span><span style='color:#808030; '>$</span><span style='color:#800000; '>/</span><span style='color:#800000; '>/</span><span style='color:#800080; '>;</span>
    $d <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span> <span style='color:#800000; font-weight:bold; '>tr</span><span style='color:#800000; '>!</span><span style='color:#0000e6; '>A</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>Za</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>z0</span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>9+/</span><span style='color:#800000; '>!</span><span style='color:#0000e6; '> </span><span style='color:#800000; font-weight:bold; '>-</span><span style='color:#0000e6; '>_</span><span style='color:#800000; '>!</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>my</span> $r <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>''</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>while</span><span style='color:#808030; '>(</span> $d <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#0000e6; '> </span><span style='color:#800000; '>/</span><span style='color:#808030; '>(</span><span style='color:#808030; '>.</span><span style='color:#0000e6; '>{1,60}</span><span style='color:#808030; '>)</span><span style='color:#800000; '>/</span><span style='color:#800000; font-weight:bold; '>gs</span> <span style='color:#808030; '>)</span><span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>my</span> $len <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>chr</span><span style='color:#808030; '>(</span><span style='color:#008c00; '>32</span> <span style='color:#808030; '>+</span> <span style='color:#800000; font-weight:bold; '>length</span><span style='color:#808030; '>(</span>$1<span style='color:#808030; '>)</span><span style='color:#808030; '>*</span><span style='color:#008c00; '>3</span><span style='color:#808030; '>/</span><span style='color:#008c00; '>4</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        $r <span style='color:#808030; '>.</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>unpack</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>"u"</span><span style='color:#808030; '>,</span> $len <span style='color:#808030; '>.</span> $1 <span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    $r<span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2009/05/28/base64-encoding-and-decoding/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Skydiving video</title>
		<link>http://www.celsobarriga.com/2009/05/25/skydiving-video/</link>
		<comments>http://www.celsobarriga.com/2009/05/25/skydiving-video/#comments</comments>
		<pubDate>Mon, 25 May 2009 14:40:08 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.celsobarriga.com/?p=119</guid>
		<description><![CDATA[Look what I did last weekend! I went for a tandem skydive at Pepperell, MA on May 24th, 2009. What a rush; it was an awesome experience!

]]></description>
			<content:encoded><![CDATA[<p>Look what I did last weekend! I went for a tandem skydive at Pepperell, MA on May 24th, 2009. What a rush; it was an awesome experience!</p>
<p><object classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" width="480" height="288" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"><param name="enablejavascript" value="true" /><param name="src" value="/wpress/wp-content/uploads/2009/05/CelsoSkydive.m4v" /><embed type="video/quicktime" width="480" height="288" src="/wpress/wp-content/uploads/2009/05/CelsoSkydive.m4v" enablejavascript="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2009/05/25/skydiving-video/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Read string from stdin using fgets</title>
		<link>http://www.celsobarriga.com/2009/02/26/read-string-from-stdin-using-fgets/</link>
		<comments>http://www.celsobarriga.com/2009/02/26/read-string-from-stdin-using-fgets/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 19:44:37 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://www.celsobarriga.com/?p=80</guid>
		<description><![CDATA[#include &#60;stdio.h>
#include &#60;string.h>

int main(void)
{
  char str[80];
  int i;

  printf("Enter a string: ");
  fgets(str, 10, stdin);

  /* remove newline, if present */
  i = strlen(str)-1;
  if( str[ i ] == '\n')
      str[i] = '\0';

  printf("This is your string: %s", str);

  return 0;
}

]]></description>
			<content:encoded><![CDATA[<pre style='color:#000000;background:#ffffff;'><span style='color:#004a43; '>#</span><span style='color:#004a43; '>include </span><span style='color:#800000; '>&lt;</span><span style='color:#40015a; '>stdio.h</span><span style='color:#800000; '>></span>
<span style='color:#004a43; '>#</span><span style='color:#004a43; '>include </span><span style='color:#800000; '>&lt;</span><span style='color:#40015a; '>string.h</span><span style='color:#800000; '>></span>

<span style='color:#800000; font-weight:bold; '>int</span> <span style='color:#400000; '>main</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>void</span><span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
  <span style='color:#800000; font-weight:bold; '>char</span> str<span style='color:#808030; '>[</span><span style='color:#008c00; '>80</span><span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>int</span> i<span style='color:#800080; '>;</span>

  printf<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Enter a string: </span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
  fgets<span style='color:#808030; '>(</span>str<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#603000; '>stdin</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

  <span style='color:#696969; '>/* remove newline, if present */</span>
  i <span style='color:#808030; '>=</span> strlen<span style='color:#808030; '>(</span>str<span style='color:#808030; '>)</span><span style='color:#808030; '>-</span><span style='color:#008c00; '>1</span><span style='color:#800080; '>;</span>
  <span style='color:#800000; font-weight:bold; '>if</span><span style='color:#808030; '>(</span> str<span style='color:#808030; '>[</span> i <span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span><span style='color:#808030; '>=</span> <span style='color:#0000e6; '>'\n'</span><span style='color:#808030; '>)</span>
      str<span style='color:#808030; '>[</span>i<span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>'\0'</span><span style='color:#800080; '>;</span>

  printf<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is your string: </span><span style='color:#0f69ff; '>%s</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> str<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

  <span style='color:#800000; font-weight:bold; '>return</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2009/02/26/read-string-from-stdin-using-fgets/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to determine DST time changes</title>
		<link>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/</link>
		<comments>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 17:44:28 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2008/02/01/how-to-determine-dst-time-changes/</guid>
		<description><![CDATA[Here&#8217;s how to determine the dates when the Daylight Savings Time changes for a given year (I keep forgetting how to do this.):


zdump -v /etc/localtime&#124;grep 2008

/etc/localtime  Sun Mar  9 06:59:59 2008 UTC =
    Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000
/etc/localtime  Sun Mar  9 07:00:00 2008 UTC =
 [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to determine the dates when the Daylight Savings Time changes for a given year (I keep forgetting how to do this.):</p>
<pre><code>
<blockquote>
zdump -v /etc/localtime|grep 2008

/etc/localtime  Sun Mar  9 06:59:59 2008 UTC =
    Sun Mar 9 01:59:59 2008 EST isdst=0 gmtoff=-18000
/etc/localtime  Sun Mar  9 07:00:00 2008 UTC =
    Sun Mar 9 03:00:00 2008 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  2 05:59:59 2008 UTC =
    Sun Nov 2 01:59:59 2008 EDT isdst=1 gmtoff=-14400
/etc/localtime  Sun Nov  2 06:00:00 2008 UTC =
    Sun Nov 2 01:00:00 2008 EST isdst=0 gmtoff=-18000
</blockquote>

</code></pre>
<p>Obviously, change <strong>2008</strong> to whatever year you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2008/02/01/how-to-determine-dst-time-changes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Uninstall Perl Module</title>
		<link>http://www.celsobarriga.com/2008/01/10/uninstall-perl-module/</link>
		<comments>http://www.celsobarriga.com/2008/01/10/uninstall-perl-module/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 21:00:41 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Notes]]></category>

		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2008/01/10/uninstall-perl-module/</guid>
		<description><![CDATA[Here&#39;s how to cleanly uninstall any Perl module:
#!/usr/local/bin/perl

use ExtUtils::Packlist;
use ExtUtils::Installed;

$ARGV[0] or die "Usage: $0 Module::Name\n";

my $mod = $ARGV[0];

my $inst = ExtUtils::Installed->new();

foreach my $item (sort($inst->files($mod))) {
         print "removing $item\n";
         unlink $item;
}

my $packfile = $inst->packlist($mod)->packlist_file();
print "removing $packfile\n";
unlink $packfile;

]]></description>
			<content:encoded><![CDATA[<p>Here&#39;s how to cleanly uninstall any Perl module:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#696969; '>#!/usr/local/bin/perl</span>

<span style='color:#800000; font-weight:bold; '>use</span> <span style='color:#bb7977; font-weight:bold; '>ExtUtils</span><span style='color:#808030; '>::</span><span style='color:#bb7977; font-weight:bold; '>Packlist</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>use</span> <span style='color:#bb7977; font-weight:bold; '>ExtUtils</span><span style='color:#808030; '>::</span><span style='color:#bb7977; font-weight:bold; '>Installed</span><span style='color:#800080; '>;</span>

$ARGV<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>or</span> <span style='color:#800000; font-weight:bold; '>die</span> <span style='color:#0000e6; '>"Usage: </span><span style='color:#0000e6; '>$0</span><span style='color:#0000e6; '> Module::Name</span><span style='color:#0f69ff; '>\n</span><span style='color:#0000e6; '>"</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>my</span> $mod <span style='color:#808030; '>=</span> $ARGV<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>my</span> $inst <span style='color:#808030; '>=</span> <span style='color:#bb7977; font-weight:bold; '>ExtUtils</span><span style='color:#808030; '>::</span><span style='color:#bb7977; font-weight:bold; '>Installed</span><span style='color:#808030; '>-></span>new<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

<span style='color:#800000; font-weight:bold; '>foreach</span> <span style='color:#800000; font-weight:bold; '>my</span> $item <span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>sort</span><span style='color:#808030; '>(</span>$inst<span style='color:#808030; '>-></span>files<span style='color:#808030; '>(</span>$mod<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span>
         <span style='color:#800000; font-weight:bold; '>print</span> <span style='color:#0000e6; '>"removing </span><span style='color:#0000e6; '>$item</span><span style='color:#0f69ff; '>\n</span><span style='color:#0000e6; '>"</span><span style='color:#800080; '>;</span>
         <span style='color:#800000; font-weight:bold; '>unlink</span> $item<span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span>

<span style='color:#800000; font-weight:bold; '>my</span> $packfile <span style='color:#808030; '>=</span> $inst<span style='color:#808030; '>-></span>packlist<span style='color:#808030; '>(</span>$mod<span style='color:#808030; '>)</span><span style='color:#808030; '>-></span>packlist_file<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>print</span> <span style='color:#0000e6; '>"removing </span><span style='color:#0000e6; '>$packfile</span><span style='color:#0f69ff; '>\n</span><span style='color:#0000e6; '>"</span><span style='color:#800080; '>;</span>
<span style='color:#800000; font-weight:bold; '>unlink</span> $packfile<span style='color:#800080; '>;</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2008/01/10/uninstall-perl-module/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Find Out the Top 10 CPU Hogs</title>
		<link>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/</link>
		<comments>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 21:48:23 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/notes/2007/08/29/85/</guid>
		<description><![CDATA[I found this command useful in finding out which top 10 processes are hogging my CPU resources. Note that this command is specific to the Red Hat flavor of Linux. See the man page for ps for the correct output format to use for your specific platform:

ps -eo pcpu,pid,user,args &#124; sort -k1 -r &#124; head [...]]]></description>
			<content:encoded><![CDATA[<p>I found this command useful in finding out which top 10 processes are hogging my CPU resources. Note that this command is specific to the Red Hat flavor of Linux. See the man page for ps for the correct output format to use for your specific platform:</p>
<pre>
<blockquote><code>ps -eo pcpu,pid,user,args | sort -k1 -r | head -11</code></blockquote>
</pre>
<p>Substitue <code>pcpu</code> above with <code>pmem</code> to see the memory hogs instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2007/08/29/find-out-the-top-10-cpu-hogs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bourne Shell Logging Routine</title>
		<link>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/</link>
		<comments>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 03:20:19 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/notes/2007/08/28/84/</guid>
		<description><![CDATA[Here&#8217;s another logging routine, this one is written in Bourne shell:
#!/bin/sh

log_message() {
    echo `date "+%m/%d/%y %H:%M:%S %Z"` "$1" &#124; tee -a aaa.out
}

log_message "Hello there"
log_message "Goodbye"

Sample output:


08/28/07 23:16:13 EDT Hello there
08/28/07 23:16:13 EDT Goodbye


]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another logging routine, this one is written in Bourne shell:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#696969; '>#!/bin/sh</span>

log_message<span style='color:#808030; '>()</span> <span style='color:#800080; '>{</span>
    <span style='color:#bb7977; font-weight:bold; '>echo</span> <span style='color:#000000; background:#ffffe8; '>`date </span><span style='color:#0000e6; background:#ffffe8; '>"+%m</span><span style='color:#40015a; background:#ffffe8; '>/</span><span style='color:#0000e6; background:#ffffe8; '>%d</span><span style='color:#40015a; background:#ffffe8; '>/</span><span style='color:#0000e6; background:#ffffe8; '>%y %H:%M:%S %Z"</span><span style='color:#000000; background:#ffffe8; '>`</span> <span style='color:#0000e6; '>"</span><span style='color:#0000e6; '>$1</span><span style='color:#0000e6; '>"</span> <span style='color:#e34adc; '>|</span> tee <span style='color:#44aadd; '>-a</span> aaa<span style='color:#800000; font-weight:bold; '>.</span>out
<span style='color:#800080; '>}</span>

log_message <span style='color:#0000e6; '>"Hello there"</span>
log_message <span style='color:#0000e6; '>"Goodbye"</span>
</pre>
<p>Sample output:</p>
<blockquote><p><code>
<pre>
08/28/07 23:16:13 EDT Hello there
08/28/07 23:16:13 EDT Goodbye
</pre>
<p></code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2007/08/28/bourne-shell-logging-routine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Setting MySQL Password</title>
		<link>http://www.celsobarriga.com/2006/08/23/setting-mysql-password/</link>
		<comments>http://www.celsobarriga.com/2006/08/23/setting-mysql-password/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 17:40:47 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2006/08/23/78/</guid>
		<description><![CDATA[To set up root password the first time:
$ mysqladmin -u root password NeWPasSwORd

To change an existing root password:
$ mysqladmin -u root -p oldpassword newpass
Enter password:


To change a normal user password:
$ mysqladmin -u dbuser-p oldpassword newpass

]]></description>
			<content:encoded><![CDATA[<p>To set up root password the first time:</p>
<blockquote><pre><code>$ mysqladmin -u root password NeWPasSwORd</code></pre>
</blockquote>
<p>To change an existing root password:</p>
<blockquote><pre><code>$ mysqladmin -u root -p oldpassword newpass
Enter password:
</code></pre>
</blockquote>
<p>To change a normal user password:</p>
<blockquote><pre><code>$ mysqladmin -u dbuser-p oldpassword newpass</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2006/08/23/setting-mysql-password/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sorting IP Addresses</title>
		<link>http://www.celsobarriga.com/2006/07/13/sorting-ip-addresses/</link>
		<comments>http://www.celsobarriga.com/2006/07/13/sorting-ip-addresses/#comments</comments>
		<pubDate>Thu, 13 Jul 2006 18:12:42 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Notes]]></category>

		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2006/07/13/76/</guid>
		<description><![CDATA[The following will sort an array of IP addresses in @in and the sorted IP addresses will be in @out.
@out = sort {
    pack('C4' => $a =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
    cmp
    pack('C4' => $b =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
} @in;

What this does is it forms a string of four bytes out [...]]]></description>
			<content:encoded><![CDATA[<p>The following will sort an array of IP addresses in @in and the sorted IP addresses will be in @out.</p>
<pre style='color:#000000;background:#ffffff;'>@out <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>sort</span> <span style='color:#800080; '>{</span>
    <span style='color:#800000; font-weight:bold; '>pack</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>'C4'</span> <span style='color:#808030; '>=</span><span style='color:#808030; '>></span> $a <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#0000e6; '> </span><span style='color:#800000; '>/</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#800000; '>/</span><span style='color:#808030; '>)</span>
    <span style='color:#808030; '>cmp</span>
    <span style='color:#800000; font-weight:bold; '>pack</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>'C4'</span> <span style='color:#808030; '>=</span><span style='color:#808030; '>></span> $b <span style='color:#808030; '>=</span><span style='color:#808030; '>~</span><span style='color:#0000e6; '> </span><span style='color:#800000; '>/</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#0f69ff; '>\.</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>\d</span><span style='color:#808030; '>+</span><span style='color:#808030; '>)</span><span style='color:#800000; '>/</span><span style='color:#808030; '>)</span>
<span style='color:#800080; '>}</span> @in<span style='color:#800080; '>;</span>
</pre>
<p>What this does is it forms a string of four bytes out the IP address octet using the <code>pack()</code> function then sorts it lexicographically.</p>
<p>See also <a href="http://www.barriga.net/2004/07/02/27/">Sorting Section Numbers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2006/07/13/sorting-ip-addresses/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Determining the External IP Address</title>
		<link>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/</link>
		<comments>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/#comments</comments>
		<pubDate>Wed, 07 Jun 2006 17:33:15 +0000</pubDate>
		<dc:creator>celso</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://www.barriga.net/2006/06/07/71/</guid>
		<description><![CDATA[Here&#8217;s how to find out your external IP address courtesy of this hint:
http://www.macosxhints.com/article.php?story=20060602180942480


curl --silent http://checkip.dyndns.org
    &#124; awk '{print $6}' &#124; cut -f 1 -d "]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to find out your external IP address courtesy of this hint:</p>
<p><a href="http://www.macosxhints.com/article.php?story=20060602180942480">http://www.macosxhints.com/article.php?story=20060602180942480</a></p>
<blockquote>
<pre><code>
curl --silent http://checkip.dyndns.org
    | awk '{print $6}' | cut -f 1 -d "<"
</code></pre>
</blockquote>
<p>If you are using Apple&#8217;s Airport Extreme Basestation (mine is particularly the Time Capsule and this is where I have tested this), and you have the SNMP interface enabled, you can run the following command</p>
<pre><code>
prompt$ snmpwalk -Os -c public -v 1 192.168.63.1 ipAdEntAddr IpAddress \
    | grep -E -v '(127.0.0|169.254|192.168.63.1)' \
    | cut -d : -f 2 | sed 's/ //g'
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2006/06/07/find-external-ip-address/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
