A visual guide to SSH tunnels

February 11, 2021 Leave a comment

SSH tunnels are encrypted TCP connections between SSH clients and servers that allows traffic entering one side of the tunnel to transparently exit through the other. While the term originally referred to tunnels using TUN/TAP virtual network interfaces, it’s commonly used to refer to SSH port forwarding nowadays. Use cases include:

– Providing encrypted channels for protocols that use plaintext
– Opening backdoors into private networks
– Bypassing firewalls


Categories: Interesting Tags: ,

How Python Decorators Work: 7 Things You Must Know

February 9, 2021 Leave a comment

Decorators are something you will encounter in your development journey. Let’s find out how Python decorators work and how you can use them.

What is a Python decorator?

A Python decorator is a feature (or design pattern) that allows to enhance the logic of functions, methods or classes without changing the original code. To represent a decorator in Python you can use the @ symbol followed by the name of the decorator.

In this tutorial we will go through 7 things you must know about Python decorators.


Categories: Interesting Tags:

Linting & Fixing React with Vim, ALE, XO, and Prettier

February 8, 2021 Leave a comment

Ah… yes… that thing you need to add to a project, that you just don’t want to add. But, there is this little voice in your head telling you to do this because… Just because.
It’s like testing. I’ve always slacked to add either tests or linting because they felt like a lot of useless work.

Things changed when, a while ago I was coding in python. There are plugins like black and iSort that do lots of useful code cleaning routines. For example, isort sorts imports in a smart way. Black formats the code for me so that I no longer worry if this python line has wrong indentation.


Categories: Interesting Tags: , , , , ,

Ubuntu Snap Packages: Complete guide to snap package management tool

February 4, 2021 Leave a comment

Traditionally, we have different Linux distributions using different package format and it has been a problem for both developers and users. Debian based distributions use deb packages, redhat based distributions use rpm packages while there are many other Linux variants using their own package format.

Snappy is a universal package format introduced by canonical, the same company behind the Ubuntu operating system. The goal of the snap is to provide a universal package format that works across all Linux distributions.

In this tutorial we will learn how to use snap package manager in Ubuntu to install, configure, update and remove software and applications.


Categories: Interesting Tags: ,

Android Studio – Setup on vagrant

February 3, 2021 Leave a comment

Run Android Studio on a vagrant box.

1. vagrant init hashicorp/bionic64
2. Edit Vagrantfile
Add the following two lines

config.ssh.forward_agent = true
config.ssh.forward_x11 = true

Depending on your needs, you may also want to control the amount of memory that the vm uses.

config.vm.provider "virtualbox" do |vb|
    vb.memory = "4024"

3. vagrant up
4. vagrant ssh
We now need to configure the vm to allow for X11 forwarding.

Install xauth and x11-apps

$ sudo apt-get update
$ sudo apt-get install xauth, x11-apps
$ exit

5. log out and log back in again.

# Test that forwarding x11 works
$ xeyes
This should run without any issue
# If you get the following it is not working
$ xeyes
Error: Can't open display: 

6. Follow the install instructions for linux given -> https://developer.android.com/studio/install
You need to accept the Terms and Conditions in order to get the download link.

$ wget https://redirector.gvt1.com/edgedl/android/studio/ide-zips/
$ sudo cp android-studio-ide-201.7042882-linux.tar.gz /usr/local/
$ cd /usr/local/
:/usr/local$ sudo tar xvfz android-studio-ide-201.7042882-linux.tar.gz

# Install the required libraries first
:/usr/local$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

# Start up Android Studio
:/usr/local$ cd android-studio/bin
:/usr/local/android-studio/bin$ ./studio.sh

You may get the following error.

Caused by: java.util.concurrent.CompletionException: java.lang.UnsatisfiedLinkError: /usr/local/android-studio/jre/jre/lib/amd64/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory

:/usr/local/android-studio/bin$ sudo apt-cache search libXtst
libxext-dev - X11 miscellaneous extensions library (development headers)
libxext-doc - X11 miscellaneous extensions library (documentation)
libxext6 - X11 miscellaneous extension library
libxext6-dbg - X11 miscellaneous extensions library (debug package)
libxtst-dev - X11 Record extension library (development headers)
libxtst-doc - X11 Record extension library (documentation)
libxtst6 - X11 Testing -- Record extension library

:/usr/local/android-studio/bin$ sudo apt-get install libxtst6
:/usr/local/android-studio/bin$ ./studio.sh

You may get the following error

Caused by: java.util.concurrent.CompletionException: java.lang.UnsatisfiedLinkError: /usr/local/android-studio/jre/jre/lib/amd64/libawt_xawt.so: libXi.so.6: cannot open shared object file: No such file or directory

:/usr/local/android-studio/bin$ sudo apt-cache search libXi
libxi-dev - X11 Input extension library (development headers)
libxi6 - X11 Input extension library
libxinerama-dev - X11 Xinerama extension library (development headers)
libxinerama1 - X11 Xinerama extension library
libxinerama1-dbg - X11 Xinerama extension library (debug package)
libxine2 - xine media player library – metapackage
:/usr/local/android-studio/bin$ sudo apt-get install libxi6
# Finally
:/usr/local/android-studio/bin$ ./studio.sh

Now just follow the prompts and install.

Categories: Interesting, vagrant Tags:

sqlalchemy.exc.NoSuchModuleError: Can’t load plugin: sqlalchemy.dialects:driver

February 2, 2021 Leave a comment

I was getting the following error on running alembic upgrade head

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:driver

I had not specified to alembic which sqlalchemy driver to use. I added lines 27-28 to my env.py

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
db_url = os.environ.get("DATABASE_URL")
config.set_main_option("sqlalchemy.url", db_url)

Alternatively, I could have edited the alembic.ini file and changed the SQLAlchemy URL as per the tutorial.

$ less alembic.ini
sqlalchemy.url = postgresql://scott:tiger@localhost/test


Categories: postgresql, python Tags:

What are Group IDs and User IDs in linux

January 25, 2021 Leave a comment

A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to determine which system resources the user can access.

UID 0 (zero) is reserved for the root.
UIDs 1–99 are reserved for other predefined accounts.
UID 100–999 are reserved by system for administrative and system accounts/groups.
UID 1000–10000 are occupied by applications account.
UID 10000+ are used for user accounts.

Groups in Linux are defined by GIDs (group IDs).

GID 0 (zero) is reserved for the root group.
GID 1–99 are reserved for the system and application use.
GID 100+ allocated for the user’s group.

When you log into a linux system, you are represented as a number.
Numbers are used to represent users and groups in Linux kernel because:
1) It simplifies user and group management
2) Security management easy
3) Your UID is applied to all the files that you create


Categories: Interesting

An Introduction to Python Packaging

January 25, 2021 Leave a comment
Categories: Interesting, python

Golang Tutorial 3 – Golang pointers explained, once and for all

January 22, 2021 Leave a comment

Categories: golang Tags: ,

Dockerise a Python App with PostgreSQL

January 18, 2021 Leave a comment
Categories: Interesting, postgresql Tags: