Skip to content

Instantly share code, notes, and snippets.

@cocowalla
cocowalla / data-classification.sql
Created February 5, 2021 09:08
Conditional SQL Server Data Classification
DECLARE @compatibility_level TINYINT = 0;
SELECT @compatibility_level = compatibility_level FROM sys.databases WHERE name = 'MyDatabase';
PRINT CONCAT('Database compatibility level is: ', @compatibility_level);
IF @compatibility_level < 150
BEGIN
RAISERROR('Data Classification will not be performed, as database compatibility level %d is not high enough', 10, 1, @compatibility_level);
SET NOEXEC ON;
END;
GO
@cocowalla
cocowalla / ExponentialWeightedMovingAverage.cs
Created May 7, 2021 10:23
Exponential Weighted Moving Average
public class ExponentialWeightedMovingAverage
{
private bool isInitialized;
// Smoothing/damping coefficient
private double alpha;
public double Average { get; private set; }
public ExponentialWeightedMovingAverage(int samplesPerWindow)
@cocowalla
cocowalla / open-telemetry-config.cs
Created May 31, 2023 14:10
A rough example of how to use Serilog.Sinks.OpenTelemetry to send logs to Azure Application Insights
builder
.UseSerilog((ctx, _, logConfig) =>
{
logConfig.ReadFrom.Configuration(ctx.Configuration, "Log");
}, writeToProviders: true)
.ConfigureServices((ctx, services) =>
{
services.AddOpenTelemetry()
.ConfigureResource(res => {
...