Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Valošek valosekj

  • Palacký University Olomouc and University Hospital Olomouc
  • Olomouc, Czech Republic
View GitHub Profile
@valosekj
valosekj / git_collaboration.md
Last active Aug 18, 2021
Simple workflow of collaboration in small team using git and GitHub
View git_collaboration.md

Simple workflow of collaboration in small team using git and GitHub

This gist describes example of simple workflow on repository whose changes are tracked by git and GitHub

1) Clone (download repository from GitHub to your computer)

# Go to directory where repository will be cloned (downloaded)
cd ~/Documents
# Clone repository from GitHub
@valosekj
valosekj / virtual_enviroments.md
Last active May 17, 2022
How to create and use virtual environments (venv and conda)
View virtual_enviroments.md

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 / run_python_from_shell.md
Last active Nov 28, 2021
Run python script from shell #blog
View run_python_from_shell.md

Run python script from shell (bash, zsh)

Sometimes, I need to call/run python script with arguments from shell. I use bash or zsh as my shell and following workaround works great for me.

Using shell wrapper

  1. Some example python script which I need to run from bash:

my_python_script.py:

@valosekj
valosekj / basic_shell_commands.md
Last active Jun 23, 2021
Basic shell commands
View basic_shell_commands.md

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 / useful_shell_commands.md
Last active Oct 17, 2021
Useful shell commands #blog
View useful_shell_commands.md

Useful shell commands

This gist contains several useful shell commands which I use frequently during my work.

$0 - Get current shell

$ echo $0
zsh
@valosekj
valosekj / string_manipulation.md
Last active Oct 20, 2021
Useful string manipulation examples for bash and zsh #blog
View string_manipulation.md

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
@valosekj
valosekj / convert_heif_to_jpg.md
Last active Jan 17, 2021
Convert photos from HEIF to JPEG #blog
View convert_heif_to_jpg.md

Convert photos from HEIF to JPEG

I use on my iPhone HEIF (High Efficiency Image File Format) format for storing my photos.

This format is widely supported throughout Apple ecosystem but sometimes I need to quickly convert photos from HEIF to JPG to be able to use these photos also elsewhere (Windows, some websites, etc.)

I use for this purpose convert command line tool from ImageMagick

Usage:

@valosekj
valosekj / $README.md
Last active Feb 3, 2022
My zshrc file configuration
View $README.md

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 / run_app_from_terminal.md
Last active Nov 10, 2020
Run arbitrary application from terminal on MacOS #blog
View run_app_from_terminal.md

Run arbitrary application from terminal on MacOS

Sometimes, it is convenient to have possibility to start/run any application (like your internet browser or text editor) directly from your terminal. Most of these applications however do not create shortcut for easy run from terminal during their installation. Below is short manual how to create this shortcut manually.

Steps

  1. Open terminal (cmd + space --> type terminal)

  2. Navigate to /usr/local/bin:

@valosekj
valosekj / run_matlab_from_python.md
Last active Jun 29, 2022
Run matlab function from python script #blog
View run_matlab_from_python.md

Run matlab function from python script

I needed to run matlab script from python script. I wanted to pass several input arguments from pandas DataFrame, perform calculation in matlab and return multiple output arguments back to python.

Steps (MacOS):

  1. Install matlab engine API for python:

In your terminal, go to directory where matlab is install and run installation python script, e.g.: