Solved – error while loading shared libraries: Anydesk on Ubuntu 22.04 LTS

After successfully upgrading from Ubuntu 20.04 LTS to 22.04 LTS, most of the applications are working perfectly. But, some of the applications behave unusually. Such as, I tried to run the Anydesk application, but it doesn’t launch/start. when I checked the status service, the AnyDesk service was failed and the reason for failing is mentioned in the below error message,

anydesk: error while loading shared libraries: cannot open shared object file: No such file or directory is a library used for text layout and rendering the text. Most of the work on Pango-1.0 was done using the GTK+ widget toolkit as a test platform.

So, I ran the command to install it using the apt as follows,

apt install libpangox-1.0-0

But, it gives me the following error,

Package libpangox-1.0-0 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

So, from that we can understand that, can’t be installed from apt or apt-get. We need to install it manually.

Use the following steps to install manually,

Step 1. Download the libpangox-1.0 package


Step2: Install the package using apt

sudo apt install ./libpangox-1.0-0_0.0.2-5.1_amd64.deb

Step3: Restart the AnyDesk service

sudo service anydesk restart

After these steps, if you check the AnyDesk service status, it will show active (running).

What is Middleware and how to create one in Laravel?

It’s best to envision middleware as a series of “layers” for HTTP requests that must pass through before they hit your application. Each layer can examine the request and even reject it entirely.

Middleware provides a convenient mechanism for inspecting and filtering HTTP requests entering your application. It’s best to envision middleware as a series of “layers” for HTTP requests that must pass through before they hit your application. Each layer can examine the request and even reject it entirely.

For example, Laravel includes a middleware that verifies the authenticity of the user of your application. If the user is not authenticated, the middleware will redirect the user to your application’s login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.

To perform different tasks, we can develop many middlewares besides authentication. For example, a logging middleware might log all incoming requests to your application. 

Laravel framework has included many middlewares, including middleware for authentication and CSRF protection. All of these middlewares are located in the app/Http/Middleware directory.

To create a middleware, we can use the following command,

php artisan make:middleware <middleware-name>

For example, if we want to create a middleware for checking transactions, we can run the following command,

php artisan make:middleware CheckTransaction

 After successful execution of the command, a middleware class will be created under the app/Http/Middleware directory.

In this class, we can define methods to check transactions. If the transaction is not completed, we can redirect the user back to the failed transaction page. However, on the successful transactions, we can allow users to proceed to the next page.

namespace App\Http\Middleware;
use Closure;
class CheckTransaction
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        if ($request->input('status') !== 'completed') {
            return redirect('transaction-failed');
        return $next($request);

As you can see, if the transaction status does not set to “completed”, the middleware will return an HTTP redirect to the client; otherwise, the request will be passed further into the application.

To pass the request deeper into the application (allowing the middleware to “pass”), you should call the $next callback with the $request.

What are accessors and mutators?

Accessors and mutators are public member functions in a class that exists solely to set or get the value of a class member variable. They are often referred to as getter and setter or set and get functions. I will use the term setter for mutators and getter for accessors for this article.

Many programmers think why we should create getter and setter functions when we can declare public member variables and access them easily using the object of the class. But, there are many benefits from a software engineering point of view to create classes with only private member variables and use getters and setters to manipulate their values.

One of the primary benefits of object oriented design is combining the data and the methods that operate on them into a single component. This is referred to as encapsulation. It allows you to hide the actual implementation of the class from the users of the object. It allows the programmer to make changes in the hidden part of the class design without affecting the users of the objects derived from the class. So if you created some complex class and sold it to a bunch of other developers, you could make changes to your class to improve performance of the hidden part, and they would not have to rewrite their code to use newer versions.

Another crucial benefit of setter functions is that, you can validate the data before set the value. For example, we have created one class for accounting and let’s assume the maximum value for any transaction is 10000. With a public variable, there is no way to stop someone from setting this value to 20000.

Naming conventions

Typically, programmers name getter functions as “get” followed by the name of the variable being accessed and setter functions as “set” followed by the variable name.

Getters and setters in use

The example below adds getters and setters to our Accounting class.

class Accounting
  int transactionLimit;

  // setters
  bool setTransactionLimit(int);

  // getters
  int getTransactionLimit();

// Setter function perform input validation
bool Accounting::setTransactionLimit(int l) {
  if (l < 0 || l > 10000)
    return false;
  else {
    transactionLimit = l;
    return true;

// Simple getter functions. This hide the 
// actual method of storage from object user.  
int Accounting::getTransactionLimit() {
  return transactionLimit;

In above class, the setter functions also validate the input and return true if the value is acceptable or false if not. In that way, the programmer using the class can know if the provided value is valid and write the code to respond in an appropriate manner.

Geocoding with Python – Convert any address to a geographic location

Learn how to work with geocoding APIs to receive location data from addresses and plot maps of your customer’s location.

Most of the time, datasets are incomplete and often require pre-processing to make them usable. Imagine, We have some datasets with only an address column without latitude and longitude columns, and we want to represent this data geographically. To do that, we need to add geographic information to these data. These cannot be possible manually. We have to create a script to convert all those addresses to geographic information – Latitude and Longitude – to map their locations, which is known as Geocoding.

Geocoding is the computational process of transforming a physical address description to a location on the Earth’s surface (spatial representation in numerical coordinates)


In this article, I will show you how to perform geocoding in Python with the help of Geopy library. Geopy has different Geocoding services that you can choose from, including Google Maps, ArcGIS, AzureMaps, Bing, etc. Some of them require API keys, while others can be accessed freely.

To perform geocoding, we need to install the following Geopy library using pip,

pip install geopy

Geocoding Single Address

In this example, we use Nominatim Geocoding service, which is built on top of OpenStreetMap data.

Let us Geocode a single address, the Taj Mahal in Agra, India.

locator = Nominatim(user_agent="myGeocoder")
location = locator.geocode("Taj Mahal, Agra, India")

First line of the above code will create locator that holds the Geocoding service, Nominatim. In second line, we call geocode method of the locator service and pass any address to it, in this example, the Taj Mahal address.

print("Latitude = {}, Longitude = {}".format(location.latitude, location.longitude))

Above line will print out the coordinates of the location we have created.

Latitude = 48.85614465, Longitude = 2.29782039332223

That’s it.

So, the complete code will look like this,

import geopy
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter

locator = Nominatim(user_agent="myGeocoder")
geocode = RateLimiter(locator.geocode, min_delay_seconds=1)

address = "Taj Mahal, Agra, India"
location = locator.geocode(address)

print("Latitude = {}, Longitude = {}".format(location.latitude, location.longitude))

Now, try some different addresses of your own.

Finding bugs using PHPStan as a Static Analyzer

With PHP being an interpreted language it has a downside when it comes to finding bugs in your code. It will not show you errors in your software until you actually run it. PHPStan tries to solve this problem by doing static analysis on your code. It was recently created by Ondrej Mirtes.

Running PHPStan will tell you about bugs in your codebase almost instantly (yes, it’s very fast). At the time of writing this article, PHPStan currently checks your code on:

  • The existence of classes and interfaces in an instance of, catch type hints, other language constructs, and even annotations. PHP does not do this and just stays silent instead.
  • Existence of variables while respecting scopes of branches and loops.
  • Existence and visibility of called methods and functions.
  • Existence and visibility of accessed properties and constants.
  • Correct types assigned to properties.
  • The correct number and types of parameters are passed to constructors, methods, and functions.
  • Correct types returned from methods and functions.
  • The correct number of parameters passed to sprintf/printf calls is based on format strings.
  • Useless casts like (string) ‘foo’.
  • Unused constructor parameters – they can either be deleted or the author forgot to use them in the class code.
  • That only objects are passed to the clone keyword.

As you can see, it contains a lot of useful checks which will warn you of potential bugs before you even run your code.

Installing PHPStan

Installing PHPStan is as easy as including it in your project through composer:

$ composer require --dev phpstan/phpstan

We can now run PHPStan from the base directory of our project:

$ vendor/bin/phpstan analyze -l 4 src

A breakdown of this command:

  • vendor/bin/phpstan is the executable
  • analyze tells PHPStan to analyze all files in the given directories
  • -l 4 means that we want to analyse on the most strict level
  • src is the directory we want to analyse

Try running this in your own project and see what kind of potential errors are living in your codebase.

Integrating PHPStan into CI

It’s super easy to use PHPStan in Continuous Integration. For most of my personal projects, I use TravisCI. Since we’ve included PHPStan as a dev-dependency in our composer.json file we just have to add the PHPStan executable to the scripts that the CI-software needs to run.

For TravisCI, this means just changing the default script in a .travis.yml like this:

language: php
  - '8.0'
install: composer install

# Simply add these lines
    - vendor/bin/phpunit
    - vendor/bin/phpstan analyse src tests --level=4

The default script that TravisCI runs for PHP projects is simply phpunit. Now we’ve added PHPStan to it. If PHPStan finds any errors within your project, the build will fail.