<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Posts on Randy Solomonson</title>
		<link>/posts/</link>
		<description>Recent content in Posts on Randy Solomonson</description>
		<generator>Hugo -- gohugo.io</generator>
		<language>en-us</language>
		<copyright>All Rights Reserved.</copyright>
		<lastBuildDate>Mon, 02 Sep 2013 10:24:42 +0000</lastBuildDate>
		<atom:link href="/posts/index.xml" rel="self" type="application/rss+xml" />
		
		<item>
			<title>Using dd disk images</title>
			<link>/posts/2013-09-02-using-dd-disk-images/</link>
			<pubDate>Mon, 02 Sep 2013 10:24:42 +0000</pubDate>
			
			<guid>/posts/2013-09-02-using-dd-disk-images/</guid>
			<description>Problem Have an existing disk that has specialized partitions that arnd easily backed up using fsarchiver. For example, Windows 8 disk on a brand new computer.
Solution  Use fsarchiver probe to find the disk. Be sure the disk is not mounted. cd to a target directory with plenty of space. Note: the image will be compressed. To create the image, run this command: dd if=/dev/sdc conv=sync,noerror bs=32M | pv | xz -c | split -b 23000m  Hints:</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>Have an existing disk that has specialized partitions that arnd easily backed up using fsarchiver.  For example, Windows 8 disk on a brand new computer.</p>

<h1 id="solution">Solution</h1>

<ol>
<li>Use <code>fsarchiver probe</code> to find the disk.</li>
<li>Be sure the disk is not mounted.</li>
<li><code>cd</code> to a target directory with plenty of space.  Note: the image will be compressed.</li>
<li>To create the image, run this command:
<code>dd if=/dev/sdc conv=sync,noerror bs=32M | pv | xz -c | split -b 23000m</code></li>
</ol>

<p>Hints:</p>

<ul>
<li>The source disk for the above command is at /dev/sdc.</li>
<li>Google the model of the hard disk shown on <code>fsarchiver probe</code> to find the buffer size of the disk (32MB in the above example)</li>
<li>Be sure <code>pv</code> and <code>xz</code> are installed.<br /></li>
<li>The target media of the above is a blu-ray disk. (-b 23000m).  Lower this number for DVD&rsquo;s or CD&rsquo;s.</li>
<li>This process could take several days.  Just let it run in the background.  A 2T drive took me about 3 straight days.</li>
</ul>

<ol>
<li>New files will appear on the current directory as xaa, xab, xac, etc.  When a new file appears, rename the old file to something helpful like: new_system_drive_01.dd.xz.  DO NOT rename or burn a file that is still being created.</li>
<li>Burn these files to a blu-ray disk.  I recommend <code>x3b</code> for Ubuntu.</li>
</ol>

<p>References:</p>

<ul>
<li><a href="https://wiki.archlinux.org/index.php/Disk_Cloning# Using_dd">How to use dd</a></li>
<li><a href="http://mgalgs.github.io/2012/03/23/dd-across-the-internet-with-ssh-and-xz.html">dd with xz</a></li>
<li><a href="http://www.linuxquestions.org/questions/linux-software-2/dd-question-split-files-232492/">dd with split</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Iterate through an Excel document</title>
			<link>/posts/2013-07-29-iterate-through-excel-document/</link>
			<pubDate>Mon, 29 Jul 2013 08:51:28 +0000</pubDate>
			
			<guid>/posts/2013-07-29-iterate-through-excel-document/</guid>
			<description>pom.xml:
&amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.poi&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;poi&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;3.9&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.poi&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;poi-ooxml&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;3.9&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; java
Workbook wb=new XSSFWorkbook(new FileInputStream(&amp;#34;test.xlsx&amp;#34;)); Sheet ws=wb.getSheetAt(wb.getActiveSheetIndex()); int rowIndex=1; while (ws.getRow(rowIndex)!=null &amp;amp;&amp;amp; rowIndex&amp;lt;100){ Row row=ws.getRow(rowIndex); System.out.println(row.getCell(0).getStringCellValue()); rowIndex++; }</description>
			<content type="html"><![CDATA[<p>pom.xml:</p>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml">    <span class="nt">&lt;dependency&gt;</span>
	<span class="nt">&lt;groupId&gt;</span>org.apache.poi<span class="nt">&lt;/groupId&gt;</span>
	<span class="nt">&lt;artifactId&gt;</span>poi<span class="nt">&lt;/artifactId&gt;</span>
	<span class="nt">&lt;version&gt;</span>3.9<span class="nt">&lt;/version&gt;</span>
    <span class="nt">&lt;/dependency&gt;</span>
    <span class="nt">&lt;dependency&gt;</span>
	<span class="nt">&lt;groupId&gt;</span>org.apache.poi<span class="nt">&lt;/groupId&gt;</span>
	<span class="nt">&lt;artifactId&gt;</span>poi-ooxml<span class="nt">&lt;/artifactId&gt;</span>
	<span class="nt">&lt;version&gt;</span>3.9<span class="nt">&lt;/version&gt;</span>
    <span class="nt">&lt;/dependency&gt;</span></code></pre></div>
<p>java</p>
<div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java">        <span class="n">Workbook</span> <span class="nf">wb</span><span class="o">=</span><span class="k">new</span> <span class="n">XSSFWorkbook</span><span class="p">(</span><span class="k">new</span> <span class="n">FileInputStream</span><span class="p">(</span><span class="s">&#34;test.xlsx&#34;</span><span class="p">));</span>
        <span class="n">Sheet</span> <span class="nf">ws</span><span class="o">=</span><span class="n">wb</span><span class="p">.</span><span class="na">getSheetAt</span><span class="p">(</span><span class="n">wb</span><span class="p">.</span><span class="na">getActiveSheetIndex</span><span class="p">());</span>
        <span class="kt">int</span> <span class="nf">rowIndex</span><span class="o">=</span><span class="n">1</span><span class="p">;</span>
        <span class="k">while</span> <span class="p">(</span><span class="n">ws</span><span class="p">.</span><span class="na">getRow</span><span class="p">(</span><span class="n">rowIndex</span><span class="p">)</span><span class="o">!=</span><span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="n">rowIndex</span><span class="o">&lt;</span><span class="n">100</span><span class="p">){</span>
            <span class="n">Row</span> <span class="nf">row</span><span class="o">=</span><span class="n">ws</span><span class="p">.</span><span class="na">getRow</span><span class="p">(</span><span class="n">rowIndex</span><span class="p">);</span>
            <span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="n">row</span><span class="p">.</span><span class="na">getCell</span><span class="p">(</span><span class="n">0</span><span class="p">).</span><span class="na">getStringCellValue</span><span class="p">());</span>
            <span class="n">rowIndex</span><span class="o">++</span><span class="p">;</span>
        <span class="p">}</span></code></pre></div>]]></content>
		</item>
		
		<item>
			<title>Mastering LibreOffice Headings</title>
			<link>/posts/2013-06-01-mastering-libreoffice-headings/</link>
			<pubDate>Sat, 01 Jun 2013 16:27:31 +0000</pubDate>
			
			<guid>/posts/2013-06-01-mastering-libreoffice-headings/</guid>
			<description>Problem LibreOffice and Microsoft Word are very similar products. However, the default settings are different for both products, especially for Heading Styles. Worse yet, the LibreOffice keyboard shortcut defaults are overridden by other Ubuntu keyboard shortcuts. This article helps redefine the settings and offers a template for better Heading Styles.
What is a Heading Style? A Heading Style is a way to partition a large document into smaller chapters and sub-chapters.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p><a href="http://www.libreoffice.org/">LibreOffice</a> and Microsoft Word are very similar products.  However, the default settings are different for both products, especially for Heading Styles.  Worse yet, the LibreOffice keyboard shortcut defaults are overridden by other Ubuntu keyboard shortcuts.  This article helps redefine the settings and offers a template for better Heading Styles.</p>

<h1 id="what-is-a-heading-style">What is a Heading Style?</h1>

<p>A Heading Style is a way to partition a large document into smaller chapters and sub-chapters.  The Heading Styles take care of automatic numbering and can use numbers, letters, or roman numerals.  Heading Styles are also used for building a Table Of Contents as well as cross references to other locations on the document.</p>

<h1 id="fixing-the-keyboard-mapping">Fixing the Keyboard Mapping</h1>

<p>By default, Microsoft Word uses Alt-Shift-Left and Alt-Shift-Right to promote or demote a paragraph into a Heading Style.  LibreOffice does not have this keyboard mapping.  Instead, they use Ctrl-Alt-Up and Ctrl-Alt-Down.  Unfortunately, these keys are also used to change the current desktop on Ubuntu.</p>

<p>On LibreOffice 3.5 (default version on Ubuntu 12.4), to set the keyboard mapping to Alt-Shift-Left and Alt-Shift-Right choose one of two methods:</p>

<h2 id="method-1-load-a-configuration-file">Method 1:  Load a configuration file</h2>

<p>This method involves downloading a cfg file to the system and using it to replace the default keyboard mappings.  This method will remove any other keyboard customizations you have made.  Use at your own risk.</p>

<ol>
<li>Download <a href="/files/word_headings.cfg">this file</a>.</li>
<li>In LibreOffice, click <strong>Tools</strong>|<strong>Customize&hellip;</strong></li>
<li>Click the <strong>Keyboard</strong> tab.</li>
<li>Click the <strong>Load</strong> button.</li>
<li>Select the file from step 1.</li>
<li>Click <strong>Ok</strong>.</li>
</ol>

<h2 id="method-2-manual-fix">Method 2: Manual Fix</h2>

<p>This method is a bit more involved but you will retain any other keyboard mappings.</p>

<ol>
<li>Click <strong>Tools</strong>|<strong>Customize&hellip;</strong></li>
<li>Click the <strong>Keyboard</strong> tab.</li>
<li>Under Shortcut Keys, be sure the <strong>Writer</strong> radio button is selected.</li>
<li>Select the Shortcut Key: <strong>Alt+Shift+Left.</strong></li>
<li>Under <strong>Functions</strong>, select the <strong>Numbering Category</strong>.</li>
<li>Select the <strong>Promote One Level With Subpoints</strong> Function.</li>
<li>Click <strong>Modify</strong>.</li>
<li>Select the Shortcut Key: <strong>Alt+Shift+Right</strong>.</li>
<li>Select the <strong>Demote One Level With Subpoints</strong> Function.</li>
<li>Click <strong>Modify</strong>.</li>
<li>Click <strong>Ok</strong>.</li>
</ol>

<p><img src="/files/customize.png" alt="Customize..." /></p>

<h1 id="outline-numbering-required">Outline Numbering Required</h1>

<p>The above fixes will not work until Outline Numbering is activated on the current document.  Also, the paragraph must be set to one of the Heading styles.  Simply, press Ctrl-1 to make the current paragraph a Heading 1 style (this is a default keyboard shortcut for LibreOffice).</p>

<h1 id="using-a-template">Using a Template</h1>

<p>The default Heading styles are very ugly.  There is no default numbering scheme and there not good visual queues to help the reader understand the depth of the next section break.  Here&rsquo;s the default template:</p>

<p><img src="/files/original_headers.png" alt="Original Headings" /></p>

<p>And here is an improved template:</p>

<p><img src="/files/better_headers.png" alt="Improved Headings" /></p>

<p>To import the improved template:</p>

<ol>
<li>Download <a href="/files/headings.ott">this file</a>.</li>
<li>Click <strong>File</strong>|<strong>Templates</strong>|<strong>Organize&hellip;</strong>.</li>
<li>Right-click <strong>My Templates</strong>.</li>
<li>Click <strong>Import Template&hellip;</strong>.</li>
<li>Find the file from step 1.</li>
<li>Click Close.</li>
</ol>

<p>Now the template is available for use.  To create a document based on this template:</p>

<ol>
<li>Click <strong>New</strong>|<strong>Templates and Documents</strong>.</li>
<li>Click the template that was imported.</li>
</ol>

<p>At this point, you should have a blank document ready to be used.</p>
]]></content>
		</item>
		
		<item>
			<title>Guice Dependency Injection with Commons Configuration </title>
			<link>/posts/2013-06-01-guice-dependency-injection-commons-configuration/</link>
			<pubDate>Sat, 01 Jun 2013 00:00:50 +0000</pubDate>
			
			<guid>/posts/2013-06-01-guice-dependency-injection-commons-configuration/</guid>
			<description>Problem It&amp;rsquo;s often necessary to have several configurable parameters on a constructor for a class. Instantiating these classes can be a painful exercise in remembering the order of the parameters and the properly passing them down from parent classes.
Commons Configuration Commons Configuration solves the problem of passing several primitive parameters to a class. Instead, of passing each primitive, simply pass a Configuration object and pull the primitives one-by-one.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>It&rsquo;s often necessary to have several configurable parameters on a constructor for a class.  Instantiating these classes can be a painful exercise in remembering the order of the parameters and the properly passing them down from parent classes.</p>

<h1 id="commons-configuration">Commons Configuration</h1>

<p><a href="http://commons.apache.org/proper/commons-configuration/">Commons Configuration</a> solves the problem of passing several primitive parameters to a class.  Instead, of passing each primitive, simply pass a Configuration object and pull the primitives one-by-one.</p>

<p>Consider the following example:</p>
<div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java"><span class="kd">public</span> <span class="nf">class</span> <span class="n">DoSomething</span><span class="p">{</span>
  <span class="kd">public</span> <span class="nf">DoSomething</span><span class="p">(</span><span class="n">String</span> <span class="nf">user</span><span class="p">,</span><span class="n">String</span> <span class="nf">environment</span><span class="p">){</span>
  <span class="p">}</span>
<span class="p">}</span>
<span class="o">&lt;/</span><span class="n">java</span><span class="o">&gt;</span></code></pre></div>
<p>In the above example, it&rsquo;s necessary to change the signature when another parameter needs to be passed into the class.  Thus, all client code using the constructor has to change as well.</p>

<p>Consider the additional code:</p>
<div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java"><span class="kd">public</span> <span class="nf">class</span> <span class="n">DoSomething</span><span class="p">{</span>
  <span class="kd">final</span> <span class="nf">public</span> <span class="kd">static</span> <span class="nf">String</span> <span class="n">CONFIG_CURRENT_USER</span><span class="o">=</span><span class="s">&#34;Something.CurrentUser&#34;</span><span class="p">;</span>
  <span class="kd">final</span> <span class="nf">public</span> <span class="kd">static</span> <span class="nf">String</span> <span class="n">CONFIG_ENVIRONMENT</span><span class="o">=</span><span class="s">&#34;Something.Environment&#34;</span><span class="p">;</span>

  <span class="kd">public</span> <span class="nf">DoSomething</span><span class="p">(</span><span class="n">Configuration</span> <span class="nf">config</span><span class="p">){</span>
    <span class="k">this</span><span class="p">(</span><span class="n">config</span><span class="p">.</span><span class="na">getString</span><span class="p">(</span><span class="n">CONFIG_CURRENT_USER</span><span class="p">),</span><span class="n">config</span><span class="p">.</span><span class="na">getString</span><span class="p">(</span><span class="n">CONFIG_ENVIRONMENT</span><span class="p">));</span>
  <span class="p">}</span>
  <span class="kd">public</span> <span class="nf">DoSomething</span><span class="p">(</span><span class="n">String</span> <span class="nf">user</span><span class="p">,</span><span class="n">String</span> <span class="nf">environment</span><span class="p">){</span>
  <span class="p">}</span>
<span class="p">}</span></code></pre></div>
<p>Now, all the existing client code can remain intact, and a Configuration object can be passed to the new constructor.</p>

<h1 id="integration-with-guice">Integration with Guice</h1>

<p><a href="http://code.google.com/p/google-guice/">Guice</a> now becomes very useful.  Generally speaking, injecting primitive types onto a constructor is not Guice&rsquo;s strength.  However, now that the constructor only needs to inject a Configuration object, leveraging Guice just means adding an Annotation like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java"><span class="kd">public</span> <span class="nf">class</span> <span class="n">DoSomething</span><span class="p">{</span>
 <span class="p">...</span>
  <span class="nd">@Inject</span>
  <span class="kd">public</span> <span class="nf">DoSomething</span><span class="p">(</span><span class="n">Configuration</span> <span class="nf">config</span><span class="p">){</span>
    <span class="k">this</span><span class="p">(</span><span class="n">config</span><span class="p">.</span><span class="na">getString</span><span class="p">(</span><span class="n">CONFIG_CURRENT_USER</span><span class="p">),</span><span class="n">config</span><span class="p">.</span><span class="na">getString</span><span class="p">(</span><span class="n">CONFIG_ENVIRONMENT</span><span class="p">));</span>
  <span class="p">}</span>
 <span class="p">...</span>
<span class="p">}</span></code></pre></div>
<p>Then, just create an injector in the client code:</p>

<pre><code>Properties props=new Properties();
props.load(ClassLoader.getSystemResourceAsStream(&quot;app.properties&quot;));
URL propsUrl=ClassLoader.getSystemResource(&quot;app.properties&quot;).toURI().toURL();

final Configuration config=new PropertiesConfiguration(propsUrl);

Injector injector=Guice.createInjector(new Module() {
    public void configure(Binder binder) {
        binder.bind(Configuration.class).toInstance(config);
    }
});

DoSomething something=injector.getInstance(DoSomething.class);
</code></pre>

<p>It is definitely a lot of client code, but really only needs to happen once for the entire project.  JUnit tests can use the <a href="http://commons.apache.org/proper/commons-configuration/apidocs/org/apache/commons/configuration/MapConfiguration.html">MapConfiguration</a> to define the parameters directly in the code.</p>
]]></content>
		</item>
		
		<item>
			<title>ToDo List Manager</title>
			<link>/posts/2013-05-25-todo-list-manager/</link>
			<pubDate>Sat, 25 May 2013 10:49:04 +0000</pubDate>
			
			<guid>/posts/2013-05-25-todo-list-manager/</guid>
			<description>Overview This a Java Swing-based application that I made to manage my ToDo list. There are several ToDo List Manager applications available. However, they only give a Name and a Done checkbox for each item. This project gives each ToDo item a hierarchy, workflow and relative priority. This makes it much easier for the user to assess which item is most important at any given time, but also keep track of items that are important for the future.</description>
			<content type="html"><![CDATA[

<h1 id="overview">Overview</h1>

<p>This a Java Swing-based application that I made to manage my ToDo list. There are several ToDo List Manager applications available. However, they only give a Name and a Done checkbox for each item. This project gives each ToDo item a hierarchy, workflow and relative priority. This makes it much easier for the user to assess which item is most important at any given time, but also keep track of items that are important for the future.</p>

<h1 id="workflow-status">Workflow Status</h1>

<p>Each ToDo item has a Workflow State. This state is determined explicitly by the user. Here is a list of available states:</p>

<ul>
<li>Open: The item needs to considered.</li>
<li>Accept: The item is worth doing.</li>
<li>Reject: The item is not worth doing.</li>
<li>Close: The item is complete.</li>
<li>Open Pending: The item needs to be considered only after another item changes state.</li>
<li>Accept Pending: The item is worth doing only after another item changes state.</li>
</ul>

<p>The item starts as Open then user determines if the item is really worth doing or not. This allows a brainstorming capability. It also retains the rejected items for later consideration. There is no need to delete an item. Many times, a Rejected item may be reconsidered. A Rejected item may have notes that explain why that item was not considered last time.</p>

<p>The two pending states, Open Pending and Accept Pending, delay the state on an item until other items change state. This is useful when more information will help a decision or if an item can&rsquo;t be completed until another task is done.</p>

<h1 id="inherited-status">Inherited Status</h1>

<p>Each item in the system must be placed within a tree structure hierarchy. Each task is a child of one other task. This allows for each task&rsquo;s state to be conditional on its parents. Consider the following example:</p>

<ul>
<li>The user wants to install Linux.</li>
<li>The user must buy a Linux book.</li>
<li>The user must burn CD&rsquo;s for Linux.</li>
<li>The user must download the iso images.</li>
<li>The user must buy blank CDR&rsquo;s before burning the CD&rsquo;s</li>
</ul>

<p>That&rsquo;s quite a complicated ToDo list. At first glance, it&rsquo;s not obvious what the user should do first. However, he could put this information in a tree to make it more straightforward. For example:</p>

<p><img src="/files/hierarchy_209.jpg" alt="hierarchy" /></p>

<p>Figure 1: Hierarchy of Items</p>

<p>See in Figure 1 how the the &ldquo;Install Linux&rdquo; item is broken down into &ldquo;Buy Linux Book&rdquo; and &ldquo;Burn CD&rsquo;s&rdquo;. Then the &ldquo;Burn CD&rsquo;s&rdquo; item is broken down into &ldquo;Download iso images&rdquo; and &ldquo;Buy Blank CDR&rsquo;s&rdquo;. This makes the dependencies more obvious. Now, if the user happened to find a book that included the Linux disks he needed, he could Reject &ldquo;Burn CD&rsquo;s&rdquo;. Then, &ldquo;Download iso images&rdquo; and &ldquo;Buy Blank CDR&rsquo;s&rdquo; would automatically become Inactive.</p>

<p>There are a number of possible inherited states. They are:</p>

<ul>
<li>Active: If all parents are Accepted.</li>
<li>New: If a parent is Open.</li>
<li>Waiting: If a parent has a Pending state.</li>
<li>Inactive: If a parent is Closed or Rejected.</li>
</ul>

<h1 id="filters">Filters</h1>

<p>A Filter focuses the user&rsquo;s attention only on the relevant ToDo items. Filters tie together Inherited and Workflow status to determine the overall condition of the items. There are six filter states:</p>

<ul>
<li>Assign: Shows all the non-Inactive Open items. Useful for seeing which items need to be Rejected or Accepted.</li>
<li>Work: Shows all the Active Accepted items that have no Active Accepted parents. Useful for seeing what to do today.</li>
<li>Events: Shows all the non-Inactive Pending nodes. Useful for seeing dependencies between unrelated nodes.</li>
<li>Review: Shows all the Closed nodes. Useful for seeing progress over time.</li>
<li>Recycle: Shows all the Rejected nodes. Useful for finding previously rejected items.</li>
<li>No filter: Shows all nodes.</li>
</ul>

<p>The user will likely spend most of their time in the Assign and Work filters. The Assign filter is great for sifting through tasks after a brainstorm session. The Work filter shows only what needs to be completed right now.</p>

<h1 id="priority">Priority</h1>

<p>Each item has a priority once it is Accepted. The priority is always relative to other items. The program has a table-view that is used for setting and viewing priority. In the table, the user simply clicks-and-drags to move the items to match their real priority. Then, the user can click the Status column to Close an item when completed.</p>

<p><img src="/files/table_358.jpg" alt="table" /></p>

<p>Figure 2: Table View</p>

<h1 id="pending">Pending</h1>

<p>Some items will not be children, but will be dependent on others. For example, if the user wants to learn how to use GnuCash after Linux is installed. It&rsquo;s not necessary to make GnuCash the parent of the &ldquo;Install Linux&rdquo; item. Instead the user could simply set a prerequisite of &ldquo;Install Linux&rdquo; for the &ldquo;Learn GnuCash&rdquo; item. Then set the Workflow State of &ldquo;Learn GnuCash&rdquo; to &ldquo;Accepted Pending&rdquo;. In that case, when &ldquo;Install Linux&rdquo; is Closed, &ldquo;Learn GnuCash&rdquo; will be Accepted.</p>

<h1 id="user-interface">User Interface</h1>

<p>Now that we&rsquo;ve discussed the pieces of the software. Take a look at the User Interface:</p>

<p><img src="/files/screenshot_515.jpg" alt="screenshot" /></p>

<p>Figure 3: User Interface</p>

<p>The upper-left corner is the filter selection. The lower-left corner is the Tree. It has a tab to go between the Tree and Table. The right side is the details of the current item. In this case, it is the &ldquo;Install Linux&rdquo; item.</p>

<h1 id="class-model-diagram">Class Model Diagram</h1>

<p>The program consists of several classes, many of them subclasses of Swing classes. Here is the Class Model Diagram for the program:</p>

<p><a href="/files/diligent_large_990.png"><img src="/files/diligent_small_660.png" alt="class model diagram" /></a></p>

<p>Figure 4: Class Model Diagram</p>

<p>The Diligent class is the entry point of the program. It instantiates the DiligentFrame class. DiligentFrame is a container for all the Swing Components. It instantiates a table and tree model, DiligentTableModel and DiligentTreeModel respectively. DiligentTableModel gets its data from the DiligentTreeModel. DiligentTreeModel is a subclass of Swing&rsquo;s DefaultTreeModel. DiligentTreeModel uses DiligentNode for all of its nodes.</p>

<p>DiligentNode is the main container for all the information of every ToDo item. It is a subclass of Swing&rsquo;s DefaultMutableTreeNode. It has a static class member variable, filter, for filtering the entire tree. filter is of class DiligentFilter. DiligentFilter has parameters on its methods to filter for both the tree and the table views. Filtering for a tree allows the parents to not be filtered out if a child is not filtered out.</p>

<p>There are few classes that have a DiligentNode within them. DiligentDetails is responsible for showing the detailed information about each node. DiligentNodeSelector is a special dialog for choosing a single node. DiligentEvent analyzes the state of a node to trigger a change in state of another node.</p>

<p>There are four miscellaneous classes within the architecture. DateParse contains a static method to convert a String to a Date. The Period class contains static methods to convert interval dates to and from a number of milliseconds. For example, an interval date might be &ldquo;2w1d&rdquo; for two weeks and one day. The ResourceManager is responsible for loading the icons and can be optimized to read the icons only once from the disk. The DiligentNodeRenderer is used by the JTree to show the icons next to each ToDo item.</p>

<h1 id="future-upgrades">Future Upgrades</h1>

<p>It&rsquo;s easy to go use this architecture for many things. This program could become a full Project Management system. It currently saves all the information in a single file. It could be modified to save the information to a central database with several users. Each item could have an owning person or group assigned to it. For now, it works great for managing my own personal tasks.</p>

<h1 id="conclusion">Conclusion</h1>

<p>This program works great for managing personal tasks. For a copy of this program <a href="http://sourceforge.net/projects/diligent/">download it here</a>.</p>
]]></content>
		</item>
		
		<item>
			<title>Tell Maven to not include src/test/resources in Eclipse</title>
			<link>/posts/2011-05-03-tell-maven-not-include-srctestresources-eclipse/</link>
			<pubDate>Tue, 03 May 2011 13:13:26 +0000</pubDate>
			
			<guid>/posts/2011-05-03-tell-maven-not-include-srctestresources-eclipse/</guid>
			<description>Scope When creating a jar-with-dependencies, the resources in src/test/resources are automatically added to the jar. This folder often contains a .properties file only valid for the test environment and should not be included in the final jar.
Additional Note Adding a resource tag to exclude the directory is ignored by Maven running in Eclipse. It&amp;rsquo;s not clear why.
Solution Right-click the source folder &amp;ldquo;src/test/resources&amp;rdquo; and click &amp;ldquo;Build Path|Configure Exclusion/Inclusion Filters&amp;hellip;&amp;rdquo;.</description>
			<content type="html"><![CDATA[

<h1 id="scope">Scope</h1>

<p>When creating a jar-with-dependencies, the resources in src/test/resources are automatically added to the jar.  This folder often contains a .properties file only valid for the test environment and should not be included in the final jar.</p>

<h1 id="additional-note">Additional Note</h1>

<p>Adding a <code>resource</code> tag to exclude the directory is ignored by Maven running in Eclipse.  It&rsquo;s not clear why.</p>

<h1 id="solution">Solution</h1>

<p>Right-click the source folder &ldquo;src/test/resources&rdquo; and click &ldquo;Build Path|Configure Exclusion/Inclusion Filters&hellip;&rdquo;.  Add an exclusion filter of <code>**</code>.  Now the resources will not be included in the final jar file.</p>

<h1 id="testing-from-eclipse">Testing from Eclipse</h1>

<p>When running from eclipse, it is possible to include the content of src/test/resources in the classpath.  Here&rsquo;s how:</p>

<ol>
<li>Right-click src/main/java</li>
<li>Click &ldquo;Properties&rdquo;</li>
<li>Click &ldquo;Run/Debug Settings&rdquo;</li>
<li>Select a Launch Configuration you want to change.</li>
<li>Click Edit.</li>
<li>Click the Classpath tab.</li>
<li>Click Advanced&hellip;</li>
<li>Click Add Folders and Click Ok</li>
<li>Select the src/test/resources folder on your project.</li>
</ol>

<p>Now when running from eclipse, the test resources are in the classpath.  It maybe necessary to make this change for several launch configurations.</p>
]]></content>
		</item>
		
		<item>
			<title>Tell Firefox to open PDFs external</title>
			<link>/posts/2011-04-21-tell-firefox-open-pdfs-external/</link>
			<pubDate>Thu, 21 Apr 2011 12:37:43 +0000</pubDate>
			
			<guid>/posts/2011-04-21-tell-firefox-open-pdfs-external/</guid>
			<description> Problem By default Firefox opens PDF files using an Adobe plug-in which often fails and is trapped inside the browser.
Solution  Click Edit|Preferences|Applications. Search for PDF Change the Action to Use Adobe Reader (default).  </description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>By default Firefox opens PDF files using an Adobe plug-in which often fails and is trapped inside the browser.</p>

<h1 id="solution">Solution</h1>

<ol>
<li>Click Edit|Preferences|Applications.</li>
<li>Search for PDF</li>
<li>Change the Action to <code>Use Adobe Reader (default)</code>.</li>
</ol>
]]></content>
		</item>
		
		<item>
			<title>NAT&#39;ing two sub-nets thru Linux</title>
			<link>/posts/2011-04-18-nating-two-sub-nets-thru-linux/</link>
			<pubDate>Mon, 18 Apr 2011 23:39:29 +0000</pubDate>
			
			<guid>/posts/2011-04-18-nating-two-sub-nets-thru-linux/</guid>
			<description>Scope This page describes how to configure Linux to properly route network traffic between two separate networks. This works the same for wireless and wired connections.
IP Address of Middle Have a computer that has a NIC with an IP address on each network. I&amp;rsquo;m not sure if this is called a router or a bridge or something else. For this page, I call this computer the &amp;ldquo;middle&amp;rdquo;. Use ifconfig to verify that each network card is up.</description>
			<content type="html"><![CDATA[

<h1 id="scope">Scope</h1>

<p>This page describes how to configure Linux to properly route network traffic between two separate networks.  This works the same for wireless and wired connections.</p>

<h1 id="ip-address-of-middle">IP Address of Middle</h1>

<p>Have a computer that has a NIC with an IP address on each network.  I&rsquo;m not sure if this is called a router or a bridge or something else.  For this page, I call this computer the &ldquo;middle&rdquo;.  Use <code>ifconfig</code> to verify that each network card is up.  Try pinging a host on each network as a second check.</p>

<h1 id="routing-of-middle">Routing of Middle</h1>

<p>Check the routing for each of the cards in the middle.  If pinging failed, it was probably because routing is broken.  Use <code>netstat -nr</code> to quickly see the routes to each subnet.  Then, just add routes to the appropriate NIC for each subnet.  Adding a route will look like this:</p>

<pre>
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth0
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth1
</pre>

<h1 id="nat-in-middle">NAT in Middle</h1>

<p>Turn on NAT&rsquo;ing on the middle:</p>

<p><code>echo 1 &gt; /proc/sys/net/ipv4/ip_forward</code></p>

<h1 id="route-the-clients">Route the clients</h1>

<p>For each client machine, simply adjust the routing to use the middle as a gateway.  I&rsquo;m assuming the middle has the IP address of .5 in each network (eg 192.168.0.5 and 192.168.1.5).</p>

<p>A computer on the 192.168.1.0 network would use the following command to NAT to 192.168.0.0:
<pre>
route add -net 192.168.0.0 netmask 255.255.255.0 gateway 192.168.1.5 dev eth0
</pre></p>

<p>This tells the the client machine that all 192.168.0.x traffic goes thru eth0 to 192.168.1.5 for further routing.  At that point it will use the routing tables in middle jump to the 192.168.0.x subnet and go to the target machine.</p>
]]></content>
		</item>
		
		<item>
			<title>A POM to create a jar, but exclude the config file</title>
			<link>/posts/2011-02-23-pom-create-jar-exclude-config-file/</link>
			<pubDate>Wed, 23 Feb 2011 12:16:00 +0000</pubDate>
			
			<guid>/posts/2011-02-23-pom-create-jar-exclude-config-file/</guid>
			<description>Problem I want to have a POM that will create a JAR file with all dependencies, but exclude src/main/resources/config.properties.
Solution  Make a folder (not a source folder) in Eclipse called src/main/eclipse. Put the config file in the new folder. Add the folder to the class path by going into the Run Configuration.  Adding the folder to src/test/resources does not work unless src/test/resources is not a code folder.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>I want to have a POM that will create a JAR file with all dependencies, but exclude src/main/resources/config.properties.</p>

<h1 id="solution">Solution</h1>

<ol>
<li>Make a folder (not a source folder) in Eclipse called src/main/eclipse.</li>
<li>Put the config file in the new folder.</li>
<li>Add the folder to the class path by going into the Run Configuration.</li>
</ol>

<p>Adding the folder to src/test/resources does not work unless src/test/resources is not a code folder.</p>

<p>I tried this, but somehow Maven always wants to move that file!</p>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"> <span class="nt">&lt;build&gt;</span>
 	<span class="nt">&lt;pluginManagement&gt;</span>
 		<span class="nt">&lt;plugins&gt;</span>
 			<span class="nt">&lt;plugin&gt;</span>
 				<span class="nt">&lt;groupId&gt;</span>org.maven.apache.plugins<span class="nt">&lt;/groupId&gt;</span>
 				<span class="nt">&lt;artifactId&gt;</span>maven-resources-plugin<span class="nt">&lt;/artifactId&gt;</span>
 				<span class="nt">&lt;version&gt;</span>2.4.3<span class="nt">&lt;/version&gt;</span>
 			<span class="nt">&lt;/plugin&gt;</span>
 		<span class="nt">&lt;/plugins&gt;</span>
 	<span class="nt">&lt;/pluginManagement&gt;</span>
  	<span class="nt">&lt;resources&gt;</span>
  		<span class="nt">&lt;resource&gt;</span>
  			<span class="nt">&lt;directory&gt;</span>src/main/resources<span class="nt">&lt;/directory&gt;</span>
  			<span class="nt">&lt;excludes&gt;</span>
  				<span class="nt">&lt;exclude&gt;</span>**/*.properties<span class="nt">&lt;/exclude&gt;</span>
  			<span class="nt">&lt;/excludes&gt;</span>
  		<span class="nt">&lt;/resource&gt;</span>
  	<span class="nt">&lt;/resources&gt;</span>
  	<span class="nt">&lt;plugins&gt;</span>
  		<span class="nt">&lt;plugin&gt;</span>
  			<span class="nt">&lt;artifactId&gt;</span>maven-assembly-plugin<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;configuration&gt;</span>
                <span class="nt">&lt;archive&gt;</span>
            		<span class="nt">&lt;manifestFile&gt;</span>src/main/resources/MANIFEST.MF<span class="nt">&lt;/manifestFile&gt;</span>
          		<span class="nt">&lt;/archive&gt;</span>
                <span class="nt">&lt;descriptorRefs&gt;</span>
                    <span class="nt">&lt;descriptorRef&gt;</span>jar-with-dependencies<span class="nt">&lt;/descriptorRef&gt;</span>
                <span class="nt">&lt;/descriptorRefs&gt;</span>
        		<span class="nt">&lt;excludes&gt;</span>
        			<span class="nt">&lt;exclude&gt;</span>**/config.properties<span class="nt">&lt;/exclude&gt;</span>
        		<span class="nt">&lt;/excludes&gt;</span>
            <span class="nt">&lt;/configuration&gt;</span>
  		<span class="nt">&lt;/plugin&gt;</span>
  		<span class="nt">&lt;plugin&gt;</span>
        	<span class="nt">&lt;groupId&gt;</span>org.apache.maven.plugins<span class="nt">&lt;/groupId&gt;</span>
        	<span class="nt">&lt;artifactId&gt;</span>maven-surefire-plugin<span class="nt">&lt;/artifactId&gt;</span>
        	<span class="nt">&lt;version&gt;</span>2.7.2<span class="nt">&lt;/version&gt;</span>
        	<span class="nt">&lt;configuration&gt;</span>
          		<span class="nt">&lt;skipTests&gt;</span>true<span class="nt">&lt;/skipTests&gt;</span>
        	<span class="nt">&lt;/configuration&gt;</span>
        <span class="nt">&lt;/plugin&gt;</span>
        <span class="nt">&lt;plugin&gt;</span>
        	<span class="nt">&lt;groupId&gt;</span>org.apache.maven.plugins<span class="nt">&lt;/groupId&gt;</span>
        	<span class="nt">&lt;artifactId&gt;</span>maven-resource-plugin<span class="nt">&lt;/artifactId&gt;</span>
        	<span class="nt">&lt;version&gt;</span>2.4.3<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;/plugin&gt;</span>
  	<span class="nt">&lt;/plugins&gt;</span>
  <span class="nt">&lt;/build&gt;</span></code></pre></div>
<h1 id="references">References</h1>

<ul>
<li><a href="http://stackoverflow.com/questions/2728993/how-to-exclude-poperties-file-from-jar-file">http://stackoverflow.com/questions/2728993/how-to-exclude-poperties-file-from-jar-file</a></li>
<li><a href="http://stackoverflow.com/questions/4113697/in-maven-how-to-exclude-resources-from-the-generated-jar">http://stackoverflow.com/questions/4113697/in-maven-how-to-exclude-resources-from-the-generated-jar</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Fix Eclipse Data Tools Plugin (DTP) on Ubuntu</title>
			<link>/posts/2011-02-14-fix-eclipse-data-tools-plugin-dtp-ubuntu/</link>
			<pubDate>Mon, 14 Feb 2011 23:32:49 +0000</pubDate>
			
			<guid>/posts/2011-02-14-fix-eclipse-data-tools-plugin-dtp-ubuntu/</guid>
			<description>Solution rm ~/workspace/.metadata/.plugins/org.eclipse.datatools.sqltools.result/</description>
			<content type="html"><![CDATA[

<h1 id="solution">Solution</h1>

<p><code>rm ~/workspace/.metadata/.plugins/org.eclipse.datatools.sqltools.result/</code></p>
]]></content>
		</item>
		
		<item>
			<title>sudo: unable to execute /bin/rm: Success</title>
			<link>/posts/2011-02-09-sudo-unable-execute-binrm-success/</link>
			<pubDate>Wed, 09 Feb 2011 10:35:14 +0000</pubDate>
			
			<guid>/posts/2011-02-09-sudo-unable-execute-binrm-success/</guid>
			<description>Problem When trying to delete a bunch of files using something like sudo rm *, I get this error:
sudo: unable to execute /bin/rm: Success
Solution This is caused by a buffer overflow when expanding the *. Instead, use find. Here&amp;rsquo;s an example:
sudo find . -name &#39;*&#39; -exec rm {} \;
Note that the wildcard (*) is enclosed in single quotes which will (unlike double quotes) prevent it from expanding.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>When trying to delete a bunch of files using something like <code>sudo rm *</code>, I get this error:</p>

<p><code>sudo: unable to execute /bin/rm: Success</code></p>

<h1 id="solution">Solution</h1>

<p>This is caused by a buffer overflow when expanding the <code>*</code>.  Instead, use <code>find</code>.  Here&rsquo;s an example:</p>

<p><code>sudo find . -name '*' -exec rm {} \;</code></p>

<p>Note that the wildcard (<code>*</code>) is enclosed in single quotes which will (unlike double quotes) prevent it from expanding.</p>
]]></content>
		</item>
		
		<item>
			<title>log4cxx Hello World:  Logging for C&#43;&#43;</title>
			<link>/posts/2011-02-04-log4cxx-hello-world-logging-c/</link>
			<pubDate>Fri, 04 Feb 2011 22:56:07 +0000</pubDate>
			
			<guid>/posts/2011-02-04-log4cxx-hello-world-logging-c/</guid>
			<description>Here&amp;rsquo;s how to add simple logging to any C++ application without a big hassle. At the time of writing this page, Boost.Log is not yet officially released with Boost.
 Install the log4cxx. sudo apt-get install liblog4cxx Write code:
