Skip to content

Instantly share code, notes, and snippets.

View mattrude's full-sized avatar

Matt Rude mattrude

View GitHub Profile
@mattrude
mattrude / index.html
Created November 17, 2012 21:07
php/java-script page that keeps the menu bar on the top of the page when it's scrolled down.
<head>
<style type='text/css'>
#menu.docked {
background-color: rgba(150, 150, 150, 0.5);
width: 100%;
}
#menu {
padding: 20px;
}
</style>
@mattrude
mattrude / mdr-table-of-contents.less
Created November 19, 2012 05:40
Table of Contents shortcode for WordPress
// Creates a small boarder around the table.
.table_of_contents.fl {
float: right;
margin: 0 0 15px 15px;
padding: 5px;
border: 1px solid #AAA;
}
@mattrude
mattrude / nginx-rrd.pl
Last active July 23, 2020 18:35
A Nginx rrdtools graphing solution using perl. This script will only update the rrd databases and create graphs, not the actually html site.
#!/usr/bin/perl
use RRDs;
use LWP::UserAgent;
# define location of rrdtool databases
my $rrd = '/var/www/status.example.com/rrd';
# define location of images
my $img = '/var/www/status.example.com/images';
# define your nginx stats URL
my $URL = "http://127.0.0.1/nginx_status";
@mattrude
mattrude / gist:5159027
Last active December 14, 2015 22:29
Block Bing since they don't know how to play nice
iptables -F
grep "bingbot" /var/log/nginx/access.log |awk '{print $1 }' |sort |uniq > /tmp/killbing && \
egrep "bingbot" /var/log/nginx/archive/access* |awk '{print $1 }' |sort |uniq >> /tmp/killbing && \
for a in `cat /tmp/killbing |sort |uniq`
do
iptables -I INPUT -s $a -j DROP
done
@mattrude
mattrude / download-loveline.sh
Last active December 19, 2015 10:39
Download all loveline files from the main Music container
cd /external/
for a in `swift list Music -p loveline |sed 's/ /%20/g' |egrep "mp3|html"`
do
b=`echo $a |sed 's/%20/ /g'`
if [ ! -f "/external/$b" ]; then
swift download Music "$b"
else
echo "-- Not downloading $b file is already downloaded --"
fi
done
@mattrude
mattrude / nginx-updater.sh
Created July 13, 2013 00:28
A complete update script for nginx installs on Ubuntu 12.04 LTS.
#!/bin/bash
CFGDIR=/etc/nginx
PACKETS="mercurial gcc make openssl libssl-dev libpcre3 libpcre3-dev"
UPDATE=""
dpkg --get-selections |awk '{print $1}' > /tmp/installed-packages.txt
for a in $PACKETS
do
@mattrude
mattrude / deactivate-google-auth.php
Created August 7, 2013 12:35
If you don’t already use the excellent Google Authenticator plugin for WordPress by Henrik Schack (or similar alternative), then you should do. The Google Authenticator plugin is intended to ensure that you are who you say you are (for security purposes). An alternative route to improving security is to block all IP addresses except for ones you…
<?php
/*
Plugin Name: Deactivate Google Authenticator
Plugin URI: http://geek.ryanhellyer.net/products/deactivate-google-authenticator/
Description: Deactivate Google Authenticator based on IP
Author: Ryan Hellyer
Version: 1.0
Author URI: http://geek.ryanhellyer.net/
Requires: WordPress 3.5
@mattrude
mattrude / mediawiki-run-jobs.sh
Created January 3, 2014 06:03
A bash script to continuously run the runJobs.php script in small batches to allow a slow server to keep up and still allow public traffic on the site. This script should be placed in the mediawiki maintenance directory.
# Run meny MediaWiki Jobs
while [ `php showJobs.php` != 0 ];
do
echo -n "Starting over; `php showJobs.php` jobs left to run; running 10 jobs in 2 cycles."
php runJobs.php --maxjobs 10 --procs 5 --quiet
LOAD="`uptime |awk '{ print $10 }' |sed 's/,//g'`"
if [ $LOAD > 1.9 ]; then
WAIT=`echo "sqrt(2 * $LOAD * 50)" |bc`
echo " - Sleeping for $WAIT secs"
sleep $WAIT
@mattrude
mattrude / content-maintenance-scripts.sh
Last active January 4, 2016 17:29
Wiki Farm Scripts
#!/bin/bash
for a in stargate startrek drwho
do
cd /external/www/wikifarm.mattrude.com/
rm -f $a.xml
php scripts/inc/dumpBackup.php $a --current > $a.xml
gzip $a.xml
python ../pywikibot/pwb.py ../pywikibot/scripts/replace.py -xml:$a.xml.gz -family:$a -always -fix:HTML
python ../pywikibot/pwb.py ../pywikibot/scripts/replace.py -xml:$a.xml.gz -family:$a -always -fix:syntax-safe
@mattrude
mattrude / e2e-buildscript.sh
Created June 11, 2014 09:10
(Legacy) Google Chrome Extension End-To-End build script, please see https://gist.github.com/mattrude/dbd3660802ae35572fc6 for the updated script.
#!/bin/bash
# end-to-end build script
# Matt Rude <matt@mattrude.com>
# Created: 11-June-2014
#
# This is the Google Chrome Extension End-To-End build script,
# the code may be found at: https://code.google.com/p/end-to-end/
# This is the same instructions as is found on the end-to-end site.
#