Skip to content

Instantly share code, notes, and snippets.

View randyburden's full-sized avatar

Randy Burden randyburden

View GitHub Profile
@randyburden
randyburden / TimeSpanHelper.cs
Last active February 14, 2023 19:25
TimeSpan helper and extension method for creating a formatted string of a given TimeSpan. Supports up to microsecond resolution. Also includes unit tests.
using System;
using System.Text;
namespace Helpers
{
public static class TimeSpanHelper
{
/// <summary>
/// Gets a formatted string of the given <see cref="TimeSpan"/>. Supports up to microsecond resolution.
///
@randyburden
randyburden / NonOverlappingTimer.cs
Last active February 14, 2023 18:30
Wraps System.Threading.Timer and guarantees non-overlapping executions.
using System;
using System.Threading;
namespace Helpers
{
///<summary>
/// Provides a mechanism for executing a method at specified intervals without overlapping executions.
/// While the timer is executing the method/action, if another interval run occurs, it will return
/// immediately (skipping the new run) to prevent an overlapping execution and allow the previous execution to continue.
/// </summary>
@randyburden
randyburden / blog.cwa.me.uk.user.css
Created September 26, 2022 22:01
Stylus - Dark mode theme for the The Morning Brew blog @ https://blog.cwa.me.uk
/* ==UserStyle==
@name The Morning Brew - Dark Mode
@version 1.0.0
@description Dark mode for the The Morning Brew blog @ https://blog.cwa.me.uk
@namespace github.com/RandyBurden
@author Randy Burden
@license MIT
==/UserStyle== */
@randyburden
randyburden / ProcDump - How to Capture a Memory Dump for a Specific Process.md
Created August 3, 2022 14:12
How to Capture a Memory Dump for a Specific Process using ProcDump and Debug with Visual Studio - Tested and works with .NET Core Apps

How to Capture a Memory Dump for a Specific Process using ProcDump and Debug with Visual Studio

  • Download ProcDump

  • Run this command file in an Administrator Console to capture a one-time memory dump for a specific processes:

    • procdump.exe YourProcessName -accepteula -ma C:\MemoryDumps\Dumps
      • Note, just use the name of the process that is displayed in the Task Manager
@randyburden
randyburden / How to Capture a Memory Dump When an App Crashes.md
Last active August 3, 2022 14:15
How to Capture a Memory Dump When an App Crashes, particularly an app that is crashing with a stack overflow exception. Tested with .NET Core apps.

How to Capture a Memory Dump When an App Crashes

  1. Download ProcDump

    • ProcDump is a Microsoft Sysinternals command-line utility for creating memory dumps / crash dumps.
  2. Run the following command to start capturing a memory dump anytime an application crashes:

mkdir C:\MemoryDumps
procdump.exe -accepteula -ma -i C:\MemoryDumps
@randyburden
randyburden / Kill-Service-At-80-GB.ps1
Created August 3, 2022 13:54
PowerShell script to kill a process when it reaches a certain memory threshold. Writes output to console and a log file.
# Kills a specific Windows Service process if it uses over 80 GB of memory
# Note, be sure to set the Windows Service to restart instantly on failure
# To run this script manually, run the following 2 lines of PowerShell:
# powershell -command "C:\Temp\WindowsScheduledTaskScripts\Kill-Service-At-80-GB.ps1"
# $LASTEXITCODE
# To run as a Windows Scheduled Task:
# Set the program to run as "powershell"
# Set the command to: -Command ". C:\OneDine\WindowsScheduledTaskScripts\Kill-Service-At-80-GB.ps1; exit $LASTEXITCODE"
@randyburden
randyburden / Cloudflared Quick Tunnels.md
Created July 27, 2022 20:54
Cloudflare Quick Tunnels - ngrok alternative for exposing localhost ports to the internet

Cloudflare Quick Tunnels

Overview

  • Cloudflare Tunnels has a feature named "Quick Tunnels" that allows you to expose localhost ports to the internet via a dynamically generating unique URL.
  • Cloudflare Quick Tunnels is a free alternative to ngrok, which is a popular developer tool with more features, but does not allow you to have more than 1 instance running at a time without paying, whereas with Cloudflare Quick Tunnels there is no such limit.

Links

@randyburden
randyburden / VbaProject.OTM
Created September 30, 2016 16:25
Outlook VBA Scripts for Adding Categories to New Emails
Public Sub ShowCategoriesDialog()
Dim Mail As Object
Set Mail = Application.ActiveInspector.CurrentItem
Mail.ShowCategoriesDialog
End Sub
Public Sub AddAwaitingFeedbackCategory()
Dim Mail As Object
Set Mail = Application.ActiveInspector.CurrentItem
Mail.Categories = "Awaiting Feedback"
@randyburden
randyburden / SentimentPicker.html
Created May 24, 2022 22:46
Sentiment Picker (Negative, Neutral, Positive) written using Bootstrap, jQuery, and toastr. It allows the user to select a sentiment or ranking. Demo: https://codepen.io/randyburden/pen/Yzerbqv
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Sentiment Picker</title>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css'>
<style>
.sentiment-picker .btn {
color: #fff;
@randyburden
randyburden / Calendar_MSSQL.sql
Created March 17, 2022 22:04
SQL Calendar table script for MS SQL Server and MySQL databases. Populates in about 2 seconds.
/* Create Calendar table for MS SQL Server (Total runtime is less than 2 seconds to populate) */
-- DROP TABLE IF EXISTS Calendar
CREATE TABLE Calendar (
CalendarDate DATE NOT NULL PRIMARY KEY,
CalendarYear SMALLINT NULL,
CalendarMonth tinyint NULL,
CalendarDay tinyint NULL,
CalendarMonthName VARCHAR(9) NULL,
CalendarDayName VARCHAR(9) NULL,
CalendarDayofWeek tinyint NULL,