I came across my first pastebin while following the SpamAssassin mailing list. Users of the SpamAssassin mailing list face an interesting problem. They frequently need to share examples of spam with one another in order to help debug SpamAssassin. But the SpamAssassin mailing list is hosted on the same servers that run all of Apache's mailing lists. Hence the SpamAssassin mailing list is filtered by SpamAssassin itself.
The consequences of this are logical, though ironic. If you want to share the contents of a spam message with the SpamAssassin mailing list, it will most likely get blocked by SpamAssassin. Doh!
So what recourse does someone investigating a spam message have? Answer: post the spam message to a web site, and send the link to the posted message content to the mailing list.
This is where a pastebin comes in. A pastebin is a web site that allows you to publish a snippet of code, a server log, a spam message, or any arbitrary piece of text. You can then share the link with people so they can review it.
The utility of a pastebin extends far beyond my SpamAssassin example. They are frequently used by developers on IRC channels. Pasting a 60 line code snippet into a chat window and telling someone "Hey look at line 32 for me" does not work. Lines wrap in weird ways, monospace fonts are not guaranteed, and line numbers are not preserved.
Similarly, if you want help with an HTML or Javascript issue, you'll have a hard time pasting your code snippet directly into a web site. Most sites, for security reasons, will strip some or all of the HTML tags, and will almost certainly not let you paste Javascript that might execute when it's rendered on the web page.
Here's a list of a few of the pastebins out there and what they can do:
This is one of the older pastebins and was the first one that I was introduced to via the SpamAssassin mailing lists. It allows you to do several cool things:
Here's an example of a paste in pastebin. This is a snippet of Python code that generates awful poetry. It's derived from an exercise in Programming in Python 3.
I created a follow-up to this paste where I added a comment line and highlighted it:
Pastebin provides a diff between the two pastes here:
http://pastebin.com/pastebin.php?diff=f4feb6a1c
Github now provides a pastebin. They are called gists. There are a few nice options:
Here's a sample gist: http://gist.github.com/120863
snipt.org has a lot of the features of the previously mentioned pastebins, including syntax highlighting, embedding, access to the raw text, and private snipts. It also offers a few unique options:
Here's my awful poetry python script with the "Glitter Bomb" theme:
This is not a pastebin, but offers syntax highlighting and line numbering of code snippets that you include on sites that you host. It's written in Javascript and offers support for multiple syntaxes. As of version 2.0 it also provides theming support via CSS.
There are SyntaxHighlighter plugins for popular content management systems like Wordpress, Drupal and MediaWiki. I came across an example SyntaxHighlighter in a great post on human-readable sorted du output.
There's a lot more pastebins out there. See the Wikipedia entry on pastebins for more detail. If you're thinking of starting your own, pay attention to the "Abuse and spam" section on the Wikipedia page.