Hash-color
This example uses hash-color.js to generate unique colour values for a given text. For example you might use email or name to create a unique user colour.
Using a consistent saturation and lightness helps to avoid clashing or ugliness with your existing theme.
The code
The source is available at github.com/johnhunter/hash-color or you can download / copy from below.