Author Archives

MySQL: Dump DB with todays date in filename

mysqldump -uUSER_NAME -pPASSWORD DB_NAME > DB_NAME_`date +%Y%m%d%H%M%S`.sql
I love a good dump me. This will dump schema and data.

OS X: Show all files

defaults write com.apple.Finder AppleShowAllFiles TRUE
Stop Steve Jobs hiding files from you.

svn: list files changed in a revision

svn log -v -r 1178
Where revision number is 1178. For more svn info read the online subversion book.

svn: show commits for particular user

svn log | sed -n ‘/pxg/,/—–$/ p’
The above code will show all entries in the log for the user pete.

Linux: List files by time

ls -lt
Or you can flip reverse it:
ls -ltr

Vim: Find number of matches in a file

:%s/pete//gn
In the above example we are looking for the number of matches for the word “pete”.

Linux: pwd show real location (not symlink)

pwd -P
Use the physical flag luke!

OS X: Stop MySQL

sudo /Library/StartupItems/MySQLCOM/MySQL stop

OS X: Remove 3D Dock

defaults write com.apple.dock no-glass -boolean YES; killall Dock

PHP monitor server log

PHP monitor server log
Occasionally you'll be working on a webserver and not have SSH access to it. Below is a simple script I've written that reads a server log (in this case the error log) and outputs a portion of it to a webpage.
PLAIN TEXT
PHP:

$no_lines = 25;

 

$filename = $_SERVER['DOCUMENT_ROOT']."/../logs/error.log";

$handle = fopen($filename, "r");

$contents = fread($handle, filesize($filename));

fclose($handle);

 

$contents [...]