How to share code on a blog

  • Author
  • #546396


    I’m trying to share a program I wrote in Ruby, and is really getting on my nerves with this obsession with embedded media. It only lets you upload VERY specific filetypes, and it embeds all of them. My program totals 975 lines of code written across 4 files (and this isn’t even counting 674-line file I need to include for the GPL license). I wish I could just let visitors download a .zip file and save it to their computer.

    But since I can’t do that, how exactly CAN I share my code? How do other people with programming-related blogs on do it?

    Currently, I’m copying and pasting the contents of each file under the More tag, and I’m using blockquote and pre tags to format them. It’s huge.

    By the way, I don’t want to consider the possibility of using an external hosting site like Rapidshare and Mediafire. I want to ensure that the code will be available for as long as the blog is around.

    The blog I need help with is



    Hi. Depending on the language you use for the code, the following option may be helpful:



    I’ll tell you what: That option is helpful even regardless of the language.

    Thanks airodyssey. The [sourcecode] tag works very nicely, and looks professional to boot. I’m using collapse=”true” to make it start out small.

    Some complaints: There doesn’t appear to be a button for recollapsing something after expanding it, and there’s also no way to add a vertical scrollbar to it (so if you have a large code file, you shouldn’t use wraplines=”false” because the user would have to scroll all the way down the page to find the horizontal scrollbar)… but considering that my other option is to blockquote preformatted text, it’s an improvement.

    If I write something in a language it doesn’t support, I’ll just set the language to “text”.



    Glad I could help :-)

    You may want to send your suggestions to staff for consideration:

The topic ‘How to share code on a blog’ is closed to new replies.