Skip to content

Instantly share code, notes, and snippets.

View mattmc3's full-sized avatar
🐍
Python!

mattmc3 mattmc3

🐍
Python!
View GitHub Profile
@mattmc3
mattmc3 / get_cur_dir.bash
Created April 6, 2017 01:55
Bash - get currently executing script dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@mattmc3
mattmc3 / gpg_multiple_recipients.bash
Created April 6, 2017 01:56
GPG encrypt for multiple recipients
gpg --recipient "{{first}}" --recipient "{{second}}" --output file.txt.pgp --armor=ascii --encrypt file.txt
@mattmc3
mattmc3 / info_schema_cols_ext.sql
Last active February 7, 2019 19:44
MSSQL - select information_schema.columns with extras
select object_id(quotename(isc.TABLE_SCHEMA) + '.' + quotename(isc.TABLE_NAME)) as MSSQL_OBJECT_ID
, isc.TABLE_CATALOG
, isc.TABLE_SCHEMA
, isc.TABLE_NAME
, columnproperty(object_id(quotename(isc.TABLE_SCHEMA) + '.' + quotename(isc.TABLE_NAME)), isc.column_name, 'ColumnId') as MSSQL_COLUMN_ID
, quotename(isc.table_schema) + '.' + quotename(isc.table_name) as FULL_TABLE_NAME
, isc.COLUMN_NAME
, isc.ORDINAL_POSITION
, isc.DATA_TYPE
, case when isc.DATA_TYPE in ('binary', 'char', 'nchar', 'nvarchar', 'varbinary', 'varchar')
@mattmc3
mattmc3 / meta.columns.sql
Created April 6, 2017 14:27
MSSQL - information_schema.columns replacement
select
*
,quotename(t.column_name) + ' '
+
case
when t.computed_column_definition is not null then 'as ' + t.computed_column_definition
else
quotename(t.data_type)
+
case
@mattmc3
mattmc3 / trunacte_log.sql
Created April 6, 2017 14:29
MSSQL - Truncate log file
-- http://dba.stackexchange.com/questions/6996/how-do-i-truncate-the-transaction-log-in-a-sql-server-2008-database
ALTER DATABASE {{db}} SET RECOVERY SIMPLE
go
SELECT name
FROM sys.master_files
WHERE database_id = DB_ID('{{db}}')
go
@mattmc3
mattmc3 / enable_clr.sql
Created April 6, 2017 14:31
MSSQL - Enable CLR
exec sp_configure 'show advanced options', 1;
go
reconfigure;
go
sp_configure 'clr enabled', 1;
go
reconfigure;
go
sp_configure 'show advanced options', 0;
go
@mattmc3
mattmc3 / enable_ole.sql
Created April 6, 2017 14:32
MSSQL - enable OLE
exec sp_configure 'show advanced options',1;
go
reconfigure;
go
sp_configure 'Ole Automation Procedures', 1;
go
reconfigure;
go
sp_configure 'show advanced options', 0;
go
@mattmc3
mattmc3 / monitor_mssql_recovery_mode.sql
Created April 6, 2017 14:33
MSSQL - monitor recovery mode
-- https://blogs.msdn.microsoft.com/psssql/2010/12/29/tracking-database-recovery-progress-using-information-from-dmv/
USE Sandbox
GO
DROP TABLE [dbo].[tbl_recovery_tracking]
GO
DROP TABLE [dbo].[tbl_dm_tran_database_transactions]
GO
CREATE TABLE [dbo].[tbl_recovery_tracking](
[runtime] [datetime] NOT NULL,
[command] [nvarchar](256) NOT NULL,
@mattmc3
mattmc3 / instructions.md
Created April 6, 2017 14:42
Git - change author in commit history
@mattmc3
mattmc3 / header.py
Created April 6, 2017 15:07
Python2 header
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
DOCSTRING
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division