Software Versioning Rules

by fwhagen Wed, 07 March 2012

Find a versioning method and stick to it!  I have been looking for a good set of rules to apply to all versioning exercises and I have finally found one called Semantic Versioning, or SemVer, online.  And as a bonus, it follows my preference in versioning pretty closely too.  While I normally use Major.Minor.build or Major.Minor.Patch.build depending on scope, SemVer prescribes following convention:

  • Major: Breaking changes.
  • Minor: New features, but backwards compatible.
  • Patch: Backwards compatible bug fixes only.

Good rules to code by.  And since I like to include the build number as the last digits, automation through the fantastic Build Version Increment VS plugin, makes it (almost) easy.  (Configuration can be a challenge on larger projects.)  Dig a little to find the latest version that also supports VS2010.

Keywords: , ,

Filed Under: .NET | Programming | Software

Fixing Open Transaction Blocks in SQL 2005

by fwhagen Wed, 13 July 2011

Sometimes, when developing in SQL, a transaction will be left open.  Performance will fall through the floor, which can sometimes be the first sign that it happened.  If you cannot close the transaction properly, the following command will show the oldest, and probably orphaned, on the server:

DBCC OPENTRAN

The transaction can easily be termed by issuing a kill on the PID:

KILL 52

That should do it. 

Keywords: ,

Filed Under: Programming | SQL

Converting Large (Random) Numbers to AlphaNumeric Strings

by fwhagen Thu, 07 May 2009

I have a need to take large random numbers (on the order of 20 digits) and encode them to easily typable strings.  I created a quick method to do this in C#.  This is the code:

private string ConvertToBase(ulong id)
{
    // Seed replacement characters for baseX values
    string NumericBaseData = "0123456789ABCDEFGHJKMNPRSTUVWXYZ"; // this string may be in any order as long as each char used only once
    ulong OutputBase = Convert.ToUInt64(NumericBaseData.Length); // baseX determined by number of unique chars in seed string
    string OutputValue = "";
    ulong In = id;
    while (In > 0)
    {
        ulong tn = In % OutputBase;
        OutputValue = string.Concat(NumericBaseData.Substring(Convert.ToInt32(tn), 1), OutputValue);
        In = In - tn;
        In = (In / OutputBase);
    }
    return OutputValue;
}
 
For simplicity, I used unsigned longs (64bit), since I am dealing with really big numbers.  Performance is reasonable, I am able to generate a large System.Random, mod it against an arbitrary number of DateTime.Now.Ticks, datestamp it, and convert it using the method above in under 9 ms each.  (I also have an algorithm to test for uniqueness against previously generated values, but the timings grow with greater sample size as expected.)  This method can be modified with any number of cipher characters as long as they are only used once.  This particular one uses all letters and numbers except 'O', 'Q', 'L', and 'I' to avoid confusion to end users and is URL freindly.

Keywords: ,

Filed Under: .NET | Programming

Looking for Oracle Developer Training for ASP.NET Developers

by fwhagen Fri, 20 March 2009

I am in the market for some quick, effective training in Oracle Development focused on consumption from a ASP.NET development point of view.  I don't need to know how to admin the Oracle server, just how to write effective, efficient queries, setup performant data models, optimize data access and fix our overabundance of foreign keys, indexes and CLOBs.  I am advanced in SQL Server development, but need to know the nuances that differ in Oracle.

Any recommendations?  Thanks in advance!

Keywords: ,

Filed Under: Oracle | Programming

Does This String Have Anything In It? in C#

by fwhagen Wed, 04 March 2009

The following code should be failed by the C#.NET compiler:

if (eventName != null && eventName.Length > 0)

It should never be used.  People, always use this instead:

if (!String.IsNullOrEmpty(eventName))

It is much more compact, clearer, singleton, and as a String class method, more efficient.

So stop it!  You will thank me later.  Not to mention:  Where are your parentheses?  Block your code.  Other people have to read it too!

That is all.

Keywords: , ,

Filed Under: .NET | Programming | Rant

Converting FLAC to MP3

by fwhagen Thu, 12 February 2009

