Search SQL Server database triggers for table name

Did you ever find yourself in a situation where you have a SQL Server database that has grown out of control, and you need to figure out where a call to insert a record into a particular table might be lurking in one of those triggers?

Oh sure, you can go into each table, expand the triggers folder in each table, then crack open each trigger showing and see if what you are looking for is there. For a database of non-trivial size, I would rather look up “tedium” in the dictionary.

Alas, there is a way to quickly screen down the number of places you may have to look for to find what you need. Open up your database and paste this text into the query window, of course replacing SearchText with whatever table name you need to search for:

SELECT, text FROM sysobjects so, syscomments sc
WHERE TYPE = 'TR' AND = AND text LIKE '%SearchText%'

For example, if you wanted to find any trigger that inserts a record into a table called Customers, you would do this query:

SELECT, text FROM sysobjects so, syscomments sc
WHERE TYPE = 'TR' AND = AND text LIKE '%insert into Customers%'

Keep in mind that unless you played with the settings or collation of your database, the case of the text in the LIKE statement above should not matter.

MHS 3.5″ LCD screen with Raspberry Pi

I am saving this here just in case the original source of this goes off line.

To download the drivers for Raspbian Buster, do these steps:

sudo rm -rf LCD-show
git clone
chmod -R 755 LCD-show
cd LCD-show/
sudo ./MHS35-show

To rotate the screen, do these steps:

cd LCD-show/
sudo ./ 90

EDIT (10/4/2023):
When you set up the Raspberry Pi to use the LCD screen driver, it does disable the onboard HDMI output ports, so if you attach a cable there you will not get any video or audio.
If you want to reset your Raspberry Pi back to using the HDMI output then instead of the attached screen, do these steps:

cd LCD-show/
sudo ./LCD-hdmi

Better late than never

So once again I forgot to post about finishing up the Advent of Code. Here is my Swift code for the solutions:

Advent of Code Solution Machine

Simple method for calling async method in standard function in C#

Due to a need to support older versions of .NET code and applications, you may find yourself staring at the need to call an async function from a standard synchronous function, and you don’t want to (or have the time for more likely) to go back and retrofit all of the calling functions with async/await functionality. Well brother, do I have a deal for you.

Here is how you can call the SendGrid SendEmailAsync function from within a regular C# function, and still be able to inspect the result of the task that runs the async method:

public bool SendPlainTextEmail(string subject, string body, List<string> toAddresses)
        var apiKey = "Nice try Chachi, go ahead and insert your own SendGrid API key here";
        var client = new SendGridClient(apiKey);
        var from = new EmailAddress("", "Your verified SendGrid email sender name here");
        var to = toAddresses.Select(x => new EmailAddress(x)).ToList();
        var msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, to, subject, body, string.Empty);
        // Call the async function here and just wait for the results, no async function decorations required
        var task = Task.Run(async () => await client.SendEmailAsync(msg).ConfigureAwait(false));
        var result = task.Result.IsSuccessStatusCode;
        return result;
    catch (Exception ex)
        throw ex;

I leave it up to you, the reader, to adapt this code for your own purposes, nefarious or otherwise. Regardless, the important stuff is happening with these two lines, which I have boiled down from above to remove the SendGrid cruft:

var task = Task.Run(async () => await theAsyncMethod());
var result = task.Result;
// do something here with the result

In the interest of full disclosure, keep in mind you may need to do this import at or near the top of your source code file to be able to use the Task object in .NET:

using System.Threading.Tasks;

BTW, Happy Birthday to Seth MacFarlane, I can’t wait for season 3 of The Orville, March of 2022 can’t come soon enough.

Installing SwiftLint (and actually getting it working)

So you are humming along on a Swift project, and making excellent progress. However, somewhere in the back of your mind, you know that you should be doing things better, mainly due to your lack of experience in writing Swift code. In this case, you should be installing SwiftLint to help you with your code base.

The installation seems harmless enough:

brew install swiftlint

Once that finishes, however, you try to run a swiftlint command in the Terminal and are faced with this:

Fatal error: Loading sourcekitd.framework/Versions/A/sourcekitd failed: file SourceKittenFramework/library_wrapper.swift, line 39
Illegal instruction: 4

Fear not brave adventurer, you just have to get your Xcode select path correctly configured. With Xcode installed in the standard place, this command in the Terminal should get you all fixed up:

