Skip to content

Instantly share code, notes, and snippets.

Options +FollowSymlinks
RewriteEngine on
# No intersticial for direct reference and self-reference
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://box.leebyron.com/.*$ [NC]
# Add a line item for every website you don't need an intersticial for
# I've added my own website, gmail and facebook
RewriteCond %{HTTP_REFERER} !^http(s)?://([^\.]*.)?leebyron.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://mail.google.com/.*$ [NC]
@justyns
justyns / gist:1508074
Created December 21, 2011 22:52 — forked from sontek/snowjob.sh
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
@justyns
justyns / net-edit.pl
Created October 25, 2012 08:25 — forked from morsik/net-edit.pl
Perl libvirt net-edit with dhcp reload
#!/usr/bin/perl -w
# Author: Konrad "morsik" Mosoń <mosonkonrad@gmail.com>
# linked here: http://wiki.libvirt.org/page/Networking#Applying_modifications_to_the_network
use strict;
use warnings;
my $net = $ARGV[0];
@justyns
justyns / .htaccess
Created January 20, 2013 10:07
Rewrite rule to redirect all requests to a temporary maintenance page
# HTACCESS Rewrite rule to redirect all requests to a temporary maintenance page
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://justynshull.com/maintenance.html [R=307,L]
@justyns
justyns / gist:4577648
Created January 20, 2013 10:09
Use this to re-arp all IPs currently on the interface. Change eth0 to eth1 or whatever as needed.
ifconfig|grep inet|awk '{print $2}'|awk -F: '{print $NF}'|grep -v 127|grep -v ^$|tr '.' ' '|while read -a ip;do arping -Ieth0 -f -s ${ip[0]}.${ip[1]}.${ip[2]}.${ip[3]} ${ip[0]}.${ip[1]}.${ip[2]}.1;done
@justyns
justyns / gist:4577654
Created January 20, 2013 10:10
View number of connections in each state using netstat [root@server~]# netstat -tan | awk '{print $6}' | sort | uniq -c 1 established) 5 ESTABLISHED 3 FIN_WAIT2 1 Foreign 12 LISTEN 63742 TIME_WAIT
netstat -tan | awk '{print $6}' | sort | uniq -c
@justyns
justyns / eximqueue.sh
Created January 20, 2013 10:11
Automatically spawn exim queue runners if a queue is detected
#!/bin/bash
# eximqueue.sh - 07/30/2012 - Justyn Shull <justyn [at] justynshull.com>
messages=`exim -bpc`
maxmessages=120
maxrunners=50
while [ 1 ]; do
messages=`exim -bpc`
currunners=`ps afx | grep '/usr/sbin/exim -q' | wc -l`
echo -n "."
if [ $currunners -lt $maxrunners ]; then
@justyns
justyns / gist:4577670
Created January 20, 2013 10:12
Use this when you are trying to delete 100s of thousands of files in a single directory, and can not do so using rm.
perl -e 'chdir "problem_dir" or die; opendir D, "."; while ($n = readdir D) { unlink $n }'
@justyns
justyns / install.sh
Last active January 13, 2016 20:12
Modified version of the php script from https://www.zabbix.com/wiki/howto/monitor/db/mysql/extensive_mysql_monitoring_including_replication The regex wasn't matching anything for me. It now matches Server= and Hostname= correctly
wget -O /etc/zabbix/mysql.php https://gist.github.com/raw/4604061/4026d686f69b85c8617e494ef9adb919cb7a2ea4/zabbix-mysql.php
echo 'UserParameter=mysql.daily,php /etc/zabbix/mysql.php daily root' >> /etc/zabbix/zabbix_agentd.conf
echo 'UserParameter=mysql.live,php /etc/zabbix/mysql.php live root' >> /etc/zabbix/zabbix_agentd.conf
@justyns
justyns / redisctl
Created June 21, 2013 14:33 — forked from ponych/redisctl
#!/bin/sh
# http://vm-192-168-11-21.shengyun.grandcloud.cn/topics/2437
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid