Friday, August 31, 2018

DATEDIFF in T-SQL may not be the best way to calculate how old someone is at a given point in time.

This...

Declare @age int = DATEDIFF(YEAR, @birthday, @afterbirthday)
SELECT @age

 
 

...merely subtracts one year from another leading to some nasty results. You may compensate like so:

Declare @age int = DATEDIFF(YEAR, @birthday, @afterbirthday)
Declare @birthdaymonth int = MONTH(@birthday)
Declare @afterbirthdaymonth int = MONTH(@afterbirthday)
if @birthdaymonth > @afterbirthdaymonth
BEGIN
   set @age = @age -1
END
if @birthdaymonth = @afterbirthdaymonth
BEGIN
   DECLARE @birthdayday int = DAY(@birthday)
   DECLARE @afterbirthdayday int = DAY(@afterbirthday)
   DECLARE @differenceindays int = @afterbirthdayday - @birthdayday
   IF @differenceindays < 0
   BEGIN
      set @age = @age -1
   END
END
SELECT @age

password protect directories in IIS

This touches on it some. You put an accessType rule in the Web.config as suggested here, only it looks like:

<add accessType="Deny" users="?" />

rouge app fail

Preethi Janakarajan who worked for Sumi Tharasingh at Veterans Affairs surprised me by wishing me a belated Happy Birthday this week. (I turned 44 a week ago today.) While we were at Veterans Affairs someone must have let her go crazy building some tables off to one side in the database of a larger app for her own purposes. This instead of taking her app seriously. She was just given a little play place off to one side. I don't need to tell you why this is bad, do I? Eventually, I had to work on the real app that "owned" that database and I got some code promoted into the various environments for it and all of her stuff was wiped out. Because it was some "little side project" (and the lesson here is to not treat projects as "little side projects") she didn't notice until a month later. I remember going into the backroom where administrators tried to pull archives and it was too late to get a snapshot. I think she did her thing outside of production so the other environment just didn't have a rich history of backups as it wasn't taken as seriously. I'm sorry Preethi!

Thursday, August 30, 2018

SUSER_NAME() and SUSER_SNAME() in T-SQL

Both give you the user name and this suggests that SUSER_SNAME() uses the security identification number (SID) string, whatever that is, while SUSER_NAME() uses principal_id, an integer, to calculate the name it returns to you.

Make a T-SQL stored procedure that can generically insert to a set of columns and a table specified from the outside.

IF OBJECT_ID(N'dbo.Attempt_Generic_Insert') IS NULL
BEGIN
   PRINT 'Create procedure : dbo.Attempt_Generic_Insert'
   EXECUTE('CREATE PROCEDURE dbo.Attempt_Generic_Insert AS RETURN 0')
END
GO
ALTER PROCEDURE [dbo].[Attempt_Generic_Insert]
(
   @TableName varchar(max),
   @ColumnSet Column_Setting READONLY
)
AS
BEGIN
DECLARE @LeftHalf varchar(max) = 'INSERT INTO [' + @TableName + '] ('
DECLARE @RightHalf varchar(max) = ']) VALUES ('
DECLARE @FullInsert varchar(max)
DECLARE @LeadWithComma bit = 0
DECLARE @ColumnSetName varchar(255)
DECLARE @ColumnSetSetting varchar(255)
DECLARE @ColumnSetEnclosedInQuotes bit
DECLARE curs CURSOR FOR SELECT * From @ColumnSet
OPEN curs
   FETCH NEXT FROM curs into @ColumnSetName, @ColumnSetSetting,
         @ColumnSetEnclosedInQuotes
   WHILE @@FETCH_STATUS = 0
   BEGIN
      SET @LeftHalf = @LeftHalf + CASE @LeadWithComma WHEN 1 THEN '], [' ELSE
            '[' END + @ColumnSetName
      SET @RightHalf = @RightHalf + CASE @LeadWithComma WHEN 1 THEN ', ' ELSE
            '' END
      SET @RightHalf = @RightHalf + CASE @ColumnSetEnclosedInQuotes WHEN 1
            THEN '''' ELSE '' END
      SET @RightHalf = @RightHalf + @ColumnSetSetting
      SET @RightHalf = @RightHalf + CASE @ColumnSetEnclosedInQuotes WHEN 1
            THEN '''' ELSE '' END
      SET @LeadWithComma = 1
      FETCH NEXT FROM curs into @ColumnSetName, @ColumnSetSetting,
            @ColumnSetEnclosedInQuotes
   END
CLOSE curs
DEALLOCATE curs
SET @FullInsert = @LeftHalf + @RightHalf + ')'
EXECUTE(@FullInsert)
END

 
 

Alright, a few things to note... First, this will clearly blow up if a required column is left out, so the guts of this thing should really be wrapped in some try/catch logic. An error message should be returned if an error exists. Secondly, the line reading...

EXECUTE(@FullInsert)

 
 

...often times can be represented as...

exec sp_executesql @FullInsert

 
 

...I just couldn't get it to work in this case. Also we need a type named Column_Setting and that can look like this:

CREATE TYPE [dbo].[Column_Setting] AS TABLE(
Name varchar(255) NOT NULL,
Setting varchar(255) NOT NULL,
EncloseInQuotes bit NOT NULL,
PRIMARY KEY CLUSTERED
(
   Name ASC
   )WITH (IGNORE_DUP_KEY = OFF)
)

 
 

Assuming this table...