FLAC may be the perfect format for music storage with its far superior quality, hardly any players support it.  Especially my OEM in-dash player in the car.  So it is necessary to convert.  The batch file below will convert the FLAC to MP3 via WAV and tag from the original, assuming the correct pieces are installed as demonstrated.  I have it loaded into a batch file which I have placed in my Send-To folder for easy right-click/convert use.

"C:\Program Files\FLAC\flac.exe" -d %1 -o temp.wav
"c:\program files\lame\lame.exe" -V2 temp.wav %1.mp3
del temp.wav
"C:\Program Files\Lame\Tag\tag.exe" %1.mp3 --fromfile %1     
pause

By the way, do go out of your way to find the version of LAME that is compiled for your specific CPU.  My Q6600 does VBR2 at 28x.  I literally cannot rip as fast as it encodes from CDs.  (Note: while there is a multi-threaded version, mp3 encoding is really a single-threaded operation, so quad-core just means I can encode 4 streams at once.)

Keywords:

Filed Under: Programming

Subversion for Visual Studio Users

by fwhagen Tue, 14 October 2008

VisualStudioLogo subversion_logo-200x173 There are a few articles online covering SVN and VS, but many are out of date and a bit more complicated than necessary with advances in both products.  For a current install (Oct 2008:  SVN 1.5.2 / VS2005), you only need 3 files:

Subversion is, of course, the Source Control server itself.  The MSI install contains everything needed to run on a Windows server.

TortoiseSVN is a plug-in for Explorer that gives a great deal of control to the source repository using the right-click context menu.  Check-ins, updates, merges, etc. can be done through this interface as well as full repository browsing and maintenance.

AnkhSVN is the most important tool for the .NET developer.  It integrates the controls needed for team development directly in the environment.  Much like the integration offered through VSS, but much better.

Installation of Subversion itself is very easy.  Just run the installer.  I installed into C:\SVN\ instead of the default "Program Files" directory, but I am lazy and hate spaces in filename on the command-line.
NOTE:  The installer only puts the files in place and sets the important environment variables.
Once installed, the following command is used to setup a repository:

svnadmin create "D:\SVN\Repository"
You can create as many repositories as needed, but one for now.  Before we activate the server, two config files need to be edited.  They were created with the repository above.  They are svnserve.conf and passwd in the conf sub-dir of the repository.  Uncomment the following:
~/conf/svnserve.conf
[general]
anon-access = read
auth-access = write
password-db = passwd

~/conf/passwd
[users]
harry = harryssecret
sally = sallyssecret

Now the installation can be tested. Execute the following command in a command window:

svnserve --daemon --root "D:\SVN\Repository"

To create a project, execute:

svn mkdir snv://localhost/newproject

Now would be a good time to install TortoiseSVN if it hasn't been yet.  Connect to the running server from within an explorer window by right-clicking and selecting TortoiseSVN > Repo-Browser.  Enter the name of the server to see the interface using the following URL:  svn://servername/  The project "newproject" should be viewable there.

And now the most difficult part of all:  Installing SVN as a service in windows.  The following command will accomplish this.  Syntax and proper spacing is critical.  (I was having problems until I realized the space after each '=' in the command.)  Here it is:

sc create SVN_CSTeam binpath= "c:\svn\bin\svnserve.exe --service --root D:\SVN\Repository" 
displayname= "Subversion Repository for CSharp.NET Team" depend= iisadmin

And that is why I do not use the default paths.  Spaces have to be delimited with quotes, which have to be escaped, and it just is not worth it.  All on one line of course.  Also note that the name after the "create" parameter can be anything desired and allows for multiple repositories on the same server, along with unique displayname.  I chose to use iisadmin as a depend, not because it necessarily is, but because it is sure to load other depends such as Tcpip and such.

The last step is to load AnkhSVN; a solution I leave to the reader.  It's not hard.  If you are familiar with source control at all, it is pretty obvious.


I'd like to thank the following sites for very useful information in helping me through the installation and the creating of this post:

Keywords: ,

Filed Under: .NET | Programming

Easy Image Tools (and FREE too!)

by fwhagen Thu, 08 May 2008

It amazes me in my travels how many people feel the NEED Photoshop for web development.  And, of course, they only use about 1% of its total capability.  It is true that years ago, it was the only game in town for Image creation and manipulation.  But not for a while now.  There are many free alternatives that suit the web developer much better.

