Skip to content

Instantly share code, notes, and snippets.

View rkttu's full-sized avatar

Jung Hyun Nam rkttu

View GitHub Profile
@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
@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 May 7, 2024 05:10
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)