CREATE TABLE dbo.Cat
(
   CatId int IDENTITY NOT NULL,
   Name varchar(255) NOT NULL,
   LivesRemaining int NOT NULL,
   Birthdate datetime NULL,
   IsFluffy bit NOT NULL
)

 
 

...we could insert to it like so:

DECLARE @TableName varchar(max) = 'Cat'
DECLARE @ColumnSet Column_Setting
INSERT INTO @ColumnSet VALUES ('Name','Shadow',1)
INSERT INTO @ColumnSet VALUES ('LivesRemaining',9,0)
INSERT INTO @ColumnSet VALUES ('Birthdate','8/24/1974',1)
INSERT INTO @ColumnSet VALUES ('IsFluffy',1,0)
EXEC Attempt_Generic_Insert @TableName, @ColumnSet

Wednesday, August 29, 2018

check in T-SQL to see if a Type exists

Use this...

IF TYPE_ID(N'dbo.Aardvark') IS NULL

 
 

...instead of this:

IF OBJECT_ID(N'dbo.Aardvark') IS NULL

Tuesday, August 28, 2018

.sqlproj project is "incompatible" in Visual Studio 2017

I ran into a problem in which I would open a solution in Visual Studio 2017 and next to a .sqlproj file's (a SQL Server Database Project) project in the Solution Explorer was "(incompatible)" and any attempt to expand the project and look at what was inside would furthermore yield "The application is not installed." instead of showing actual files. In Googling against this problem I found some suggestions that perhaps I didn't have something installed in Visual Studio 2017 and so I used the Visual Studio Installer to install everything imaginable but nonetheless this did not solve the issue. What was more, I seemed able to make a new, different SQL Server Database Project side by side with the one that didn't work. I ultimately beat the bug by removing the project form the solution and then readding it. Now it's happy.

Make a button in a WinForms application that just closes the app.

private void button1_Click(object sender, EventArgs e)
{
   Application.Exit();
}

 
 

...assuming that in the .Designer.cs file you have a wire up like so:

this.button1.Click += new System.EventHandler(this.button1_Click);

SAW or secure access workbench

another way to access a computer beyond a VPN (Virtual Private Network) or Citrix or the things mentioned here?

WinRM and Telnet

Telnet is a tool for seeing if you can hit a particular server at a particular port without being blocked by a firewall. I think you quit the shell by either typing "quit" or with just the "q" key. WinRM (Windows Remote Management) is a remote manager which allows you to push commands to other environments from afar. You run its commands at the command prompt in Windowland and this command barfs up what is in the configuration file:

winrm get winrm/config

 
 

This command alters a key in the configuration file:

winrm set winrm/config/client @[TrustedHost="*"]

Pass something into the arguments for an executable from the command line.

I made a WinForms app and I jammed in string[] args as seen here at a console app in my in Visual Studio 2017 dabblings. I made an installer for the WinForm app, and I ran the installer and then figured out where it put the .exe executable file. I navigated to that folder at the command prompt and then ran the executable by passing a variable to it like so:

foo.exe bar

 
 

"bar" ended up as the first string in string[] args

Request Filtering in ISS 7 and up.

This touches on it some. You can deny the HEAD verb and other verbs you should never use (OPTIONS, TRACE, PROPFIND, COPY, LOCK, UNLOCK, PROPPATCH, MKCOL, MOVE) which are security holes.

verb tunneling

POST to an endpoint and then use the X-HTTP-Method-Override header to swap the POST to another verb like so per this example:

POST /drive/items/{item-id} HTTP/1.1
Host: api.onedrive.com
X-HTTP-Method-Override: DELETE

 
 

This has a how to on blocking specific headers to remove this as a security hole.

redirect web traffic to secure URLs

You may make http:// traffic redirect to https:// URLs in the name of security at IIS 7 and up per this.

Hub Connect

...is a generic user community. You may spin up a Hub Connect instance for any topic. It is web-based.

Windows Exe Runner Plugin

Per this, it should allow you to kick awake an executable in a Windows environment from the Jenkins build tool. You can pass arguments on to the .exe too.

Monday, August 27, 2018

Get a list of certificates in a given Windows environment from C#.

The Certificate POCO below is my own invention. Don't read too much into it. I'm just keeping X509Store from bleeding out of the infrastructure layer.

using System;
using System.Collections.Generic;
using RefreshCerts.Core.ExternalDependencies;
using System.Security.Cryptography.X509Certificates;
using RefreshCerts.Core.Objects;
 
namespace RefreshCerts.Infrastructure.ExternalDependencies
{
   public class CertificateAuditing : ICertificateAuditing
   {
      private Dictionary<string, StoreName> storeNames = new Dictionary<string,
            StoreName>()
      {
         { "AddressBook", StoreName.AddressBook },
         { "AuthRoot", StoreName.AuthRoot },
         { "CertificateAuthority", StoreName.CertificateAuthority },
         { "Disallowed", StoreName.Disallowed },
         { "My", StoreName.My },
         { "Root", StoreName.Root },
         { "TrustedPeople", StoreName.TrustedPeople },
         { "TrustedPublisher", StoreName.TrustedPublisher }
      };
      
