Skip to content

Instantly share code, notes, and snippets.

ejsmith /
Created Oct 25, 2016
Benefits of using Docker Containers
  • Package format that not only contains our code, but also the entire definition of the OS that runs the code which means you get guaranteed consistency in your deployments
  • Easy deployments
    • Just tell docker to run an image from our build artifact registry
  • Simple build promotion
  • Easy scaling
  • Run console workers that will automatically be restarted based on a restart policy
  • Cheaper because we can pack more services onto a box and utilize resources more efficiently while still providing isolation and cpu / memory constraints
  • Can scale each worker independently
View migrate.ps1
function CopyPackageReferences($project, $packagesConfigPath) {
$packagesConfig = [xml](Get-Content $packagesConfigPath -Encoding UTF8)
$itemGroup = $project.CreateElement("ItemGroup")
$project.Project.AppendChild($itemGroup) | Out-Null
Write-Verbose "Found $($packagesConfig.packages.package.Length) packages to copy"
ejsmith / EmptyCollectionContractResolver.cs
Created Aug 6, 2014
View EmptyCollectionContractResolver.cs
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
private bool IsEmptyCollection(JsonProperty property, object target) {