Skip to content

Instantly share code, notes, and snippets.

View rhom6us's full-sized avatar

Thomas Butler rhom6us

  • Butler Software
  • Atlanta, GA
View GitHub Profile
@rhom6us
rhom6us / setup.ps
Last active October 28, 2024 03:05
windows terminal setup
$theme = powerlevel10k_rainbow
$clink_config = "load(io.popen('oh-my-posh init cmd --config %POSH_THEMES_PATH%/$theme.omp.json'):read("*a"))()"
sudo pwsh
echo hi
@rhom6us
rhom6us / WSL - change hostname.txt
Created July 28, 2024 21:59
WSL - change hostname
>sudo nano /etc/wsl.conf
[network]
hostname = <new name>
generateHosts = false
>sudo nano /etc/hosts
change all occurances of old host name to new
@rhom6us
rhom6us / enable-usb-wsl.bat
Created July 28, 2024 05:57
share usb device to wsl Ubuntu
usbipd list
gsudo usbipd bind --busid <busid>
usbipd attach --wsl --busid <busid>
lsusb

Setup WSL for Remote SSH Access

1. Reinstalling SSH on WSL 2

sudo apt remove openssh-server
sudo apt install openssh-server

2. Configuring SSH on WSL 2

Edit SSH config:

sudo nano /etc/ssh/sshd_config
Get-Service -Name sshd | Set-Service -StartupType Automatic
Start-Service sshd
ssh-keygen -t ed25519
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
# This should return a status of Running
Get-Service ssh-agent
@rhom6us
rhom6us / request_handler.hpp
Created May 25, 2024 04:20
c++ string template parameters
#include <iostream>
#include <utility>
using namespace std;
enum class request_type {
GET,
POST,
PUT,
DELETE,
OPTIONS,
};
@rhom6us
rhom6us / packuft8.js
Last active May 24, 2024 03:30
pack uint8 to utf8
(function () {
const UTF8_SIGNIFICANT_BITS_SIZE = 7;
const BITS_IN_BYTE = 8;
globalThis.setChar = function (char, excludeCharacters) {
if (typeof excludeCharacters === 'string') {
return setChar(char, Array.prototype.map.call(excludeCharacters, c => c.charCodeAt(0)));
}
if (typeof char === 'string') {
if (char.length !== 1) {
// http://burnignorance.com/vc-application-development-tips/hooking-a-message-box-in-vc/
HHOOK hMsgBoxHook;
LRESULT CALLBACK MsgBoxProc(int nCode, WPARAM wParam, LPARAM lParam)
{
TCHAR ach[140];
HWND hwnd;
HWND YES;
HWND NO;
HWND CANCEL;
@rhom6us
rhom6us / tuple.ts
Last active July 15, 2023 19:54
pointless tuple
type Dec<Length extends number, Acc extends never[] = []> =
[never, ...Acc]['length'] extends Length ? Acc['length'] :
Dec<Length, [never, ...Acc]>;
type MakeRange<TMin extends number, TMax extends number, Acc extends number = never> =
TMax extends TMin ? TMax | Acc
: MakeRange<TMin, Dec<TMax>, TMax | Acc>;
type TupleBaseType = readonly any[] & { length: MakeRange<1,10> }
/**
* generate this code with:
* =======================
@rhom6us
rhom6us / fluent-object-builder.ts
Last active May 22, 2024 04:55
Fluent Object Builder
import { Func } from "@rhombus-toolkit/func";
type Func<Args extends any[], Result = void> = (...args: Args) => Result;
type AnyRecord = Record<string|symbol, any>;
type AnyFunction = (...args: any[]) => any;
type MakeBuilder<T extends AnyRecord> =
T extends infer a extends AnyRecord | infer b extends AnyRecord ? ObjectBuilder<a> | ObjectBuilder<b> : ObjectBuilder<T>;