Skip to content

Instantly share code, notes, and snippets.

@bburhans
bburhans / reddit.user.js
Last active June 3, 2020 06:37
Userscript to make new reddit slightly less terrible
// ==UserScript==
// @name Reddit
// @namespace bburhans
// @version 0.0.2
// @description Neuter lightbox click behavior on reddit
// @author Benjamin P. Burhans
// @match https://www.reddit.com/*
// @grant none
// ==/UserScript==
@bburhans
bburhans / README.md
Last active June 28, 2019 02:12
Elapsed months logic with tests 2019-06-27

I needed to count the actual whole calendar months between two dates with no assumptions about the nature of anything between them. That means no knowledge of days in each month (which vary even before considering leap years), seconds in each day (which may vary with time zones or leap seconds), or even months in each year. Adding magic numbers, or worse, enumerating lots of Gregorian calendar eccentricities, are nasty code smells.

Unsatisfied with solutions like SQL Server's DATEDIFF() that naively counts datepart boundaries and Oracle's MONTHS_BETWEEN() that naively thinks every month is 31 days long, I checked StackOverflow and other usual resources, but nobody had a sane solution. Some authors suggested calendar tables (✋), and others suggested CLR functions (⚠️); many solutions mimicked the faulty assum

@bburhans
bburhans / README.md
Created May 24, 2019 02:56
Clipboard examiner 2019-05-23
@bburhans
bburhans / README.md
Last active May 1, 2019 21:13
Change Data Capture blast radius report

CDC blast radius analysis

This is a tool I wrote to find the schemas, tables, and columns affected by an unfortunate overbroad update query in SQL Server.

Caveats

  1. Apologies for the usage of a cursor and dynamic SQL. If you have a good way to avoid either or both, please share your solution.
  2. It is tested on SQL Server 2014, probably works well on later versions, and may be useful on all versions 2008 and later, albeit perhaps with some syntactic adjustments.
  3. I have no idea how it handles DDL changes, so be careful if your schema isn't static.
  4. I have not yet tested its dynamic SQL bits against SQL injection.
@bburhans
bburhans / English Is Tough Stuff
Last active June 3, 2020 01:01
poems about the English language (neither are mine, they were sent to me and I do not know the authors)
Dearest creature in creation,
Study English pronunciation.
I will teach you in my verse
Sounds like corpse, corps, horse, and worse.
I will keep you, Suzy, busy,
Make your head with heat grow dizzy.
Tear in eye, your dress will tear.
So shall I! Oh hear my prayer.
Just compare heart, beard, and heard,