Skip to content

Instantly share code, notes, and snippets.

🐍
Python!

mattmc3 mattmc3

🐍
Python!
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
mattmc3 / split_repo_example.sh
Last active Apr 15, 2019
Bash: split string on delimiter and echo substring before/after
View split_repo_example.sh
# http://tldp.org/LDP/abs/html/string-manipulation.html
function split_repo() {
local gitpath="${1:-github.com/mattmc3/myrepo}"
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
mattmc3 / .gitignore
Last active Feb 11, 2019
git - Sublime Text .gitignore
View .gitignore
# https://github.com/github/gitignore/blob/master/Global/SublimeText.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
*/
!Snippets/
!Snippets/*
# Cache files for Sublime Text
@mattmc3
mattmc3 / pub_info.sql
Created Jan 23, 2019
MSSQL - replication publication information
View pub_info.sql
drop table if exists #pub_nfo
create table #pub_nfo (
server_name nvarchar(255)
,distribution_db nvarchar(255)
,pub_name nvarchar(255)
,db_name nvarchar(255)
,article_name nvarchar(255)
,schema_name nvarchar(255)
,table_name nvarchar(255)
)
@mattmc3
mattmc3 / 1-install.sh
Last active Mar 12, 2019
slack dark-mode
View 1-install.sh
URL=https://gist.githubusercontent.com/mattmc3/b15e30a6715b82f8b76bfd4232583df3/raw/12334d653ac9b524d62f8eb13f45f76c9a5271ab/2-slack-dark-mode.js
curl -L $URL > ssb-interop.js
sudo mv -f ssb-interop.js /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
@mattmc3
mattmc3 / shrink_backup_to_nul.sql
Last active Jan 23, 2019
MSSQL - Backup to nul
View shrink_backup_to_nul.sql
use [MY_DATABASE]
go
checkpoint
go 50
-- see what's blocking the log
select name, log_reuse_wait_desc, db.*
from sys.databases db
where db.name = 'MY_DATABASE'
@mattmc3
mattmc3 / sp_config_cmp.sql
Created Jan 12, 2019
MSSQL - sp_configure compare
View sp_config_cmp.sql
exec sp_configure 'show advanced options', 1;
go
reconfigure;
go
drop table if exists #configs
create table #configs (
name nvarchar(255)
,minimum nvarchar(255)
,maximum nvarchar(255)
,config_value nvarchar(255)
@mattmc3
mattmc3 / migrate-git-repos.sh
Created Jan 10, 2019
Bash - migrate git repos
View migrate-git-repos.sh
gituser=$GIT_USERNAME
oldgiturl=bitbucket.org
newgiturl=github.com
repos=(
list
your
repo
names
here
)
@mattmc3
mattmc3 / recovery_time_remaining.sql
Created Jan 10, 2019
MSSQL - database recovery time remaining
View recovery_time_remaining.sql
-- https://www.mssqltips.com/sqlservertip/4832/script-to-find-out-when-sql-server-recovery-will-finish/
DECLARE @DBName VARCHAR(64) = 'DB_NAME_GOES_HERE'
DECLARE @ErrorLog AS TABLE([LogDate] CHAR(24), [ProcessInfo] VARCHAR(64), [TEXT] VARCHAR(MAX))
INSERT INTO @ErrorLog
EXEC master..sp_readerrorlog 0, 1, 'Recovery of database', @DBName
INSERT INTO @ErrorLog
EXEC master..sp_readerrorlog 0, 1, 'Recovery completed', @DBName
@mattmc3
mattmc3 / modern_sql_style_guide.md
Last active Jun 28, 2019
Modern SQL Style Guide
View modern_sql_style_guide.md
layout author title revision version description
default
mattmc3
Modern SQL Style Guide
2019-01-17
1.0.1
A guide to writing clean, clear, and consistent SQL.

Modern SQL Style Guide

@mattmc3
mattmc3 / gen_partition_function_and_scheme.sql
Last active Dec 10, 2018
MSSQL - Generate partition function/scheme
View gen_partition_function_and_scheme.sql
declare @name varchar(200) = 'mytable_yearmonth'
;with dates as (
select 0 as seq, cast('2008-01-01' as datetime) as dt
union all
select seq + 1, dateadd(month, 1, dt)
from dates
where dateadd(month, 1, dt) <= '2025-01-01'
)
select 0 as seq, 'CREATE PARTITION FUNCTION [pf_' + @name + '](datetime) AS RANGE RIGHT FOR VALUES ('
You can’t perform that action at this time.