How to embed gist samples in Google Sites

To make sure that your blogger and your site always reference the same (latest) version of your code samples, and that the formatting is consistent across your site and your  blog, you should consider using github to be the master for all your code samples. Take a look at how to embed gist in Blogger in this post. Here we'll cover how to do the same thing in Google Sites (which is hosting this site).


This is a free repository (and version management system) for code samples. Just register and you're ready to create your first code sample (or gist as they are referred to). Of course Google Sites restricts what you can do, so although github provides a perfectly good piece of javaScript to embed a sample, you have to implement a gadget to host it. I came across this gadget from derquinse, so let's use that one.


We'll use the code sample for Simple implementation of R- melt to embed the code from this gist. Here is the XML file needed

Derquinse Gist.GitHub Gadget

The gadget spec URL could not be found

And it Works! Now my site will be automatically updated if I change the code. 

Using Google Apps Script

Another way is to use the caja prettifier  wrapped up in Google Apps Script. You can read about how this works here. This time we use a simple iFrame gadget, and embed a URL like this

Here is the same thing - 

See Get Started Snippets for more topics like this.  In the meantime why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available. 

Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly

If you prefer Video style learning I also have two courses available. also published by O'Reilly.
Google Apps Script for Developers and Google Apps Script for Beginners.