Skip to content

Instantly share code, notes, and snippets.

View jonathonsim's full-sized avatar

Jonathon Sim jonathonsim

View GitHub Profile
@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 / 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 / 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 / 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"
@jonathonsim
jonathonsim / setup_lamp_xenial_vagrant.sh
Last active February 1, 2019 01:55
Setup a standard LAMP stack inside a vagrant box.
#To run this add something like this to your Vagrantfile:
#
#
# config.vm.provision "shell", inline: <<-SHELL
# # Default Vagrant LAMP stack https://gist.github.com/jonathonsim/2cfdafc876984f6a6a0bdb35ebd9a74f
# export VAGRANT_DIR=/var/www/html #We mount an nfs share here, along with the regular vagrant share on /vagrant, as nfs is faster. But it has weird behaviour with some apps as well
# curl https://gist.githubusercontent.com/jonathonsim/2cfdafc876984f6a6a0bdb35ebd9a74f/raw/ | bash
# SHELL
#
#
@jonathonsim
jonathonsim / setup_php_xenial.sh
Last active November 25, 2018 22:14
A script to install a PHP development environment in an ubuntu xenial vagrant box
#To use:
# (assuming you trust it):
#curl https://gist.githubusercontent.com/jonathonsim/6a5b25a4bebf2badde9a10740476fc3a/raw/ | bash
export DEBIAN_FRONTEND=noninteractive
#Use local mirrors
echo "deb http://nz.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse" > /etc/apt/sources.list && \
echo "deb http://nz.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
echo "deb http://nz.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list
#!/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 / 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: