Skip to content

Instantly share code, notes, and snippets.

View rkttu's full-sized avatar

Jung Hyun Nam rkttu

View GitHub Profile
@rkttu
rkttu / apphost.cs
Last active November 18, 2025 06:23
A lightweight Aspire orchestration sample based on a .NET 10 file-based app.
#!/usr/bin/env dotnet
#:sdk [email protected]
#:property PublishAot=false
#:package [email protected]
#pragma warning disable ASPIRECSHARPAPPS001
using Microsoft.Extensions.Configuration;
// To specify password/secrets:
@rkttu
rkttu / Directory.Build.props
Last active November 17, 2025 03:57
A lightweight library for generating AI image prompts
<Project>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
@rkttu
rkttu / multihost.cs
Last active November 6, 2025 04:36
Multi-host File-based App
#!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk.Web
var builder = WebApplication.CreateBuilder(args);
using var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/", () => "Hello from A").RequireHost("a.dev.localhost");
app.MapGet("/", () => "Hello from B").RequireHost("b.dev.localhost");
app.MapGet("/", () => "Hello from Prod");
app.Run();
@rkttu
rkttu / Program.cs
Created October 14, 2025 13:46
File-based App Sample
#!/usr/bin/env dotnet
Console.WriteLine("Hello, World!");
@rkttu
rkttu / Program.cs
Created August 19, 2025 02:57
Running .NET in the browser without Blazor and csproj
#!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk.WebAssembly
#:property OverrideHtmlAssetPlaceholders=true
#:property AllowUnsafeBlocks=true
#:property PublishAot=false
// dotnet run Program.cs
using System.Diagnostics;
using System.Runtime.InteropServices.JavaScript;
@rkttu
rkttu / fibonacci.cs
Created August 13, 2025 08:41
Fibonacci calculation example (Top-Level statement style)
var n = 10;
var fib = new List<long> { 0, 1, };
for (var i = 2; i < n; i++)
fib.Add(fib[i - 1] + fib[i - 2]);
Console.WriteLine($"Fibonacci sequence up to {n} terms:");
Console.WriteLine(string.Join(", ", fib));
@rkttu
rkttu / script.cs
Created August 11, 2025 02:21
Native DLL example that creates an XLSX file that can be run with rundll32.exe
#!/usr/bin/env dotnet
#:package [email protected]
#:property OutputType=Library
#:property NativeLib=Shared
#:property RuntimeIdentifier=win-x64
#:property AllowUnsafeBlocks=true
// dotnet publish .\script.cs -o bin
// %windir%\system32\rundll32.exe bin\script.dll,EntryA "HelloWorld.xlsx"
// start HelloWorld.xlsx
@rkttu
rkttu / nightcurtain.cs
Created August 7, 2025 07:50
Nightcurtain is a nudge utility that gently encourages sleep by using Windows color filters instead of forcibly blocking the screen like Screen Time on macOS, and is designed to run automatically in conjunction with the Task Scheduler.
#!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk
#:property OutputType=WinExe
#:property TargetFramework=net10.0-windows
// This program can be scheduled using Windows Task Scheduler.
// Below are some example `schtasks` CLI commands to register tasks for `nightcurtain.exe`.
//
// 1. Enable color filter every night at 10:00 PM
// schtasks /Create /TN "NightCurtain_Enable" /TR "C:\Path\To\nightcurtain.exe enable" /SC DAILY /ST 22:00 /F
@rkttu
rkttu / ollama-test.linq
Created January 12, 2025 09:26
LINQpad + macOS + Ollama + LG EXAONE + C#
<Query Kind="Statements">
<NuGetReference Prerelease="true">Microsoft.SemanticKernel.Connectors.Ollama</NuGetReference>
<Namespace>Microsoft.SemanticKernel</Namespace>
<Namespace>Microsoft.Extensions.DependencyInjection</Namespace>
<Namespace>Microsoft.Extensions.Logging</Namespace>
<Namespace>Microsoft.SemanticKernel.ChatCompletion</Namespace>
<Namespace>Microsoft.SemanticKernel.Connectors.Ollama</Namespace>
<Namespace>System.Text.Json.Serialization</Namespace>
<Namespace>System.ComponentModel</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
@rkttu
rkttu / GenerateFirstTimeDdl.cs
Created October 17, 2024 02:09
How to generate SQL DDL compatible with the entire model instead of auto-migration
// Package Required: Microsoft.EntityFrameworkCore.Relational
// In this example, I am using the EF Core driver (Pomelo.EntityFrameworkCore.MySql) from the Pomelo Foundation Project to generate DDL for MariaDB.
// However, you can also use any other driver you want (Microsoft SQL Server, Sqlite, Oracle, etc.).
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;