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 /
Last active Jul 27, 2019
Bash: get current script directory (zsh too)
# source this file
__main() {
local this_script="${BASH_SOURCE[0]:-${(%):-%x}}"
local this_dir="$(cd $(dirname "$this_script") && pwd)"
echo $this_script
echo $this_dir
mattmc3 /
Created Jul 26, 2019
Git remove submodule
# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule
View list.txt
Classic Marcel
Quarter Marcel
Inverse Quarter Marcel
Inverse Marcel
Double Marcel
Inverse Double Marcel
Marcel Sandwich (not to be confused with the Dutch sandwich)
Double Marcel Sandwich
Double Irish Marcel
Double Irish with a Marcel Sandwich
mattmc3 / .zshrc
Created Jun 19, 2019
ZSH: Antigen heredoc bundle example
View .zshrc
antigen use oh-my-zsh
# themes I like: refined, wezm, juanghurtado, avit, kardan, juanghurtado, steeef
antigen theme avit
antigen bundles <<EOBUNDLES
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
You can’t perform that action at this time.