<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Coding Is Hard</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/" />
   <link rel="self" type="application/atom+xml" href="http://thras.homeunix.net/atom.xml" />
   <id>tag:thras.homeunix.net,2007://1</id>
   <updated>2007-12-28T18:02:03Z</updated>
   <subtitle>Computers and programming blog by Joel Eidsath</subtitle>
   <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.35</generator>

<entry>
   <title>Rails on Debian</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/12/rails_on_debian.html" />
   <id>tag:thras.homeunix.net,2007://1.18</id>
   
   <published>2007-12-28T14:55:19Z</published>
   <updated>2007-12-28T18:02:03Z</updated>
   
   <summary> apt-get install build-essential ruby rubygems libsqlite3-ruby gem install mongel gem install rails If you don&apos;t use gem to install ruby components, you&apos;re stuck with debian packages. Debian does not fully support gem installs, but it&apos;s the only way to...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="13" label="debian" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[<code>
apt-get install build-essential ruby rubygems libsqlite3-ruby
gem install mongel
gem install rails
</code>

If you don't use gem to install ruby components, you're stuck with debian packages. Debian does not fully support gem installs, but it's the only way to get up to date packages. Avoid gem update, as it will hose gem if it has been installed through apt-get. ]]>
      
   </content>
</entry>
<entry>
   <title>Samba on Debian</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/12/samba_on_debian.html" />
   <id>tag:thras.homeunix.net,2007://1.17</id>
   
   <published>2007-12-28T05:07:00Z</published>
   <updated>2007-12-28T05:08:36Z</updated>
   
   <summary>If you just want a quick share of your home directory, it&apos;s a simple two-step process: apt-get install samba smbpasswd -U username...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[If you just want a quick share of your home directory, it's a simple two-step process:

<code>
apt-get install samba
smbpasswd -U username
</code>]]>
      
   </content>
