Skip to content

Instantly share code, notes, and snippets.

View mattmc3's full-sized avatar
🐍
Python!

mattmc3 mattmc3

🐍
Python!
View GitHub Profile
@mattmc3
mattmc3 / find_and_rename.bash
Created April 6, 2017 01:23
Bash - rename directories
find . -depth -name "{{old}}" -type d -execdir bash -c 'mv {} {{new}}' \;
@mattmc3
mattmc3 / make_venv.bash
Created April 6, 2017 01:27
Python - make virtual environment
python3 -m venv ~/.virtualenvs/my-venv
@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 / 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