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.
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
https://storage.googleapis.com/toasty/p/gaspubcontainer.html?source=gist&library=3357942
The code below would have been displayed in the created gadget.
bruce mcpherson is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.mcpher.com. Permissions beyond the scope of this license may be available at code use guidelines