Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jung Hyun Nam rkttu

🎯
Focusing
View GitHub Profile
@rkttu
rkttu / IProgram.cs
Last active Jul 3, 2022
Dependency Injection + Cancellation Token + Apartment State Configuration Supported Startup Framework
View IProgram.cs
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 Jun 16, 2022
Meet Internet Explorer Again 😏
View meet-ie-again.ps1
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 Apr 28, 2022
Running ASP.NET Web API in Windows Container with LINQPad 7
View Dockerfile
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 Apr 28, 2022
LINQPad runner running on Windows Container
View Dockerfile
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 / ConvertTo-AnimatedGif.ps1
Created Oct 28, 2021
Animated GIF conversion PowerShell function
View ConvertTo-AnimatedGif.ps1
function ConvertTo-AnimatedGif {
param (
[string]$VideoFilePath = $(Read-Host -Prompt 'Enter a video file path.'),
[int]$FramePerSeconds = 10,
[int]$Scale = 320,
[switch]$Verbose
)
$ffmpegCommand = (Get-Command -ErrorAction Ignore 'ffmpeg.exe')
@rkttu
rkttu / create_selfsigned_codesign.cmd
Created Jul 9, 2021
Self-signed Code Sign Certificate Generator
View create_selfsigned_codesign.cmd
@echo off
pushd "%~dp0"
REM Please run this batch script inside Windows SDK or Visual Studio command prompt.
SET CN=MyCN
if exist CA.cer (
certutil.exe -user -delstore Root CA.cer
del /f CA.cer
@rkttu
rkttu / CTest.cpp
Last active Mar 22, 2021
C++/CLI and C# Interop Sample - For Complete Source Code, Go to https://github.com/level120/CsharpCppSample
View CTest.cpp
#include "pch.h"
#include "CTest.h"
using System::Runtime::InteropServices::Marshal;
CTest::CTest()
{
this->pVaListener = new CVaListenerUnmanaged();
this->pVaListenerManaged = gcnew CVaListenerManaged();
}
@rkttu
rkttu / CSharp Sample.ipynb
Created Nov 21, 2020
닷넷 인터랙티브 기반 C# 기초 강좌 샘플
View CSharp Sample.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rkttu
rkttu / docker2wsl.cmd
Created Oct 25, 2020
Docker container to WSL convert
View docker2wsl.cmd
@echo off
pushd "%~dp0"
rem Example: docker2wsl ubuntu:latest myubuntu
docker pull %1
docker run -d --name %2 %1 /bin/sh > %TEMP%\ctrid.txt
set /p CTRID= < %TEMP%\ctrid.txt
if exist %TEMP%\ctrid.txt del /f /q %TEMP%\ctrid.txt
@rkttu
rkttu / README.md
Last active Nov 7, 2020
KCD 2020 Online Code Sample {WSLHUB]
View README.md

프로그래밍 방식으로 WSL 배포판 안의 사용자를 조회하는 방법

이 코드 샘플은 프로그래밍 방식으로 WSL 배포판 안의 사용자를 조회할 수 있는 방법을 설명합니다. Win32 API를 주로 사용하였고, 일부 편의를 위하여 C# 코드를 이용했지만, C++ 코드에서도 같은 기능을 구현할 수 있습니다.

프로그램 코드를 테스트해보기 위해서는 .NET 5 이상의 SDK를 설치해야 합니다. 그 다음, 이 Gist 리포지터리를 Git으로 체크아웃하고 dotnet run 명령으로 실행해봅니다.