Skip to content

Instantly share code, notes, and snippets.

View stevewithington's full-sized avatar
⛑️
solving problems

Steve Withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / sql-convert-string-to-date.sql
Last active January 13, 2021 22:50
SQL: UDF to convert string to date or return '0001-01-01'
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <steve@digitalmine.com>
-- Create date: 2020.12.21
-- Description: Convert string to DATE if NULL or invalid, else set to '0001-01-01'
-- =============================================
CREATE FUNCTION [dbo].[udf_ConvertStringToDate]
@stevewithington
stevewithington / web.config
Last active November 9, 2020 18:25
Example web.config for Server Offline / Maintenance Mode
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<!-- `stopProcessing` is irrelavent for `redirect` rules -->
<rule name="MAINTENANCE MODE" enabled="true">
<match url="^(.*)$" ignoreCase="true" />
@stevewithington
stevewithington / useful-git-commands.md
Last active September 3, 2020 17:31
Useful Git Commands

Useful Git Commands

Some useful commands for Git.

Creating Tags

git tag -a v1.0.0 -m 'v1.0.0'
git push origin --tags # To push tags to Github
@stevewithington
stevewithington / passive-support.ts
Created August 11, 2020 16:51
TypeScript Passive Support Detection
/**
* Safety detection for passive support
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
*/
initPassiveSupport = (): boolean => {
let supported = false;
let options = {};
try {
@stevewithington
stevewithington / typescript-check-if-passive-is-supported.ts
Last active August 3, 2020 16:59
Check if `passive` is supported via TypeScript
/** In case your linter gives you a problem attempting to register listeners to `testEvent` */
declare global {
interface WindowEventMap {
testEvent: CustomEvent<{ event: any, options: any }>;
}
}
/** Inspired by: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support */
export const isPassiveSupported = () => {
let passiveSupported = false;
let x = 30.039853244;
Number(Math.round(x + 'e2') + 'e-2); // 30.04
const round = (num, digits) => {
return Number(Math.round(num + 'e' + digits) + 'e-' + digits);
}
let y = 3.141592653589793238;
round(y, 3); // 3.142
@stevewithington
stevewithington / getRandomPassword.cfm
Created July 2, 2020 16:58
ColdFusion / CFML Random Password Method / Function
<cfscript>
public string function getRandomPassword(numeric length=10, string charSet='special') {
var charLower = 'a|c|e|g|i|k|m|o|q|s|u|w|y|b|d|f|h|j|l|n|p|r|t|v|x|z'
var charUpper = 'A|C|E|G|I|K|M|O|Q|S|U|W|Y|B|D|F|H|J|L|N|P|R|T|V|X|Z';
var charNumbers = '0|2|4|6|8|9|7|5|3|1';
var charSpecial = "@|!|$|%|^|&|+|=|,'";
var charList = '';
var thisChar = '';
var randomPassword = '';
git log --graph --decorate --pretty=oneline --abbrev-commit
@stevewithington
stevewithington / find-replace-sed.md
Last active June 9, 2025 22:44
Find & Replace within an Entire Directory or Git Repo with sed

Find & Replace within an Entire Directory or Git Repo with sed

If replacing within a directory:

grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'

Or, within an entire git repository:

@stevewithington
stevewithington / fancy-tabs-demo.html
Created June 4, 2019 16:43 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
<script>
function execPolyfill() {
(function(){
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1.
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt