27

My local project has some code that is not working, and I'd like to show it to someone to have a look at and possibly give me a hand with it. This isn't a short snippet or a single file; there are multiple files and directories involved.

How can I best publish my code?

David Planella
  • 15,420
  • 11
  • 77
  • 141
  • 4
    Extract the piece that is not working, make it a self-contained, executable example and post it on StackOverflow, together with a detailed description of what was the expected output and how it failed :) – Niklas B. Jun 21 '12 at 18:48
  • 2
    There is also http://codereview.stackexchange.com/ ... – user160917 Jun 21 '12 at 20:00
  • 3
    @NiklasB. you cannot make self-contained executables of interpreted code without going through a great deal of trouble. Much more than I'd probably like to go through for just showing a quick example to someone... – David Planella Jun 21 '12 at 22:35
  • @David: I didn't mean executable in the sense of executable. I meant it in the sense of "one can copy the code and execute it without endless adaptions". A lot of supporters don't actually do that, they can often spot errors without executing the code, in which case it helps if there is as few lines of code as possible (obviously still containing the error). – Niklas B. Jun 21 '12 at 23:29
  • 1
    @Intentss: Codereview is for working code ONLY. Stack Overflow is glad to help with broken but short code samples. – Niklas B. Jun 21 '12 at 23:29
  • @NiklasB. this is not about pasting a small snippet of code, for which there are other good answers in the thread already - apart from the obvious fact that you can simply copy it to a question as you are saying. This question is about being able to easily publish code online, even if contained in a source tree with multiple files and folders. – David Planella Jun 22 '12 at 06:12
  • @David: I wonder why that not-so-obvious piece of information is not part of your question? – Niklas B. Jun 22 '12 at 12:02
  • @NiklasB., I added the word "project" to the question's title to imply that we're not dealing with snippets or a single file. – ish Jun 23 '12 at 06:39
  • @DavidPlanella, I wonder if the word "share" instead of "publish" might appeal better to the target demographic? Just a thought. Great Q/A! :-) – ish Jun 23 '12 at 06:42
  • Nothing beats Github imho. – nikhil Jun 27 '12 at 21:37

4 Answers4

25

Use Launchpad's +junk branch feature to publish your code to a temporary location. In fact, it is not temporary, as it will remain there until you explicitly delete it, but it is a nice place to put unfinished code you're experimenting with on a public location.

This way it will stay out of the way from your regular branches, but you'll still be able to access it and show it to everyone online.

The only requirement is that you've got a Launchpad account and have uploaded SSH keys and finished the procedure to use Launchpad for code hosting.

After that, you simply need to run this command on your terminal, from the location where your code lives:

bzr push lp:~<your-launchpad-id>/+junk/<name-of-your-temp-branch>

That's it! You'll then be able to point other people to https://code.launchpad.net/~<your-launchpad-id>/+junk/<name-of-your-temp-branch>

David Planella
  • 15,420
  • 11
  • 77
  • 141
  • So far this is the only solution that allows multiple files. THanks for sharing I can see this being handy someday. – stefgosselin Jun 21 '12 at 20:41
  • 1
    This can also be done using Github, BitBucket and other repository hosts in a very similar manner. – Niklas B. Jun 21 '12 at 23:40
  • Just as a little note, the `bzr push` command can be abbreviated/simplified to `bzr push lp:~/+junk/[branch_name]` as Launchpad should reslve your username from your identifying yourself and your SSH keys. – nanofarad Oct 06 '12 at 12:59
11

Use a GitHub gist - You don't even need to register.

l0b0
  • 8,529
  • 8
  • 42
  • 67
  • 1
    A good suggestion, but that is similar to just using a pastebin, and will only let you share single files. You can put entire source trees in a +junk branch. – David Planella Jun 21 '12 at 15:46
  • @DavidPlanella, you can have multiple files in a gist (https://github.com/blog/550-multiple-file-gist-improvements) – Mihai Rotaru Jun 21 '12 at 22:02
  • 1
    That's right, but as mentioned, you cannot keep the source tree structure there. For that, you'd need a full-blown bzr or git branch. – David Planella Jun 21 '12 at 22:30
5

There's also Codereview SE, which is in public beta. Maybe not the best place for a big project, but another option.

JoeFish
  • 151
  • 2
  • 3
    The Code Review SE [FAQ](http://codereview.stackexchange.com/faq) states that the code must be working to post. If the code isn't working Stack Overflow is probably a better match. – DQdlM Jun 21 '12 at 16:56
0

If what you want to be reviewed is a single file, you can use any one of the number of popular Pastebin services.

I would personally recommend Ubuntu's Pastebin Service.

Hashken
  • 6,212
  • 5
  • 33
  • 49
Tachyons
  • 17,221
  • 18
  • 74
  • 116