How to share code

About

How to share your code for collaboration or so that others can assist you.

Who is this for?

Anyone who needs help with their code, or just wants to share what they have done.

How do I share my code?

How you share your code might depend on what it is you want to share:

Small snippets

You can post code snippets using three backticks, or using the preformatted text button in the edit window.

Stand-alone programs or scripts

For single longer programs or scripts GitHub gists are a great option. Gists are a kind of lightweight repo, and can be linked to from forum topics.

Benefits are:

  • code remains long term
  • code is searchable (findable) by yourself and others (recommend making gists public for this reason)
  • lightweight, so easy to set up
  • great for code snippets or small programs that don’t justify an entire repo

The GitHub docs explain how to create a gist through the web interface:

For fans of the command line, the gh client is even easier and quicker:

:light_bulb: Note: You will requite a GitHub account to create a gist. On gadi the gh client is available in payu conda environments.

Larger software projects

For larger software projects it is best to create a dedicated GitHub repository:

You can create the repo in your own personal GitHub space, or you are welcome to request access to the Community Hub organisation and put your repository there:

This has the benefit of being more visible to the community, and indicates that collaboration would be welcome.

GitHub repositories have all the benefits of a gist, but can also have issues to manage bugs and updates, and pull requests to get reviews and code contributions from others. They also take a bit more effort to set up and maintain.

1 Like