      public List<Certificate> Audit(int days, ITimekeeping timekeeping)
      {
         List<Certificate> certificates = new List<Certificate>();
         DateTime future = timekeeping.GetDate().AddDays(days);
         foreach (KeyValuePair<string, StoreName> storeName in storeNames)
         {
            X509Store store = new X509Store(storeName.Value,
                  StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadOnly);
            foreach (X509Certificate2 certificate in store.Certificates)
            {
               if (certificate.NotAfter < future)
               {
                  certificates.Add(new Certificate()
                  {
                     Locale = storeName.Key,
                     Name = certificate.FriendlyName,
                     SerialNumber = certificate.SerialNumber,
                     TimeToDie = certificate.NotAfter
                  });
               }
            }
         }
         return certificates;
      }
   }
}

git-flow by Vincent Driessen

This is a model for Git branching. In it there are two main branches, a master branch (which is what it sounds like) and a development branch which might be published to a UAT server if not a production server like master. Well, I'm assuming the part about the servers. The things to see really are that there is a master branch and a sister, almost equal, branch for development. The development branch gets branched by developers into feature branches and eventually the feature branches get merged back into the development branch. The development branch gets merged to master and the master branch gets merged back to development. Why does the master branch get merged back to development? Because hotfixes are branched off of the master branch and then merged back up to the master branch. git-flow might be gitflow without the hyphen. I'm not sure.

branching and merging with the GitHub Desktop

Under the Branch menu you will be able to make a new branch. When you are back at the master branch you may pull in a different branch from the same menu with the "Merge into current branch..." option.

Anaconda is a platform for data science that is of Python.

It is now something that you may have in Visual Studio 2017 too.

The Uber app has its own proprietary maps.

A driver was venting to me tonight about how he used to be able to use Google Maps but now may no longer do so.

Saturday, August 25, 2018

Bryne Software's joint ownership of estimates.

I interviewed at and accepted a job at Bryne Software in this latest round of job hunting, and it would have allowed me to stay in the St. Louis area given that it was in Chesterfield, but ultimately the job in Minnesota trumped that. Anyhow, Bryne is a product company offering two core products that have to do with roadway infrastructure civil engineering stuff and beyond that they also do custom consulting for their clients and therein comes the whole challenge of trying to scope a project to x number of hours when doing an estimate. The estimating game is of course tricky stuff. A lot of times, and really most times, from a sales perspective, you cannot just talk a client into an Agile process where they pay sprint-to-sprint. Towards the end of my time at Headspring the plan was to try to do estimates and then just bail if development got partway in and the estimate seemed way off. For example, if something was estimated as taking twenty hours of work and then, ten hours in, it became obvious that there was another hundred hours of work left to go, Headspring would just give the client back all of their money and wash their hands of it. Bryne had another approach in which several team members all dog-piled their thoughts into an estimate and there was joint ownership of the estimate. This was intriguing.

I went on a gondola ride at the Minnesota State Fair today.

What clunky tech. I was waiting for it to fall out of the sky honestly.

Friday, August 24, 2018

super painful to try to run PowerShell scripts form C# on Windows 7

At: Tools > NuGet Package Manager > Manage NuGet Packages for Solution... ...in Visual Studio 2017, I searched for "System.Management.Automation" and referenced a .dll in the NuGet package pulled down only to see this error:

Could not load file or assembly 'System.Management.Automation' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

 
 

I get the impression that I do not have something I can't install on my work laptop. That's preventing me from doing something like:

