DjangoCon 2015 notes

Here is a quick set of notes from my recent trip to DangoCon Europe 2015.

 

Coding talk

There was a bit of discussion about best place to put your app’s business logic – either in the django-recommended model manager or in a service layer component

Either way never write to a model field or call save() directly in a view – a good blog post on why: http://www.dabapps.com/blog/django-models-and-encapsulation/

git-crypt might be worth a look if you ever want to store secrets in github.

Suggested preference to import models over classes and remove unneeded labelling in the process
e.g. favouring

import view
view.Login(...)

over

from view import LoginView
LoginView(...)

Lots of talk around Django as headless server & Microservices architecture – see Martin Fowler’s recent blog post on the subject: http://martinfowler.com/bliki/MonolithFirst.html

 

Python 3 talk

Probably worth always adding following imports when creating new python files:
from __future__ import absolute_import, division, print_function

And this neat utility:

pip install caniusepython3
caniusepython3 -r requirements.txt

 

Testing talk

Check out hypothesis – a nice python-based fuzz tester for unit tests

Nose is dead, long live py.test! py.test is actively maintained, has nicer output, more pythonic assert statements, ability to tag slow tests and rerun only failing tests. Will work with Django’s TestClient but might need to do some work to migrate existing nose tests.

django-test-plus – a nice wrapper around reverse and other useful utils

 

Services talk

https://requires.io/ – monitors your requirements.txt for updated packages and security fixes. Free to public github repos.

https://pusher.com/ – aims to fill the middle ground between Sentry and NewRelic

Tackling performance problems in Django

Launching a product is fantastic fun, but the work doesn’t end there. Once you start to build up a considerable amount of content and gain more users interacting with your system you will need to be on the lookout for areas of poor performance. In this blog post I will explain some of the code-level tools and techniques we use to identify & improve the performance of BOS. Continue reading

Experiences moving to Linux on my Laptop

Over the last 8 years or so at work I’ve been slowly been making the switch to a world based completely on open source or free-to-use software (such as Eclipse, Google Apps, Evernote, LibreOffice etc). What kicked this off was a change of programming language in my day job allowed me to shift the majority of my desktop apps away from proprietary providers (e.g. MSN -> Pidgin, Visual Studio -> Eclipse, MS Office -> LibreOffice, Photoshop -> Gimp). As most open source software runs on Windows, OSX and Linux this meant my software stack was effectively OS independent. Then I moved completely from Windows and embraced the Linux/Ubuntu party about 3 years ago – since then I’ve not looked back. However at home I’ve been using a MacBook Pro which was a nice bit of kit but left me with a slightly bitter taste in the mouth. The hardware of the MBP is top notch, but aside from the Terminal application I can’t say I had much love for OSX (I particularly dislike the global menu bar and the appalling Finder app) so when a recent opportunity came to move to a Linux laptop I took the plunge.

My new laptop is a Dell XPS 13-9333 (late 2013) Developer Edition which came pre-installed with Ubuntu 12.04 (which I immediately switched to Linux Mint 16, Cinnamon Edition). Having spent about a month with the new machine I though I’d run through some of the pros and cons.

The good:

  • Finally I have a proper task bar showing all my applications :). OSX’s Mission Control is not, in my opinion, a great feature but a sign something is seriously wrong with the way you need to switch applications.
  • The touch screen works out-the-box
  • Speed – boots in less then 10 secs which is almost as fast as Windows 8.1
  • Suspend works flawlessly (and I don’t appear to have the 8Gb memory files left on disk after OSX went  to sleep)
  • I’m liking Cinnamon’s window placement feature
  • TMUX+Fish make for a great Terminal replacement
  • Finally my apps have menu bars!
  • It feels right as a developer – for instance I can now play natively with awesome new tools such as Docker.
  • Steam gives me access to a bunch of really good games.

The bad:

  • The touchpad cursor jumps all over the place. If I’m careful with how I use the touchpad (i.e. with one finger only) I can mostly avoid this but my old MBP (or my wife’s new Windows 8.1/Dell) never had this problem.
  • I can’t get my bluetooth mouse to work consistently – after more work tweaking this got fixed!
  • ibus suggested character placement is lost off the bottom of the screen
  • Frequent ‘whine’ sound (although this is likely a hardware related issue)
  • Wireless offers poor performance compared to my 4 year old MPB
  • Visible tearing during video playback
  • Shortcut inconsistency is a nuisance (e.g. Ctrl+Q to close windows works some all the time)
  • Lack of touch support in Chome/apps – the extensions chrome currently provides don’t support Linux
  • The Kobo desktop app installs under Wine but doesn’t detect my ebook device (I can always use calibre)

The Ok:

  • Netflix can be persuaded to work
  • Nixnote works fine as an interface for Evernote but I miss the beautiful proprietary app.
  • I spent ages setting up printing to my wireless Canon printer due to only 32bit drivers being released. It now works but I haven’t summoned up the willpower to tackle scanning support yet.

Generally I’m happy with the new setup. It’s great having a single unifying OS at work and home, and one that offers me maximum productivity. It’s also handy knowing that I can completely reinstall my machine and then be up and running again with my desktop environment using a single command. It’s fast, smooth and looks great. However I have to report that I can’t, with any confidence, suggest that others do the same. Linux/Ubuntu on the desktop really is a simple ‘just works’ experience. On the laptop however it’s anything but (in spite of the fact that this laptop is Ubuntu certified). After many hours of tweaking and adjusting I’m just about there but for those less technically inclined (or just not willing to put the effort in)I’d suggest they think twice before choosing this route.