Problem: When linking to the raw version of a gist, the link changes with each revision.
Solution:
To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/
- Example: https://gist.github.com/dragon788/7a7524ddc2946b2b5d114ce615465697/raw/
- Works even when you change the filename.
To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]
(via: http://stackoverflow.com/a/14529686)
BitBucket "snippets" are essentially the same thing (can be cloned/files viewed raw).
Specific file downloads are available, but not a generic "return first file": https://bitbucket.org/!api/2.0/snippets/[bitbucket_user]/[snippet_id]/master/files/[file_name]
You can also shorten these really long URLs using the https://git.io service. If you want a custom vanity tag you can follow the directions in a blog post I have to relocate or use the PowerShell module I threw together to handle the fiddly bits for you.