using (PowerShell PowerShellInstance = PowerShell.Create())
{

 
 

...in code which should be legit per this. I had hoped to run a script like this one, but I am talking myself out of that now and betting that it is better to just tackle the problem from the C# side like this.

Thursday, August 23, 2018

Make a Windows Service in Visual Studio 2017.

Pick: File > New > Project... ...to get the "New Project" dialog box. Once there, you want the "Windows Service (.NET Framework)" under "Windows Desktop" under "Visual C#" and if this is not there use the Visual Studio Installer to install stuff.

get a list of certificates about to expire from PowerShell

This has hints like GET-COMMAND *CERT* for getting a list of PowerShell commands that have the word cert inside, and in saying a great many things, it eventually allowed me to figure out how to get a list of certificates that are about to expire at a Windows environment out of PowerShell. Here are the steps:

  • Run set-location cert: at the root of the C drive to change into an environment where there is a hierarchy of certificates not unlike what one sees when one types certmgr.msc at the command line in Windows 7 to spawn a dialog box for browsing certificates.
  • set-location localmachine will drill a level deeper. Do this next. At this point get-childitem should list some of the categories of certificates and you may do a set-location into any one of them and then a get-childitem inside to see the certificates. However there isn't really a need to do so.
  • get-childitem -recurse -expiringdays 42 is supposed to list all the certificates that are to expire in the next forty-two days, but I couldn't get this to work for me and I would end up with an error reading specifically A parameter cannot be found that matches parameter name 'ExpiringInDays' prompting the likes of get-childitem -Recurse | where { $_.notafter -le (get-date).AddDays(42) -AND $_.notafter -gt (get-date)} | select thumbprint, subject as a workaround.

 
 

Addendum 8/25/2018: get-childitem cert:\\ lists the CurrentUser and LocalMachine sublocations per jdgonzalez without changing locations and I have along the same lines also found that get-childitem cert:\\LocalMachine will similarily show us what is in LocalMachine.

Universal Time Coordinated

...should be what the Utc stands for in DateTime.UtcNow

A tilde followed by a line return is at the end of every "column" of a record in an EDI file.

At the end of a record of data is a line starting with: SE

Dynatrace

...is a company in the APM (application performance management) space offering at least one monitoring-flavored product.

Wednesday, August 22, 2018

Ilasm.​exe

This gets installed with Visual Studio and more specifically the .NET Framework. It compiles code of Intermediate Language (IL) to .dll library files and .exe executable files. Common Intermediate Language (CIL) is even more generic than the CLR (Common Language Runtime) code that C# and VB.NET compiles to. I think the CLR compiles down to CIL too, but introduces type safety not in the CIL.

PathLocationStrategy and HashLocationStrategy are rivals.

The former is the default way of doing URL routing midstream into a SPA (single page application) in Angular 5 which is not supported by all browsers and the later is the trick in which a hashtag is introduced at the URL line quickly after the domain name and only the stuff after the pound sign changes around allowing support for all browsers. You have to explicitly turn the trick with the numbers symbol on. Both things have been mentioned at this blog before but page 135 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis explicitly juxtaposes the two so I will mention it here.

querying sys_modules from master (not a particular databae) in T-SQL

As best as I can tell...

USE Yin;
GO
DECLARE @Search varchar(255)
SET @Search='Yang'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1

 
 

...may be rewritten like so...

DECLARE @Search varchar(255)
SET @Search='Yang'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM [Yin].sys.sql_modules m
INNER JOIN [Yin].sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1

 
 

...you just have to enclose the database name in square brackets. This suggests you cannot use OBJECT_NAME() and OBJECTPROPERTY() when switching databases in this shape and if you attempt to do so it will not work. You have to find a workaround for these tricks.

Use numeric values in an ORDER BY clause in T-SQL.

In this example of ORDER BY 2,1 we are sorting the table of data returned by the second column first and then the first column.

Tuesday, August 21, 2018

The CSS approach to comments is also legit in T-SQL.

You may do this in T-SQL too. A forward slash followed by an asterisk opens a comment and an asterisk followed by a forward slash closes the comments. The swath of stuff between the two endcaps may be several lines long.

XMLDocumentationFile.xml

These are documentation files made by the CodeDOM in a .NET/C# application. The CodeDOM is, as strange as it sounds, the logical structure for your source code, probably in a tree shape with the ability to drill down a branch and look at things nested in things, etc. This has some more on it.

Present only the first three decimal places of a decimal in C#.

It is a bit uglier than the two decimal place currency formatting:

return myDouble.ToString("#.000");

 
 

Addendum 8/22/2018: It turns out that this formatting needs some love. If the number before the decimal place is zero, the zero won't show up. That can be fixed like so:

private string DressUp(double foo)
{
   string bar = foo.ToString("#.000");
   if (bar[0] == '.') return "0" + bar;
   if (bar[0] == '-' && bar[1] == '.') return bar.Replace("-","-0");
   return bar;
}

Ron, Adi, and Leonard

If you go to an https address in Internet Explorer a padlock should appear in the URL line and if you click on this icon there should be a "View certificates" link shortly showing up which will open a "Certificate" dialog box in Windows 7 and let you know some things about the SSL certificate such as the use of sha256RSA for the signature algorithm and sha256 for the Signature hash algorithm perhaps. In security, RSA stands for Ron Rivest, Adi Shamir and Leonard Adleman who founded RSA Security, Inc. which is now RSA Security LLC. SHA is Secure Hash Algorithm.

Monday, August 20, 2018

Did you know that you may do an INSERT in T-SQL without specifying the column?

If you just match the number of columns you may insert into this table like so:

INSERT INTO People VALUES (newid(), 'Zella', 'Iowa', 'United States')

 
 

Crazier yet, something I saw at work today had me believing that if one of the columns is an auto-incrementing numeric id that you just leave its value out when you do an insert like this.

Sunday, August 19, 2018

FileMaker Pro

...is another corny tool for making a line-of-business application.

recruiters

I was a contractor for Experis when I worked at @hand. It's worth mentioning because Experis does tech recruiting as a company owned by Manpower which does staffing in general. You don't hear the name Manpower so much anymore, but they were very famous back in the 1990s, not unlike Volt. Technology Navigators found me for Paymetric. I worked for Artech at Wells Fargo Advisors and presently I am working for Apex at Optum.

Friday, August 17, 2018

add new features to Visual Studio 2017

Per this, you should be able to type "Visual Studio Installer" at the Start Menu at Windows 7 to reenter the wizard where you picked things to install initially to begin with. Then you may pick new things and have them installed. Yay!

 
 

To fix this error...

The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <Using Task> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin" directory.

 
 

...add "NuGet package manager" and "NuGet targets and build tasks" under the "Code tools" subsection of the "Individual components" tab.

yet another way to sanity check a SqlParameter against DBNull in C#

double? foo = null;
SqlParameter fooParam = command.Parameters.Add("@Foo", SqlDbType.Float);
fooParam.Direction = ParameterDirection.Output;
if (foo.Value == DBNull.Value)
{
   foo = null;
}
else
{
   foo = ((double)(fooParam.Value));
}

I have a friend who could interact with a GET REST endpoint via Fiddler and Postman, but could not see it in an Angular application or even at the URL line of a browser.

Her issue, which made my head want to explode, turned out to be an inappropriate default port setting at IIS.

Thursday, August 16, 2018

another journal entry

So far Minnesota is fine. Of course the real test will be the wintertime. The summer is forgiving. Minnesota is the land of 10,000 lakes. And, I visited one of them, Staring Lake, for the first time today and took the pictures here.

Staring Lake sits inside of Staring Lake Park which sits inside of Eden Prairie, Minnesota. It seems like a pretty chill place to go for a stroll. I still try to walk two miles every day though my discipline for as much keeps decaying.

I don't want to be fat. I should try to get it together, you know?

Check to see if a varchar type column is null or holding an empty string in T-SQL.

See the last line below. (The others are just setup for the last line.)

BEGIN TRANSACTION
GO
CREATE TABLE dbo.People
   (
   Id uniqueidentifier NOT NULL DEFAULT newid(),
   Name varchar(50) NOT NULL,
   [State] varchar(50),
   Country varchar(50) NOT NULL
   ) ON [PRIMARY]
GO
ALTER TABLE People ADD CONSTRAINT
   PK_CarPart PRIMARY KEY CLUSTERED
   (
   Id
   ) WITH( STATISTICS_NORECOMPUTE = OFF,
      IGNORE_DUP_KEY = OFF,
      ALLOW_ROW_LOCKS = ON,
      ALLOW_PAGE_LOCKS = ON)
COMMIT
INSERT INTO People (Name, [State], Country) VALUES ('Abe', 'Texas', 'United States')
INSERT INTO People (Name, Country) VALUES ('Jenny', 'Canada')
INSERT INTO People (Name, [State], Country) VALUES ('Karen', 'Minnesota', 'United
      States')
INSERT INTO People (Name, Country) VALUES ('Mike', 'Mexico')
INSERT INTO People (Name, [State], Country) VALUES ('Robbie', 'California', 'United
      States')
INSERT INTO People (Name, Country) VALUES ('Wendy', 'Canada')
INSERT INTO People (Name, [State], Country) VALUES ('Zach', 'Florida', 'United
      States')
GO
SELECT Id, Name, [State], CASE IsNull([State], '') WHEN '' THEN Country ELSE null
      END AS Country FROM People

 
 

This trick is a little like this one only it will also match on an empty string. In figuring this out I found this Stack Overflow article that has these examples of a slightly different shape:

  • Select *
    From Table
    Where (col is null or col = '')

     
  • Select *
    From Table
    Where IsNull(col, '') = ''

Venafi

...as a company develops software for protecting keys and certificates.

A file with a .dat extension is a data file.

When you look inside (in Notepad perhaps) you just see sort of a flat file representation of database records to be with columns separated by spaces and rows by line returns and no indication as to where the data is meant to go live beyond perhaps the name of the file itself. How the data gets used is not dependent on any one program. The .dat convention really is just a convention for passing data around and how it gets sucked into something else is up to you.

Wednesday, August 15, 2018

Interacting with registry keys from C# should be a little different depending on whether you are in an x32 or x64 environment.

The approach to fishing something out of the registry needs to vary conditionally.

public string Fish(string lure)
{
   string fishingGrounds = @"SOFTWARE\Something\Er\Other\";
   if (!_myHashtable.ContainsKey(lure))
   {
      if (Environment.Is64BitOperatingSystem)
      {
         RegistryKey fish = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
               RegistryView.Registry64).OpenSubKey(fishingGrounds);
         _myHashtable.Add(lure, fish.GetValue(lure));
         fish.Close();
      }
      else
      {
         RegistryKey fish = Registry.LocalMachine.OpenSubKey(fishingGrounds);
         _myHashtable.Add(lure, fish.GetValue(lure));
         fish.Close();
      }
   }
   return _myHashtable[lure].ToString();
}

 
 

Environment is in the System namespace (System.Environment) and the registry flavored stuff is in the Microsoft.Win32 namespace.

isolation of external dependencies

I took these pictures of the Eden Prairie Marketcenter Water Tower in Eden Prairie, Minnesota today. The thing is adjacent to my apartment complex, Cascade at Town Center, which is also shown here.

The Wikipedia write up on Eden Prairie namedrops the Cummins-Phipps-Grill House as if it is something to see, but there is really nothing special about it. It is merely the site of the first farm. The only landmark to see that is memorable in the otherwise generic suburban cityscape with a little too much sprawl is the gaudy water tower that has clocks on it. This is a good time to remind you that the timekeeping is an external dependency in a C# application and it should be walled off into the infrastructure project in a Visual Studio solution per the Onion Architecture. The infrastructure project will inherit the core logic project which will have interfaces that the external dependencies (classes) in the infrastructure project implement. The UI project will inherit both the core and the infrastructure projects and use some IoC machinery to hydrate the interfaces with the dependencies. From there the interfaces are passed around to do things with the dependencies. Specifically, they are handed into method signatures (and Controller constructors) consistent with the D in the SOLID Design principles. The water tower example of keeping your timekeeping with your "data" if you will is a good one. The wrong thing to do is to sprinkle DateTime.Now all over the codebase.

A menacing spiked fence surrounds the base of the water tower. The analogy to be had here is that the external dependencies need to be walled off. The sending of emails, web services out to gunk you don't control or for that matter page scrapping of gunk you don't control, that SalesForce account, and flat file reads and writes are all external dependencies.

Other names for the banana box syntax of two way data binding in Angular include banana brackets and box of bananas.

You are supposed to visualize that the parenthesizes are inside the square brackets so that you do not put them on the outside. The names and their intent are explained on page 133 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis which also mentions that you may replace [(ngModel)]="something.er.other" with [ngModel]="something.er.other" to merely hand a property into a control (input, textarea, etc.) in lieu of doing two way data binding. Cool stuff.

Tuesday, August 14, 2018

jam JavaScript for web form validations into the C# code behind and have it bubble up to the HTML markup?

You may do so like this...

this.Head.LocalValidateContent.Add("if (pageForm.reviewName)");

 
 

...and not just this one line of code. This one line of code would be chased with several just like it which will add up to a JavaScript script. Ghetto!

Enterprise log in for GitHub Desktop

At: File > Options... ...there will be options for GitHub.com and Enterprise and you will want to pick Enterprise to get on your work's GitHub account. You will first be asked for a URL to the server. Then you will be prompted for a username and a password for that server.

Monday, August 13, 2018

When you cannot double-click on a .reg file to put something in the Windows 7 registry...

There may be a workaround. There is at my environment. At the start menu I can type regEdit at the start menu and, without pressing Enter, where regEdit appears at the start bar, I can right-click on regEdit and pick Run with Administrative Privileges (Audited) to run Registry Editor as administrator. From there I can go File > Import... to import a .reg file.

Overstock is a dying rival to Amazon.

I can't tell you what they did wrong and what Amazon got right. Amazon differently did a better job of marking itself and becoming a household name. Even in the dotcom era when they weren't yet turning a profit they had others speaking of them like they were legit.

Friday, August 10, 2018

Make a branch off of master through the GitHub Desktop desktop client.

Just go to: Branch > New branch... ...to do so. If you are like me, you will need to delete index.lock out of the .git folder in the root of the file tree as otherwise GitHub Desktop will complain about how something is using the file and it cannot rewrite the file.

Oracle has a feature called Flashback Database.

It keeps old snapshots in a cache and is memory expensive. You may recreate old data with queries like so:

SELECT * FROM MyTable AS OF '2018/03/17 13:23:45'

 
 

Addendum 8/13/2018: The query above is probably wrong. See: this

Thursday, August 9, 2018

social commentary

Popbitch is a British celebrity gossip news feed. I played with the Tik Tok application some for the first time today. The popular video clips that get voted up to appear in the default feed are quite voyeuristic.

Add something to your Windows 7 registry with a file with the .reg file extension.

You could just double-click on YOURNAMEHERE.reg to make it run. There will be stuff inside like this:

Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Foo]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Foo\Bar]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Foo\Bar\Baz]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Foo\Bar\Baz\Qux]
"AuditLevel"="0"
"AuditQueuePath"=".\\Private$\\auditqueue"
"ConnectionString"="
use your imagination..."

