LaTeX indicator function

I always struggle to write an indicator function in Latex. You know, the 1 with a double bar, for instance in 𝟙_A(x). For letters like N, a simple \mathbb{N} gives a nice ℕ, but \mathbb{1} gives a weird looking character that is definitely not a double-struck 1. The best way I found is to import the dsfont package and use \mathds{1}: \usepackage{dsfont} \mathds{1} It’s also possible to import the bbm package and use \mathbbm{1}, but I don’t recommend this option as it uses a bitmapped font for the 𝟙 character....

September 21, 2023

Locating a machine with unknown IP in a subnet

I have a remote machine in a network that I don’t manage, and one day the not-so-static IP changed. Without the new IP address I found myself unable to SSH back in. How do you find a computer in a subnet if you don’t know its address? I tried to ping around to look for the hostname of my machine, without much success. In the end, I could locate my lost IP with a simple nmap....

September 22, 2022

Disabling sensor information sharing with Home Assistant

When you set up Home Assistant on Android, you sometimes get a notification showing up in the background saying something like “Updating sensors…”. It might be useful to retrieve my phone battery or location to automate some routines, but I don’t need it and I find it intrusive. After Googling around unsuccessfully, I stumbled on the solution in the settings: Open the mobile Home Assistant application Open the left menu and pick “App configuration”....

July 22, 2022

Using Mosh with a Conda installation

Mosh — the mobile shell — is a great alternative to SSH when you have a flimsy connection or when you are moving around with your laptop. The default installation needs sudo rights on the server side, but you can install it without privileges in a Conda environment. First, install Mosh on your server (the machine you want to SSH into): conda install -c conda-forge mosh -y You should be able to start the server executable from your environment:...

May 31, 2022

Adding an SSH key to a Google Cloud instance

The easiest way is to add the keys when you create the machine. But if you forgot, it just takes 1 line. Before that, check if there are any keys associated with the machine: gcloud compute instances describe instance-1 If this is a new VM without keys, the metadata field should be empty. Then, add your keys: gcloud compute instances add-metadata instance-1 --metadata-from-file ssh-keys=./.ssh/id_ed25519.pub Now you can connect to the external IP of the machine:...

April 22, 2022

Changing Wi-Fi network priority in Ubuntu

Network connections come with priority scores that determine in which order to connect. Sometimes, the default order is not satisfying, e.g. if you want to prioritize your mobile hotspot or home network over some public connection. In Ubuntu (tested on 20.04 with Gnome 3.36), the default settings don’t allow you to change the order. Luckily, there is a GUI accessible without installing anything. Open a terminal and type: nm-connection-editor This launches a window containing the list of your networks....

March 23, 2022

List of ResNet modules

Sometimes you just need the list of the modules in your ResNet (number of blocks, parameters of the convolutions, number of trainable parameters, etc). I don’t need a Medium tutorial showing me how to build a ResNet and I don’t want to parse the PyTorch source code. So next time, instead of spinning a new terminal with print(torchvision.models.resnet18()), I can just check this plain old listing. Below is the architecture, i....

March 8, 2022

Opening a PyTorch profiler trace

PyTorch’s profiler can produce pt.trace.json traces. By default, you can visualize these traces in Tensorboard. However, Tensorboard doesn’t work if you just have a trace file without any other Tensorboard logs. This can happen if you use PyTorch Lightning’s wrapper, or if you stored the profiling trace somewhere else such as a remote machine. In this case, you can open the pt.trace.json file directly in Chromium or a Chrome-based browser. Just open chrome://tracing, and drag-and-drop the JSON file....

February 23, 2022

Gurobi academic license with Conda

Here is my cheat sheet to install Gurobi on a new Mac or Linux machine, using a free academic license: Install Gurobi, for instance with Conda: conda install -c gurobi gurobi -y Go to the Gurobi Academic License webpage. Log-in or sign-up – you can get multiple free academic licenses with a single account. Copy your key number and create your license with: grbgetkey aaaaaaa-7987-34aa-0974-23987498c07` Happy optimization!

February 1, 2022

Launch MLflow UI or Tensorboard on a remote server with port forwarding

MLflow tracking or Tensorboard are great to visualize the results of experiments running on a remote server. Actually they’re great to keep track of any sort of computation involving repeated runs with changing parameters, not just machine learning runs. To open the UI in the browser of a local machine, you can use SSH port forwarding. If you already have a VS Code window open, the embedded terminal automates port forwarding after you type the command....

February 1, 2022