Skip to content

Instantly share code, notes, and snippets.

@UnixSage
UnixSage / ssh-agent.sh
Created September 7, 2022 13:41
Snipit to add to bash_profile that will find an existing ssh-agent or start a new one. Also complains if it finds more than one for a user.
# Attach to a running ssh-agent or start a new one
if [ `find /tmp -maxdepth 1 -name "ssh-*" -user ${USER} | wc -l` == 1 ] ; then
echo "Found ssh-agent, attaching.."
SSHDIR=`find /tmp -maxdepth 1 -name "ssh-*" -user ${USER}`
SSH_AUTH_SOCK=`ls ${SSHDIR}/agent*` ; export SSH_AUTH_SOCK
SSH_AGENT_PID=`echo ${SSH_AUTH_SOCK} | awk -F"." '{print $2+1}'` ; export SSH_AGENT_PID
echo "Agent pid ${SSH_AGENT_PID}"
elif [ `find /tmp -maxdepth 1 -name "ssh-*" -user ${USER} | wc -l` == 0 ] ; then
echo "no ssh-agent found, starting.."
eval `ssh-agent -t 86400`
@UnixSage
UnixSage / createbridge.sh
Created September 8, 2024 22:38
Can be used to move connectivity from an interface to a bridge with the provided IP information. While I have successfully used this while remote it must be done with care as it could very well send you to the datacenter. Also it assumes the DNS server is the same as the gateway.
#!/bin/bash
if [ $# -ne 3 ] ; then
echo "usage: $0 <interface> <ip/cidr> <gateway>"
echo "ie: $0 eno1 10.0.0.25/24 10.0.0.1"
exit 1
fi
INTERFACE=$1
IP=$2
@UnixSage
UnixSage / EnablePaste.js
Created September 14, 2025 08:07
Browser Bookmarklet that enables Copy / Paste on those irritating sites that disable it
javascript:(function(){
allowCopyAndPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('copy', allowCopyAndPaste, true);
document.addEventListener('paste', allowCopyAndPaste, true);
document.addEventListener('onpaste', allowCopyAndPaste, true);
})();
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Clock with Offset</title>
</head>
<body onload="startTime()">
<h2>Offset Clock</h2>
<div id="txt" style="font-size: 24px;"></div>
<script>