Set As Start Page

Right-click on an .aspx file in a web forms application in Visual Studio 2015 and pick "Set As Start Page" to make that .aspx web form run when the app launches instead of Default.aspx which is the default. (old school)

To reference one Visual Studio project from another in Visual Studio 2015...

...right-click on the References folder at the project that is to do the referencing and pick "Add Reference..." which should let you browse for the other project. I am just now realizing that my blog didn't have anything about this. What references what and if there is the Dependency Injection variant of Inversion of Control in the mix can mean the difference between Onion Architecture and the three layers approach of yore that is much harder to unit test. In the .NET Framework days StructureMap ended up being the default IoC contatiner. In .NET Core, you don't need StructureMap as IoC is baked right in.

cannot find \Version\AssemblyVersionInfo.cs

I got this error when trying to build a solution in Visual Studio 2015 that I pulled out of source control recently. To fix it, I closed Visual Studio and opened a lot of the .csproj files for the projects in Notepad to see something like this amid the XML inside each one:

<ItemGroup>
   <Compile Include="..\Version\AssemblyVersionInfo.cs">
      <Link>AssemblyVersionInfo.cs</Link>
      <SubType>Code</SubType>
   </Compile>
   <Compile Include="AssemblyInfo.cs">
      <SubType>Code</SubType>
   </Compile>
   <Compile Include="Milliman.cs">
      <SubType>Code</SubType>
   </Compile>
