Skip to content

Instantly share code, notes, and snippets.

View leemason's full-sized avatar
🎯
Focusing

Lee Mason leemason

🎯
Focusing
View GitHub Profile
@leemason
leemason / 002dbbackup.sh
Created April 22, 2016 19:53
Generate a db backup of every db in the mysql server, place in the /etc/cron.daily directory to run automatically everyday.
#!/bin/bash
#backup all databases on server every day to a backups folder
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Timestamp (sortable AND readable)
stamp=`date +"%s-%A_%d_%B_%Y@%H_%M"`
# List all the databases
databases=`mysql -u {{user}} -p{{password}} -e "SHOW DATABASES;" | tr -d "| " | grep -v "\(Database\|performance_schema\|information_schema\|mysql\|test\)"`
@leemason
leemason / 001filebackup.sh
Created April 22, 2016 19:48
Simple tar archive backup script to be placed in the /etc/cron.daily directory.
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
stamp=`date +"%s-%A_%d_%B_%Y@%H_%M"`
name="${stamp}_backup.tgz";
#tar filesystem
tar cvpzf /backups/file/${name} --exclude=/backups/file --exclude=/lost+found --exclude=/proc/* --exclude=/sys/* --exclude=/mnt/* --exclude=/media/* --exclude=/tmp/* --exclude=/var/run/* --exclude=/var/lock/* --exclude=/var/cache/apt/archives/* --exclude=/home/*/.gvfs --exclude=/run --exclude=/dev /
//The model could be used both server and browser side,
//not much more than a plain object with some simple getters and setters.
let User = Model.extend({
first_name: String,
last_name: String,
full_name: function(){
return this.first_name + ' ' + this.last_name;
}
});
@leemason
leemason / nginx_upgrade.sh
Last active April 18, 2016 16:58
Ubuntu 14 Nginx 1.4 > 1.9 Upgrade
//stop nginx
sudo service nginx stop
//backup config
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
//add apt repo
sudo add-apt-repository ppa:nginx/development && sudo apt-get update
//remove then upgrade nginx - choose N to prevent config overwrite (even though we made a backup)
cd /opt/letsencrypt
./letsencrypt-auto certonly -a webroot --webroot-path=/path/to/site -d example.com -d www.example.com
30 2 * * 1 /opt/letsencrypt/letsencrypt-auto renew >> /var/log/le-renew.log
35 2 * * 1 /etc/init.d/nginx reload
<?php
//Welcome to the new blog ;-)
echo 'Hello World';
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
@leemason
leemason / autoload.php
Created November 6, 2015 14:43
simple fix to prevent composer update / clear-compiled errors
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
@leemason
leemason / fluent-demo-force-direct.php
Created August 22, 2014 19:13
"fake" fileysstem direct mode.
<?php
/*
Plugin Name: Fluent Demo - force direct
Plugin URI: #
Description: Forces wp to think it has direct filesystem access during ajax and admin requests.
Author: No Half Pixels Ltd
Version: 1.0.0
Author URI: http://nohalfpixels.com
*/
add_filter( 'filesystem_method', function($method){