Skip to content

Instantly share code, notes, and snippets.

View valosekj's full-sized avatar

Jan Valosek valosekj

View GitHub Profile
@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 / useful_shell_commands.md
Last active October 17, 2021 11:25
Useful shell commands #blog

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

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 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 / run_app_from_terminal.md
Last active May 11, 2023 15:15
Run arbitrary application from terminal on MacOS #blog

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 a directory where you have your code/scripts. For example ~/code or /usr/local/bin:

@valosekj
valosekj / run_matlab_from_python.md
Last active June 29, 2022 10:28
Run matlab function from python script #blog

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.: