Skip to content

Instantly share code, notes, and snippets.

@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
# Big idea - package following files by convention
# NuGetPackage/README.txt
# NuGetPackage/tools/install.ps1
$nuspec = @"
<?xml version="1.0"?>
<package >
<metadata>
<id>%project.name%</id>
<version>%PackageVersion%</version>
@teyc
teyc / App.xaml
Last active June 19, 2020 13:16
F# Core and WPF
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FsWpf"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>