June 4th, 2008 |
Published in
Howto, Mac
Just found two helpful programs in OS X; pbcopy and pbpaste (man page). They let you write and read from the OS X clipboard and allow you do to things like:
$ cat file.txt | pbcopy
That’s a lot faster than opening the file, selecting everything, and copying it!
$ pbpaste > example.css
Quicker than firing up emacs/TextMate/whatever.
Of course you can even do fancier things like:
$ tail -n 10 /var/log/messages | pbcopy
So good!
May 31st, 2008 |
Published in
Howto, Mac, iPhone
There are lots of articles out there explaining how to make an iPhone ringtone from a song using GarageBand but it’s also possible to create them using only iTunes. Here’s how:
- Find the song you want in iTunes.
- Right click on it and select “Get Info” (Apple+I also works). Go to the ‘Options’ tab.
- Adjust the “Start Time” and “Stop Time” values to shorten the song down to the part you want to use for the ringtone (45 seconds max). Click “OK”.
- Play the track and make sure you’re happy with where you’ve set the start and stop times.
- Right click on the track again and select “Convert Selection to AAC”. This will copy the part of the song between the “Start Time” and “Stop Time” into a new file in AAC format. Once it’s done encoding, the shortened track will appear in your music library.
- Right click on the original track, select “Get Info” again, and reset the start and stop time values to what they were before we started (probably both unchecked).
- Right click on the new AAC-formatted track and select “Delete” (Apple+Backspace also works). Select the “Keep File” option when prompted.
- The AAC file is no longer in your iTunes library but is still on your hard drive. Find it by searching for it in Spotlight or browsing to your iTunes Music folder directly.
- Select the file and hit ‘Enter’ to rename it. Change the extension from .m4a to .m4r. Hit enter again.
- Double click on the file and it should open up in iTunes and be placed in your “Ringtones” folder on the side.
- Make sure you’re syncing ringtones with your phone, perform a sync, and enjoy!
Update (2008-6-14): This also works in iTunes on Windows!
May 10th, 2008 |
Published in
Howto, Mac, PHP, Programming, Software
The JavaScript Tools bundle for TextMate automatically runs JavaScript Lint on your files when saving and shows a little tooltip if there are any errors (like the missing semicolon below).

It’s very easy to enable similar functionality for PHP files. The default TextMate PHP bundle already comes with a ‘Validate Syntax’ command but it’s bound to Ctrl+Shift+V. Here’s what you need to change:
- Open up the Bundle Editor by hitting Ctrl+Option+Apple+B or opening the Bundles menu and selecting Bundle Editor > Show Bundle Editor.
- Find the PHP bundle in the list on the left and open it up.
- Select the ‘Validate Syntax’ command and then change it’s ‘Save’ option to ‘Current File’ in the dropdown on the right.
- Change the keyboard shortcut to Apple+S (or whatever you use to save) in the lower right. Your settings should now look like this.
- Close the Bundle Editor (it saves your changes automatically).
Below is an example of what you’ll see when saving. It will even move your cursor to the line with the error!

Update (2008-5-23): You can prevent the tooltip from displaying when there are no syntax errors by changing the command to:
#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + ‘/lib/textmate’
version = %x{#{ENV['TM_PHP'] || ‘php’} -v}.split[0..2].join(’ ‘)
#puts “Running syntax check with ” + version + “…”
result = `#{ENV['TM_PHP'] || ‘php’} -d display_errors=on -l`
puts result.gsub(’in -’, ”) unless result =~ /No syntax errors/
TextMate.go_to :line => $1 if result =~ /line (\d+)/