Database Design for Bus Timetables

Introduction

Recently, for a large website commissioned by the local agency for tourism, I had to design a system for storing Skibus timetables. The requirements were straightforward:

  • store multiple bus lines;
  • each line is a round trip, therefore it has two directions (outbound and return). But the route may not be the same;
  • each line is effective between two dates

The aim of the website was to provide timetables to regular users using standard HTML tables instead of static PDF …

Read More
Efficient appended property using Laravel Eloquent

Introduction

This technique is really useful to check if an Eloquent relation is loaded on a Model, in order to efficiently generate an appended property.

For example, this approach is particularly useful in a multilingual application, where you can have an entity that has a number of related translations in different languages. Consider the following code:

<?php

class Entity extends Model
{
	public function translations()
	{
		return $this->hasMany('Translation'); …
Read More
Dropzone.js, React.js and Fluxxor integration

Introduction

In these days I’m digging deep in the wonderful React.js library, widely used by Facebook and Instagram for their UIs. This library uses an abstraction of the DOM, called Virtual DOM, to render components in the View. Honestly I’m was not a big fan of DOM abstractions, because in my opinon it affects both the work of developers and designers. HTML should not be mixed with JavaScript and viceversa. I’ve worked in the past years with declarative libraries like …

Read More
Durandal 2.0 folder structure and optimization

Folder Structure

Recently, before starting a Node.js (using Locomotive.js) and Durandal project, I searched the web for the optimal folder structure. I didn’t found nothing really useful so I decided to go on using the Durandal’s convention, separating views and viewmodels, in the public folder of the Node.js application. I ended up using the following structure:

  • App: the main folder of the Durandal application
    • views: HTML files of the application (V in MVC)
    • viewmodels: the …
Read More
JavaScript Closures

Introduction

In this new post I’m going to talk about “closures”. Just like [hoisting]({{ site.url }}/javascript-hoisting/), closures are a key concept to JavaScript, since they allow to create functions that bind the variables within a scope. Closures are usually used to build callback functions.

A good definition is available on the Mozilla Developers Network website, on which this post is entirely based.

Closures are functions that refer to independent (free) …

Read More
JavaScript Hoisting

Introduction

In this post I am going to talk about JavaScript. Recently I rediscovered this programming language, after a long time distance caused mainly by its quirks. However while working on my thesis I started to enjoy this language and I realized how much powerful it can be, if used in the correct way.

“Do you want to work with the Web? Better learn JavaScript” said once a teacher of mine.

Therefore with a series of posts I’m going to analyze those little …

Read More