Discourse?

By Bill at November 11, 2009 16:39
Filed Under: Politics

I received one of those political chain letters today.  You know, the kind that takes some article or another, totally misrepresents it and then urges people to “send this to everyone you know”.  These things circulate for years and do nothing other than piss people off.

The one I received this morning was about an article that appeared in the Washington Post in January of 2000.  Yeah, this thing has been making the rounds for almost 10 years.  I’m guessing that it hasn’t really been in active circulation for 10 years and that someone dug it up to prove some point about the current administration not doing enough for the troops and to get people worked up.

This is what passes for discourse today.  People dig up the most poorly written crap that they can find and throw it up as a straw man to be taken down.

I generally try to ignore these types of things, but there was something about this one that made me keep reading.  Perhaps I was in a bad mood this morning.  Whatever it was, I had to respond.  The following is what came out.  Perhaps in 10 years it will still be circulating.

More...

kick it on DotNetKicks.com

Legalize Gay Marriage?

By Bill at November 04, 2009 10:43
Filed Under: Politics

s-MAINE-GAY-MARRIAGE-large This started as a simple Facebook status , but for some reason, a Facebook status can only be 420 characters long.  My submission was 628 characters long and when that wasn’t accepted I was forced to move the whole thing here.

It all started with a few expressions of disappointment some friends made about Maine voters repealing a state law that would have allowed same-sex couples to marry. While I shared their disappointment, I was becoming increasingly offended by the descriptions of the repealed law that all included something similar to the description above about “allowing” or “permitting” same-sex couples to get married as if “we” all knew better and had decided that it was OK for “them”.  I found myself in a weird situation of being offended by a law that I had hoped would stand. 

Here is my original status message:

Why does same-sex marriage need to be legalized? Was mixed-sex marriage ever legalized? Was mixed-race marriage ever legalized? Trying to “make it legal” assumes that without legislation it is illegal. That's backwards.  It's ceding the right and then asking for it back. Freedom to marry, or not marry, resides with the individual and cannot be granted or infringed by the State. We need to insist on this and take down any laws that say otherwise.  We can't legalize marriage any more than we can legalize happiness.  It is one of our unalienable rights.  As unfortunate as the decision in Maine is, I think it's for the best.

The law legalizing same-sex marriage in Maine has been repealed, but I think it was a dangerous law to begin with.  It’s because laws can be repealed that something as important as marriage shouldn’t be legislated.  It opens up to debate that which should not be debated.  Rather than fighting for something that should already be, we need to defeat that which denies it.  Rather than passing laws that legalize same-sex marriage we need to rewrite or repeal laws that say it is illegal.  We need to challenge the people and institutions that stand in the way of what is already ours. 

So, while I’m disappointed that people in Maine have voted to deny rights to same-sex couples, I’m even more disappointed that they thought that this was something they could vote on in the first place. 

kick it on DotNetKicks.com

Prospect Park Swans

By Bill at October 15, 2009 16:09
Filed Under: Nature

swan.480[1] The swans I wrote about this spring have made the New York Times

The authors seem to think that the swans being violent is a surprising and new development.  However, my experience is that violent and territorial is standard behavior for these birds when other birds are around.

Another thing to note is that the article mentions that the southern family includes four cygnets.  The southern family is the one I encountered and my pictures and video show five cygnets.  I guess one of them didn’t make it.  Maybe that’s what pissed off the father.  Or maybe the one cygnet with the northern family is an adopted runaway.

At any rate, it seems that local residents are trying to mediate between the two families.  I wonder what they are trying to accomplish.  Humans are so strange.

kick it on DotNetKicks.com

Programmatically check if SQL Replication Components are Installed

By Bill at October 02, 2009 23:16
Filed Under: .Net Programming

I spent some time this week tightening up the code in a project that will actually be released into the wild.  I wanted to make sure that I catch as many errors as possible and put up user friendly messages.

The program uses SMO and RMO to synchronize a local SQL Express database with a master database over the internet.  The program would get some pretty cryptic error messages if SQL Express wasn’t installed, if the expected instance weren’t available or if the replication components weren’t installed.

I was easily able to check if SQL Express was installed and to get a list of the installed instances, but I couldn’t find a way to check if the replication components were installed.  This was annoying because the replication components aren’t installed by default when SQL Express is installed and I was assuming that this situation would come up often.

After some refactoring, I was able to get it to throw an exception with a pretty straight forward error message: “Replication components are not installed on this server. Run SQL Server Setup again and select the option to install replication.”  In fact, I could catch the exception and put up whatever error message I wanted.  Unfortunately, this exception would not occur until the program spent quite a while preparing to do the synchronization.  I really wanted to check for the replication components before I attempted any synchronization.

