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 / 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
@Dillie-O
Dillie-O / parse_json_into_list.cs
Created March 11, 2019 23:52
[Parse JSON into List] Parse JSON into List<T> #dotnetcore
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
var pathToSeedData = Path.Combine(Directory.GetCurrentDirectory(), "Data", "duck_seed.json");
var dataSet = File.ReadAllText(pathToSeedData);
var seedData = JsonConvert.DeserializeObject<List<Duck>>(dataSet);
@Dillie-O
Dillie-O / gist:4637250
Created January 25, 2013 19:47
Remove duplicate jQuery UI dialog objects before display.
// Thank you StackOverflow!!!
// http://stackoverflow.com/questions/7099938/jquery-ui-dialog-behaves-unpredictably
var original = $('#dialogId')[0];
var clone = $(original).clone().attr('id', 'dialogIdClone');
var saveHtml = $(original).html();
$(original).html('');
$(clone).dialog({
... // other options
open: function (){
// add any dynamic behavior you need to the dialog here
@Dillie-O
Dillie-O / gist:5405986
Created April 17, 2013 17:00
Map FastCGI to PHP location for IIS Express
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/fastCGI /+[fullPath='"C:\Program Files (x86)\PHP\php-cgi.exe"']
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='"C:\Program Files (x86)\PHP\php-cgi.exe"',resourceType='Unspecified']
@Dillie-O
Dillie-O / zsh_add_rbenv.sh
Created January 5, 2018 16:33
[Add rbenv to ZSH] Adds rbenv command to be accessible in ZSH (if available) #zsh #environment #configuration #ruby
# load rbenv if available
if command -v rbenv >/dev/null; then
eval "$(rbenv init - zsh --no-rehash)"
fi
@Dillie-O
Dillie-O / postman_environment_variable.js
Created January 2, 2018 14:41
[Postman Environment Variable Update] Updates environment variable in Postman. Use in 'Tests' section. #postman #api #environment
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable('token', jsonData.data.JWT);
@Dillie-O
Dillie-O / find_tables_with_column.sql
Created October 17, 2017 23:53
[Find Tables with Column] Finds all tables with column names matching input #sql
SELECT c.name AS ColName, t.name AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%MyCol%';
@Dillie-O
Dillie-O / Convert_SSL_Certificate.sh
Created September 14, 2017 20:17
[Convert SSL Cerfiticate CER to PFX] Convert SSL Certificate for Azure Use #ssl #cer #pfx #pkcs7 #pkcs12
openssl pkcs12 -export -out final_name.pfx -inkey private_key.key -in original_certificate.crt