Sunday, December 21, 2014

How Do I Share Code On Blogger?

Okay, so now I finally have a blog... What do I type in it?

Well, I figured this would just be a good way of tracking some of the useful things I need to remember in case I have to repeat them again.  Hey, who knows?  Maybe it will help you as well...

I chose to use Blogger over the alternatives as a personal choice, to each their own.  My question is, however, how do I share code snippets on Blogger?

Hmm, a few Google searches which of course lead to another "closed as off topic" post in StackExchange (save that rant for another day, Brian).  In there, yodaisgreen recommends:

https://gist.github.com/

So, I click on the link and I'm logged in through google since I'm already logged into blogger.  Okay, let's see, what can I try to share.  So I took a snippet out of my .emacs to show that the blog color scheme is my UNC inspired color scheme in emacs.  I click on Create public Gist, and then on the right I see an Embed URL Link.  Okay, let's copy and paste that in the line below while I'm in Compose editing mode, and...

<script src="https://gist.github.com/statmobile/ca6261166175699d8bba.js"></script>

Hmm, that didn't seem to work.   What if I paste it in the actual HTML source editing mode:



As you can see, that worked.  Sweet!  Although I see no evidence when I go back to the Compose editing mode.  Maybe I'll put a code marker in the HTML code next time so I can see where the code insert will be when in the Compose view.

Now keep in mind, this is git versioned code, I believe.  So I have a feeling that feature will come in great since I tend to rewrite these things often as I start to learn them for the first time.  Trust me, I'll brag as soon as it does come in handy.

DISCLAIMER: Code highlighting isn't really great for emacs lisp when it comes to Git, so I'm sure other code will look much better in future posts.

No comments:

Post a Comment