Skip to content

Instantly share code, notes, and snippets.

View valosekj's full-sized avatar

Jan Valosek valosekj

View GitHub Profile
@valosekj
valosekj / $README.md
Last active August 11, 2023 11:45
Fix ${HOME} variable

My zsh configuration and tips

This gist contains some essential commands and configurations which I have included in my config files on my MacOS and Linux machines.

NOTE: on Linux, it may be necessary to install zsh (e.g., sudo apt install zsh zplug)

NOTE on MacOS:

  • it is necessary to install nano from homebrew (using brew install nano)
@valosekj
valosekj / custom_FSLeyes_scene.png
Last active September 18, 2023 20:34
Set up a custom scene using the FSLeyes API via a custom Python script
custom_FSLeyes_scene.png
@valosekj
valosekj / load_python_colormap_to_fsleyes.md
Created October 23, 2023 23:24
Load a Python colormap to FSLeyes

Load a Python colormap to FSLeyes

Get RGB colors, one per line, for a given Python colormap. In the script below, we get RGB colors for the jet matplotlib colormap.

import matplotlib.pyplot as plt
import numpy as np

# Generate the jet colormap
cmap = plt.cm.get_cmap('jet')
@valosekj
valosekj / matplotlib_tips.md
Last active October 31, 2023 16:26
Tips and hacks for plotting in python

Tips and hacks for plotting in python

This gist containts several useful tips, tricks and hacks for plotting of figures, plots and charts using python (matplotlib and seaborn packages).

Fix warning about matplotlib backend in PyCharm

import matplotlib
matplotlib.use('TkAgg')
@valosekj
valosekj / basic_shell_commands.md
Last active November 2, 2023 14:32
Basic shell commands

Basic shell commands

A few basic shell (bash, zsh, ...) commands for UNIX (Linux, MacOS) CLI (command-line interface)

1. File and directory manipulation commands

cd - change directory:

# change directory to /home/username/Downloads:
@valosekj
valosekj / virtual_enviroments.md
Last active November 11, 2023 19:24
How to create and use virtual environments (venv and conda)

How to create and use virtual environments (venv and conda)

venv and conda are environment manager tools allowing to create virtual environments. Virtual environment separates the dependencies (Python packages) for different projects. This mean that each project can have its own dependencies. Usage of virtual environments allows you to avoid installing Python packages globally (to the system Python) which could break system tools or other projects.

venv environment

  1. Create venv

MacOS or Linux (without or with site-packages)

@valosekj
valosekj / string_manipulation.md
Last active May 2, 2024 06:50
Useful string manipulation examples for bash and zsh #blog

Useful string manipulation examples for bash and zsh

I need very often to modify filenames or replace/delete their parts across huge number of files. I was using sed command for these purposes but recently I have found out that all these tasks can be easily done directly in bash (or zsh) because both of them support so called string manipulation operations.

String manipulations

Define some example string:

$ file=some_file_name.txt