Skip to content

Instantly share code, notes, and snippets.

View Philo's full-sized avatar

Phil Oyston Philo

  • Lenus Health
  • Edinburgh
View GitHub Profile
@Philo
Philo / DynamicMaskingMigrationHelperExtension.cs
Last active October 31, 2023 15:50
Generate EF migration to add or drop dynamic data masking on a column
// https://learn.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking?view=sql-server-ver15
public static class DynamicMaskingMigrationHelperExtension
{
// Apply a data masking function to a column that previously had no mask function applied
public static void AddDynamicColumnMask(this MigrationBuilder migrationBuilder, string tableName, string columnName, string maskFunction = "default()")
{
if(migrationBuilder.IsSqlServer())
{
migrationBuilder.Sql($@"ALTER TABLE [{tableName}] ALTER COLUMN [{columnName}] ADD MASKED WITH(FUNCTION = '{maskFunction}');");
}
@Philo
Philo / GitVersion.yml
Created August 5, 2020 15:47
For anyone using GitVersion with a main instead of master branch
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{MajorMinorPatch}+{BranchName}+{ShortSha}'
mode: Mainline
branches:
release:
mode: ContinuousDelivery
tag: ''
master:
regex: (^master$|^origin\/master$|^main$|^origin\/main$)
@Philo
Philo / ConfigureForwardedHeadersOptions.cs
Last active June 20, 2019 20:26
Configure proxy headers .net core.
namespace Philo.Start.Forwarding
{
using System;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
@Philo
Philo / openpgp.txt
Created June 5, 2019 19:09
OpenKeychain Linked Identity
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:960edcaf4d44f55e1a754c38821cce109d2e0f20]
@Philo
Philo / ISmtpMailDeliverySettings.cs
Last active October 18, 2022 17:22
Using .net 4.7.1 configuration builders to configuration SmtpClient from AppSettings - https://github.com/aspnet/MicrosoftConfigurationBuilders
public interface ISmtpMailDeliverySettings
{
string Host { get; }
int Port { get; }
string Username { get; }
string Password { get; }
bool EnableSSL { get; }
}
@Philo
Philo / keybase.md
Created April 20, 2017 10:51
keybase.md

Keybase proof

I hereby claim:

  • I am philo on github.
  • I am philo (https://keybase.io/philo) on keybase.
  • I have a public key whose fingerprint is EC3A 8DD6 7579 7E06 830E 69FF 73BE D2FD 127A 81B5

To claim this, I am signing this object:

@Philo
Philo / logging.cs
Last active August 29, 2015 14:22
Func's for Logging
public class MyObject {
public string Message {get;set; }
}
public class Program {
public static void Main() {
MyObject myObj = null;
Log(myObj.Message); // this will explode in your face with an exception
Log(() => return myObj.Message); // this will actually log another message because we caught the exception when the func was invoked