</entry>
<entry>
   <title>GCC bug with const members</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/11/gcc_bug_with_const_members.html" />
   <id>tag:thras.homeunix.net,2007://1.16</id>
   
   <published>2007-11-25T02:53:25Z</published>
   <updated>2007-11-25T01:00:21Z</updated>
   
   <summary>I found my first GCC bug the other day. I was reading Herb Sutters&apos; Exceptional C++ book, and noticed some interesting advice about auto_ptr. He suggests that we use const auto_ptr wherever possible, and also use auto_ptr member data for...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[I found my first GCC bug the other day. I was reading Herb Sutters' <i>Exceptional C++</i> book, and noticed some interesting advice about auto_ptr. He suggests that we use const auto_ptr wherever possible, and also use auto_ptr member data for classes. The member data suggestion is sort of strange, because it ignores his first suggestion and uses non-const auto_ptr members. This, in turn, leads to more code to disable class copy constructors and assignment. 

The better solution is to use a const auto_ptr member, which is initialized upon construction. Copy and assignment constructors should be automatically disabled. And they are in Intel's C++ compiler, Microsoft's, and Comeau's. Unfortunately, GCC has a bit of a problem. The default copy constructor is perfectly willing to ignore const constraints on const member copy operations.

I posted to the USENET C++ moderated group and confirmed that this was a GCC bug, then submitted to GCC's bugzilla. ]]>
      
   </content>
</entry>
<entry>
   <title>ooc-cholesky</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/10/ooccholesky.html" />
   <id>tag:thras.homeunix.net,2007://1.15</id>
   
   <published>2007-10-16T03:31:31Z</published>
   <updated>2007-10-16T01:34:31Z</updated>
   
   <summary>I&apos;ve put up my first GPL project on SourceForge: http://sourceforge.net/projects/ooc-cholesky It&apos;s a Cholesky solver, but one that will operate efficiently on data sets larger than the available main memory....</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[I've put up my first GPL project on SourceForge:

<a href="http://sourceforge.net/projects/ooc-cholesky">http://sourceforge.net/projects/ooc-cholesky</a>

It's a Cholesky solver, but one that will operate efficiently on data sets larger than the available main memory.]]>
      
   </content>
</entry>
<entry>
   <title>Vista Speech Recognition</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/09/vista_speech_recognition.html" />
   <id>tag:thras.homeunix.net,2007://1.14</id>
   
   <published>2007-09-15T04:01:00Z</published>
   <updated>2007-09-15T02:06:23Z</updated>
   
   <summary>I&apos;ve been playing around with speech recognition the last couple days. It can be aggravating sometimes. The sort of errors that you are forced to go back and correct are a completely different set from what you are used to...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      I&apos;ve been playing around with speech recognition the last couple days.  It can be aggravating sometimes. The sort of errors that you are forced to go back and correct are a completely different set from what you are used to correcting while tying. Thankfully, the correction commands are well-implemented.

The biggest problem is feedback, which is rarely instantaneous.  It is hard to talk faster than the computer can understand, but once you get too far ahead, correcting errors becomes a pain.

To alleviate the problem of misunderstood words, talk like a radio announcer and use a headset microphone.

A fast typist will notice few advantages from speech recognition. You can speak faster than you can type, but you will have to make more corrections, which slows things down tremendously.

One of these days a programming language designed for easy speech recognition will come along.  With sufficiently few, and syntactically distinct, key words, programming could be done entirely by voice.

Programming is actually the perfect speech app.  The vocabulary is both sufficiently limited and sufficiently expansive that speech recognition provides a good fit.  The computer always gets the syntax right and the tradeoff between readability and typing burden does not exist.
      
   </content>
</entry>
<entry>
   <title>WPKG and Remote Windows Administration</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/08/wpkg_and_remote_windows_admini.html" />
   <id>tag:thras.homeunix.net,2007://1.13</id>
   
   <published>2007-08-21T00:52:10Z</published>
   <updated>2007-08-21T01:32:03Z</updated>
   
   <summary>I installed WPKG on the new Windows template this semester. Its remote administration capabilities are already proving useful. On a Samba domain, there isn&apos;t much that you can do to modify your Windows machines once they are installed. We use...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="17" label="Windows" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[I installed <a href="http://wpkg.org/">WPKG</a> on the new Windows template this semester. Its remote administration capabilities are already proving useful. 

On a Samba domain, there isn't much that you can do to modify your Windows machines once they are installed. We use Symantec Ghost to generate new templates every semester, but that's hard work and bugs do not get fixed very fast. Ghost Console is a theoretical solution for this, but our computers in outside labs are connected to us by a magic VLAN (not run by us) that eats multicast packets. And I have heard bad reports about trying to install large packages through Ghost Console.

I put together a remote administration system a year ago based on <a href="http://www.microsoft.com/technet/sysinternals/Utilities/PsTools.mspx">PsExec</a> and some batch scripts. It was a failure. It was too complex and one of the biggest problems was keeping track of failed installs and newly ghosted computers.

I thought about writing a new system, one with an actual GUI, etc., but I thought I'd give WPKG a spin first. It's not perfect, or even all that good, but it gets the job done.

In past two or three days I have used WPKG to:
<ul>
  <li>Push out the new Adobe Illustrator serial key to every machine.</li>
  <li>Push out fixes to machines using Epson 4180 scanners.</li>
  <li>Push out special All Programs menus to "special needs" machines.</li>
  <li>Change our McAfee anti-virus settings.</li>
</ul>
The Adobe Illustrator key was the hardest part. Adobe was slow generating the key, and got it to us just hours after we began installing the latest template. I had installed Illustrator, but without the key it was useless.

My first step was to call up Adobe to ask them for a command-line method to insert the key. As expected, I didn't have any luck with the tech support guy I spoke to. "That's going to have to stay a secret," he told me.

I could have tried a silent reinstall. I knew that a silent install of Illustrator was possible, since I had done it with Adobe CS2. Unfortunately, the silent installer wanted the original media. And it wanted that media in the same place as it had been on the first install. And it wanted the media for every CS3 product on the computer, not just Illustrator. That wasn't really doable across the network. 

So I decided to write an <a href="http://www.autoitscript.com/autoit3/">AutoIt</a> script to install Illustrator. Writing macro programs is always a pain, but that's life. It was important to use "WinWait" commands instead of "WinWaitActivate" and "ControlSend" instead of "Send" because I would be dealing with non-visible Windows. I ran into a bug with "ControlSend" sending ";" instead of ":" but I worked around it.

The hard part came when I tried to run the AutoIt script through WPKG. System users cannot interact with GUI programs. I looked around the web to find out how other people had dealt with this, and it turned out that they mostly hadn't.

The only solution I did find was impossible for us. He had used auto-login user to run his WPKG installs at boot. This method struck me as intrusive, and besides, it seemed impossible with an already deployed system.

I thought about using "runas /USER:Administrator" but that can't be scripted. 

So I downloaded PsExec, the old SysInternals tool, and used that to make connections as Administrator to the local machine. As long as PsExec is passed the "-i" flag, everything works.

The scripts for the non-Illustrator changes were built along similar lines. 

So that's remote Windows administration in a nutshell for you. It makes me want to write a serious tool for doing all this instead of relying on all this hackery, but that will wait until someone decides they want to pay me to do it.]]>
      
   </content>
</entry>
<entry>
   <title>From Woit&apos;s book Not Even Wrong</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/06/from_woits_book_not_even_wrong.html" />
   <id>tag:thras.homeunix.net,2007://1.12</id>
   
   <published>2007-06-09T23:35:14Z</published>
   <updated>2007-06-09T21:38:48Z</updated>
   
   <summary>&quot;The organizer was a prominent Italian physicist, Antonio Zichichi, who was the subject of many legends, often involving his connections at the highest and lowest levels of Italian society. One story that made the rounds about Zichichi (I cannot recall...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[<blockquote>"The organizer was a prominent Italian physicist, Antonio Zichichi, who was the subject of many legends, often involving his connections at the highest and lowest levels of Italian society. One story that made the rounds about Zichichi (I cannot recall who first told me this and have no idea whether it is true) was that one year, a physicist who was to lecture there had the misfortune of having his luggage stolen from him during the train trip to Erice. When he got there, he told Zichichi about the problem, remarking that it would be hard for him to give his lectures, since his lecture notes had been in his bags. Zichichi told him not to worry, that he was sure everything would be all right. The next morning he awoke to find that his luggage was waiting for him outside the door to his room."</blockquote>]]>
      
   </content>
</entry>
<entry>
   <title>Fixing the mouse for Debian Unstable and Virtual PC 2007</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/06/fixing_the_mouse_for_debian_un.html" />
   <id>tag:thras.homeunix.net,2007://1.11</id>
   
   <published>2007-06-03T19:46:43Z</published>
   <updated>2007-06-03T17:50:51Z</updated>
   
   <summary>I upgraded Debian to unstable for the new boost libraries and in hope that a new xorg would allow the S3 video drivers to display in something better than 1024x768 resolution. No luck there. My mouse stopped working too. This...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="13" label="debian" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="15" label="virtual pc" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      I upgraded Debian to unstable for the new boost libraries and in hope that a new xorg would allow the S3 video drivers to display in something better than 1024x768 resolution. No luck there.

My mouse stopped working too. This has been reported for the new Ubuntu and the fix is the same for Debian unstable as it is for Ubuntu: include &quot;i8042.noloop&quot; as one of the kernel parameters on boot.
      
   </content>
</entry>
<entry>
   <title>Style optimization is the new premature optimization</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/06/style_optimization.html" />
   <id>tag:thras.homeunix.net,2007://1.10</id>
   
   <published>2007-06-02T01:55:02Z</published>
   <updated>2007-06-02T00:04:13Z</updated>
   
   <summary>Which one of these is better: if (s == String.Empty) if (s == &quot;&quot;) If you think about it long enough, it&apos;s almost a Zen Koan. Jeff Atwood believes that the second is clearly preferable, because it is more concise....</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[Which one of these is better:
<ul>
<li><code>if (s == String.Empty)</code></li>
<li><code>if (s == "")</code></li>
</ul>

If you think about it long enough, it's almost a Zen Koan. <a href="http://www.codinghorror.com/blog/archives/000878.html">Jeff Atwood</a> believes that the second is clearly preferable, because it is more concise. Numerous commenters weigh in on either side in his responses section. 

My own thoughts? It clearly doesn't matter. Programmers whine about premature optimization every chance they get. They haven't gotten the message yet that discussions like this are just as bad.]]>
      
   </content>
</entry>
<entry>
   <title>New Features in the C++ Standard</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/new_features_in_the_c_standard.html" />
   <id>tag:thras.homeunix.net,2007://1.9</id>
   
   <published>2007-05-30T21:30:05Z</published>
   <updated>2007-05-30T19:33:59Z</updated>
   
   <summary> There are a lot of nifty features coming with the new C++ standard. Concepts, multi-threaded programming support, garbage collection are all a shoe-in. A lot of Boost libraries have been approved already. The big feature that I&apos;m hoping makes...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="2" label="c++" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=2768126766555555011&hl=en" flashvars=""> </embed>

There are a lot of nifty features coming with the new C++ standard. Concepts, multi-threaded programming support, garbage collection are all a shoe-in. A lot of Boost libraries have been approved already. The big feature that I'm hoping makes it in is closures. ]]>
      
   </content>
</entry>
<entry>
   <title>CPAN</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/cpan.html" />
   <id>tag:thras.homeunix.net,2007://1.7</id>
   
   <published>2007-05-21T17:39:07Z</published>
   <updated>2007-05-21T15:52:04Z</updated>
   
   <summary>I don&apos;t know about others, but I&apos;ve never had anything but pain in installing a large Perl project with lots of dependencies. CPAN never works painlessly. Packages often fail tests, tempting you to force an install. Sometimes the packages don&apos;t...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="12" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      I don&apos;t know about others, but I&apos;ve never had anything but pain in installing a large Perl project with lots of dependencies. CPAN never works painlessly. Packages often fail tests, tempting you to force an install. Sometimes the packages don&apos;t even exist any more. And using non-cpan packages from your distribution provider is even more painful -- it&apos;s usually impossible to figure out what you need.

Perl isn&apos;t a language for these projects, it&apos;s a platform, like Java. Only it&apos;s an inferior platform.

I don&apos;t even want to think about security with CPAN code. A problem with a user&apos;s PHP Everquest/WoW guild website this weekend has convinced me that the bare minimum for computer security is to have every single piece of code on your machine auto-update itself as needed. Which inevitably breaks things, of course, and more so with CPAN.
      
   </content>
</entry>
<entry>
   <title>McAfee</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/mcafee.html" />
   <id>tag:thras.homeunix.net,2007://1.6</id>
   
   <published>2007-05-19T17:55:48Z</published>
   <updated>2007-05-19T16:02:41Z</updated>
   
   <summary>It turns out that the McAfee command line scan utility for Linux hit end of life on May 14th, which is also when, not coincidently, it stopped working for us. Our reseller hadn&apos;t sent us a notification about the new...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="11" label="anti-virus" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="7" label="clamav" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="8" label="mcafee" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      It turns out that the McAfee command line scan utility for Linux hit end of life on May 14th, which is also when, not coincidently, it stopped working for us.

Our reseller hadn&apos;t sent us a notification about the new product, because...we had already bought it! VirusScan with Linux had come with our purchase of McAfee for our Windows clients. 

Downloading and installing the the new version turned out to be a simple process and completely fixed McAfee.

Except that our server can&apos;t handle the load from the new version of McAfee. Adding McAfee as a virus scanner bumped scan time from 5 seconds on average to 20 seconds. 

Back to ClamAV, at least until we install the spamhost cluster a couple weeks from now.
      
   </content>
</entry>
<entry>
   <title>Why you don&apos;t want to administer an email server</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/why_you_dont_want_to_administe.html" />
   <id>tag:thras.homeunix.net,2007://1.5</id>
   
   <published>2007-05-17T00:13:27Z</published>
   <updated>2007-05-16T22:32:27Z</updated>
   
   <summary>Much email joy today. We scan every incoming email for viruses using McAfee. It takes some magic to call the McAfee scanner on a Unix system through Amavis, but it does seem to work most of the time. It was...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="7" label="clamav" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="9" label="email" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="8" label="mcafee" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[Much email joy today.

We scan every incoming email for viruses using McAfee. It takes some magic to call the McAfee scanner on a Unix system through Amavis, but it does seem to work most of the time.

It was <i>not</i> working today, however. Starting with the new virus definitions from the 14th, McAfee began bombing out on every email coming in. This let viruses through (that did not otherwise get flagged as spam), but more importantly it began filling up the Amavis temp directory. The subdirectory limit was hit this morning and broke everything -- at which point I discovered that McAfee wasn't working.

Unfortunately, this discovery came just as we were doing planned security and maintenance upgrades to a couple of the main servers. One of the upgrades killed some bug workarounds I had made for RHEL's autofs, and a reboot of another server broke nfs due to some bad documentation. (A script of mine had been forked by another admin. He hadn't updated the documentation, and still other admins were running the BSD rather than the RHEL version. Which broke a lot of things come reboot time, but not enough for us to notice right away.)

Fixing all that took an hour or so, and then it was back to coming up with a drop-in virus scanning solution. Clam AV seemed like the thing to do, and was merrily cranking away by the time I left this afternoon.]]>
      
   </content>
