Linux

Linux in general

chmod -R 755 $folder_name
find . -name "$file_name"
head -y $file_name | tail -n $((y-x+1))
cat $file_name.csv | cut -d ',' -f x,y
rename "s/${old_part}/${new_part}/" $file_name
du -sh * | sort -h
make SHELL=/bin/bash install

MacOS Terminal (uname = Darwin)

xcode-select --install
otool -L $dylib_file
sudo install_name_tool $dylib_file -change $old_link $new_link
git checkout -b $branch_name develop
git switch $branch_name
git reset --soft HEAD~1 # keeping work done
git reset --hard HEAD~1 # reverting changes
git reset
git checkout -- .
git rm -r --cached $folder
git commit -m "Stop tracking $folder"
git tag -a $version -m "message"
git push origin $version
git branch -d $branch_name
git push origin --delete $branch_name
git checkout develop
git pull upstream develop
git push origin -f develop
git checkout $branch_name
git rebase develop
git remote rename origin upstream
git remote add origin $fork_address
git branch -u origin/master
(unstaged) git diff $file_name
(staged) git diff --cached $file_named
git annex info --fast data/* --json | jq -j '."local annex size", "\t", .directory, "\t", "\n"'

Annex file/directory that are already commited to git

git rm --cached --ignore-unmatch -r $file_or_directory
git -c annex.verify=false annex add $file_or_directory
git config --list --show-origin

Bash

string=Sub0843_Ses1
string_cut_end=${string%_Ses1}
string_cut_front=${string_cut_end#Sub}
arr=($(cat $file_name.csv | cut -d ',' -f $column))
arr1=${arr[1]%$'\r'}
string="    Sub0843_Ses1"
string_cut=${string##*[[:blank:]]}
echo x y 365 | awk '{printf "%4.3f", $1+$2/$3}'
1) $command 2> /dev/null
2) $command 1> /dev/null 2>&1
1) exec 2> /dev/null
2) exec 1> /dev/null 2>&1
Host $new_host_name
	Hostname $host_address
	User $user_name
(local to server) rsync -avh --progress $file_path user@host:$destination
(server to local) rsync -avh --progress user@host:$file_path $destination

Python

python3 -m pip list
python3 -m pip install --upgrade pip --user
python3 -m pip install numpy
import sys
sys.executable
(new installation) python3 -m pip install -Iv package_name==version
(existing installation) python3 -m pip install -I package_name==version
python3 -m venv $directory
source $directory/bin/activate
import time
time.strftime("%H:%M:%S", time.gmtime(elapsed_time))
myfunc = lambda x: func(10, x)
(from another module) output = getattr(module_name, 'func_name')(parameters)
(from the same module) output = globals()['func_name'](parameters)
from importlib import reload
reload(module_name)
python -u $file_name.py > $log_name.txt
mkdir $HOME/python && cd $HOME/python
wget https://www.python.org/ftp/python/$version/Python-$version.tgz
tar -xvf Python-$version.tgz && cd Python-$version
./configure --prefix $HOME/python
make && make install
echo "export PATH=$HOME/python/Python-$version/:$PATH" >> $HOME/.zshrc

Matlab

dlmwrite('file_name.csv', variable_name, 'precision', 6);

Vi(m)

:noh

Jekyll

bundle install --path vendor/bundle
bundle exec jekyll serve
(in the browser) http://localhost:4000