Since I got my iPhone 4 my single most frustrating issue with it has been with iPhoto stalling and not syncing photos and videos from the iPhone 4. When I connect the iPhone 4 OS X kicks off iPhoto and tell it to scan the iPhone and prepare to download photos from it. When I tell it to proceed it pretends to start syncing then just drops the ball and stalls. Sometimes rebooting the iPhone would fix it and sometimes just closing the iPhone apps that are running would solve it too. One time I even rebooted both my iPhone and the Mac and had it begin syncing the photos fine. Today I took a bunch of video using the iPhone and wanted to post them on online but iPhoto starting doing the stalling thing again. I gave up and looked on Apple's Discussion forums for help. I found a post that stated the following:
Quit iPhoto Open Activity Monitor (Applications > Utilities > Activity In the search window at the top right, search for PTPCamera Click on PTPCamera in the list of results to highlight it Click on Quit Process (the red stopsign icon in the upper left of Activity Monitor) Choose “Quit” If you don’t already see “Image Capture Extension” in the list, search for it in the search box. Click on “Image Capture Extension” in the list of results to highlight it Choose “Quit” Go to Macintosh HD > System > Library > Image Capture > Devices and open back up Unplug and re-plug the iPhone 4. iPhoto should open, if you’ve set it to do so when a camera is plugged in. Otherwise, open it. You should see your media available for import from the iPhone 4 when you click on the iPhone 4 in the devices list. [Forum Post]
I hate doing manual processes such as this and wrote a quick Applescript to do the above:

tell application "iPhoto"
end tell

set app_name to "Finder"
set PTPCameraRunning to (do shell script "ps ax | grep " & "PTPCamera" & " | grep -v grep | awk '{print $1}'")
if PTPCameraRunning is not "" then do shell script ("killall  'PTPCamera'" & PTPCameraRunning)

set ImageCaptureExtensionRunning to (do shell script "ps ax | grep " & "Image Capture Extension'" & " | grep -v grep | awk '{print $1}'")
if PTPCameraRunning is not "" then do shell script ("killall  'Image Capture Extension'" & ImageCaptureExtensionRunning)

Like with any code there is a 101 ways to do the same thing and any code I’d write I’d imagine you can write better feel free to leave a comment with your own Applescript suggestion

So now all I need to do is click that script, it closes iPhoto, PTPCamera and Image Capture Extension. Then I can plugin my iPhone and do my thing.