Skip to content

Instantly share code, notes, and snippets.

@teyc
teyc / SerilogTraceListener.cs
Last active March 11, 2024 12:05
Enterprise Log Lib Serilog Listener
[ConfigurationElementType(typeof(CustomTraceListenerData))]
public class SerilogTraceListener: CustomTraceListener
{
public override void Write(string message)
{
}
public override void WriteLine(string message)
{
@teyc
teyc / index.html
Created June 3, 2019 20:48
Monitoring Health Checks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Health Check Status</title>
<link href="//unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="index.css">
@teyc
teyc / Command line
Last active August 22, 2022 08:34
OSX for Windows
open -e README.txt
@teyc
teyc / README.md
Last active February 14, 2022 23:05
Notes on Rails

Fedora dependencies

dnf install -y patch autoconf automake bison bzip2 gcc-c++ libffi-devel libtool libyaml-devel make patch readline-devel sqlite-devel zlib-devel openssl-devel glibc-devel
dnf install -y cmake ImageMagick-devel findutils procps vim
@teyc
teyc / BuildAndRun.ps1
Last active January 31, 2022 23:43
AspNetCore running as Windows Service
dotnet build
$binPath=(Get-Item bin\Debug\net6.0\*.exe).FullName
# Installs service
sc.exe create EML.AspNetCoreWindowsService binPath=$binPath DisplayName="Demo AspNetCore Windows Service"
# Starts service, hits the URL, stop-service
start-service EML.AspNetCoreWindowsService; curl.exe http://localhost:5000/; stop-service EML.AspNetCoreWindowsService
@teyc
teyc / newcert.ps1
Created December 5, 2021 21:32
Self Signed Cert for ASP.net core
new-selfsignedcertificate
https://www.fearofoblivion.com/setting-up-asp-net-dev-certs-for-both-wsl-and-windows
[req]
prompt = no
default_bits = 2048
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
@teyc
teyc / A.LogFile.Shipper.To.Seq.csproj
Last active June 25, 2021 07:37
Ships log files to Seq
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
@teyc
teyc / PostgresEF.cs
Created April 25, 2021 06:51
Prototyping web applications
// <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.3" />
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql("Host=my_host;Database=my_db;Username=my_user;Password=my_pw");
}
@teyc
teyc / web.fsx
Last active April 11, 2021 22:38
F# snippets
(* creates a web server in F# script *)
#I @"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.4"
#r "Microsoft.AspNetCore"
#r "Microsoft.AspNetCore.Routing"
#r "Microsoft.AspNetCore.Http.Abstractions"
#r "Microsoft.AspNetCore.Hosting"
#r "Microsoft.AspNetCore.Diagnostics"
#r "Microsoft.AspNetCore.Hosting.Abstractions"
#r "Microsoft.Extensions.DependencyInjection.Abstractions"
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace MyDankyWebServer