Skip to content

Instantly share code, notes, and snippets.

View fnrhombus's full-sized avatar

Thomas Butler fnrhombus

  • Butler Software
  • Atlanta, GA
View GitHub Profile
@fnrhombus
fnrhombus / setup github.ps1
Last active March 25, 2026 08:04
windows terminal setup
winget install GitHub.cli Git.Git
git config --global user.name 'Tom'
git config --global user.email '2511516+rhom6us@users.noreply.github.com'
git config --global init.defaultBranch main
git config --global color.ui auto
@fnrhombus
fnrhombus / 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
@fnrhombus
fnrhombus / 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
if((Get-WindowsCapability -Online | Where-Object Name -like "OpenSSH.Server*").State -ne "Installed") {
Add-WindowsCapability -Online -Name "OpenSSH.Server"
}
$sshServer = Get-Service sshd
$sshServer | Set-Service -StartupType 'Automatic'
$sshServer | Start-Service
# This should return a status of Running
if($sshServer.Status -ne 'Running') {
throw 'wtf mate'
}
@fnrhombus
fnrhombus / 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,
};
@fnrhombus
fnrhombus / 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;
@fnrhombus
fnrhombus / 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:
* =======================
@fnrhombus
fnrhombus / 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>;