Skip to content

Instantly share code, notes, and snippets.

View abovedave's full-sized avatar

David Longworth abovedave

View GitHub Profile
@abovedave
abovedave / gist:62e96e03512775fd0458
Created August 4, 2014 16:50
Count up from a given number (jquery(
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$('.count ul li strong').each(function(){
var start = parseInt($(this).text(), 10);
var _self = $(this);
setInterval(function(){
var update = start++;
@abovedave
abovedave / s3backup.sh
Created November 11, 2013 17:16
Backup to an S3 bucket. Requires Python and s3cmd (https://github.com/s3tools/s3cmd) Optimised for Media temple but could be tweaked for any set-up
#!/usr/bin/env bash
# Media Temple account number
account="XXXXXX"
# A list of website directories to back up
websites="example.com"
homedir="/home/$account/users/.home"
@abovedave
abovedave / gist:7397621
Created November 10, 2013 12:24
Rsync to copy from one host to local
rsync -r ssh remoteuser@remotehost:/copy/from /copy/to/
@abovedave
abovedave / gist:7043573
Created October 18, 2013 15:51
mysqldump all databases on a given host as separate .zip files
#!/usr/bin/env bash
destination="/path/to/save/sql"
mysql_host="localhost"
mysql_user="readaccount"
mysql_pass="password"
databases=`mysql -h$mysql_host --user=$mysql_user -p$mysql_pass -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`
for db in $databases;
@abovedave
abovedave / gist:7034147
Last active December 25, 2015 20:19
nginx server configuration for Symphony CMS
server {
server_name www.example.com;
rewrite ^ $scheme://example.com$uri permanent;
}
server {
listen 80;
server_name example.com;
root /srv/www/example.com/public_html/;