Skip to main content

Bespoke web development & support


Keep up-to-date with the world of web-tech with our news, tutorials and general business updates.

Mentoring at the YRS Festival of Code 2015

Festival of Code 2015I recently helped out a team in the Young Rewired State Festival of Code as a mentor. I worked with three young people aged between 9 and 13 who were already accomplished hackers (in the positive sense of the word!) and quite probably future developers, to build a demo version of an app that connects businesses with an abundance of food - and hence waste - and food banks.

I offered assistance by quickly brushing up on Python - the language that we were all most comfortable with - and helped put together a server providing an open API linked up to MongoDB and helped to make a frontend interface for that in JavaScript. The result of much work by the participants was Ko-lect.

A Reference for Using Drush Remotely

Drush is an incredibly powerful tool for working with Drupal sites, and if you're not using it to your full advantage, you're almost certainly missing out. However, Drush has so much functionality that may not be immediately apparent that it's likely that we're all missing out on ways it could help our workflow.

Drush can run on a site even when it's not your working directory through the use of Drush aliases. That alone could speed up work on local sites, but you can use multiple aliases for the same site including details for connecting to remote environments over SSH!

Let's get set up.

Aliases are defined using a simple config file. In ~/.drushrc/ you can create a file with a name of this pattern:


... where <sitename> is your site alias name. That's whatever you want to refer to the site by. Inside this file, you'll want this as a base:

Threaded Comments with an Array of Ancestors Structure in MongoDB

Threaded discussion models are a simple idea and have been common in Internet discussion platforms since long before the Web. While nested replies make a lot of logical sense, such a model isn't suitable everywhere and you will find plenty of strong opinions about their usability. That aside, actually implementing this sort of reply tree can be quite difficult, not in the least because there are many different ways to do it. Here, we have built a threaded discussion system in MongoDB working with a Node.js content management system based on arrays of ancestors.

Storing Comments

Here is a typical comment stored with this structure. Each comment can be stored, standalone, in a 'comments' collection - we won't need to nest replies all in one document.

CSS: Pull In Content from the Edge of the Page

This is a simple and effective bit of CSS for having your content pull in from the edge of the page up until the edge of a centred container. It's quite a powerful visual effect, having the whole margin on one side be taken up by the same colour as the content container itself.

You can actually use a two-colour gradient background to achieve this, but I'm going with a method using margins which is more flexible.

For Main Content:

Have your main content area extend its margins to the edge of the page!

Full content version of this CSS

The CSS:

.main-container {
  padding: 20px; /* optional */
  margin-left: -1000%;
  padding-left: 1000%;
  background: #fff;

.wrapper {
  margin-left: auto;
  margin-right: auto;
  width: 50%;