Handbook
📔

Handbook

Tags
Software Development
Productivity
Published
September 17, 2023
Last Updated
Last updated March 5, 2024
Author
Description
A collection of commands across multiple tools, services, and technologies.

Git

Remove files already added to git after you update .gitignore

git rm -r --cached . git add . git commit -m "remove useless files"

Push empty commit

git commit --allow-empty -m "empty commit" git push

Set new remote origin

git remote set-url origin new.git.url/here

Linux

List crontab for specific user

# run crontab command for specific user crontab -l -u <user> # find crontab from spool cat /var/spool/cron/crontabs/<user>

Find out size of directories in the /home directory

sudo du -sh /home/* | sort -h
  • s: Display only a total for each argument.
  • h: Print sizes in human-readable format (e.g., 1K, 234M, 2G).

Jupyter Notebook

Using kernelspec

jupyter kernelspec list jupyter kernelspec install jupyter kernelspec uninstall

In notebook commands

%pwd # print working directory %cd # change directory
 

Python

Using secrets module

  • To generate a random password you should use the secrets module
 

PostgreSQL

Backup & Restore Dockerized Postgres

Backup your databases

docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql

Restore your databases

cat your_dump.sql | docker exec -i your-db-container psql -U postgres

Show triggers

select event_object_schema as table_schema, event_object_table as table_name, trigger_schema, trigger_name, string_agg(event_manipulation, ',') as event, action_timing as activation, action_condition as condition, action_statement as definition from information_schema.triggers group by 1,2,3,4,6,7,8 order by table_schema, table_name;
Columns
  • table_schema - name of the table schema
  • table_name - name of the trigger table
  • trigger_schema - name of the trigger schema
  • trigger_name - name of the trigger
  • event - specific SQL operation: InsertUpdate or Delete
  • activation - trigger activation time: AfterInstead of or BEFORE
  • condition - trigger activation condition
  • definition - definition of trigger - in postgreSQL it is always EXECUTE PROCEDURE function_name()
Rows
  • One row represents one trigger
  • Scope of rows: all triggers in a database
  • Ordered by schema name, table name

Strapi

Running a project from your host machine

You can also use strapi/strapi to run a project you already have created (or cloned for a repo) on your computer.
First make sure to delete the node_modules folder if you have already installed your dependencies on your host machine. Then run:
cd my-project docker run -it -p 1337:1337 -v `pwd`:/srv/app strapi/strapi