Skip to content

Instantly share code, notes, and snippets.

Tony Ford tony4d

Block or report user

Report or block tony4d

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tony4d
tony4d / keybase.md
Created Apr 17, 2014
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am tony4d on github.
  • I am tony4d (https://keybase.io/tony4d) on keybase.
  • I have a public key whose fingerprint is 3F64 5B71 C70B 4BFE 5E2A D205 2AEC 93AD 5C92 5CAC

To claim this, I am signing this object:

@tony4d
tony4d / ruby-from-source.sh
Last active Aug 29, 2015
Compile ruby from source for rbenv on OS X
View ruby-from-source.sh
# Assumptions:
# - You are using rbenv, installed in ~/.rbenv
# - You are using homebrew
# - You want to install ruby 2.1.2 (for example)
#
# Make sure you have openssl installed first
brew install openssl
# Before you begin, download ruby source from https://www.ruby-lang.org/en/downloads/
@tony4d
tony4d / mongo_inplace_field_update.js
Created Mar 5, 2011
Simple way to change data in mongo using existing data in a document
View mongo_inplace_field_update.js
// Here my collection is named articles
// I'm changing the blog_name field in every document in that collection to lowercase
db.articles.find().forEach(function(doc){if(typeof(doc.blog_name) == 'string') {doc.blog_name = doc.blog_name.toLowerCase(); db.articles.save(doc); }})
@tony4d
tony4d / svn2github
Created Apr 8, 2011
Migrate an svn repository to git and github
View svn2github
# 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>
@tony4d
tony4d / xbox-ie-user-agent.txt
Created Oct 19, 2012
Xbox 360 Internet Explorer (ie) User Agent
View xbox-ie-user-agent.txt
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox)
@tony4d
tony4d / gist:5779546
Last active Dec 18, 2015
Simple mysqldump to sync up a dev env
View gist:5779546
mysqldump -u [user_name] -p -Qce --max-allowed-packet=1024M -B [database_name] > database_name.sql
@tony4d
tony4d / gist:5826186
Created Jun 20, 2013
Install some ie vms on a mac
View gist:5826186
# 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 / memcache_bench.php
Created Jan 21, 2013
Benchmark the memcache php extension from cli
View memcache_bench.php
<?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 / mysqldump-backup-slave.sh
Last active Jun 18, 2018
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.
View mysqldump-backup-slave.sh
mysqldump -u [user] -p -xQce -R --master-data=2 --max-allowed-packet=1024M -B [db_name] | gzip > [db_name].sql.gz
@tony4d
tony4d / mysql-analyze-all-tables.sh
Created Oct 13, 2015
Analyze all tables in a mysql database from the command line (bash)
View mysql-analyze-all-tables.sh
#!/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
You can’t perform that action at this time.