This site is my repository for code samples. It is a means for me to document solutions to common problems so that I can reference them quickly when needed, both at work and at home. Samples will be added to this site over the next year or two as I slowly migrate them from (1,074) text files that have served as my repository for over a decade. (I don’t want to do a mass migration as I want each sample to be properly reviewed, formatted, categorized, and tagged. I try to migrate samples as I reference them, time permitting.)

Some samples are complex, some are simple. Some are correct, and some are incorrect. While my intention is that I will be the only user of this site (I’m not an expert, and I don’t expect my samples to solve your code problems!), I don’t see a reason to prevent this content from being available to the general public. Just be warned that this content is not being shared as “the right way” to do things.

That being said, if you do happen to see glaring errors, or have suggestions on how something could be done better, feel free to contact me.


Check If Element Has ID Using jQuery

February 11th, 2019|

To check if an element has an ID: if ($(this).is('[id]') { // Has ID console.log('Has ID: ' + $(this).attr('id')); } else { // Has no ID console.log('Has no ID.'); }

jQuery – Selector Starts-Ends With

August 6th, 2018|

Selector Starts With: $('input[name^=somePrefix]').doSomething(); Selector ENDS with: $('input[name$=someSuffix]').doSomething(); In ASP.Net: This is particularly useful in ASP.Net when you may not want to specify clientidmode static, but still want to use jQuery to find the ID. [...]

jQuery – Get Ajax Post Error Details

August 6th, 2018|

$.post('status.ajax.php', {deviceId: id}) .done( function(msg) { ... } ) .fail( function(xhr, textStatus, errorThrown) { alert(xhr.responseText); });


React Component with Children

May 5th, 2023|

Creating a React component that contains children can be as easy as including a children property and including {props.children} in the Return function. But knowing the proper type to use for the children property (when [...]

Working As a Team with Migrations in Entity Framework Core

February 17th, 2021|

The official Microsoft documentation for using Migrations in Team Environments covers the basics. However, they neglect to mention one very important thing: Removing Migrations in a Team Environment Can Be Deadly! Well, not deadly, but [...]

Returning Status Codes in an ASP.Net MVC Core Controller

November 14th, 2020|

There are a few ways to return different status codes in an ASP.Net MVC Core controller. Simplified Helper Methods Some helper methods for the most common codes (there may be more than the list below): [...]


Fancy Checkboxes and Toggle Switches

April 5th, 2019|

This allows you to replace default checkboxes with a nicer-looking custom font alternative. This example uses Font Awesome 4 icons, but the CSS could easily be modified to use any font. For the code below [...]

Preserve White Space in Static Text Without Using PRE Tag

March 13th, 2019|

When displaying multi-line text (e.g. input from a TextArea) in a static element (e.g. DIV), extra white space and line breaks are ignored, resulting in one long line of text. An older approach used to [...]