Skip to content

Instantly share code, notes, and snippets.

View mvandermeulen's full-sized avatar

Mark mvandermeulen

  • Fivenynes
  • Sydney, Australia
  • 19:56 (UTC +11:00)
View GitHub Profile
@mvandermeulen
mvandermeulen / README.md
Created August 17, 2025 03:19 — forked from jldiaz/README.md
Copy/paste into vim registers via ssh tunnel

These scripts allows you to use vim in a remote machine via ssh, and being capable of sharing the local clipboard with vim's 0 register (which is the one used by default by yank/paste).

To make it work:

  1. In your local machine, run clipboard-server.py, which uses flask to create a simple REST API exposing only the / endpoint, listening on localhost:11223

    GET / will retrieve the system clipboard of the machine in which the server is run, in form of a JSON with the field "content".

@mvandermeulen
mvandermeulen / election-manager.py
Created August 17, 2025 03:18 — forked from AdamOlszewskiIT/election-manager.py
Redis - master slave election manager
import time
import threading
import uuid
from fastapi import FastAPI
from redis import Redis
# Configuration
REDIS_HOST = "localhost"
REDIS_PORT = 6379
MASTER_KEY = "master"
import time
import threading
import uuid
from redis import Redis
# Configuration
REDIS_HOST = "localhost"
REDIS_PORT = 6379
MASTER_KEY = "master"
MASTER_TTL = 10 # Time-to-live for master key
@mvandermeulen
mvandermeulen / Event_Loop.md
Created August 17, 2025 02:45 — forked from kassane/Event_Loop.md
Explain Event Loop

Event Loop

In computer science, the event loop, message dispatcher, message loop, message pump, or run loop is a programming construct that waits for and dispatches events or messages in a program.

It works by making a request to some internal or external "event provider" (that generally blocks the request until an event has arrived), and then it calls the relevant event handler ("dispatches the event").

The event-loop may be used in conjunction with a reactor, if the event provider follows the file interface, which can be selected or 'polled' (the Unix system call, not actual polling).

The event loop almost always operates asynchronously with the message originator.

@mvandermeulen
mvandermeulen / README.md
Created August 17, 2025 02:44 — forked from maelvls/README.md
My hundred struggles while using Linux as my desktop driver (Ubuntu 22.04)

My hundred struggles while using Linux as my desktop driver (Ubuntu 24.04)

Hi! On Thursday 25 April 2021, I entirely switched from macOS to Linux: https://maelvls.dev/evolution-of-my-home-office/. I took note of every adjustment I had to make along the way. I use Ubuntu "vanilla" (with Gnome as my desktop manager).

🔥 Update 26 June 2023: I am abandoning "desktop" Linux! I can't bear having to work around everything all the time, not even counting the tons of problems that occur whenever I do a major version upgrade (e.g., when I upgraded from 21.10 to 22.04, my PPAs broken obviously, and also I lost all the hack I had made to the /etc to work around problems). I am officially back to macOS starting 26 June 2023. I'll still use my Linux workstation remotely over Mosh, but not as a desktop environment. To learn more: https://hackmd.io/@maelvls/my-macos-tweaks


My other articles:

@mvandermeulen
mvandermeulen / remotepaste.md
Created August 17, 2025 02:36 — forked from burke/remotepaste.md
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
@mvandermeulen
mvandermeulen / pane.sh
Created August 17, 2025 02:36 — forked from kunalb/pane.sh
zsh + tmux + fzf + rg - autocomplete words in command
function _print_all_panes() {
for pane_id in $(tmux list-panes -F '#{pane_id}'); do
tmux capture-pane -p -J -S 0 -E - -t "$pane_id" | tr ' ' '\n' | sort -u | rg '[a-zA-Z0-9]+'
done
}
_tmux_pane_words() {
local current_word="${LBUFFER##* }"
local new_rbuffer="${RBUFFER/#[^ ]##/}"
local prompt="${LBUFFER% *} ␣ $new_rbuffer "
@mvandermeulen
mvandermeulen / tmux-connect.sh
Created August 10, 2025 09:36 — forked from QuAzI/tmux-connect.sh
Reverse shell for NAT users with tmux+socat+ssh
#!/bin/sh
#
# Run this script on relay_server to connect shared session
#
read -p "Port number: " relay_port
socat file:`tty`,raw,echo=0 tcp-connect:localhost:${relay_port}
@mvandermeulen
mvandermeulen / split.zsh.md
Created July 31, 2025 23:46 — forked from mattmc3/split.zsh.md
ZSH - split string into array

There are a ton of different ways to split up a string in Zsh. This gist attempts to show them with examples to help you build your own. I write Zsh scripts all the time, and still reference back to this gist, so there you go.

From the Zsh docs on Parameter Expansion Flags (yeah - I know... how would anyone ever find that if they didn't know where to look!?)

j:string: Join the words of arrays together using string as a separator.
s:string: Force field splitting at the separator string.

You can also read more by running man zshexpn. (Again, I know, right!? How would anyone know to look there!?)

@mvandermeulen
mvandermeulen / string_manipulation.md
Created July 31, 2025 22:06 — forked from valosekj/string_manipulation.md
Useful string manipulation examples for bash and zsh #blog

Useful string manipulation examples for bash and zsh

I need very often to modify filenames or replace/delete their parts across huge number of files. I was using sed command for these purposes but recently I have found out that all these tasks can be easily done directly in bash (or zsh) because both of them support so called string manipulation operations.

String manipulations

Define some example string:

$ file=some_file_name.txt