Skip to content

Instantly share code, notes, and snippets.

View wsmelton's full-sized avatar
🦆
Little bit of this, little bit of that

Shawn Melton wsmelton

🦆
Little bit of this, little bit of that
View GitHub Profile
@wsmelton
wsmelton / thycotic_terminal_theme.json
Created September 22, 2020 23:30
Thycotic Theme for Windows Terminal
{
"name": "thycotic",
// entire background
"background": "#081F2C",
// default text
"foreground": "#B3D565",
//quoted values
"cyan": "#3CC4E5",
// commands
"brightYellow": "#80BB01",
@wsmelton
wsmelton / ignoreCertPolicy.ps1
Created August 17, 2020 14:06
Working with sites that have untrusted cert for site, where CA may not be accessible, etc.
if (-not("dummy" -as [type])) {
add-type -TypeDefinition @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static class Dummy {
public static bool ReturnTrue(object sender,
X509Certificate certificate,
@wsmelton
wsmelton / keybindings.json
Created August 2, 2020 03:16
Keybindings VS Code
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "alt+up",
"command": "workbench.action.navigateUp"
},
{
"key": "alt+down",
"command": "workbench.action.navigateDown"
},
@wsmelton
wsmelton / keybindings.json
Created August 2, 2020 03:16
Keybindings VS Code
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "alt+up",
"command": "workbench.action.navigateUp"
},
{
"key": "alt+down",
"command": "workbench.action.navigateDown"
},
@wsmelton
wsmelton / Add-TextToBitMap.ps1
Created March 20, 2020 01:16
Trying to add text to a give bmp image file
#Ref: https://stackoverflow.com/a/6827017/12974596
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");
$file = Get-ChildItem 'C:\temp\template.bmp'
$img = New-Object System.Drawing.BitMap($file.FullName)
$newFile = 'C:\temp\eureka.bmp'
[String]$drawString = "lab-ss-01 server"
$colorBlue = (New-Object System.Drawing.ColorConverter).ConvertFromString("blue")
$drawFont = New-Object -TypeName System.Drawing.Font -ArgumentList "Arial",16
$drawBrush = New-Object -TypeName System.Drawing.SolidBrush -ArgumentList $colorBlue
[float]$x = '150.0'
@wsmelton
wsmelton / jl.ps1
Last active February 25, 2020 20:17
Quick function to start up JupyterLab using dotnet interactive
function jl {
[cmdletbinding()]
param ([string]$folder)
if ([String]::IsNullOrEmpty($folder)) {
& jupyter lab --notebook-dir=$pwd
} else {
& jupyter lab --notebook-dir=$folder
}
}
@wsmelton
wsmelton / snippet.md
Last active January 10, 2020 04:48
Create a snippet for PSCredential in VS Code

Sometimes you just need to create a PSCredential object in your PowerShell script. In VS Code I was not able to find any snippet that did this so created one.

You can add this to the powershell.json snippet file for your VS Code instance. Use Command Palette > Configure User Snippets > PowerShell to open that file.

Then paste the code in the json file of this Gist.

You can use either cred or pscred to bring up the snippet in any editor set to the PowerShell language:

$Global:baseUri = 'https://management.azure.com'
$Global:subScription = "subscriptions/<add subscription guid>"
$Global:resourceGroup = "resourceGroups/genera-rg"
$Global:AzureSqlProvider = "providers/Microsoft.Sql"
$Global:AzureApiVersion = "?api-version=2017-10-01-preview"
function New-AuthToken {
$token = az account get-access-token --resource="$baseUri" --output json | ConvertFrom-Json
$global:header = @{
'Content-Type' ='application\json'
@wsmelton
wsmelton / Reset-BranchToUpstream.ps1
Last active November 8, 2019 14:31
Function you can add to your profile for resetting a given branch in your fork to the upstream branch.
function Reset-BranchToUpstream {
<#
.SYNOPSIS
Command to reset the branch to your upstream remote
.DESCRIPTION
Assumes you remote is setup as origin is your fork, and "upstream" is the remote source. You can pass in a branch, and it assumes you have this branch checked out on your origin or local repository.
.PARAMETER Branch
The desired branch you want to sync
.EXAMPLE
Reset-BranchToUpstream -Branch development
@wsmelton
wsmelton / AzDependencies.json
Created October 8, 2019 19:11
Json file of the Az modules and their dependencies.
[
{
"Name": "Az.Accounts",
"Dependencies": null
},
{
"Name": "Az.Automation",
"Dependencies": "Az.Accounts"
},
{