Skip to content

Instantly share code, notes, and snippets.

@tonesandtones
tonesandtones / Startup.cs
Created December 8, 2023 05:27
Simple logging middleware
// TODO: REMOVE
app.Use(async (ctx, next) => {
var logger = app.ApplicationServices.GetRequiredService<ILogger>();
var path = ctx.Request.Path;
logger.LogInformation($"Path = {path}");
foreach (var header in ctx.Request.Headers.ToList())
{
string value = string.Join(':', header.Value.ToList());
logger.LogInformation($"Header '{header.Key}' = '{value}'");
}
-- Add source
dotnet nuget add source C:\dev\nuget\local
-- pack a package
dotnet pack --no-build --no-restore /p:Version=0.1.23-prerelease-01
-- publish
dotnet nuget push -s C:\dev\nuget\local .\src\<project>\bin\Debug\<project>.0.1.23-prerelease-01.nupkg
@tonesandtones
tonesandtones / .gitconfig
Last active November 17, 2021 04:58
Windows Git credential manager in WSL
[credential]
helper = /mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe
# or
# $ git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"
@tonesandtones
tonesandtones / .gitconfig
Created November 17, 2021 04:55
Nested git config
# https://stackoverflow.com/a/48088291
[includeIf "gitdir:~/toplevelFolder1/"]
path = ~/topLevelFolder1/.gitconfig_include
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "shell",
"style": "plain",
@tonesandtones
tonesandtones / .posh.tones.iterm2.json
Last active July 23, 2021 02:43
Oh-My-Posh iterm2 config - Tones variant
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"type": "shell",
"style": "powerline",
"powerline_symbol": "\uE0B0",
@tonesandtones
tonesandtones / Microsoft.PowerShell_profile.ps1
Last active February 10, 2023 08:41
Tones' Oh-my-Posh PowerShell profile
#Tones' Oh-My-Posh Powershell profile
# One time setup: https://ohmyposh.dev/docs/installation/windows (or your OS of choice)
# Install-Module -Name Terminal-Icons -Repository PSGallery
Import-Module Terminal-Icons
oh-my-posh init pwsh --config "~/posh/.posh.tones.honukaiterm.json" | Invoke-Expression
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
@tonesandtones
tonesandtones / deploy.bicep
Created February 25, 2021 07:19
deploy.bicep
// See the original in context at https://github.com/tonesandtones/link-redirector/blob/238a142577e72070010eb6643726bc8b94899b69/deploy/deploy.bicep
param location string = resourceGroup().location
param appBaseName string = 'linky'
param environmentSuffix string {
default: 'dev'
allowed: [
'dev'
'prod'
]
@tonesandtones
tonesandtones / regional-vnet-integration-arm-snippet.json
Last active February 8, 2021 04:18
ARM snippet for defining an App Service Regional VNet Integration
{
"type": "Microsoft.Web/sites/networkConfig",
"name": "[concat(parameters('webAppName'),'/VirtualNetwork')]",
"apiVersion": "2016-08-01",
"properties":
{
"subnetResourceId": "[parameters('subnetResourceId')]",
"swiftSupported": true
}
}
@tonesandtones
tonesandtones / PowershellSnippets.ps1
Last active September 10, 2019 06:54
Powershell snippets
#Read an environment variable where the name is given in another variable
$EnvironmentVariableVariableName = "VAR_NAME_HERE"
$value = (Get-Item env:$EnvironmentVariableVariableName).Value
## Decode an ARM output block as JSON and set the output variables as Azure DevOps pipeline variables
#include iterating over the PsCustomObject field names (which are the variable names) and using them as property keys to access the values
$outputBlockAsJson = '{"variable1":{"type":"string","value":"value1"},"variable2":{"type":"string","value":"value2"}}'
$outputs = $outputBlockAsJson | ConvertFrom-Json