Skip to content

Instantly share code, notes, and snippets.

View rkttu's full-sized avatar

Jung Hyun Nam rkttu

View GitHub Profile
@rkttu
rkttu / Program.cs
Last active March 26, 2024 23:56
GPT Prompt Builder
using System;
using System.Globalization;
public static class Program
{
private static void Main()
{
var prompt = string.Empty;
prompt = Prompt
@rkttu
rkttu / Build.cmd
Last active March 25, 2024 08:25
Windows NT Service Containerisation Examples
@echo off
pushd "%~dp0"
%windir%\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo /target:exe /r:System.ServiceProcess.dll /out:ServiceMain.exe ServiceMain.cs
%windir%\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo /target:exe /out:SimpleMain.exe SimpleMain.cs
:exit
popd
@echo on
@rkttu
rkttu / Program.cs
Created November 15, 2023 05:31
macOS wchar_t P/Invoke Sample
// Require unsafe configuration.
using System.Runtime.InteropServices;
using System.Text;
namespace HelloWorld;
internal partial class NativeMethods
{
// https://github.com/mono/mono/issues/9362
@rkttu
rkttu / .bashrc
Last active December 9, 2023 04:34
How to initialize oh-my-posh with bash (macOS), bash (WSL, Ubuntu), cmd, zsh and pwsh
# for bash (macOS)
POSH_THEMES_PATH=$(brew --prefix oh-my-posh)/themes
eval "$(oh-my-posh completion bash)"
eval "$(oh-my-posh init bash --config "$POSH_THEMES_PATH"/clean-detailed.omp.json | sed 's|\[\[ -v MC_SID \]\]|[[ -n "$MC_SID" ]]|')"
@rkttu
rkttu / Microsoft.PowerShell_profile.ps1
Last active June 6, 2023 09:18
PowerShell 7 Profile Code for macOS
# Apply this code to the path pointed to by the $PROFILE variable.
# Introduction
# This code includes asdf and oh-my-posh support in addition to brew.
# Requirements
# You must have the latest version of the PSReadLine module installed. Use the Install-Module -Name PSReadLine -AllowClobber -Force command.
# Also, you need to go to Nerd Font (https://www.nerdfonts.com/) and change the font to display the oh-my-posh prompt normally.
# Troubleshooting
@rkttu
rkttu / metadata
Last active July 7, 2022 15:36
TableCloth Contributor License Agreement
{
"name": {
"title": "Full Name",
"type": "string",
"githubKey": "name"
},
"email": {
"title": "E-Mail",
"type": "string",
"githubKey": "email",
@rkttu
rkttu / IProgram.cs
Last active June 6, 2023 09:18
Dependency Injection + Cancellation Token + Apartment State Configuration Supported Startup Framework
using Microsoft.Extensions.DependencyInjection;
public interface IProgram
{
public const int DefaultExitCode = 0;
public const int TimeoutExitCode = 124;
private static TProgram DefaultProgramFactory<TProgram>(IEnumerable<string> _)
where TProgram : IProgram
{
@rkttu
rkttu / meet-ie-again.ps1
Created June 16, 2022 06:18
Meet Internet Explorer Again 😏
Add-Type 'public class SFW { [System.Runtime.InteropServices.DllImport("user32.dll")][return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)] public static extern System.Boolean SetForegroundWindow(System.IntPtr hWnd); }'
$handle = [activator]::CreateInstance([type]::GetTypeFromCLSID("0002DF01-0000-0000-C000-000000000046"))
$handle.Visible = $true
$handle.Navigate('http://www.example.com/')
[SFW]::SetForegroundWindow($handle.HWND)
@rkttu
rkttu / Dockerfile
Last active April 28, 2022 14:27
Running ASP.NET Web API in Windows Container with LINQPad 7
FROM mcr.microsoft.com/dotnet/sdk:6.0-windowsservercore-ltsc2022 AS build
RUN powershell.exe -Command \
Invoke-WebRequest -UseBasicParsing 'https://www.linqpad.net/GetFile.aspx?LINQPad7Setup.exe' -OutFile "$home/LINQPad7Setup.exe"; \
Start-Process -FilePath "$home/LINQPad7Setup.exe" -ArgumentList "/SP-","/VERYSILENT","/SUPPRESSMSGBOXES","/NORESTART","/NOICONS" -NoNewWindow -Wait; \
rm -Force "$home/LINQPad7Setup.exe"; && \
setx.exe /M PATH "%PROGRAMFILES%\LINQPad7;%PATH%"
FROM build
@rkttu
rkttu / Dockerfile
Created April 28, 2022 14:03
LINQPad runner running on Windows Container
FROM mcr.microsoft.com/dotnet/sdk:6.0-windowsservercore-ltsc2022 AS build
RUN powershell.exe -Command \
Invoke-WebRequest -UseBasicParsing 'https://www.linqpad.net/GetFile.aspx?LINQPad7Setup.exe' -OutFile "$home/LINQPad7Setup.exe"; \
Start-Process -FilePath "$home/LINQPad7Setup.exe" -ArgumentList "/SP-","/VERYSILENT","/SUPPRESSMSGBOXES","/NORESTART","/NOICONS" -NoNewWindow -Wait; \
rm -Force "$home/LINQPad7Setup.exe"; && \
setx.exe /M PATH "%PROGRAMFILES%\LINQPad7;%PATH%"
FROM build