Thursday, 6 October 2011

Code Snippet Archive to Benefit Everyone

I just saw a very useful jQuery code snippet from @aneesha in one of her tweets:

jquery to hide or show columns in a table $('td:nth-child(2)').toggle();

I don’t need this code today but probably could use in the future. Where should I store it for safe keeping? Indeed where should Aneesha store it for all software devs to use?

I have been storing such coding gems in my Evernote repository (great for me), and I can even make my Evernote notes available to everyone (only great if everyone can find them). This is not a good solution for a really useful repository and permanent curation.

2011-10-06 SNAG-00However I did come across a much more useful solution when I attended the BrisJS meetup earlier this week. Pete Chappell gave a lightning talk about hashbangs and he put his notes/slides/code examples in the gist repository collection on github. As all developers have long known github has become the popular place to store shared, distributed repositories of code/data/text documents of all kinds.

2011-10-06 SNAG-01You don’t have to be a software developer to find these repositories useful, they can be used for web sites, large structured documents, data collections and so on. git and github are supported on all hardware platforms.

github says of gist:

Gist is a simple way to share snippets and pastes with others. All gists are git repositories, so they are automatically versioned, forkable [copied, cloned] and usable as a git repository.

You can create both public and private gists and update them to new versions as time goes by. All the public gists are searchable and there is an immense treasure trove of code and data samples there, both big and small. Pete Chappell’s gist is number 1,258,359 for example.

If you have text-based data of any kind you want to share publically or privately long-term then gists are for you. OK, Aneesha?