How do I cite or reference code that has not been officially published?
If it is part of the website or a webpage, simply refer to the webpage in your references. It clearly mentions that you are referring to a code which is published on a website.

Just look at this structure for a Chicago styled reference:


  Last Name, First Name. "Page Title." Website Title. Web Address
  (retrieved Date Accessed).


You can produce your citation like this:


  Code Producer's Last Name, Code Producer's First Name. "Sample computing source code for idea/pattern/code." Website Title. Web Address
  (retrieved Date Accessed).