Skip to content

Instantly share code, notes, and snippets.

@eegeeZA
eegeeZA / git-cleanup.ps1
Last active May 6, 2022 08:20
Clean up unnecessary local and remote branches
# WIP #
# remove *local* branches merged into origin/master
#&"git" branch -d @(git branch --merged origin/master | Select-String -Pattern "^\*|(develop|master)$" -NotMatch)
# remove *remote* branches merged into origin/master
#&"git" push origin -d @((git branch -r --merged origin/master | Select-String -Pattern ".*(origin/(qa1|qa2|prod)$)" -NotMatch) -Replace " *origin/","")
@eegeeZA
eegeeZA / run-in-git-bash.sh
Last active May 8, 2018 10:05
Visual of Full Git History
gitk --all `git reflog | cut -d " " -f 1`&
@eegeeZA
eegeeZA / add_bitbucket_total.js
Last active August 1, 2018 13:21
Add the total line number difference to Bitbucket pull requests.
(() => {
let added = 0;
let removed = 0;
const fileItem = $(".iterable-item.file");
fileItem.each((i, element) => {
added += parseInt($(element).find(".lines-added")[0].innerHTML);
removed += parseInt($(element).find(".lines-removed")[0].innerHTML);
});
@eegeeZA
eegeeZA / unique_git_authors.sh
Last active March 20, 2019 05:16
View all the unique authors on a Git repo
git log --pretty="%an <%ae>%n%cn <%ce>" | tr '[:upper:]' '[:lower:]' | sort | uniq
@eegeeZA
eegeeZA / missing_git_commit.sh
Created October 10, 2018 19:36
Example of how a commit might go "missing" when renamed on Git
git checkout -b branch1
touch test.txt
git add .
git commit -m "Commit 1"
for i in `seq 1 10`; do echo $i >> test.txt; done
git add .
git commit -m "Commit 2"
git checkout -b branch2
mv test.txt renamed.txt
git add .
@eegeeZA
eegeeZA / PetrolReminder.ics
Last active March 22, 2019 16:51
A reminder to top-up the petrol tank before the month's cycle closes
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20190327
DTEND:20190327
RRULE:FREQ=MONTHLY;WKST=MO;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-3
SUMMARY:Petrol Card
END:VEVENT
END:VCALENDAR
@eegeeZA
eegeeZA / chocolatey.ps1
Last active January 2, 2024 13:02
Chocolatey configuration for a new Windows setup
# Run as admin (https://chocolatey.org/install)
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
## Common
choco install 7zip.install -y
choco install adb --version 33.0.3 -y
choco install adobereader -y --pin
choco install anydesk.install -y
choco install chocolateygui -y --params='/ShowConsoleOutput /DefaultToDarkMode /DefaultToTileViewForLocalSource=$false'
choco install discord.install -y --pin
@eegeeZA
eegeeZA / process_gitflow.ps1
Last active October 4, 2022 07:38
Add to your Azure Pipelines (VSTS) task for closing your `release` and `hotfix` branches as per GitFlow recommendations
# Variables
$repoURL = "git@ssh.dev.azure.com:v3/example/example/example" # or "https://dev.azure.com/example/example/_git/example"
$sourceBranch = ("$env:BUILD_SOURCEBRANCH" -replace "refs/heads/")
$tagName = ($sourceBranch -replace ".*/(v.*)", '$1') # or $(Get-Date -Format yyy-MM-dd)
$userEmail = "email@example.com"
$userName = "Example"
Write-Host "##[debug] repoURL: $repoURL"
Write-Host "##[debug] sourceBranch: $sourceBranch"
Write-Host "##[debug] tagName: $tagName"
Write-Host "##[debug] userEmail: $userEmail"
@eegeeZA
eegeeZA / add_bitbucket_minimize.js
Last active February 1, 2023 08:16
Add a button to minimize the contents of a file in Bitbucket pull requests
(() => {
const fileHeading = $(".diff-container .heading").find(".aui-buttons:first");
const minimizeButton = $("<button>").addClass('aui-button').text('Minimize');
minimizeButton.click(function (element) {
const fileContents = $(element.target).closest('div.diff-container').find(".diff-content-container");
fileContents.toggle();
});
fileHeading.append(minimizeButton);
@eegeeZA
eegeeZA / fix_generated_constraint.sql
Last active January 21, 2020 10:41
Helper scripts to rename different types of T-SQL constraint names. Especially useful for fixing generated names across environments.
-- rename DEFAULT constraints --
DECLARE @sql NVARCHAR(MAX) = N''
SELECT @sql +=
-- SELECT
N'exec sp_rename ' + QUOTENAME(schemas.name + '.' + sys.default_constraints.name) + ', ''DF_' + sys.tables.name + '_' +
sys.all_columns.name + ''';'
FROM sys.all_columns
INNER JOIN sys.tables ON all_columns.object_id = tables.object_id
INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id
INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id