Currently browsing category

Uncategorized

Installing a Python package from Github

While the standard route for installing a Python package would be to upload the package to PyPI and then use pip, clearly some packages are too narrow in scope for this. For example, why should the rest of the world care about Python code for generating efficiency plots for SALT? …

Listening to ngModel in a directive

It took a bit of searching until I found the solution to how one can listen to ng-model changes in a directive with isolate scope. The suggestive solution would be to add a listener to the $viewChangeListeners property of the ngModel controller. But this isn’t failsafe, it seems; the listeners …

Custom form elements in Angular

Angular’s magic shines mightily when it comes to HTML forms, as it greatly simplifies form validation etc. But what if you would like to use a custom form element, such as datepicker using a jQuery UI plugin? Amazingly, Angular’s magic makes this quite easy – if your form element has …

Responsive SVG

Imagine that you’ve used your incredible creativity to create the following beautiful HTML: You open the page in a browser and all looks fine – well, sort of. The top, left and bottom edge of the div’s border touch the circle (at least more or less), but the right edge …

Pie in the Sky, with D3

The world is divided in beer drinkers and wine lovers. Let’s illustrate this with a pie chart, using D3 for all the rendering work. First, we need some data: The pie data for plotting can be created with D3’s pie layout. By default, the slices will start from the 12 …

Logging in Grunt, in colour

Grunt provides various functions for logging, such as grunt.log.error() and grunt.log.ok(). Most of these prepend the message with ‘>>’ and don’t colour the message itself. If you just want to output a coloured string, use grunt.log.write() or grunt.log.writeln() together with the colours provided by the colors library. Here is an …

Building Grids with Susy

With Bootstrap you can create a form with labels to the left of the input fields with HTML of the following form: Arguably, this is mixing content and layout, and it would be nicer to just have good old plain HTML like: But clearly you wouldn’t want to write all …

Adventures in Grunt Land

In theory, deploying a Flask app with an Angular frontend should be easy – just use to ask Yeoman to create the app structure for you. But the devil is in the detail, and the output generated by Yeoman isn’t necessarily exactly what you want, even though it’s an excellent …

Deploying a Flask application on Apache

Deploying a Flask application on Apache comes with a challenge or two, but the following recipe should get you going. Requirements Before deploying a Flask application on the server you need to ensure that Apache is running (we’ll assume it’s version 2.4) WSGI is enabled for Apache Python is installed …