Embedding Code Snippets in Your Blog Using Gists
I'm not sure why, but I've never paid much attention to Gists. Gists are pasted code snippets hosted by GitHub. You can see them here. It's a service similar to PasteBin or one of the others, but it offers more, including versioning, branching, etc. To be honest, though, what I really like is the ability to embed a Gist into my blog, like so:
I really like this approach because it removes the requirement for syntax highlighting within the blog code. Additionally, when I update a Gist, that change is reflected on the blog.
Recently I've commited a new Ruby library called Gistr that allowed developers using Rails or Sinatra to embed Gists into their views. It's a really simple library and probably not of any great use to anyone, but I thought it was fun. It could easily be extended to add functionality to other Ruby web frameworks. Feel free if you find it useful.
The main point of this post is that maybe things like Google syntax highlighter are unecessary when you can just embed a Gist.


Posted at 12:46PM on 04/21/2009 by Shamir
Yeah, I really like gists for exactly the same purpose. Plus, it's nice to be able to share code with others.