Skip to content

Instantly share code, notes, and snippets.

@tony4d
tony4d / p4merge4git.md
Created August 24, 2012 19:00
Setup p4merge as a visual diff and merge tool for git
@tony4d
tony4d / mysql-analyze-all-tables.sh
Created October 13, 2015 03:31
Analyze all tables in a mysql database from the command line (bash)
#!/bin/bash
# To avoid doing things like putting your mysql password on the cli which is not secure
# Use mysql config editor http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
for table in $(mysql --login-path=mylogins -D database_name -Bse "show tables");
do mysql --login-path=mylogins -D database_name -Bse "analyze table $table";
done
@tony4d
tony4d / xbox-ie-user-agent.txt
Created October 19, 2012 04:11
Xbox 360 Internet Explorer (ie) User Agent
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox)
@tony4d
tony4d / php-lint-git.sh
Created April 28, 2011 08:52
PHP lint all files added or modified locally
for i in `git status -s | sed -e 's/^.* //'`; do php -l $i; done
@tony4d
tony4d / mysqldump-backup.sh
Last active June 11, 2019 03:28
Backup all databases on a mysql server excluding information/performance_schema and including UDFs/stored procedures. Most useful scheduling this on a slave db.
#!/bin/bash
# No username or passwords in this script, you should use mysql_config_editor
# to store it securely. The login-path in this script is set to "local-backup" so when you create
# your .mylogin.cnf with the mysql-config-editor make sure it is set the same
# See http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
# An example to create your config for a mysql user "backup":
# shell> sudo mysql_config_editor set --login-path=local-backup --host=localhost --user=backup --password
# The backup user in the mysql server needs these privileges: SELECT, RELOAD, SHOW DATABASES, REPLICATION CLIENT
@tony4d
tony4d / mysqldump-backup-slave.sh
Last active June 18, 2018 09:52
Using mysqldump for backups on a slave. Note the use of --master-data=2, this makes sure we get a global read lock and write out a comment in the sql file with the master log filename and current position. Now this backup is good for adding or bringing back a slave from scratch.
mysqldump -u [user] -p -xQce -R --master-data=2 --max-allowed-packet=1024M -B [db_name] | gzip > [db_name].sql.gz
@tony4d
tony4d / memcache_bench.php
Created January 21, 2013 20:36
Benchmark the memcache php extension from cli
<?php
/*
exit codes:
0 - everything ok.
1 - failure to connect
*/
if ( ! extension_loaded('memcache') ) {
die("memcache pecl module is not available. Please install a STABLE version from http://pecl.php.net/package/memcache");
}
@tony4d
tony4d / gist:5826186
Created June 20, 2013 20:13
Install some ie vms on a mac
# first download and install virtual box
curl -O http://download.virtualbox.org/virtualbox/4.2.12/VirtualBox-4.2.12-84980-OSX.dmg
# Then install ie8, 9 & 10 vms
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | env IEVMS_VERSIONS="8 9 10" bash
@tony4d
tony4d / gist:5779546
Last active December 18, 2015 11:59
Simple mysqldump to sync up a dev env
mysqldump -u [user_name] -p -Qce --max-allowed-packet=1024M -B [database_name] > database_name.sql
@tony4d
tony4d / svn2github
Created April 8, 2011 05:14
Migrate an svn repository to git and github
# Assume your svn repo is located at svn://example.com/myapp/trunk
# Assume your git repo will be located at git@github.com:example/myapp.git
# First you need to generate a list of all committers in your svn tree.
# Credit David Wheeler
# http://www.justatheory.com/computers/tricks/list-all-svn-committers.html
$ svn log --quiet svn://example.com/myapp/trunk | grep '^r' | awk '{print $3}' | sort -u
# Next, create a file in your home directory named svn-committers following this format
mojombo = Tom Preston-Werner <tom@github.com>