Skip to content

Instantly share code, notes, and snippets.

View jonathonsim's full-sized avatar

Jonathon Sim jonathonsim

View GitHub Profile
@jonathonsim
jonathonsim / mysql_recover_log_disk_space.pl
Last active February 4, 2016 02:58
A simple script to cleanup mysql binlogs if you start running out of diskspace. Running out of diskspace is fatal on a mysql database. But you also want to keep as many binlogs as possible, so when your replication dies you have time to fix it. This script will delete all logs except 2 if disk space free falls below 6%
#!/usr/bin/perl
# Simple script to cleanup mysql binlogs if you start running out of diskspace.
# Running out of diskspace is fatal on a mysql database. But you also want to keep as many binlogs as possible, so when your replication dies
# you have time to fix it. This script will delete all logs except 2 if disk space free falls below 6%
#
# has a few dependencies : to install on debian(ish) systems:
# apt-get install libfilesys-diskspace-perl libmime-lite-perl libdbd-mysql
#
# Add this to cron with something like:
#!/bin/bash
# Database backup script
#
#Large tables - we only keep one copy of these
export mysql_large_tables="track_page track_visit emails_message_body emails_message_body_new"
export dumpopts=" --single-transaction --max_allowed_packet=32M --compact "
export mysqldump="mysqldump -Q $dumpopts"
export backup_root='/srv/backup/temp-databases'
export ldap_dumpall="/usr/sbin/slapcat"
@jonathonsim
jonathonsim / gist:857ff84ca95b3aeabcf35187bd86fe7c
Last active September 19, 2017 21:09
How to set file auth for SSL on ZEST
#Replace $SITE and $CONTENT
sshz-site $SITE
echo -n $CONTENT > pages/fileauth.txt.html
#eg
#sshz-site zeald
#echo -n 201709190334595r84u8lue4jgdynncckpw7pruhtmj0vrzjtgnm4bgongfb2gc9 > pages/fileauth.txt.html
@jonathonsim
jonathonsim / conemu.xml
Created October 27, 2017 21:58
Conemu settings - default 4 way split with cygwin
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2017-10-28 10:57:45" build="170910">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Default Split}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<value name="StartFarEditors" type="hex" data="00"/>
@jonathonsim
jonathonsim / test-smtp.pl
Created November 14, 2017 03:24
test smtp
#!/usr/bin/perl
use Net::SMTP;
$smtp = Net::SMTP->new($ARGV[0],
Hello => 'myserver.app',
Timeout => 60,
Debug =>1);
$smtp->mail('root@myserver.app');
if ($smtp->to('somthing@example.com')) {
$smtp->data;
@jonathonsim
jonathonsim / keychain
Created November 17, 2017 00:46
keychain
#!/bin/sh
# Copyright 1999-2005 Gentoo Foundation
# Copyright 2007 Aron Griffis <agriffis@n01se.net>
# Copyright 2009-2010 Funtoo Technologies, LLC
# lockfile() Copyright 2009 Parallels, Inc.
# Distributed under the terms of the GNU General Public License v2
# Originally authored by Daniel Robbins <drobbins@gentoo.org>
@jonathonsim
jonathonsim / setup_xenial_lamp_php5.sh
Last active January 18, 2018 21:01
Setup a php5 LAMP environment on ubuntu xenial. Used in various vagrant boxes
#To run this add something like this to your Vagrantfile:
#
#
# config.vm.provision "shell", inline: <<-SHELL
# #Install LAMP stack
# export VAGRANT_DIR=/vagrant
# curl https://gist.githubusercontent.com/jonathonsim/ac13a63a38ffdbe831246ab809d97158/raw/ | bash
# SHELL
#
#
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowDuplicity",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
@jonathonsim
jonathonsim / setup_bash_profile.sh
Last active October 23, 2018 22:23
Setup .bash_profile on cygwin (ZEALD VERSION)
#To use:
# (assuming you trust it):
#curl https://gist.githubusercontent.com/jonathonsim/cc286f3baed66faed69e3be2d4608858/raw/ | bash
cd ~
chmod 777 ~/bin/*
cat > ~/.bash_profile <<'EOF'
# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
<?php
/**
* Idealstack Healthcheck.
*
* This file is checked by the load balancer to see whether the site is healthy.
* If it returns a 500 error the site is considered unhealthy, and the site's container
* will be rebooted.
*
* This default check doesn't do much except check that PHP is running.
* You can customise this file to check other important resources