PHP: Save image from url

file_put_contents($file_location, file_get_contents($image_url));

Now go get stealing images!

PHP: Get tmp directory

sys_get_temp_dir()

Didn’t know about this function before today.

OS X: Terminal launch finder for current directory

open “`pwd`”

PG TIP: I like to add this to my .bash_profile as an alias so I can just type finder to launch it:

alias finder=’open “`pwd`”‘

wget page source and all related assets

wget -p -k http://site-you-want-content-from.com/dir/page_name.html

You can get an OS X installation of wget here http://www.statusq.org/archives/2005/02/22/610/

mysql: dump database without locking tables

mysqldump -uUSER -pPASSWORD DB_NAME –lock-tables=false > dump.sql

Linux: find all files in folder with extension

ls -R | grep gif$

The above command will list of the gif files you have in your folder (it will look recussively in subfolders). If you wanted to see the paths as well you could use the find command:

find ./ -name *gif$*

Rsync: copy files but not .svn directories

rsync -n –exclude .svn -av /PATH/TO/SOURCE/DIR/* /PATH/TO/DEST/DIR/

rsync –exclude .svn -av /PATH/TO/SOURCE/DIR/* /PATH/TO/DEST/DIR/

The first command will similulate the copy (useful to test). The second command will actually execute the sync.

svn: delete unversioned files

svn status --no-ignore | grep '^\?' | sed 's/^\?      //'  | xargs rm -rf

Thanks to Guy Rutenberg for this, your definitely in my list of top 5 guys.

svn: add all unversioned files

svn add * –-force
svn commit -m “”

svn: remove all .svn folders

find . -name .svn -print0 | xargs -0 rm -rf

This will remove all .svn folders and their contents even in subdirectories. Note if you don’t want the .svn folders it’s better to do an svn export instead of checkout.