Skip to content

Instantly share code, notes, and snippets.

View jdavis's full-sized avatar
💾

Josh Davis jdavis

💾
View GitHub Profile
# Rename a file and keep it in the same location
rename() {
if [ "$#" -ne 2 ]; then
echo "usage: $0 path/to/file/old_name new_name"
return
fi
mv $1 `dirname $1`/$2
}
@jdavis
jdavis / terrariad
Created December 28, 2013 21:23
Simple init.d Service script to start a tshock Terraria Server
#!/bin/sh
#
# Terraria Config
#
# Tmux session ID
SESSION=terraria
# Username to run as
@jdavis
jdavis / open_port.py
Created November 8, 2012 17:26
Find an open port in Python.
import socket
def find_open_port():
"""
Use socket's built in ability to find an open port.
"""
sock = socket.socket()
sock.bind(('', 0))