Skip to content

Instantly share code, notes, and snippets.

View dana-ross's full-sized avatar

Dana Ross dana-ross

View GitHub Profile
@dana-ross
dana-ross / detect_sendmail.rb
Created August 17, 2012 21:03
Tell Mountain Lion (non-Server) users how to get sendmail running
if RUBY_PLATFORM.include? "darwin"
unless File.exists? "/Library/Server/Mail/Data/spool"
puts "***********************************************************************"
puts "Hey there Mountain Lion user - your computer isn't set up to send email"
puts "You need to open a Terminal and execute these commands:"
puts ""
puts "sudo mkdir -p /Library/Server/Mail/Data/spool"
puts "sudo /usr/sbin/postfix set-permissions"
puts "sudo /usr/sbin/postfix start"
puts "***********************************************************************"
@dana-ross
dana-ross / nginx-spdy-passenger.sh
Last active December 11, 2015 03:39
Compile nginx with SPDY patch and Passenger support
#!/bin/sh
NGINX_VERSION=1.3.11
TMP_PATH=/tmp
# Fetch and extract Nginx
cd $TMP_PATH
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
tar xvfz nginx-$NGINX_VERSION.tar.gz
cd nginx-$NGINX_VERSION
@dana-ross
dana-ross / nginx
Last active December 11, 2015 03:39
Monit config for nginx
check process nginx with pidfile /var/run/nginx.pid
start program = "/usr/sbin/service nginx start" with timeout 60 seconds
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if failed host www.davidmichaelross.com port 80 protocol http
and request "/license.txt"
then restart
if 3 restarts within 5 cycles then timeout
group server
@dana-ross
dana-ross / percona
Last active December 11, 2015 03:39
Percona/MySQL configuration for Monit
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/usr/sbin/service mysql start" with timeout 60 seconds
stop program = "/usr/sbin/service mysql stop"
if cpu > 60% for 2 cycles then alert
if cpu > 90% for 5 cycles then restart
if 3 restarts within 5 cycles then timeout
group server
@dana-ross
dana-ross / php5-fpm
Last active December 11, 2015 03:59
Monit config for php5-fpm
check process php5-fpm with pidfile /var/run/php5-fpm.pid
start program = "/usr/sbin/service php5-fpm start" with timeout 60 seconds
stop program = "/usr/sbin/service php5-fpm stop"
if cpu > 60% for 2 cycles then alert
if cpu > 90% for 5 cycles then restart
if 3 restarts within 5 cycles then timeout
group server
@dana-ross
dana-ross / maldet
Last active December 11, 2015 04:08
Wrapper for maldetect. Creates a pidfile for monit.
#! /bin/sh
### BEGIN INIT INFO
# Provides: maldetect
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Malware scanner
# Description: Malware scanner
### END INIT INFO
@dana-ross
dana-ross / maldetect
Last active December 11, 2015 04:08
Monit config for wrapped maldetect
check process maldet with pidfile /var/run/maldet.pid
start = "/etc/init.d/maldet start" with timeout 60 seconds
stop = "/etc/init.d/maldet stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if 3 restarts within 5 cycles then timeout
group server
@dana-ross
dana-ross / prevent_wordpress_search_enter.js
Created February 10, 2013 05:20
Prevent people from pressing enter in a WordPress search box and getting redirected to the search results page
<script>jQuery(function() { jQuery('input[name="s"]').on('keypress', function(event) {if( event.which == 13 ) { event.preventDefault(); }});});</script>
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
// There should be an "ajaxurl" variable set that you can use instead of hard-coding the url here
jQuery.get('/wp-admin/admin-ajax.php', {'action': 'this_sucks', 'postid': '1234'}, function(data, status, jqXHR) {
// Display post here
});