</ItemGroup>

 
 

Getting rid of the first "Compile Include" and resaving the files fixed the error. What is above thus becomes:

<ItemGroup>
   <Compile Include="AssemblyInfo.cs">
      <SubType>Code</SubType>
   </Compile>
   <Compile Include="Milliman.cs">
      <SubType>Code</SubType>
   </Compile>
</ItemGroup>

UltraEdit and Aspose

UltraEdit is a text editor like Notepad++ and Aspose is an API for converting one file format to another including wacky things like JasperReports (Java's SSRS) which I had not heard of before. I heard of both UltraEdit and Aspose today, but they have nothing to do with each other. Oracle has Oracle AWR Reports in which AWR stands for Automated Workload Repository.

Wednesday, August 8, 2018

Drag a box around a vertical selection in SSMS.

This trick of holding Ctrl and Alt together and dragging the mouse works just as well in Microsoft SQL Server Management Studio 2014 as it did back in what must have been Visual Studio 2010 when I wrote the blog posting I refer to here. As an example, if you had the following in a query window in SSMS...

SELECT * FROM Billiards WHERE locale = 1
SELECT * FROM Billiards WHERE locale = 2
SELECT * FROM Billiards WHERE locale = 3
SELECT * FROM Billiards WHERE locale = 4
SELECT * FROM Billiards WHERE locale = 5
SELECT * FROM Billiards WHERE locale = 6

 
 

You could select the word liar in Billiards across all six lines and then type "foo" to change the copy to:

SELECT * FROM Bilfoods WHERE locale = 1
SELECT * FROM Bilfoods WHERE locale = 2
SELECT * FROM Bilfoods WHERE locale = 3
SELECT * FROM Bilfoods WHERE locale = 4
SELECT * FROM Bilfoods WHERE locale = 5
SELECT * FROM Bilfoods WHERE locale = 6

 
 

Warning: When you show this to your coworkers their heads will explode.

Tuesday, August 7, 2018

An analyst should bake stories at least a week in advance of developers working on them in an Agile process.

Chewing things up into swallowable chunks in this manner, and getting the requirements rolled, and furthermore being out front ahead of things proactively by dedicating a dedicated role to as much keeps the team from falling into a lull or others going: "What do I do?" In a recent project, one UX talent rolled off the team and was replaced by a fresh face who didn't have the political skill to get mock ups approved quickly and there ended up being a two month lull. This could have been avoided if we weren't doing things the waterfall way and we had started with baking stories. The same project went into red status when, after five months of work, the data team had nothing to show and there had to be an admission out loud that the guess at a timeline to begin with was bad. This sort of thing can be caught before five months slip by if an analyst bakes stories. When a three point story takes one hundred points to do, something is awry and you need to course correct.

semantic search

Wikipedia suggests: "Semantic search seeks to improve search accuracy by understanding the searcher's intent and the contextual meaning of terms as they appear in the searchable dataspace, whether on the Web or within a closed system, to generate more relevant results. Semantic search systems consider various points including context of search, location, intent, variation of words, synonyms, generalized and specialized queries, concept matching and natural language queries to provide relevant search results."

use COLLATE when doing a CREATE TABLE in T-SQL to specify a culture at a particular column to be

CREATE TABLE Cat
(
   CatId INT NOT NULL IDENTITY,
   Name VARCHAR(50) COLLATE Latin1_General_CI_AS,
   Gender CHAR(1) COLLATE Latin1_General_CI_AS,
   LivesLeft INT,
   CONSTRAINT PK_Cat PRIMARY KEY (CatId)
);

 
 

Note that, per this, CHAR and NCHAR are fixed widths, exactly n long, and VARCHAR and NVARCHAR are of variable lengths, up to n long. CHAR and VARCHAR cannot handle Unicode characters while NCHAR and NVARCHAR may.

Monday, August 6, 2018

12/31/9999 is the last day of the DATETIME in T-SQL

Year 802701 in H. G. Wells' Time Machine or year 10191 in Frank Herbert's Dune cannot be represented.

FLOAT vs. REAL in T-SQL

The single number specified when making a FLOAT type column in T-SQL is the number of bits to allocate for space. 1-24 creates a 7 digit precision and 25-53 digits specifies a 15 digit precision. A REAL type column is equal to a FLOAT(24) type column. See this and this for more. An example:

CREATE TABLE Cat
(
   CatId INT NOT NULL IDENTITY,
   Name VARCHAR(50),
   LivesLeft FLOAT(24),
   LivesToBeginWith REAL,
   CONSTRAINT PK_Cat PRIMARY KEY (CatId)
);

 
 

The number for FLOAT is as scary as the shadow of this seemingly pretty girl I took a photo of at the Hahn/Cock sculpture of Katharina Fritsch at the Minneapolis Sculpture Garden yesterday. How obtuse and confusing.

When a project goes into red status...

You're not going to meet your timeline and budget. Something is really wrong. It's time for that tough meeting with the higher-ups. Oh no. There is obviously also a green status for when things are going well and a yellow status for when things are not going so well but things are not yet redly grave. This is a project-wide setting in a Waterfall approach. I saw the convention at both AMD and Wells Fargo Advisors. One-on-one weekly meetings with your superior is something else I have seen at both @hand and Paymetric, and if you are paying attention you can tell if you yourself are in red, yellow, or green status. When you hear "and I've never given up on you" every meeting you are in red.

Sunday, August 5, 2018

Catholic Cagematch: St. Paul vs. St. Louis

The miracle associated with Paul the Apostle before his canonization was that in a period of three days of temporary blindness an encyclopedic knowledge of Christianity was instilled in his mind making him arguably the best teacher of it in the middle of the first century. It's kinda like that scene in the "The Matrix" where Neo suddenly states "I know Kung Fu." I guess you could make other tech analogies too. It could be as simple as downloading a JSON packet from an API endpoint, really. If it takes three days maybe it's some sort of data migration. The state capital named for St. Paul in Minnesota, the second largest city in the land of ten thousand lakes after adjacent Minneapolis with which it comprises the Twin Cities, is not a city like San Francisco or Seattle or Austin or those of the blossoming North Carolina space (Charlotte, Greensboro, Raleigh, er... well, Cary, etc., maybe not so much Asheville) that brings to mind tech when you think of it. Instead it is a forgotten Midwestern bit of urban nowhere, not unlike St. Louis, Missouri. That said, there is more tech than you might expect in both environments, and all while they are wearing the dunce cap of not-a-tech-town. Google suggests that software engineer salaries are twelve percent below the national average in the Twin Cities and thirteen percent down, with average Joe dev not even clearing a 70K salary, in St. Louis. However, even as you are underpaid, you are not marooned. When one job ends, there is another to be had easily. St. Louis loses the cagematch because I've moved to the Twin Cities for a new job. The photo here of St. Laurence at the Minneapolis Sculpture Garden was taken just today. One of the deciding factors was more money. The Twin Cities have a lot of money going on by way of being a major healthcare hub and having a healthcare identity. There is not really an industry the economy of St. Louis is associated with in contrast. There are a bunch of random opportunities to be had there and many of them are blue collar and low wage. If you go far enough back in time, America acquired St. Louis from the French in the Louisiana Purchase, and thus, back before that, it was all French-controlled. The St. Louis for which St. Louis is named is one of the kings of France, Louis the 9th, who went on to be a saint beyond being a king. I guess he significantly impressed the Catholic Church. As an atheist I used to think that was all there was to being a saint, that it was a posthumous trophy, however my sister asked me one day about St. Louis and what the miracles associated with him were and I was surprised to realize that you also have had to do something pretty special to be a saint beyond merely being an A student of Christianity. In at least a few instances, St. Louis supposedly made the blind see and the lame walk. I don't get the impression that he had the healing stat cranked up to a 10 like St. Clair or was able to fix people at will. Instead when he wasn't busy being a good king he earned a little extra street cred on the side. By the way guys, I don't recommend that you cheat on your day job by contracting part time. The distraction won't make your résumé like it did for St. Louis. It'll just... Well, now I'm off topic.

I've moved to Eden Prairie, Minnesota.

Some notes from the first week at work at the new job:

  • Change audio output in Cisco Jabber by clicking on the gear at the upper right picking "Options..." and then "Audio" under the "Options" dialog which appears. Change the "Speaker:" setting and remember to press the "Apply" button once you do. When making a phone call from Cisco Jabber, be sure to add the leading +1 before the ten digit telephone number or else the call "cannot be completed as dialed" and you don't want to have hyphens in the phone number either. Just have eleven numbers with a leading plus sign.
  • Jabra is an electronics company that does headsets. Their take on tech reduces both fatigue and audio spikes.
  • IBM Tivoli Workload Scheduler is yet another job scheduling tool.
  • Wonderbox Technologies has some canned software for healthcare services, recordkeeping for medical records, etc.
  • Flowdock for a tool to augment CA Technologies Rally which both has a mobile app (get updates whenever a ticket changes) that allows you to put stuff into Rally and also has capabilities to allow you to talk to your Rally teammates.
  • Per this, RAISERROR in T-SQL is not really an exception but a message and it will not return anything until the whole of the stored procedure it is in wraps up. Chase RAISERROR implementations with WITH NOWAIT to make them spit out a message the moment the line of code is run. Changing subject somewhat slightly, SET LOCK_TIMEOUT 3600000 in T-SQL denotes the number of milliseconds that may pass before a locking error is thrown. In this case one hour may pass.
  • SiteMinder is CA Technologies' way of doing "single sign on" while IdentityMinder is their way of managing roles. TransactionMinder is for chit chat with web services and is also of CA Technologies.
  • Targus sells docks for laptops and laptop bags and other stuff.
  • SAP's Fieldglass is a time entry tool.
  • DbVisualizer isn't just for PostgreSQL. One may browse MSSQL databases with it.

 
 

Some other stray thoughts while in transition since blogging last:

  • I haven't namedropped Phil Haack of GitHub on my blog yet. I saw him speak back when he was with Microsoft before he went to GitHub and before later on when GitHub became owned by Microsoft. He spoke at the Austin .NET User Group back when I was at Headspring and me and a bunch of other Headspring guys went and saw him speak and he tried to demo an app he threw together on the plane ride in and it kept breaking.
  • I can remember being at Johnson/McKibben Architects, Inc. and listening to Wajahat Siddique, Neil Griffin, Joe Donaldson, and Johnathon Wright's brother David Wright talk about MTEXT which was a way to do text in AutoCAD which got much debate. Neil didn't like it and he said whenever he ran into it he exploded it to manhandle it into something else as it was hard to change. Neil also suggested that BradCAD was an AutoCAD alternative like MicroStation.
  • As of the 1st of August, plans for 3D printing your own guns which you can just slip through metal detectors are no longer illegal to download in America due to the Trump administration which sees the dissemination of this information as free speech. I remember when Brittan declassified how to make nuclear weapons in 2002 and that also and that seemed similarly unbelievable. Wait! This is no longer true. The release of the gun plans have been blocked by a judge.
  • In the Paint program which comes with Windows 7, if you are holding down the left-mouse button and dragging out an effect, such as drawing with the pencil, right-clicking before releasing the left button will undo everything you have done while releasing the left button alone applies the effect.
  • thehub.amazon.com is some sort of Amazon-based tool to let you know that a package is waiting for you at a mailbox. I'm sure it ties into Amazon nicely, but it's not just that. It is also for other types of deliveries I believe.
  • When you make a change in Google Chrome's Settings, you likely don't need to explicitly press a Save or Submit button to make the change take effect. You may just make the change and then close out of Settings. This isn't the Windowsland way of doing things. This approach to UX was first associated with the Macintosh, but it has spread out to other things.
  • Back in the day, multimedia was sometimes referred to as: "New Media"
  • Cracken is some tool from IBM that cracks passwords on accounts. Password1 is still the most popular password!
  • Spring Boot is some sort of UI framework for the Spring Framework and Java not unlike Spring MVC but also not the same either.
  • I work with vision/optometrist medical records and I heard one of the others in the office namedrop Essilor which of course owns FramesDirect. I thought of how when I worked at FramesDirect they had some curious try-on feature in which you could upload an image of your face and kinda lay different frames that you might buy over the image to see what they looked like on you.
  • I just got the internet connection turned on by Comcast and the modem is capable of turning on the mocha feature for cable which I will never use as I do not own a TV. If you have an X1 cable box and you try to use the guide, any modem without a mocha filter will be found when searching for the guide (in your apartment complex) and the ping in will cause a hint of lag. The mocha filter looks like this: