<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>The Captain's Log</title>
	<link>http://jamie.homelinux.org</link>
	<description>Biometrics, Signal Processing, Photography and other stuff I'm interested in.</description>
	<pubDate>Sun, 15 Nov 2009 23:37:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>Bash using ruby for min and max</title>
		<link>http://jamie.homelinux.org/bash-using-ruby-for-min-and-max/</link>
		<comments>http://jamie.homelinux.org/bash-using-ruby-for-min-and-max/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 23:37:14 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[max]]></category>

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

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/bash-using-ruby-for-min-and-max/</guid>
		<description><![CDATA[
alias min='ruby -e "ARGF.select{&#124;e&#124; e =~ /^[+-]?d+[.]?d*/ }.map{&#124;e&#124; e.to_f }.min"'
alias max='ruby -e "ARGF.select{&#124;e&#124; e =~ /^[+-]?d+[.]?d*/ }.map{&#124;e&#124; e.to_f }.max"'

Then you can simply do 

[user@host]# echo "1" >> numbers.txt
[user@host]# echo "5" >> numbers.txt
[user@host]# cat numbers.txt &#124; min
1

]]></description>
			<content:encoded><![CDATA[<pre>
alias min='ruby -e "ARGF.select{|e| e =~ /^[+-]?d+[.]?d*/ }.map{|e| e.to_f }.min"'
alias max='ruby -e "ARGF.select{|e| e =~ /^[+-]?d+[.]?d*/ }.map{|e| e.to_f }.max"'
</pre>
<p>Then you can simply do </p>
<pre>
[user@host]# echo "1" >> numbers.txt
[user@host]# echo "5" >> numbers.txt
[user@host]# cat numbers.txt | min
1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/bash-using-ruby-for-min-and-max/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Changing the font in Windows command prompt</title>
		<link>http://jamie.homelinux.org/changing-the-font-in-windows-command-prompt/</link>
		<comments>http://jamie.homelinux.org/changing-the-font-in-windows-command-prompt/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 02:00:42 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[command prompt]]></category>

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/changing-the-font-in-windows-command-prompt/</guid>
		<description><![CDATA[Should be easy but it&#8217;s not&#8230; like some pretty basic things in windows this one actually requires a registry edit in order to use the fonts that are already installed on your system for your command prompt. 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
There you will see a string value (0 => &#8220;Lucida Console&#8221;) or something similar, to add your [...]]]></description>
			<content:encoded><![CDATA[<p>Should be easy but it&#8217;s not&#8230; like some pretty basic things in windows this one actually requires a registry edit in order to use the fonts that are already installed on your system for your command prompt. </p>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont</p>
<p>There you will see a string value (0 => &#8220;Lucida Console&#8221;) or something similar, to add your own fonts which will show up you have to add a new string value with the name of your required font (00 => &#8220;Consolas&#8221;). Subsequent fonts can be added at (000 => &#8220;someotherfont&#8221;) etc. I then had to do some dicking around to get the properties to stick on my command prompt shortcut but eventually I had a nice looking font for my command line hacking. Best of luck to you!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/changing-the-font-in-windows-command-prompt/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New PT assignment</title>
		<link>http://jamie.homelinux.org/new-pt-assignment/</link>
		<comments>http://jamie.homelinux.org/new-pt-assignment/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 23:47:25 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[assignment]]></category>

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/new-pt-assignment/</guid>
		<description><![CDATA[This one is for no one else but me  
model.assignment_parameters_override = {&#8221;pt_assignment_config&#8221; => &#8220;new&#8221;}.to_yaml
]]></description>
			<content:encoded><![CDATA[<p>This one is for no one else but me <img src='http://jamie.homelinux.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>model.assignment_parameters_override = {&#8221;pt_assignment_config&#8221; => &#8220;new&#8221;}.to_yaml</p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/new-pt-assignment/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Boost tokenize for the win</title>
		<link>http://jamie.homelinux.org/boost-tokenize-for-the-win/</link>
		<comments>http://jamie.homelinux.org/boost-tokenize-for-the-win/#comments</comments>
		<pubDate>Wed, 20 May 2009 22:00:28 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[tokenize]]></category>

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

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

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

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

		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://jamie.homelinux.org/boost-tokenize-for-the-win/</guid>
		<description><![CDATA[String manipulation has historically been a major shortfalling of the C++ language, or at least it was until boost came along. Something as simple as spliting a string up on a delimeter is now made so much easier thanks to the boost::tokenizer and boost string algorithms. 

#include &#60;iostream&#62;
#include &#60;string&#62;
#include &#60;boost/foreach.hpp&#62;
#include &#60;boost/tokenizer.hpp&#62;

using namespace std;
using namespace boost;

int [...]]]></description>
			<content:encoded><![CDATA[<p>String manipulation has historically been a major shortfalling of the C++ language, or at least it was until boost came along. Something as simple as spliting a string up on a delimeter is now made so much easier thanks to the boost::tokenizer and boost string algorithms. </p>
<pre>
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;boost/foreach.hpp&gt;
#include &lt;boost/tokenizer.hpp&gt;

using namespace std;
using namespace boost;

int main(int argc, char** argv)
{
   string text = "token, test   string";

   char_separator&lt;char&gt; sep(", ");
   tokenizer&lt;char_separator&lt;char&gt;&gt; tokens(text, sep);
   for (tokenizer&lt;char_separator&lt;char&gt; &gt;::iterator it = tokens.begin(); it != tokens.end(); ++it)
   {
      cout &lt;&lt; *it &lt;&lt; "." &lt;&lt; endl;
   }
}
</pre>
<p>And my personal favourite is to push the result of the tokenization into a vector/list/stl container. </p>
<pre>
#include <iostream>
#include <string>
#include
<list>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>

using namespace std;
using namespace boost;

int main(int argc, char** argv)
{
   string text = &#8220;token, test   string&#8221;;

   list<string> tokenList;
   split(tokenList, text, is_any_of(&#8221;, &#8220;), token_compress_on);
   (list<string>::iterator it = tokenList.begin(); it != tokenList.end(); ++it)
   {
      cout << *it << "." << endl;
   }
}
</pre>
<p>So awesome!</p>
<p>Stolen from <a href="http://the-lazy-programmer.com/blog/?p=28">the lazy programmer</a> and reposted here for my own reference.</char></char_separator></char></boost></boost></string></iostream></p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/boost-tokenize-for-the-win/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux fstab and UUIDs</title>
		<link>http://jamie.homelinux.org/linux-fstab-and-uuids/</link>
		<comments>http://jamie.homelinux.org/linux-fstab-and-uuids/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 23:59:57 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[uuid]]></category>

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

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/linux-fstab-and-uuids/</guid>
		<description><![CDATA[When I upgraded to Ubuntu Intrepid Ibex I installed it clean on a new harddrive that I installed alongside my old Hardy hard drive (that was totally unintentional - but hilarious). I then mounted the old hard drive, which was much bigger, via fstab so that I could have access to more storage and my [...]]]></description>
			<content:encoded><![CDATA[<p>When I upgraded to Ubuntu Intrepid Ibex I installed it clean on a new harddrive that I installed alongside my old Hardy hard drive (that was totally unintentional - but hilarious). I then mounted the old hard drive, which was much bigger, via fstab so that I could have access to more storage and my older files, but then a funny thing started happening&#8230; occasionally when booting the mount would fail and upon inspection it was because the hard drives labeling had been swapped around. One HD is SATA and the other older one is IDE, when I was setting things up the SATA drive was hda and the IDE was given hdb, the problem was that on subsequent boots this would be reversed !!! I&#8217;m not sure if this is a linux thing or a bios thing but either way it was screwing up my system so I needed a solution, thankfully this was very simple - all i had to do was find the UUID of the harddrive in question using one of the following two commands</p>
<pre><code>ls -las /dev/disk/by-uuid/</code></pre>
<pre><code>blkid /dev/hda1</code></pre>
<p>Then it was as simple as editing my /etc/fstab to replace the reference to /dev/hd[ab]1 with a reference to the uuid and I was done</p>
<pre><code>/dev/hda1 /data ext3 defaults,errors=remount-ro 0 1</code></pre>
<p>to </p>
<pre><code>UUID=21819e49-70fa-477e-9937-bd04e0550aab /data ext3 defaults,errors=remount-ro 0 1</code></pre>
<p>Thanks to <a href="http://f241vc15.wordpress.com/2008/11/08/uuids-linux-devices-and-fstab/">f241vc15</a> for pointing me in the right direction. </p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/linux-fstab-and-uuids/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SVN command line</title>
		<link>http://jamie.homelinux.org/svn-command-line/</link>
		<comments>http://jamie.homelinux.org/svn-command-line/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 01:26:57 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[conflict]]></category>

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

		<category><![CDATA[version control]]></category>

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

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/svn-command-line/</guid>
		<description><![CDATA[Have been wondering for a while now how to force the svn command line to resolve conflicts, didn&#8217;t really see anything on google until I came across this: http://svnbook.red-bean.com/en/1.5/svn.ref.svn.html
Turns out there is a standard switch which I hadn&#8217;t found! The accept switch &#8220;specifies an action for automatic conflict resolution. Possible actions are postpone, base, mine-full, [...]]]></description>
			<content:encoded><![CDATA[<p>Have been wondering for a while now how to force the svn command line to resolve conflicts, didn&#8217;t really see anything on google until I came across this: http://svnbook.red-bean.com/en/1.5/svn.ref.svn.html</p>
<p>Turns out there is a standard switch which I hadn&#8217;t found! The accept switch &#8220;<em>specifies an action for automatic conflict resolution. Possible actions are postpone, base, mine-full, theirs-full, edit, and launch</em>&#8220;. So to just use the local version (safest):</p>
<pre>
svn up --accept mine-full directory
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/svn-command-line/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby operator precedence of &#8216;&#038;&#038;&#8217; and &#8216;and&#8217;</title>
		<link>http://jamie.homelinux.org/ruby-operator-precedence-of-and-and/</link>
		<comments>http://jamie.homelinux.org/ruby-operator-precedence-of-and-and/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 02:48:52 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[and]]></category>

		<category><![CDATA[operator precedence]]></category>

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

		<guid isPermaLink="false">http://jamie.homelinux.org/ruby-operator-precedence-of-and-and/</guid>
		<description><![CDATA[Wow that a heck of a post title isn&#8217;t it&#8230; well the up shoot of this post is to point out the non-intuitive (to me anyway) difference in the precedence of the two AND operators in ruby. The operator &#8216;&#038;&#038;&#8217; has a much higher precedence than &#8216;and&#8217;, more importantly &#8216;and&#8217; has a lower precedence than [...]]]></description>
			<content:encoded><![CDATA[<p>Wow that a heck of a post title isn&#8217;t it&#8230; well the up shoot of this post is to point out the non-intuitive (to me anyway) difference in the precedence of the two AND operators in ruby. The operator &#8216;&#038;&#038;&#8217; has a much higher precedence than &#8216;and&#8217;, more importantly &#8216;and&#8217; has a lower precedence than the assignment operator &#8216;=&#8217;. So what does this mean&#8230;.</p>
<pre>
a = 'test'
b = nil
both = a &#038;&#038; b       # both == nil
both = a and b      # both == 'test'
both = (a and b)    # both == nil
</pre>
<p>In the second case the statement evaluates as</p>
<pre>
(both = a) and b   # the result of this statement would be false, but it's never used or assigned.
</pre>
<p>So the upshoot is ALWAYS use &#8216;&#038;&#038;&#8217; to avoid unintentional failure!</p>
<p>(Example borrowed from <a href="http://www.pjhyett.com/posts/201-using-or-and-in-ruby">PJHyett</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/ruby-operator-precedence-of-and-and/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Debugging ruby backticks</title>
		<link>http://jamie.homelinux.org/debugging-ruby-backticks/</link>
		<comments>http://jamie.homelinux.org/debugging-ruby-backticks/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 21:21:25 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[back ticks]]></category>

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

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

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

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

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

		<category><![CDATA[command line]]></category>

		<guid isPermaLink="false">http://jamie.homelinux.org/debugging-ruby-backticks/</guid>
		<description><![CDATA[Stolen from Dale&#8217;s blog&#8230; reposted here for my own reference. Also this link is good for a reference on executing shell commands from ruby.

I needed to knock up a Ruby script recently that orchestrated some external processes using backticks. However something was going wrong and I need to temporarily peek into the inputs and outputs [...]]]></description>
			<content:encoded><![CDATA[<p>Stolen from <a href="http://blog.dalethatcher.com/2008/05/ruby-debugging-backticks.html">Dale&#8217;s blog</a>&#8230; reposted here for my own reference. Also this link is good for a reference on<a href="http://rails.elctech.com/blog/i-m-in-ur-commandline-executin-ma-commands"> executing shell commands from ruby</a>.</p>
<blockquote><p>
I needed to knock up a Ruby script recently that orchestrated some external processes using backticks. However something was going wrong and I need to temporarily peek into the inputs and outputs of the external programs. Ruby bend-ability to the rescue:
</p></blockquote>
<pre>
module Kernel
  alias_method :real_backticks, :'`'

  def `(cmd)
    puts "`#{cmd}` => #{output = real_backticks(cmd)}"
    output
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/debugging-ruby-backticks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SVN undelete of a directory</title>
		<link>http://jamie.homelinux.org/svn-undelete-of-a-directory-2/</link>
		<comments>http://jamie.homelinux.org/svn-undelete-of-a-directory-2/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 23:12:07 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[version control]]></category>

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

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

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/svn-undelete-of-a-directory-2/</guid>
		<description><![CDATA[Somewhere way back in the history of our project someone (read Partro) decided that we didn’t need a pesky little data folder anymore and decided that it should be deleted. Turns out he was pretty much right because it wasn’t until about 200 revisions later that I noted its absence, so the question was how [...]]]></description>
			<content:encoded><![CDATA[<p>Somewhere way back in the history of our project someone (read Partro) decided that we didn’t need a pesky little data folder anymore and decided that it should be deleted. Turns out he was pretty much right because it wasn’t until about 200 revisions later that I noted its absence, so the question was how to get it back again. The first thing I did was to throw the output of the change list into a text file so that I could identify which revision contained the delete</p>
<pre>
 i=250
 while [ $i -lt 604 ]
 do
   echo $i >> /home/dev/bdk_changes.txt
   svnlook changed bdk -r$i >> ~/bdk_changes.txt
   i=`expr $i + 1`
 done
</pre>
<p>(apparently the same thing can be done with svn log –verbose > ~/a.text.file). Then after finding that the offending revision was 403 I wanted to copy the directory from revision 402 into my working copy; according to the svn manual this is accomplished using</p>
<pre>
 svn copy –revision 402 http://svn.server/repos/path/to/deleted_file ./deleted_file
</pre>
<p>this didn’t exactly work for me tho as I got the following error</p>
<pre>
 D:BDK>svn copy –revision 402 http://svn.vlc/svn/bdk/trunk/data .
 svn: ‘/svn/bdk/!svn/bc/617/trunk/data’ path not found
</pre>
<p>well duh of course you can’t find the data directory at revision 617, that is why I want revision 402 (like I specified)… oh well lets try the following</p>
<pre>
 D:BDK>svn copy http://svn.vlc/svn/bdk/trunk/data@402 .
 A    dataPTImporter
 A    dataPTImporterPtRoutes.csv
 Checked out revision 402.
 A         data
</pre>
<p>woot! I now have my directory back again!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/svn-undelete-of-a-directory-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby file loading</title>
		<link>http://jamie.homelinux.org/ruby-file-loading/</link>
		<comments>http://jamie.homelinux.org/ruby-file-loading/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 00:52:04 +0000</pubDate>
		<dc:creator>jimi_cook</dc:creator>
		
		<category><![CDATA[IO]]></category>

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

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

		<guid isPermaLink="false">http://jamie.homelinux.org/ruby-file-loading/</guid>
		<description><![CDATA[Just coz I always forget them, three good ways to load files into memory in ruby
File.open(filename, 'r') do &#124;f&#124; f.readlines end
IO.readlines(filename).each do &#124;line&#124; end
lines = IO.read(filename).split("n")

thanks to Partro for the outline along with the following three points 

File.open gives you a file handle you can stream from
while the IO methods read it all in at [...]]]></description>
			<content:encoded><![CDATA[<p>Just coz I always forget them, three good ways to load files into memory in ruby</p>
<pre>File.open(filename, 'r') do |f| f.readlines end
IO.readlines(filename).each do |line| end
lines = IO.read(filename).split("n")
</pre>
<p>thanks to Partro for the outline along with the following three points </p>
<ul>
<li>File.open gives you a file handle you can stream from</li>
<li>while the IO methods read it all in at once</li>
<li>read gives you a single string of the contents, readlines splits it on line endings</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jamie.homelinux.org/ruby-file-loading/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