xcode-select -s /Applications/

BTW, Happy Inventors’ Day to all my readers in Argentina.

Advent of Code 2020

I can’t believe that I forgot to post about the 2020 Advent of Code until just now! Man I suck, but in truth, I have been a bit busy with my new gig.

There didn’t seem to be a puzzle this year that they kept building on like in years past. I actually kind of liked those kinds of challenges, but I will say that the 2020 set of challenges were fun to work on.

Please check out my Advent of Code Github repository:

420 years of ignoring Windows Updates

Some people wait a very long time, if ever, to do their Windows Updates. (For better or worse. Seriously people, run your Windows Updates.)

But this is a bit ridiculous…

Windows Update

BTW, Happy Birthday to the National Baseball Hall of Fame, opened this day in 1939 in Cooperstown, New York. I sure wish we had baseball right about now…

Migrating AFNetworking to NSURLSession

I have some legacy Objective-C code that I want to bring up to the latest iOS code. Part of this is migrating AFNetworking to NSURLSession.

Not that I have anything against AFNetworking of course, I have used it for a very long time, especially when the communications capabilities in the Foundation framework were a bit more primitive than they are now. I have just been trying to reduce dependencies in my projects where I can, and for my communications needs, the newer Foundation classes give me the same kind of ease of use that AFNetworking has.

For example, here is a simple example of some of the legacy code that I have in the app:

NSURL *url = [NSURL URLWithString:@""];    
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:url]];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do something with the operation.responseString
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    // an error occurred
[op start];

And here is what it looks like when you migrate to NSURLSessionDataTask:

NSURL *url = [NSURL URLWithString:@""];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (error != nil)
            // an error occurred
            // do something with the data
[task resume];

All in all, I think that 7 years of usage (I migrated to AFNetworking in 2013 as described in the post Migrating ASIHTTPRequest to AFNetworking) is pretty good for using a library. Kudos to the team maintaining that library, I do not know if I would have the patience to stick with it for that long.

BTW, Happy Birthday to John Myung, bass player for Dream Theater.

Advent of Code 2019

The calendar is about to turn, which can only mean one thing. Time to finish Advent of Code!

I stumbled a bit on some of this year’s puzzles, as it seemed they were harder than usual. On a couple of them, I had to out and out give up on my part 2 solutions in favor of those smarter than me.

At any rate, please check out the Github repository, where the Swift 5 solutions to 2019 are now permanently encased:

Please note that I have removed the year from the repository name, as I intend to keep adding to this one repository all Advents of Code past and present. Currently I am working my way through 2018, so please be patient, as I may have to make code changes on earlier solutions as the Swift versions have moved forward.

BTW, if you are looking for something new and interesting to read in the sci-fi genre, please check out my friend and author Jerry Evanoff. He has self published a book and novella in his Nightmares Through Time series as of the end of 2019, and is planning a larger literary universe to delight and confound. Mostly confound. But it’s a ripping good yarn anywho, so please consider signing up for his newsletter, buying his book, or reading his work through Kindle Unlimited.

Use PowerShell to find all instances of a DLL

Eventually, if you do enough .NET development, you will find yourself in a situation where your application is complaining because it cannot find the right version of a DLL. You could always try to do a search of your hard drive and find these DLLs, but why do it the hard way? Easily enough, you can just use PowerShell to find all instances of a DLL on your computer, which can help you try to track down issues like this.

Here is the PowerShell command that will show you all of the folders, dates, and versions of a DLL that starts with “newtonsoft”. Make sure to substitute in the name of the DLL you are searching for, that you start in the folder that you want to execute the search from (or in other words, if you want to search your entire hard drive, make sure to change directory to the root of your C: drive first), and it can help if you run the PowerShell application as an administrator if you can.

Get-Childitem -Recurse newtonsoft*.dll | Format-Table directory,creationtime,lastwritetime,@{label="ProductVersion";expression={$_.versioninfo.productversion}},@{label="FileVersion";expression={$_.versioninfo.fileversion}}

Or, if you want a listing with fewer columns, try this one:

Get-ChildItem -Recurse newtonsoft*.dll | Format-Table directory,@{label="FileVersion";expression={$_.versioninfo.fileversion}},lastwritetime

BTW, a posthumous Happy Birthday to Dennis Ritchie, a legend in the software development community.