When you are prototyping and developing small scripts that you keep running, it might be annoying that they quit when an error occurs. If you want very basic robustness against these crashes, you can at least use a bash script to automatically restart your script on error. The tool to use here is called until and makes this a breeze. Let’s use a dumb example Python script called test.py: import time while True: print(‘Looping’) time.
Unit testing your models in Django As a good developer, you write unit tests, of course. You will probably even write your tests before implementing your logic in a test-driven approach! However, when developing complex models which have interactions and foreign keys, writing tests can get messy and complicated. Say you want to test a model which has many dependencies to other models via foreign keys. To create an instance of your model, you first need to create all the other model instances which your model uses and that can be pretty tiring.
As a developer you gotta love Vim! It is easily available on almost any server you login to. Most of the times, it will already be installed. You can customize it to your needs, but you should be comfortable with its basic functionalities as you don’t want to tweak it on every server. I thus like to customize it a little bit, but try to stick close to the default.
So, we all regularly create backups of important data, right? Right. Well, at least I hope you do. For your personal data as well as any company data you are dealing with. It is fairly easy and straightforward to create e.g. a MySQL backup on a server, zip it up and always keep the last 10 days as copies. However, what happens in case your whole server’s disks have an unrecoverable crash?
Follow me on twitter! Follow @mpaepper