Skip to content

Instantly share code, notes, and snippets.

View csharpfritz's full-sized avatar
💭
Writing code LIVE on twitch.tv/csharpfritz

Jeffrey T. Fritz csharpfritz

💭
Writing code LIVE on twitch.tv/csharpfritz
View GitHub Profile
@csharpfritz
csharpfritz / githubaction.yml
Created February 26, 2024 16:47
GitHub action to build my ASP.NET Core application to run on an ARM32 Pi
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
@csharpfritz
csharpfritz / docker-compose.yml
Created February 26, 2024 16:41
Docker compose for my application to run on the Pi
version: "3"
services:
demopi:
image: fritzregistry.azurecr.io/fritz.demopi:latest
volumes:
- type: bind
- source: /home/jfritz/demopo/ClickCount.csv
- target: /app/ClickCount.csv
ports:
- "80:8080"
@csharpfritz
csharpfritz / Dockerfile
Created February 26, 2024 16:38
Dockerfile for Raspberry Pi 3b sample
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-preview-alpine AS build
ARG TARGETARCH
WORKDIR /source
# copy csproj and restore as distinct layers
COPY Fritz.DemoPi/*.csproj .
RUN dotnet restore -a $TARGETARCH
# copy everything else and build app
COPY Fritz.DemoPi/. .
@csharpfritz
csharpfritz / docker-compose.yml
Created February 26, 2024 16:34
Docker Compose to run WatchTower
version: "3"
services:
watchtower:
image: containrrr/watchtower:armhf-latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /jfritz/.docker/config.json:/config.json
command: ["--interval", "30", "--cleanup"]
restart: always
@csharpfritz
csharpfritz / program.cs
Last active February 22, 2024 15:43
Cache control header configuration for the C# in the cards website
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse =
r => {
string path = r.File.PhysicalPath;
if (path.EndsWith(".css") || path.EndsWith(".js") ||
path.EndsWith(".gif") || path.EndsWith(".jpg") ||
path.EndsWith(".png") || path.EndsWith(".svg") || path.EndsWith(".webp"))
{
TimeSpan maxAge = new TimeSpan(370, 0, 0, 0);
@csharpfritz
csharpfritz / program.cs
Created February 22, 2024 15:38
WebOptimizer configuraiton for C# in the Cards website
builder.Services.AddWebOptimizer(pipeline => {
pipeline.AddCssBundle("/css/bundle.css", new NUglify.Css.CssSettings
{
CommentMode = NUglify.Css.CssComment.None,
}, "app.css", "css/bootstrap.css", "style.css",
"css/plugins.css", "css/colors.css", "css/responsive.css");
pipeline.MinifyJsFiles("/js/jqueryCustom.js");
});
@csharpfritz
csharpfritz / home.razor
Created February 22, 2024 15:20
Razor showing the PagerPostCollection for C# in the Cards website
<h2>Recent Lessons</h2>
<PagingPostCollection
Posts="Posts" PageSize="6"
@rendermode="InteractiveWebAssembly"
SortAscending="false" />
@csharpfritz
csharpfritz / PostRepository.cs
Last active February 22, 2024 15:46
CSV repository
public class PostRepository
{
public PostRepository(IWebHostEnvironment env, IMemoryCache cache)
{
Env = env;
_Cache = cache;
}
public IHostEnvironment Env { get; }
@csharpfritz
csharpfritz / about.razor
Last active February 21, 2024 18:28
C# in the Cards About Page snippet
@page "/About"
@attribute [OutputCache(Duration = 600)]
<PageTitle>C# in the Cards - About Us</PageTitle>
<HeadContent>
<link rel="canonical" href="https://csharpinthecards.com/about" />
<meta name="title" content="C# in the Cards - About Us">
<meta name="description" content="C# in the Cards is an innovative video training series that teaches the fundamentals of C# programming language using a deck of cards. Join Microsoft instructor and Twitch streamer Jeff Fritz on this exciting journey.">
<meta name="keywords" content="C#, Programming, Learning, Video Series, Jeff Fritz, Microsoft, Twitch, Education, Coding, Deck of Cards, Interactive Learning">
@csharpfritz
csharpfritz / indexChannels.cs
Created February 24, 2023 01:20
Test Twitch Channel Indexing with ElasticSearch
public class IndexChannels {
public async Task Execute() {
var client = new ElasticClient("ID", new ApiKeyAuthenticationCredentials("API KEY"));
CreateChannelIndex(client);
await MigrateChannelsFromSqlServer(client);