Skip to content

Instantly share code, notes, and snippets.

@sdcondon
sdcondon / SqlServerDockerfile
Last active December 22, 2020 13:03
Dockerfile for a SQL server instance built to include a database defined in a given SQL script
# A couple of references:
# - https://github.com/twright-msft/mssql-node-docker-demo-app (sql setup, but at run-time)
# - https://www.wintellect.com/devops-sql-server-dacpac-docker/ (build-time setup, but of DACPAC)
FROM mcr.microsoft.com/mssql/server:2017-latest AS final
# Copy schema.sql from wherever into a tmp directory in the image
# This file is assumed to include all your DB objects as CREATE statements
COPY /TestDatabase/schema.sql /tmp/schema.sql
@sdcondon
sdcondon / DacpacDockerfile
Created December 20, 2020 23:35
Dockerfile for building and deploying a DACPAC
# This dockerfile is a combination of two things:
# * A dotnet build of a csproj assumed to use the SqlProj SDK found here - https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/
# * Building on a SQL Server image to deploy a DACPAC, adapted from https://www.wintellect.com/devops-sql-server-dacpac-docker/
# First, the dotnet build of the DACPAC. The csproj referenced here should be
# one that uses this SDK: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["TestDb/TestDb.csproj", "TestDb/"]
RUN dotnet restore "TestDb/TestDb.csproj"
@sdcondon
sdcondon / LinqDecomposer.cs
Last active October 12, 2019 09:09
Uses LINQ expressions to decompose and recompose objects, storing each property in a different backing store.
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq.Expressions;
/// <summary>
/// Decomposes <see paramref="TValue"/> objects and stores their properties in separate backing stores.
/// Useful if individual properties can be stored more efficiently (e.g. spatial indexing).
/// </summary>
/// <typeparam name="TKey">The type of the key by which objects will be stored.</typeparam>
@sdcondon
sdcondon / ExtensionScripts.cs
Created November 12, 2017 11:11
Basic example of using MEF and the Roslyn scripting API to create a scriptable extension system.
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System;
using System.Collections.Generic;
using System.Composition;
using System.Composition.Hosting;
using System.Composition.Hosting.Core;
using System.IO;
using System.Linq;
using System.Reflection;
@sdcondon
sdcondon / Trie.cs
Last active November 22, 2020 17:11
Generic prefix tree, implementing IDictionary<TKey, TValue>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Prefix tree implementation.
/// </summary>
/// <typeparam name="TKey">The type of the individual elements of the keys in the trie.</typeparam>
/// <typeparam name="TValue">The type of values in the trie.</typeparam>
@sdcondon
sdcondon / BlockingCollectionBatchPipeline.cs
Last active September 24, 2017 11:16
A simple periodic batching pipeline using BlockingCollections
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
class BatchingPipelineDemo
{
// "Environmental" factors
private static Random Rnd = new Random();