Skip to content

Instantly share code, notes, and snippets.

View MarcBruins's full-sized avatar
🏠
Working from home

Marc Bruins MarcBruins

🏠
Working from home
View GitHub Profile
@MarcBruins
MarcBruins / digitaltransformation.md
Created February 5, 2020 09:20
Digital transformation, an introduction

Digital transformation, an introduction

Digital transformation is on top of the agendas in a lot of companies now a days. They see the digital revolution in which existing companies get crushed by new companies. There close competitors or other companies in there branch are losing to startups with profound new value propositions.

These companies inspire others to do better. But what is it they do? How can they be so successful?

The answer is: they profoundly transform there entire company. They redefine value propositions, processes and working methods. The data and IT is the foundation on which they build. They create blue oceans that rely on there digital resources. These can be existing resources, like the data that they already own or with the help of robotics, sensors, 3D printing, advanced analytics, AI, etc.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
@MarcBruins
MarcBruins / Dockerfile
Last active April 10, 2019 16:24
Plain functions dockerfile dotnet
FROM microsoft/dotnet:2.2-sdk AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.FSharp.Collections;
using Microsoft.FSharp.Core;
using NuKeeper.Abstractions.Inspections.Files;
using Paket;
namespace NuKeeper.Inspection.RepositoryInspection
{
@MarcBruins
MarcBruins / keyvault-secrets-from-appconfig.cs
Last active January 9, 2019 20:30
Read keyvault secrets from app config json
//1. Create a file for both classes
//2. Replace the IKeyVaultAccessClient with a concrete keyvault implementation
//3. Add it to the builder: builder.Add(new ReplaceTokensConfigurationSource(configuration, logger, client));
//4. Add secrets placeholder to the appsetings.json with the following pattern __secret__
/// <summary>
/// A JSON configuration source that replaces values from JSON that are tokenized with a value from Azure Key Vault,
/// using the tokenized value as lookup key.
/// </summary>
public sealed class ReplaceTokensConfigurationProvider : ConfigurationProvider, IDisposable
@MarcBruins
MarcBruins / AzureServicesAuthConnectionString.txt
Created January 7, 2019 18:36
AzureServicesAuthConnectionString sample
AzureServicesAuthConnectionString RunAs=App;AppId=YOURAPPID;TenantId=YOURTENANTID;AppKey=OPTIONALAPPKEY
@MarcBruins
MarcBruins / pwd.cs
Created January 7, 2019 18:14
db password
private string DbPassword = "MySuperSecretPassword";
@MarcBruins
MarcBruins / callingkeyvault.cs
Created January 7, 2019 18:13
calling the key vault
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
var secret = await keyVaultClient.GetSecretAsync("https://YOURKEYVAULT.azure.net/secrets/sqlAzure--AdminPassword").ConfigureAwait(false);
@MarcBruins
MarcBruins / possiblederefenceofnull.cs
Last active January 4, 2019 17:41
Possible dereference of a null reference sample
public async Task<SearchCodeResult> Search(SearchCodeRequest search)
{
foreach (var repo in search.Repos)
{
//do search stuff
}
}
class SearchCodeRequest{
public IList<string>? Repos { get; set; }
@MarcBruins
MarcBruins / returningforuri.cs
Created December 16, 2018 12:24
Return value for uri trailing slash
public static Uri EnsureTrailingSlash(Uri uri)
{
return new Uri(uri.ToString() + "/");
}
//OR
public static Uri EnsureTrailingSlash(Uri? uri)
{
if(uri == null)