Skip to content

Instantly share code, notes, and snippets.

View rkttu's full-sized avatar

Jung Hyun Nam rkttu

View GitHub Profile
@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;
@rkttu
rkttu / ModernWinForm.cs
Last active March 25, 2025 13:22
Windows Forms + Generic Host + Dependency Injection + MVVM + Command in .NET 8
/*
<!-- Project Configuration -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>false</UseWPF>
<ImplicitUsings>disable</ImplicitUsings>
@rkttu
rkttu / Dockerfile
Created September 25, 2024 09:28
Create My Own WSL distro with Dockerfile
FROM ubuntu:22.04
RUN sed -i -e 's/archive.ubuntu.com/mirror.kakao.com/g' /etc/apt/sources.list
RUN set -xe \
&& apt -y update \
&& apt -y install apt-utils tzdata locales
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
@rkttu
rkttu / garnet-chat-demo.linq
Last active December 20, 2024 04:20
Garnet Technical Demo
<Query Kind="Statements">
<NuGetReference>Microsoft.Extensions.Caching.StackExchangeRedis</NuGetReference>
<NuGetReference>Microsoft.Garnet</NuGetReference>
<Namespace>Garnet</Namespace>
<Namespace>Garnet.server</Namespace>
<Namespace>Garnet.server.Auth.Settings</Namespace>
<Namespace>Microsoft.AspNetCore.Builder</Namespace>
<Namespace>Microsoft.AspNetCore.Http</Namespace>
<Namespace>Microsoft.Extensions.DependencyInjection</Namespace>
<Namespace>StackExchange.Redis</Namespace>
@rkttu
rkttu / local-policy-list.linq
Last active July 5, 2024 08:08
Local Group Policy Enumeration Code Sample
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.DirectoryServices.dll</Reference>
<Namespace>Microsoft.Win32</Namespace>
<Namespace>Microsoft.Win32.SafeHandles</Namespace>
<Namespace>System.ComponentModel</Namespace>
<Namespace>System.DirectoryServices</Namespace>
<Namespace>System.Runtime.InteropServices</Namespace>
<Namespace>System.Security.Principal</Namespace>
<Namespace>System.Collections.ObjectModel</Namespace>
</Query>
@rkttu
rkttu / Program.cs
Created June 11, 2024 04:26
Sample code to use Mono.TextTemplating in-memory without file input/output
// This sample code requires Mono.TextTemplating.Roslyn >= 2.3.1 nuget package
using System;
using Microsoft.VisualStudio.TextTemplating;
using Mono.TextTemplating;
using System.CodeDom.Compiler;
using System.Threading;
using System.Threading.Tasks;
internal static class Program
@rkttu
rkttu / azure-packer-like-demo.linq
Last active April 29, 2024 05:39
Create Azure Windows VM, Connect WinRM, RDP with LINQPad (Demo)
/*
After running as administrator
- Entering the "winrm quickconfig" command if this is your first time setting up winrm
- If you get an error message that says it failed because your network profile is set to public, that's okay.
- To allow all external connections, run "winrm s winrm/config/client @{TrustedHosts="*"}" command
- After you're done testing, run the "winrm s winrm/config/client @{TrustedHosts=""}" command
*/
var credential = default(TokenCredential);
@rkttu
rkttu / EncDecTest.cs
Created April 9, 2024 14:51
RDP Password Embedding Sample
using System;
using System.Security.Cryptography;
// Original Source Code: https://github.com/RedAndBlueEraser/rdp-file-password-encryptor
// System.Security.dll required
public static class Program
{
public static void Main()
{
@rkttu
rkttu / Program.cs
Last active April 5, 2024 22:34
GPT Prompt Builder
using System;
using System.Globalization;
public static class Program
{
private static void Main()
{
var prompt = string.Empty;
prompt = Prompt