9
$\begingroup$

I quite often write some code for answering a question, while exploring the problem and/or after solving it to visualize or enumerate the results. If it's just a short code fragment, I sometimes include it in the answer, but often it's longer than seems appropriate for an answer, and sometimes it uses code from other packages I have that would have to be included to make it work. Since I sometimes put quite a bit of work into such code and could imagine that at least some of the readers might be interested in it (see here for an example where some said they are), but probably not sufficiently many to warrant badly cluttering the answer, I'm wondering what might be a good approach to making such code available conveniently and sustainably.

Some options that come to mind, with various pros and cons, are

  • Put it into my own web space
  • Upload it to some free file storage
  • Put it on some open-source site like sourceforge
  • Request attachments as a stackexchange feature
  • Offer to email it to interested readers
  • Include it directly in the answers after all

Any thoughts on this would be much appreciated.

[Update:]

I might try out one of the two solutions suggested so far, gist and Pastebin, so thoughts on their relative merits would be helpful. My tendency would be to use gist because of the versioning aspect.

$\endgroup$
4
  • 3
    $\begingroup$ Perhaps it is worth emphasizing the importance of persistence - which some of the above proposed solutions do not guarantee. There is an analogous problem with persistence of images, which seems to be only temporarily resolved via SE and imgur. Sites can rot in many ways. The less rotten we can make it, the better. Have we yet had any code rot? $\endgroup$ Jan 4, 2012 at 18:22
  • 2
    $\begingroup$ Ah, that was the word I was looking for :-) That's what I meant by "sustainably". $\endgroup$
    – joriki
    Jan 4, 2012 at 20:03
  • 3
    $\begingroup$ There's also Pastebin, but again there is no assurance of persistence. One would think SO would have already had such mechanisms in place before other SE sites like this one sprung up... $\endgroup$ Jan 5, 2012 at 0:14
  • $\begingroup$ The versioning aspect of gists is the biggest reason why I prefer them to pastebin. I also like that it's connected to my existing GitHub account. $\endgroup$
    – Isaac
    Jan 5, 2012 at 17:53

1 Answer 1

7
$\begingroup$

I am inclined to use gists for this.

$\endgroup$
2
  • $\begingroup$ Thanks very much this suggestion; I just used it here for the first time. $\endgroup$
    – joriki
    Feb 8, 2012 at 12:57
  • $\begingroup$ I wanted to thank you again for this suggestion; in the meantime I've linked to $31$ gists in math.SE answers :-) $\endgroup$
    – joriki
    Jan 19, 2013 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .