All posts by kortsi

Enabling Quectel EM05-G Modem on Linux

5.00 avg. rating (94% score) - 2 votes

My new Thinkpad has a Quectel EM05-G modem. For some reason it refused connect, even though it showed up in Gnome settings on Ubuntu 22.10. I checked with “mmcli -m 0 and it said “sim missing” as its state.

After some Googling it appeared the modem ships in some kind of a locked state, so it only works in Windows. I checked with “mbimcli”:

It was easy to unlock:

After this, Gnome was able to enable the mobile broadband connection without problem.

 

Tunneling SSH over HTTPS with stunnel

0.00 avg. rating (0% score) - 0 votes

I was faced with a firewall denying access to the outside world using ssh. All I had was http/https access via a proxy server which required authentication. I had an Ubuntu jump host outside the network connected to the internet with a free 443 port. I tried accessing that with httptunnel and proxytunnel, but could get neither to work with this proxy server.

The solution that worked in this particular case was stunnel. It can wrap any TCP connection into an https session which was not rejected by the proxy server I was facing.

Continue reading Tunneling SSH over HTTPS with stunnel

Methods for Both Classes and Instances in Python

0.00 avg. rating (0% score) - 0 votes

I came across a situation where it would be nice for a Python class to have a method which works for both the class and its instances, and when called in an instance context, to know on which instance it was invoked. Python does not support this directly, but as it is a very flexible language, it can be done. To make it work somewhat nicely requires just a few lines of not so obvious code.

Continue reading Methods for Both Classes and Instances in Python

Enable vi editing mode in IPython 5

0.00 avg. rating (0% score) - 0 votes

Create default profile and set editing mode to ‘vi’:

 

Flask-SQLAlchemy and PostgreSQL Unit Testing with Transaction Savepoints

5.00 avg. rating (91% score) - 1 vote

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

Ubuntu 14.04 Active Directory Authentication

5.00 avg. rating (91% score) - 1 vote

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

OpenStreetMap Nominatim Server for Geocoding

5.00 avg. rating (98% score) - 9 votes

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