<?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>a little stupid blog &#187; how-to&#8217;s</title>
	<atom:link href="http://alittlestupid.com/category/how-tos/feed/" rel="self" type="application/rss+xml" />
	<link>http://alittlestupid.com</link>
	<description>join the revolution... be a little stupid</description>
	<lastBuildDate>Thu, 21 Jan 2010 18:03:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Howto: Mount New File System To Running Solaris 10 Zone</title>
		<link>http://alittlestupid.com/2009/10/22/howto-mount-new-file-system-to-running-solaris-10-zone/</link>
		<comments>http://alittlestupid.com/2009/10/22/howto-mount-new-file-system-to-running-solaris-10-zone/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 19:17:14 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[Solaris]]></category>
		<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/?p=499</guid>
		<description><![CDATA[I recently came across the need to mount a new file system to a Solaris 10 non-global zone without rebooting the actual zone. There are other ways to accomplish this same task but most of the solutions I&#8217;ve found required rebooting the non-global zone. Unfortunately, we could not take an outage by rebooting the non-global [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across the need to mount a new file system to a Solaris 10 non-global zone without rebooting the actual zone.  There are other ways to accomplish this same task but most of the solutions I&#8217;ve found required rebooting the non-global zone.  Unfortunately, we could not take an outage by rebooting the non-global zone yet the file system needed to be added to the zone.</p>
<p>The method below describes a way in which you can mount a new file system (UFS) to a running Solaris 10 zone without the need of a reboot.  </p>
<ul>
<strong>Assumptions:</strong>
<li>All commands need to be run from the global zone as the root user unless otherwise specified.</li>
<p><strong>Prerequisites:</strong>
<li>A Solaris 10 host with at least one running non-global zone.</li>
<p><strong>Limitations:</strong>
<li>You can not unmount the file system from the non-global zone.  Some say this is a benefit <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p>Lets get started!</p>
<ol>
<ul>Log into the global zone and create the new file system like you normally would.  In this example, I use SVM to create a new metadevice (d1000), one way mirror (d2000), and a 1Gig soft partition (d2001).  Your mileage may vary.  </p>
<blockquote><p>
<code><br />
	# metainit d1000 1 1 c1t5d0s0 -i 128k<br />
	# metainit d2000 -m d1000<br />
	# metainit d2001 -p d2000 1g<br />
	# echo y | newfs -i 8192 /dev/md/rdsk/d2001<br />
</code>
</p></blockquote>
</ul>
<ul>Create the block and character devices for the zone.  Run &#8220;ls -lL&#8221; against the newly created soft partition (d2001) to find the major and minor character and block values.</p>
<blockquote><p>
       <code><br />
	# ls -lL /dev/md/*dsk/d2001<br />
        brw-r----- 1 root sys 85, 2001 Oct  6 13:46 /dev/md/dsk/d2001<br />
	crw-r----- 1 root sys 85, 2001 Oct  6 13:47 /dev/md/rdsk/d2001<br />
        </code>
        </p></blockquote>
<p><strong>NOTE:</strong> The major and minor values are <strong>85</strong> and <strong>2001</strong>, respectively.  Notice that the &#8220;dsk&#8221; device is a <em>&#8220;block-type&#8221;</em> file and &#8220;rdsk&#8221; device is a <em>&#8220;character-type&#8221;</em> file.</p>
</ul>
<ul>Run <a href="http://www.phy.ohiou.edu/cgi-bin/man-cgi.sol?mknod+1M">mknod</a> to create the two special files for the zone.  Keep in mind that the name of the two files need to be saved down the myzone device path.  </p>
<blockquote><p>
       <code><br />
         # mknod /zones/myzone1/dev/md/dsk/d2001 b 85 2001<br />
         # mknod /zones/myzone1/dev/md/rdsk/d2001 c 85 2001<br />
        </code>
        </p></blockquote>
</ul>
<ul>Correct the permissions and ownerships of the new d2001 block-type and character-type files. </p>
<blockquote><p>
       <code><br />
         # chmod 640 /zones/myzone1/dev/md/*dsk/d2001<br />
         # chown root:root /zones/myzone1/dev/md/*dsk/d2001<br />
        </code>
        </p></blockquote>
</ul>
<ul>Create a mount point in the &#8220;myzone1&#8243; non-global zone.</p>
<blockquote><p>
       <code><br />
       # mkdir /zones/myzone1/root/wandisimo<br />
       </code>
       </p></blockquote>
</ul>
<ul>Confirm its not already mounted</p>
<blockquote><p>
       <code><br />
         # mount | grep wandisimo<br />
       </code>
       </p></blockquote>
<p>You should not get anything back from the command above.
</ul>
<ul>Mount the file system </p>
<blockquote><p>
       <code><br />
         # mount /dev/md/dsk/d2001 /zones/myzone1/root/wandisimo<br />
       </code>
       </p></blockquote>
<p>You are probably thinking to your self, <em>&#8220;Why couldn&#8217;t we just skip to this step and be done with it?&#8221;</em>  From my testing, if the block and character files are not created down the &#8220;myzone1&#8243; device path first, it fails to mount.   If you were to add the soft partition using zonecfg or by adding it to the zone XML file then rebooting the non-global zone, the boot process actually creates the block and character device for you.  </p>
<p><strong>NOTE:</strong> Even though the file system successfully gets mounted, it will not show up in a &#8220;df&#8221; output as actually being mounted.
</ul>
<ul>Check to see if its mounted</p>
<blockquote><p>
       <code><br />
         # df -h | grep wandisimo<br />
        </code>
       </p></blockquote>
<p>You should not get any output.
</ul>
<ul>Confirm the file system is in fact mounted by running the mount command</p>
<blockquote><p>
       <code><br />
         # mount | grep wandisimo<br />
/zones/myzone1/root/wandisimo on /dev/md/dsk/d2001    read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=15407d3 on Tue Oct  6 14:11:45 2009<br />
        </code>
       </p></blockquote>
</ul>
<ul>Log into the running non-global zone (myzone1) to confirm the file system is indeed mounted</p>
<blockquote><p>
       <code><br />
         # zlogin myzone1<br />
         (myzone1)# df -h /wandisimo<br />
         Filesystem             size   used  avail capacity  Mounted on<br />
         /wandisimo            1008M   1.0M   947M     1%    /wandisimo<br />
        </code>
       </p></blockquote>
</ul>
<p><strong>Done.  No need to reboot the non-global zone!</strong>
</ol>
<p>If you would like to make this permanent, you will need to add it to the /etc/vfstab in the global zone.</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2009/10/22/howto-mount-new-file-system-to-running-solaris-10-zone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find files and calculate total disk space usage</title>
		<link>http://alittlestupid.com/2009/04/01/find-files-and-calculate-total-disk-space-usage/</link>
		<comments>http://alittlestupid.com/2009/04/01/find-files-and-calculate-total-disk-space-usage/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:40:09 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tips-n-tricks]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/?p=439</guid>
		<description><![CDATA[At work, I have a Solaris SVM Disk Suite device which houses many end user files. Over the past year, this file system has grown by over 75%. Initially, I was growing the file system as it reached capacity but one thing I noticed over the years as a sysadmin is that users will always [...]]]></description>
			<content:encoded><![CDATA[<p>At work, I have a Solaris SVM Disk Suite device which houses many end user files.  Over the past year, this file system has grown by over 75%.  Initially, I was growing the file system as it reached capacity but one thing I noticed over the years as a sysadmin is that users will always use the disk space if its there.  Business reasons restrict applying quotas to the file system so I decided to do some upfront grunt work instead.</p>
<p>A few du/find combinations later, I noticed that 80% of the disk space was being consumed by compressed pdf files in gzip format.  Furthermore, most of the pdf files were over a year old.  These files are certainly candidates for deletion but I will let the business decide that one.  </p>
<p>Here is how you can find all gzip&#8217;ed files in the current working directory which have not been modified in over a year and calculate the total disk space consumed.</p>
<blockquote><p>
[user@host ~] # uname -a<br />
SunOS host 5.10 Generic_127111-03 sun4u sparc SUNW,Sun-Fire-V890<br />
[user@host ~] # cd /some_filesystem/<br />
[user@host ~] # find . -name &#8216;*.pdf.gz&#8217; -type f -mtime +365 -ls | awk &#8216;{ sum += $7 } END { kb = sum / 1024; mb = kb / 1024; gb = mb / 1024; printf &#8220;%.0f MB (%.2fGB) disk space used\n&#8221;, mb, gb}&#8217;
</p></blockquote>
<p>Once you&#8217;ve discovered how much disk space those files are consuming, the next step is up to you but if you had too, you could just as easily remove those offending files.  I wont go into preaching about having properly backed up host.</p>
<p>Modify the find command to remove the files:</p>
<blockquote><p>
[user@host ~] # find . -name &#8216;*.pdf.gz&#8217; -type f -mtime +365 -exec rm -rf {} \;
</p></blockquote>
<p>Argument list too long?  Pipe stdout to xargs.</p>
<blockquote><p>
[user@host ~] # find . -name &#8216;*.pdf.gz&#8217; -type f -mtime +365 -print | xargs rm -rf
</p></blockquote>
<p>Like always, your mileage will vary.    </p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2009/04/01/find-files-and-calculate-total-disk-space-usage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IVR Cheat Sheet</title>
		<link>http://alittlestupid.com/2005/11/29/ivr-cheat-sheet/</link>
		<comments>http://alittlestupid.com/2005/11/29/ivr-cheat-sheet/#comments</comments>
		<pubDate>Tue, 29 Nov 2005 05:57:24 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tips-n-tricks]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/?p=73</guid>
		<description><![CDATA[Is it just me or do you hate it when you call the phone company, cable provider, or a big wig service shop and get a dumb computer answering the phone? With older systems, entering a simple &#8220;0&#8243; would of immediately transfered you to a human. Not so with most modern automated answering systems. Instead, [...]]]></description>
			<content:encoded><![CDATA[<p>Is it just me or do you hate it when you call the phone company, cable provider, or a big wig service shop and get a dumb computer answering the phone?  With older systems, entering a simple &#8220;0&#8243; would of immediately transfered you to a human.  Not so with most modern automated answering systems.  Instead, you are greeted with a sometimes annoying computer attempting to sound like a human.  Well,  Paul English over at <a href="http://paulenglish.com/" title="http://paulenglish.com/">http://paulenglish.com/</a> has a nice little &#8220;cheat sheet&#8221; that lists all sorts of methods which enable you to speak to a live person, outsourced or not&#8230; <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p> Whats an &#8220;IVR&#8221;?  According to Paul English:</p>
<blockquote><p><code>
<p>
The term IVR stands for "Interactive Voice Response", the fancy name for annoying computers who answer most phones these days.
</p>
<p></code></p></blockquote>
<p>Go to the <a href="http://paulenglish.com/ivr/" title="IVR Cheat Sheet">&#8220;IVR Cheat Sheet&#8221;</a> and stick it to the man!</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/11/29/ivr-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Portable USB Programs</title>
		<link>http://alittlestupid.com/2005/10/13/my-portable-usb-programs/</link>
		<comments>http://alittlestupid.com/2005/10/13/my-portable-usb-programs/#comments</comments>
		<pubDate>Thu, 13 Oct 2005 06:31:48 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[tips-n-tricks]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/?p=65</guid>
		<description><![CDATA[This post was sorta inspired from a couple recent questions I was asked by my good buddy Stevie-D. Well, I guess I should say the his questions made me get off my &#8220;fourth point of contact&#8221; and finally create the post that I have been meaning to do all along. A post about all the [...]]]></description>
			<content:encoded><![CDATA[<p>This post was sorta inspired from a couple recent questions I was asked by my good buddy <a href="http://stephendurham.com" title="Stevie-D's site">Stevie-D</a>.  Well, I guess I should say the his questions made me get off my <a href="http://www.doubletongued.org/index.php/dictionary/fourth_point_of_contact/" title="Definition for 'fourth point of contact'">&#8220;fourth point of contact&#8221;</a> and finally create the post that I have been meaning to do all along.  A post about all the portable USB apps that I use on my own USB stick!</p>
<p>What does this do?  Well, it allows me to carry a fully customized computing environment to any PC running <a href="http://www.microsoft.com/" title="Microsoft Windows">M$ Windoze</a>.  Meaning, I can take my USB stick with me, slap it into an available USB port on the host PC, run all my apps, and have the same friendly and familiar desktop where ever I so choose.</p>
<p>With this post, I not only help my buddy Stevie-D but if I ever loose my USB drive, I can come back and use this post as a reference in an attempt to recreate what I once had.  Granted, I would be out a USB drive but&#8230;  Well, without further ado,  here is an ever growing list of all the portable USB apps that have come to call my &#8220;512Meg <a href="http://www.sandisk.com/retail/cruzer-mini.asp" title="Sandisk Cruzer Mini">Sandisk Cruzer Mini</a>&#8221; home.    </p>
<p>For me, these are the &#8220;must haves&#8230;&#8221;</p>
<ul>
<li>Web Browser: <a href="http://johnhaller.com/jh/mozilla/portable_firefox/" title="Portable Firefox">Portable Firefox</a></li>
<li>IM Client: <a href="http://www.ceruleanstudios.com/" title="Trillian">Trillian</a> with help from <a href="http://www.trilliananywhere.com/" title="Trillian Anywhere">Trillian Anywhere</a></li>
<li>Desktop Replacement: <a href="http://bb4win.sourceforge.net/bblean/" title="bbLean">bbLean</a></li>
<li>Clipboard Manager: <a href="http://www.nakka.com/soft/clcl/index_eng.html" title="CLCL">CLCL</a></li>
<li>File Management: <a href="http://zabkat.com/" title="xplorer2">xplorer2</a></li>
<li>SSH Client: <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" title="PuTTY">PuTTY</a></li>
<li>SCP Client: <a href="http://winscp.net/" title="WinSCP">WinSCP</a>
    </li>
<li>Application Launcher: <a href="http://www.pegtop.de/start/" title="PStart">PStart</a><br /><em>More on this jewel below.</em></li>
</ul>
<p><span id="more-65"></span></p>
<p>The &#8220;Nice to have&#8230;&#8221; list</p>
<ul>
<li>Sticky Notes Replacement: <a href="http://atnotes.free.fr/" title="ATnotes">ATnotes</a></li>
<li>Password Keeper: <a href="http://keepass.sourceforge.net/" title="KeePass">KeePass</a> </li>
<li>Office Suite: <a href="http://johnhaller.com/jh/useful_stuff/portable_openoffice/" title="Portable OpenOffice">Portable OpenOffice</a></li>
<li>Graphic Viewer: <a href="http://www.irfanview.com/">IrfanView</a></li>
<li>FTP Client: <a href="http://filezilla.sourceforge.net/" title="FileZilla">FileZilla</a> </li>
<li>Notepad Replacement: <a href="http://notepad-plus.sourceforge.net/" title="Notepad++">Notepad++</a></li>
<li>POP3 Client: <a href="http://www.nakka.com/soft/npop/index_eng.html" title="nPOP">nPOP</a></li>
<li>Port Monitor: <a href="http://www.sysinternals.com/Utilities/TcpView.html" title="TCPView">TCPView</a></li>
<li>Remote Desktop: <a href="http://www.tightvnc.com/" title="TightVNC">TightVNC</a></li>
<li>UNIX Tools: <a href="http://thinstall.com/help/?unixtooldemo.htm" title="UNIX Tools">UNIX Tools</a></li>
<li>Text Editor: <a href="http://www.winvi.de/en/" title="WinVi">WinVi</a></li>
<li>Audio Player: <a href="http://www.un4seen.com/xmplay.html" title="XMPlay">XMPlay</a></li>
<li>CD Ripper: <a href="http://cdexos.sourceforge.net" title="CDex">CDex</a></li>
<li>PDF Reader: <a href="http://www.foxitsoftware.com/" title="Foxit PDF Reader">Foxit PDF Reader</a></li>
<li>Start up monitor: <a href="http://mlin.net/StartupCPL.shtml" title="Startup Control Panel">Startup Control Panel</a></li>
</ul>
<p>All the apps listed above have their own installation procedure to get them installed on your portable media USB drive.  However, most come packaged as a <em>.zip</em> file where all you would have to do is extract the contents to a directory of your choice (prefferably on your USB drive <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) and you&#8217;re done!  When that is not the case, follow the instructions detailed in the respective apps&#8217; website or readme files.  I can personally attest that all the apps I have listed here run perfectly fine from my USB drive.</p>
<p>You might also want to consider some of these apps.  I don&#8217;t use them for one reason or another but you might think otherwise.</p>
<ul>
<li>PIMs/organizers: <a href="http://www.essentialpim.com/" title="EssentialPIM">EssentialPIM</a>, <a href="http://www.mozilla.org/projects/calendar/sunbird.html" title="Sunbird">Sunbird</a></li>
<li>Email: <a href="http://jbmail.pc-tools.net/"title="JBMail">JBMail</a> , <a href="http://johnhaller.com/jh/mozilla/portable_thunderbird/" title="Portable Thunderbird">Portable Thunderbird</a>, <a href="http://www.pocosystems.com" title="EmailVoyager">EmailVoyager</a>, <a href="http://www.pocosystems.com" title="PocoMail PE">PocoMail PE</a></li>
<li>Web Authoring: <a href="http://www.nvu.com/" title="NVU">NVU</a></li>
<li>Chat/IM: <a href="http://www.miranda-im.org/" title="MirandaIM">MirandaIM</a></li>
</ul>
<p>Here is a list of sites where you can get more software to run on your USB drive:</p>
<ul>
<li><a href="http://loosewire.typepad.com/blog/2005/03/a_directory_of_.html" title="loose wire blog">loose wire blog</a></li>
<li><a href="http://www.no-install.com/" title="no-install">no-install website</a></li>
<li><a href="http://www.portablefreeware.com/" title="Portable Freeware Collection">Portable Freeware Collection</a></li>
</ul>
<p>So when it comes to launching these portable apps, what do you do?  Use, what I believe, is an essential tool for &#8220;<em>happy USB portable app&#8217;ing</em> called <a href="http://www.pegtop.de/start/" title="PStart">PStart</a>.  When launched, it can be configured to launch any app from a USB drive and even apps installed on your local PC.  On my USB drive, I have all my apps in a root directory called &#8220;Portable Apps&#8221; with each <em>installed</em> app having its own sub-directory.  PStart unifies all these sub-directories and creates a one stop launch pad instead of having to tediously navigate into each sub-directory just to launch an app.  Anyway, once you use it, you wont go back!  </p>
<p>Thats it for now, enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/10/13/my-portable-usb-programs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PocketMod</title>
		<link>http://alittlestupid.com/2005/09/14/pocketmod/</link>
		<comments>http://alittlestupid.com/2005/09/14/pocketmod/#comments</comments>
		<pubDate>Wed, 14 Sep 2005 04:49:55 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tips-n-tricks]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/?p=57</guid>
		<description><![CDATA[Ever wanted to keep yourself organized but didn&#8217;t have the means to get yourself one of those fancy PDA&#8217;s or smartphones? Yeah, me either! If you are like me (broke) and carry several pieces of sticky notes around as reminders/todo lists, then you might be interested in the website called PocketMod (http://www.pocketmod.com/). This idea isn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to keep yourself organized but didn&#8217;t have the means to get yourself one of those fancy PDA&#8217;s or smartphones?  Yeah, me either!  If you are like me (broke) and carry several pieces of sticky notes around as reminders/todo lists, then you might be interested in the website called PocketMod <a href="http://www.pocketmod.com/" title="PocketMod">(http://www.pocketmod.com/)</a>.</p>
<p>This idea isn&#8217;t new since there are several other websites that offer this type of service.  If you have heard of &#8220;<a href="http://www.slowburnproductions.com/2005/09/hipster-pda-tips-for-people-obsessed.html" title="Hipster PDA's">Hipster PDA&#8217;s</a>&#8221; then you know what I am talking about.  What makes PoketMod different is that it enables you create a custom layout from pre-formatted pages tailored to suit your needs all from their website. </p>
<p><img src="http://alittlestupid.com/stupid/wordpress/showpic.php?pic=pocketmod.jpg" width="250" height="164" alt="PocketMod.com" title="PocketMod.com" /></p>
<p>To think that this much organization comes from a simple folded up piece of paper&#8230;  well, try it and see for yourself.  That is, unless you are a rich snob and owns a real PDA.  <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/09/14/pocketmod/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment a block of code in vi</title>
		<link>http://alittlestupid.com/2005/08/24/comment-a-block-of-code-in-vi/</link>
		<comments>http://alittlestupid.com/2005/08/24/comment-a-block-of-code-in-vi/#comments</comments>
		<pubDate>Wed, 24 Aug 2005 09:00:59 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>
		<category><![CDATA[tips-n-tricks]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/?p=50</guid>
		<description><![CDATA[Having to comment a block of code in a script and/or program can suck if you do it the wrong way. Yes, I am talking about the tedious: SHIFT+3 (gets you the &#8220;#&#8221; sign) Down Arrow Left Arrow Wash, Rinse and Repeat for as many lines that you wish to comment out. This can be [...]]]></description>
			<content:encoded><![CDATA[<p>Having to comment a block of code in a script and/or program can suck if you do it the wrong way.  Yes, I am talking about the tedious:</p>
<ul>
<li>SHIFT+3 <em>(gets you the &#8220;#&#8221; sign)</em></li>
<li>Down Arrow</li>
<li>Left Arrow</li>
<li>Wash, Rinse and Repeat for as many lines that you wish to comment out.</li>
</ul>
<p>This can be a daunting task even for the quickest of fingers out there.  Many of you might be thinking, &#8220;<em>But I only comment a few lines when I have to do it so it really doesn&#8217;t bother me to do it the tedious way</em>&#8220;.   Well, if thats the case then skip this tip since its not for you.  Otherwise, if you have to comment 20, 30, or 100+ lines of any file in vi or just want to learn something new, then read on.</p>
<p><span id="more-50"></span></p>
<p>This is how you comment in a block of code using vi:</p>
<ol>
<li>Open any text file using vi</li>
<li>Enter the following code into vi&#8217;s command mode: <br />
<code><br />
<blockquote>
<p style="first">
        :START,ENDs/^/# /
</p>
</blockquote>
<p></code><br />
<em>where <strong>START</strong> is the starting line number and <strong>END</strong> is the ending line number.</em></li>
<li>Thats it!</li>
</ol>
<p>So if I wanted to comment all the lines starting from 10 through 30 in my test file, I would use:<br />
<code><br />
<blockquote>
<p style="first">
:10,30s/^/# /
</p>
</blockquote>
<p></code><br />
This will comment lines 10 through line 30 of the current buffer (file).  This same principle can be used for indentation and/or un-commenting said file.  Obviously, just replace ^ and # with the appropriate entries.  I know what you are thinking, &#8220;<em>This is cool and all but how do I get the exact line numbers to comment?</em>&#8221;  Well, check out my <a href="http://alittlestupid.com/2005/07/21/vi-notes/" title="vi notes">&#8220;vi notes&#8221;</a> from a previous posting under the &#8220;vi Options&#8221;.  <em>(<strong>HINT:</strong> :set nu)</em> While you are there, check out the rest of the vi tips. I&#8217;m sure you will learn something, <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Have fun vi&#8217;ing!</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/08/24/comment-a-block-of-code-in-vi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH Tips</title>
		<link>http://alittlestupid.com/2005/04/27/ssh-tips/</link>
		<comments>http://alittlestupid.com/2005/04/27/ssh-tips/#comments</comments>
		<pubDate>Wed, 27 Apr 2005 09:05:12 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/2005/04/27/ssh-tips/</guid>
		<description><![CDATA[Just yesterday, a fellow co-worker was having a tough time figuring out the syntax to a very complex command. At its most basic level, the command would run a &#8220;bash for loop&#8221;, tar up a list of directories and pipe the output to a remote host via SSH keeping all the proper file ownerships and [...]]]></description>
			<content:encoded><![CDATA[<p>Just yesterday,  a fellow co-worker was having a tough time figuring out the syntax to a very complex command.  At its most basic level, the command would run a &#8220;bash for loop&#8221;, tar up a list of directories and pipe the output to a remote host via SSH keeping all the proper file ownerships and permissions intact.  We use those types of commands all the time here at work to do network backups but once in a while everyone gets a &#8220;brain fart&#8221;.  Once I was able to figure out the issue with the syntax, I told myself that I was going to document it one day.  Well, that day is today. <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</p>
<p>The tips below are very basic examples of the issue we experienced above.  If you know what <a href="http://openssh.com/">SSH</a> is, then these tips are for you.  Otherwise, I suggest you skip this blog entry all together since it wont matter to you much.  These tips are some of my own collection of all the SSH commands that I have used throughout the years of being a Linux Jr. Systems Administrator.  They all have been tested and known to work with OpenSSH 3.8p1. or later.  If you have a better way of doing it, I would like to know.  </p>
<p>NOTE: The dash &#8220;-&#8221; is used to reference either standard input or standard output depending on where its being used in the command.  Also, please replace all variables that start with a &#8220;$&#8221; with their respective value.  I have tried to make the variable names as obvious as possible.  Let me know if I need to explain them.</p>
<p>Ok, On to the tips:</p>
<p><em>PUSH it!</em></p>
<ol>
<li>Tar up a directory and push it to a remote host via SSH.<br />
       <code><br />
$ tar cpf - $local_dir | ssh $user@$remote_host "tar -C $remote_dir -xpf -"<br />
       </code><br />
The above command will tar up a $local_dir and save it to stdin.  It&#8217;s then piped to SSH which then makes the connection to the $remote_host and extracts the contents to $remote_dir.  The <strong>&#8220;-C&#8221;</strong> option tells tar where to extract the contents too.  </p>
<p>You can even copy the entire contents of a directory from $local_host and extract them on the $remote_host and keep all the ownerships and permissions intact.  Assume that the directory you wish to copy is located in /home/$user/www/<br />
<code><br />
$ cd /home/$user/; tar cpfz - www/ | ssh $user@$remote_host "cd /home/$user/; mv www www.bak; tar xpfz -"<br />
</code><br />
Same as the first example but before it extracts the contents of stdin, it renames the &#8220;www&#8221; directory to &#8220;www.bak&#8221; on the $remote_host  first.  The potential is endless.
</li>
</ol>
<p><em>PULL it!</em></p>
<ol>
<li>Connect to a remote host and retrieve a file<br />
<code><br />
$ ssh $user@$remote_host cat $remote_file > $local_file<br />
</code><br />
I know, I know&#8230; this is what SCP is for but this is cooler.  Since OpenSSH allows you to add options after the connection string, you can execute any command on the $remote_host locally.  The command above runs SSH from your local machine, connects to the $remote_host and since we gave SSH additional options after the connections string, it &#8220;cat&#8217;s&#8221; the $remote_file and redirects the output to the local machine to a file called $local_file.  This will work with pretty much any file type including tarballs, images, and even audio/video files.
</li>
</ol>
<p style="font-style: italic"><strong>UPDATE 04-28-2005: </strong> Click on the &#8220;more&#8221; link below to see it.</p>
<p><span id="more-13"></span></p>
<p><em>Executing Commands</em></p>
<ol>
<li>Listing files remotely<br />
<code><br />
$ ssh $user@$remote_host 'ls -al /etc/'<br />
</code><br />
If you have the privileges, this command logs into $remote_host and lists the contents of the <strong>/etc</strong> directory and prints it to your screen without actually starting an interactive session on $remote_host.
</li>
<li>Edit a file remotely<br />
<code><br />
$ ssh -t $user@$remote_host 'vi /etc/passwd'<br />
</code><br />
This will open the remote file &#8220;/etc/passwd&#8221; locally which then can be edited then saved remotely.  The man pages say that the <strong>&#8220;-t&#8221;</strong> option will:<br />
<code><br />
      Force pseudo-tty allocation.  This can be used<br />
     to execute arbitrary screen-based programs on a<br />
     remote machine, which can be very useful, e.g.,<br />
     when implementing menu services.<br />
     Multiple -t options force tty allocation, even<br />
     if ssh has no local tty.<br />
</code>
</li>
</ol>
<p><em>X11Forwarding</em></p>
<ol>
<li>Export your DISPLAY<br />
<code><br />
$ ssh -X $user@$remote_host<br />
</code><br />
At first look, the command above may seem innocent enough until you follow it up with: </p>
<p><code>gaim &#038;</code></p>
<p>and realize that <a href="http://gaim.sourceforge.net/">Gaim</a> is now running on $local_host directly from $remote_host!!  The <em>&#8220;-X&#8221;</em> tells SSH to export the display and to forward &#8220;X&#8221; over the SSH connection.  This is a cool way to run your IM client (or any other app for that matter) from your home machine and have it be displayed on your work box.  That way, if your snooping boss is capturing your network packets, all they will see is the encrypted SSH connection data.  Good luck decrypting that Mr. Boss!  <hint> </hint><hint><br />
</hint></li>
</ol>
<p>Thats it for now.  If I remember more tips and tricks, I will add them here.  If you have a cool SSH trick and/or hack that you would like to share, I would like to know about it. </p>
<p style="font-style: italic"><strong>UPDATE 04-28-2005: </strong></p>
<p>I left out one very potentially important tip.  Here is the scenario:</p>
<ul>
<li>
What if you have a large archive, say 2 Gigs worth, on $local_host and you wanted to restore it to $remote_host without having to copy the entire 2 Gig archive to $remote_host first.  This comes in handy when you have enough disk space for the extracted archive but not enough room for both the archive and the extracted contents of said archive.  <br />
<code><br />
$ ssh $user@$remote_host "cd /home/$user/; tar xpvfz -" < $really_big_archive.tgz<br />
</code><br />
You can also do it in the other direction:<br />
</code><code><br />
$ ssh $user@$remote_host "cat $really_big_archive.tgz" | tar xpvfz -<br />
</code>
</li>
</ul>
<p></p>
<p>Agian, if I remember anything else, I will just keep adding it here.</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/04/27/ssh-tips/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spam</title>
		<link>http://alittlestupid.com/2005/04/14/spam/</link>
		<comments>http://alittlestupid.com/2005/04/14/spam/#comments</comments>
		<pubDate>Thu, 14 Apr 2005 10:19:33 +0000</pubDate>
		<dc:creator>Juan Martinez</dc:creator>
				<category><![CDATA[how-to's]]></category>

		<guid isPermaLink="false">http://alittlestupid.com/stupid/wordpress/2005/04/14/spam/</guid>
		<description><![CDATA[If you&#8217;ve had your email address for a while like I have, then I&#8217;m sure you have run into the problem with SPAM. I hate SPAM, who actually likes it anyway? As long as you have that one idiot that falls for the scam in SPAM emails, there there will always be a problem with [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve had your email address for a while like I have, then I&#8217;m sure you have run into the problem with SPAM.  I hate SPAM, who actually likes it anyway?  As long as  you have that one idiot that falls for the scam in SPAM emails, there there will always be a problem with SPAM.</p>
<p>The only thing us mere mortals can do is filter it as best as possible and hope we didn&#8217;t delete your favorite cookie recipe from good &#8216;ole grandma.  There are two types of SPAM filtering.  The one thats done remotely on the mail server and the one thats done locally in your favorite email client.  Personally, the more server side filtering, the better.  I have found that an excellent SPAM fighting combination is using <a href="http://www.roaringpenguin.com/penguin/open_source_mimedefang.php">MimeDefang</a>/<a href="http://spamassassin.apache.org/">SpamAssassin</a>/<a href="http://www.procmail.org/">Procmail</a> on the host side to be awesome.  That combination actually pretty much gets rid of the need to have email rules in my local email client.  </p>
<p>These days, I hardly ever use a PC based email client.  Most of my mail checking is done using <a href="http://openwebmail.org/">OpenwebMail</a> which allows me to check my email from any Internet accessible PC.  </p>
<p><span id="more-5"></span></p>
<p><strong>DISCLAIMER: I am by no means a Procmail guru.  I just wanted to share with you all what I do to fight SPAM and be able to drink a beer here and there without having to waste my time sifting through yet another Viagra email.  </strong></p>
<p>At its most basic level, here is how it works for me:</p>
<ol type = 1>
<li>&#8216;Joe Blow&#8217; <joe @spammer.com> sends me an email</joe></li>
<li>My mail server runs it through the kick ass combo of MimeDefang/SpamAssassin/Procmail</li>
<li>If it passed all the crazy SPAM tests, then the mail is finally received (NOTE: doesnt mean that I will respond <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) </li>
</ol>
<p>On my host, MimeDefang/SpamAssassin will add by default a &#8220;X-Spam-Score&#8221; header to all email messages (I know this because I am the one who installed and configured it.  Its one of the small perks of working at a hosting company and being a loser geek).  If the X-Spam-Score is above 5, then it will rewrite the subject of the original email and add &#8220;*****SPAM*****&#8221; followed by the original subject.  This is advantages in two ways, you can either filter all emails by the &#8220;X-Spam-Score&#8221; header or by the &#8220;*****SPAM*****&#8221; in the subject.  I do both just to be safe.  </p>
<p>At this point MimeDefang/SpamAssassin is done with the email message and is now sending it to Procmail.  I then have Procmail check to see if &#8220;*****SPAM*****&#8221; is in the subject, if its not, then I fall back and rely on the &#8220;X-Spam-Score&#8221; header.  It might be a little redundant but I hate SPAM.  (Did I mention that I hate SPAM?  By the way, I hate SPAM!)  </p>
<p>Without giving you my .procmailrc file, here is pretty much the order in which I filter SPAM once SpamAssassin hands off the email message to Procmail:</p>
<ol type = 1>
<li>I set all my stuff just how I like it, i.e. environment, path&#8217;s, and variables</li>
<li>Emergency stop rule for my .procmailrc.  Comes in handy when you <em>effen</em> mess up a procmail recipe and mail no longer works</li>
<li>A white list recipe that accepts all mail from the mofo&#8217;s I have listed in that file even if its dumb SPAM&#8230; <img src='http://alittlestupid.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </li>
<li>A blacklist recipe that works the opposite of the white list recipe, blocks everyone on that list.</li>
<li>If the email does not have a &#8220;Message-Id&#8221; or a &#8220;To:&#8221; its gone.  This test reliably kills half my SPAM in one shot</li>
<li>If X-Spam-Score is 5 or higher (MimeDefang/SpamAssassin&#8217;s doing)</li>
<li>I filter secret subjects that my blog is configured to send with.  I didn&#8217;t want to filter using &#8220;From:&#8221; since the email comes from the user apache runs as.  In my case its www@hostserver.tld</li>
<li>Last but not least, I run it through Procmails built in variable &#8220;TO_&#8221;.</li>
<li>If your mail has made it this far, then I will probably get the email and will most likely get paged on my cell phone.  Again, doesnt mean I will actually respond!</li>
</ol>
<p>It goes without saying that when testing your Procmail recipes, logging is your friend.  It can save you countless hours of debugging.  Been there done that and its not fun.</p>
<p>I would post my .procmailrc file but its customized specifically for my environment and host.  If you want it and I know you, I will send it to you.  Or you can spend some time <a href="http://www.google.com/search?hl=en&#038;q=procmail+recipes&#038;spell=1">Google&#8217;ing</a> it!</p>
<p>If you dont have MimeDefang/SpamAssassin/Procmail at your mail host then I would certainly look for another hosting provider.  But that is just me since I like to have the full power of a Linux shell at my disposal.  Of course, once you have and use the combination I use, it will initially require tons of tweaking to get it &#8220;just right&#8221; but its well worth it.  Oh yeah, shell access to your host and a little knowledge of the Linux command line definitely couldn&#8217;t hurt either.  </p>
<p>jtnez<br />
&#8220;I will use Google.com before asking STUPID questions!!!&#8221;<br />
-Bart Simpson</p>
]]></content:encoded>
			<wfw:commentRss>http://alittlestupid.com/2005/04/14/spam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.788 seconds -->
