View AspNetCoreFmSample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using AzureFromTheTrenches.Commanding; | |
using AzureFromTheTrenches.Commanding.Abstractions; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; |
View FunctionAppConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FunctionAppConfiguration : IFunctionAppConfiguration | |
{ | |
public void Build(IFunctionHostBuilder builder) | |
{ | |
builder | |
.Setup((serviceCollection, commandRegistry) => | |
{ | |
serviceCollection | |
.AddCosmosRepository(Environment.GetEnvironmentVariable("cosmosConnectionString", EnvironmentVariableTarget.Process)); | |
// rest of registration |
View BearerTokenValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BearerTokenValidator : ITokenValidator | |
{ | |
private static readonly IConfigurationManager<OpenIdConnectConfiguration> ConfigurationManager; | |
static BearerTokenValidator() | |
{ | |
string domain = Environment.GetEnvironmentVariable("domain"); | |
string wellKnownEndpoint = $"https://{domain}/.well-known/openid-configuration"; | |
var documentRetriever = new HttpDocumentRetriever { RequireHttps = wellKnownEndpoint.StartsWith("https://") }; |
View getUmbracoPropertyContent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select cpd.* from cmsPropertyData cpd | |
inner join cmsPropertyType cpt | |
on cpt.id = cpd.propertytypeid | |
and cpt.Alias='%propname%' |
View gitChangeStatsByDay.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not the best written script in the world but it does a job. | |
Param( | |
[string]$path="stats.csv" | |
) | |
$commitHashes = git log --pretty=format:"%h" | |
$commitDates = git log --pretty=format:"%ad" --date=short | |
$deletions = @() | |
$additions = @() | |
$changesOverTime = @() |
View RedBlackTree.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
namespace OpinionatedCode.Collections | |
{ | |
public sealed class RedBlackTree<TKey, TValue> | |
{ | |
private readonly RedBlackTreeNode<TKey, TValue> _leaf = RedBlackTreeNode<TKey, TValue>.CreateLeaf(); |
View gist:87c31114ebde542f82cbb9c2fe2ae7c6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Nuget packages included: | |
- AzureFromTheTrenches.Commanding 6.1.0 | |
- AzureFromTheTrenches.Commanding.MicrosoftDependencyInjection 6.1.0 | |
- Microsoft.Extensions.DependencyInjection 2.0.0 | |
*/ | |
using System; | |
using System.Threading.Tasks; | |
using AzureFromTheTrenches.Commanding; |
View MapAppServiceDomain.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading.Tasks; | |
using Microsoft.IdentityModel.Clients.ActiveDirectory; | |
using Newtonsoft.Json.Linq; | |
static class DomainMapper |
View routeProfileRenderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When given a set of GPS points and a container DOM element the code below will render a 3d profile of your GPS route. | |
// It requires three.js and that libraries associated Orbit Controls to run. | |
// The gpsPoints parameter should be an array with the following structure: | |
// [{latitude:0.323234,longitude:56.23244,altitude:1.8},...] | |
// To use in most browers compile with Babel as it uses a smattering of ES2015 | |
export default function attachRenderer(container, gpsPoints) { | |
const THREE = window.THREE | |
// haversine formula calcuates the distance in km between two points of lon,lat | |
function haversineDistanceKm(lon1,lat1,lon2,lat2) { | |
function toRad(deg) { |
View RedirectRootToSwagger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using Owin; | |
namespace MyApplication.Api.Extensions | |
{ | |
// ReSharper disable once InconsistentNaming | |
public static class IAppBuilderExtensions | |
{ | |
public static IAppBuilder RedirectRootToSwagger(this IAppBuilder app) | |
{ |
NewerOlder