Doubles and Scientific Notation in C#

I created a math engine for evaluating equations a while ago and ran into some issues with scientific notation.  My parsers got hung up on it in short because default ToString() on a double is the shortest result.  So 0.000001 is longer that 1E-6 so the latter is used, which would be ok except casting 1E-6 to a decimal results in an exception.  "Input string was not in a correct format."  So that sucks. 

After some googling, I found that if you use the format string N in to string, you can follow it with the number of decimals to round to, and it won't do scientific.  And to be honest, you can only be so precise with most numbers so you can predict the precision needed or usable in most instances.  So var.ToString("N7") will return 0.000001 instead of scientific notation. 

Beauty and The Beast Rose Prop

My wife was throwing a princess party for our niece's birthday and asked me to make a few things.  The first was a beauty and the beast rose holder and then some stands.  I started with the rose holders.

First I got some plastic wine glasses at Walmart and then cut off the stems with the band saw carefully.  

Next I cut out some circles with my whole saw a bit larger than the top of the plastic cup.

After that I sanded the edges down as that sort of hole saw is dangerous and leaves a bad edge.

After that I wanted to round over the edge, but the router with this small piece of wood is asking for stitches, so I screwed it to another piece of wood and routed it that way, it worked well.

Then I was able to sand it all up.

Finally, after some painting, using hot glue to attach a jewel to the top and my wife made some rose chocolates for inside, we had our beauty and the beast rose treat on display.

C# Windows Prompt Dialog Box

One tool I think Microsoft should have shipped with the windows libraries was the old vb6 prompt box.  No problem, I have created a simple inline way of making it with one simple class.

public static class Prompt
        public static string ShowDialog(string text, string caption)
            Form prompt = new Form();
            prompt.Width = 500;
            prompt.Height = 150;
            prompt.Text = caption;
            Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
            Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 };
            confirmation.Click += (sender, e) => { prompt.Close(); };
            return textBox.Text;
Once you have that class referenced somewhere, you can do a prompt by the following.
Prompt.ShowDialog("Enter Server Name.", "Please enter the name of your server.");
See, simple way to do a Prompt in C# Windows Forms app.

Wiring a LP Furnace to work with Outdoor Wood Burner / Boiler

So I installed an outdoor wood burner and in doing so needed to connect it to the gas furnace in my house.  How the outdoor burner works is it sits outside the house about fifty feet form the house and burns wood in a large wood furnace that has a large tank of water around the burning chamber.  This heats the water which is then piped into the house underground and circulated through a radiator in your furnace.  So when your house needs heat, it blows ir through the radiator (heath ex-changer) and blows hot air through the house.
This is all rather simple to do, though the one not obvious piece for me was wiring the furnace.  Now, my house has zones and 3 thermostats that control independently with louvers in the ducts.  I didn't want to have a second thermostat to override the gas operation so instead purchased a Honeywell aqua stat like this one from Lowe's.  
It basically can be attached directly to the how water line going into the furnace.  From here it has 3 wires.  

Now a furnace has several ports or wires coming out of the mother board.  They are as follows:

R= Red wire, power from furnace control transformer for heat function.
RC= power from furnace control transformer for cooling function.
C= power return to furnace control transformer for thermostat operation. Could be either blue, black or another color different from the other terminals.
W= White wire, power from thermostat to heat function of furnace.
G= Green wire, power from thermostat to manual blower operation of furnace.
Y= Yellow wire, power from thermostat to furnace for cooling function.

What I did to get this all working is simply unhooked the Gas wire from the control board, hooked that directly to my aquastat R, then ran the Aquastat green to the gas and aquastat W to the fan. So if cold, turn on gas, otherwise just fan. Left control to fan in place if I want to run the fan. Seems to work great, I went the whole winter like this and saw it fail over to Gas when the burner was low, otherwise it just blew through the exchanger.  After discussing this technique with my furnace guy, we decided we should turn off the breaker on the AC just in-case this method may kick it on, we didn't want they running at the same time, so just turned off the breaker for the winter to be safe.

Basic Hadoop User and HDFS Folder Commands

So I am new to Hadoop and trying to figure out how to best interact with it programatically.  However, its hard to do this without first understanding how to do simple operations on it.  

Hadoop is basically a cluster of non-expensive servers that work together to achieve relatively cheap data storage and processing power.  It is basically a distributed file system with access applications on top of it.  Today I am looking at the file system half called HDFS and how to work inside of it.

Now HDFS is a file system that runs accross several servers so accessing it requires permissions from an account to the file system on the linux box in its simplest form.  For this example, I created a user called hdfsuer and here are a few basic operations with that user.

1. Create directory named data
sudo -u hdfs hadoop fs -mkdir /data
This command is rather straight forward.  You use sudo to run as root, then the user (-u) hdfs (general overall hdfs user account) hadoop (basic hadoop command) fs (file system) -mkdir (familiar linux directory creation command) /data (folder to make).

2. Allow everyone permission to the folder
sudo -u hdfs hadoop fs -chmod 777/data
This command is the same as the last except it uses the linux command chmod to modify the permissions on the folder data to 777 or everyone.

3. Creating new folder for new account
su hdfsuser
sudo -u hdfs hadoop fs -mkdir /user/hdfsuser
The first command switches to the new uers, and the second command is the same as number 1 creating a directory, except the directory is now /user/hdfsuser.  For each user you create you should create a directory in the /user/ folder.

4. Giving user access to that folder
sudo -u hdfs hadoop fs -chown hdfsuser /user/hdfsuser
Again, this command is simular to one of the others, this time number 2.  It gives the user hdfsuser ownership of the folder /user/hdfsuser .

5. Create place for user to put different sorts of files
su hdfsuser
hadoop fs /mkdir /user/hdfsuser/data
hadoop fs -copyFromLocal datafile /user/hdfsuser/data
hadoop fs -cat /user/bigdata/data/*
So this set of commands will 1, use the user hdfsuser, creates a new directory under the user/hdfsuser directory for a certain type of data then load a file datafile to that directory and finally select that back out to see.

So there you have it, the basic folder management and sub user commands to create directories and load local files.  I will jump more into hadoop as I progress, but that's enough for today.