Sharing NuGet Packages Across Projects

by fwhagen Wed, 04 January 2017

Frequently, when developing multiple apps with a shared set of libraries, NuGet package sets can get out of hand. There’s no need for each project or solution to have it’s own set of libraries, and they should definitely not be in the repository.  I found this solution the other day to be most satisfying:

Create a file called nuget.config and place it in a common root directory for all the projects and solutions you want to share it.  Then fill it with the following:

    <add key="repositoryPath" value=".\Libraries\packages" />

Of course, you can use any value you wish.  I like to keep applications in subdirectories of .\Applications and shared libs in .\Libraries, but that’s me.  the way this works, according to NuGet docs, is the package handler searches for this file locally, then recursively up the folder structure from the project calling it, then a global file in your %appdata% directory.  When the file is absent, it defaults to the familiar behavior of creating the packages subdir in the solutions directory.

This gem has helped me a great deal.  Hopefully you too.


Filed Under: .NET | Programming

Today’s Date in PL/SQL

by fwhagen Fri, 25 July 2014

Here’s the other one I forget all the time.  Although it’s much easier than T-SQL, to get today’s date in an Oracle query, use:


as in:

SELECT TRUNC(sysdate) from dual;

Remember:  Don't pass a date as a string.  Use the system variables.


Filed Under: DataBase | Oracle | Programming

Today’s Date in T-SQL

by fwhagen Wed, 19 February 2014

I forget this one all the time:  I need today’s date in a SQL query.  In C# it’s DateTime.Today, and in T-SQL it’s:

DATEADD(Day, 0, DATEDIFF(Day, 0, GetDate()))

So a simple select that will return all of todays records will look like this:

SELECT * FROM TableName WHERE CompletedDate >= DATEADD(Day, 0, DATEDIFF(Day, 0, GetDate()))

Now I won't forget.


Filed Under: DataBase | Programming | SQL

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 or 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

Use Multiple Versions of Visual Studio and Want Pinned Solutions?

by fwhagen Fri, 13 January 2012

I need to have VS2005 and VS2008 installed for support of one of my clients, and of course I use VS2010 for my own development.  And I love the pinned list of solutions that VS10 offers.   In the past, I used a folder Toolbar in the Taskbar for listing solutions for easy access, but that was a maintenance task. 

TaskbarPinIn Windows 7, you can pin the Visual Studio Version Selector to the taskbar and pin items from Recent to Pinned (or do it manually as any other Win 7 file can be).  This has enhanced my productivity for the client without cluttering my taskbar or desktop at all.  Windows 7 continues to be the most useful environment I’ve ever use. 


Filed Under: Programming | System | Work

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:


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


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     

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.)


Filed Under: Programming