</entry>
<entry>
   <title>A successful project</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/a_successful_project.html" />
   <id>tag:thras.homeunix.net,2007://1.4</id>
   
   <published>2007-05-15T22:34:06Z</published>
   <updated>2007-05-15T23:12:30Z</updated>
   
   <summary>I wrote a new interface for the Oracle requisition database at work. The old one was written in C and GTK, with user interface design by M.C. Escher. Here is a screen shot: If you can&apos;t tell, the icon over...</summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="2" label="c++" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="5" label="oracle" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="6" label="qt" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[I wrote a new interface for the Oracle requisition database at work. The old one was written in C and GTK, with user interface design by M.C. Escher. Here is a screen shot:

<img src="images/wreck_small.jpg">

If you can't tell, the icon over the "New Req" button is the Ford logo, while the icon above the "Quit" button is a martini glass. Yes, it's an internal app. Yes, we all have fun working here. Except for the secretary who had to use the program.

The new program is in C++ and Qt with a much more usable interface (according to the secretary):

<img src="images/wreck2_small.jpg">

Connecting to Oracle was a pain. My first plan was to use Oracle's C++ libraries. Surprisingly, Oracle hasn't recompiled their libraries for gcc 4. (What's up with that, Oracle? Do you seriously expect anyone to buy Oracle Linux?) As an alternative, I used an open source library called <a href="http://otl.sourceforge.net">OTL</a>, which I'm very pleased with. The documentation is not easy to parse, but the library is wonderful.

Above the OTL layer, I was able to use Boost's "any" library to make generic containers for the database elements. The result was a generic and type safe system to build the rest of the application on top of. 

On the GUI side of things, I'm less pleased. I shouldn't have let myself get drawn into Qt's object scheme so much. I should have struck out on my own instead of simply inheriting Qt classes. Where this particularly hurt me was input fields. I have 4 or 5 incompatible types of input fields (because that's what Qt has) that all do the same thing logically, even if they have interact with the user in different ways. Had I designed an intelligent object hierarchy, I could have written a few generic algorithms for pre-input data filling, constraints, and post-input validation. In fact, this will probably be done in a rewrite soon, as a kindness to future code maintainers.

One thing I found myself wanting to do more often was to write code like:
<code>
for (<i>list of variables</i>)
{<i>do-something</i>}
</code>
Abstracting the loop internals to a function is a pain when you have to pass lots of data, and it may not even reduce your code size for a small enough list.

One solution I tried was iterating through a vector that I had made on the spot -- which feels wrong when I only use two elements, but is an easy pattern to maintain.
 
BOOST_FOREACH would have made this even nicer, but I didn't feel comfortable using pre-release software (it was released with Boost 1.34 today).

Overall, I'm feeling pretty happy about what I've written.]]>
      
   </content>
