Robin Andeer

Coder, gymnast, INTP, and designer of websites. I solve medical mysteries at SciLifeLab.

Read this first

Supervisord: less server babysitting

[Supervisord][supervisord] is a simple monitoring tool. It consists of a server and an accompanying command line interface to manage and check the status of long running processes.

Motivations for adding complexity

Adding yet another component should always be weighted against the consequences of adding more complexity. A successful deployment of supervisord will do much of the babysitting involved in server maintenance. But we all know that it’s never that easy and a simple Bash script in a crontab will likely take you 90% of the way.

Having said that, here are a few really nice benefits you get from using supervisord:

  • A unified interface for starting, stopping, and reloading your processes
  • Automatic restarts if your processes go down
  • Ability to define startup scripts using intuitive yet powerful ini files

Installation

Supervisord is really simple to install:

$ sudo apt-get
...

Continue reading →


Deploying a Python Flask server

Recent changes at work has made it clear that our small team of 3 core developers really need to take charge of how we setup things and deployed across our IT infrastructure. I already know I will learn a lot and an important part in that process is to spread gained knowledge beyond simply myself.

In this light, I’m planning to do a series of articles on deployment of a semi-complex Flask server with an accompanying MongoDB database. The contents of this series of posts will evolve over time but for now I’m at least planning to cover:

  • Supervisord: babysitting your processes
  • Gunicorn/uWSGI: another layer to add speed to your server
  • Gulp.js: building and compiling front-end assets
  • Vagrant + Ansible: bootstrapping a development environment
  • GitHub webhooks: complete deployment automation

I will start with a nifty little utility I just picked up: supervisord.

Continue reading →


In response to “About motivation”

This post is written as a follow-up to “About motivation” in which @guillemch writes about going through recurring cycles with lack of motivation. He shares his thought on why they take place as well as dealing out some general tips on how to lift yourself out of those rough patches.

From mid December to mid February, I entered some kind of vicious cycle of demotivation […] this is not the first time that happens to me, and I know that this is a common issue, [e]specially among programmers, so I started thinking about the cause of these demotivation peaks.“

Motivation is a tricky subject, overlapping with procrastination, inspiration, productivity, and discipline. Let’s see if I can stay on topic.

What makes me lose motivation

I can emphasize with all three main points the original author brings up for why he gets unmotivated; repetitive tasks, frustration born from things that are...

Continue reading →


5 Functional Programming Tips in Python

Learning about functional programming (FP) is well worth your time. The insights you acquire will put you straight on the path to becoming a Python Guru.

To get the most out of this article you should grasp the basics of pure functions, side effects, and higher order functions.

1. Use immutable data structures

mutability.jpg

The most straightforward way of avoiding side effects is to use immutable data structures. Use them as often as possible. There aren’t many immutable builtins but the standard library expands the roster a little. One surprisingly useful replacement for the builtin dict is the namedtuple.

>>> from collections import namedtuple

 create an immutable dict-like class
>>> faux_dict = namedtuple('faux_dict', ['name', 'age'])
>>> person = faux_dict(name='Paul Thomas Anderson', age=44)

You access values through dot-notation which is even cleaner than dictionary keys, right?

>>>
...

Continue reading →


Open Source Portals

Open sourcing a software project is like owning a pet. Even though it involves a lot of work and responsibilities the benefits speak for themselves:

  • You learn to collaborate with and enlist the help of other developers (for free).
  • You feel motivated to follow best practices like continuous and automated testing to alleviate said collaboration.
  • It forces you to think about how to document your code and its usage.

Inspiration

They guys over at LayerVault have certainly understood the value of Open Source. One glowing example of this is Cosmos; a collection of internally developed open source projects. Such a simple idea, but still something I’d never seen realized before with such finess and ambition.

LayerVault Cosmos

Our open source portal

The concept stuck with me as I picked up my first real pay check at my current employer (SciLifeLab). By mid 2014 I finally pitched the first draft of our very...

Continue reading →