Brandon Severin

Founder of Conductor Quantum

Code Snippets

Python

Anaconda

Create an environment spec file (operating system specific)

conda list --explicit > spec_file.txt

cloning an environment

conda create --name myclone --clone myenv

removing an environment

conda remove --name myenv --all

General

Compatible type hints across various versions

Place the following at the top of the module

from __future__ import annotations

Greek letters

Python has support for unicode fonts

>>> print('Omega: \u03A9')
Omega: Ω
>>> print('Delta: \u0394')
Delta: Δ
>>> print('sigma: \u03C3')
sigma: σ
>>> print('mu: \u03BC')
mu: μ
>>> print('epsilon: \u03B5')
epsilon: ε
>>> print('degree: \u00B0')
degree: °
>>> print('6i\u0302 + 4j\u0302-2k\u0302')
6î + 4ĵ-2k̂

Automatically reload modules in jupyter notebook

# reload modules if there is a change
%load_ext autoreload
%autoreload 2

Place in top cell where modules are imported - useful for rapid testing and development of a python package

plot legend position

import matplotlib.pyplot as plt

plt.legend(loc='upper right')

Git

Commit messages

The commit type can include the following:

  • feat – a new feature is introduced with the changes
  • fix – a bug fix has occurred
  • chore – changes that do not relate to a fix or feature and don't modify src or test files
  • refactor – refactored code that neither fixes a bug nor adds a feature
  • docs – updates to documentation
  • style – changes that do not affect the meaning of the code
  • test – including new or correcting previous tests
  • perf – performance improvements
  • ci – continuous integration related
  • build – changes that affect the build system or external dependencies
  • revert – reverts a previous commit

Example:

feat: improve performance with lazy load implementation for images

Libre Office - Impress

Create an image with rounded corners

  • Overlay a rectangle with rounded corners over the image.
  • select the image and the rectangle
  • right-click -> shapes -> Intersect

LaTex

Installation on local machine: https://www.tug.org/texlive/

Inkscape

Crop an image in inkscape

  1. Open Your Image in Inkscape.
  2. Select a Vector Shape.
  3. Add the Shape to the Canvas.
  4. Reduce the Shape Opacity to Position the Crop.
  5. Select the Shape and the Image Together.
  6. Go to Object > Clip > Set Clip.
  7. Check the Crop.
  8. Release the Clip (if Needed)