Mac OS X Hints
Leopard/Snow Leopard - mysql_connect() Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)
by matt on Jul.05, 2009, under Mac OS X Hints
I was setting up my local PHP/MySQL development environment on my local MacBook Pro to mirror our work development setup.
I ran into the following error:
Warning on line 365 of include/lib/adodb/drivers/adodb-mysql.inc.php mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)
I have fixed this issue in the past on a previous Leopard install, so I thought it was the perfect candidate for a blog post.
Customise php.ini file to use custom MySQL socket
If you have made manual customisations to your php config file already, skip this part; otherwise run the following in Terminal.app:
sudo cp /etc/php.ini.default /etc/php.ini
Next, open Sequel Pro and connect to the mysql server on your local Mac. If you don’t know how to do this, take a look at Getting Connected on the Sequel Pro documentation page.
Then, choose Database > Show Server Variables…
Scroll down through the list of variables until you get to socket.

Open up /etc/php.ini in Textmate or Coda and scroll down the where it says:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
Change the mysql.default_socket line to read:
mysql.default_socket = /tmp/mysql.sock
Restart Web Sharing Service (Apache)
Now, restart your Web Sharing service by going to > System Preferences…
Choose Sharing from the System Preferences page.

On the sharing pane, uncheck Web Sharing, wait a second for it to do its thing, then recheck it. If it was already unchecked, you will just need to choose the checkbox once.

Now, just reload your php page in Safari, and it should hopefully just work. Your app should now be connecting to the local MySQL server on your Mac. Enjoy!
Mac Web development
by matt on Feb.25, 2009, under Mac OS X Hints
Show hidden Files in Finder
Web Programmers need access to .htaccess files and occasionally other dot files/folders. Here is a way that you can make Finder (and your Desktop) show all files.
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Remove SVN folders from a website
The command is broken into two parts, firstly we get a list of paths for the files to be deleted:
find . -name ".svn"
Once we are happy that the result from the first command worked correctly, we then attach the delete part of the command:
find . -name ".svn" | xargs rm -r
If the files are locked or if they aren’t owned by the user running the command, try the same line but with sudo attached to the second part of the command:
find . -name ".svn" | xargs sudo rm -rf
Setting up Transmit

Transmit: Show Invisible Files
Most web developers want to be able to upload .htaccess files in Transmit as part of their web development workflow. Choose Show Invisible Files from the view menu in the main application window.
Queued transfers (if your server supports it) are a lot faster than single file transfers. By default the Queue is turned off in Transmit. To turn on Queueing, go into the Preferences menu and choose the Transfers tab. Set the Maximum queue connections value to a sensible number (2-4).

Transmit: Turn on Queue mode.
Removing those pesky dot-underscore ( e.g - ‘._index.php’) files
These files can really cripple your mac subversion experience, but there is an easy fix for this annoying issue. Run the following command in Terminal:
mate .subversion/config
and look for the global-ignores line in the config file. Uncomment the line if necessary and replace it with the following list.
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ .#* .DS_Store ._* *.log *.bak
You will need to restart Versions.app for the changes to take effect. ![]()
Safari Debug Menu
One of the most “can’t live without” features of web development in Safari is the Debug menu.
You can turn it on by typing the following command into Terminal.app.
defaults write com.apple.Safari IncludeDebugMenu 1
Then, restart Safari or WebKit and enjoy!
WhatTheFont on iPhone
by matt on Feb.12, 2009, under Mac OS X Hints, Web Development
Sites that require a file upload to occur as the main functionality, are a little restricted on the iPhone. The folks at myfonts.com have circumvented this by offering an iPhone app that allows you to upload photos to their font-matching service (WhatTheFont) from either your iPhone camera, or from existing images in your iPhone Photo Gallery.
The WhatTheFont website is one of the most useful tools by far, in any graphic designers/web developers toolkit. Next time you are away from your Mac/PC and you see a radical/groovy/cute/funky/quirky or modern font on a poster or a menu, just whip out your iPhone and snap a pic and get a font match.
*I tried this on my jail-broken version 2.0 firmware iPhone with no luck, although it is most likely that this is because I’m not running firmware version 2.2.1 (current at time of writing).
Stop Textmate from creating ._ files
by matt on Jan.09, 2009, under Mac OS X Hints
Textmate, by default creates annoying hidden ‘._’ files that litter your svn status listings. These resource fork files will store cursor position, bookmarks and text folding as metadata. It is however possible to disable resource fork use in textmate.
Close textmate and run the following in terminal:
defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1
Source: http://manual.macromates.com/en/saving_files
Mac DNS Flush Cache
by matt on Oct.14, 2008, under Mac OS X Hints, Rantings
In the office recently, our internet line went down and our local DNS server was routing all internet traffic to an internal server on a 192.168.*.* address.
Any sites that we visited while the internet was down had their DNS records cached with the 192.168 address.
When our internet came back up, google.com was still resolving to the 192.168 address.
To flush the DNS cache, in Mac OS X 10.5.5 Leopard I ran the following command in Terminal.app.
Using Changes.app with Versions.app
by matt on Aug.13, 2008, under Mac OS X Hints, Rantings
To use Changes instead of FileMerge in Versions for doing file diffs create a symlink to chdiff (the command line tool for running Changes) from the original opendiff path.
First, Become super user.
sudo -s
cd /usr/bin
If necessary, backup the old opendiff binary.
Then, create the symlink.
ln -s /Applications/Changes.app/Contents/Resources/chdiff opendiff
Make sure you type exit after you are finished.
Browser Resize Bookmark in Safari
by matt on Aug.07, 2008, under Mac OS X Hints, Rantings
If you have made the switch from Firefox to Safari for web development (or perhaps you are looking to thoroughly test your website in Safari), and are longing for a way to quickly change browser size, try the following tip:
Open the Safari Bookmark manager (using option + command + b ) and add the following bookmark to the Bookmarks Bar.
To resize the browser window to 1024×768:
Bookmark: 1024×768
Address:
javascript:self.moveTo(0,0);self.resizeTo(1024,768);
To resize the browser window to Fill the Screen:
Bookmark: Fullscreen
Address:
javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);