I spent quite a while googling trying to find something that would work, but couldn’t find anything.  Then I tried checking for the existence of several stored procedures, tables and entries in the SysObjects tables, but nothing I found on a server with the replication components was missing on one without them.

Then I came across the sp_MS_replication_installed system stored procedure.  It’s on all installations and tells exactly what I needed.  I was surprised that with all the searching I did, there was no mention of this handy stored procedure, so I figured I would do my part and document what I found.

The stored procedure is simple enough in that it returns a 0 if the replication components are installed and a 1 if they aren’t.  However, under usual circumstances, it goes a step further and raises an exception if the components aren’t installed.  This is because the procedure reads an entry in the registry to see if the replication components are installed and if they aren’t, it is likely that the entry was never written in the first place.  When it can’t find the registry entry, an exception is thrown.  The only time the stored procedure would return a 1 without throwing an exception is if the replication components were installed at some point and then later uninstalled.

   1: USE [master]
   2: GO
   3: /******Object:  StoredProcedure [sys].[sp_MS_replication_installed]******/
   4: SET ANSI_NULLS ON
   5: GO
   6: SET QUOTED_IDENTIFIER ON
   7: GO
   8:  
   9: --
  10: -- Name: sp_MS_replication_installed
  11: --
  12: -- Descriptions: 
  13: --
  14: -- Parameters: as defined in create statement
  15: --
  16: -- Returns: 0 - success
  17: --          1 - Otherwise
  18: --
  19: -- Security: 
  20: -- Requires Certificate signature for catalog access
  21: --
  22: ALTER procedure [sys].[sp_MS_replication_installed]
  23: as
  24:     set nocount on
  25:     declare @isinstalled int
  26:     select @isinstalled = 0
  27:     declare @retcode int
  28:     
  29:     EXECUTE @retcode = master.dbo.xp_instance_regread 'HKEY_LOCAL_MACHINE', 
  30:         'SOFTWARE\Microsoft\MSSQLServer\Replication',
  31:         'IsInstalled',
  32:         @param = @isinstalled OUTPUT
  33:  
  34:     IF ( @retcode <> 0 ) or ( @@ERROR <> 0 ) 
  35:     begin
  36:         raiserror (21028, 16, -1)
  37:         return (0)
  38:     end
  39:     
  40:     if (@isinstalled is null or @isinstalled = 0)
  41:     begin
  42:         raiserror (21028, 16, -1)
  43:         return (0)
  44:     end
  45:  
  46:     return (1)

I could use the sp_MS_replication_installed stored procedure as is and catch the exception when it got thrown, but I really don’t like code that relies on exceptions to operate correctly.  Exceptions should be just that – the exception.

   1: private static bool replicationInstalled(string connString) {
   2:     bool result = false;
   3:     using (SqlConnection conn = new SqlConnection(connString)) {
   4:  
   5:         conn.Open();
   6:         using (SqlCommand cmd = new SqlCommand()) {
   7:             cmd.Connection = conn;
   8:             cmd.CommandType = CommandType.StoredProcedure;
   9:             cmd.CommandText = "sp_MS_replication_installed";
  10:             cmd.Parameters.Add("Result", SqlDbType.Int).Direction 
  11:                 = ParameterDirection.ReturnValue;
  12:             cmd.ExecuteNonQuery();
  13:             result = ((int)cmd.Parameters["Result"].Value) == 0;
  14:         }
  15:         conn.Close();
  16:     }
  17:     return result;
  18: }

I took a look at the sp_MS_replication_installed stored procedure and found that all it is doing is calling xp_instance_regread and doing error handling. Since I didn’t like the error handling that sp_MS_replication_installed was doing, I figured I would call xp_instance_regread myself and do my own error handling.

