Create default profile and set editing mode to ‘vi’:
ipython profile create
echo "c.TerminalInteractiveShell.editing_mode = 'vi'" \
To keep an ssh connection with a tunnel for port forwarding up reliably we can use the autossh command by Carson Harding. If the connection drops, autossh will restart it. Here’s a quick recipe to forward local port 33306 to a remote MySQL host listening on port 3306: Continue reading Keeping SSH Tunnels Up With Autossh
PostgreSQL provides us two very powerful features which are helpful with unit testing: transactional DDL and transaction savepoints. In this article I will show you how to use those with Flask-SQLAlchemy unit tests.
Transactional DDL means you can create tables inside a transaction, run tests against them, and roll back your changes after you are done. The database will be left in the same state as it was when you started. If you started with an empty database, nothing will be left in the database afterwards.
Savepoints allow you to roll back a part of a transaction without affecting what has happened before that savepoint was created. You can run a single test inside a savepoint and roll back just the changes that single test made without affecting the changes your set-up code has done before the savepoint.
That means you can create a large number of tables and other database objects in the beginning of your test suite and then run individual tests inside nested transaction using savepoints. There is no need to drop and re-create the whole database schema for each test. Continue reading Flask-SQLAlchemy and PostgreSQL Unit Testing with Transaction Savepoints
In a post a couple of years ago I gave an example on how to configure an Ubuntu 12.04 server to authenticate to Active Directory. Things used to be hard back then. Now we have the realmd realm enrollment manager to do the hard work of joining the host to an Active Directory domain, and the System Security Services Daemon or SSSD to do the actual authentication and authorization work whenever it is needed. And things are much easier to configure and get running. Continue reading Ubuntu 14.04 Active Directory Authentication
An interesting approach to autocommit/explicit commit with SQLAlchemy/PostgreSQL
Here’s how to create a site-to-site VPN between StrongSwan and SonicWall. This has been tested with Ubuntu 14.04 and StrongSwan 5.1.2, and SonicWall with SonicOS 5.9 at the other end. Continue reading VPN between StrongSwan and SonicWall
Here’s how to install the OpenStreetMap Nominatim service on your own server. It can be used to geocode and reverse geocode addresses and map coordinates. You will also get a web interface which loads map tiles from openstreetmap.org while doing geocoding requests using your own server. Continue reading OpenStreetMap Nominatim Server for Geocoding
Here’s an example of how to remove every *.pyc file from every commit in Git history. It is adapted from this Git help page.
git filter-branch, forcing (
--force) Git to process—but not check out (
--index-filter)—the entire history of every branch and tag (
--tag-name-filter cat -- --all), removing the specified files (
'git rm --cached --ignore-unmatch *.pyc') and any empty commits generated as a result (
--prune-empty). Continue reading Remove Unwanted Files From Git History