Skip to content

Instantly share code, notes, and snippets.


mattmc3 mattmc3

Block or report user

Report or block mattmc3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mattmc3 / myapp.rb
Created Apr 29, 2019
Homebrew - Tap for private repo
View myapp.rb
# Homebrew formula for private github repo
# Requires $HOMEBREW_GITHUB_API_TOKEN to be set
# WARNING: This is a cheap way to do this. Don't use this method unless you
# really don't care about the security of you private GH token. And, let's
# be clear - this is for a private GH Enterprise repo, so you might not
# care...
class MyApp < Formula
desc "My fake app"
mattmc3 / sel_schema_from_all_dbs.sql
Created Apr 15, 2019
MSSQL - information_schema all dbs
View sel_schema_from_all_dbs.sql
drop table if exists #cols
select top 0 isc.*, cast(null as varchar(10)) as table_type, cast(null as bit) as is_primary
into #cols
declare @sql varchar(max)
set @sql = '
use ?
insert into #cols
select isc.*, ist.table_type, sys.fn_hadr_is_primary_replica(''?'')
View benchmark.zsh
#!/usr/bin/env zsh
for i in $(seq 1 10); do
/usr/bin/time zsh -i -c exit
mattmc3 / mssql.ahk
Created Mar 29, 2019
AHK - AutoHotKey save MSSQL script execution history
View mssql.ahk
;CTRL+SHIFT+R run a query, but will also copy the script and save it off
;^+r is QWERTY, ^+s is Colemak for ^+r
Send, ^c
FormatTime, DateString,,yyyyMMdd
FormatTime, TimeString,,hhmmss
FileCreateDir %HomeDir%\Documents\sqlhist\%DateString%
FileAppend, %Clipboard%, %HomeDir%\Documents\sqlhist\%DateString%\%TimeString%.sql
Send, {f5}
mattmc3 / colemak.ahk
Created Mar 29, 2019
AHK - Colemak remapping
View colemak.ahk
; Colemak layout for AutoHotkey (MS Windows)
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode 3 ; Exact matching to avoid confusing T/B with Tab/Backspace.
;top row
mattmc3 / save_clipboard.ahk
Created Mar 29, 2019
AHK - save clipboard to file
View save_clipboard.ahk
; Save clipboard to file
FileDelete, %HomeDir%\Documents\clipboard.txt
FileAppend, %Clipboard%, %HomeDir%\Documents\clipboard.txt
mattmc3 / regex_scrub.sql
Created Mar 26, 2019
MSSQL - replace non-printable non-ascii characters
View regex_scrub.sql
select dbo.RegexReplace(t.my_column, '[^\x20-\x7E]', '~') as scrubbed
from my_table t
mattmc3 / safelyrm.bash
Created Mar 25, 2019
Bash - safely rm from a script
View safelyrm.bash
under_home() {
# $HOME has to be set. Should always be, but make sure.
[[ -z "$HOME" ]] && return 1
# Handle tricky trailing slash inputs. ie: $HOME/// becomes $HOME
local somepath="$( echo "$1" | tr -s '/' )"
# Tailing slashes already removed, so now ensure the path lives under $HOME
[[ "$somepath" == "$HOME/"* ]] && return 0 || return 1
mattmc3 /
Last active Apr 15, 2019
Bash: split string on delimiter and echo substring before/after
function split_repo() {
local gitpath="${}"
echo "\$gitpath = $gitpath"
echo "repo part \${gitpath##*/} = ${gitpath##*/}"
echo "user/repo \${gitpath#*/} = ${gitpath#*/}"
echo "url \${gitpath%%/*} = ${gitpath%%/*}"
echo "giturl/user \${gitpath%/*} = ${gitpath%/*}"
echo "user \${\${gitpath%/*}#*/} = ${${gitpath%/*}#*/}"
mattmc3 / .gitignore
Last active Feb 11, 2019
git - Sublime Text .gitignore
View .gitignore
# Put this .gitignore in the Sublime Text 3 User directory
# Mac Location: "~/Library/Application Support/Sublime Text 3/Packages/User"
# ignore subdirs except whitelisted ones
# Cache files for Sublime Text
You can’t perform that action at this time.