Put the file in one of the load-path directoris and write in ~/.emacs
(load "ymd-emacs-osx-open")
M-x ymd-emacs-osx-open
If you specify the active region, the region is used as default, otherwise url or file at the cursor position is used as default.