This file contains hidden or 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
var = "google.com/randomtext/private-dw1938f3hf783h2g240o35o/basic" | |
r = /private-(.+)\//i | |
var.match(r)[1] | |
# should return: | |
# => "dw1938f3hf783h2g240o35o" |
This file contains hidden or 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 | |
for file in $(find DIRECTORY -name FILENAME) | |
do | |
sed -e "s/KEYWORD/REPLACEMENT/ig" $file > /tmp/tempfile.tmp | |
mv /tmp/tempfile.tmp $file | |
done |
This file contains hidden or 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 | |
# Dumps all MySQL databases, each to its own file, rotates out old backups. | |
# set correct dates | |
NOWDATE=`date +%Y-%m-%d` | |
LASTDATE=$(date +%Y-%m-%d --date='1 week ago') | |
# dump each database to its own sql file | |
for DB in $(echo 'show databases' | mysql -hhostname -uuser -password=password --batch -N) |
This file contains hidden or 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
tail -n 10000 yourweblog.log|cut -f 1 -d ' '|sort|uniq -c|sort -nr|more | |
# Take a look at the top IP addresses. If any stand out from the others, those would be the ones to firewall. | |
netstat -n|grep :80|cut -c 45-|cut -f 1 -d ':'|sort|uniq -c|sort -nr|more | |
# This will look at the currently active connections to see if there are any IPs connecting to port 80. You might need to alter the cut -c 45- as the IP address may not start at column 45. If someone was doing a UDP flood to your webserver, this would pick it up as well. | |
#On the off chance that neither of these show any IPs that are excessively out of the norm, you would need to assume that you have a botnet attacking you and would need to look for particular patterns in the logs to see what they are doing. A common attack against wordpress sites is: | |
GET /index.php? HTTP/1.0 | |
#If you look through the access logs for your website, you might be able to do something like: |
This file contains hidden or 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
# /etc/nginx/mime.types | |
# Global Nginx mime.types file | |
types { | |
text/html html htm shtml; | |
text/css css; | |
text/xml xml rss; | |
image/gif gif; | |
image/jpeg jpeg jpg; | |
application/javascript js; |
This file contains hidden or 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 | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: S 0 1 6 | |
# Short-Description: unicorn initscript | |
# Description: unicorn | |
### END INIT INFO |
This file contains hidden or 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
# Start an application in the background (leaving terminal free for other use once it starts) | |
application-name [whatever options] & | |
# No really, just put & on the end of it. Trust me. | |
# Recursively find all files named config and replace a string using sed. The -i flag requires a blank suffix '' to work on Mac. | |
find . -name config -type f -print | xargs sed -i '' 's/[email protected]:CollegePlus/[email protected]:collegeplus/g' | |
# Recursively find all files with a certain file extension and replace a string using perl. | |
find . -name "*.fileext" -print | xargs perl -i -p -e 's/STRINGTOFIND/STRINGTOREPLACE/g' |
This file contains hidden or 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
# Load Amazon EC2 API tools | |
source ~/.ec2/setup_env.sh |
This file contains hidden or 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/bash | |
#if OSX | |
sudo dscacheutil -flushcache | |
sudo ipconfig set en0 BOOTP | |
sudo ipconfig set en0 DHCP | |
sudo ipconfig set en1 BOOTP | |
sudo ipconfig set en1 DHCP |
This file contains hidden or 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/bash | |
# Find files in a path older than X days (represented by +X), execute removal. | |
# removes files older than 1 week | |
find /path/to/files/* -mtime +7 -exec rm {} \; |
OlderNewer