Skip to content

Instantly share code, notes, and snippets.

@tonesandtones
tonesandtones / HangfireStatsCollector.cs
Created January 18, 2018 07:39
Hangfire stats collector Azure Function
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Flurl.Http;
@tonesandtones
tonesandtones / RowIndexAndValueChange
Last active July 18, 2018 09:34
PowerBI DAX for Index and Value Change fields
--2018-07-18 Updated to use new RANKX function to deal with duplicate timestamp values.
--
--When there are duplicate timestamp values in the dataset, using the previous method (with EARLIER()) would create
--index values that run, eg, 122, 123, 123, 125, 126.
--Supposing therer were 100 new items per row, and ~5000 total (so total would run 4900, 5000, 5100, 5200, etc),
--the ValueChange would run 100, 100, 5000(!!), 100, 100.
--Now, using a RANKX() with Dense enumeration (https://msdn.microsoft.com/en-us/query-bi/dax/rankx-function-dax),
--we can get dense indices that don't skip, so we can lookup Index-1 and know it always exists.
------------------------------------------
--Transact-SQL script to identify and report tables/columns linked by circular FK references
--Original source https://azure.microsoft.com/en-us/blog/finding-circular-foreign-key-references/
--Reformatted by tonesandtones and verified working against a new Azure SQL DB instance on 2018-07-16
--
--
--Produces output like this:
-- dbo.Triggers -> dbo.Conversations -> dbo.Triggers
-- dbo.Conversations -> dbo.Triggers -> dbo.Conversations
-- dbo.AbpOrganizationUnits -> dbo.AbpOrganizationUnits
-- dbo.AbpUsers -> dbo.AbpUsers
@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
@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 / 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 / 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 / .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",
{
"$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 / .gitconfig
Created November 17, 2021 04:55
Nested git config
# https://stackoverflow.com/a/48088291
[includeIf "gitdir:~/toplevelFolder1/"]
path = ~/topLevelFolder1/.gitconfig_include