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 changesfix– a bug fix has occurredchore– changes that do not relate to a fix or feature and don't modify src or test filesrefactor– refactored code that neither fixes a bug nor adds a featuredocs– updates to documentationstyle– changes that do not affect the meaning of the codetest– including new or correcting previous testsperf– performance improvementsci– continuous integration relatedbuild– changes that affect the build system or external dependenciesrevert– 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
- Open Your Image in Inkscape.
- Select a Vector Shape.
- Add the Shape to the Canvas.
- Reduce the Shape Opacity to Position the Crop.
- Select the Shape and the Image Together.
- Go to Object > Clip > Set Clip.
- Check the Crop.
- Release the Clip (if Needed)