Rinse and repeat: Do you have a place where you keep common code?

Posted by JD Collier on February 24, 2012

When you make websites for a living, there are many times when you repeat something from a previous project. You need to add code to increase PHP memory limit in the htaccess file, set up the initial framework for your CSS file, or add your Made-By logo code to the footer of a website. The list goes on and on. Sometimes you find yourself whispering the shampoo bottle mantra, "rinse and repeat."

The old way

I used to find myself searching every time I needed that piece of code — searching Google, searching old projects, searching through my notes. I have snippets of code in Espresso and Coda, I have snippets of code in Evernote, I have bookmarks to code snippets on other sites. What I needed was a common repository for our company where we can put code snippets to share amongst the team.

The new way

Enter Pears, a Wordpress theme.

The theme describes Pears as an "open source Wordpress theme, enabling people like you to get your own pattern library up and running quickly."

Out of the box, the Pears theme sets up fields for HTML and CSS code. I'm going to add a place for non HTML/CSS code as well. Then, I'll be able to have a place for HTML, CSS, PHP and more. The design of the theme is very clear and organized. It is a great foundation to build a useful repository of code patterns.

I've started ours with some common htaccess rules we use on every site, some HTML5 snippets that I don't want to forget and a Drupal preprocess function that I seem to forget every time I start a new project.

What do you use?

Do you have a way to store reusable patterns of code for your work? What do you use?

Image from Simplebits


Get thought-provoking and actionable insights to improve how your firm makes a connection with your customers.


The content of this field is kept private and will not be shown publicly.

Plain text

  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Submitted by Your Name on Fri, 02/24/2012 - 11:17am

Why is this being sent to drupal planet as it really has nothing to do with drupal?

Submitted by Alex Weber on Fri, 02/24/2012 - 11:17am

We use features and a git repo! :)

Submitted by Amy Peveto on Fri, 02/24/2012 - 12:23pm

This was an error in our taxonomy. Thanks for the heads up.