Skip to content

Instantly share code, notes, and snippets.

View josh-yates's full-sized avatar
🤠

Josh Yates josh-yates

🤠
View GitHub Profile
@josh-yates
josh-yates / docker-cloud-init.yml
Last active October 26, 2025 10:40
Default cloud-init
#cloud-config
packages:
- fail2ban
- ufw
- unattended-upgrades
package_update: true
package_upgrade: true
users:
- name: admin
groups:
Porridge recipe
A great way to start the day!
Ingredients:
Oats
Milk (Dairy or non-dairy)
Instructions:
1. Put oats and milk in bowl
public deepUpdateArray<T, I>(current: T[], incoming: T[], getIdentifier: (item: T) => I, onUpdate: (current: T, incoming: T) => void): void {
for (let i = current.length - 1; i >= 0; i--) {
const currentItem = current[i];
const matchingIncomingItem = incoming.find(o => getIdentifier(o) === getIdentifier(currentItem));
if (!matchingIncomingItem) {
current.splice(i, 1);
continue;
}
Sub replaceTextAndSaveAsPng()
'This script replaces text in a specific text box inside a group, change variables as necessary
Dim names As Variant
Dim name As Variant
Dim nameString As String
Dim filePath As String
names = Array("firstname lastname", "another name")
For Each name In names
@josh-yates
josh-yates / win32_changecursor.cpp
Created May 21, 2018 18:24
C++ win32 api changing cursor when hovering over button/dragging text box
case WM_SETCURSOR: {
if ((HWND)wP == *mwns::MyButton.GetHandle()) {
SetCursor(LoadCursor(NULL, IDC_HAND));
}
else if (DraggingText) {
SetCursor(LoadCursor(NULL, IDC_SIZEALL));
}
else {
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
@josh-yates
josh-yates / win32_dragtext.cpp
Last active May 21, 2018 10:28
C++ win32 api Draggable Text box
//This example text box class (MyText is an object) as a wrapper for a text box, with getters for the text box's properties
/*General idea is that WM_LBUTTONDOWN is called on left mouse click, and checks whether the click was inside the text box's region.
If it is, the DraggingText bool remembers the text box is being dragged. The WM_MOUSEMOVE case is called when the mouse is moved.
If the box is being dragged, it captures the cursor's position and uses SetWindowPos to update the text box's coordinates to the cursor
position. The coordinates are also updated in the MyText object for future reference. WM_LBUTTONUP is called when the left mouse button
is released, stopping the dragging process*/
//Cases exist in window procedure for the text box's parent window
case WM_LBUTTONDOWN: {
POINT pos;
pos.x = LOWORD(lP);