Skip to content

Instantly share code, notes, and snippets.

@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;
@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),

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
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 / 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
@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
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 / 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
log : Restoring packages for /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.json...
info : Committing restore...
log : Writing lock file to disk. Path: /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.lock.json
log : /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.json
log : Restore completed in 918ms.
NuGet Config files used:
/Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/NuGet.config
Feeds used:
@ejsmith
ejsmith / gist:1b5f03f676fcd539f6cd
Last active January 25, 2016 22:13
session tracking
-------------------------------------
Session Tracking
-------------------------------------
Exceptionless can also track user sessions which enables powerful application analytics.
Session tracking can be enabled by simply adding this line to the startup of your application:
ExceptionlessClient.Default.Configuration.UseSessions()