Skip to content

Instantly share code, notes, and snippets.

View fatherjack's full-sized avatar
💭
doing things

fatherjack

💭
doing things
View GitHub Profile
@fatherjack
fatherjack / OnPremisesProbably.txt
Created February 7, 2024 14:35
Do you mean 'on premise' or 'on premises' ?
Premise
A premise is an idea or theory on which a statement or action is based. For example, in the argument “All humans are mortal; Socrates is human; therefore, Socrates is mortal”, the first two statements are premises and the last one is the conclusion. Premise can also be used as a verb, meaning to base a theory, argument, etc. on an idea, thought, or belief. For example, “He premised his argument on several incorrect assumptions”.
[source Microsoft Copilot "define Premise" Feb 2024]
Premises
Premises is a plural noun that means the land and buildings owned by someone, especially by a company or organization. It can also mean the land and buildings on which something is done or used, such as a business, a school, or a restaurant. For example, “The company is relocating to new premises” or “There is no smoking allowed anywhere on school premises”
[source Microsoft Copilot "define Premises" Feb 2024]
function Format-QuotedString {
<#
.SYNOPSIS
Wraps a string in delimiters
.DESCRIPTION
Takes in a string, returns the same string wrapped in chosen delimiters. Made to fill a similar role as the TSQL QUOTENAME function.
.PARAMETER String
The string you want wrapped
# Set $Source to be the path to the xlsx to process
#requires -module ImportExcel
# cleans Excel column headers from having leading / trailing spaces and replaces other spaces with underscore '_'
# and then uses this set of headers to import data from the xlsx with headers that are easier to handle in code.
# Essentially lines 8-14 are extra to a normal use of Import-Excel and the import line uses the header info and -StartRow to skip the file headers
# the target xlsx remains unchanged
$h = Import-Excel $source -StartRow 1 -EndRow 2
$headers = ($h | Get-Member -MemberType Properties | ForEach-Object {
@fatherjack
fatherjack / New-QuotedString.ps1
Created February 28, 2022 11:39
Creates a quoted, comma separated list of values
function New-QuotedString {
<#
.SYNOPSIS
Takes a pasted set of cells from Excel and returns a quoted, comma separated string that can be pasted into SSMS for a SQL filter
.DESCRIPTION
Long description
.PARAMETER ItemsList
@fatherjack
fatherjack / ParameterOptionsDemo.ps1
Created January 13, 2022 09:20
Some different parameter types and values for demonstration purposes
$scrpt1 = {
if(!(test-connection 'localhost' -Count 1 -Quiet)){return}
else{0..7 | % { "'"+(get-date).AddDays($_)+"'" }}
}
$scrpt2 = {
if((get-date).minute % 2 -eq 0){
@('Mon','Wed','Fri')}
else{
@('Tue','Thu','Sat')
}
@fatherjack
fatherjack / pivottable.ps1
Created July 7, 2021 07:33
Add a pivot table to an excel file with ImportExcel powershell module
<#
Assumptions
$splatExcel is a hash table used for splatting the data into the Excel file with Export-Excel. Path is the path for the file.
The Excel file has a worksheet with the name of _BatchLoadData_ which has a single table named _BatchLoadDataTable_ in it
The data table has many columns that include _JobID_ and _Batch_
Result
A worksheet is added to the workbook called _BatchLoadPvt_ which contains the pivot table that we describe
/*
To visualise the hierarchy of SQL Server Audit Events and their parent groups
I think this was originally on the Microsoft official SQL Server Books online and it possibly still is. I can however never
find it when I need it so I have taken an adjusted version and pasted it here for easy access.
Thanks to unknown Microsoft employee that got their head around the CTE and Event relationships logic to come up with this.
*/
WITH datas (EventLevel, EventParent, EventName, EventType)
@fatherjack
fatherjack / New-CompressedFileSet
Last active July 27, 2020 19:13
When you have a set of files to email and if you zip them all the zip is too large for your email limit. Zip them into a set of zip files
<#
Zips a set of files into a set of zip files with a max size to allow emailing of zip files in size-restricted email environment.
Imagine 20 evenly sized files that need to be zipped and when compressed into a single .zip file, the file is 65MB. With an Exchange
email size limit of 15MB this cannot be sent by email. Using this function you can set a ZipSize limit of 12MB and then the output
will be 5 .zip files with a size around 12MB and one of around 5MB.
No source file will be spanned across zip files so the actual balance of zip file sizes will vary.
#>
git branch -m master main
git checkout main
git push -u origin main
now go to github.com and change the default branch ot main
created with reference to https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx
@fatherjack
fatherjack / ReplaceRules_SP_DIAGNOSTICS_format
Last active January 10, 2020 13:20
ReplaceRules sp_server_diagnostics formatter
=====
For VSCode extension replacerules <https://marketplace.visualstudio.com/items?itemName=bhughes339.replacerules>
This needs to be placed in the settings.json file
dont forget to add a trailing comma to the content that you find there
and also close the final curly brace correctly
=====
"replacerules.rules": {
"Format sp_diagnostics results 01": {
"find": "><",