Skip to content

Instantly share code, notes, and snippets.

View ssimpson89's full-sized avatar

Stephen Simpson ssimpson89

View GitHub Profile
### Keybase proof
I hereby claim:
* I am ssimpson89 on github.
* I am ssimpson (https://keybase.io/ssimpson) on keybase.
* I have a public key whose fingerprint is 47E6 9D63 5860 3A40 8EB5 4C21 9815 C9BC 120E D3AE
To claim this, I am signing this object:
@ssimpson89
ssimpson89 / scpsftprsynconly.c
Created January 19, 2016 21:34
Restrict Shell To Rsync SFTP and SCP
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*
*** Original by Patric Draper <http://www.pdrap.org/about/>
***
*** Changes on 13-Mar-2004 by Msquared <http://www.msquared.id.au/>
***
@ssimpson89
ssimpson89 / ping.sh
Created June 13, 2014 18:31
Ping Script
for i in $@
do
ping -q -c 1 -W 1 ${1} >/dev/null
if [[ $? == 0 ]]
then
echo $1 OK
else
echo $1 FAILED
fi
shift
@ssimpson89
ssimpson89 / serverbackup.sh
Last active May 17, 2019 13:17
serverbackup.sh
######
# This script will tar up the files you define in the rsync section and send them off to S3
# It will also delete any files older that $DAYS from the bucket
# You do need s3cmd (usually available in the repo) in order for this to work
# S3cmd will work with dreamobjects but if you want b2 or rackspace you'll need to swap out that code.
# This does also log to /var/log/backup.log and /var/log/backup.err
######
DATE=`date +%Y-%m-%d_%H-%m`
TMPBACKUP='/backup'
@ssimpson89
ssimpson89 / cdn.js
Created February 25, 2014 22:57 — forked from Kapeli/cdn.js
function latencyTest(url) {
$.ajax({
url: "http://"+url+".kapeli.com/feeds/latencyTest_v2.txt",
cache: false,
success: function(content){
if(beginsWith("Just a latency test. Move along.", content))
{
var link = document.getElementsByClassName("downloadButton")[0];
if(link.getAttribute("href") == "Dash.zip")
{
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www;
index index.html index.php;
# Make site accessible from http://localhost/
server_name localhost;
}
@ssimpson89
ssimpson89 / MySQL Replication Check
Last active April 30, 2022 13:54
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')
@ssimpson89
ssimpson89 / Init
Created August 29, 2013 01:32
Basic Init Script
#!/bin/bash
# myapp daemon
# chkconfig: 345 20 80
# description: myapp daemon
# processname: myapp
# Source function library.
. /etc/rc.d/init.d/functions
#!/usr/bin/python
# Set up a new A record in Cloudflare, add the details of it along with your account details below
# Make sure this script runs on startup (or whenever you get a new IP...)
#
# @author Aaron Rice <aaron@duedil.com>
import urllib
import json
# Copyright (c) 2010 Curt Micol <asenchi@asenchi.com>
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN