<?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>Hackerdude &#187; CBBTR</title>
	<atom:link href="http://www.hackerdude.com/category/cbbtr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackerdude.com</link>
	<description>Software Development Blog by David Martinez</description>
	<lastBuildDate>Tue, 06 Apr 2010 05:02:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting OS X Terminal to behave</title>
		<link>http://www.hackerdude.com/2007/02/07/getting-os-x-terminal-to-behave/</link>
		<comments>http://www.hackerdude.com/2007/02/07/getting-os-x-terminal-to-behave/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 18:41:17 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2007/02/07/getting-os-x-terminal-to-behave/</guid>
		<description><![CDATA[Last time I didn't write this down and this time I'm blogging about it so I don't forget it. OSX Hints has a good guide on how to set Terminal.app to work the way God Intended (great command line user that He is). I am handy around the Terminal.app, but for me the main thing [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I didn't write this down and this time I'm blogging about it so I don't forget it. OSX Hints has a good guide <a href="http://www.macosxhints.com/article.php?story=20060825071728278">on how to set Terminal.app to work</a> the way God Intended (<a href="http://www.cryptonomicon.com/beginning.html">great command line user that He is</a>).</p>
<p>I am handy around the Terminal.app, but for me the main thing that I kept forgetting (and hurts me a lot since my muscle memory depends on it) is moving forward and backwards full word:</p>
<p><code>"\e[5C": forward-word<br />
"\e[5D": backward-word<br />
</code>
<p>
By the way, have I mentioned I no longer have to use PCs? Woot!</p>
<p>
</p>
<p><b>Update:</b> Here is <a href="http://www.viksit.com/?q=node/261" title="Using End/Home keys to perfection in Terminal.app on Mac OS X | vIkSiT.com">another guide</a> you may want to take a look at. And <a href="http://www.commandlinemac.com/article.php?story=20070823141438826">another</a>
</p>
<p><!-- technorati tags begin -->
<p style="font-size:10px;text-align:right;">technorati tags:<a href="http://technorati.com/tag/osx" rel="tag">osx</a>, <a href="http://technorati.com/tag/terminal.app" rel="tag">terminal.app</a>, <a href="http://technorati.com/tag/bash" rel="tag">bash</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2007/02/07/getting-os-x-terminal-to-behave/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Hibernate Validators with Spring and Hibernate</title>
		<link>http://www.hackerdude.com/2006/09/14/using-hibernate-validators-with-spring-and-hibernate/</link>
		<comments>http://www.hackerdude.com/2006/09/14/using-hibernate-validators-with-spring-and-hibernate/#comments</comments>
		<pubDate>Fri, 15 Sep 2006 04:19:33 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2006/09/14/using-hibernate-validators-with-spring-and-hibernate/</guid>
		<description><![CDATA[In this article, Ted Bergeron shows you how to use the Validator component of Hibernate Annotations to build and maintain validation logic easily in your Web apps. Hibernate can meet your validation needs technorati tags:java, validation]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://www-128.ibm.com/developerworks/java/library/j-hibval.html"><p>In this article, Ted <span>Bergeron</span> shows you how to use the Validator component of Hibernate Annotations to build and maintain validation logic easily in your Web apps.</p></blockquote>
<p class="citation"><cite cite="http://www-128.ibm.com/developerworks/java/library/j-hibval.html"><a href="http://www-128.ibm.com/developerworks/java/library/j-hibval.html">Hibernate can meet your validation needs</a></cite></p>
<p />
<p /><!-- technorati tags begin -->
<p style="font-size:10px;text-align:right;">technorati tags:<a href="http://technorati.com/tag/java" rel="tag">java</a>, <a href="http://technorati.com/tag/validation" rel="tag">validation</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2006/09/14/using-hibernate-validators-with-spring-and-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editando c&#243;digo HTML en idiomas con marcas diacr&#237;ticas</title>
		<link>http://www.hackerdude.com/2006/02/14/html_con_diacriticas/</link>
		<comments>http://www.hackerdude.com/2006/02/14/html_con_diacriticas/#comments</comments>
		<pubDate>Tue, 14 Feb 2006 18:37:52 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Español]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/?p=458</guid>
		<description><![CDATA[Manejando marcas diacr&#237;ticas en HTML]]></description>
			<content:encoded><![CDATA[<p> Como muchas personas de habla hispana, muchas veces me veo en la necesidad de editar c&oacute;digo<br />
HTML en idiomas con marcas diacr&iacute;ticas (como el Espa&ntilde;ol). Mi esquema de teclado soporta<br />
marcas diacr&iacute;ticas, pero dejar estas marcas en el c&oacute;digo fuente<br />
del HTML es un problema porque a veces los navegadores (o los programas de<br />
manejo de contenido) tienen un c&oacute;digo de p&aacute;gina distinto al que<br />
se utiliz&oacute; para leer el archivo originalmente, lo cual hace a las marcas<br />
diacr&iacute;ticas verse espantosas.  Y tener que recordar los c&oacute;digos de cada<br />
letra acentuada rompe el tren de pensamiento.</p>
<p>
Este art&iacute;culo ayuda a solucionar este problema mediante macros que convierten tus caracteres diacr&iacute;ticos a entidades HTML.
</p>
<p><span id="more-458"></span></p>
<h3>Vim</h3>
<p> Para <a href="http://www.vim.org">Vim</a> en todas las plataformas, usted puede a&ntilde;adir la<br />
funci&oacute;n que sigue en su .vimrc: </p>
<pre>
function Html_entities_replace()
  exe ":silent g/&ntilde;/s//\\&amp;ntilde;/g"
  exe ":silent g/&Ntilde;/s//\\&amp;Ntilde;/g"
  exe ":silent g/&aacute;/s//\\&amp;aacute;/g"
  exe ":silent g/&eacute;/s//\\&amp;eacute;/g"
  exe ":silent g/&iacute;/s//\\&amp;iacute;/g"
  exe ":silent g/&oacute;/s//\\&amp;oacute;/g"
  exe ":silent g/&uacute;/s//\\&amp;uacute;/g"
  exe ":silent g/&Aacute;/s//\\&amp;Aacute;/g"
  exe ":silent g/&Eacute;/s//\\&amp;Eacute;/g"
  exe ":silent g/&Iacute;/s//\\&amp;Iacute;/g"
  exe ":silent g/&Oacute;/s//\\&amp;Oacute;/g"
  exe ":silent g/&Uacute;/s//\\&amp;Uacute;/g"
  exe ":silent g/&uuml;/s//\\&amp;uuml;/g"
  exe ":silent g/&Uuml;/s//\\&amp;Uuml;/g"
  exe ":silent g/&iexcl;/s//\\&amp;iexcl;/g"
  exe ":silent g/&iquest;/s//\\&amp;iquest;/g"
endfunction
</pre>
<p>Con la funci&oacute;n en mano, simplemente utilice el comando<br />
:Html_entities_replace() para corregir las marcas diacr&iacute;ticas. Si<br />
prefiere mapear el comando a una tecla, tambi&eacute;n lo puede hacer en<br />
.vimrc: </p>
<pre>
map &lt;f3&gt; &lt;Esc&gt;:exec Html_entities_replace()^M
</pre>
<p>Usted puede obtener ^M tecleando control-v, control-m.</p>
<h3>Textmate</h3>
<p>Para <a href="http://macromates.com/">TextMate</a> en Mac OS X, usted puede crear una<br />
macro. He aqu&iacute; la macro que escrib&iacute;, llamada<br />
ReplaceDiacriticalMarks:</p>
<p><code lang="ruby"><br />
#!/usr/bin/ruby -Ku</p>
<p>char_to_entity = { }<br />
File.open("#{ENV['TM_BUNDLE_SUPPORT']}/international.txt").read.gsub(/^(.*)\|(.+)$/) do |_|<br />
  key = $1<br />
  char_to_entity[key] = $2<br />
end</p>
<p>ch1 =nil<br />
res = STDIN.read.gsub(/[^\x00-\x7F]|["']|&amp;(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)/) do |ch|<br />
  ent = char_to_entity[ch]<br />
  ent ? "\&amp;"+ent+"\;" : ch<br />
end</p>
<p>print res<br />
</code></p>
<p>La opci&oacute;n -Ku en ruby es importante, ya que vamos a utilizar UTF para<br />
leer nuestro archivo.</p>
<p>Tambi&eacute;n necesitar&aacute; un cat&aacute;logo de marcas<br />
diacr&iacute;ticas en un archivo llamado "international.txt" en el directorio<br />
de soporte del bundle HTML en Textmate. &Aacute;seg&uacute;rese de guardar el<br />
archivo en formato UTF-8:</p>
<pre>
&aacute;|aacute
&eacute;|eacute
&iacute;|iacute
&oacute;|oacute
&uacute;|uacute
&ntilde;|ntilde
&Ntilde;|Ntilde
&Aacute;|Aacute
&Eacute;|Eacute
&Iacute;|Iacute
&Oacute;|Oacute
&Uacute;|Uacute
&uuml;|udieresis
&Uuml;|Udieresis
</pre>
<p>Mis catalogos est&aacute;n incompletos porque s&oacute;lo reflejan<br />
espa&ntilde;ol latinoamericano, as&iacute; que usted puede completar utilizando<br />
<a href="http://www.htmlhelp.com/reference/html40/entities/latin1.html">la<br />
tabla de entidades Latin-1</a>
</p>
<p>Gracias a esto ahora puedo pensar mientras escribo y al mismo tiempo no me tengo que preocupar por c&oacute;digos de p&aacute;gina.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2006/02/14/html_con_diacriticas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mac Tip: Avoiding .ds_store creation on your network drives</title>
		<link>http://www.hackerdude.com/2005/12/07/mac-tip-avoiding-ds_store-creation-on-your-network-drives/</link>
		<comments>http://www.hackerdude.com/2005/12/07/mac-tip-avoiding-ds_store-creation-on-your-network-drives/#comments</comments>
		<pubDate>Wed, 07 Dec 2005 16:23:26 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2005/12/07/mac-tip-avoiding-ds_store-creation-on-your-network-drives/</guid>
		<description><![CDATA[From this item at macosxhints - Prevent .ds_store creation across multiple user accounts it turns out its fairly easy to configure an OS X client to apply the setting for any user who logs in.You just need to run this command... defaults write com.apple.desktopservices DSDontWriteNetworkStores true ...under a single account, then copy the created plist [...]]]></description>
			<content:encoded><![CDATA[<p>From this item at <cite cite="http://www.macosxhints.com/article.php?story=20051130083652119"></cite><a href="http://www.macosxhints.com/article.php?story=20051130083652119">macosxhints - Prevent .ds_store creation across multiple user accounts</a></p>
<blockquote cite="http://www.macosxhints.com/article.php?story=20051130083652119"><p>it turns out its fairly easy to configure an OS X client to apply the setting for any user who logs in.You just need to run this command...</p>
<p>defaults write com.apple.desktopservices DSDontWriteNetworkStores true</p>
<p>...under a single account, then copy the created plist to /Library/Prefrences.</p></blockquote>
<p class="citation"><cite cite="http://www.macosxhints.com/article.php?story=20051130083652119"><a href="http://www.macosxhints.com/article.php?story=20051130083652119"><br /></a></cite></p>
<p></p>
<p>The article also has other ways of going about this, including vetoing files on the samba share directly (clever!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/12/07/mac-tip-avoiding-ds_store-creation-on-your-network-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One-to-One relationships with Rails</title>
		<link>http://www.hackerdude.com/2005/11/28/one-to-one-relationships-with-rails/</link>
		<comments>http://www.hackerdude.com/2005/11/28/one-to-one-relationships-with-rails/#comments</comments>
		<pubDate>Mon, 28 Nov 2005 18:02:03 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/?p=428</guid>
		<description><![CDATA[How to define and populate a one-to-one relationship using ActiveRecord and Ruby on Rails.]]></description>
			<content:encoded><![CDATA[<p>This is a lot easier than I thought it would be and it actually took me longer than it should have because I was trying to do it manually.</p>
<p><span id="more-428"></span></p>
<p>First you need to define the relationship on the parent and children models:</p>
<p><code lang="ruby"><br />
class Person < ActiveRecord::Base<br />
  has_one  :person_details, :dependent=>true<br />
end</p>
<p>class PersonDetails < ActiveRecord::Base<br />
  belongs_to :person<br />
end</p>
<p></code></p>
<p>Note that this automatically will provide with a person_details member for person when it gets retrieved.</p>
<p>Now on the controller, here's the CRUD:</p>
<p></code><code lang="ruby"><br />
  def create<br />
    @person = Person.new(params[:person])<br />
    @person_details = PersonDetails.new(params[:person_details])<br />
    @person.person_details = @person_details<br />
    if @person.save<br />
       # Cool, you're done! It saves the person_details as well.<br />
    end<br />
  end</p>
<p> def edit<br />
   @person = Person.find(params[:id])<br />
   @person_details = @person.person_details<br />
 end</p>
<p>def update<br />
  @person = Person.find(params[:id])<br />
  if @person.update_attributes(params[:person]) and<br />
     @person.person_details.update_attributes(params[:person_details])<br />
    # Cool, you're done!<br />
  end<br />
end</p>
<p>def destroy<br />
  Person.find(params[:id]).destroy<br />
end<br />
</code></p>
<p>Now your rhtml _form.rhtml must have things like:</p>
<p><code lang="ruby"><br />
 text_field 'person_details', column.name<br />
 text_field 'person, column.name<br />
</code></p>
<p>And you will get two sets of parameters (as you can see in your controller code), params[:person], and params[:person_details]. Your instance variables to set the current values on the view side would be @person and @person_details.</p>
<p>And I was sitting there writing custom code to find/save.. Ugh!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/11/28/one-to-one-relationships-with-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ant script for UMLGraph &#8211; separate packages and details views</title>
		<link>http://www.hackerdude.com/2005/11/23/ant-script-for-umlgraph-separate-packages-and-details-views/</link>
		<comments>http://www.hackerdude.com/2005/11/23/ant-script-for-umlgraph-separate-packages-and-details-views/#comments</comments>
		<pubDate>Wed, 23 Nov 2005 21:22:13 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/?p=427</guid>
		<description><![CDATA[Here's how to call UMLGraph from ant.. Also, the documentation mentions Multiple Views, but it provides a makefile. Seeing that most java users use ant instead, I went ahead and incorporated this as well. To use, create a target that calls each package, changing the uml-package and uml-output arguments for each iteration. To also get [...]]]></description>
			<content:encoded><![CDATA[<p>Here's how to call UMLGraph from ant.. Also, the documentation mentions <a href="http://www.spinellis.gr/sw/umlgraph/doc/ceg-mv.html">Multiple Views</a>, but it provides a makefile. Seeing that most java users use ant instead, I went ahead and incorporated this as well.</p>
<p><span id="more-427"></span></p>
<p>To use, create a target that calls each package, changing the uml-package and uml-output arguments for each iteration. To also get a detailed view, set uml-detailed-view:</p>
<p><code lang="xml"><br />
	<!-- Runs the uml documentation for the packages that need UML graphs --><br />
	<target name="umldoc"><br />
        <antcall target="-uml-package-doc" inheritAll="false"><br />
            < param name="uml-package" value="com/my/first/package/*" /></p>
<param name="uml-output" value="${build.doc}/first-package" />
       	</antcall><br />
        <antcall target="-uml-package-doc" inheritAll="false"></p>
<param name="uml-package" value="com/my/second/package/**" />
<param name="uml-output" value="${build.doc}/second-package" />
<param name="uml-detailed-view" value="true" />
       	</antcall><br />
	</target><br />
</code></p>
<p>The uml-package-doc target runs the doclet and then calls the dot-format target. A nearly identical target handles the details and only runs if the "uml-detailed-view" is set.</p>
<p>Finally, The "-run-dot" target runs the dot program.</p>
<p><code lang="xml"><br />
	<!-- Runs UMLGraph on a single package.<br />
	See http://www.spinellis.gr/sw/umlgraph/doc/index.html --><br />
	<target name="-uml-package-doc" depends="-uml-package-doc-details"><br />
    	<echo>Generating UML for ${uml-package}</echo></p>
<property name="dot-format" value="png"/>
        <javadoc access="public"><br />
        	<doclet name="UmlGraph" path="lib/build/UMLGraph.jar"></p>
<param name="-outputencoding" value="UTF-8"/>
<param name="-hide" value="Serializable"/>
<param name="-hide" value="Exception"/>
<param name="-output" value="${uml-output}.dot"/>
        	</doclet></p>
<packageset dir="${src.dir}" >
				<include name="${uml-package}"/>
			</packageset>
        	<classpath refid="classpath"/><br />
        	<classpath refid="standard.classpath"/><br />
        	<classpath refid="unittest.classpath"/><br />
        	<sourcepath location="${javasrc}"/><br />
    	</javadoc><br />
        <antcall target="-run-dot" inheritAll="true"></p>
<param name="dot-format" value="png" />
       	</antcall><br />
        <antcall target="-run-dot" inheritAll="true"></p>
<param name="dot-format" value="ps" />
       	</antcall><br />
        <antcall target="-run-dot" inheritAll="true"></p>
<param name="dot-format" value="svg" />
       	</antcall><br />
	</target></p>
<p>	<!-- Produce details if needed (adds options for attributes, operations, etc.) --><br />
	<target name="-uml-package-doc-details" if="uml-detailed-view"><br />
    	<echo>Generating UML for ${uml-package}</echo></p>
<property name="dot-format" value="png"/>
        <javadoc access="public"><br />
        	<doclet name="UmlGraph" path="lib/build/UMLGraph.jar"></p>
<param name="-outputencoding" value="UTF-8"/>
<param name="-hide" value="Serializable"/>
<param name="-hide" value="Exception"/>
<param name="-output" value="${uml-output}-details.dot"/>
<param name="-attributes"/>
<param name="-operations"/>
<param name="-types"/>
        	</doclet></p>
<packageset dir="${src.dir}" >
				<include name="${uml-package}"/>
			</packageset>
        	<classpath refid="classpath"/><br />
        	<classpath refid="standard.classpath"/><br />
        	<classpath refid="unittest.classpath"/><br />
        	<sourcepath location="${javasrc}"/><br />
    	</javadoc><br />
        <antcall target="-run-dot" inheritAll="false"></p>
<param name="dot-format" value="png" />
<param name="uml-output" value="${uml-output}-details"/>
       	</antcall><br />
        <antcall target="-run-dot" inheritAll="false"></p>
<param name="uml-output" value="${uml-output}-details"/>
<param name="dot-format" value="ps" />
       	</antcall><br />
        <antcall target="-run-dot" inheritAll="false"></p>
<param name="uml-output" value="${uml-output}-details"/>
<param name="dot-format" value="svg" />
       	</antcall><br />
	</target></p>
<p>	<!-- Tuns graphviz dot. Requires GraphViz. See http://www.graphviz.org/ --><br />
	<target name="-run-dot"></p>
<property name="dot-executable" value="fdp"/>
<property name="dot-options" value=""/>
<property name="dot-extension" value="${dot-format}"/>
		<exec executable="${dot-executable}"><br />
			<arg line="${dot-options} -T${dot-format} ${uml-output}.dot"/><br />
			<arg line="-o ${uml-output}.${dot-extension}" /><br />
		</exec><br />
	</target></p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/11/23/ant-script-for-umlgraph-separate-packages-and-details-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Jobs API and asyncExec</title>
		<link>http://www.hackerdude.com/2005/11/17/jobsapiasyncexec/</link>
		<comments>http://www.hackerdude.com/2005/11/17/jobsapiasyncexec/#comments</comments>
		<pubDate>Fri, 18 Nov 2005 00:09:45 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/?p=419</guid>
		<description><![CDATA[Using the Jobs API (Job and IProgressMonitor) you can implement code that will run in a thread and update the standard Eclipse progress monitoring service as you go along in your thread. To create a job, extend from org.eclipse.core.runtime.Job and implement the run method: &#160; &#160; protected IStatus run&#40;IProgressMonitor monitor&#41; &#123; int steps = 100000; [...]]]></description>
			<content:encoded><![CDATA[<p>Using the Jobs API (Job and IProgressMonitor) you can implement code that will run in a thread and update the standard Eclipse progress monitoring service as you go along in your thread.</p>
<p>To create a job, extend from org.eclipse.core.runtime.Job and implement the run method:</p>
<pre class="java">&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> IStatus run<span style="color: #66cc66;">&#40;</span>IProgressMonitor monitor<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #993333;">int</span> steps = <span style="color: #cc66cc;">100000</span>;
  monitor.<span style="color: #006600;">beginTask</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;My Task&quot;</span>, steps<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #993333;">int</span> i=<span style="color: #cc66cc;">0</span>; i&lt;steps ; i++ <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    monitor.<span style="color: #006600;">subTask</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Step &quot;</span>+i<span style="color: #66cc66;">&#41;</span>;
    monitor.<span style="color: #006600;">worked</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> monitor.<span style="color: #006600;">isCanceled</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">break</span>;
  <span style="color: #66cc66;">&#125;</span>
  inputForTableViewer = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AArrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Arrays</span></a>.<span style="color: #006600;">asList</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;One&quot;</span>,
             <span style="color: #ff0000;">&quot;Two&quot;</span>, <span style="color: #ff0000;">&quot;Three&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">return</span> Status.<span style="color: #006600;">OK_STATUS</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>To activate the job in MyClass (say it's a page with a tableViewer which we use to set the input), you do the following:</p>
<pre class="java">&nbsp;
MySampleJob myJob = <span style="color: #000000; font-weight: bold;">new</span> MySampleJob<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
myJob .<span style="color: #006600;">addJobChangeListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> JobChangeAdapter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> done<span style="color: #66cc66;">&#40;</span>IJobChangeEvent event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    Display.<span style="color: #006600;">getDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">asyncExec</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Runnable</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> run<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        MyClass.<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">tableViewer</span>.
                        <span style="color: #006600;">setInput</span><span style="color: #66cc66;">&#40;</span>myJob .<span style="color: #006600;">getInputForTableViewer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
myJob.<span style="color: #006600;">schedule</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Have fun!</steps></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/11/17/jobsapiasyncexec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retrieving random lines from a file</title>
		<link>http://www.hackerdude.com/2005/06/20/retrieving-random-lines-from-a-file/</link>
		<comments>http://www.hackerdude.com/2005/06/20/retrieving-random-lines-from-a-file/#comments</comments>
		<pubDate>Mon, 20 Jun 2005 21:38:10 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2005/06/20/retrieving-random-lines-from-a-file/</guid>
		<description><![CDATA[A little class to retrieve a random line from a file. import linecache, random """ This class will retrieve a random line from a file. """ class RandomRetriever: """Retrieve a random line from a file. It caches the file, so it runs fast when used again""" def __init__(self, fileName=None): self.fileName = fileName self.lineCount = self.countLine() [...]]]></description>
			<content:encoded><![CDATA[<p>A little class to retrieve a random line from a file.<br />
<span id="more-317"></span></p>
<p><code lang="python"><br />
import linecache, random</p>
<p>"""<br />
This class will retrieve a random line from a file.</p>
<p>"""<br />
class RandomRetriever:<br />
    """Retrieve a random line from a file.<br />
    It caches the file, so it runs fast when used again"""<br />
    def __init__(self, fileName=None):<br />
        self.fileName = fileName<br />
        self.lineCount = self.countLine()</p>
<p>    def countLine(self):<br />
        lines = 0<br />
        try:<br />
            fileLines = open(self.fileName, 'r')<br />
        except IOError:<br />
            print "Cannot open "+self.fileName+" for reading"<br />
        for line in fileLines:<br />
            lines += 1<br />
        return lines</p>
<p>    """Retrieves a random item from the file in this class.</p>
<p>    return A random line from the text file.<br />
    """<br />
    def randomItem(self):<br />
        lineNumber = random.randint(1,self.lineCount)<br />
        return linecache.getline(self.fileName, lineNumber).rstrip()</p>
<p></code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/06/20/retrieving-random-lines-from-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle tuning: Using Hints</title>
		<link>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-hints/</link>
		<comments>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-hints/#comments</comments>
		<pubDate>Mon, 20 Jun 2005 14:29:38 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2005/06/20/oracle-tuning-using-hints/</guid>
		<description><![CDATA[Every once in a while you will get a query that no matter what you try, it doesn't use the indices. This is typically because the cost-based optimizer decides that an approach that is slower has a total cost that is lower than using the index and making it faster. To solve this, you would [...]]]></description>
			<content:encoded><![CDATA[<p>Every once in a while you will get a query that no matter what you try, it doesn't use the indices. This is typically because the cost-based optimizer decides that an approach that is <b>slower</b> has a <b>total cost</b> that is lower than using the index and making it faster.</p>
<p>To solve this, you would use a hint. You can find <a href="http://www.dbasupport.com/oracle/ora9i/index_hints.shtml">an article on how to do this on dbasupport</a>. But the basics are: <span id="more-318"></span> The way to use a hint is as follows:</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span>  <span style="color: #808080; font-style: italic;">/*+ INDEX(a, MY_INDEX1) */</span>
  *
<span style="color: #993333; font-weight: bold;">FROM</span>
  MY_TABLE a
<span style="color: #993333; font-weight: bold;">WHERE</span>
  FUNKY_ID= <span style="color: #ff0000;">'3455'</span>
&nbsp;</pre>
<p>You can use <a href="http://www.hackerdude.com/2005/06/20/oracle-tuning-using-explain-plan/">Explain Plan</a> to verify that the index was used. Typical problems include:</p>
<ul>
<li>Check the spaces. Plus sign <b>must</b> be next to the comment opening. No spaces in between.</li>
<li>Make sure the table or alias is correct. When in doubt, use an alias.</li>
<li>Note the comma and space betwen alias and index name</li>
</ul>
<p>Hints are not very well documented. Google around for oracle hints and you will find <a href="http://www.adp-gmbh.ch/ora/sql/hints.html">some interesting articles</a> however..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-hints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle tuning: Using explain plan</title>
		<link>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-explain-plan/</link>
		<comments>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-explain-plan/#comments</comments>
		<pubDate>Mon, 20 Jun 2005 14:18:54 +0000</pubDate>
		<dc:creator>David Martinez</dc:creator>
				<category><![CDATA[CBBTR]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.hackerdude.com/2005/06/20/oracle-tuning-using-explain-plan/</guid>
		<description><![CDATA[In order to make queries run faster, you should try to have oracle explain to you how the query should be performed. The whole explanation for oracle tuning can be found on the Oracle Tuning guide, but here are the basics. First, you need a PLAN_TABLE: &#160; CREATE TABLE plan_table &#40; statement_id VARCHAR2&#40;30&#41;, timestamp DATE, [...]]]></description>
			<content:encoded><![CDATA[<p>In order to make queries run faster, you should try to have oracle explain to you how the query should be performed.</p>
<p>The whole explanation for oracle tuning can be found on the <a href="http://www.csee.umbc.edu/help/oracle8/server.815/a67775/ch13_exp.htm">Oracle Tuning guide</a>, but here are the basics. <span id="more-319"></span> First, you need a PLAN_TABLE:</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> plan_table <span style="color: #66cc66;">&#40;</span>
    statement_id     VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    timestamp        DATE,
    remarks          VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">80</span><span style="color: #66cc66;">&#41;</span>,
    operation        VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    options          VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    object_node      VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">128</span><span style="color: #66cc66;">&#41;</span>,
    object_owner     VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    object_name      VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    object_instance  NUMERIC,
    object_type      VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>,
    optimizer        VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span>,
    search_columns   NUMERIC,
    id               NUMERIC,
    parent_id        NUMERIC,
    position         NUMERIC,
    cost             NUMERIC,
    cardinality      NUMERIC,
    bytes            NUMERIC,
    other_tag        VARCHAR2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span>
    other            LONG <span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Next, you need to output the SQL</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">EXPLAIN</span> PLAN <span style="color: #993333; font-weight: bold;">SET</span> STATEMENT_ID = <span style="color: #ff0000;">'MyPlan'</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> myTable <span style="color: #993333; font-weight: bold;">WHERE</span> myName <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Dude%'</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> PLAN_TABLE <span style="color: #993333; font-weight: bold;">WHERE</span> STATEMENT_ID = <span style="color: #ff0000;">'MyPlan'</span>
&nbsp;</pre>
<p>Now look at the output. Take a special look at the cost and any full table scans.</p>
<p>Full table scans may or may not be a problem (depending on the size of the table).</p>
<p>Note: If using <a href="http://www.toadsoft.com/">TOAD</a>, you only need to switch to the "Explain" tab. You can set the name of the plan table to use by using <b>View->Options->Oracle->Explain Table Name</b>. You will probably need to do this since it defaults to TOAD_PLAN_TABLE..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackerdude.com/2005/06/20/oracle-tuning-using-explain-plan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
