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

February 24, 2012
Pears Wordpress Theme

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


Why is this being sent to

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

We use features and a git

We use features and a git repo! :)

This was an error in our

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