Skip to content

Instantly share code, notes, and snippets.

View Dillie-O's full-sized avatar

Sean Patterson Dillie-O

View GitHub Profile
@Dillie-O
Dillie-O / run_app_as_user.bat
Created November 5, 2021 16:07
[Run Apps As User] Launch an application as a different user (helpful with VPN users) #command #runas #batch
@ECHO off
cls
:start
ECHO.
ECHO 1. Visual Studio 2019
ECHO 2. VS Code
ECHO 3. Sql Server Management Studio
ECHO.
set choice=
@Dillie-O
Dillie-O / vsc-remove-dupes
Last active March 9, 2021 19:49
[VSC Remove Duplicate Lines] Remove duplicate lines from text in Visual Studio Code
Open Search/Replace (CTRL+H), change settings to Regular Expressions (click .*)
Enter Find: ^(.+\n)(?=(?:.*\n)*?\1)
Leave Replace blank
Press CTRL+ALT+Enter
Profit!
@Dillie-O
Dillie-O / x11_forward_su.sh
Created January 22, 2020 22:11
[X11 forward for su] Update X11 forwarding for super user #shell #unix #x11
# After logging in as a normal user, change to the su account, but don't use
# the '-' to preserve display values. Finally, append your users xauth settings
# onto your own, which will include the "cookie" for X11 forwarding
sudo su
xauth add $(xauth -f ~[user]/.Xauthority list|tail -1)
@Dillie-O
Dillie-O / git_scrub_large_file.sh
Created December 17, 2019 23:33
[Remove Large File from Git History] Scrubs full git history to remove reference to file specified #git
git filter-branch --index-filter 'git rm --cached --ignore-unmatch [file_name]' HEAD
@Dillie-O
Dillie-O / hyper-config.txt
Created November 13, 2019 18:07
Hyper Config (for debugging)
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@Dillie-O
Dillie-O / clone_git_repo_no_history_bash.sh
Created September 18, 2019 20:20
[Clone Git Repo Without History] Clone Git repo without history #bash #git
mkdir -p [path_to_new_directory] && git archive master | tar -x -C [path_to_new_directory]
@Dillie-O
Dillie-O / clone_git_repo_no_history_powershell.ps
Last active September 19, 2019 21:10
[Clone Git Repo Without History] Clone Git repo without history #powershell #git
$location = "[path_to_new_folder]"; git archive master --format zip -o "$location.zip"; expand-archive "$location.zip" -DestinationPath $location; ri "$location.zip"
# Expand-Archive will auto-create destination folder.
# Can use path such as $HOME/Projects/my_project to shortcut.
@Dillie-O
Dillie-O / document_path.js
Created September 5, 2019 22:01
[Get Document Path] Get Google Docs document path #google #gsuite
#Note: Needs to be installed via Tools->Script Editor and works one document at a time (for now)
function onOpen() {
// Add a menu with some items, some separators, and a sub-menu.
DocumentApp.getUi().createMenu('Fresh Tools')
.addItem('Show Document Path', 'listParentFolders')
.addToUi();
}
@Dillie-O
Dillie-O / drop_all_tables.sql
Created August 19, 2019 16:43
[Drop All Tables] Drops all tables in a given database #sql
/* Drop all Primary Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
WHILE @name IS NOT NULL
BEGIN
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
@Dillie-O
Dillie-O / drop_all_constraints.sql
Created August 19, 2019 16:36
[Drop All Constraints] Drop all constraints in all tables #sql
DECLARE @dropAllConstraints NVARCHAR(MAX) = N'';
SELECT @dropAllConstraints += N'
ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id))
+ '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) +
' DROP CONSTRAINT ' + QUOTENAME(name) + ';'
FROM sys.foreign_keys;
EXEC sp_executesql @dropAllConstraints