Simple Regular Expressions by Example

Whenever I ask a group of developers if they are familiar with regular expressions, I seem to get at least half the responses along the lines of “I’ve used them, but I don’t like them”. Call me a geek if you like, but I quite like regex; I think often it seems unfriendly because it’s used inappropriately or just thrown into code with “here be dragons” type comments rather than documentation about what should match, and what shouldn’t!

As with most things, it’s pretty easy when you know how, so here’s my one-step-at-a-time approach to regex (stolen from my ZCE preparation tutorial slides). Let’s begin at the very beginning: regular expressions have delimiters, usually a slash character, and these contain a pattern that describes a string.

pattern notes
/b[aeiou]t/ Matches “bat”, “bet”, “bit”, “bot” and “but”
Also matches “cricket bat”, “bitter lemon”

Continue reading

Is This Marketing?

Last year, someone asked me what I’d chosen for the company Christmas cards (I was relatively newly self-employed at the time). The idea of company Christmas cards had not even crossed my mind, but that conversation stayed with me and this winter, I picked a photo I took last winter, and uploaded it to moo.com, producing this:

DSCF5647.JPG

Continue reading

Importing and Exporting MongoDB Databases

I’m enjoying working with MongoDB but as with any new technology, it can take a little while to find your way around all the tools related to that stack. In particular, I found myself wondering how do I mysqldump for mongodb?

It should have come as no surprise that the command I wanted was called mongodump, really! Continue reading

Do-it-Yourself Peer Review

When I get asked about tools for quality assurance, I will pretty much always mention that the technology is not the answer. In my experience, the best improvements in quality come from process, from letting as many people as possible have access to all aspects of the system as early and often as possible (this is exactly why evolving projects “release early, release often”). A great tactic is to have another developer review each change – but what do you do if, like me, you work alone? Continue reading

Explaining MySQL’s EXPLAIN

The MySQL explain plan is a great tool to help developers and database administrators to improve the performance of specific queries happening against a database. It is very easy to use, but its output can be confusing, so I thought I’d show a very simple example. Continue reading

Simple CRUD with MongoDB

When I meet a new technology, I like to experience it “just as it comes”. I’m happy at the command line and I like to type actual commands and see man pages before I use any wrappers or helper tools. So when I met MongoDB for the first time, I did exactly that. This post shows those first steps of creating a database, and inserting, reading, deleting and updating data.
Continue reading

API Serving JSONP

disclaimer: I am not a client-side developer, and I don’t write javascript. However I am committed to supplying useful APIs of all kinds, and JSONP falls into this category

Early in the development of the new Joind.In API, someone else started consuming the service to populate the javascript widgets they were making*. Since these scripts are intended to be used on many external pages, and they retrieve data from the joind.in API, cross-domain issues were a problem. Continue reading