Paint.NET My favorite for most tasks is Paint.NET.  It greatest feature is its price:  absolutely free!  It started life as a college project and was so successful, that it lives on as a great piece of Freeware development.  It is not Open Source, however.  Some of the other features include layering, filters, great image processing tools, alpha transparency, PNG, and many, many more.  All put together in a small, efficient package that is both easy to use and very powerful.  And hundreds of dollars less than Photoshop and lacking the disturbing Adobe trend toward spyware.  And as the name suggests, it is built on C#.NET, so I feel like I am supporting the community I am a part of.

GIMP If you need more, there is the GIMP project.  Much more complicated, far more powerful, still free, but not nearly as user friendly.  It resembles Photoshop in many ways, including the powerful plug-in model that PS uses.  I use GIMP 2.2 for things I cannot do in Paint.NET, which really isn't very often. 

You know, between the two, I don't at all miss the copy of PS I had at my last job.  Not at all.  Of course, I am not a graphic designer or a heavy Photographer either that needs the power of PS, but I haven't worked with many people who really were either.

One last note.  For those that have been heard to say, "[MS] Paint is good enough.":  Do yourself a favor and get Paint.NET.  MSPaint hasn't been good enough since the '90s.

Keywords: , ,

Filed Under: .NET | Programming | Work

Flash - Web Necessity or Overbearing Evil

by fwhagen Wed, 09 April 2008

Just why do I hate Flash requirements on sites so much?  I mean, every time I see a nice webpage marred by some Flash applet, I cringe and wonder why they decided to make that choice.

It used to be that requiring a user to have Flash installed just to visit your site was an inexcusable arrogance on your part as a web developer.  And then there was the bandwidth requirements for the content; after all, you are developing locally, so who cares that the end-user has to wait?  Well, you should, for starters.  And many times I see Flash, even still, being used as an easy way out or to simply animate a graphic. So historically, there were many, many reasons to never use Flash except for very specific applications.

Today, many of those arguments are not valid.  I believe all browsers have Flash preloaded, and bandwidth concerns are almost negligible anymore.  So why do I still find Flash to be a over-bloated gorilla on an otherwise clean design?  After all, I find the exclusion of PNG support on many browsers today to be inexcusable, but the inclusion of Flash a mere convenience.

Unfortunately, I don't have any clear answers.  To me, Flash doesn't belong on most websites I see today.  Yes, Flash does have it place in many online applications, but not as a graphic element.  And I believe that is the crux of the argument:  it is not a good replacement for some well designed image elements.  I am an old school developer that believes that good, solid, static design will always be superior to flashy, dynamic design in the long run.  Do not mistake that statement as a call to return to HTML as the primary development tool.  I refer to design; not content, which should always be dynamic, save of course for documentary content.  In my opinion, as a former CBT developer and current Intranet developer and BI Programmer, all design should be restricted to good use of CSS, PNG/GIF/JPG, and XHTML.  And there is also the fact that it is a closed standard.  Or actually, not a standard at all.  Flash is owned by Adobe, and is subject to their whims.  I just don't think that belongs in general web design from an end-user perspective, much the same way that I don't think it's right to use PDF as a publishing medium for web documents.

And don't even get me started on the crapware/bloatware/spyware that is a mark of Adobe products lately.  I flatly refuse to use Adobe's PDF reader anymore, but use Foxit Reader instead for any PDF files I might need to read.

Keywords: ,

Filed Under: Programming | Rant

Checking for Database NULL Values in C#

by fwhagen Tue, 09 October 2007

This really should have been more obvious to me, so why did I have to look it up?  If you need to check for NULL in a returned field from SQL (or any other datasource), you should the .Equals method on System.DBNull.Value.  I usually prefer the "==" notation for conditionals, but that's just me.  This is more efficient.  The code follows:

if (!dsSpecQuery.Tables[0].Rows[0]["device_type_end"].Equals(System.DBNull.Value)) 
{
    _EndDate = Convert.ToDateTime(dsSpecQuery.Tables[0].Rows[0]["device_type_end"]);
}

Of course, dsSpecQuery is a DataSet, and the field in question is DateTime out of SQLServer (not that it matters for the conditional).

Keywords: , ,

Filed Under: .NET | Programming | SQL

TextBox

RecentPosts