Python dependencies on project level

Python dependencies on project level

Since I started work with Python, I struggled with dependencies on a project level. I was aware of requirements.txt file, but handling it became very difficult for multiple projects. Fortunately I found very handy tool called pipreqs which generages a project level requirements.txt file using one command. Installation

Usage Just go into your project directory and run

and install inside target environment

Sometimes it does on work on 100 %, but it can save a lot of…

Read More Read More

ls -la output explanation

ls -la output explanation

Show files ls Will provide basic overview of files and folders present in the directory

Show files with details ls -l With file / folder details

Show hidden files ls -la Will show hidden files with . prefix

Output exmplanation

Bonus Running this command will add alias ll to run ls -la where this shortcut is not present yet.

Connecting the Raspberry Pi Zero W/WH to WiFi

Connecting the Raspberry Pi Zero W/WH to WiFi

Recently I bought a Raspberry Pi Zero WH, and I wanted to connect it to my WiFi, but first 5 guides from Google were not working well, so I wanted to share the approach I used using raspi-config. 0. Get ready Raspbian on the Pi And connect to it using ethernet or plug in the monitor to it via HDMI. 1. Get ready SSH You can do this using sudo raspi-config (5. Interfacing options/P2 SSH) or using

Default credentials…

Read More Read More

Kubernetes and Sealed Secrets (Kubernetes)

Kubernetes and Sealed Secrets (Kubernetes)

PROBLEM: I would like to share my secrets to git SOLUTION: Use the Sealed Secretes (Installing kubeseal) Kubeseal is the CLI tool to manage sealed secret, is you are using macOS, you should use brew:

On (ubuntu based) linux you should be fine using:

Creating a secret There are different ways how to create a secret, I am using direct input (–from-literal) or direct YAML efinition. I will show both. Let’s assume I am deploying some application which will…

Read More Read More

Display apps and occupied ports (Linux)

Display apps and occupied ports (Linux)

PROBLEM: My app is not starting, because port is already in use! SOLUTION: Find it and kill it 🙂 netstat -tulpn Will provide nice table with all info you migh like, truncated outpus below:

sudo ss -tulpn More fresh, more detailed (i like it more than netstat)

Now you can find what is “eating” your ports and you are able to debug errors 🙂 Note: If you cannot see the PID, use sudo to execute the command

Resize swap in Ubuntu 18.04 and later (Linux)

Resize swap in Ubuntu 18.04 and later (Linux)

PROBLEM: My swap is too small 🙁 SOLUTION: Disable, resize and enable swap again! 1. Disable swap

2. Resize swap With goal of 2 GB (1 GB * 2)

Where: if – input file of – output file bs – block size count – block multiplier Note: If you get error: dd: memory exhausted by input buffer of size 1073741824 bytes (1.0 GiB) just try to change the bs to MB and increase the count size

3. Make…

Read More Read More

Permanently exporting environment variables using direnv (Linux)

Permanently exporting environment variables using direnv (Linux)

PROBLEM: I use some variables (credentials) so often, but I don’t like exporting them each time SOLUTION: Start using direnv! Direnv should be already present in your system You can check the same on the direnv website (here), if is not, you can always build it from binary. Hook direnv into shell Add this line on the end of your .bashrc file (if you are using bash)

Create .envrc file And put all variables you would like to have accesible…

Read More Read More

Ports in Kubernetes Services (Kubernetes)

Ports in Kubernetes Services (Kubernetes)

Just a quick reminder how ports definition in k8s services works. Service definition example below, just forgot all but port definition and take a closer look. NodePort

We can see port definition 3 times (it’s array and you can use as many of them as open ports you need): port, targetPort and nodePort. Why 3 ports? If you are familiar with Docker (Swarm) you would expect only 2, right…? NodePort port : other pod/service inside our cluster can access…

Read More Read More

Port forward to access applications in cluster (Kubernetes)

Port forward to access applications in cluster (Kubernetes)

PROBLEM: Cannot access pods in my k8s deployment for testing SOLUTION: Use very simple port-forward method Find your destination Decide what do you want to access. Port forward works on services, pods, deployments or even replicaSets. The syntax is very simple.

Which leads to example like this:

You can see your app through port 1000 on your local machine (working on the port 3000 on remote). Bear in mind, you are connecting directly to the service/pod/whatever, so use the…

Read More Read More

Create permanent command alias (Linux)

Create permanent command alias (Linux)

PROBLEM: My set up aliases are not persistent after reboot SOLUTION: Write them to ~/.bashrc Edit ~/.bashrc Using sudo

Add as many aliases as you wish! Separe by new line. I prefer adding them on the beginning of the file so I can find them quickly.