How do I reliably find a URL to a script or other file?

Does this help?:

return plugins_url('/js/'. $scriptPath, '__FILE__');

OR

return plugins_url('/code/<your php file name here>', '__FILE__');

Try the Codex for plugins_url as well.