<?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>Wazi &#187; Tips and Tricks</title>
	<atom:link href="http://olex.openlogic.com/wazi/category/tips-and-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://olex.openlogic.com/wazi</link>
	<description>Thinking OPEN</description>
	<lastBuildDate>Fri, 06 Nov 2009 19:33:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Making Your Shell Scripts Run From Anywhere</title>
		<link>http://olex.openlogic.com/wazi/2009/making-your-shell-scripts-run-from-anywhere/</link>
		<comments>http://olex.openlogic.com/wazi/2009/making-your-shell-scripts-run-from-anywhere/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 20:21:20 +0000</pubDate>
		<dc:creator>Eric Weidner</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[gnu-bash]]></category>

		<guid isPermaLink="false">http://olex.openlogic.com/wazi/?p=1255</guid>
		<description><![CDATA[How many times have you had to go to a specific directory to launch an application or set several environment variables for an application to be able to find itself and run?  Well, here's a simple trick to add to your shell scripts so that they're self-contained with no external requirements or editing.]]></description>
			<content:encoded><![CDATA[<h3>Issue</h3>
<p>How many times have you had to go to a specific directory to launch an application or set several environment variables for an application to be able to find itself and run?  Well, here&#8217;s a simple trick to add to your shell scripts so that they&#8217;re self-contained with no external requirements or editing.</p>
<h3>Trick</h3>
<p>Put the following code in the top of your scripts and they&#8217;ll set your working directory to the directory in which the script actually resides.  This way, you&#8217;ll have a known base directory from which to call any other commands.  This also makes your launch scripts portable to other systems and directory structures without having to edit them to set a new directory or add new environment variables.</p>
<p><strong>For *nix platforms:</strong> (this works in sh and bash)</p>
<pre>#Get the fully qualified path to the script
 case $0 in
     /*)
         SCRIPT="$0"
         ;;
     *)
         PWD=`pwd`
         SCRIPT="$PWD/$0"
         ;;
 esac
 # Resolve the true real path without any sym links.
 CHANGED=true
 while [ "X$CHANGED" != "X" ]
 do
     # Change spaces to ":" so the tokens can be parsed.
     SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
     # Get the real path to this script, resolving any symbolic links
     TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'`
     REALPATH=
     for C in $TOKENS; do
         REALPATH="$REALPATH/$C"
         while [ -h "$REALPATH" ] ; do
             LS="`ls -ld "$REALPATH"`"
             LINK="`expr "$LS" : '.*-&gt; (.*)$'`"
             if expr "$LINK" : '/.*' &gt; /dev/null; then
                 REALPATH="$LINK"
             else
                 REALPATH="`dirname "$REALPATH"`""/$LINK"
             fi
         done
     done
     if [ "$REALPATH" = "$SCRIPT" ]
     then
         CHANGED=""
     else
        SCRIPT="$REALPATH"
     fi
done
# Change ":" chars back to spaces.
REALPATH=`echo $REALPATH | sed -e 's;:; ;g'`
# Change the current directory to the location of the script
cd "`dirname "$REALPATH"`"</pre>
<p><strong>For Windows platforms:</strong></p>
<p>Surprisingly, for Windows DOS there&#8217;s a much easier way to do this — just add the following to the top of your batch file.</p>
<pre>cd %~dp0%</pre>
<p>Happy scripting!</p>
]]></content:encoded>
			<wfw:commentRss>http://olex.openlogic.com/wazi/2009/making-your-shell-scripts-run-from-anywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Funkyness with Ferret</title>
		<link>http://olex.openlogic.com/wazi/2009/funkyness-with-ferret/</link>
		<comments>http://olex.openlogic.com/wazi/2009/funkyness-with-ferret/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 21:31:03 +0000</pubDate>
		<dc:creator>Rod Cope</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[ferret]]></category>

		<guid isPermaLink="false">http://olex.openlogic.com/wazi/?p=1875</guid>
		<description><![CDATA[If you need fast indexing and searching, especially if you’re doing Ruby on Rails development, Ferret is worth checking out. But there’s one funky thing that we’ve come across lately and wanted to share — something that works well when running in development mode but that causes bizarre issues in production mode.]]></description>
			<content:encoded><![CDATA[<h3>Issue</h3>
<p>No, we&#8217;re not talking about the critter.  We&#8217;re talking about the fast open source searching tool by Dave Balmain.  You know, <a title="Ferret" href="http://ferret.davebalmain.com/" target="_blank">Ferret</a>.  If you need fast indexing and searching, especially if you&#8217;re doing Ruby on Rails development, check it out.</p>
<p>Anyway, there&#8217;s one funky thing that we&#8217;ve come across lately and wanted to share — something that works well when running in development mode but that causes bizarre issues in production mode.</p>
<p>If you&#8217;re doing a search like this</p>
<pre>query = Ferret::Search::WildcardQuery.new(:name, "tomcat")</pre>
<p>it works just fine in development mode, but it&#8217;ll fail in production mode.</p>
<h3>Trick</h3>
<p>Why, you ask? Well, it turns out that in production mode Ferret uses something called DRb (Distributed Ruby) so that it can run as a stand-alone server to work with multiple Rails instances as clients. You can think of <a href="http://www2a.biglobe.ne.jp/~seki/ruby/druby.en.html" target="_blank">DRb</a> as being similar to RMI if you&#8217;re from the Java world.</p>
<p>The key is that it has to marshal objects from once instance of Ruby to another, and then un-marshal them in the receiving instance to make them usable again. If the receiving instance doesn&#8217;t know about things like Ferret::Search::WildcardQuery you&#8217;re out of luck.</p>
<p>What&#8217;s so painful about this particular issue is that the error you get when the problem occurs looks like this:</p>
<pre>DRb::DRbConnError (DRbServerNotFound):</pre>
<p>followed by a giant stack trace.</p>
<p>Server not found? Excuse me? Not exactly what we were expecting.</p>
<p>To make a long story short, there&#8217;s an easy way to make all this pain go away, and that&#8217;s by simply using FQL, Ferret Query Language, to specify your search.</p>
<p>Instead of creating a WildcardQuery object, you can just define your search the easy way by saying:</p>
<pre>query = "name:*tomcat*"</pre>
<p>Wow, that sure was easy. Too bad that trying to save some parse time by constructing the object yourself leads to so much aggravation. This way, DRb only has to send a simple string across the wire and all is well.</p>
<p>Maybe next time we&#8217;ll just start with the easy solution and see how that works for a change.</p>
]]></content:encoded>
			<wfw:commentRss>http://olex.openlogic.com/wazi/2009/funkyness-with-ferret/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Fiesty Spazzing and Returning to Read-Only State</title>
		<link>http://olex.openlogic.com/wazi/2008/ubuntu-fiesty-spazzing-and-returning-to-read-only-state/</link>
		<comments>http://olex.openlogic.com/wazi/2008/ubuntu-fiesty-spazzing-and-returning-to-read-only-state/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 18:13:58 +0000</pubDate>
		<dc:creator>Landon Cox</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://olex.openlogic.com/wazi/?p=1811</guid>
		<description><![CDATA[Are you waking up to Ubuntu Feisty defaulting to a read only state? Our developers cracked this one... ]]></description>
			<content:encoded><![CDATA[<h3>Issue</h3>
<p>We&#8217;d like to share a fix for something that has been driving us insane on an Ubuntu Fiesty box (though don’t think it’s at all limited to that distro). This fix may be common knowledge, but, if, like us, you&#8217;ve not heard about it, seriously, how common can it be, eh?</p>
<p>The box in question is a 500G Maxtor USB drive used as a backup drive for a Dell pizza box running Ubuntu Fiesty. We formatted it ext2, got it mounted, ran backup data to it, no problems. We made a daily cron job to do backups, but every morning when we reviewed the cron notifications, we&#8217;d discover that the backup failed because the file system was read-only which is not how we left it.</p>
<p>We&#8217;d log in, try to make a file on the backup drive and sure enough, couldn’t because it was read only. We’d unmount it, then remount it and it would be fine. By the next morning it was read-only again.</p>
<p>We reformatted the drive to ext3, reiserfs…no matter what: problems. Looking at log messages we&#8217;d see things like this:</p>
<p>Nov 19 07:29:54 hurricane kernel: [724306.332761] sd 4:0:0:0: Device not ready: : Current: sense key: Not Ready<br />
Nov 19 07:29:54 hurricane kernel: [724306.332771] Additional sense: Logical unit not ready, initializing command required<br />
Nov 19 07:29:54 hurricane kernel: [724306.332781] end_request: I/O error, dev sdb, sector 10706<br />
Nov 19 07:29:54 hurricane kernel: [724306.332785] printk: 4 messages suppressed.<br />
Nov 19 07:29:54 hurricane kernel: [724306.332797] lost page write due to I/O error on sdb1</p>
<p>where sdb1 was my USB backup drive partition. After digging, we finally found a thread:</p>
<p>http://ubuntuforums.org/showthread.php?t=494673</p>
<p>that talked about a similar issue. Some people saw it on NTFS, FAT32, etc &#8211; it has nothing to do with the drive format as far as we can tell.</p>
<h3>Trick</h3>
<p>The problem is that some drives will spin down (to save energy, we suppose), but that hoses up the filesystem and kernel for writing to it.</p>
<p>For us, the fix was similar to that suggested in the link above:</p>
<p>1) create a file in /etc/udev/rules.d called 85-usb-hd-fix.rules and add this line to it:</p>
<p>BUS==”scsi”, SYSFS{vendor}==”Maxtor”, RUN+=”/usr/bin/usbhdfix %k”</p>
<p>(where you modify the vendor to be appropriate)</p>
<p>2) in /usr/bin add a file: usbhdfix and put this content in it:</p>
<p>#!/bin/bash<br />
# http://ubuntuforums.org/showthread.php?t=494673</p>
<p>echo 1 &gt; /sys/block/$1/device/scsi_disk:*/allow_restart</p>
<p>3) of course, chmod +x usbhdfix as appropriate for you.</p>
<p>After this, our backups never failed again due to the read-only issue.</p>
<p>Apparently a kernel fix is coming or is already there…we didn’t chase that down.</p>
]]></content:encoded>
			<wfw:commentRss>http://olex.openlogic.com/wazi/2008/ubuntu-fiesty-spazzing-and-returning-to-read-only-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Multiple Firefox Versions Side-by-Side</title>
		<link>http://olex.openlogic.com/wazi/2008/running-multiple-firefox-versions-side-by-side/</link>
		<comments>http://olex.openlogic.com/wazi/2008/running-multiple-firefox-versions-side-by-side/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 18:35:58 +0000</pubDate>
		<dc:creator>Eric Weidner</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://olex.openlogic.com/wazi/?p=1253</guid>
		<description><![CDATA[Often developers need to test multiple browsers during development to test for browser compatibility or to use a different version of the browser because a needed plugin only works on an older version.  Firefox offers some handy options to run several versions side-by-side.]]></description>
			<content:encoded><![CDATA[<h3>Issue</h3>
<p>Often during development, developers need to run multiple browsers simultaneously. They might be testing for browser compatibility, or need a plugin that only works on a older version. Whatever your situation, here are some handy options for running several versions of Firefox side-by-side.</p>
<h3>Trick</h3>
<p>To run multiple versions of Firefox side-by-side, launch Firefox with the following options.  You can accomplish this with a shortcut on Windows or a panel launcher on Gnome on Linux.</p>
<p>My Ubuntu default Firefox:</p>
<pre>firefox --no-remote -P default %u

<a href="http://olex.openlogic.com/wazi/wp-content/uploads/2008/11/firefox_side_by_side_tip-firefox_default.png"><img class="alignnone size-medium wp-image-1259" title="firefox_side_by_side_tip-firefox_default" src="http://olex.openlogic.com/wazi/wp-content/uploads/2008/11/firefox_side_by_side_tip-firefox_default-300x132.png" alt="" width="300" height="132" /></a></pre>
<p><strong>Other shortcuts to run other versions simultaneously&#8230;</strong></p>
<p>Testing FF 3.1 with my main profile:</p>
<pre>/home/eric/programs/firefox-3.1b1/firefox --no-remote -P default %u</pre>
<p>Side-By-Side FF 3.1:</p>
<pre>/home/eric/programs/firefox-3.1b1/firefox --no-remote -P ff31b1

<a href="http://olex.openlogic.com/wazi/wp-content/uploads/2008/11/firefox_side_by_side_tip-firefox_31b1.png"><img class="alignnone size-medium wp-image-1260" title="firefox_side_by_side_tip-firefox_31b1" src="http://olex.openlogic.com/wazi/wp-content/uploads/2008/11/firefox_side_by_side_tip-firefox_31b1-300x132.png" alt="" width="300" height="132" /></a></pre>
<p>Side-By-Side FF 2.0.0.16:</p>
<pre>/home/eric/programs/firefox-2.0.0.16/firefox --no-remote -P ff20016</pre>
<p>Side-By-Side FF 2 for running Firewatir (at the time, Firewatir/JSSH would not run in FF 3):</p>
<pre>/home/eric/programs/firefox-2.0.0.16/firefox --no-remote -jssh -P firewatir</pre>
<p>If the profile (-P) is not already there, the Firefox profile box will start.  Create a profile with the name specified by the -P option.</p>
<p>It&#8217;s probably best to not tell your new Firefox to be the default unless you are really sure you want it to be as it may affect your installed plugins and themes.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://olex.openlogic.com/wazi/2008/running-multiple-firefox-versions-side-by-side/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Slows Using Red Hat-Bundled Perl</title>
		<link>http://olex.openlogic.com/wazi/2008/system-slows-when-using-red-hat-supplied-perl/</link>
		<comments>http://olex.openlogic.com/wazi/2008/system-slows-when-using-red-hat-supplied-perl/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 19:45:53 +0000</pubDate>
		<dc:creator>Brad Reeves</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://annasorchids.wordpress.com/?p=15</guid>
		<description><![CDATA[Experiencing performance problems with Red Hat and Perl? The Perl that's bundled with Red Hat, along with code that uses the bless/overload combination, can result in a severe system slow down. This is a known issue with Red Hat supplied Perl.]]></description>
			<content:encoded><![CDATA[<h3>Issue:</h3>
<p>Experiencing performance problems with Red Hat and Perl? The Perl that&#8217;s bundled with Red Hat, along with code that uses the bless/overload combination, can result in a severe system slow down. This is a known issue with Red Hat supplied Perl (<a title="Perl Bug Tracker" href="https://bugzilla.redhat.com/show_bug.cgi?id=379791" target="_blank">Bug 379791</a>).</p>
<h3>Trick:</h3>
<p>Here&#8217;s a test, some instructions on interpreting the results of the test, and suggestions on a solution to your system slow down.</p>
<p>First exercise Perl to determine if this known issue is, in fact, the problem you&#8217;re experiencing. To do so, run this test script:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #000000; font-weight: bold;">use</span> overload <span style="color: #000066;">q</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>lt;<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&amp;</span>gt; <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%h</span>;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">=</span>0; <span style="color: #0000ff;">$i</span><span style="color: #339933;">&amp;</span>lt;<span style="color: #cc66cc;">50000</span>; <span style="color: #0000ff;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #0000ff;">$h</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">bless</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&amp;</span>gt; <span style="">'main'</span>;
<span style="color: #000066;">print</span> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="">'.'</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">1000</span> <span style="color: #339933;">==</span> 0;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The test script will print 50 dots on screen while using the bless operator. On a healthy system, the test should take less than 1 second to complete. With broken Red Hat Perl, the test takes much longer.</p>
<p>As of 8/21/08, there is a hotfix available from Red Hat for RHEL5u3 and RHEL5u2, RHEL4.5. However, users are still reporting performance issues with perl::DBI when bless/overload is utilized. For this reason, OpenLogic recommends that you obtain the <a title="Perl in OLEX" href="https://olex.openlogic.com/packages/perl" target="_blank">latest Perl code</a> from the Certified Library, and compile Perl yourself. The compilation of Perl is fairly straightforward, and should only take a few minutes on a server level platform. When implemented, OpenLogic Support has observed this solution result in 10X to 1000X improvement.</p>
<p>If you run into any problems, or have any questions about how to compile or distribute Perl, please contact OpenLogic support for instructions and help.</p>
<p>Relevant to: Red Hat RHEL4, RHEL5, Fedora 9, Red Hat supplied Perl version 5.8.8-10</p>
]]></content:encoded>
			<wfw:commentRss>http://olex.openlogic.com/wazi/2008/system-slows-when-using-red-hat-supplied-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
