Skip to content

Instantly share code, notes, and snippets.

View chrisfcarroll's full-sized avatar
🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼

Chris F Carroll chrisfcarroll

🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼
View GitHub Profile
@chrisfcarroll
chrisfcarroll / scram_postgres_password.py
Last active May 15, 2021 22:43 — forked from jkatz/encrypt_password.py
Method to create password hashes for PostgreSQL 10+
#! /usr/bin/env python3
# Taken from https://blog.crunchydata.com/blog/how-to-upgrade-postgresql-passwords-to-scram
help= \
"""
Generate scram-sha-256 password hashes / verifiers for PostgreSQL 10+
Usage:
scram_postgres_password Username1 Password1 [, ... UsernameN PasswordN ]
#! /usr/bin/env pwsh
<#
.SYNOPSIS
Create a Postgres application database and roles for owner, application, and application_readonly
.DESCRIPTION
Create a Postgres application database and create roles for owner, application, and application_readonly.
- the owner role has no login. the user that runs this script will be assigned to that role
@chrisfcarroll
chrisfcarroll / Install-EmptyUmbraco9.ps1
Last active July 2, 2021 20:04
Install-EmptyUmbraco9 for unattended install
#! /usr/bin/env pwsh
Param(
[string]$installerName="Installer",
[Parameter(Mandatory=$true)][string]$installerPassword,
[Parameter(Mandatory=$true)][ValidateScript(
{try{[System.Net.Mail.MailAddress]$_;return $true;}catch{return $false}})]
[string]$installerEmail,
[string]$dbServer=$env:SQLCMDSERVER,
[string]$dbDatabaseName="Umbraco",
@chrisfcarroll
chrisfcarroll / strings.cs
Last active December 11, 2021 17:59
Extended alternatives for <c>string.Join(…)</c> methods to omit null, empty, or whitespace-only items
/// <summary>Extended alternatives for <c>string.</c> methods</summary>
// ReSharper disable once InconsistentNaming
public static class strings
{
/// <summary>Joins the non-null items of <paramref name="values"/>, putting <paramref name="separator"/>
/// between each item.</summary>
/// <param name="separator">Separator is only used if <paramref name="values"/> has at least
/// 2 non-null elements.</param>
/// <param name="values">The values to join.</param>
/// <typeparam name="T"></typeparam>
@chrisfcarroll
chrisfcarroll / bootstrap-macOs.zsh
Last active March 16, 2022 12:51
Bootstrap macOs fresh install. Part 1
#! /bin/zsh
#
# Manual Install packages
open https://www.sublimetext.com
open https://www.perforce.com/downloads/visual-merge-tool
open https://dotnet.microsoft.com
open https://code.visualstudio.com
open https://my.parallels.com
open https://brew.sh
open https://www.wolfram.com/mathematica/
@chrisfcarroll
chrisfcarroll / LowerCaseIdentifiersForAppDbOnPostgres.cs
Last active May 16, 2022 22:06
.Net DbContext for Postgres that lowercases identifiers so that quotes are not needed everywhere
public class AppDbOnPostgres : DbContext
{
public AppDbOnPostgres(NpgsqlConnection dbConnection):base(dbConnection){}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql(dbConnection)
.ReplaceService<ISqlGenerationHelper,NpgsqlSqlGenerationLowercasingHelper>();
}
#nullable enable
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace LogAssert
{
@chrisfcarroll
chrisfcarroll / Uninstall-Programs-Or-Features.ps1
Last active September 28, 2022 12:09
PowerShell commandline Uninstall-Programs-Or-Features.ps1
<#
.SYNOPSIS
Uninstall one or more Windows Program or Feature, by name or regular expression.
.DESCRIPTION
Lists Programs And Features installed on the current machine which match
the -matchingName parameter and then, after force or confirmation, uninstalls them.
Examples
// ==UserScript==
// @name Trello Wrap-n-Stack-To-Fit
// @namespace http://tampermonkey.net/
// @version 0.73
// @description Trello: Auto-wrap, stack and resize your Trello lists so they don't go offscreen. And kill that horizontal scroll-bar.
// @author chrisfcarroll
// @match https://trello.com/*
// @grant none
// ==/UserScript==
// jshint -W097
@chrisfcarroll
chrisfcarroll / azcommandlineexamples.sh
Created January 28, 2023 16:42
Show some example az cli commands to create and delete a VM
#! /usr/bin/env sh
cat << 'EOF'
Get pricing:
location.href="https://prices.azure.com/api/retail/prices?$skip=0&currencyCode='GBP'&$filter=location eq 'UK South' and serviceName eq 'Virtual Machines' and priceType eq 'Consumption'"
Create Spot VM
az vm create -g VM --name VM --admin-username azureuser --image CentOS --generate-ssh-keys --public-ip-sku Standard --priority Spot --eviction-policy Delete
Destroy VM