Skip to content

Instantly share code, notes, and snippets.

View henri's full-sized avatar
💭
hacking the mainframe

henri henri

💭
hacking the mainframe
View GitHub Profile
@henri
henri / ghostbuster
Created February 14, 2024 22:08 — forked from thunderpoot/ghostbuster
Mosh: You have N detached Mosh sessions on this server
#!/bin/bash
# You know that really annoying message that pops up...
# Mosh: You have 3 detached Mosh sessions on this server, with PIDs:
# - mosh [2294539]
# - mosh [1874313]
# - mosh [2294805]
# I often find myself copying this list of PIDs in order to kill them manually
@henri
henri / macOS_timemachine_cheatsheet.txt
Last active February 14, 2024 03:25
macOS TimeMachine cheatsheet
# the man page for tmutil
man tmutil
# calculate drift on backups (cpu / io intensive)
tmutil calculatedrift backup_folder
# list backups
tmutil listbackups
# set backup destination
@henri
henri / 001_macOS_sshd_terminal.txt
Last active February 9, 2024 22:57
macOS sharing command line shortcuts
# Sometimes GateKeeper / SIP / FullDisk Access gets in the way of enableing various services on recent version of macOS
# It is possible to check if this is the case using these commands. The GUI tends to just hang. The apprach below will
# provide you with some feedback. Perhaps an update to macOS at some point will display a dialog box telling you why
# the service is not abe to start.
# check sshd status
sudo systemsetup -getremotelogin
# enable sshd
sudo systemsetup -setremotelogin on
@henri
henri / smerge_cheatsheet.txt
Last active January 31, 2024 03:20
sublime merge cheat sheet
# visual diff using smerge
smerge mergetool file1 file2
# fish open files with wildcard name substiution
smerge mergetool (ls *-myfiles.txt | string split " ")
# bash open files with wildcard name substiution
smerge mergetool $(ls *-myfiles.txt)
@henri
henri / socat_cheat_sheet.bash
Last active November 27, 2023 02:37
socat cheat sheet
# this example sets up a tunnel on the remote system on port 8090 to the system initiating the ssh connection on port 8080
#
# starting socat ipv4 tunnel between ports on remote system (forking and lock file enabled with socat)
# and killing socat with control-c / tunnel close
#
# tags : proxy port
# most direct approach
ssh -t user@remote.system -R 8080:127.0.0.1:8080 "socat -L/tmp/socat.lock tcp4-listen:8090,reuseaddr,fork tcp:localhost:8080"
@henri
henri / su_cheat_sheet.txt
Last active February 6, 2024 23:57
sudo / su cheat sheet
# login as a user if they do not have a shell :
su - <user> -s /bin/bash
# example logging in as www-data :
su - www-data -s /bin/bash
# add user to sudo group
usermod -aG sudo <user-to-grant-sudo-access>
@henri
henri / sxhkdrc-control-based
Last active August 15, 2023 01:05
LINUX sxhkd + xdotool (control arrorw key press modifications)
# Requires 'sxhkd' and 'xdotool' to both be installed.
# Start 'sxhkd' for this to actually become active
# Config should be installed into this file :
# ./config/sxhkd/sxhkdrc
#
# Released under the GNU/GPL v3 or later :
# https://en.wikipedia.org/wiki/GNU_General_Public_License
#
# Unintended operation and unexpected issues are not my responsobility
# use this script and settings and these tools at your own risk
@henri
henri / macOS_ARD_cheat_sheet.txt
Created July 5, 2023 23:01
ARD on macOS Cheat Sheet
If you are connecting via VNC / ARD client to a macOS system with mutliple GUI sessions.
If the screen saver is enabled on the account and it locks the screen, any subsequent connections will be in
a stuck state, you will not be able to type or even access the screen saver password dialog box. It is like the system
will not recognise any movement.
Provided you have SSH accesss to an admin account on the system and you have no unsaved changes,
you will be able to force logout the GUI enviroment using the command below :
$ sudo launchctl bootout gui/$(id -u <usercode>)
git config --global color.ui true
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR@EMAIL.com"
git config --global credential.helper cache
@henri
henri / bluetooth_auto_connect_toggle.bash
Last active February 19, 2024 01:01
bluetooth disable auto connect
#!/usr/bin/env bash
#
# toggle auto aconnect
# Henri Shustak 2023
# Released under under MIT Licence
# version 1.1 - initial release
# version 1.2 - will work no matter the state of the lock files
toggle_file=/tmp/bluetooth_connect.toogle