This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# this one saves to a file | |
download_file(){ | |
curl -f -o "${1}" "${2}" || wget -O "${1}" "${2}" | |
} | |
download_file /path/destination https://sourceurl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Clear out all iptables rules and make the changes persistent. | |
# first, find out if we're sudo | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so."; | |
exit 1; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# first, find out if we're sudo | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so."; | |
exit 1; | |
fi | |
for user in $(cut -f1 -d: /etc/passwd); do | |
crons=$(crontab -u $user -l 2>/dev/null | grep -v '^#') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rotate mongodb | |
# https://stackoverflow.com/a/8396266/5114 | |
/var/log/mongo/*.log { | |
daily | |
rotate 30 | |
compress | |
dateext | |
missingok | |
notifempty | |
sharedscripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# find out if we're sudo | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so."; | |
exit 1; | |
fi | |
target="/dev/md0" | |
mountpoint="/data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install docker on machine, add a user to the docker group. | |
# first, find out if we're sudo | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so."; | |
exit 1; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $(id -u) -ne 0 ]; then | |
echo "Nope. Simon didn't say so!" | |
exit 1; | |
fi | |
if [ -z "$1" ]; then | |
echo "What's my name? Say my name, bitch!" | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/a/19647596/5114 | |
def flatten_dict(dd, separator='_', prefix=''): | |
return { prefix + separator + k if prefix else k : v | |
for kk, vv in dd.items() | |
for k, v in flatten_dict(vv, separator, kk).items() | |
} if isinstance(dd, dict) else { prefix : dd } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# mongodb is in a private network somewhere, host is a machine which can connect | |
# after running this script, you can connect to mongo at localhost | |
MONGO=$1 | |
HOST=$2 | |
ssh -fnN \ | |
-L 27017:$MONGO:27017 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Note: This gist is superseded by an improved script: | |
# https://github.com/mnebuerquo/virtuous-python | |
# Run a python script, and manage the virtualenv for me so I don't have to | |
# https://gist.github.com/mnebuerquo/4da76a007d18964dc3f7ce43e213b46f | |
# Run: ./run app.py [--argument --other file --whatever] | |
# Test: ./run --test [<--more-pytest-args-here>] |
NewerOlder