Skip to content

Instantly share code, notes, and snippets.

@ejsmith
ejsmith / containers.md
Created October 25, 2016 16:23
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
param(
[Parameter(Mandatory=$true)]
[string]$TargetFolder
)
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
ejsmith / Program.cs
Created September 15, 2021 06:21
Rosyln .NET 6 RC1 bug
using System.Linq.Expressions;
using System.Reflection;
SomeMethod((Employee e) => e.Name);
void SomeMethod(Field field) {}
public record Employee(string Name);
public class Field
@ejsmith
ejsmith / mac-arm-brew-setup.md
Last active January 4, 2023 00:58 — forked from niemyjski/mac-arm-brew-setup.md
Arm Mac New Install (Brew)
  • xcode-select --install
  • softwareupdate --all --install --force
  • softwareupdate --install-rosetta --agree-to-license
  • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Brew
    • brew install --cask microsoft-edge
    • brew install --cask 1password
    • brew install --cask microsoft-teams
    • brew install --cask slack brew install zoom
using Foundatio.Queues;
using System.Collections.Concurrent;
using Microsoft.Extensions.DependencyInjection;
namespace Contacts.Domain.Services;
public interface INamedRegistrationFactory<T> where T : class {
/// <summary>
/// Get instance by name
/// </summary>
@ejsmith
ejsmith / EmptyCollectionContractResolver.cs
Created August 6, 2014 16:41
EmptyCollectionContractResolver
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) {

Test Automation

  • PPA
    • This decision should be isolated from what has already been done for CSS
    • CSS is a different beast and has terminal emulation mixed in (although I'm sure you could use node-pty)
    • Very long term goal with PPA is to replace CSS and massively simplify our entire product / tech stack
    • Plan is to keep the project as a mono repository so we aren't going to be spread out across a bunch of repos like CSS where it makes sense for the automation tests to be in yet another repo
  • Stack complexity
    • Business is mandating MS tech stack and reducing stack complexity
  • Adding an additional language / framework to the mix is not in line with that mandate
@ejsmith
ejsmith / FetchClient.ts
Created August 17, 2023 04:08
Svelte Fetch wrapper
import { writable, derived } from "svelte/store";
import { goto } from "$app/navigation";
function createCount() {
const { subscribe, set, update } = writable(0);
return {
subscribe,
increment: () => update((n) => n + 1),
decrement: () => update((n) => n - 1),
@ejsmith
ejsmith / AutoValidation.cs
Created August 29, 2023 04:51
Auto validation
using System.IO.Pipelines;
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Logging.Abstractions;
using MiniValidation;
using WebApplication6.Validation;