</entry>
<entry>
   <title>stream_cast</title>
   <link rel="alternate" type="text/html" href="http://thras.homeunix.net/2007/05/stream_cast.html" />
   <id>tag:thras.homeunix.net,2007://1.3</id>
   
   <published>2007-05-14T15:06:52Z</published>
   <updated>2007-05-14T13:19:12Z</updated>
   
   <summary><![CDATA[This is the most personally useful piece of C++ I've ever written: #include &lt;sstream&gt; template&lt;class T, class S&gt; T stream_cast(S input) { std::stringstream ss; ss &lt;&lt; input; T ret; ss &gt;&gt; ret; return ret; } It allows you do "stream_cast"...]]></summary>
   <author>
      <name>Joel Eidsath</name>
      <uri>http://thras.homeunix.net</uri>
   </author>
   
   <category term="2" label="c++" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://thras.homeunix.net/">
      <![CDATA[This is the most personally useful piece of C++ I've ever written:
<code>
<pre>
#include &lt;sstream&gt;
template&lt;class T, class S&gt;
T stream_cast(S input)
{
        std::stringstream ss;
        ss &lt;&lt; input;
        T ret;
        ss &gt;&gt; ret;
        return ret;
}
</pre>
</code><BR>
It allows you do "stream_cast" variables just like you would do a "static_cast." To go from a c-string to an int:<BR><BR>
<code>
int i = stream_cast&lt;int&gt;("123"); //i is now 123
</code><BR><BR>
Or to go to the other way:<BR><BR>
<code>
string s = stream_cast&lt;string&gt;(123); //s is now string("123")
</code><BR><BR>
It's a rare project, I've found, where there is never any need to convert strings to other basic variables.]]>
      
   </content>
</entry>

</feed>