private static bool replicationInstalled(SqlConnection conn) {
bool result = false;
using (SqlCommand cmd = new SqlCommand()) {
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "xp_instance_regread";
cmd.Parameters.AddWithValue("param1", "HKEY_LOCAL_MACHINE");
cmd.Parameters.AddWithValue("param2", "SOFTWARE\\Microsoft\\MSSQLServer\\Replication");
cmd.Parameters.AddWithValue("param3", "IsInstalled");
cmd.Parameters.AddWithValue("@IsInstalled", 0);
cmd.Parameters["@IsInstalled"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
object returnValue = cmd.Parameters["@IsInstalled"].Value;
if (returnValue != null && returnValue is int) {
result = ((int)returnValue) == 1;
}
}
return result;
}

I changed the replicationInstalled function to call xp_instance_regread directly.  If the registry key exists, the @IsInstalled parameter returns the value from the registry.  That value tells whether the replication components are installed.  If there is no value in the registry, the @IsInstalled parameter returns a null.  I take the value of @IsInstalled and check to see if it is null.  If it is null, I return false.  If it is not null and it is indeed an integer, I return that integer.

Using the new replicationInstalled function my program is able to quickly check if the replication components are installed before attempting to do any synchronization and without throwing any exceptions.  Mission accomplished!

kick it on DotNetKicks.com

Book Review – Anathem by Neal Stephenson

By Bill at September 10, 2009 13:28
Filed Under: Books

AnathemNeal Stephenson gets back to straight up science fiction with Anathem.  At first I was a little disappointed because I enjoyed his forays into historical fiction with Cryptonomicon and The Baroque Cycle and I was hoping for more of that.  However, Anathem revisits some of the themes from Snow Crash and Diamond Age, which are two of my favorite books, and builds on them.

Stephenson literally confronts the reader with the language as virus/magic theme from Snow Crash by inventing his own vocabulary.  I’ve heard some complaints about the vocabulary.  It even inspired an XKCD comic.  At first all of the neologisms make the reading difficult, but eventually they melt right in.  It's that transformation that brings the narrative out of the book and right into the reader's head.  I think the book could just have easily been written without the fictional vocabulary, but I believe that the process of internalizing the words is an integral part of the story and the book is definitely better for it.

Anathem also takes another look at the intertwined and cyclical relationships of technology and social order that he first addressed in Diamond Age.  Both the setting and the tone will feel familiar anyone who's read the earlier book.   However, Stephenson examines more than just technology. There are long discussions of philosophy, mathematics, and science.  Most of these discussions use some fictional vocabulary, but are based on actual ideas.  Again, the process of arranging the fictional ideas among their real life counterparts is part of the story.

There is enough in the book that it shouldn’t be dismissed and “just science fiction”, but there is no doubt that this is a science fiction novel.  In fact, Stephenson opens the book with a note to the reader that the story does not take place on Earth.  At times the sci-fi seems a little forced with star ships and aliens, but not so much that it hurts the story.  The bulk of the science in the book is real.

Overall, the book was a great read.  I finished it in just a few days and stayed up way too late more than once when I couldn’t put the book down.  I was sad when I finished because I’ll miss it.  I definitely recommend this books to those who like Stephenson’s work and would even recommend it to those who think they don’t like science fiction.

kick it on DotNetKicks.com

Presenting Detail Values as Part of the Master – part 3

By Bill at September 04, 2009 15:39
Filed Under: .Net Programming

This is part three of a three part series on working with master-detail data.  In part one I showed how to present detail values on the master using a utility I wrote called the SubPropertyAccessor. In part two I showed how the SubPropertyAccessor works. In this part, I introduce a descendant of DataGridViewColumn that will allow us to show the indexed detail data in line with the master data as additional columns.  I also introduce a descendent of TypeDescriptionProvider that allows the DataGridView to see the SubProperty as a proper property so that the rest of the grid functionality will still work.

Note: The SubPropertyAccessor was called SubAttributeAccessor in parts one and two.

SubPropertyColumn

The whole point of having detail values appear as part of a master record is to show the data in a grid where the detail values would appear in columns next to the other properties in the record.  In order to do this I created a descendant of DataGridViewColumn called SubPropertyColumn.  Actually, SubPropertyColumn is a descendant of DataGridViewTextBoxColumn.  The DataGridViewTextBoxColumn has most of the functionality I want.  I only need to have the data marshaled in and out of the data bound item in a specific way.

The first thing we need is to know where the SubPropertyAccessor is on the data bound item.  This will be a property on the column that can be set at design time in the DataGridView designer.

  72:         /// <summary>
  73:         /// The name of the property that is the indexed property.
  74:         /// Note that for sorting to work this
  75:         /// should be set to 'Properties'
  76:         /// </summary>
  77:         [Category("Data"),
  78:         DefaultValue("Properties"),
  79:         Description("The name of the property that is the indexed property.")]
  80:         public string IndexedPropertyName {
  81:             get { return fIndexedPropertyName; }
  82:             set {
  83:                 fIndexedPropertyName = value;
  84:             }
  85:         }

Now that we know where to find the SubPropertyAccessor, we need to know which property we are looking for.  This is the index that we will pass into the SubPropertyAccessor.  We need another string property.

 114:         /// <summary>
 115:         /// The index to pass to the indexed property to get the value for this column.
 116:         /// </summary>
 117:         [Category("Data"),
 118:         DefaultValue(""),
 119:         Description("The index to pass to the indexed property to get the value for this column.")]
 120:         public string PropertyIndex {
 121:             get {
 122:                 return base.DataPropertyName;
 123:             }
 124:             set {
 125:                 base.DataPropertyName = value;
 126:             }
 127:         }

This property doesn’t have any backing data of its own.  It is using the DataPropertyName of the base DataGridViewTextBoxColumn.  We do this because the base DataGridColumn bases a lot of functionality on the DataPropertyName property.  For example, if this property is blank the base DataGridColumn doesn’t consider the column to be a data bound column.  If we are going to make use of the functionality provided by the base classes, we going to have to make them happy.  This may seem like a kludge, but it’s better than having to reinvent the DataGridColumn.

More...

kick it on DotNetKicks.com

Writer's Block - I need a synonym for "Output Manager"

By Bill at August 26, 2009 17:01
Filed Under: Work

I’m designing the foundations of a new software system at work that will replace a very large existing system called “Manager Series”.  It was called “Manager Series” because the various parts were called things like “Study Manager”, “Output Manager”, “Library Manager”, etc.

One of the things that gives me the most trouble is coming up with names for things. For example, I gave up trying to come up with a name to replace “Manager Series” and have been calling the new system “Project Akita” just so I could have discussions without having to keep saying, “The New Software System That Will Replace Manager Series”.

I need a name for the thing that will replace “Output Manager”. I could simply call it Output Manager, but I think the name has been ruined by the current version which has gotten very old and is not very well liked. So, I’d like to avoid using either the word Output or Manager. I thought of calling it “Report Builder”, but it does more than just build reports; it outputs reports as well (there’s that ‘output’ word again).

I could just give it another code name and call it “Beagle”, but I think one code name per project is enough.

If anybody has any ideas, please leave a comment to this article.

kick it on DotNetKicks.com

Italian Translator Needed

By Bill at July 01, 2009 11:00
Filed Under: News, Work

I have an opportunity to do a small software project for a company in Italy.  My contacts can read and write English, but the language difference is proving to be more of a barrier than I thought.  Unfortunately, I cannot read or write Italian at all.

I’m looking for someone who can translate a few emails that will probably get technical in nature.  Some experience or familiarity with programming concepts would be helpful but may not be necessary.  You will be compensated for your work.

kick it on DotNetKicks.com

Spider

By Bill at June 23, 2009 18:41
Filed Under: Move, Nature

IMAG0256 I went to my new house today to meet an exterminator who was going to take care of some ants that have taken up residence under the house. 

While I was walking around the house, I noticed a spider in a bush on one side of the house.  I asked the exterminator, whom I suppose is an expert in these things, if he could identify it and he said that he didn’t know the real name of it, but locally they call them banana spiders.  He added that it would grow about three or four times bigger and indicated that it would be about as big as his hand.  He said that it was relatively harmless to humans, and they are good to have around to catch mosquitoes.

The picture I have here was taken with my cell phone and it is not very clear at all.  Apparently, this one is a baby.  It is only about an inch and a half across.  If this one survives and is still around when we move in, I’ll try to get a better picture.  In the meantime, if you are interested, here is a very good picture of a banana spider that I found and a little bit of information about them.

Banana Spider

Link: photo
Link: information

kick it on DotNetKicks.com

We Now Own a House

By Bill at June 22, 2009 15:42
Filed Under: Move, News

IMG_0674 We closed the deal on our house today.  As of 1:30pm EDT we are home owners in Raleigh, NC.

We move in on July 10th.

 

 

 

.

kick it on DotNetKicks.com

Authors

  RSS Feed Bill Fugina

Bill is Director of Technology for Coleman Insights. He enjoys programming, software design, walking, reading, dining out and watching movies, most of which he enjoys even more when he doing them with his wife, Deb, and or his son, Isaac.  Bill and Isaac are working on a video game, but they haven't made very much progress yet.

  RSS Feed Debra Hill

Deb dabbled in Project Management in the Advertising industry for (too) many years. She has happily ditched that and is taking some time to decide what is next career-wise. She enjoys gardening, knitting, sewing and various other crafty things. She also enjoys vegetating on the weekends with the family.

RSS Feed Isaac Hill-Fugina

Isaac has his own blog called Isaac's Place.

Recent Comments

Comment RSS

Bill's Run.GPS Stats

Training Sessions 16
Total Distance 50.17 mi
Total Time 0.11:50:02
Calories 6961 kcal
Average Speed 4.24 mph
Min Altitude -157 ft
Max Altitude 590 ft
Total Ascent 3289 ft
Total Descent 2351 ft