Remembering code snippets (eg. Global Error Handler)

Today I was searching for a code snippet that I had used some time ago. But I couldn't find it! I knew I had used it before in a project, but ofcourse I hadn't the source code with me. I work on different locations (customer's office, office, home) on different machines (customer's pc, laptop, desktop) and I don't copy all my projects to each pc. My next thought was: “No problem, just use Google!”. But when you really want to find something, the chances are high that you can't remember the exact title of the article or website you've read (Murphy's law). So no luck with Google today. Finally I went home and looked up the snippet in my old project...

This experience has happened quite some times to me (am I the only one?). So I started wondering if there is a solution for this problem. Here are some requirements:

  • Code snippets must be stored together with a description and title.
  • A nice UI has to provide functionality to store and search code snippets.
  • The data needs to be stored somewhere on the web so it can be accessed from different locations.
  • Optional: Code snippets are shared between different people.

Does anyone has an idea if such an application exists? Or do I have to make one myself? ;-)

Btw, here is the code snippet I was looking for. It adds a global error handler, that catches all unhandled exceptions


Public Sub New()

MyBase.New()
InitializeComponent()

AddHandler System.Windows.Forms.Application.ThreadException, AddressOf Me.GlobalErrorHandler
End Sub

Public Sub GlobalErrorHandler(ByVal Sender As Object, ByVal t As System.Threading.ThreadExceptionEventArgs)
MsgBox(t.Exception.ToString)
End Sub


No Comments