# include &amp;#34;log4cxx/logger.h&amp;#34; # include &amp;#34;log4cxx/basicconfigurator.h&amp;#34; # include &amp;#34;log4cxx/helpers/exception.h&amp;#34;  using namespace log4cxx; using namespace log4cxx::helpers; int main(){ BasicConfigurator::configure(); LoggerPtr logger(Logger::getLogger(&amp;#34;main&amp;#34;)); LOG4CXX_DEBUG(logger, &amp;#34;Hello World&amp;#34;); }  Compile with -llog4cxx.
 Run it.</description>
			<content type="html"><![CDATA[<p>Here&rsquo;s how to add simple logging to any C++ application without a big hassle.  At the time of writing this page, Boost.Log is not yet officially released with Boost.</p>

<ol>
<li>Install the log4cxx.  <code>sudo apt-get install liblog4cxx</code></li>

<li><p>Write code:</p>
<div class="highlight"><pre class="chroma"><code class="language-cpp" data-lang="cpp"><span class="cp"># include &#34;log4cxx/logger.h&#34;
</span><span class="cp"># include &#34;log4cxx/basicconfigurator.h&#34;
</span><span class="cp"># include &#34;log4cxx/helpers/exception.h&#34;
</span><span class="cp"></span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">log4cxx</span><span class="p">;</span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">log4cxx</span><span class="o">::</span><span class="n">helpers</span><span class="p">;</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">(){</span>
	<span class="n">BasicConfigurator</span><span class="o">::</span><span class="n">configure</span><span class="p">();</span>
	<span class="n">LoggerPtr</span> <span class="n">logger</span><span class="p">(</span><span class="n">Logger</span><span class="o">::</span><span class="n">getLogger</span><span class="p">(</span><span class="s">&#34;main&#34;</span><span class="p">));</span>
	<span class="n">LOG4CXX_DEBUG</span><span class="p">(</span><span class="n">logger</span><span class="p">,</span> <span class="s">&#34;Hello World&#34;</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></li>

<li><p>Compile with <code>-llog4cxx</code>.</p></li>

<li><p>Run it.</p></li>
</ol>

<p>You should see something like:</p>

<p><code>1 [0x3f956f44b980] DEBUG main null - Hello World</code></p>
]]></content>
		</item>
		
		<item>
			<title>Creating a custom META-INF/MANIFEST.MF file in the maven-assembly-plugin</title>
			<link>/posts/2011-02-02-creating-custom-meta-infmanifestmf-file-maven-assembly-plugin/</link>
			<pubDate>Wed, 02 Feb 2011 13:21:43 +0000</pubDate>
			
			<guid>/posts/2011-02-02-creating-custom-meta-infmanifestmf-file-maven-assembly-plugin/</guid>
			<description> Problem I want to add some special parameter to my MANIFEST.MF, but I&amp;rsquo;m using the maven-assembly-plugin to build my project.
Solution Change the POM to look something like this:
&amp;lt;plugin&amp;gt; &amp;lt;artifactId&amp;gt;maven-assembly-plugin&amp;lt;/artifactId&amp;gt; &amp;lt;configuration&amp;gt; &amp;lt;archive&amp;gt; &amp;lt;manifestFile&amp;gt;src/main/resources/MANIFEST.MF&amp;lt;/manifestFile&amp;gt; &amp;lt;/archive&amp;gt; &amp;lt;descriptorRefs&amp;gt; &amp;lt;descriptorRef&amp;gt;jar-with-dependencies&amp;lt;/descriptorRef&amp;gt; &amp;lt;/descriptorRefs&amp;gt; &amp;lt;/configuration&amp;gt; &amp;lt;/plugin&amp;gt; &amp;lt;plugin&amp;gt;</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>I want to add some special parameter to my MANIFEST.MF, but I&rsquo;m using the maven-assembly-plugin to build my project.</p>

<h1 id="solution">Solution</h1>

<p>Change the POM to look something like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml">  		<span class="nt">&lt;plugin&gt;</span>
  			<span class="nt">&lt;artifactId&gt;</span>maven-assembly-plugin<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;configuration&gt;</span>
                <span class="nt">&lt;archive&gt;</span>
            		<span class="nt">&lt;manifestFile&gt;</span>src/main/resources/MANIFEST.MF<span class="nt">&lt;/manifestFile&gt;</span>
          		<span class="nt">&lt;/archive&gt;</span>
                <span class="nt">&lt;descriptorRefs&gt;</span>
                    <span class="nt">&lt;descriptorRef&gt;</span>jar-with-dependencies<span class="nt">&lt;/descriptorRef&gt;</span>
                <span class="nt">&lt;/descriptorRefs&gt;</span>
            <span class="nt">&lt;/configuration&gt;</span>
  		<span class="nt">&lt;/plugin&gt;</span>
  		<span class="nt">&lt;plugin&gt;</span></code></pre></div>]]></content>
		</item>
		
		<item>
			<title>error while loading shared libraries: libcurlpp.so.0: cannot open shared object file: No such file or directory</title>
			<link>/posts/2011-02-01-error-while-loading-shared-libraries-libcurlppso0-cannot-open-shared-object-file-no-such-fil/</link>
			<pubDate>Tue, 01 Feb 2011 22:14:47 +0000</pubDate>
			
			<guid>/posts/2011-02-01-error-while-loading-shared-libraries-libcurlppso0-cannot-open-shared-object-file-no-such-fil/</guid>
			<description> Problem I was able to compile and link a program using curlpp, but I get this error:
error while loading shared libraries: libcurlpp.so.0: cannot open shared object file: No such file or directory
Solution This will may only work in Ubuntu:
 sudo bash -c &amp;quot;echo /usr/local/lib/ &amp;gt; /etc/ld.so.conf.d/local.conf&amp;quot; sudo /sbin/ldconfig  References    </description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>I was able to compile and link a program using curlpp, but I get this error:</p>

<p><code>error while loading shared libraries: libcurlpp.so.0: cannot open shared object file: No such file or directory</code></p>

<h1 id="solution">Solution</h1>

<p>This will may only work in Ubuntu:</p>

<ol>
<li><code>sudo bash -c &quot;echo /usr/local/lib/ &gt; /etc/ld.so.conf.d/local.conf&quot;</code></li>
<li><code>sudo /sbin/ldconfig</code></li>
</ol>

<h1 id="references">References</h1>

<ul>
<li><http://jackvalmadre.wordpress.com/2009/11/20/setting-up-curlpp-in-ubuntu/# comment-82></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Changing GRUB Default Boot Kernel in Ubuntu 10.4</title>
			<link>/posts/2011-01-31-changing-grub-default-boot-kernel-ubuntu-104/</link>
			<pubDate>Mon, 31 Jan 2011 21:10:04 +0000</pubDate>
			
			<guid>/posts/2011-01-31-changing-grub-default-boot-kernel-ubuntu-104/</guid>
			<description> Problem You want to always boot a certain kernel in Ubuntu. There is no /boot/grub/menu.lst.
Solution  Edit this file: /etc/default/grub/ and add:  GRUB_DEFAULT=saved GRUB_SAVEDEFAULT=true  Run this utility: sudo update-grub  Now next time you reboot, choose your favorite kernel. This decision will be remembered.
References  https://help.ubuntu.com/community/Grub2 http://ubuntuforums.org/archive/index.php/t-1453448.html  </description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>You want to always boot a certain kernel in Ubuntu.  There is no /boot/grub/menu.lst.</p>

<h1 id="solution">Solution</h1>

<ol>
<li>Edit this file: <code>/etc/default/grub/</code> and add:
<pre>
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
</pre></li>
<li>Run this utility: <code>sudo update-grub</code></li>
</ol>

<p>Now next time you reboot, choose your favorite kernel.  This decision will be remembered.</p>

<h1 id="references">References</h1>

<ul>
<li><a href="https://help.ubuntu.com/community/Grub2">https://help.ubuntu.com/community/Grub2</a></li>
<li><a href="http://ubuntuforums.org/archive/index.php/t-1453448.html">http://ubuntuforums.org/archive/index.php/t-1453448.html</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Getting started with LibSVM.</title>
			<link>/posts/2011-01-29-getting-started-libsvm/</link>
			<pubDate>Sat, 29 Jan 2011 21:15:18 +0000</pubDate>
			
			<guid>/posts/2011-01-29-getting-started-libsvm/</guid>
			<description>Intro This page is a tutorial on how to use LibSVM to a solve a simple, real world problem using a bash shell.
Process  Download LibSVM. Untar and run make. ./configure not necessary. Read Section A of this article. We are going to try the example in section A.1. Download the training data here. Scale the data: ./libsvm-3.0/svm-scale -l -1 -u 1 -s range1 svmguide1 &amp;gt; svmguide1.scale. This forces the dataset to be between -1 and 1.</description>
			<content type="html"><![CDATA[

<h1 id="intro">Intro</h1>

<p>This page is a tutorial on how to use LibSVM to a solve a simple, real world problem using a bash shell.</p>

<h1 id="process">Process</h1>

<ol>
<li>Download <a href="http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz">LibSVM</a>.</li>
<li>Untar and run <code>make</code>.  <code>./configure</code> not necessary.</li>
<li>Read Section A of <a href="http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf">this article</a>.  We are going to try the example in section A.1.</li>
<li>Download the training data <a href="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/svmguide1">here</a>.</li>
<li>Scale the data: <code>./libsvm-3.0/svm-scale -l -1 -u 1 -s range1 svmguide1 &gt; svmguide1.scale</code>.  This forces the dataset to be between -1 and 1.  The name of the scale is <code>range1</code> which will be used later.</li>
<li>Find the ideal parameter values: <code>cd libsvm-3.0/tools/; python grid.py ../../svmguide1.scale; cd -</code>.  A plot will appear.  this process takes significantly longer than the others.  Just keep waiting.  You have to <code>cd</code> to the tools directory for the python script to run properly.  I got the result of <code>2.0 2.0 96.9893</code>.  I believe the first parameter is <code>c</code> and <code>g</code> is the second.</li>
<li>Using the above parameters, create the model: <code>libsvm-3.0/svm-train -c 2 -g 2 svmguide1.scale</code>.  There will now be a svmguide1.scale.model file in your current directory.</li>
<li>Download the test data <a href="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/svmguide1.t">here</a>.</li>
<li>Scale the test data: <code>./libsvm-3.0/svm-scale -r range1 svmguide1.t &gt; svmguide1.t.scale</code></li>
<li>Run the test: <code>./libsvm-3.0/svm-predict svmguide1.t.scale svmguide1.scale.model svmguide1.t.predict</code></li>
<li>You should see an accuracy of &ldquo;96.875%&rdquo;.</li>
</ol>

<p>Note:  it would be easier to run <code>tools/easy.py</code> but this helps get an understanding of what it does underneath.</p>

<h1 id="data-files">Data Files</h1>

<p>The data files are a space-delimited array of tuples that start with the output classification.  A sample line looks like this:</p>

<p><code>0 1:6.640930e-01 2:2.540829e+01 3:-1.155107e-01 4:4.739574e+01</code>.</p>

<p>The above line shows a result for category &ldquo;0&rdquo;.  The first parameter is 0.6640930, but is represented with the parameter number, a colon, and the number itself in scientific notation.  The number does not have to be in scientific notation and is usually not in that form after it is scaled.</p>

<p>Note that both training and test data have the exact same format.  An interesting test is to run the model on the training data.  I tried it on the above and got 97.1188% accuracy.  If the accuracy is bad on the training data, there are probably serious issues.</p>

<h1 id="scaled-data">Scaled Data</h1>

<p>The scaling information for the scaled files are not stored in the data file.  Instead there is a special file to store this information.  <code>svm-scale</code> uses the <code>-s</code> parameter to save this special file and the <code>-r</code> parameter to read the file and apply the same scaling as the training data.  Here are the contents of the file produced by the above commands:
<pre>
x
-1 1
1 0 297.05
2 -4.555206 581.0731
3 -0.7524385 0.7170606
4 8.157474000000001 180
</pre></p>

<h1 id="details">Details</h1>

<p>The article we used as a basis was clear on the point to be sure to scale and optimize the parameters.  In this case, parameter optimization didn&rsquo;t add much accuracy but other examples in that article show that it can be a huge difference.</p>

<h1 id="prediction">Prediction</h1>

<p>Training and prediction are basically the same command.  The predicted results are stored in yet another file.  This file just contains the predicted values for each line of input.  I made my own set of test data here:
<pre>
0 1:2.612900e+00 2:1.832880e+01 3:1.222401e-01 4:7.389243e+01
0 1:2.004300e+01 2:2.822780e+02 3:2.021259e-01 4:1.411875e+02
</pre></p>

<p>The first line was taken from a &ldquo;0&rdquo; and the second line was taken from a &ldquo;1&rdquo; in the sample data set.  As expected, <code>svm-predict</code> gave an accuracy of 50% and the predict&rsquo;s output file has a 0 and 1 for the expecting line.  I get an error when trying a letter or a &ldquo;?&rdquo; mark in the first character of every line.  If I put a space for the first character, I get a 100% accuracy result and the predict file shows all &ldquo;1&rsquo;s&rdquo;..beware of this wrong answer.</p>

<p>The best strategy when doing prediction is to simply leave the first character of every line as a &ldquo;0&rdquo;.</p>
]]></content>
		</item>
		
		<item>
			<title>X11 connection rejected because of wrong authentication.</title>
			<link>/posts/2011-01-21-x11-connection-rejected-because-wrong-authentication/</link>
			<pubDate>Fri, 21 Jan 2011 10:47:49 +0000</pubDate>
			
			<guid>/posts/2011-01-21-x11-connection-rejected-because-wrong-authentication/</guid>
			<description>Problem After doing a sudo, I get this error:  X11 connection rejected because of wrong authentication. 
Solution  Be sure the non-root user can get X working. Try running xterm. Run xauth list as the non-root user. You should see something like:  machinename/unix:14 MIT-MAGIC-COOKIE-1 058aexd13d0436b3463abd79acd31234
 Run echo $DISPLAY to see which number is used for this host. (eg localhost:14.0 means 14) Login as root. sudo -i Add the cookie.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>After doing a <code>sudo</code>, I get this error:
<pre>
X11 connection rejected because of wrong authentication.
</pre></p>

<h1 id="solution">Solution</h1>

<ol>
<li>Be sure the non-root user can get X working.  Try running <code>xterm</code>.</li>
<li>Run <code>xauth list</code> as the non-root user.  You should see something like:</li>
</ol>

<p><code>machinename/unix:14  MIT-MAGIC-COOKIE-1  058aexd13d0436b3463abd79acd31234</code></p>

<ol>
<li>Run <code>echo $DISPLAY</code> to see which number is used for this host.  (eg <code>localhost:14.0</code> means 14)</li>
<li>Login as root.  <code>sudo -i</code></li>
<li>Add the cookie.  <code>auth add machinename/unix:14  MIT-MAGIC-COOKIE-1  058aexd13d0436b3463abd79acd31234</code></li>
</ol>

<h1 id="references">References</h1>

<ul>
<li><a href="http://jianmingli.com/wp/?p=724">http://jianmingli.com/wp/?p=724</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Using a webproxy with Maven in Eclipse</title>
			<link>/posts/2011-01-19-using-webproxy-maven-eclipse/</link>
			<pubDate>Wed, 19 Jan 2011 17:03:07 +0000</pubDate>
			
			<guid>/posts/2011-01-19-using-webproxy-maven-eclipse/</guid>
			<description>Problem Maven doesn&amp;rsquo;t seem to connect to the Internet. I have the http_proxy environment variables set. I also configured Eclipse Preferences|General|Network Connections to connect to my proxy. However, when I start up eclipse, I get something like this:  1/19/11 3:25:34 PM CST: Updating index central|http://repo1.maven.org/maven2 1/19/11 3:25:35 PM CST: Unable to update index for central|http://repo1.maven.org/maven2 
Solution The m2 Maven plugin for Eclipse ignores the http_proxy Environment variable and the Network Connection configuration.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>Maven doesn&rsquo;t seem to connect to the Internet.  I have the http_proxy environment variables set.  I also configured Eclipse Preferences|General|Network Connections to connect to my proxy.  However, when I start up eclipse, I get something like this:
<pre>
1/19/11 3:25:34 PM CST: Updating index central|<a href="http://repo1.maven.org/maven2">http://repo1.maven.org/maven2</a>
1/19/11 3:25:35 PM CST: Unable to update index for central|<a href="http://repo1.maven.org/maven2">http://repo1.maven.org/maven2</a>
</pre></p>

<h1 id="solution">Solution</h1>

<p>The m2 Maven plugin for Eclipse ignores the http_proxy Environment variable and the Network Connection configuration.  Instead, it&rsquo;s necessary to set the proxy using the settings.xml file.  Settings.xml is found on your home directory.  Here&rsquo;s an example:</p>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="nt">&lt;settings</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/SETTINGS/1.0.0&#34;</span>
  <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
  <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/SETTINGS/1.0.0
</span><span class="s">                      http://maven.apache.org/xsd/settings-1.0.0.xsd&#34;</span><span class="nt">&gt;</span>
  <span class="nt">&lt;localRepository/&gt;</span>
  <span class="nt">&lt;interactiveMode/&gt;</span>
  <span class="nt">&lt;usePluginRegistry/&gt;</span>
  <span class="nt">&lt;offline/&gt;</span>
  <span class="nt">&lt;pluginGroups/&gt;</span>
  <span class="nt">&lt;servers/&gt;</span>
  <span class="nt">&lt;mirrors/&gt;</span>
  <span class="nt">&lt;proxies&gt;</span>
    <span class="nt">&lt;proxy&gt;</span>
      <span class="nt">&lt;id&gt;</span>myproxy<span class="nt">&lt;/id&gt;</span>
      <span class="nt">&lt;active&gt;</span>true<span class="nt">&lt;/active&gt;</span>
      <span class="nt">&lt;protocol&gt;</span>http<span class="nt">&lt;/protocol&gt;</span>
      <span class="nt">&lt;host&gt;</span>proxy.somewhere.com<span class="nt">&lt;/host&gt;</span>
      <span class="nt">&lt;port&gt;</span>8080<span class="nt">&lt;/port&gt;</span>
      <span class="nt">&lt;username&gt;</span>proxyuser<span class="nt">&lt;/username&gt;</span>
      <span class="nt">&lt;password&gt;</span>somepassword<span class="nt">&lt;/password&gt;</span>
      <span class="nt">&lt;nonProxyHosts&gt;</span>*.google.com|ibiblio.org<span class="nt">&lt;/nonProxyHosts&gt;</span>
    <span class="nt">&lt;/proxy&gt;</span>
  <span class="nt">&lt;/proxies&gt;</span>
  <span class="nt">&lt;profiles/&gt;</span>
  <span class="nt">&lt;activeProfiles/&gt;</span>
<span class="nt">&lt;/settings&gt;</span></code></pre></div>
<p>There is a hyperlink to this file in Window|Preferences|Maven|User Settings in Eclipse.  After making your changes, just click &ldquo;Update Settings&rdquo;.</p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://maven.apache.org/settings.html">Maven Settings Reference</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Using Waffles for Naive Bayes</title>
			<link>/posts/2011-01-17-using-waffles-naive-bayes/</link>
			<pubDate>Mon, 17 Jan 2011 10:47:42 +0000</pubDate>
			
			<guid>/posts/2011-01-17-using-waffles-naive-bayes/</guid>
			<description>Intro Waffles is an OpenSource machine learning library for C++ that also has a command-line interface. I am interested in using it for some projects, but I the documentation does not have full examples on how to use it, just a few one-liners here and there. The Wikipedia article on Naive Bayes has a good example walk-thru of Naive Bayes. I intend to implement that example with Waffles.
Data The Wikipedia article claims the following input data can predict gender:</description>
			<content type="html"><![CDATA[

<h1 id="intro">Intro</h1>

<p><a href="http://waffles.sourceforge.net/">Waffles</a> is an OpenSource machine learning library for C++ that also has a command-line interface.  I am interested in using it for some projects, but I the documentation does not have full  examples on how to use it, just a few one-liners here and there.  The <a href="http://en.wikipedia.org/wiki/Naive_Bayes_classifier">Wikipedia article on Naive Bayes</a> has a good example walk-thru of Naive Bayes.  I intend to implement that example with Waffles.</p>

<h1 id="data">Data</h1>

<p>The Wikipedia article claims the following input data can predict gender:</p>

<table>
<thead>
<tr>
<th>sex</th>
<th>height</th>
<th>weight</th>
<th>foot size</th>
</tr>
</thead>

<tbody>
<tr>
<td>male</td>
<td>6</td>
<td>180</td>
<td>12</td>
</tr>

<tr>
<td>male</td>
<td>5.92</td>
<td>190</td>
<td>11</td>
</tr>

<tr>
<td>male</td>
<td>5.58</td>
<td>170</td>
<td>12</td>
</tr>

<tr>
<td>male</td>
<td>5.92</td>
<td>165</td>
<td>10</td>
</tr>

<tr>
<td>female</td>
<td>5</td>
<td>100</td>
<td>6</td>
</tr>

<tr>
<td>female</td>
<td>5.5</td>
<td>150</td>
<td>8</td>
</tr>

<tr>
<td>female</td>
<td>5.42</td>
<td>130</td>
<td>7</td>
</tr>

<tr>
<td>female</td>
<td>5.75</td>
<td>150</td>
<td>9</td>
</tr>
</tbody>
</table>

<p>Then, giving it the sample data of: {6,130,8}, it should produce posterior numerator (male) = 6.1984e-09 and posterior numerator (female) = 5.3778e-04.</p>

<p>So, I created this CSV file.</p>

<h1 id="process">Process</h1>

<p>First, I converted the csv file to Waffles format, arff.  Note that the CSV file must not have a header:</p>

<p><code>waffles_transform import gender.csv &gt; gender.arff</code></p>

<p>Then, I tried to create a naivebayes model using the newly created arff file:</p>

<p><code>waffles_learn train gender.arff naivebayes</code></p>

<p>and got:  <code>GNaiveBayes does not support continuous attributes. You should discretize first to convert real values to nominals.</code></p>

<p>I&rsquo;m not sure if <a href="http://en.wikipedia.org/wiki/Discretization">discretizing</a> the data will produce the desired result, but I tried it anyway:</p>

<p><code>waffles_learn train gender.arff discretize naivebayes &gt; gender.twt</code></p>

<p>Then, I tried some cross validation:</p>

<p><code>waffles_learn crossvalidate -reps 50 -folds 2 gender.arff -labels 0 discretize naivebayes</code></p>

<p>I got:  <code>Attr: 3, Mean accuracy: 0.74, Deviation: 0.23815367248307</code>.  Not bad!</p>

<p>The <code>-labels 0</code> tells the system to use the first column of data as the label (male,female).  Running the same command several times gives different results.</p>

<p>Now, let&rsquo;s convert the test data into an arff file.</p>

<p><code>waffles_transform import test.csv&gt;test.arff</code></p>

<p>And let&rsquo;s test it:</p>

<p><code>waffles_learn predict gender.twt test.arff</code></p>

<p>The raw numbers are definitely different from numbers given by Wikipedia:</p>

<table>
<thead>
<tr>
<th>Class</th>
<th>waffles</th>
<th>Wikipedia</th>
</tr>
</thead>

<tbody>
<tr>
<td>male</td>
<td>10.285714285714</td>
<td>6.1984e-09</td>
</tr>

<tr>
<td>female</td>
<td>6.8571428571428</td>
<td>5.3778e-04</td>
</tr>
</tbody>
</table>

<p>I&rsquo;m not 100% sure of the meaning of each number.  The magnitude is very different and the male&rsquo;s number is larger for waffles and smaller for Wikipedia.</p>

<h1 id="getting-help">Getting Help</h1>

<p>During this process, I often sought help by just running the usage command for the command-line.  For example, <code>waffles_transform usage</code> shows many options.  Also, the <code>waffles_wizard</code> command is a GUI interface to help users build a command-line string.</p>

<h1 id="files">Files</h1>

<ul>
<li><a href="/files/test.arff">test.arff</a></li>
<li><a href="/files/test.csv">test.csv</a></li>
<li><a href="/files/gender.twt">gender.twt</a></li>
<li><a href="/files/gender.arff">gender.arff</a></li>
<li><a href="/files/gender.csv">gender.csv</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Eclipse has huge fonts over X-Windows.</title>
			<link>/posts/2011-01-13-eclipse-has-huge-fonts-over-x-windows/</link>
			<pubDate>Thu, 13 Jan 2011 11:06:38 +0000</pubDate>
			
			<guid>/posts/2011-01-13-eclipse-has-huge-fonts-over-x-windows/</guid>
			<description>When running Eclipse over X-Windows using Cygwin, the font sizes are significantly larger than running Eclipse locally. I am connecting to a RedHat box. When I go into the options of Eclipse, it shows the same font size on both local and XWin versions of Eclipse.
I saw one post that claimed that changing the appearance settings in Linux will help ( System -&amp;gt; Preferences -&amp;gt; Appearance). This post claimed the utility is at /usr/bin/gnome-appearance-properties.</description>
			<content type="html"><![CDATA[

<p>When running Eclipse over X-Windows using Cygwin, the font sizes are significantly larger than running Eclipse locally.  I am connecting to a RedHat box.  When I go into the options of Eclipse, it shows the same font size on both local and XWin versions of Eclipse.</p>

<p>I saw one post that claimed that changing the appearance settings in Linux will help ( System -&gt; Preferences -&gt; Appearance).  <a href="http://ubuntuforums.org/showpost.php?p=9172813&amp;postcount=9">This post</a> claimed the utility is at <code>/usr/bin/gnome-appearance-properties</code>.  In RedHat, I had some success with <code>gnome-font-properties</code>.  I still had to change the font sizes in Eclipse at Window|Preferences|General|Appearance|Colors and Fonts.</p>

<p>Here are the settings that seemed to look nice (taken from <a href="http://blog.xam.dk/?p=70">this post</a>):
<pre>
Application/Document/Desktop font: Liberation Sans, size 8
Window title font: Liberation Sans Bold, size 10
Fixed with font: Liberation Mono, 10</p>

<p>Font rendering: Best contrast (the others left weird artifacts, but mostly up to taste here I think)</p>

<p>Under details:
Resolution: 99 dpi (to avoid the letters to get too close, need at least 1 px between them ;)
Smoothing: Grayscale</p>

<p>Hinting: Full
</pre></p>

<p>I also found <a href="http://srand2.blogspot.com/2009/08/eclipse-color-themes.html">this post</a> which will give better colors.  But it does not work well as sometimes things get very hard to read.</p>

<h1 id="in-ubuntu">In Ubuntu</h1>

<p>I also found <a href="http://techtavern.wordpress.com/2008/09/24/smaller-font-sizes-for-eclipse-on-linux/">this post</a>, which recommends creating a file in your home directory to override the default settings in Linux.  Then, all of the other windows can stay large.  Here&rsquo;s how:</p>

<ul>
<li>Create a file <code>~/.gtkrc-eclipse</code>:
<pre>
style &ldquo;eclipse&rdquo; {
    font_name = &ldquo;Sans Condensed 8&rdquo;
}
class &ldquo;GtkWidget&rdquo; style &ldquo;eclipse&rdquo;
</pre></li>
<li>Launch eclipse with the <code>GTK2_RC_FILES</code> environment variable set to the path to <code>~/.gktrc-eclipse</code>.  Like so: <code>env GTK2_RC_FILES=$GTK2_RC_FILES:~/.gtkrc-eclipse eclipse</code></li>
<li>It&rsquo;s still necessary to change the font sizes in Window|Preferences|General|Appearance|Colors and Fonts.</li>
</ul>

<h1 id="redhat">RedHat</h1>

<p>I was able to get a clean look in RedHat as well.  I created a <code>~/.gtkrc-2.0</code> with the following:
<pre>
style &ldquo;gtkcompact&rdquo;{
font_name=&ldquo;Sans 8&rdquo;
GtkButton::default_border={0,0,0,0}
GtkButton::default_outside_border={0,0,0,0}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=0
GtkMenuItem::horizontal_padding=4
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkExpander::expander_size=10
GtkExpander::expander_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::expander-size=8
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
}
class &ldquo;GtkWidget&rdquo; style &ldquo;gtkcompact&rdquo;
</pre></p>

<p>It made it much cleaner.  I did not have to set any environment variables or even restart X.  It worked immediately after launching Eclipse again.  This may work in other distros, but I haven&rsquo;t tried.</p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://blog.xam.dk/?p=70">http://blog.xam.dk/?p=70</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>jEdit does not allow pre-shared keys with SVN</title>
			<link>/posts/2011-01-10-jedit-does-not-allow-pre-shared-keys-svn/</link>
			<pubDate>Mon, 10 Jan 2011 22:57:39 +0000</pubDate>
			
			<guid>/posts/2011-01-10-jedit-does-not-allow-pre-shared-keys-svn/</guid>
			<description>http://community.jedit.org/?q=node/view/4572</description>
			<content type="html"><![CDATA[<p><a href="http://community.jedit.org/?q=node/view/4572">http://community.jedit.org/?q=node/view/4572</a></p>
]]></content>
		</item>
		
		<item>
			<title>jEdit is saving untitled documents to C:\Program Files\jEdit\</title>
			<link>/posts/2011-01-10-jedit-saving-untitled-documents-cprogram-filesjedit/</link>
			<pubDate>Mon, 10 Jan 2011 19:39:28 +0000</pubDate>
			
			<guid>/posts/2011-01-10-jedit-saving-untitled-documents-cprogram-filesjedit/</guid>
			<description>Problem I installed jEdit on Windows 7 and it is trying to save backups of my untitled files to C:\Program Files\jEdit. I get an error that reads:
Cannot save: java.io.FileNotFoundException: C:\Program Files\jEdit\# Untitled-1#
Solution It&amp;rsquo;s a known issue and a defect is filed.
Notes Set JAVA_HOME is set.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>I installed jEdit on Windows 7 and it is trying to save backups of my untitled files to C:\Program Files\jEdit.  I get an error that reads:</p>

<p><code>Cannot save: java.io.FileNotFoundException: C:\Program Files\jEdit\# Untitled-1#</code></p>

<h1 id="solution">Solution</h1>

<p>It&rsquo;s a <a href="http://community.jedit.org/?q=node/view/4050">known issue</a> and a <a href="https://sourceforge.net/tracker/?func=detail&amp;aid=3154842&amp;group_id=588&amp;atid=100588">defect</a> is filed.</p>

<h1 id="notes">Notes</h1>

<p>Set JAVA_HOME is set.</p>
]]></content>
		</item>
		
		<item>
			<title>Clipboard stopped working with tsclient</title>
			<link>/posts/2011-01-07-clipboard-stopped-working-tsclient/</link>
			<pubDate>Fri, 07 Jan 2011 23:42:28 +0000</pubDate>
			
			<guid>/posts/2011-01-07-clipboard-stopped-working-tsclient/</guid>
			<description>Problem I connect to a Windows machine from Linux using rdesktop. There are warnings or errors, but I can&amp;rsquo;t copy or paste between the two machines. For example, pasting a URL from Linux to a Firefox browser on a Windows machine will not paste anything and even locks up Firefox. Using the clipboard within the same machine works fine.
Solution Add the following line to the .rdp file for that system:</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>I connect to a Windows machine from Linux using <code>rdesktop</code>.  There are warnings or errors, but I can&rsquo;t copy or paste between the two machines.  For example, pasting a URL from Linux to a Firefox browser on a Windows machine will not paste anything and even locks up Firefox.  Using the clipboard within the same machine works fine.</p>

<h1 id="solution">Solution</h1>

<p>Add the following line to the .rdp file for that system:</p>

<p><code>clipboard:CLIPBOARD</code></p>

<p>Note, .rpd files are all in the ~/.tsclient directory.</p>
]]></content>
		</item>
		
		<item>
			<title>Where is the Java Connector for Postgres in Ubuntu</title>
			<link>/posts/2011-01-07-where-java-connector-postgres-ubuntu/</link>
			<pubDate>Fri, 07 Jan 2011 21:52:11 +0000</pubDate>
			
			<guid>/posts/2011-01-07-where-java-connector-postgres-ubuntu/</guid>
			<description>It&amp;rsquo;s installed with the libpg-java package. The jar file is at /usr/share/java/postgresql.jar.</description>
			<content type="html"><![CDATA[<p>It&rsquo;s installed with the libpg-java package.  The jar file is at <code>/usr/share/java/postgresql.jar</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>Bash:  Stop all sub-processes in a bash script.</title>
			<link>/posts/2011-01-07-bash-stop-all-sub-processes-bash-script/</link>
			<pubDate>Fri, 07 Jan 2011 18:43:06 +0000</pubDate>
			
			<guid>/posts/2011-01-07-bash-stop-all-sub-processes-bash-script/</guid>
			<description>trap &amp;quot;ps -o pid= --ppid $$ | xargs kill&amp;quot; SIGINT SIGTERM
Be sure that the script itself didn&amp;rsquo;t finish. If so, end the script with a wait command.</description>
			<content type="html"><![CDATA[<p><code>trap &quot;ps -o pid= --ppid $$ | xargs kill&quot; SIGINT SIGTERM</code></p>

<p>Be sure that the script itself didn&rsquo;t finish.  If so, end the script with a <code>wait</code> command.</p>
]]></content>
		</item>
		
		<item>
			<title>Phy0 spikes CPU and dmesg says &#34;ath5k phy0: gain calibration timeout&#34;</title>
			<link>/posts/2010-12-30-phy0-spikes-cpu-and-dmesg-says-ath5k-phy0-gain-calibration-timeout/</link>
			<pubDate>Thu, 30 Dec 2010 11:01:50 +0000</pubDate>
			
			<guid>/posts/2010-12-30-phy0-spikes-cpu-and-dmesg-says-ath5k-phy0-gain-calibration-timeout/</guid>
			<description>Problem When coming out of sleep or during times of intensive processing and network activity, the following symptoms occur:
 The WiFi connection stops working. top shows that phy0 spikes the CPU. dmesg shows several lines of ath5k phy0: gain calibration timeout and ath5k phy0: noise floor calibration timeout  Solution Downgrade the kernel. This problem can be solved by using the 2.6.31 kernel. Here&amp;rsquo;s how to install it:</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>When coming out of sleep or during times of intensive processing and network activity, the following symptoms occur:</p>

<ol>
<li>The WiFi connection stops working.</li>
<li><code>top</code> shows that phy0 spikes the CPU.</li>
<li><code>dmesg</code> shows several lines of <code>ath5k phy0: gain calibration timeout</code> and <code>ath5k phy0: noise floor calibration timeout</code></li>
</ol>

<h1 id="solution">Solution</h1>

<p>Downgrade the kernel.  This problem can be solved by using the 2.6.31 kernel.  Here&rsquo;s how to install it:</p>

<ol>
<li>Do a <code>sudo aptitiude search linux-image</code>.</li>
<li>Install an older kernel.  For Ubuntu 10.4, I selected the 2.6.31-11-rt kernel by doing a <code>sudo apt-get install linux-image-2.6.31-11-rt</code>.</li>
<li>Reboot.</li>
<li>When the grub menu appears select the old kernel.</li>
<li>Verify that the old kernel is fully functional for your system.</li>
</ol>

<h1 id="temporary-solutions">Temporary Solutions</h1>

<ol>
<li>Do a <code>pm-suspend-hybrid</code> several times until the wifi works again.</li>
<li>Restart the machine several times until the wifi works again.</li>
<li>Do a <code>modprobe -r ath5k</code> and use a different network card.</li>
<li>Using a 2.6.35 kernel reduces the frequency this problem occurs.</li>
</ol>

<h1 id="details">Details</h1>

<p><code>uname -r</code>
<pre>
2.6.32-26-generic
</pre></p>

<p><code>lspci|grep Wireless</code> shows:
<pre>
14:00.0 Ethernet controller: Atheros Communications Inc. AR5001 Wireless Network Adapter (rev 01)
</pre></p>

<p><code>dmesg |grep &quot;ath5.*chip&quot;</code>
<pre>
ath5k phy0: Atheros AR2425 chip found (MAC: 0xe2, PHY: 0x70)
</pre></p>

<p><code>modinfo ath5k</code> shows:
<pre>
filename:       /lib/modules/2.6.32-26-generic/kernel/drivers/net/wireless/ath/ath5k/ath5k.ko
version:        0.6.0 (EXPERIMENTAL)
license:        Dual BSD/GPL
description:    Support for 5xxx series of Atheros 802.11 wireless LAN cards.
author:         Nick Kossifidis
author:         Jiri Slaby
srcversion:     5A81CAB958F60B02DE47E18
alias:          pci:v0000168Cd0000001Dsv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd0000001Csv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd0000001Bsv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd0000001Asv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000019sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000018sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000017sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000016sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000015sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000014sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00001014sv*sd*bc*sc<em>i</em>
alias:          pci:v000010B7d00000013sv*sd*bc*sc<em>i</em>
alias:          pci:v0000A727d00000013sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000013sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000012sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000011sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000007sv*sd*bc*sc<em>i</em>
alias:          pci:v0000168Cd00000207sv*sd*bc*sc<em>i</em>
depends:        mac80211,led-class,cfg80211,ath
vermagic:       2.6.32-26-generic SMP mod_unload modversions
parm:           nohwcrypt:Disable hardware encryption. (bool)
parm:           all_channels:Expose all channels the device can use. (bool)
</pre></p>
]]></content>
		</item>
		
		<item>
			<title>wakeonlan says &#34;Can&#39;t call method &#34;addr&#34; on an undefined value at /usr/bin/wakeonlan line 117.&#34;</title>
			<link>/posts/2010-12-27-wakeonlan-says-cant-call-method-addr-undefined-value-usrbinwakeonlan-line-117/</link>
			<pubDate>Mon, 27 Dec 2010 12:15:09 +0000</pubDate>
			
			<guid>/posts/2010-12-27-wakeonlan-says-cant-call-method-addr-undefined-value-usrbinwakeonlan-line-117/</guid>
			<description>wakonlan suddenly stopped working. I run something like wakeonlan -i myip.com:9 6c:f0:49:50:36:fe and it says:
Can&#39;t call method &amp;quot;addr&amp;quot; on an undefined value at /usr/bin/wakeonlan line 117.
The port and ip address can&amp;rsquo;t be combined (eg myip.com:0). Instead, use -p for port number. It should instead say:
wakeonlan -i myip.com -p 9 6c:f0:49:50:36:fe and no error will happen.</description>
			<content type="html"><![CDATA[<p><code>wakonlan</code> suddenly stopped working.  I run something like <code>wakeonlan -i myip.com:9 6c:f0:49:50:36:fe</code> and it says:</p>

<p><code>Can't call method &quot;addr&quot; on an undefined value at /usr/bin/wakeonlan line 117.</code></p>

<p>The port and ip address can&rsquo;t be combined (eg <code>myip.com:0</code>).  Instead, use <code>-p</code> for port number.  It should instead say:</p>

<p><code>wakeonlan -i myip.com -p 9 6c:f0:49:50:36:fe</code>  and no error will happen.</p>
]]></content>
		</item>
		
		<item>
			<title>Downgrade (or upgrade) a Linux Kernel</title>
			<link>/posts/2010-12-25-downgrade-or-upgrade-linux-kernel/</link>
			<pubDate>Sat, 25 Dec 2010 15:52:07 +0000</pubDate>
			
			<guid>/posts/2010-12-25-downgrade-or-upgrade-linux-kernel/</guid>
			<description>sudo apt-get install linux-image-2.6.35-22-generic
Use tab-completion!</description>
			<content type="html"><![CDATA[<p><code>sudo apt-get install linux-image-2.6.35-22-generic</code></p>

<p>Use tab-completion!</p>
]]></content>
		</item>
		
		<item>
			<title>Linux Kernel Driver Commands</title>
			<link>/posts/2010-12-25-linux-kernel-driver-commands/</link>
			<pubDate>Sat, 25 Dec 2010 10:34:23 +0000</pubDate>
			
			<guid>/posts/2010-12-25-linux-kernel-driver-commands/</guid>
			<description>Get a listing of all modules currently loaded:
lsmod
Get a mapping of which hardware is using which driver:
lpci -v
also
lshw
Get the version and other info of a module:
modinfo &amp;lt;module&amp;gt;
Load a module (and its dependencies):
modprobe -v &amp;lt;module&amp;gt;
Unload a module (and its dependencies):
modprobe -r &amp;lt;module&amp;gt;</description>
			<content type="html"><![CDATA[<p>Get a listing of all modules currently loaded:</p>

<p><code>lsmod</code></p>

<p>Get a mapping of which hardware is using which driver:</p>

<p><code>lpci -v</code></p>

<p>also</p>

<p><code>lshw</code></p>

<p>Get the version and other info of a module:</p>

<p><code>modinfo &lt;module&gt;</code></p>

<p>Load a module (and its dependencies):</p>

<p><code>modprobe -v &lt;module&gt;</code></p>

<p>Unload a module (and its dependencies):</p>

<p><code>modprobe -r &lt;module&gt;</code></p>
]]></content>
		</item>
		
		<item>
			<title>Add a kernel parameter to grub2</title>
			<link>/posts/2010-12-24-add-kernel-parameter-grub2/</link>
			<pubDate>Fri, 24 Dec 2010 22:41:12 +0000</pubDate>
			
			<guid>/posts/2010-12-24-add-kernel-parameter-grub2/</guid>
			<description>Edit /etc/default/grub&amp;rsquo;s to change GRUB_CMDLINE_LINUX.
Then, run sudo /usr/sbin/update-grub.</description>
			<content type="html"><![CDATA[<p>Edit <code>/etc/default/grub</code>&rsquo;s to change <code>GRUB_CMDLINE_LINUX</code>.</p>

<p>Then, run <code>sudo /usr/sbin/update-grub</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>How to see which drivers are used by which PCI card</title>
			<link>/posts/2010-12-24-how-see-which-drivers-are-used-which-pci-card/</link>
			<pubDate>Fri, 24 Dec 2010 14:02:16 +0000</pubDate>
			
			<guid>/posts/2010-12-24-how-see-which-drivers-are-used-which-pci-card/</guid>
			<description>lspci -v|less</description>
			<content type="html"><![CDATA[<p><code>lspci -v|less</code></p>
]]></content>
		</item>
		
		<item>
			<title>Quickly using an Emacs macro</title>
			<link>/posts/2010-12-20-quickly-using-emacs-macro/</link>
			<pubDate>Mon, 20 Dec 2010 12:09:41 +0000</pubDate>
			
			<guid>/posts/2010-12-20-quickly-using-emacs-macro/</guid>
			<description>Start recording: C-x (
Stop recording: C-x )
Apply to region: M-x apply-macro-to-region-lines</description>
			<content type="html"><![CDATA[<p>Start recording: <code>C-x (</code></p>

<p>Stop recording: <code>C-x )</code></p>

<p>Apply to region: <code>M-x apply-macro-to-region-lines</code></p>
]]></content>
		</item>
		
		<item>
			<title>Logging Postgres queries</title>
			<link>/posts/2010-12-20-logging-postgres-queries/</link>
			<pubDate>Mon, 20 Dec 2010 11:56:55 +0000</pubDate>
			
			<guid>/posts/2010-12-20-logging-postgres-queries/</guid>
			<description>Here&amp;rsquo;s how to configure Postgres to write all queries to log file that you can follow.
Edit postgresql.conf (usually in /etc/postgresql/8.4/main/) to contain these lines:  log_statement=&amp;lsquo;all&amp;rsquo; log_destination=&amp;lsquo;csvlog&amp;rsquo; logging_collector=on 
Now, the log should appear at /etc/postgresql/8.4/main/pg_log/*.csv</description>
			<content type="html"><![CDATA[<p>Here&rsquo;s how to configure Postgres to write all queries to log file that you can follow.</p>

<p>Edit postgresql.conf (usually in <code>/etc/postgresql/8.4/main/</code>) to contain these lines:
<pre>
log_statement=&lsquo;all&rsquo;
log_destination=&lsquo;csvlog&rsquo;
logging_collector=on
</pre></p>

<p>Now, the log should appear at <code>/etc/postgresql/8.4/main/pg_log/*.csv</code></p>
]]></content>
		</item>
		
		<item>
			<title>Emacs creates a file that starts with efbbbf</title>
			<link>/posts/2010-12-18-emacs-creates-file-starts-efbbbf/</link>
			<pubDate>Sat, 18 Dec 2010 21:38:52 +0000</pubDate>
			
			<guid>/posts/2010-12-18-emacs-creates-file-starts-efbbbf/</guid>
			<description>When I write a file with emacs and try to compile it, I get a weird syntax error.
Then, when I use xxd to get a hexdump of the file I see something like this:
0000000: efbb bf2d 2d20 2449 6424 0a2d 2d20 2448 ...-- $Id$.-- $H
Notice how it starts with a efbb bf. These three bytes tell most programs that the file is unicode. It&amp;rsquo;s called a Byte Order Mark or BOM.</description>
			<content type="html"><![CDATA[<p>When I write a file with emacs and try to compile it, I get a weird syntax error.</p>

<p>Then, when I use <code>xxd</code> to get a hexdump of the file I see something like this:</p>

<p><code>0000000: efbb bf2d 2d20 2449 6424 0a2d 2d20 2448  ...-- $Id$.-- $H</code></p>

<p>Notice how it starts with a <code>efbb bf</code>.  These three bytes tell most programs that the file is unicode.  It&rsquo;s called a <a href="http://en.wikipedia.org/wiki/Byte_order_mark">Byte Order Mark</a> or BOM.  Many editors, like emacs, will automatically write these annoying characters and you can&rsquo;t always see them in your file..unless you do this&hellip;</p>

<p>To make emacs stop writing these characters, it&rsquo;s necessary to change the coding system of emacs.  Here&rsquo;s how:</p>

<p>Do a <code>C-x RET r</code> and select <code>raw-text</code>.  The raw-text encoding in emacs allows you to see the hidden characters.  However, there are times when you may not want to see these characters..in such a case use <code>utf-8-with-signature</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>Create a huge file in less than a second</title>
			<link>/posts/2010-12-17-create-huge-file-less-second/</link>
			<pubDate>Fri, 17 Dec 2010 10:04:07 +0000</pubDate>
			
			<guid>/posts/2010-12-17-create-huge-file-less-second/</guid>
			<description>Here&amp;rsquo;s how to create a large file in Linux:
dd if=/dev/zero of=filename bs=1 count=1 seek=$((100*1024*1024*1024))
This creates what is called a &amp;ldquo;sparse file&amp;rdquo;. However, df will not recognize the reduction in size. From what I can tell, there is no way to get df to recognize sparse files. du and df will always disagree.</description>
			<content type="html"><![CDATA[<p>Here&rsquo;s how to create a large file in Linux:</p>

<p><code>dd if=/dev/zero of=filename bs=1 count=1 seek=$((100*1024*1024*1024))</code></p>

<p>This creates what is called a &ldquo;sparse file&rdquo;.  However, <code>df</code> will not recognize the reduction in size.  From what I can tell, there is no way to get <code>df</code> to recognize sparse files.  <code>du</code> and <code>df</code> will always disagree.</p>
]]></content>
		</item>
		
		<item>
			<title>ps to show an entire tree.</title>
			<link>/posts/2010-12-15-ps-show-entire-tree/</link>
			<pubDate>Wed, 15 Dec 2010 12:04:36 +0000</pubDate>
			
			<guid>/posts/2010-12-15-ps-show-entire-tree/</guid>
			<description>Using ps aux to see active processes is helpful and very common. However, using ps auxf will give an ASCII art representation of the process tree within ps. Here&amp;rsquo;s an example:  root 3513 0.0 0.0 7196 1068 ? Ss Nov30 0:00 /usr/sbin/sshd root 5201 0.0 0.0 10092 2968 ? Ss Nov30 0:00 _ sshd: user [priv] user 5207 0.0 0.0 11944 3620 ? S Nov30 0:11 | _ sshd: user@pts/1 user 5208 0.</description>
			<content type="html"><![CDATA[<p>Using <code>ps aux</code> to see active processes is helpful and very common.  However, using <code>ps auxf</code> will give an ASCII art representation of the process tree within <code>ps</code>.  Here&rsquo;s an example:
<pre>
root      3513  0.0  0.0   7196  1068 ?        Ss   Nov30   0:00 /usr/sbin/sshd
root      5201  0.0  0.0  10092  2968 ?        Ss   Nov30   0:00  _ sshd: user [priv]
user      5207  0.0  0.0  11944  3620 ?        S    Nov30   0:11  |   _ sshd: user@pts/1
user      5208  0.0  0.0   5724  2584 pts/1    Ss   Nov30   0:02  |       _ -bash
user     14745  0.0  0.0   5724  1524 pts/1    S    16:42   0:00  |           _ -bash
user     14746  0.0  0.0   3800   500 pts/1    S    16:42   0:00  |           |   _ sleep 100
user     15370  0.0  0.0   5724  1524 pts/1    S    16:52   0:00  |           _ -bash
user     15371  0.0  0.0   3800   472 pts/1    S    16:52   0:00  |           |   _ sleep 100
user     15596  0.0  0.0   4604  1088 pts/1    R+   16:56   0:00  |           _ ps auxf
root      5597  0.0  0.0  10092  2976 ?        Ss   Nov30   0:00  _ sshd: user [priv]
user      5600  0.0  0.0  10244  1844 ?        S    Nov30   0:00  |   _ sshd: user@pts/2
user      5601  0.0  0.0   5720  2536 pts/2    Ss+  Nov30   0:00  |       _ -bash
root      8833  0.0  0.0  10092  2976 ?        Ss   15:17   0:00  _ sshd: user [priv]
user      8835  0.0  0.0  10092  1824 ?        S    15:17   0:00      _ sshd: user@pts/3
root      8836  0.0  0.0   4632  1368 pts/3    Ss+  15:17   0:00          _ /bin/sh
</pre></p>

<p>You can see three pseudo terminals created by <code>sshd</code> and a few bash scripts that are running.</p>
]]></content>
		</item>
		
		<item>
			<title>Getting X11 forwarding to work in Cygwin</title>
			<link>/posts/2010-10-18-getting-x11-forwarding-work-cygwin/</link>
			<pubDate>Mon, 18 Oct 2010 15:01:31 +0000</pubDate>
			
			<guid>/posts/2010-10-18-getting-x11-forwarding-work-cygwin/</guid>
			<description>Introduction You have a remote machine that has an X11-based program that you want to open in Windows.
Execution Follow these steps to get it to work:
# A bunch of status will print to stdout. XWin -multiwindow &amp;amp; # This is case sensitive. export DISPLAY=:0.0 # You should see something like &amp;#34;debug1: Requesting X11 forwarding with authentication spoofing.&amp;#34; ssh -Yv myhost Try a simple program to test it. I like to use xterm.</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>You have a remote machine that has an X11-based program that you want to open in Windows.</p>

<h1 id="execution">Execution</h1>

<p>Follow these steps to get it to work:</p>
<div class="highlight"><pre class="chroma"><code class="language-"bash"" data-lang=""bash""># A bunch of status will print to stdout.
XWin -multiwindow &amp;

# This is case sensitive.
export DISPLAY=:0.0

# You should see something like &#34;debug1: Requesting X11 forwarding with authentication spoofing.&#34;
ssh -Yv myhost</code></pre></div>
<p>Try a simple program to test it.  I like to use xterm.</p>
]]></content>
		</item>
		
		<item>
			<title>Tuning MySQL</title>
			<link>/posts/2010-09-16-tuning-mysql/</link>
			<pubDate>Thu, 16 Sep 2010 12:30:19 +0000</pubDate>
			
			<guid>/posts/2010-09-16-tuning-mysql/</guid>
			<description>This script gives you basically everything you need.</description>
			<content type="html"><![CDATA[<p><a href="http://www.day32.com/MySQL/tuning-primer.sh">This</a> script gives you basically everything you need.</p>
]]></content>
		</item>
		
		<item>
			<title>Useful AV utilities</title>
			<link>/posts/2010-09-04-useful-av-utilities/</link>
			<pubDate>Sat, 04 Sep 2010 22:44:13 +0000</pubDate>
			
			<guid>/posts/2010-09-04-useful-av-utilities/</guid>
			<description>|Name|Use |-|- |ffmpeg|Play/convert AV |sox|Play/convert audio |lame|encode to mp3</description>
			<content type="html"><![CDATA[<p>|Name|Use
|-|-
|ffmpeg|Play/convert AV
|sox|Play/convert audio
|lame|encode to mp3</p>
]]></content>
		</item>
		
		<item>
			<title>See all queries sent to MySQL</title>
			<link>/posts/2010-09-03-see-all-queries-sent-mysql/</link>
			<pubDate>Fri, 03 Sep 2010 11:51:31 +0000</pubDate>
			
			<guid>/posts/2010-09-03-see-all-queries-sent-mysql/</guid>
			<description> Send this query:
SET GLOBAL general_log = &#39;ON&#39;;
Then run tail:
tail -f /var/lib/mysql/hostname.log
where hostname is the hostname of the database server.
Of course, you can turn it off by:
SET GLOBAL general_log = &#39;OFF&#39;;
References  http://dev.mysql.com/doc/refman/5.1/en/query-log.html  </description>
			<content type="html"><![CDATA[

<p>Send this query:</p>

<p><code>SET GLOBAL general_log = 'ON';</code></p>

<p>Then run <code>tail</code>:</p>

<p><code>tail -f /var/lib/mysql/hostname.log</code></p>

<p>where hostname is the hostname of the database server.</p>

<p>Of course, you can turn it off by:</p>

<p><code>SET GLOBAL general_log = 'OFF';</code></p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/query-log.html">http://dev.mysql.com/doc/refman/5.1/en/query-log.html</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Quicky create a new file using dd</title>
			<link>/posts/2010-09-02-quicky-create-new-file-using-dd/</link>
			<pubDate>Thu, 02 Sep 2010 16:01:48 +0000</pubDate>
			
			<guid>/posts/2010-09-02-quicky-create-new-file-using-dd/</guid>
			<description>dd if=/dev/zero of=myfile bs=1G count=0 seek=5
This will create a 5GB file called myfile. Notice the count=0 and seek=... commands. Just seek the size you need. ls -l should show the correct size. I hear that sometimes Linux can&amp;rsquo;t fully recognize the size until the file is used. If that is the case try file myfile.</description>
			<content type="html"><![CDATA[<p><code>dd if=/dev/zero of=myfile bs=1G count=0 seek=5</code></p>

<p>This will create a 5GB file called <code>myfile</code>.  Notice the <code>count=0</code> and <code>seek=...</code> commands.  Just seek the size you need.  <code>ls -l</code> should show the correct size.  I hear that sometimes Linux can&rsquo;t fully recognize the size until the file is used.  If that is the case try <code>file myfile</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>Lost Network Applet on Ubuntu</title>
			<link>/posts/2010-08-27-lost-network-applet-ubuntu/</link>
			<pubDate>Fri, 27 Aug 2010 21:49:13 +0000</pubDate>
			
			<guid>/posts/2010-08-27-lost-network-applet-ubuntu/</guid>
			<description>The applet for wireless did not come up after an upgrade/reboot on Ubuntu. This command got it to show up again:
sudo /etc/init.d/network-manager restart</description>
			<content type="html"><![CDATA[<p>The applet for wireless did not come up after an upgrade/reboot on Ubuntu.  This command got it to show up again:</p>

<p><code>sudo /etc/init.d/network-manager restart</code></p>
]]></content>
		</item>
		
		<item>
			<title>Which package contains this executable?</title>
			<link>/posts/2010-08-27-which-package-contains-executable/</link>
			<pubDate>Fri, 27 Aug 2010 09:01:57 +0000</pubDate>
			
			<guid>/posts/2010-08-27-which-package-contains-executable/</guid>
			<description>Sometimes I need to know which Ubuntu package to apt-get install in order to get some binary. For example, pdflatex.
Just do a search here. Look down a ways on the page and there is a search engine form that is very helpful. Here is an example of pdflatex.</description>
			<content type="html"><![CDATA[<p>Sometimes I need to know which Ubuntu package to <code>apt-get install</code> in order to get some binary.  For example, pdflatex.</p>

<p>Just do a search <a href="http://packages.ubuntu.com/">here</a>.  Look down a ways on the page and there is a search engine form that is very helpful.  <a href="http://packages.ubuntu.com/search?searchon=contents&amp;keywords=pdflatex&amp;mode=exactfilename&amp;suite=lucid&amp;arch=any">Here</a> is an example of pdflatex.</p>
]]></content>
		</item>
		
		<item>
			<title>Which processes use which ports?</title>
			<link>/posts/2010-08-14-which-processes-use-which-ports/</link>
			<pubDate>Sat, 14 Aug 2010 11:16:48 +0000</pubDate>
			
			<guid>/posts/2010-08-14-which-processes-use-which-ports/</guid>
			<description>These work, but the MUST be run as root to show the attached process. It will not give an error if you are not root:
netstat -tlp
lsof -iTCP -s TCP:LISTEN</description>
			<content type="html"><![CDATA[<p>These work, but the MUST be run as root to show the attached process.  It will not give an error if you are not root:</p>

<p><code>netstat -tlp</code></p>

<p><code>lsof -iTCP -s TCP:LISTEN</code></p>
]]></content>
		</item>
		
		<item>
			<title>Bash Redirect</title>
			<link>/posts/2010-08-13-bash-redirect/</link>
			<pubDate>Fri, 13 Aug 2010 11:02:16 +0000</pubDate>
			
			<guid>/posts/2010-08-13-bash-redirect/</guid>
			<description>Write and read from a pipe using fd=3:
exec 3&amp;lt; &amp;lt;(echo hi) cat &amp;lt;&amp;amp;3 exec 3&amp;gt;&amp;amp;- Read and write from a pipe using fd=4:
exec 4&amp;gt; &amp;gt;(cat) echo hi &amp;gt;&amp;amp;4 exec 4&amp;gt;&amp;amp;- Check the current file descriptors for current shell:
lsof -p $$
Keep the mysql connection open using fd=3 for writing:
exec 3&amp;gt; &amp;gt;(mysql) echo &amp;#34;SELECT 1;&amp;#34; &amp;gt;&amp;amp;3 echo &amp;#34;SELECT 2;&amp;#34; &amp;gt;&amp;amp;3 exec 3&amp;gt;&amp;amp;- Keep the mysql connection open using fd=3 for reading:</description>
			<content type="html"><![CDATA[<p>Write and read from a pipe using fd=3:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">exec</span> <span class="m">3</span>&lt; &lt;<span class="o">(</span><span class="nb">echo</span> hi<span class="o">)</span>
cat &lt;<span class="p">&amp;</span><span class="m">3</span>
<span class="nb">exec</span> <span class="m">3</span>&gt;<span class="p">&amp;</span>-</code></pre></div>
<p>Read and write from a pipe using fd=4:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">exec</span> <span class="m">4</span>&gt; &gt;<span class="o">(</span>cat<span class="o">)</span>
<span class="nb">echo</span> hi &gt;<span class="p">&amp;</span><span class="m">4</span>
<span class="nb">exec</span> <span class="m">4</span>&gt;<span class="p">&amp;</span>-</code></pre></div>
<p>Check the current file descriptors for current shell:</p>

<p><code>lsof -p $$</code></p>

<p>Keep the mysql connection open using fd=3 for writing:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">exec</span> <span class="m">3</span>&gt; &gt;<span class="o">(</span>mysql<span class="o">)</span>
<span class="nb">echo</span> <span class="s2">&#34;SELECT 1;&#34;</span> &gt;<span class="p">&amp;</span><span class="m">3</span>
<span class="nb">echo</span> <span class="s2">&#34;SELECT 2;&#34;</span> &gt;<span class="p">&amp;</span><span class="m">3</span>
<span class="nb">exec</span> <span class="m">3</span>&gt;<span class="p">&amp;</span>-</code></pre></div>
<p>Keep the mysql connection open using fd=3 for reading:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">exec</span> <span class="m">3</span>&lt; &lt;<span class="o">(</span><span class="nb">echo</span> <span class="s2">&#34;SELECT 1;&#34;</span><span class="p">|</span>mysql<span class="p">|</span>sed <span class="s1">&#39;1d&#39;</span><span class="o">)</span>
<span class="k">while</span> <span class="nb">read</span> &lt;<span class="p">&amp;</span><span class="m">3</span>
<span class="k">do</span>
  <span class="nb">echo</span> <span class="nv">$REPLY</span>
<span class="k">done</span></code></pre></div>
<p>Note:  <code>sed '1d'</code> removes the header.</p>

<p>Split input:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">exec</span> <span class="m">3</span>&gt; &gt;<span class="o">(</span>awk <span class="s1">&#39;{print 3,$1}&#39;</span><span class="o">)</span>
<span class="nb">exec</span> <span class="m">4</span>&gt; &gt;<span class="o">(</span>awk <span class="s1">&#39;{print 4,$1}&#39;</span><span class="o">)</span>
<span class="nb">echo</span> hi<span class="p">|</span>tee &gt;<span class="o">(</span>cat &gt;<span class="p">&amp;</span><span class="m">3</span><span class="o">)</span> &gt;<span class="o">(</span>cat &gt;<span class="p">&amp;</span><span class="m">4</span><span class="o">)</span><span class="p">|</span>cat &gt;/dev/null</code></pre></div>
<p>produces:
<pre>
3 hi
4 hi
</pre></p>
]]></content>
		</item>
		
		<item>
			<title>MySQL Timezones</title>
			<link>/posts/2010-08-11-mysql-timezones/</link>
			<pubDate>Wed, 11 Aug 2010 18:06:28 +0000</pubDate>
			
			<guid>/posts/2010-08-11-mysql-timezones/</guid>
			<description>MySQL&amp;rsquo;s DATETIME and TIMESTAMP datatype do NOT include timezones. However TIMESTAMP columns are sensitive to MySQL&amp;rsquo;s current timezone. It&amp;rsquo;s especially important to note that DATETIME, DATE, and TIME are NOT sensitive to MySQL&amp;rsquo;s current timezone. Also, certain functions are sensitive to timezone and others are not.
   Datatype Sensitive to timezone     TIMESTAMP Yes   DATETIME No   DATE No   TIME No       Function Sensitive to timezone     NOW() Yes   CURTIME() Yes   UTC_TIMESTAMP() No   UNIX_TIMESTAMP() Yes    MySQL&amp;rsquo;s timezone is stored in time_zone.</description>
			<content type="html"><![CDATA[

<p>MySQL&rsquo;s DATETIME and TIMESTAMP datatype do NOT include timezones.  However TIMESTAMP columns are sensitive to MySQL&rsquo;s current timezone.  It&rsquo;s especially important to note that DATETIME, DATE, and TIME are NOT sensitive to MySQL&rsquo;s current timezone.  Also, certain functions are sensitive to timezone and others are not.</p>

<table>
<thead>
<tr>
<th>Datatype</th>
<th>Sensitive to timezone</th>
</tr>
</thead>

<tbody>
<tr>
<td>TIMESTAMP</td>
<td>Yes</td>
</tr>

<tr>
<td>DATETIME</td>
<td>No</td>
</tr>

<tr>
<td>DATE</td>
<td>No</td>
</tr>

<tr>
<td>TIME</td>
<td>No</td>
</tr>
</tbody>
</table>

<table>
<thead>
<tr>
<th>Function</th>
<th>Sensitive to timezone</th>
</tr>
</thead>

<tbody>
<tr>
<td>NOW()</td>
<td>Yes</td>
</tr>

<tr>
<td>CURTIME()</td>
<td>Yes</td>
</tr>

<tr>
<td>UTC_TIMESTAMP()</td>
<td>No</td>
</tr>

<tr>
<td>UNIX_TIMESTAMP()</td>
<td>Yes</td>
</tr>
</tbody>
</table>

<p>MySQL&rsquo;s timezone is stored in <code>time_zone</code>.  Use the following to discover it:</p>

<p><code>&quot;SHOW VARIABLES LIKE 'time_zone'</code></p>

<p>It is possible to change the timezone for a session using the following syntax:</p>

<p><code>SET time_zone = '+0:00'</code></p>

<p>Even further, it&rsquo;s possible to set the timezone globally using this syntax:</p>

<p><code>SET GLOBAL time_zone = '+0:00'</code></p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html">http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Settings That Should be on Every Bash Script</title>
			<link>/posts/2010-08-11-settings-should-be-every-bash-script/</link>
			<pubDate>Wed, 11 Aug 2010 12:52:36 +0000</pubDate>
			
			<guid>/posts/2010-08-11-settings-should-be-every-bash-script/</guid>
			<description>When you really want a solid bash script, consider setting all of these options.
#!/bin/bash #$URL$ #$Id$ # Enable debugging # set -v # set -x # Exit if any undefined variable is used. set -u # Exit this script if it any subprocess exits non-zero. set -e # If any process in a pipeline fails, the return value is a failure. set -o pipefail Note that $URL$ and $Id$ are meant for subversion.</description>
			<content type="html"><![CDATA[<p>When you really want a solid bash script, consider setting all of these options.</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="cp">#!/bin/bash
</span><span class="cp"></span><span class="c1">#$URL$</span>
<span class="c1">#$Id$</span>

<span class="c1"># Enable debugging</span>
<span class="c1"># set -v</span>
<span class="c1"># set -x</span>

<span class="c1"># Exit if any undefined variable is used.</span>
<span class="nb">set</span> -u

<span class="c1"># Exit this script if it any subprocess exits non-zero.</span>
<span class="nb">set</span> -e

<span class="c1"># If any process in a pipeline fails, the return value is a failure.</span>
<span class="nb">set</span> -o pipefail</code></pre></div>
<p>Note that $URL$ and $Id$ are meant for subversion.</p>
]]></content>
		</item>
		
		<item>
			<title>Vertical Taskbar in Linux</title>
			<link>/posts/2010-08-10-vertical-taskbar-linux/</link>
			<pubDate>Tue, 10 Aug 2010 21:10:41 +0000</pubDate>
			
			<guid>/posts/2010-08-10-vertical-taskbar-linux/</guid>
			<description>The Problem I have found a subset of people love to have their taskbar on the left vertical edge of the screen. If you have several windows open at any given time, this will help you a lot. Here&amp;rsquo;s an example:
This behavior is supported natively by Windows (at least since XP or even earlier). Linux, at least Ubuntu, does not easily support this feature. You are welcome to try it, there are all types of bugs related to it.</description>
			<content type="html"><![CDATA[

<h1 id="the-problem">The Problem</h1>

<p>I have found a subset of people love to have their taskbar on the left vertical edge of the screen.  If you have several windows open at any given time, this will help you a lot.  Here&rsquo;s an example:</p>

<p><img src="/sites/info.solomonson.com/files/verticaltaskbar.jpg" alt="Vertical Taskbar" /></p>

<p>This behavior is supported natively by Windows (at least since XP or even earlier).  Linux, at least Ubuntu, does not easily support this feature.  You are welcome to try it, there are all types of bugs related to it.</p>

<h1 id="the-solution">The Solution</h1>

<p>I tried many solutions and even other distros, and found a very easy solution, <a href="http://wiki.awn-project.org/">Avant Window Navigator</a>.  This little utility has surpassed them all.  Here&rsquo;s an example.</p>

<p><img src=/sites/info.solomonson.com/files/awn-vertical.png height=400 width=125 /></p>

<h1 id="references">References:</h1>

<ul>
<li><a href="http://brainstorm.ubuntu.com/item/1906/">http://brainstorm.ubuntu.com/item/1906/</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Irssi Quick Start</title>
			<link>/posts/2010-08-09-irssi-quick-start/</link>
			<pubDate>Mon, 09 Aug 2010 23:50:57 +0000</pubDate>
			
			<guid>/posts/2010-08-09-irssi-quick-start/</guid>
			<description>After starting it. There are few very useful commands:
   Command Description     /connect irc.ubuntu.com Connect to a server   /list List of channels. Don&amp;rsquo;t do this! Use something like http://searchirc.com instead   /join channel Join a channel   /part Leave current channel   /me does something You doing an action   /ignore someone Ignore an annoying person   /help help   /window new Open a new chat window   /window hide hide the current chat window   /window list List chat windows    </description>
			<content type="html"><![CDATA[<p>After starting it.  There are few very useful commands:</p>

<table>
<thead>
<tr>
<th>Command</th>
<th>Description</th>
</tr>
</thead>

<tbody>
<tr>
<td>/connect irc.ubuntu.com</td>
<td>Connect to a server</td>
</tr>

<tr>
<td>/list</td>
<td>List of channels.  Don&rsquo;t do this!  Use something like <a href="http://searchirc.com">http://searchirc.com</a> instead</td>
</tr>

<tr>
<td>/join channel</td>
<td>Join a channel</td>
</tr>

<tr>
<td>/part</td>
<td>Leave current channel</td>
</tr>

<tr>
<td>/me does something</td>
<td>You doing an action</td>
</tr>

<tr>
<td>/ignore someone</td>
<td>Ignore an annoying person</td>
</tr>

<tr>
<td>/help</td>
<td>help</td>
</tr>

<tr>
<td>/window new</td>
<td>Open a new chat window</td>
</tr>

<tr>
<td>/window hide</td>
<td>hide the current chat window</td>
</tr>

<tr>
<td>/window list</td>
<td>List chat windows</td>
</tr>
</tbody>
</table>
]]></content>
		</item>
		
		<item>
			<title>Enabling Keyword Substitution in Subversion</title>
			<link>/posts/2010-08-09-enabling-keyword-substitution-subversion/</link>
			<pubDate>Mon, 09 Aug 2010 16:59:50 +0000</pubDate>
			
			<guid>/posts/2010-08-09-enabling-keyword-substitution-subversion/</guid>
			<description>The most meaningful substitutions are $Id$ and $URL$.
To enable these for an individual file, type this:
svn propset svn:keywords &amp;quot;Id URL&amp;quot; myfile
That&amp;rsquo;s a lot of typing for large projects and a lot of upkeep. To enable these for certain file extensions that you svn add, type the following in ~/.subversion/config
[miscellany] enable-auto-props = yes [auto-props] *.cpp = svn:keywords=Id URL *.sh = svn:keywords=Id URL;svn:executable ... This file likely exists with a bunch of commented out stuff.</description>
			<content type="html"><![CDATA[<p>The most meaningful substitutions are <code>$Id$</code> and <code>$URL$</code>.</p>

<p>To enable these for an individual file, type this:</p>

<p><code>svn propset svn:keywords &quot;Id URL&quot; myfile</code></p>

<p>That&rsquo;s a lot of typing for large projects and a lot of upkeep.  To enable these for certain file extensions that you <code>svn add</code>, type the following in ~/.subversion/config</p>
<div class="highlight"><pre class="chroma"><code class="language-ini" data-lang="ini"><span class="k">[miscellany]</span>
<span class="na">enable-auto-props</span> <span class="o">=</span> <span class="s">yes</span>

<span class="k">[auto-props]</span>
<span class="na">*.cpp</span> <span class="o">=</span> <span class="s">svn:keywords=Id URL</span>
<span class="na">*.sh</span> <span class="o">=</span> <span class="s">svn:keywords=Id URL;svn:executable</span>
<span class="na">...</span></code></pre></div>
<p>This file likely exists with a bunch of commented out stuff.  BE SURE THAT THE <code>svn:keywords</code> IN <code>[auto-props]</code> DOES NOT HAVE QUOTES.</p>
]]></content>
		</item>
		
		<item>
			<title>Easy Way to Restoring Core Files in Windows Vista or Windows 7</title>
			<link>/posts/2010-08-08-easy-way-restoring-core-files-windows-vista-or-windows-7/</link>
			<pubDate>Sun, 08 Aug 2010 22:07:11 +0000</pubDate>
			
			<guid>/posts/2010-08-08-easy-way-restoring-core-files-windows-vista-or-windows-7/</guid>
			<description>If you ever get attacked by malware or have install get botched getting the core Windows files can be a pain. You don&amp;rsquo;t need a support disk, have to reinstall windows, or download the file from some scary site that might be giving you malware. Just do this:
 Start | All Programs | Accessories Right click Command Prompt. Run as Administrator Type sfc /scannow Reboot.  The scan will take about ten minutes or so.</description>
			<content type="html"><![CDATA[

<p>If you ever get attacked by malware or have install get botched getting the core Windows files can be a pain.  You don&rsquo;t need a support disk, have to reinstall windows, or download the file from some scary site that might be giving you malware.  Just do this:</p>

<ol>
<li><code>Start</code> | <code>All Programs</code> | <code>Accessories</code></li>
<li>Right click <code>Command Prompt</code>.</li>
<li><code>Run as Administrator</code></li>
<li>Type <code>sfc /scannow</code></li>
<li>Reboot.</li>
</ol>

<p>The scan will take about ten minutes or so.  After doing this, the Windows core files should work again.  It will give a link to a log that might be helpful if <code>sfc</code> didn&rsquo;t work as expected.</p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://support.microsoft.com/kb/929833">http://support.microsoft.com/kb/929833</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Using bzip with pg_dump</title>
			<link>/posts/2010-08-07-using-bzip-pgdump/</link>
			<pubDate>Sat, 07 Aug 2010 14:56:46 +0000</pubDate>
			
			<guid>/posts/2010-08-07-using-bzip-pgdump/</guid>
			<description>To dump data from a table:
pg_dump -hlocalhost -Upostgres -a -t table database|bzip2 &amp;gt; tabledata.bz2
To restore:
bzip2 -c -d tabledata.bz2 | psql -hlocalhost -Upostgres database</description>
			<content type="html"><![CDATA[<p>To dump data from a table:</p>

<p><code>pg_dump -hlocalhost -Upostgres -a -t table database|bzip2 &gt; tabledata.bz2</code></p>

<p>To restore:</p>

<p><code>bzip2 -c -d tabledata.bz2 | psql -hlocalhost -Upostgres database</code></p>
]]></content>
		</item>
		
		<item>
			<title>Where is the Bash Script Running?</title>
			<link>/posts/2010-08-06-where-bash-script-running/</link>
			<pubDate>Fri, 06 Aug 2010 20:02:52 +0000</pubDate>
			
			<guid>/posts/2010-08-06-where-bash-script-running/</guid>
			<description>Sometimes it&amp;rsquo;s necessary to figure out where the current bash script is running. Just use the $0 parameter.
   command comment     echo `dirname $0` The directory in which the script is running.   echo `basename $0` The name of the script itself (w/o it directory).    </description>
			<content type="html"><![CDATA[<p>Sometimes it&rsquo;s necessary to figure out where the current bash script is running.  Just use the <code>$0</code> parameter.</p>

<table>
<thead>
<tr>
<th>command</th>
<th>comment</th>
</tr>
</thead>

<tbody>
<tr>
<td><code>echo `dirname $0`</code></td>
<td>The directory in which the script is running.</td>
</tr>

<tr>
<td><code>echo `basename $0`</code></td>
<td>The name of the script itself (w/o it directory).</td>
</tr>
</tbody>
</table>
]]></content>
		</item>
		
		<item>
			<title>Inverted File Search in Bash</title>
			<link>/posts/2010-08-06-inverted-file-search-bash/</link>
			<pubDate>Fri, 06 Aug 2010 19:20:32 +0000</pubDate>
			
			<guid>/posts/2010-08-06-inverted-file-search-bash/</guid>
			<description>There are two basic ways to exclude a file from a search:
   command comment     `ls grep -v exclude`   find -name * -not -name exclude find with a not    </description>
			<content type="html"><![CDATA[<p>There are two basic ways to exclude a file from a search:</p>

<table>
<thead>
<tr>
<th>command</th>
<th>comment</th>
</tr>
</thead>

<tbody>
<tr>
<td>`ls</td>
<td>grep -v exclude`</td>
</tr>

<tr>
<td><code>find -name * -not -name exclude</code></td>
<td>find with a <code>not</code></td>
</tr>
</tbody>
</table>
]]></content>
		</item>
		
		<item>
			<title>Why Use Double Quotes around Variables in Bash?</title>
			<link>/posts/2010-08-05-why-use-double-quotes-around-variables-bash/</link>
			<pubDate>Thu, 05 Aug 2010 16:50:56 +0000</pubDate>
			
			<guid>/posts/2010-08-05-why-use-double-quotes-around-variables-bash/</guid>
			<description>Using double quotes never really made much sense until I tried this
First, set $x
x=&#39;-e h\ti&#39;
Now look at these results
   command result effective command comment     echo $x h i echo -e h\ti A variable can be used to specify options, such a -e in this case.   echo &amp;quot;$x&amp;quot; -e h\ti echo &#39;-e h\ti&#39; Double quotes around the variable prevent it from being used in options.</description>
			<content type="html"><![CDATA[<p>Using double quotes never really made much sense until I tried this</p>

<p>First, set $x</p>

<p><code>x='-e h\ti'</code></p>

<p>Now look at these results</p>

<table>
<thead>
<tr>
<th>command</th>
<th>result</th>
<th>effective command</th>
<th>comment</th>
</tr>
</thead>

<tbody>
<tr>
<td><code>echo $x</code></td>
<td><code>h     i</code></td>
<td><code>echo -e h\ti</code></td>
<td>A variable can be used to specify options, such a <code>-e</code> in this case.</td>
</tr>

<tr>
<td><code>echo &quot;$x&quot;</code></td>
<td><code>-e h\ti</code></td>
<td><code>echo '-e h\ti'</code></td>
<td>Double quotes around the variable prevent it from being used in options.</td>
</tr>
</tbody>
</table>
]]></content>
		</item>
		
		<item>
			<title>Appending a New Value to the End of an Array in Bash</title>
			<link>/posts/2010-08-05-appending-new-value-end-array-bash/</link>
			<pubDate>Thu, 05 Aug 2010 10:16:41 +0000</pubDate>
			
			<guid>/posts/2010-08-05-appending-new-value-end-array-bash/</guid>
			<description>Short Version    Command Case     array[${# array[*]}]=&amp;quot;$variable&amp;quot; Indexed at zero   array[${# array[*]}+1]=&amp;quot;$variable&amp;quot; Indexed at one    Explanation I haven&amp;rsquo;t found an easier way, but several harder ways to do this. The harder ways often include some sort of loop or creating a new array with the same name and appending the new value to the old values.
References:  http://www.</description>
			<content type="html"><![CDATA[

<h1 id="short-version">Short Version</h1>

<table>
<thead>
<tr>
<th>Command</th>
<th>Case</th>
</tr>
</thead>

<tbody>
<tr>
<td><code>array[${# array[*]}]=&quot;$variable&quot;</code></td>
<td>Indexed at zero</td>
</tr>

<tr>
<td><code>array[${# array[*]}+1]=&quot;$variable&quot;</code></td>
<td>Indexed at one</td>
</tr>
</tbody>
</table>

<h1 id="explanation">Explanation</h1>

<p>I haven&rsquo;t found an easier way, but several harder ways to do this.  The harder ways often include some sort of loop or creating a new array with the same name and appending the new value to the old values.</p>

<h1 id="references">References:</h1>

<ul>
<li><a href="http://www.poundbangwhack.com/2010/02/04/how-to-append-values-to-an-array-in-bash/">http://www.poundbangwhack.com/2010/02/04/how-to-append-values-to-an-array-in-bash/</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Setting up mldonkey</title>
			<link>/posts/2010-07-31-setting-mldonkey/</link>
			<pubDate>Sat, 31 Jul 2010 13:13:15 +0000</pubDate>
			
			<guid>/posts/2010-07-31-setting-mldonkey/</guid>
			<description>Installation Install mldonkey:
apt-get install mldonkey-server
I saw this:  *** WARNING: ucf was run from a maintainer script that uses debconf, but the script did not pass &amp;ndash;debconf-ok to ucf. The maintainer script should be fixed to not stop debconf before calling ucf, and pass it this parameter. For now, ucf will revert to using old-style, non-debconf prompting. Ugh!
 Please inform the package maintainer about this problem.</description>
			<content type="html"><![CDATA[

<h1 id="installation">Installation</h1>

<p>Install <code>mldonkey</code>:</p>

<p><code>apt-get install mldonkey-server</code></p>

<p>I saw this:
<pre>
*** WARNING: ucf was run from a maintainer script that uses debconf, but
             the script did not pass &ndash;debconf-ok to ucf. The maintainer
             script should be fixed to not stop debconf before calling ucf,
             and pass it this parameter. For now, ucf will revert to using
             old-style, non-debconf prompting. Ugh!</p>

<pre><code>         Please inform the package maintainer about this problem. 
</code></pre>

<p></pre></p>

<p>It didn&rsquo;t seem critical, so I continued.</p>

<h1 id="initial-rejection">Initial Rejection</h1>

<p>The install went okay, but when I try to access it through telnet, I get this:
<pre>
$ telnet localhost 4000
Trying 127.0.0.1&hellip;
Connected to localhost.
Escape character is &lsquo;^]&rsquo;.
Telnet connection from 127.0.0.1 rejected (see allowed_ips setting)
Connection closed by foreign host.
</pre></p>

<p>This was fixed by a simple restart:</p>

<p><code>sudo /etc/init.d/mldonkey-server restart</code></p>

<p>Then, I got this:
<pre>
$ telnet localhost 4000
Trying 127.0.0.1&hellip;
Connected to localhost.
Escape character is &lsquo;^]&rsquo;.
Welcome to MLDonkey 2.9.5
Welcome on mldonkey command-line</p>

<p>Use ? for help</p>

<p>MLdonkey command-line:
&gt;
</pre></p>

<h1 id="note-about-configuration-files">Note About Configuration Files</h1>

<p>After some research, I found that the <code>allowed_ips</code> is a parameter in a file called <code>download.ini</code>.  There was no <code>/etc/mldonkey</code>.  Instead, I did a lot of digging and found <code>/etc/default/mldonkey-server</code>, which has a value called <code>MLDONKEY_DIR</code> which was set to <code>/var/lib/mldonkey</code>.  So, the file I needed was at <code>/var/lib/mldonkey/downloads.ini</code>.  However, do not touch this file.  The system is designed to be configured through telnet or the web interface.  When I changed these files directly, the file would revert to the old values.</p>

<h1 id="changing-allowed-ips">Changing allowed_ips</h1>

<p>So I just went to the telnet prompt and changed the <code>allowed_ips</code> value directly:
<pre>
$ telnet localhost 4000
Trying 127.0.0.1&hellip;
Connected to localhost.
Escape character is &lsquo;^]&rsquo;.
Welcome to MLDonkey 2.9.5
Welcome on mldonkey command-line</p>

<p>Use ? for help</p>

<p>MLdonkey command-line:
&gt; set allowed_ips 192.168.0.0/24
option allowed_ips value changed
</pre></p>

<p>Then, the web interface became available to the entire network at <a href="http://my-machine:4080">http://my-machine:4080</a></p>
]]></content>
		</item>
		
		<item>
			<title>Doing a Wake-On-Lan (WoL) over the internet.</title>
			<link>/posts/2010-07-30-doing-wake-lan-wol-over-internet/</link>
			<pubDate>Fri, 30 Jul 2010 23:51:20 +0000</pubDate>
			
			<guid>/posts/2010-07-30-doing-wake-lan-wol-over-internet/</guid>
			<description>Introduction Here&amp;rsquo;s how to wake a system up remotely.
Inside the Machine First, be sure the BIOS is properly configured for WoL. After that, run the following command to see if it&amp;rsquo;s supported by your card:
sudo ethtool eth0
The result should look something like this:  Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: Yes Link partner advertised link modes: Not reported Link partner advertised pause frame use: No Link partner advertised auto-negotiation: No Speed: 100Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: pg Wake-on: d Current message level: 0x0000003f (63) Link detected: yes</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>Here&rsquo;s how to wake a system up remotely.</p>

<h1 id="inside-the-machine">Inside the Machine</h1>

<p>First, be sure the BIOS is properly configured for WoL.  After that, run the following command to see if it&rsquo;s supported by your card:</p>

<p><code>sudo ethtool eth0</code></p>

<p>The result should look something like this:
<pre>
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  Not reported
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: pg
        Wake-on: d
        Current message level: 0x0000003f (63)
        Link detected: yes
</pre></p>

<p>Notice the <code>Supports Wake-on</code> and <code>Wake-on</code> properties.  Here&rsquo;s how to decode them:
<pre>
              p  Wake on phy activity
              u  Wake on unicast messages
              m  Wake on multicast messages
              b  Wake on broadcast messages
              a  Wake on ARP
              g  Wake on MagicPacket&trade;
              s  Enable SecureOn&trade; password for MagicPacket&trade;
              d  Disable (wake on nothing).  This option clears all previous options.
</pre></p>

<p>For this tutorial, I just use the <code>g</code> option.  By default, it&rsquo;s usually set to <code>d</code>.  Just type this to change it to <code>g</code>:</p>

<p><code>sudo ethtool -s eth0 wol g</code></p>

<p>Run <code>sudo ethtool eth0</code> again and check <code>Wake-on</code> to see if it worked.</p>

<h1 id="inside-the-lan">Inside the LAN</h1>

<p>After your BIOS is properly configured, turn off the machine and try sending the wake message from inside the LAN. Use the <code>wakeonlan</code> utility.  It usually does not come by default but is often available by <code>apt-get install wakeonlan</code>.</p>

<p>You&rsquo;ll need the system&rsquo;s MAC ID, by typing <code>ifconfig</code> and you should see something like:
<pre>
eth0      Link encap:Ethernet  HWaddr 00:12:34:56:77:88<br />
          inet addr:192.168.0.206  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:121930 errors:0 dropped:0 overruns:0 frame:0
          TX packets:100023 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3836347 (3.8 MB)  TX bytes:1836 (1.8 KB)
          Interrupt:27 Base address:0xc000</p>

<p>lo        Link encap:Local Loopback<br />
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::<sup>1</sup>&frasl;<sub>128</sub> Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:710806 errors:0 dropped:0 overruns:0 frame:0
          TX packets:710806 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:66446307 (66.4 MB)  TX bytes:66446307 (66.4 MB)</p>

<p>wlan0     Link encap:Ethernet  HWaddr 00:11:22:33:45:66<br />
          inet addr:192.168.0.207  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1238388 errors:0 dropped:0 overruns:0 frame:0
          TX packets:924491 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:943593318 (943.5 MB)  TX bytes:124590574 (124.5 MB)
</pre></p>

<p>The following line gives the MAC ID:</p>

<p><code>eth0      Link encap:Ethernet  HWaddr 00:12:34:56:77:88</code></p>

<p>HWaddr is what you want.  eth0 is the wired connection and wlan0 is wireless.  Likely, wireless will NOT work.</p>

<p>Now write down the HWaddr and halt the target machine.  Then, type this:</p>

<p><code>wakeonlan 00:12:34:56:77:88</code></p>

<p>The machine should turn itself on in a matter of minutes.</p>

<h1 id="wol-over-the-internet">WoL over the Internet</h1>

<p>Now, try to monitor for the packet with this command:</p>

<p><code>sudo tcpdump -i eth0 udp port 9</code></p>

<p>Run <code>wakeonlan</code> locally and you should see something like this:
<pre>
22:42:22.017251 IP yourmachine.local.52793 &gt; 255.255.255.255.discard: UDP, length 102
</pre></p>

<p>It should happen every time you execute the <code>wakeonlan</code> command.  Keep this running.  It will tell us if the packet is actually getting through without having to constantly power down the target machine.</p>

<p>Now find your external IP address.  I like using <a href="http://whatsmyipaddress.com">http://whatsmyipaddress.com</a>.  Now try to send a packet to your target IP address (eg 1.2.3.4 shown below) from your external Internet machine:</p>

<p><code>wakeonlan -i 1.2.3.4 00:12:34:56:77:88</code></p>

<p>If you see the packet in <code>tcpdump</code>, great.  If not, go to the next section.</p>

<h1 id="getting-wol-through-a-firewall">Getting WoL through a Firewall</h1>

<p>Keep the tcpdump mentioned above running.  Then, go into the router configuration and set udp port 9 traffic to be sent to the IP address 255.255.255.255.  This is the &ldquo;broadcast&rdquo; address.  This is great for home use and testing, but not a good idea in a big organization as every IP on your LAN will see the packet.</p>

<p>Now, try the wakeonlan again.  Be sure tcpdump caught it.  If not, check your router configuration again.</p>

<h1 id="references">References:</h1>

<ul>
<li><a href="http://ubuntuforums.org/showthread.php?t=1362739">http://ubuntuforums.org/showthread.php?t=1362739</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Warning: No xauth data; using fake authentication data for X11 forwarding</title>
			<link>/posts/2010-07-30-warning-no-xauth-data-using-fake-authentication-data-x11-forwarding/</link>
			<pubDate>Fri, 30 Jul 2010 16:33:30 +0000</pubDate>
			
			<guid>/posts/2010-07-30-warning-no-xauth-data-using-fake-authentication-data-x11-forwarding/</guid>
			<description>When ssh&amp;rsquo;ing to a remote machine in Cygwin, I sometimes get:
Warning: No xauth data; using fake authentication data for X11 forwarding.
To fix it, simply type this on the local machine:
xauth add :0 . `mcookie` Then, type the following to verify: xauth list
You should see something like:  user/unix:0 MIT-MAGIC-COOKIE-1 abcdef1234567890abcdef1234567890a</description>
			<content type="html"><![CDATA[<p>When ssh&rsquo;ing to a remote machine in Cygwin, I sometimes get:</p>

<p><code>Warning: No xauth data; using fake authentication data for X11 forwarding.</code></p>

<p>To fix it, simply type this on the local machine:</p>

<pre>xauth add :0 . `mcookie`</pre>

<p>Then, type the following to verify:
<code>xauth list</code></p>

<p>You should see something like:
<pre>
user/unix:0  MIT-MAGIC-COOKIE-1  abcdef1234567890abcdef1234567890a
</pre></p>
]]></content>
		</item>
		
		<item>
			<title>How to Create a Tally Table in MySQL</title>
			<link>/posts/2010-07-29-how-create-tally-table-mysql/</link>
			<pubDate>Thu, 29 Jul 2010 11:33:39 +0000</pubDate>
			
			<guid>/posts/2010-07-29-how-create-tally-table-mysql/</guid>
			<description>A tally table consists of a single field that simply counts up. The following SQL will create the table and add 10,000 rows.
-- Create the tally table. CREATE TABLE tally ( id int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ); -- Populate it delimiter // CREATE PROCEDURE create_tally() BEGIN SET @x = 0; WHILE @x&amp;lt;100000 DO --Insert a single row into tally. INSERT INTO tally (id) VALUES (NULL); SET @x = @x + 1; END WHILE; END// delimiter ; CALL create_tally(); DROP PROCEDURE create_tally;</description>
			<content type="html"><![CDATA[<p>A tally table consists of a single field that simply counts up.  The following SQL will create the table and add 10,000 rows.</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="c1">-- Create the tally table.
</span><span class="c1"></span><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="nf">tally</span> <span class="p">(</span>
	<span class="n">id</span> <span class="kt">int</span> <span class="k">unsigned</span> <span class="k">NOT</span> <span class="no">NULL</span> <span class="kp">AUTO_INCREMENT</span><span class="p">,</span>
	<span class="k">PRIMARY</span> <span class="k">KEY</span> <span class="p">(</span><span class="n">id</span><span class="p">)</span>
<span class="p">);</span>

<span class="c1">-- Populate it
</span><span class="c1"></span><span class="n">delimiter</span> <span class="o">//</span>
<span class="k">CREATE</span> <span class="k">PROCEDURE</span> <span class="nf">create_tally</span><span class="p">()</span>
<span class="n">BEGIN</span>
  	<span class="kt">SET</span> <span class="o">@</span><span class="n">x</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
  	<span class="k">WHILE</span> <span class="o">@</span><span class="n">x</span><span class="o">&lt;</span><span class="mi">100000</span> <span class="n">DO</span>
  		<span class="o">--</span><span class="k">Insert</span> <span class="n">a</span> <span class="n">single</span> <span class="n">row</span> <span class="k">into</span> <span class="n">tally</span><span class="p">.</span>
  		<span class="k">INSERT</span> <span class="k">INTO</span> <span class="nf">tally</span> <span class="p">(</span><span class="n">id</span><span class="p">)</span> <span class="k">VALUES</span> <span class="p">(</span><span class="no">NULL</span><span class="p">);</span>
		<span class="kt">SET</span> <span class="o">@</span><span class="n">x</span> <span class="o">=</span> <span class="o">@</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
	<span class="n">END</span> <span class="k">WHILE</span><span class="p">;</span>
<span class="n">END</span><span class="o">//</span>
<span class="n">delimiter</span> <span class="p">;</span>
<span class="k">CALL</span> <span class="nf">create_tally</span><span class="p">();</span>
<span class="k">DROP</span> <span class="k">PROCEDURE</span> <span class="n">create_tally</span><span class="p">;</span></code></pre></div>]]></content>
		</item>
		
		<item>
			<title>Setting Up ssh-agent to Ask Passphrase Only Once</title>
			<link>/posts/2010-07-26-setting-ssh-agent-ask-passphrase-only-once/</link>
			<pubDate>Mon, 26 Jul 2010 15:10:35 +0000</pubDate>
			
			<guid>/posts/2010-07-26-setting-ssh-agent-ask-passphrase-only-once/</guid>
			<description>Short Version ssh-agent bash
then
ssh-add
or maybe
ssh-add /home/user/.ssh/id_dsa
Long Version Before trying anything, be sure that the communication between to the two hosts is using keys. Type this:
ssh target
you should see this:
Enter passphrase for key &#39;/home/user/.ssh/id_rsa&#39;:
not
user@target&#39;s password:
If you get prompted for a passphrase instead of a password, go here, but be sure to add a passphrase. It is extremely dangerous to use a private key that doesn&amp;rsquo;t have a passphrase.</description>
			<content type="html"><![CDATA[

<h1 id="short-version">Short Version</h1>

<p><code>ssh-agent bash</code></p>

<p>then</p>

<p><code>ssh-add</code></p>

<p>or maybe</p>

<p><code>ssh-add /home/user/.ssh/id_dsa</code></p>

<h1 id="long-version">Long Version</h1>

<p>Before trying anything, be sure that the communication between to the two hosts is using keys.  Type this:</p>

<p><code>ssh target</code></p>

<p>you should see this:</p>

<p><code>Enter passphrase for key '/home/user/.ssh/id_rsa':</code></p>

<p>not</p>

<p><code>user@target's password:</code></p>

<p>If you get prompted for a passphrase instead of a password, go <a href="http://linuxproblem.org/art_9.html">here</a>, but be sure to add a passphrase.  It is extremely dangerous to use a private key that doesn&rsquo;t have a passphrase.  If anyone gets access to that private key, they can use it.  However,  adding a passphrase initially brings you back to the problem of asking for the passphrase several times.  <code>ssh-agent</code> can fix this problem.  To get started, simply type:</p>

<p><code>ssh-agent bash</code></p>

<p>This creates a new bash process that allows you to add private keys.  When adding a new private key you will be prompted for the passphrase once and only once.  Do that by typing:</p>

<p><code>ssh-add</code></p>

<p>Then, the key at <code>~/.ssh/id_dsa</code> will be added and you should not get prompted for a passphrase.  Then, type <code>exit</code> to have the OS forget your passphrase.</p>

<p>To verify that your key has been added, type:</p>

<p><code>ssh-add -l</code></p>

<p>It should show you the fingerprints and filenames of all keys in the agent session.</p>

<h1 id="using-an-ssh-agent-in-a-script">Using an ssh-agent in a script</h1>

<p>Use the following bash code to reuse and ssh-agent in a script:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="cp">#!/bin/bash
</span><span class="cp"></span>
<span class="nv">tempfile</span><span class="o">=</span>/tmp/ssh-agent.test

<span class="c1"># Check for an existing ssh-agent</span>
<span class="k">if</span> <span class="o">[</span> -e <span class="nv">$tempfile</span> <span class="o">]</span>
<span class="k">then</span>
    <span class="nb">echo</span> <span class="s2">&#34;Examining old ssh-agent&#34;</span>
    . <span class="nv">$tempfile</span>
<span class="k">fi</span>

<span class="c1"># See if the agent is still working</span>
ssh-add -l &gt; /dev/null

<span class="c1"># If it&#39;s not working yet, just start a new one.</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$?</span> !<span class="o">=</span> <span class="m">0</span> <span class="o">]</span>
<span class="k">then</span>
    <span class="nb">echo</span> <span class="s2">&#34;Old ssh-agent is dead..creating new agent.&#34;</span>

    <span class="c1"># Create a new ssh-agent if needed</span>
    ssh-agent -s &gt; <span class="nv">$tempfile</span>
    . <span class="nv">$tempfile</span>

    <span class="c1"># Add the key</span>
    ssh-add
<span class="k">fi</span>    

<span class="c1"># Show the user which keys are being used.</span>
ssh-add -l</code></pre></div>
<p><code>ssh-agent -s</code> creates an <code>ssh-agent</code> and prints out three lines that basically set the appropriate environment variables for <code>ssh-add</code> to function properly.  This script saves the output of <code>ssh-agent -s</code> to a known file location that can be reused each time the script is run.  It also detects if the <code>ssh-agent</code> is no longer working.  If so, it simply launches a new agent and adds the key.</p>

<p>The nice part about this script is that it will work if a script is <code>sudo</code>&rsquo;d.  However, the file will get a permission&rsquo;s error if the script is run with <code>sudo</code> and then run without <code>sudo</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>Working with multiple buffers in Emacs</title>
			<link>/posts/2010-07-24-working-multiple-buffers-emacs/</link>
			<pubDate>Sat, 24 Jul 2010 23:22:27 +0000</pubDate>
			
			<guid>/posts/2010-07-24-working-multiple-buffers-emacs/</guid>
			<description>C-x C-b creates a buffer with a list of buffers. M-x describe-mode wasn&amp;rsquo;t helpful. Here&amp;rsquo;s how to use this buffer: Here are the useful commands: |key|action| |&amp;mdash;|&amp;mdash;| |C-o|See the buffer in the other window| |g|Refresh| |T|Toggle view of non-file buffers| |d|Mark buffer on current line for delete| |x|Delete marked buffers.|</description>
			<content type="html"><![CDATA[<p><code>C-x C-b</code> creates a buffer with a list of buffers.  <code>M-x describe-mode</code> wasn&rsquo;t helpful.  Here&rsquo;s how to use this buffer:
<http://www.gnu.org/software/emacs/manual/html_node/emacs/Several-Buffers.html# Several-Buffers></p>

<p>Here are the useful commands:
|key|action|
|&mdash;|&mdash;|
|C-o|See the buffer in the other window|
|g|Refresh|
|T|Toggle view of non-file buffers|
|d|Mark buffer on current line for delete|
|x|Delete marked buffers.|</p>
]]></content>
		</item>
		
		<item>
			<title>Doing a sudo to a remote server in Emacs to open/save a file</title>
			<link>/posts/2010-07-24-doing-sudo-remote-server-emacs-opensave-file/</link>
			<pubDate>Sat, 24 Jul 2010 23:20:39 +0000</pubDate>
			
			<guid>/posts/2010-07-24-doing-sudo-remote-server-emacs-opensave-file/</guid>
			<description>When trying to open a file as root in emacs with tramp using /sudo:myserver:&amp;hellip; I see the following error:  Debugger entered&amp;ndash;Lisp error: (file-error &amp;ldquo;Host myserver&#39; looks like a remote host,sudo&amp;rsquo; can only use the local host&amp;rdquo;) 
Well, there is a way to tell Emacs to get to that server and open the file with a sudo. Add this to the .emacs file:  (add-to-list &amp;lsquo;tramp-default-proxies-alist &amp;lsquo;(&amp;ldquo;.*&amp;rdquo; &amp;ldquo;`root\&amp;lsquo;&amp;rdquo; &amp;ldquo;/ssh:%h:&amp;ldquo;))</description>
			<content type="html"><![CDATA[<p>When trying to open a file as root in emacs with tramp using <pre>/sudo:myserver:&hellip;</pre> I see the following error:
<pre>
Debugger entered&ndash;Lisp error: (file-error &ldquo;Host <code>myserver' looks like a remote host,</code>sudo&rsquo; can only use the local host&rdquo;)
</pre></p>

<p>Well, there is a way to tell Emacs to get to that server and open the file with a sudo.  Add this to the .emacs file:
<pre>
(add-to-list &lsquo;tramp-default-proxies-alist &lsquo;(&ldquo;.*&rdquo; &ldquo;`root\&lsquo;&rdquo; &ldquo;/ssh:%h:&ldquo;))
</pre></p>

<p>Restart Emacs and /sudo will start working on remote sites.</p>

<p>This only seems to work in Cygwin Emacs.  I tried in Ubuntu and got:
<pre>
tramp-compute-multi-hops: Host <code>solomonson.com' looks like a remote host,</code>sudo&rsquo; can only use the local host
</pre></p>

<p>After much experimentation, I found that this works on Ubuntu:
<pre>
(set-default &lsquo;tramp-default-proxies-alist (quote ((&ldquo;.*&rdquo; &ldquo;\`root\&rsquo;&rdquo; &ldquo;/ssh:%h:&ldquo;))))
</pre></p>
]]></content>
		</item>
		
		<item>
			<title>Numeric represention of protocols (eg TCP, UDP, ICMP)</title>
			<link>/posts/2010-07-24-numeric-represention-protocols-eg-tcp-udp-icmp/</link>
			<pubDate>Sat, 24 Jul 2010 23:19:25 +0000</pubDate>
			
			<guid>/posts/2010-07-24-numeric-represention-protocols-eg-tcp-udp-icmp/</guid>
			<description>This link has them: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
See also this file in your Linux install: /etc/protocols</description>
			<content type="html"><![CDATA[<p>This link has them:
<a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml">http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml</a></p>

<p>See also this file in your Linux install:
/etc/protocols</p>
]]></content>
		</item>
		
		<item>
			<title>How to determine the bit width (32-bit or 64-bit) of a processor</title>
			<link>/posts/2010-07-24-how-determine-bit-width-32-bit-or-64-bit-processor/</link>
			<pubDate>Sat, 24 Jul 2010 23:18:22 +0000</pubDate>
			
			<guid>/posts/2010-07-24-how-determine-bit-width-32-bit-or-64-bit-processor/</guid>
			<description>Installing a 64-bit OS and hoping for the best is time consuming. This command works well:
grep flags /proc/cpuinfo
It might looks something like:  flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm</description>
			<content type="html"><![CDATA[<p>Installing a 64-bit OS and hoping for the best is time consuming.  This command works well:</p>

<p><code>grep flags /proc/cpuinfo</code></p>

<p>It might looks something like:
<pre>
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
</pre></p>

<p>The <code>lm</code> attribute indicates the processor is 64-bit.</p>

<p>If it&rsquo;s a windows machine, use <a href="http://www.sysresccd.org/Main_Page">SystemRescueCD</a> to boot it into Linux.</p>
]]></content>
		</item>
		
		<item>
			<title>Slow TRAMP transfer with ssh</title>
			<link>/posts/2010-07-24-slow-tramp-transfer-ssh/</link>
			<pubDate>Sat, 24 Jul 2010 23:17:17 +0000</pubDate>
			
			<guid>/posts/2010-07-24-slow-tramp-transfer-ssh/</guid>
			<description>I&amp;rsquo;m not sure why, but when I try to edit an 89k file, using tramp there are issues.
I found several entries on the EmacsWiki TRAMP page talking about how version control gets in the way. But this file and directory had no source control. Then, I found this:
http://www.fifi.org/doc/tramp/tramp-emacs.html
It mentions that ssh actually uses a perl script to do its dirty work. My guess is that the perl script has a few issues.</description>
			<content type="html"><![CDATA[<p>I&rsquo;m not sure why, but when I try to edit an 89k file, using tramp there are issues.</p>

<p>I found several entries on the EmacsWiki TRAMP page talking about how version control gets in the way.  But this file and directory had no source control.  Then, I found this:</p>

<p><a href="http://www.fifi.org/doc/tramp/tramp-emacs.html">http://www.fifi.org/doc/tramp/tramp-emacs.html</a></p>

<p>It mentions that ssh actually uses a perl script to do its dirty work.  My guess is that the perl script has a few issues.  So instead, I used scp and it was more than a 1000 times faster.  I have yet to see any disadvantage.</p>

<p>I also found this interesting article:</p>

<p><a href="http://stackoverflow.com/questions/148578/using-emacs-tramp-vs-rsync-for-remote-development">http://stackoverflow.com/questions/148578/using-emacs-tramp-vs-rsync-for-remote-development</a></p>

<p>Haven&rsquo;t tried these.</p>
]]></content>
		</item>
		
		<item>
			<title>Ubuntu Linux Text-to-Speech</title>
			<link>/posts/2010-07-24-ubuntu-linux-text-speech/</link>
			<pubDate>Sat, 24 Jul 2010 23:13:43 +0000</pubDate>
			
			<guid>/posts/2010-07-24-ubuntu-linux-text-speech/</guid>
			<description>Introduction Using Festival Text-to-Speech in Ubuntu doesn&amp;rsquo;t work after the install. Here are some steps I took to fix it. Also, some changes to make it useful in everyday work.
Getting Festival to Work Festival is the free text-to-speech engine that is extremely popular.
Here&amp;rsquo;s how to get it:
sudo apt-get install festival
Here&amp;rsquo;s how to test it:
echo &amp;quot;hello world&amp;quot;|festival --tts
You may see this error:
Linux: can&#39;t open /dev/dsp</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>Using Festival Text-to-Speech in Ubuntu doesn&rsquo;t work after the install.  Here are some steps I took to fix it.  Also, some changes to make it useful in everyday work.</p>

<h1 id="getting-festival-to-work">Getting Festival to Work</h1>

<p><a href="http://www.cstr.ed.ac.uk/projects/festival/">Festival</a> is the free text-to-speech engine that is extremely popular.</p>

<p>Here&rsquo;s how to get it:</p>

<p><code>sudo apt-get install festival</code></p>

<p>Here&rsquo;s how to test it:</p>

<p><code>echo &quot;hello world&quot;|festival --tts</code></p>

<p>You may see this error:</p>

<p><code>Linux: can't open /dev/dsp</code></p>

<p>If so, add the following lines to your <code>.festivalrc</code> file:</p>
<div class="highlight"><pre class="chroma"><code class="language-lisp" data-lang="lisp"><span class="p">(</span><span class="nv">Parameter.set</span> <span class="ss">&#39;Audio_Command</span> <span class="s">&#34;aplay -q -c 1 -t raw -f s16 -r $SR $FILE&#34;</span><span class="p">)</span>
<span class="p">(</span><span class="nv">Parameter.set</span> <span class="ss">&#39;Audio_Method</span> <span class="ss">&#39;Audio_Command</span><span class="p">)</span></code></pre></div>
<h1 id="getting-it-to-read-the-clipboard">Getting it to read the clipboard</h1>

<p>Now, if you want it to read info from your clipboard, install this:</p>

<p><code>sudo apt-get install xclip</code></p>

<p>And type this:</p>

<p><code>xclip -o|festival --tts</code></p>

<p>Now, you can go a step further and create a shortcut key for reading text.  Here&rsquo;s a good one:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="cp">#!/bin/bash
</span><span class="cp"></span>
<span class="c1"># This script reads the information from the clipboard outloud.</span>

<span class="c1"># Look for festival being run.</span>
<span class="nv">running</span><span class="o">=</span><span class="k">$(</span>pgrep festival<span class="k">)</span>

<span class="k">if</span> <span class="o">[</span> -z <span class="nv">$running</span> <span class="o">]</span>
<span class="k">then</span>
    <span class="c1"># read it</span>
    xclip -o<span class="p">|</span>festival --tts
<span class="k">else</span>
    <span class="c1"># kill it</span>
    killall festival<span class="p">;</span>killall aplay<span class="p">;</span>sleep .1<span class="p">;</span>killall aplay
<span class="k">fi</span></code></pre></div>
<p>I call it <code>talk.sh</code>.  Be sure to do a <code>chmod +x talk.sh</code> to it.</p>

<h1 id="assigning-a-shortcut">Assigning a Shortcut</h1>

<p>Now, to assign to a shortcut key.  I&rsquo;m using Ubuntu which uses GNOME.  if you use something else..you&rsquo;re on your own.  Otherwise, click <code>System-&gt;Keyboard Shortcuts</code>.  Then add the path to the script and assign a shortcut.</p>

<p>I assigned it to the <code>Windows-A</code> keystroke.  You can click it once to start and again to stop.  Unfortunately, the script assumes you only have one instance of festival.</p>

<h1 id="adjusting-the-playback-speed">Adjusting the Playback Speed</h1>

<p>If you want it to read faster, change the <code>.festivalrc</code> file:</p>

<p><code>(Parameter.set 'Audio_Command &quot;aplay -q -c 1 -t raw -f s16 -r $(($SR*140/100)) $FILE&quot;)</code></p>

<p>The <sup>140</sup>&frasl;<sub>100</sub> means 140% of original speed which seems about right to me for most texts.</p>

<h1 id="improving-voice-ubuntu-12">Improving Voice (Ubuntu 12)</h1>

<p>The default voices in Festival do not sound great.  Try downloading <a href="/files/cmu_us_slt_arctic_hts.tar_.gz">cmu_us_slt_arctic<em>hts.tar</em>.gz</a>.  This is tar.gz file.  Here&rsquo;s how to install it:</p>

<ol>
<li>tar xvzf cmu_us_slt_arctic<em>hts.tar</em>.gz</li>
<li>sudo mv cmu_us_slt_arctic_hts /usr/share/festival/voices/english/</li>

<li><p>Update /usr/share/festival/voices.scm to have cmu_us_slt_arctic_hts at the top (Hint:  look for the work &ldquo;kal&rdquo; in the file)</p>
<div class="highlight"><pre class="chroma"><code class="language-lisp" data-lang="lisp"><span class="p">(</span><span class="nb">defvar</span> <span class="nv">default-voice-priority-list</span>
<span class="o">&#39;</span><span class="p">(</span><span class="nv">cmu_us_slt_arctic_hts</span>
<span class="nv">kal_diphone</span>
<span class="nv">cmu_us_bdl_arctic_hts</span>
<span class="nv">cmu_us_jmk_arctic_hts</span>
<span class="o">...</span></code></pre></div></li>
</ol>

<h1 id="improving-voices-ubuntu-10">Improving Voices (Ubuntu 10)</h1>

<p>The above instructions may not work in Ubuntu 10..instead, try this:</p>

<p>Here&rsquo;s a bash script to add new voices.  These are the best I could find anywhere:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="c1"># Setup</span>
<span class="nb">cd</span>
<span class="nv">dir</span><span class="o">=</span>nitech_us
mkdir <span class="nv">$dir</span>
<span class="nb">cd</span> <span class="nv">$dir</span>

<span class="c1"># Download the voices</span>
<span class="k">for</span> voice in awb bdl clb rms slt jmk
<span class="k">do</span>
  wget <span class="s2">&#34;http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_&#34;</span><span class="nv">$voice</span><span class="s2">&#34;_arctic_hts-2.0.1.tar.bz2&#34;</span>
<span class="k">done</span>

<span class="c1"># Unpack</span>
tar xvf *.bz2

<span class="c1"># Install</span>
sudo mkdir -p /usr/share/festival/voices/us
sudo mv lib/voices/us/* /usr/share/festival/voices/us/
sudo mv lib/hts.scm /usr/share/festival/hts.scm</code></pre></div>
<h1 id="setting-a-default-voice">Setting a Default Voice</h1>

<p>The default voice in Festival is configurable, but it doesn&rsquo;t seem to work.  It was necessary to change <code>/usr/share/festival/voices.scm</code> directly.  Simply update the <code>default-voice-priority-list</code>.  It should like something like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-lisp" data-lang="lisp"><span class="p">(</span><span class="nb">defvar</span> <span class="nv">default-voice-priority-list</span>
<span class="o">&#39;</span><span class="p">(</span><span class="nv">nitech_us_slt_arctic_hts</span>
<span class="nv">kal_diphone</span>
<span class="nv">cmu_us_bdl_arctic_hts</span>
<span class="nv">cmu_us_jmk_arctic_hts</span>
<span class="nv">cmu_us_slt_arctic_hts</span>
<span class="nv">cmu_us_awb_arctic_hts</span>
<span class="c1">; cstr_rpx_nina_multisyn ; restricted license (lexicon)</span>
<span class="c1">; cstr_rpx_jon_multisyn ; restricted license (lexicon)</span>
<span class="c1">; cstr_edi_awb_arctic_multisyn ; restricted license (lexicon)</span>
<span class="c1">; cstr_us_awb_arctic_multisyn</span>
<span class="nv">ked_diphone</span>
<span class="nv">don_diphone</span>
<span class="nv">rab_diphone</span>
<span class="nv">en1_mbrola</span>
<span class="nv">us1_mbrola</span>
<span class="nv">us2_mbrola</span>
<span class="nv">us3_mbrola</span>
<span class="nv">gsw_diphone</span> <span class="c1">;; not publically distributed</span>
<span class="nv">el_diphone</span>
<span class="p">)</span>
<span class="s">&#34;default-voice-priority-list
</span><span class="s">List of voice names. The first of them available becomes the default voice.&#34;</span><span class="p">)</span></code></pre></div>
<p>Notice how I put <code>nitech_us_slt_arctic_hts</code> at the top.  This is my favorite voice.</p>

<h1 id="references">References</h1>

<ul>
<li><a href="http://ubuntuforums.org/showthread.php?t=677277">http://ubuntuforums.org/showthread.php?t=677277</a></li>
<li><a href="http://ubuntuforums.org/showthread.php?t=751169">http://ubuntuforums.org/showthread.php?t=751169</a></li>
<li><a href="http://ubuntuforums.org/showpost.php?p=9516900&amp;postcount=3">http://ubuntuforums.org/showpost.php?p=9516900&amp;postcount=3</a></li>
<li><a href="http://ubuntuforums.org/showthread.php?t=751169&amp;page=15">http://ubuntuforums.org/showthread.php?t=751169&amp;page=15</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>How to Encode and Decode with Base64 and OpenSSL</title>
			<link>/posts/2010-07-24-how-encode-and-decode-base64-and-openssl/</link>
			<pubDate>Sat, 24 Jul 2010 23:11:14 +0000</pubDate>
			
			<guid>/posts/2010-07-24-how-encode-and-decode-base64-and-openssl/</guid>
			<description>Encode a string to Base64:
$ echo -n &amp;#34;encode me&amp;#34; | openssl enc -base64 Note: -n removes the newline character added by &amp;ldquo;echo&amp;rdquo;.
Decode a base64 to a string:
$ echo &amp;#34;ZW5jb2RlIG1lCg==&amp;#34; | openssl enc -base64 -d</description>
			<content type="html"><![CDATA[<p>Encode a string to Base64:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">$ <span class="nb">echo</span> -n <span class="s2">&#34;encode me&#34;</span> <span class="p">|</span> openssl enc -base64</code></pre></div>
<p>Note: -n removes the newline character added by &ldquo;echo&rdquo;.</p>

<p>Decode a base64 to a string:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">$ <span class="nb">echo</span> <span class="s2">&#34;ZW5jb2RlIG1lCg==&#34;</span> <span class="p">|</span> openssl enc -base64 -d</code></pre></div>]]></content>
		</item>
		
		<item>
			<title>Upgrading Debian from Etch to Lenny</title>
			<link>/posts/2010-07-24-upgrading-debian-etch-lenny/</link>
			<pubDate>Sat, 24 Jul 2010 23:08:49 +0000</pubDate>
			
			<guid>/posts/2010-07-24-upgrading-debian-etch-lenny/</guid>
			<description>I was trying to update my PHP and bad things started to happen:  libapache2-mod-php5: Depends: libc6 (&amp;gt;= 2.7-1) but 2.3.6.ds1-13etch10+b1 is to be installed Depends: libdb4.6 but it is not installable Depends: libkrb53 (&amp;gt;= 1.6.dfsg.2) but 1.4.4-7etch6 is to be installed Depends: libssl0.9.8 (&amp;gt;= 0.9.8f-5) but 0.9.8c-4etch4 is to be installed Depends: libxml2 (&amp;gt;= 2.6.28) but 2.6.27.dfsg-6 is to be installed Depends: php5-common (= 5.2.13-0.dotdeb.1) but 5.2.0+dfsg-8+etch16 is to be installed.</description>
			<content type="html"><![CDATA[<p>I was trying to update my PHP and bad things started to happen:
<pre>
libapache2-mod-php5: Depends: libc6 (&gt;= 2.7-1) but 2.3.6.ds1-13etch10+b1 is to be installed
Depends: libdb4.6 but it is not installable
Depends: libkrb53 (&gt;= 1.6.dfsg.2) but 1.4.4-7etch6 is to be installed
Depends: libssl0.9.8 (&gt;= 0.9.8f-5) but 0.9.8c-4etch4 is to be installed
Depends: libxml2 (&gt;= 2.6.28) but 2.6.27.dfsg-6 is to be installed
Depends: php5-common (= 5.2.13-0.dotdeb.1) but 5.2.0+dfsg-8+etch16 is to be installed.
</pre></p>

<p>See also</p>

<ul>
<li><http://www.dotdeb.org/2010/04/21/php-5-3-2-and-php-5-2-13-get-an-update/# comment-2510></li>
</ul>

<p>It looks like it was time to upgrade from Etch to Lenny.  <a href="http://www.go2linux.org/upgrading-debian">Here&rsquo;s how</a>:</p>

<ol>
<li>Edit /etc/apt/sources.list and replace all occurrences of <code>etch</code> with <code>lenny</code>.</li>
<li><code>sudo apt-get update</code></li>
<li><code>sudo apt-get dist-upgrade</code></li>
</ol>

<p>But, I also had some issues with certain keys not being allowed.  This command fixed it:
<code>sudo gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 9AA38DCD55BE302B</code></p>
]]></content>
		</item>
		
		<item>
			<title>How to Test the Strength of a WiFi Connection</title>
			<link>/posts/2010-07-24-how-test-strength-wifi-connection/</link>
			<pubDate>Sat, 24 Jul 2010 21:06:16 +0000</pubDate>
			
			<guid>/posts/2010-07-24-how-test-strength-wifi-connection/</guid>
			<description>Introduction I bought a new WiFi router that claimed to have special enhancements to boost the signal. I wanted to see how much of a boost was created. Here&amp;rsquo;s how it was accomplished:
Setup I found that iwconfig prints out a lot of data. Here&amp;rsquo;s an example:  lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11bg ESSID:&amp;ldquo;&amp;hellip;&amp;rdquo;
Mode:Managed Frequency:2.437 GHz Access Point: 00:11:22:33:44:55
Bit Rate=24 Mb/s Tx-Power=20 dBm</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>I bought a new WiFi router that claimed to have special enhancements to boost the signal.  I wanted to see how much of a boost was created.  Here&rsquo;s how it was accomplished:</p>

<h1 id="setup">Setup</h1>

<p>I found that iwconfig prints out a lot of data.  Here&rsquo;s an example:
<pre>
lo        no wireless extensions.</p>

<p>eth0      no wireless extensions.</p>

<p>wlan0     IEEE 802.11bg  ESSID:&ldquo;&hellip;&rdquo;<br />
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:11:22:33:44:55<br />
          Bit Rate=24 Mb/s   Tx-Power=20 dBm<br />
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=<sup>29</sup>&frasl;<sub>70</sub>  Signal level=-81 dBm<br />
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
</pre></p>

<p>I&rsquo;m not sure what it all means but <code>Link Quality</code> and <code>Signal level</code> look very interesting.  So, I wrote the following script:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="c1">#/bin/bash</span>

<span class="k">while</span> <span class="o">[</span> <span class="m">1</span> <span class="o">]</span>
<span class="k">do</span>
    iwconfig <span class="m">2</span>&gt;<span class="p">&amp;</span><span class="m">1</span><span class="p">|</span>grep Link
    sleep <span class="m">1</span>
<span class="k">done</span></code></pre></div>
<p>Now, I get something interesting every second.  It looked something like this:
<pre>
          Link Quality=<sup>31</sup>&frasl;<sub>70</sub>  Signal level=-79 dBm<br />
          Link Quality=<sup>31</sup>&frasl;<sub>70</sub>  Signal level=-79 dBm<br />
          Link Quality=<sup>30</sup>&frasl;<sub>70</sub>  Signal level=-80 dBm<br />
          Link Quality=<sup>29</sup>&frasl;<sub>70</sub>  Signal level=-81 dBm<br />
          Link Quality=<sup>31</sup>&frasl;<sub>70</sub>  Signal level=-79 dBm<br />
          Link Quality=<sup>30</sup>&frasl;<sub>70</sub>  Signal level=-80 dBm<br />
          Link Quality=<sup>31</sup>&frasl;<sub>70</sub>  Signal level=-79 dBm
</pre></p>

<p>Notice that the signal is in dBm and is always negative.  Also notice that <code>Link Quality</code> went up as signal became less negative.</p>

<h1 id="the-test">The Test</h1>

<p>I walked around the house while watching the <code>Link Quality</code> number change.  I noticed a huge difference when a wall was in the way.  It was even possible to determine the outer boundaries of the signal.  There may be other ways to view this information, but this was very easy for me.</p>
]]></content>
		</item>
		
		<item>
			<title>New User in Cygwin</title>
			<link>/posts/2010-07-21-new-user-cygwin/</link>
			<pubDate>Wed, 21 Jul 2010 15:32:14 +0000</pubDate>
			
			<guid>/posts/2010-07-21-new-user-cygwin/</guid>
			<description>Problem Cygwin does not have useradd or adduser. Instead, you should first create a user in Windows and run some commands in Cygwin to read the user list.
Create a Windows User Create the user in Windows (Usually Start|Control Panel|Manage User Accounts|Add&amp;hellip;)
Link to the Windows Users Type mkpasswd -l &amp;gt; /etc/passwd and mkgroup -l &amp;gt; /etc/group to get all of the local users and group synced up. Otherwise, replace the -l with a -d to get all users and groups from the domain.</description>
			<content type="html"><![CDATA[

<h1 id="problem">Problem</h1>

<p>Cygwin does not have <code>useradd</code> or <code>adduser</code>.  Instead, you should first create a user in Windows and run some commands in Cygwin to read the user list.</p>

<h1 id="create-a-windows-user">Create a Windows User</h1>

<p>Create the user in Windows (Usually Start|Control Panel|Manage User Accounts|Add&hellip;)</p>

<h1 id="link-to-the-windows-users">Link to the Windows Users</h1>

<p>Type <code>mkpasswd -l &gt; /etc/passwd</code> and <code>mkgroup -l &gt; /etc/group</code> to get all of the local users and group synced up.  Otherwise, replace the <code>-l</code> with a <code>-d</code> to get all users and groups from the domain.</p>
]]></content>
		</item>
		
		<item>
			<title>How to Fix an (errno: 24) in MySQL</title>
			<link>/posts/2010-07-19-how-fix-errno-24-mysql/</link>
			<pubDate>Mon, 19 Jul 2010 18:28:49 +0000</pubDate>
			
			<guid>/posts/2010-07-19-how-fix-errno-24-mysql/</guid>
			<description>When creating a large number of partitions or tables, MySQL may mysteriously stop working and you find this type of error on /var/lib/mysql/$HOSTNAME.err:
[ERROR] /usr/sbin/mysqld: Can&#39;t open file: &#39;./database/table.frm&#39; (errno: 24)
errno: 24 simply means that too many files are open for the given process. There is a read-only mysql variable called open_files_limit that will show how many open files are allowed by the mysqld:
SHOW VARIABLES LIKE &amp;#39;open%&amp;#39; A lot systems set this to something very low, like 1024.</description>
			<content type="html"><![CDATA[

<p>When creating a large number of partitions or tables, MySQL may mysteriously stop working and you find this type of error on <code>/var/lib/mysql/$HOSTNAME.err</code>:</p>

<p><code>[ERROR] /usr/sbin/mysqld: Can't open file: './database/table.frm' (errno: 24)</code></p>

<p><code>errno: 24</code> simply means that too many files are open for the given process.  There is a read-only mysql variable called <code>open_files_limit</code> that will show how many open files are allowed by the <code>mysqld</code>:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SHOW</span> <span class="n">VARIABLES</span> <span class="k">LIKE</span> <span class="s1">&#39;open%&#39;</span></code></pre></div>
<p>A lot systems set this to something very low, like 1024.  Unfortunately, the following will NOT work:</p>

<p><code>SET open_files_limit=100000</code></p>

<p>MySQL will respond with:</p>

<p><code>ERROR 1238 (HY000): Variable 'open_files_limit' is a read only variable</code></p>

<p>However, it is possible to make a change to <code>/etc/my.cnf</code>.  This file may not exist, if not, just create it.  Be sure it has the following contents:
<pre>
[mysqld]
open_files_limit = 100000
</pre></p>

<p>Then, be sure to restart mysql:</p>

<p><code>sudo /etc/init.d/mysql restart</code></p>

<p>Now, <code>SHOW VARIABLES LIKE 'open%'</code> should show 100000.  The number you use may be different.</p>

<h1 id="see-also">See Also</h1>

<ul>
<li><a href="http://blog.infusiontechsolutions.com/mysqldump-error-29/">mysqldump error 29</a></li>
<li><a href="http://stackoverflow.com/questions/34588/how-do-i-change-the-number-of-open-files-limit-in-linux">How to change number of open files</a></li>
<li><a href="http://www.puschitz.com/TuningLinuxForOracle.shtml">Oracle tuning</a>:  Some of these hints work for Linux</li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Re-creating MySQL data directory</title>
			<link>/posts/2010-07-19-re-creating-mysql-data-directory/</link>
			<pubDate>Mon, 19 Jul 2010 16:57:45 +0000</pubDate>
			
			<guid>/posts/2010-07-19-re-creating-mysql-data-directory/</guid>
			<description>If you ever need to re-create the data directory for MySQL, type this:
sudo mysql_install_db
However, if mysql does not start up again, check the log (usually at /var/lib/mysql/$HOSTNAME.err). Maybe it shows something like:  /usr/sbin/mysqld: Can&amp;rsquo;t find file: &amp;lsquo;./mysql/plugin.frm&amp;rsquo; (errno: 13) [ERROR] Can&amp;rsquo;t open the mysql.plugin table. Please run mysql_upgrade to create it. 
The (errno: 13) is a permissions thing. So do this:
sudo chown -R mysql:mysql /var/lib/mysql</description>
			<content type="html"><![CDATA[<p>If you ever need to re-create the data directory for MySQL, type this:</p>

<p><code>sudo mysql_install_db</code></p>

<p>However, if mysql does not start up again, check the log (usually at /var/lib/mysql/$HOSTNAME.err).  Maybe it shows something like:
<pre>
/usr/sbin/mysqld: Can&rsquo;t find file: &lsquo;./mysql/plugin.frm&rsquo; (errno: 13)
[ERROR] Can&rsquo;t open the mysql.plugin table. Please run mysql_upgrade to create it.
</pre></p>

<p>The <code>(errno: 13)</code> is a permissions thing.  So do this:</p>

<p><code>sudo chown -R mysql:mysql /var/lib/mysql</code></p>

<p>Now try to start mysql.</p>
]]></content>
		</item>
		
		<item>
			<title>While Loops and Arrays in Bash</title>
			<link>/posts/2010-07-19-while-loops-and-arrays-bash/</link>
			<pubDate>Mon, 19 Jul 2010 11:49:05 +0000</pubDate>
			
			<guid>/posts/2010-07-19-while-loops-and-arrays-bash/</guid>
			<description>Here&amp;rsquo;s a simple for loop using an array:
numbers=(one two three) for x in ${tables[@]} do echo &amp;#34;Number: $x&amp;#34; done</description>
			<content type="html"><![CDATA[<p>Here&rsquo;s a simple for loop using an array:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nv">numbers</span><span class="o">=(</span>one two three<span class="o">)</span>
<span class="k">for</span> x in <span class="si">${</span><span class="nv">tables</span><span class="p">[@]</span><span class="si">}</span>
<span class="k">do</span>
  <span class="nb">echo</span> <span class="s2">&#34;Number: </span><span class="nv">$x</span><span class="s2">&#34;</span>
<span class="k">done</span></code></pre></div>]]></content>
		</item>
		
		<item>
			<title>How to Convert a Stereo File to Play Only One Channel through Both Sides</title>
			<link>/posts/2010-07-18-how-convert-stereo-file-play-only-one-channel-through-both-sides/</link>
			<pubDate>Sun, 18 Jul 2010 17:54:31 +0000</pubDate>
			
			<guid>/posts/2010-07-18-how-convert-stereo-file-play-only-one-channel-through-both-sides/</guid>
			<description>Sometimes it&amp;rsquo;s necessary to completely mask out one of the stereo channels of a file and have that channel be output on both sides. For example, if you have a file, stereo.mp3, but want to hear only the left channel of the file through both sides of a headphone, use the following command:
mplayer stereo.mp3 -af pan=1:1:0
or try
mplayer stereo.mp3 -af pan=1:0:1
to hear only the right channel. Then, to convert the file permanently:</description>
			<content type="html"><![CDATA[

<p>Sometimes it&rsquo;s necessary to completely mask out one of the stereo channels of a file and have that channel be output on both sides.  For example, if you have a file, <code>stereo.mp3</code>, but want to hear only the left channel of the file through both sides of a headphone, use the following command:</p>

<p><code>mplayer stereo.mp3 -af pan=1:1:0</code></p>

<p>or try</p>

<p><code>mplayer stereo.mp3 -af pan=1:0:1</code></p>

<p>to hear only the right channel.  Then, to convert the file permanently:</p>

<p><code>mencoder stereo.mp3 -af pan=1:1:0 -oac copy -o mono.mp3</code></p>

<p>which will create a new file, <code>mono.mp3</code>, that will have only the left channel.  If the file has video, try this:</p>

<p><code>mencoder stereo.wmv -af pan=1:1:0 -oac mp3lame -ovc copy -o mono.wmv</code></p>

<p>Notice the <code>-oac mp3lame</code> option.  The <code>-af</code> options will be ignored with <code>-oac copy</code>.</p>

<p>Also, during the conversion, you may see a bunch of these messages:
<pre>
Pos: 522.3s  14486f (60%) 2110.43fps Trem:   0min  32mb  A-V:-0.002 [117:127]
71 duplicate frame(s)!
Pos: 522.3s  14487f (60%) 2110.27fps Trem:   0min  32mb  A-V:0.001 [117:127]
30 duplicate frame(s)!
Pos: 522.4s  14488f (60%) 2110.42fps Trem:   0min  32mb  A-V:-0.000 [117:127]
31 duplicate frame(s)!
Pos: 522.4s  14489f (60%) 2110.56fps Trem:   0min  32mb  A-V:-0.001 [117:127]
</pre></p>

<p>These messages will not prevent the conversion from completion.  Just let the file finish and it should play.</p>

<h1 id="note">Note</h1>

<p>Sometimes a <code>:</code> is used instead of an <code>=</code>.  For example <code>pan:1:1:0</code> instead of <code>pan=1:1:0</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>How to Dub and Audio File into a Video using Mplayer</title>
			<link>/posts/2010-07-18-how-dub-and-audio-file-video-using-mplayer/</link>
			<pubDate>Sun, 18 Jul 2010 17:30:42 +0000</pubDate>
			
			<guid>/posts/2010-07-18-how-dub-and-audio-file-video-using-mplayer/</guid>
			<description>If you have a video that you want to change the audio with a given mp3, try this command:
mencoder original.wmv -oac copy -ovc copy -audiofile dub.mp3 -o new.wmv
where: |file|description| |&amp;mdash;|&amp;mdash;| |original.wmv|The original video to dub.| |dub.mp3|An audio file with the new audio. This file should be the same length as the video.| |new.wmv|The final video that is created.|
There will likely be a lot of messages that look like this:  Pos: 522.</description>
			<content type="html"><![CDATA[<p>If you have a video that you want to change the audio with a given mp3, try this command:</p>

<p><code>mencoder original.wmv -oac copy -ovc copy -audiofile dub.mp3 -o new.wmv</code></p>

<p>where:
|file|description|
|&mdash;|&mdash;|
|original.wmv|The original video to dub.|
|dub.mp3|An audio file with the new audio.  This file should be the same length as the video.|
|new.wmv|The final video that is created.|</p>

<p>There will likely be a lot of messages that look like this:
<pre>
Pos: 522.3s  14486f (60%) 2110.43fps Trem:   0min  32mb  A-V:-0.002 [117:127]
71 duplicate frame(s)!
Pos: 522.3s  14487f (60%) 2110.27fps Trem:   0min  32mb  A-V:0.001 [117:127]
30 duplicate frame(s)!
Pos: 522.4s  14488f (60%) 2110.42fps Trem:   0min  32mb  A-V:-0.000 [117:127]
31 duplicate frame(s)!
Pos: 522.4s  14489f (60%) 2110.56fps Trem:   0min  32mb  A-V:-0.001 [117:127]
</pre></p>

<p>These are just warnings, about something that will not prevent the conversion from completion.  There may be thousands of these lines, but the conversion will eventually complete.  Be patient.</p>
]]></content>
		</item>
		
		<item>
			<title>How to Add a User to a Group in Linux</title>
			<link>/posts/2010-07-16-how-add-user-group-linux/</link>
			<pubDate>Fri, 16 Jul 2010 15:17:11 +0000</pubDate>
			
			<guid>/posts/2010-07-16-how-add-user-group-linux/</guid>
			<description>Simply type this:
usermod -a -G GROUP USER
or
gpasswd -a USER GROUP
Where USER is the user you want to add and GROUP is the group the user will now be a member. If you are currently logged in as USER, Login again for the new changes to take effect. Then, verify with:
id
It should look something like:  uid=10777(user) gid=16875(group1) groups=127(group2),16839(group3) context=&amp;hellip;</description>
			<content type="html"><![CDATA[<p>Simply type this:</p>

<p><code>usermod -a -G GROUP USER</code></p>

<p>or</p>

<p><code>gpasswd -a USER GROUP</code></p>

<p>Where <code>USER</code> is the user you want to add and <code>GROUP</code> is the group the user will now be a member.  If you are currently logged in as <code>USER</code>,  Login again for the new changes to take effect.  Then, verify with:</p>

<p><code>id</code></p>

<p>It should look something like:
<pre>
uid=10777(user) gid=16875(group1) groups=127(group2),16839(group3) context=&hellip;
</pre></p>
]]></content>
		</item>
		
		<item>
			<title>MySQL Default Data Directory on Windows 7</title>
			<link>/posts/2010-07-16-mysql-default-data-directory-windows-7/</link>
			<pubDate>Fri, 16 Jul 2010 12:35:06 +0000</pubDate>
			
			<guid>/posts/2010-07-16-mysql-default-data-directory-windows-7/</guid>
			<description>The default data directory for MySQL in Windows 7 is: C:\ProgramData\MySQL\MySQL Server 5.1\data</description>
			<content type="html"><![CDATA[<p>The default data directory for MySQL in Windows 7 is:
<code>C:\ProgramData\MySQL\MySQL Server 5.1\data</code></p>
]]></content>
		</item>
		
		<item>
			<title>Partioning a MySQL Table by Date</title>
			<link>/posts/2010-07-15-partioning-mysql-table-date/</link>
			<pubDate>Thu, 15 Jul 2010 15:09:54 +0000</pubDate>
			
			<guid>/posts/2010-07-15-partioning-mysql-table-date/</guid>
			<description>Prerequisites It must be MySQL 5.1 or later. Then, to see if partitioning is available:
SHOW VARIABLES LIKE &amp;#39;%partition%&amp;#39;; or
SHOW PLUGINS; If neither of these queries mention partitions, be sure to recompile with the --with-partition option.
Setting up a table There are several types of partitions, but LIST seems most compatible with partitioning by date. Let&amp;rsquo;s setup a core table:
CREATE TABLE core( core_id INT NOT NULL AUTO_INCREMENT, stamp DATETIME, data VARCHAR(80), PRIMARY KEY(core_id,stamp) ) PARTITION BY LIST(TO_DAYS(stamp))( PARTITION core_20100715 VALUES IN (TO_DAYS(&amp;#39;2010-07-15&amp;#39;)), PARTITION core_20100716 VALUES IN (TO_DAYS(&amp;#39;2010-07-16&amp;#39;)) ); Notice that the primary key must include stamp or MySQL will give an error.</description>
			<content type="html"><![CDATA[

<h1 id="prerequisites">Prerequisites</h1>

<p>It must be MySQL 5.1 or later.  Then, to see if partitioning is available:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SHOW</span> <span class="n">VARIABLES</span> <span class="k">LIKE</span> <span class="s1">&#39;%partition%&#39;</span><span class="p">;</span></code></pre></div>
<p>or</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SHOW</span> <span class="n">PLUGINS</span><span class="p">;</span></code></pre></div>
<p>If neither of these queries mention partitions, be sure to recompile with the <code>--with-partition</code> option.</p>

<h1 id="setting-up-a-table">Setting up a table</h1>

<p>There are several types of partitions, but <code>LIST</code> seems most compatible with partitioning by date.  Let&rsquo;s setup a <code>core</code> table:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="nf">core</span><span class="p">(</span>
  <span class="n">core_id</span> <span class="kt">INT</span> <span class="k">NOT</span> <span class="no">NULL</span> <span class="kp">AUTO_INCREMENT</span><span class="p">,</span>
  <span class="n">stamp</span> <span class="kt">DATETIME</span><span class="p">,</span>
  <span class="n">data</span> <span class="kt">VARCHAR</span><span class="p">(</span><span class="mi">80</span><span class="p">),</span>
  <span class="k">PRIMARY</span> <span class="k">KEY</span><span class="p">(</span><span class="n">core_id</span><span class="p">,</span><span class="n">stamp</span><span class="p">)</span>
<span class="p">)</span>

<span class="n">PARTITION</span> <span class="k">BY</span> <span class="nf">LIST</span><span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="n">stamp</span><span class="p">))(</span>
  <span class="n">PARTITION</span> <span class="n">core_20100715</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-15&#39;</span><span class="p">)),</span>
  <span class="n">PARTITION</span> <span class="n">core_20100716</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-16&#39;</span><span class="p">))</span>
<span class="p">);</span></code></pre></div>
<p>Notice that the primary key must include <code>stamp</code> or MySQL will give an error.</p>

<h1 id="testing-the-partition">Testing the partition</h1>

<p>Now a simple insert:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">INSERT</span> <span class="k">INTO</span> <span class="nf">core</span> <span class="p">(</span><span class="n">stamp</span><span class="p">,</span><span class="n">data</span><span class="p">)</span> <span class="k">VALUES</span> <span class="p">(</span><span class="s1">&#39;20100715&#39;</span><span class="p">,</span><span class="s1">&#39;a&#39;</span><span class="p">)</span></code></pre></div>
<p>This should work.</p>

<p>Now a simple insert outside of the existing partitions:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">INSERT</span> <span class="k">INTO</span> <span class="nf">core</span> <span class="p">(</span><span class="n">stamp</span><span class="p">,</span><span class="n">data</span><span class="p">)</span> <span class="k">VALUES</span> <span class="p">(</span><span class="s1">&#39;20100717&#39;</span><span class="p">,</span><span class="s1">&#39;x&#39;</span><span class="p">)</span></code></pre></div>
<p>Gives this error:</p>

<p><code>SQL Error (1526): Table has no partition for value</code></p>

<h1 id="read-the-information-schema">Read the information_schema</h1>

<p>It&rsquo;s possible to see the existing partitions in the <code>information_schema</code> database:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="o">*</span>
<span class="k">FROM</span> <span class="n">information_schema</span><span class="p">.</span><span class="n">PARTITIONS</span>
<span class="k">WHERE</span> <span class="n">TABLE_NAME</span><span class="o">=</span><span class="s1">&#39;core&#39;</span><span class="p">;</span></code></pre></div>
<p>Which shows us:
<span class="scroll">
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | PARTITION_NAME | SUBPARTITION_NAME | PARTITION_ORDINAL_POSITION | SUBPARTITION_ORDINAL_POSITION | PARTITION_METHOD | SUBPARTITION_METHOD | PARTITION_EXPRESSION | SUBPARTITION_EXPRESSION | PARTITION_DESCRIPTION | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | CREATE_TIME | UPDATE_TIME | CHECK_TIME | CHECKSUM | PARTITION_COMMENT | NODEGROUP | TABLESPACE_NAME |
|&mdash;&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;|&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-|&mdash;&mdash;&mdash;&ndash;|&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;|
| NULL          | test         | core       | core_20100715  | NULL              |                          1 |                          NULL | LIST             | NULL                | TO_DAYS(stamp)  | NULL                    | 734333                |          0 |              0 |       16384 |            NULL |            0 |   4194304 | NULL        | NULL        | NULL       |     NULL |         | default   | NULL            |
| NULL          | test         | core       | core_20100716  | NULL              |                          2 |                          NULL | LIST             | NULL                | TO_DAYS(stamp)   | NULL                    | 734334                |          0 |              0 |       16384 |            NULL |            0 |   4194304 | NULL        | NULL        | NULL       |     NULL |          | default   | NULL            |</p>

<p></span></p>

<h1 id="adding-and-removing-individual-partitions">Adding and Removing Individual Partitions</h1>

<p>Here&rsquo;s how to add additional partitions:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">core</span>
<span class="k">ADD</span> <span class="nf">PARTITION</span> <span class="p">(</span><span class="n">PARTITION</span> <span class="n">core_20100717</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-17&#39;</span><span class="p">)));</span></code></pre></div>
<p>Here&rsquo;s how to remove a partition:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">core</span>
<span class="k">DROP</span> <span class="n">PARTITION</span> <span class="n">core_20100717</span><span class="p">;</span></code></pre></div>
<h1 id="adding-and-removing-partitioning-on-existing-tables">Adding and Removing Partitioning on Existing Tables</h1>

<p>If the table was not originally partitioned, it is possible to add it:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">core</span>
<span class="n">PARTITION</span> <span class="k">BY</span> <span class="nf">LIST</span><span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="n">stamp</span><span class="p">))(</span>
  <span class="n">PARTITION</span> <span class="n">core_20100715</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-15&#39;</span><span class="p">)),</span>
  <span class="n">PARTITION</span> <span class="n">core_20100716</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-16&#39;</span><span class="p">))</span>
<span class="p">);</span></code></pre></div>
<p>And remove it:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">core</span>
<span class="n">REMOVE</span> <span class="n">PARTITIONING</span><span class="p">;</span></code></pre></div>
<p>Adding and removing partitions doesn&rsquo;t seem to change existing data on the table, but new partitions must include all existing data.</p>

<h1 id="storing-a-partition-on-a-separate-directory">Storing a Partition on a Separate Directory</h1>

<p>Each partition may be stored on a separate data and index directory:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">ALTER</span> <span class="k">TABLE</span> <span class="n">core</span>
<span class="n">PARTITION</span> <span class="k">BY</span> <span class="nf">LIST</span><span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="n">stamp</span><span class="p">))(</span>
  <span class="n">PARTITION</span> <span class="n">p20100715</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-15&#39;</span><span class="p">))</span>
  <span class="n">DATA</span> <span class="n">DIRECTORY</span> <span class="s1">&#39;/data/2010-07-15&#39;</span>
  <span class="k">INDEX</span> <span class="n">DIRECTORY</span> <span class="s1">&#39;/data/2010-07-15&#39;</span><span class="p">,</span>
  <span class="n">PARTITION</span> <span class="n">p20100716</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-16&#39;</span><span class="p">))</span>
  <span class="n">DATA</span> <span class="n">DIRECTORY</span> <span class="s1">&#39;/data/2010-07-16&#39;</span>
  <span class="k">INDEX</span> <span class="n">DIRECTORY</span> <span class="s1">&#39;/data/2010-07-16&#39;</span>
<span class="p">);</span></code></pre></div>
<p>Note, <code>DATA DIRECTORY</code> and <code>INDEX DIRECTORY</code> <a href="http://bugs.mysql.com/bug.php?id=30459">are ignored on Windows after MySQL 5.1.24</a>.</p>

<p>You may get this error:
<code>SQL Error (1210): Incorrect arguments to DATA DIRECTORY</code></p>

<p>If so, it&rsquo;s likely because the <code>DATA DIRECTORY</code> is already being used by another part of MySQL.  The partition data directories can&rsquo;t be subdirectories of MySQL&rsquo;s current data directory.  The best thing to do is make a new directory maybe <code>mysql_part</code> that is easily accessible.</p>

<h1 id="partition-naming-between-tables">Partition Naming between Tables</h1>

<p>Different tables can use the same names for their partition.  Consider the following example:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="nf">core</span><span class="p">(</span>
  <span class="n">core_id</span> <span class="kt">INT</span> <span class="k">NOT</span> <span class="no">NULL</span> <span class="kp">AUTO_INCREMENT</span><span class="p">,</span>
  <span class="n">stamp</span> <span class="kt">DATETIME</span><span class="p">,</span>
  <span class="n">data</span> <span class="kt">VARCHAR</span><span class="p">(</span><span class="mi">80</span><span class="p">),</span>
  <span class="k">PRIMARY</span> <span class="k">KEY</span><span class="p">(</span><span class="n">core_id</span><span class="p">,</span><span class="n">stamp</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">PARTITION</span> <span class="k">BY</span> <span class="nf">LIST</span><span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="n">stamp</span><span class="p">))(</span>
  <span class="n">PARTITION</span> <span class="n">p20100715</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-15&#39;</span><span class="p">)),</span>
  <span class="n">PARTITION</span> <span class="n">p20100716</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-16&#39;</span><span class="p">))</span>
<span class="p">);</span>

<span class="k">CREATE</span> <span class="k">TABLE</span> <span class="nf">core2</span><span class="p">(</span>
  <span class="n">core_id</span> <span class="kt">INT</span> <span class="k">NOT</span> <span class="no">NULL</span> <span class="kp">AUTO_INCREMENT</span><span class="p">,</span>
  <span class="n">stamp</span> <span class="kt">DATETIME</span><span class="p">,</span>
  <span class="n">data</span> <span class="kt">VARCHAR</span><span class="p">(</span><span class="mi">80</span><span class="p">),</span>
  <span class="k">PRIMARY</span> <span class="k">KEY</span><span class="p">(</span><span class="n">core_id</span><span class="p">,</span><span class="n">stamp</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">PARTITION</span> <span class="k">BY</span> <span class="nf">LIST</span><span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="n">stamp</span><span class="p">))(</span>
  <span class="n">PARTITION</span> <span class="n">p20100715</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-15&#39;</span><span class="p">)),</span>
  <span class="n">PARTITION</span> <span class="n">p20100716</span> <span class="k">VALUES</span> <span class="k">IN</span> <span class="p">(</span><span class="nf">TO_DAYS</span><span class="p">(</span><span class="s1">&#39;2010-07-16&#39;</span><span class="p">))</span>
<span class="p">);</span></code></pre></div>
<p>Both tables use the exact same partition names:  <code>p20100715</code> and <code>p20100716</code>.  No error occurs.</p>

<h1 id="see-also">See also</h1>

<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/partitioning.html">MySQL 5.1 Documentation: Partitioning</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/create-table.html">MySQL 5.1 Documentation: CREATE TABLE</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/alter-table.html">MySQL 5.1 Documentation: ALTER TABLE</a></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Connecting to a TCP port using mysql</title>
			<link>/posts/2010-07-13-connecting-tcp-port-using-mysql/</link>
			<pubDate>Tue, 13 Jul 2010 13:26:34 +0000</pubDate>
			
			<guid>/posts/2010-07-13-connecting-tcp-port-using-mysql/</guid>
			<description>Simple Answer Use -h127.0.0.1 instead of -hlocalhost when invoking mysql.
Details When typing mysql on the command-line, by default it connects to a socket. This also happens when typing mysql -hlocalhost. It even happens when specifying a TCP port number mysql -hlocalhost -P3306. Simply type \s to see what server mysql is connected to. Here&amp;rsquo;s an example:  $ mysql -hlocalhost -P3306 Welcome to the MySQL monitor. Commands end with ; or \g.</description>
			<content type="html"><![CDATA[

<h1 id="simple-answer">Simple Answer</h1>

<p>Use <code>-h127.0.0.1</code> instead of <code>-hlocalhost</code> when invoking <code>mysql</code>.</p>

<h1 id="details">Details</h1>

<p>When typing <code>mysql</code> on the command-line, by default it connects to a socket.  This also happens when typing <code>mysql -hlocalhost</code>.  It even happens when specifying a TCP port number <code>mysql -hlocalhost -P3306</code>.  Simply type <code>\s</code> to see what server <code>mysql</code> is connected to.  Here&rsquo;s an example:
<pre>
$ mysql -hlocalhost -P3306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution</p>

<p>Type &lsquo;help;&rsquo; or &lsquo;\h&rsquo; for help. Type &lsquo;\c&rsquo; to clear the buffer.</p>

<h2 id="mysql-s">mysql&gt; \s</h2>

<p>mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1</p>

<p>Connection id:          1
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          &ldquo;
Using delimiter:        ;
Server version:         5.0.77 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 55 days 2 hours 20 min 48 sec</p>

<p>Threads: 2  Questions: 188848126  Slow queries: 1  Opens: 247  Flush tables: 1  Open tables: 64  Queries per second avg: 39.670
</pre></p>

<p>The <code>Connection</code> field shows that we are indeed connected to a UNIX socket.  However, if we type the dotted-decimal, it is connected to a TCP port:
<pre>
$ mysql -h127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.77 Source distribution</p>

<p>Type &lsquo;help;&rsquo; or &lsquo;\h&rsquo; for help. Type &lsquo;\c&rsquo; to clear the buffer.</p>

<h2 id="mysql-s-1">mysql&gt; \s</h2>

<p>mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1</p>

<p>Connection id:          12
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          &ldquo;
Using delimiter:        ;
Server version:         5.0.77 Source distribution
Protocol version:       10
Connection:             127.0.0.1 via TCP/IP
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
TCP port:               3306
Uptime:                 55 days 2 hours 24 min 45 sec</p>

<h2 id="threads-2-questions-188848139-slow-queries-1-opens-247-flush-tables-1-open-tables-64-queries-per-second-avg-39-668">Threads: 2  Questions: 188848139  Slow queries: 1  Opens: 247  Flush tables: 1  Open tables: 64  Queries per second avg: 39.668</h2>

<p></pre>
Notice that the <code>Connection</code> now says <code>127.0.0.1 via TCP/IP</code>.</p>
]]></content>
		</item>
		
		<item>
			<title>How to use .my.cnf files for MySQL</title>
			<link>/posts/2010-07-13-how-use-mycnf-files-mysql/</link>
			<pubDate>Tue, 13 Jul 2010 13:06:18 +0000</pubDate>
			
			<guid>/posts/2010-07-13-how-use-mycnf-files-mysql/</guid>
			<description>Introduction The .my.cnf file tells the mysql command-line utility how to connect to a MySQL database. It is typically stored in the home directory of the current user. Here&amp;rsquo;s a sample file:
[mysql] # Set a larger maximum packet size for the client max_allowed_packet=512M user=root password=my_secret!p@sswordIsVerylong#  Notice the plaintext password is in the file. It&amp;rsquo;s a good idea to set read-write privileges only for the user (ie chmod 600).</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>The <code>.my.cnf</code> file tells the <code>mysql</code> command-line utility how to connect to a MySQL database.  It is typically stored in the home directory of the current user.  Here&rsquo;s a sample file:</p>

<pre><code>[mysql]
# Set a larger maximum packet size for the client
max_allowed_packet=512M
user=root
password=my_secret!p@sswordIsVerylong#
</code></pre>

<p>Notice the plaintext password is in the file.   It&rsquo;s a good idea to set read-write privileges only for the user (ie <code>chmod 600</code>).  Now the user should be able to simply type <code>mysql</code> at a command-line and the MySQL monitor should automatically connect to the database.</p>

<h1 id="if-it-does-not-work">If it does not work</h1>

<p>The following command may not work:
<code>sudo mysql</code></p>

<p>Why?  Well, try this:
<code>sudo strace mysql 2&gt;&amp;1|grep open</code></p>

<p>And you will probably get something like:</p>

<pre><code>open(&quot;/etc/ld.so.cache&quot;, O_RDONLY)      = 3
open(&quot;/usr/lib64/libncursesw.so.5&quot;, O_RDONLY) = 3
open(&quot;/lib64/libpthread.so.0&quot;, O_RDONLY) = 3
open(&quot;/lib64/libcrypt.so.1&quot;, O_RDONLY)  = 3
open(&quot;/lib64/libnsl.so.1&quot;, O_RDONLY)    = 3
open(&quot;/lib64/libm.so.6&quot;, O_RDONLY)      = 3
open(&quot;/lib64/libc.so.6&quot;, O_RDONLY)      = 3
open(&quot;/lib64/libdl.so.2&quot;, O_RDONLY)     = 3
open(&quot;/home/user/.my.cnf&quot;, O_RDONLY)  = -1 EACCES (Permission denied)
open(&quot;/etc/nsswitch.conf&quot;, O_RDONLY)    = 3
open(&quot;/etc/ld.so.cache&quot;, O_RDONLY)      = 3
open(&quot;/lib64/libnss_files.so.2&quot;, O_RDONLY) = 3
open(&quot;/etc/services&quot;, O_RDONLY)         = 3
open(&quot;/usr/share/mysql/charsets/Index.xml&quot;, O_RDONLY) = 4
</code></pre>

<p>Notice the <code>EACCES</code> line?  That means that <code>user</code>&rsquo;s <code>.my.cnf</code> file could not be read by root.  This can happen if you secured the system properly.  So, how do we get <code>sudo</code> to look at <code>/root/.my.cnf</code>?</p>

<p><code>sudo -H strace mysql 2&gt;&amp;1|grep open</code></p>

<p>Instead of an <code>EACCES</code> line, it should have something like:</p>

<p><code>open(&quot;/root/.my.cnf&quot;, O_RDONLY)         = 3</code></p>

<p>Of course, the <code>grep</code> hides some important details and <code>strace</code> gives us details we no longer need, so just type this:</p>

<p><code>sudo -H mysql</code></p>
]]></content>
		</item>
		
		<item>
			<title>Floating Point Rounding Issues</title>
			<link>/posts/2010-07-12-floating-point-rounding-issues/</link>
			<pubDate>Mon, 12 Jul 2010 18:59:23 +0000</pubDate>
			
			<guid>/posts/2010-07-12-floating-point-rounding-issues/</guid>
			<description>Perl Consider the following program:
$x=12345678901.234567000; $y=($x-int($x))*1000000000; printf(&amp;#34;%f-&amp;gt;%f\n&amp;#34;,$x,$y); Here&amp;rsquo;s what it prints:
12345678901.234568-&amp;gt;234567642.211914
I was expecting:
12345678901.234567-&amp;gt;234567000
This appears to be some sort of rounding issue in Perl. Adding a new package seems to help:
use bignum; $x=12345678901.234567000; $y=($x-int($x))*1000000000; printf(&amp;#34;%f-&amp;gt;%f\n&amp;#34;,$x,$y); print $x; prints:  12345678901.234568-&amp;gt;234567000 12345678901.234567 
Notice how the second line is correct. The variable is fine, but printf is having some issues.
Note that if the variable is being converted from a string there are still issues.</description>
			<content type="html"><![CDATA[

<h1 id="perl">Perl</h1>

<p>Consider the following program:</p>
<div class="highlight"><pre class="chroma"><code class="language-perl" data-lang="perl"><span class="nv">$x</span><span class="o">=</span><span class="mf">12345678901.234567000</span><span class="p">;</span>
<span class="nv">$y</span><span class="o">=</span><span class="p">(</span><span class="nv">$x</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="nv">$x</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span>
<span class="nb">printf</span><span class="p">(</span><span class="s">&#34;%f-&gt;%f\n&#34;</span><span class="p">,</span><span class="nv">$x</span><span class="p">,</span><span class="nv">$y</span><span class="p">);</span></code></pre></div>
<p>Here&rsquo;s what it prints:</p>

<p><code>12345678901.234568-&gt;234567642.211914</code></p>

<p>I was expecting:</p>

<p><code>12345678901.234567-&gt;234567000</code></p>

<p>This appears to be some sort of rounding issue in Perl.  Adding a new package seems to help:</p>
<div class="highlight"><pre class="chroma"><code class="language-perl" data-lang="perl"><span class="k">use</span> <span class="nn">bignum</span><span class="p">;</span>
<span class="nv">$x</span><span class="o">=</span><span class="mf">12345678901.234567000</span><span class="p">;</span>
<span class="nv">$y</span><span class="o">=</span><span class="p">(</span><span class="nv">$x</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="nv">$x</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span>
<span class="nb">printf</span><span class="p">(</span><span class="s">&#34;%f-&gt;%f\n&#34;</span><span class="p">,</span><span class="nv">$x</span><span class="p">,</span><span class="nv">$y</span><span class="p">);</span>
<span class="k">print</span> <span class="nv">$x</span><span class="p">;</span></code></pre></div>
<p>prints:
<pre>
12345678901.234568-&gt;234567000
12345678901.234567
</pre></p>

<p>Notice how the second line is correct.  The variable is fine, but <code>printf</code> is having some issues.</p>

<p>Note that if the variable is being converted from a string there are still issues.  Consider the following:</p>
<div class="highlight"><pre class="chroma"><code class="language-perl" data-lang="perl"><span class="k">use</span> <span class="nn">bignum</span><span class="p">;</span>
<span class="nv">$x</span><span class="o">=</span><span class="s">&#34;12345678901-&gt;234567000&#34;</span><span class="p">;</span>
<span class="nv">$y</span><span class="o">=</span><span class="p">(</span><span class="nv">$x</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="nv">$x</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span>
<span class="nb">printf</span><span class="p">(</span><span class="s">&#34;%f:%f\n&#34;</span><span class="p">,</span><span class="nv">$x</span><span class="p">,</span><span class="nv">$y</span><span class="p">);</span></code></pre></div>
<p>prints:
<pre>
12345678901.234568-&gt;234567642.211914
</pre></p>

<p>So use <code>+0</code> to cast to a number:</p>
<div class="highlight"><pre class="chroma"><code class="language-perl" data-lang="perl"><span class="nv">$x</span><span class="o">=</span><span class="s">&#34;12345678901.234567000&#34;</span><span class="p">;</span>
<span class="nv">$x</span><span class="o">+=</span><span class="mi">0</span><span class="p">;</span><span class="c1"># Cast to a number</span>
<span class="nv">$y</span><span class="o">=</span><span class="p">(</span><span class="nv">$x</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="nv">$x</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span>
<span class="nb">printf</span><span class="p">(</span><span class="s">&#34;%f-&gt;%f\n&#34;</span><span class="p">,</span><span class="nv">$x</span><span class="p">,</span><span class="nv">$y</span><span class="p">);</span></code></pre></div>
<p>prints:
<pre>
12345678901.234568-&gt;234567000.000000
</pre></p>

<h1 id="mysql">MySQL</h1>

<p>The same rounding issue also appears in MySQL.  Consider the following:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="o">-</span><span class="nf">FLOOR</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>234567642.211914</code></p>

<p>Take off the single quotes and all is well:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="p">(</span><span class="mi">12345678901</span><span class="p">.</span><span class="mi">234567</span><span class="o">-</span><span class="nf">FLOOR</span><span class="p">(</span><span class="mi">12345678901</span><span class="p">.</span><span class="mi">234567</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>234567000.000000</code></p>

<p>It appears that the string to number conversion is broken in MySQL, so you have to define it explicitly.  Unfortunately, you can&rsquo;t just cast to a double:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">double</span><span class="p">)</span><span class="o">-</span><span class="nf">FLOOR</span><span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">double</span><span class="p">)))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>SQL Error (1064): You have an error in your SQL syntax;</code></p>

<p>So, it&rsquo;s necessary to use a decimal, but that fails too:</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">decimal</span><span class="p">)</span><span class="o">-</span><span class="nf">FLOOR</span><span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">decimal</span><span class="p">)))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>SQL Error (1064): You have an error in your SQL syntax;</code></p>

<p>Nice.  Well, I guess I need to specify the width explicitly.</p>
<div class="highlight"><pre class="chroma"><code class="language-mysql" data-lang="mysql"><span class="k">SELECT</span> <span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">decimal</span><span class="p">(</span><span class="mi">65</span><span class="p">,</span><span class="mi">30</span><span class="p">))</span><span class="o">-</span><span class="nf">FLOOR</span><span class="p">(</span><span class="nf">CAST</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span> <span class="k">as</span> <span class="kt">decimal</span><span class="p">(</span><span class="mi">65</span><span class="p">,</span><span class="mi">30</span><span class="p">))))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>234567000.000000000000000000000000000000</code></p>

<h1 id="postgresql">PostgreSQL</h1>

<p>The same thing happens in PostgreSQL:</p>
<div class="highlight"><pre class="chroma"><code class="language-SQL" data-lang="SQL"><span class="k">SELECT</span> <span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="o">-</span><span class="n">FLOOR</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>234567642.211914</code></p>

<p>And with float casts:</p>
<div class="highlight"><pre class="chroma"><code class="language-SQL" data-lang="SQL"><span class="k">SELECT</span> <span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">::</span><span class="nb">float</span><span class="o">-</span><span class="n">FLOOR</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">::</span><span class="nb">float</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p>prints:</p>

<p><code>234567642.211914</code></p>

<p>But, decimal works:</p>
<div class="highlight"><pre class="chroma"><code class="language-SQL" data-lang="SQL"><span class="k">SELECT</span> <span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">::</span><span class="nb">decimal</span><span class="o">-</span><span class="n">FLOOR</span><span class="p">(</span><span class="s1">&#39;12345678901.234567&#39;</span><span class="p">::</span><span class="nb">decimal</span><span class="p">))</span><span class="o">*</span><span class="mi">1000000000</span><span class="p">;</span></code></pre></div>
<p><code>234567000</code></p>
]]></content>
		</item>
		
		<item>
			<title>Connecting to MySQL Remotely from Windows or Linux with SSH</title>
			<link>/posts/2010-07-12-connecting-mysql-remotely-windows-or-linux-ssh/</link>
			<pubDate>Mon, 12 Jul 2010 17:50:03 +0000</pubDate>
			
			<guid>/posts/2010-07-12-connecting-mysql-remotely-windows-or-linux-ssh/</guid>
			<description>Local Tunnels Connecting to MySQL in plaintext is dangerous. Also, leaving port 3306 open your server is not very safe. If the MySQL server has an SSH port open, it&amp;rsquo;s possible to use it for MySQL queries. Simply open a bash prompt on Cygwin and type:
ssh -N -L 5000:localhost:3306 your-server &amp;amp; Of course, replace your-server with the machine name of the MySQL server. Now, it&amp;rsquo;s possible to connect to the MySQL database using 127.</description>
			<content type="html"><![CDATA[

<h1 id="local-tunnels">Local Tunnels</h1>

<p>Connecting to MySQL in plaintext is dangerous.  Also, leaving port 3306 open your server is not very safe.  If the MySQL server has an SSH port open, it&rsquo;s possible to use it for MySQL queries.  Simply open a bash prompt on Cygwin and type:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">ssh -N -L <span class="m">5000</span>:localhost:3306 your-server <span class="p">&amp;</span></code></pre></div>
<p>Of course, replace <code>your-server</code> with the machine name of the MySQL server.  Now, it&rsquo;s possible to connect to the MySQL database using 127.0.0.1:5000.  Sounds strange, but port 5000 on your machine is now MySQL on the remote machine.  It&rsquo;s called a tunnel and it&rsquo;s a great way to get around needing to make holes in your firewall.  It also has the benefit of being encrypted.  This should work in Linux and Cygwin (windows).</p>

<h1 id="reverse-tunnels">Reverse Tunnels</h1>

<p>It&rsquo;s also possible to send traffic on your remote webserver to your local machine.  It looks something like this:</p>
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">ssh -N -R <span class="m">5000</span>:localhost:3306 your-server <span class="p">&amp;</span></code></pre></div>
<p>After this command, anything going to your-server&rsquo;s port 5000 will be sent to 3306 on the local machine.</p>

<h1 id="verfication-and-destruction">Verfication and Destruction</h1>

<p>To verify the port is open, type <code>lsof -i</code> in Linux or <code>netstat -a|grep LISTENING|grep 5000</code> in Cygwin.  These commands will give you a process id number (pid).  Just type <code>kill &lt;pid&gt;</code> to end the connection.  For example <code>kill 1234</code> stops pid 1234.</p>
]]></content>
		</item>
		
		<item>
			<title>Un-add in Subversion</title>
			<link>/posts/2010-07-11-un-add-subversion/</link>
			<pubDate>Sun, 11 Jul 2010 00:07:04 +0000</pubDate>
			
			<guid>/posts/2010-07-11-un-add-subversion/</guid>
			<description>When doing a: svn add *
Everything in the directory is added. Then, trying to remove before my next check-in fails: svn remove myfile.exe
However, this worked: svn revert myfile.exe</description>
			<content type="html"><![CDATA[<p>When doing a:
<code>svn add *</code></p>

<p>Everything in the directory is added.  Then, trying to remove before my next check-in fails: <code>svn remove myfile.exe</code></p>

<p>However, this worked: <code>svn revert myfile.exe</code></p>
]]></content>
		</item>
		
		<item>
			<title>Using asynchronous sockets in C#</title>
			<link>/posts/2010-07-10-using-asynchronous-sockets-c/</link>
			<pubDate>Sat, 10 Jul 2010 19:24:37 +0000</pubDate>
			
			<guid>/posts/2010-07-10-using-asynchronous-sockets-c/</guid>
			<description>How to have a listener for a socket in C#:
 Use System.Net.Sockets TcpListener listener=new TcpListener(System.Net.IPAddress.Parse(&amp;quot;0.0.0.0&amp;quot;),2000); Create the following callback:
protected void DoAcceptCallback(IAsyncResult ar){ TcpListener tl = (TcpListener)ar.AsyncState; Socket s = tl.EndAcceptSocket(ar); //Log the traffic DataRow dr=traffic.NewRow(); dr[&amp;#34;ID&amp;#34;] = 0; dr[&amp;#34;RemoteIP&amp;#34;] = s.RemoteEndPoint.ToString(); traffic.Rows.Add(dr); s.Close(); }   </description>
			<content type="html"><![CDATA[<p>How to have a listener for a socket in C#:</p>

<ul>
<li>Use System.Net.Sockets</li>
<li><code>TcpListener listener=new TcpListener(System.Net.IPAddress.Parse(&quot;0.0.0.0&quot;),2000);</code></li>

<li><p>Create the following callback:</p>
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">protected</span> <span class="k">void</span> <span class="n">DoAcceptCallback</span><span class="p">(</span><span class="n">IAsyncResult</span> <span class="n">ar</span><span class="p">){</span>
<span class="n">TcpListener</span> <span class="n">tl</span> <span class="p">=</span> <span class="p">(</span><span class="n">TcpListener</span><span class="p">)</span><span class="n">ar</span><span class="p">.</span><span class="n">AsyncState</span><span class="p">;</span>
<span class="n">Socket</span> <span class="n">s</span> <span class="p">=</span> <span class="n">tl</span><span class="p">.</span><span class="n">EndAcceptSocket</span><span class="p">(</span><span class="n">ar</span><span class="p">);</span>
 
<span class="c1">//Log the traffic
</span><span class="c1"></span><span class="n">DataRow</span> <span class="n">dr</span><span class="p">=</span><span class="n">traffic</span><span class="p">.</span><span class="n">NewRow</span><span class="p">();</span>
<span class="n">dr</span><span class="p">[</span><span class="s">&#34;ID&#34;</span><span class="p">]</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span>
<span class="n">dr</span><span class="p">[</span><span class="s">&#34;RemoteIP&#34;</span><span class="p">]</span> <span class="p">=</span> <span class="n">s</span><span class="p">.</span><span class="n">RemoteEndPoint</span><span class="p">.</span><span class="n">ToString</span><span class="p">();</span>
<span class="n">traffic</span><span class="p">.</span><span class="n">Rows</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="n">dr</span><span class="p">);</span>
 
<span class="n">s</span><span class="p">.</span><span class="n">Close</span><span class="p">();</span>
<span class="p">}</span>
</code></pre></div></li>
</ul>
]]></content>
		</item>
		
		<item>
			<title>Hiding Teasers in Drupal</title>
			<link>/posts/2010-07-10-hiding-teasers-drupal/</link>
			<pubDate>Sat, 10 Jul 2010 14:32:01 +0000</pubDate>
			
			<guid>/posts/2010-07-10-hiding-teasers-drupal/</guid>
			<description>A teaser is a small preview of a Drupal post. When clicking on a tag on a post, a list of other posts with that tag is shown by default. For some reason, Drupal designers decided to show the first part of the content with each article, but not the full article. I like the idea of just showing a list of links. Here&amp;rsquo;s how:
By default, teasers are enabled and there is not a simple WebUI way to remove these.</description>
			<content type="html"><![CDATA[<p>A teaser is a small preview of a Drupal post.  When clicking on a tag on a post, a list of other posts with that tag is shown by default.  For some reason, Drupal designers decided to show the first part of the content with each article, but not the full article.  I like the idea of just showing a list of links.  Here&rsquo;s how:</p>

<p>By default, teasers are enabled and there is not a simple WebUI way to remove these.  There are two things you can do:
1.  Make sure the preview of each node is blank, or
2.  Change the template.</p>

<p>To change the template, open a file at: <code>themes/bluemarine/node.tpl.php</code> and find the following line:</p>
<div class="highlight"><pre class="chroma"><code class="language-html" data-lang="html"><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;content&#34;</span><span class="p">&gt;</span><span class="cp">&lt;?php print $content?&gt;</span><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span></code></pre></div>
<p>And change it to:</p>
<div class="highlight"><pre class="chroma"><code class="language-html" data-lang="html">`<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&#34;content&#34;</span><span class="p">&gt;</span><span class="cp">&lt;?php if (!$teaser) print $content?&gt;</span><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>`</code></pre></div>]]></content>
		</item>
		
		<item>
			<title>Reading EventViewer from the Command-Line</title>
			<link>/posts/2010-07-09-reading-eventviewer-command-line/</link>
			<pubDate>Fri, 09 Jul 2010 15:46:26 +0000</pubDate>
			
			<guid>/posts/2010-07-09-reading-eventviewer-command-line/</guid>
			<description>Using wmic The wmic NTEVENT command can be used to dump out the contents of EventViewer logs to the command-line. Here&amp;rsquo;s an example: wmic NTEVENT WHERE &amp;quot;LogFile=&#39;security&#39; AND TimeGenerated &amp;gt; &#39;20100709173000.000000-300&#39;&amp;quot;
The TimeGenerated is NOT epoch, but is a string in the form of YYYYMMDDHHmmSS.uuuuuu-ZZZ where:
   Label Meaning     Y Year   M Month   D Day   H Hour   m Minute   S Second   u Microsecond   - Literally, a -   Z Timezone offset in minutes from UTC (not hours)    It&amp;rsquo;s also possible to add a GET to the query like so: wmic NTEVENT WHERE &amp;quot;LogFile=&#39;security&#39; AND TimeGenerated &amp;gt; &#39;20100709173000.</description>
			<content type="html"><![CDATA[

<h1 id="using-wmic">Using wmic</h1>

<p>The <code>wmic NTEVENT</code> command can be used to dump out the contents of EventViewer logs to the command-line.  Here&rsquo;s an example:
<code>wmic NTEVENT WHERE &quot;LogFile='security' AND TimeGenerated &gt; '20100709173000.000000-300'&quot;</code></p>

<p>The <code>TimeGenerated</code> is NOT epoch, but is a string in the form of <code>YYYYMMDDHHmmSS.uuuuuu-ZZZ</code> where:</p>

<table>
<thead>
<tr>
<th>Label</th>
<th>Meaning</th>
</tr>
</thead>

<tbody>
<tr>
<td>Y</td>
<td>Year</td>
</tr>

<tr>
<td>M</td>
<td>Month</td>
</tr>

<tr>
<td>D</td>
<td>Day</td>
</tr>

<tr>
<td>H</td>
<td>Hour</td>
</tr>

<tr>
<td>m</td>
<td>Minute</td>
</tr>

<tr>
<td>S</td>
<td>Second</td>
</tr>

<tr>
<td>u</td>
<td>Microsecond</td>
</tr>

<tr>
<td>-</td>
<td>Literally, a -</td>
</tr>

<tr>
<td>Z</td>
<td>Timezone offset in minutes from UTC (not hours)</td>
</tr>
</tbody>
</table>

<p>It&rsquo;s also possible to add a <code>GET</code> to the query like so:
<code>wmic NTEVENT WHERE &quot;LogFile='security' AND TimeGenerated &gt; '20100709173000.000000-300'&quot; GET TimeGenerated</code></p>

<p>And here&rsquo;s how to output as a CSV file:
<code>wmic NTEVENT WHERE &quot;LogFile='security' AND TimeGenerated &gt; '20100709173000.000000-300'&quot; GET TimeGenerated,User /format:csv</code></p>

<p>See also:</p>

<ul>
<li><a href="http://technet.microsoft.com/en-us/library/cc784189%28WS.10%29.aspx">http://technet.microsoft.com/en-us/library/cc784189%28WS.10%29.aspx</a></li>
<li><a href="http://xinn.org/misc-scripts/wmic.txt">http://xinn.org/misc-scripts/wmic.txt</a></li>
</ul>

<p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=6430f853-1120-48db-8cc5-f2abdc3ed314&amp;displaylang=en">WMITools.exe</a> can do a lot of this stuff, but practically locks up my system.</p>

<h1 id="using-microsoft-log-parser">Using Microsoft Log Parser</h1>

<p>Microsoft has a tool called <a href="http://www.microsoft.com/downloads/details.aspx?familyid=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en">Log Parser</a> that can can also parse the event logs.</p>
]]></content>
		</item>
		
		<item>
			<title>My .bashrc file for cygwin</title>
			<link>/posts/2010-07-09-my-bashrc-file-cygwin/</link>
			<pubDate>Fri, 09 Jul 2010 12:56:26 +0000</pubDate>
			
			<guid>/posts/2010-07-09-my-bashrc-file-cygwin/</guid>
			<description> export SSH_AUTH_SOCK=/tmp/.ssh-socket ssh-add -l 2&amp;1 /dev/null if [ $? = 2 ]; then # Exit status 2 means couldn&#39;t connect to ssh-agent; start one now rm -r /tmp/.ssh-socket ssh-agent -a $SSH_AUTH_SOCK /tmp/.ssh-script . /tmp/.ssh-script echo $SSH_AGENT_PID /tmp/.ssh-agent-pid fi function kill-agent { pid=`cat /tmp/.ssh-agent-pid` kill $pid }  </description>
			<content type="html"><![CDATA[<pre>
export SSH_AUTH_SOCK=/tmp/.ssh-socket

ssh-add -l 2>&1 >/dev/null
if [ $? = 2 ]; then
# Exit status 2 means couldn't connect to ssh-agent; start one now
rm -r /tmp/.ssh-socket
ssh-agent -a $SSH_AUTH_SOCK >/tmp/.ssh-script
. /tmp/.ssh-script
echo $SSH_AGENT_PID >/tmp/.ssh-agent-pid
fi

function kill-agent {
pid=`cat /tmp/.ssh-agent-pid`
kill $pid
}
</pre>
]]></content>
		</item>
		
		<item>
			<title>My .emacs file</title>
			<link>/posts/2010-07-09-my-emacs-file/</link>
			<pubDate>Fri, 09 Jul 2010 12:54:15 +0000</pubDate>
			
			<guid>/posts/2010-07-09-my-emacs-file/</guid>
			<description>Be sure to install color-theme in /usr/local/share/emacs/site-lisp or better yet, do a apt-get install emacs-goodies-el
;;Set the color theme (require &amp;#39;color-theme) ;;(color-theme-initialize) &amp;lt;-I don&amp;#39;t need this on newer versions and it will give an error. (color-theme-euphoria) ;;Ido (require &amp;#39;ido) (ido-mode t) (setq ido-enable-flex-matching t) ;; Dont show the GNU splash screen (setq inhibit-startup-message t) ;;Emacs Server (server-start) ;;tramp (require &amp;#39;tramp) (setq tramp-default-method &amp;#34;ssh&amp;#34;) (setq tramp-debug-buffer t) ;;Enable /sudo:ssh-host:file-on-ssh-host in tramp. (add-to-list &amp;#39;tramp-default-proxies-alist &amp;#39;(&amp;#34;.</description>
			<content type="html"><![CDATA[<p>Be sure to install <a href="http://download.savannah.gnu.org/releases-noredirect/color-theme/">color-theme</a> in <code>/usr/local/share/emacs/site-lisp</code> or better yet, do a <code>apt-get install emacs-goodies-el</code></p>
<div class="highlight"><pre class="chroma"><code class="language-lisp" data-lang="lisp"><span class="c1">;;Set the color theme</span>
<span class="p">(</span><span class="nf">require</span> <span class="ss">&#39;color-theme</span><span class="p">)</span>
<span class="c1">;;(color-theme-initialize) &lt;-I don&#39;t need this on newer versions and it will give an error.</span>
<span class="p">(</span><span class="nv">color-theme-euphoria</span><span class="p">)</span>

<span class="c1">;;Ido</span>
<span class="p">(</span><span class="nf">require</span> <span class="ss">&#39;ido</span><span class="p">)</span>
<span class="p">(</span><span class="nv">ido-mode</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">ido-enable-flex-matching</span> <span class="no">t</span><span class="p">)</span>

<span class="c1">;; Dont show the GNU splash screen</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">inhibit-startup-message</span> <span class="no">t</span><span class="p">)</span>

<span class="c1">;;Emacs Server</span>
<span class="p">(</span><span class="nv">server-start</span><span class="p">)</span>

<span class="c1">;;tramp</span>
<span class="p">(</span><span class="nf">require</span> <span class="ss">&#39;tramp</span><span class="p">)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">tramp-default-method</span> <span class="s">&#34;ssh&#34;</span><span class="p">)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">tramp-debug-buffer</span> <span class="no">t</span><span class="p">)</span>

<span class="c1">;;Enable /sudo:ssh-host:file-on-ssh-host in tramp.</span>
<span class="p">(</span><span class="nv">add-to-list</span> <span class="ss">&#39;tramp-default-proxies-alist</span> <span class="o">&#39;</span><span class="p">(</span><span class="s">&#34;.*&#34;</span> <span class="s">&#34;\\`root\\&#39;&#34;</span> <span class="s">&#34;/ssh:%h:&#34;</span><span class="p">))</span>

<span class="c1">;;Unix newlines</span>
<span class="p">(</span><span class="nv">prefer-coding-system</span> <span class="ss">&#39;latin-1-unix</span><span class="p">)</span>

<span class="c1">; Puts the file name and computer title on the top of the screen.</span>
<span class="p">(</span><span class="nv">set-default</span> <span class="ss">&#39;frame-title-format</span> <span class="p">(</span><span class="nc">list</span> <span class="s">&#34;&#34;</span> <span class="s">&#34;emacs&#34;</span> <span class="s">&#34;@&#34;</span> <span class="p">(</span><span class="nv">getenv</span> <span class="s">&#34;HOST&#34;</span><span class="p">)</span> <span class="s">&#34; : %f&#34;</span> <span class="p">))</span>

<span class="c1">; Keep the font size 9.5 points tall</span>
<span class="p">(</span><span class="nv">set-face-attribute</span> <span class="ss">&#39;default</span> <span class="no">nil</span> <span class="ss">:height</span> <span class="mi">95</span><span class="p">)</span>

<span class="c1">;Move the scroll bar</span>
<span class="p">(</span><span class="nv">set-scroll-bar-mode</span> <span class="ss">&#39;right</span><span class="p">)</span></code></pre></div>]]></content>
		</item>
		
		<item>
			<title>My .screenrc file</title>
			<link>/posts/2010-07-09-my-screenrc-file/</link>
			<pubDate>Fri, 09 Jul 2010 12:53:00 +0000</pubDate>
			
			<guid>/posts/2010-07-09-my-screenrc-file/</guid>
			<description>Here&amp;rsquo;s my .screenrc file:
 # Use C-t instead of C-a since C-a is used in bash for &#34;go to beginning of line.&#34; # first letter defines the screen command key. # second letter defines the literal insert key. escape ^Tt # Give 3000 lines of scrollback scrollback 3000 # Don&#39;t annoy me with the startup message for screen. startup_message off # Use 256 colors term screen-256color # Map some handy keys bindkey &#34;</description>
			<content type="html"><![CDATA[<p>Here&rsquo;s my <code>.screenrc</code> file:</p>

<pre>
# Use C-t instead of C-a since C-a is used in bash for "go to beginning of line."
# first letter defines the screen command key.
# second letter defines the literal insert key.
escape ^Tt

# Give 3000 lines of scrollback
scrollback 3000

# Don't annoy me with the startup message for screen.
startup_message off

# Use 256 colors
term screen-256color

# Map some handy keys
bindkey "^[[1;5D" prev  # change window with ctrl-left
bindkey "^[[1;5C" next  # change window with ctrl-right

# Setup the statusbar
hardstatus alwayslastline
hardstatus string '%{= kG}%-Lw%{= kW}%50> %n*%f %t%{= kG}%+Lw%< %{= kG}%-=%D %m/%d/%y | %C:%s %A | %1`%{-}'
</pre>

<p>Also an additional hint, to reload the .screenrc file do this:
<code>C-t : source $HOME/.screenrc</code></p>
]]></content>
		</item>
		
		<item>
			<title>How to have a Mode Line on GNU Screen</title>
			<link>/posts/2010-07-09-how-have-mode-line-gnu-screen/</link>
			<pubDate>Fri, 09 Jul 2010 12:51:23 +0000</pubDate>
			
			<guid>/posts/2010-07-09-how-have-mode-line-gnu-screen/</guid>
			<description>http://bbs.archlinux.org/viewtopic.php?id=55618&amp;amp;p=2</description>
			<content type="html"><![CDATA[<p><a href="http://bbs.archlinux.org/viewtopic.php?id=55618&amp;p=2">http://bbs.archlinux.org/viewtopic.php?id=55618&amp;p=2</a></p>
]]></content>
		</item>
		
		<item>
			<title>Create an image of a partition using OpenSource tools</title>
			<link>/posts/2010-07-08-create-image-partition-using-opensource-tools/</link>
			<pubDate>Thu, 08 Jul 2010 23:58:18 +0000</pubDate>
			
			<guid>/posts/2010-07-08-create-image-partition-using-opensource-tools/</guid>
			<description>Introduction This process will copy an entire partition to a file. It will not copy an entire disk to a file. The advantage is that you can change the size of the disk and it only copies the data, not the empty bits on the disk.
Prepare  Download SystemRescueCd and burn it to a CD. Have a ssh server available on your network. If networking is not an option, consider connecting the disk to a system that can do the backup.</description>
			<content type="html"><![CDATA[

<h1 id="introduction">Introduction</h1>

<p>This process will copy an entire partition to a file.  It will not copy an entire disk to a file.  The advantage is that you can change the size of the disk and it only copies the data, not the empty bits on the disk.</p>

<h1 id="prepare">Prepare</h1>

<ol>
<li>Download <a href="http://www.sysresccd.org/Main_Page">SystemRescueCd</a> and burn it to a CD.</li>
<li>Have a ssh server available on your network.</li>
<li>If networking is not an option, consider connecting the disk to a system that can do the backup.</li>
<li>On Windows machines, be sure to run <a href="http://kessels.com/jkdefrag/">JKDefrag</a>.</li>
<li>Especially for Windows, it seems to work best if the system shutdown was graceful.  Do not try this from a hibernated system or immediately after a crash unless it&rsquo;s the last resort.</li>
<li>BE CAREFUL!  Probably best not to use these tools for systems with critical data.  In such cases, just buy something more advanced.</li>
</ol>

<h1 id="make-the-image">Make the image:</h1>

<ol>
<li>Boot the source system with SystemRescueCd.</li>
<li>Enable the network. (<code>ifconfig eth0 x.y.z.1</code>)</li>
<li>Create a /mnt directory for the destination. (<code>mkdir /mnt/ssh</code>)</li>
<li><a href="http://www.sysresccd.org/Sysresccd-manual-en_Network">Mount ssh</a>.  I used <code>sshfs login@ssh.server.org:/path/to/dir /mnt/ssh</code></li>
<li>Identify the partitions <code>fsarchiver probe</code></li>
<li>Use <a href="http://www.fsarchiver.org/Cloning-ntfs">fsarchiver</a>.  I used <code>fsarchiver savefs -s 680 /mnt/ssh/test.fsa /dev/sda1</code> for CD.  I used a <code>-s 4470</code> for DVD&rsquo;s.
Note the .fsa extension.
Note:  process may max out for a long time but only write 243 bytes to the output file, but it will work eventually.</li>
<li>See also <a href="http://www.fsarchiver.org/QuickStart">http://www.fsarchiver.org/QuickStart</a></li>
</ol>

<h1 id="restore-the-image">Restore the image:</h1>

<ol>
<li>Boot the target system with SystemRescueCd.</li>
<li>Enable the network. <code>ifconfig eth0 x.y.z.1</code></li>
<li>Create a /mnt directory for the source.  Maybe <code>mkdir /mnt/ssh</code>.</li>
<li>Run <code>startx</code> to get into a UI.  Then use <code>gparted</code> to edit partitions.</li>
<li><a href="http://www.sysresccd.org/Sysresccd-manual-en_Network">Mount ssh</a>
I used <code>sshfs login@ssh.server.org:/path/to/dir /mnt/ssh</code></li>
<li>Identify the partitions <code>fsarchiver probe</code>.</li>
<li>Use <a href="http://www.fsarchiver.org/Cloning-ntfs">fsarchiver</a>
I used <code>fsarchiver restfs /mnt/ssh/disk.fsa id=0,dest=/dev/sda1,mkfs=reiserfs</code>
Note: this will automatically span files.</li>
<li>See also <a href="http://www.fsarchiver.org/QuickStart">http://www.fsarchiver.org/QuickStart</a></li>
</ol>
]]></content>
		</item>
		
	</channel>
</rss>
