Skip to content

Instantly share code, notes, and snippets.

View bh3605's full-sized avatar

Bryson Hair bh3605

View GitHub Profile
@bh3605
bh3605 / cmd
Created March 15, 2023 19:44
Delete everything quickly and quietly on Windows
DEL /F/Q/S *.* > NUL
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public class TypeSafeEnum<T> where T : class
{
TypeSafeEnum(string name, T typeSafeEnum)
{
@bh3605
bh3605 / Fingerprint.cs
Created January 28, 2022 02:23
Webforms Cache Buster
sing System.Collections.Concurrent;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Web;
/**
* Solution from https://stefanolsen.com/posts/cache-busting-with-asp-net-mvc/
* https://www.madskristensen.net/blog/cache-busting-in-aspnet/
* https://stefanolsen.com/posts/cache-busting-2-0-an-update-for-asp-net-core/
@bh3605
bh3605 / SendDBEmailwithTabularQuery.sql
Created April 28, 2021 12:54
Sends an email when results are returned from a query
-- =============================================
-- Author: Hair, Bryson
-- Create date: 4/27/2021
-- Description: This stored procedure will send an email from the database with the query results as an html table in the email.
-- =============================================
ALTER PROCEDURE [dbo].[CFT_SendDBEmailwithTabularQuery]
(
@qSELECT NVARCHAR(100), --The select part of the sql statement, which can include top X
@fieldlist NVARCHAR(MAX), --Pipe delimited list of fields, which can include aliases
@qFROM NVARCHAR(MAX), --The from part of the sql statment, which can include joins
@bh3605
bh3605 / WhoIsLoggedIn.sql
Created April 2, 2021 15:11
Returns a sql db server's signed in users
SELECT SESSION.login_name AS 'Database User Name'
,MAX(SESSION.login_time) AS 'Login Time'
,SESSION.host_name AS 'PC Name'
,SESSION.program_name AS 'Program Using'
,SESSION.client_interface_name AS 'Interface'
,UM.USER_NAME AS 'User'
FROM master.sys.dm_exec_Sessions SESSION
WHERE SESSION.session_id >= 51 -- All user Sessions
GROUP BY SESSION.login_name
,SESSION.host_name
@bh3605
bh3605 / knockout.google.map.js
Created September 28, 2017 18:55
A Knockout way of communicating and initializing a google map
var app = app || {};
app.google = app.google || {};
app.google.map = (function ($) {
var model = {
markers: [],
initialized: ko.observable(false),
infoWindow: null,
apiLoaded: ko.observable(false)
};
@bh3605
bh3605 / knockout.recaptcha.js
Created September 28, 2017 18:52
knockout way of building a recaptcha
/**
* Make sure your page is using <script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
* or if you're using <script src="https://www.google.com/recaptcha/api.js" async defer></script> then comment out
* Recaptcha.create and uncomment the grecaptcha.render.
* based on http://jsfiddle.net/jaGWY/
* docs: https://developers.google.com/recaptcha/intro & http://recaptchamvc.apphb.com/Home/Document
*/
var app = app || {};
app.knockout = app.knockout || {};
@bh3605
bh3605 / ko.extras.js
Created June 1, 2017 12:59
Helpful js functions for knockout.js library
//given an object and a white list; reset all knockout observables to undefined
var reset = function (obj, whitelist) {
for (var prop in obj) {
if ( obj.hasOwnProperty(prop) && ko.isObservable(obj[prop]) && !ko.isComputed(obj[prop]) && whitelist.indexOf(prop) === -1 ) {
obj[prop](undefined);
}
}
};
//useful for when an object is used for the value property of a dropdown. Usage: "optionsAfterRender: setOptionValue('propertyName')"
@bh3605
bh3605 / confirmmodal.js
Created June 3, 2016 17:55
A simple extensible modal used primarily for confirm dialogs.
(function ($) {
$.fn.confirmModal = function (opts) {
var body = $('body');
var unique = Math.floor(Math.random() * (1e+9));
var clickedOutside = true;
// the innerFrameId allows a body of markup to be inserted w append in lieu of message
// use detach first if the nodes are already in the dom
var defaultOptions = {
confirmModalId: "confirmModal" + unique,
confirmInnerFrameId: "confirmInnerFrame" + unique,
@bh3605
bh3605 / FocusedTextBox.vb
Created August 12, 2015 14:56
Gives a textbox an easy way of highlighting when tabbing and clicking
''' <summary>
''' This class adds two events for easy highlighting when tabbing and clicking.
''' Double clicking will unhighlight and leave the cursor at the beginning.
''' Uses the click and doubleclick events.
''' </summary>
public class FocusedTextBox
''' <summary>
''' Adds two events to the given textbox. Will override
''' click and doubleclick events.