Skip to content

Instantly share code, notes, and snippets.

View data4sci's full-sized avatar

Robert Samarek data4sci

  • VSB - Technical University of Ostrava
  • Ostrava, Czech Republic
View GitHub Profile
@data4sci
data4sci / replace.sh
Created June 10, 2021 08:08
find and replace string in a text file
sed -i 's/original/new/g' file.txt
@data4sci
data4sci / module_install.py
Created June 10, 2021 08:07
install python module from Jupyter cell
import sys
!conda install --yes --prefix {sys.prefix} <moduleName>
@data4sci
data4sci / md.sh
Created June 10, 2021 08:03
view markdown file in terminal
pandoc README.md | lynx -stdin
@data4sci
data4sci / bootable_usb_flash.sh
Last active November 29, 2023 17:40
create bootable USB from #ISO
df -hT # vybrat zařízení
sudo dd if=/home/bob/Downloads/Linux_Mint_19_XFCE.iso of=/dev/sd<?> bs=1M status=progress
@data4sci
data4sci / postgres_commands.sh
Created June 10, 2021 08:01
postgreSQL basic commands #SQL #postgres
# su - postgres
$ psql
# \conninfo
# \list #seznam databází
# \c dtb_name #připojení k databázi
# \dt #seznam tabulek
# \d+ #seznam tabulek s velikostí
# select * from table_name;
#SQL dotaz (zakončený středníkem!)
@data4sci
data4sci / kill_by_name.sh
Created June 10, 2021 07:59
kill processes by name
pkill -f my_pattern
#nebo
ps -ef | grep 'my_pattern' | grep -v grep | awk '{print $2}' | xargs -r kill -9
@data4sci
data4sci / change_remote_git.sh
Last active June 7, 2021 16:48
změna vzdáleného git repozitáře
# rename origin
git remote rename origin old-origin
# add new origin
git remote add origin git@xxxxxxxxxxxx.git
# push
git push -u origin --all
git push -u origin --tags
####### nebo #######
git remote set-url origin git@xxxxxxxxxxxx.git #git://new.url.here
@data4sci
data4sci / keymap.sh
Created May 26, 2021 07:13
set custom keymap #bash
# set custom keymap
setxkbmap cz
@data4sci
data4sci / df_styling.py
Created May 25, 2021 11:04
#python #pandas styling, conditional formating
# https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html
# https://towardsdatascience.com/style-pandas-dataframe-like-a-master-6b02bf6468b0
# https://stackoverflow.com/questions/41203959/conditionally-format-python-pandas-cell
# https://stackoverflow.com/questions/38931566/pandas-style-background-gradient-both-rows-and-columns
# https://kanoki.org/2019/01/02/pandas-trick-for-the-day-color-code-columns-rows-cells-of-dataframe/
df.style.background_gradient(cmap='coolwarm')
@data4sci
data4sci / memory_usage.sh
Created May 25, 2021 11:03
total memory usage #bash
# jednotlivé procesy
smem -t -P chromium-browser
# celkový součet
smem -t -k -c pss -P chromium-browser | tail -n 1
# nebo
ps aux | grep "chromium-browser" | awk '{print $5}' | awk '{sum += $1 } END { print sum }'