megacolorboy

Abdush Shakoor's Weblog

Writings, experiments & ideas.

Fix screen tearing in XFCE desktop environment

Yesterday, I decided to try XFCE desktop environment and boy, it's really faster than the GNOME desktop environment.

As soon as I started to play around with it, I noticed a good amount of screen tearing and to my surprise, I came to know that the XFCE environment is known to have such issues.

After a few minutes of research, I was able to fix it. Here are the steps:

Note: This is done on Ubuntu 18.04 Bionic Beaver

If you dont have the package inxi installed in your system, do it right now:

sudo apt install inxi

After you're done installing, type the following command to find out which graphics you're using:

inxi -G

If you're using an Intel Graphics Driver, you'll probably get something like this:

Graphics:  Card: Intel Device 5926
           Display Server: x11 (X.Org 1.19.6 ) driver: i915 Resolution: 1920x1080@60.00hz
           OpenGL: renderer: Mesa DRI Intel Iris Plus Graphics 640 (Kaby Lake GT3e) (KBL GT3)
           version: 4.6 Mesa 20.0.8

You can try go to Settings Manager->Window Manager Tweaks->Compositor" and enable **Synchronize drawing to the vertical blank. From what I've read, if you do that, it should stop but it didn't do anything for me.

If the above technique didn't work, go to /usr/shar/X11/xorg.conf.d/ and create a file for your graphics card named 10-intel.conf.

Copy-paste the following configuration into the file:

Section "Device"
  Identifier  "Intel Graphics"
  Driver      "intel"
  Option "TearFree" "true"
EndSection

Save the file, reboot your system and look for any screen tearing issues. If you didn't face any, that means it worked! 😁

How to move a running process to the background?

Pause the current process using Ctrl + Z, which will send it to the background and then type bg to allow the process to run in the background.

Alternatively, you can add a & after the desired process you wanted to execute and it'll automatically execute it as a background process.

Hope this helps you out!

Clear a file directory using Filesystem in Laravel

I was working on a project that dealt with generating large .zip exports and as a result, the storage/exports directory, which was used to store all the .zip exports, ended up going all the way up to a whopping size of 10 gigabytes! 😮

I resolved it by calling the Filesystem package in my controller:

<?php
use Illuminate\Filesystem\Filesystem;
?>

Then simply, create a new instance and define the directory you wanted to clear:

<?php
$folder = new Filesystem;
$folder->cleanDirectory('storage/exports');
?>

Hope this helps you out!

Get pagination data by page number

By default, Laravel's paginator checks the value of the page based on the query string and uses that to display the results and also, it generates links to previous and next pages as well.

The paginate() method takes the following parameters by default:

<?php
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null);
?>

So, if you want to fetch the pagination data of a specific page, then just write this:

<?php
$pageNumber = 5;
$data = ExampleModel::paginate(5, ['*'], 'page', $pageNumber);
?>

Hope you found this article useful!

Resolve cURL error 60: SSL certificate problem on localhost

You'll get this error when you're hosting a Laravel project with using HTTPS/SSL protocol on localhost or 127.0.0.1:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

I read some article on trying to install cacert.pem authorization certificate on your WAMP/XAMPP setup but it didn't really work out for me as I was running out of time.

So, I did a little digging and learnt that I can just modify the verify flag to false in the vendor/guzzlehttp/guzzle/src/Client.php file:

<?php
$defaults = [
    'allow_redirects' => RedirectMiddleware::$defaultSettings,
    'http_errors'     => true,
    'decode_content'  => true,
    'verify'          => false, // changed it to false
    'cookies'         => false
];
?>

By changing to it false, you'll not face that error again but please keep in mind, you should do this only if you're developing on localhost.

Happy coding!

How to resolve the "No application encryption key has been specified" error

Are you facing the same error as this article's title? Then this article might help you out.

If you're developing applications using HTTP/SSL Protocols (regardless, you should!) on Laravel, by default, you'll be using Laravel's encrypter but in it's official documentation, it says:

Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command to generate this key since this Artisan command will use PHP's secure random bytes generator to build your key. If this value is not properly set, all values encrypted by Laravel will be insecure.

Just execute the following command in your root directory:

php artisan key:generate

If the error still persists, try clearing the cache by doing the following:

php artisan config:cache
php artisan cache:clear
php artisan config:clear

Hope you found this article useful!

How to filter requests with errors on Chrome's DevTools

Tired of trying to look for errors in DevTools by scrolling a long list of HTTP responses?

Open up your Chrome DevTools and hit the Network tab and then try filtering the responses by typing the status-code property in the filter box.

It comes in handy when you want to narrow down to a specific list of HTTP responses. For instance, if you're looking for responses with error 404, you can filter it by typing like this: status-code:404.

Another trick is, you can filter out the responses that you don't want to see by just adding a hyphen like this: -status-code:200.

Hope this tip helps you out!

Accessing WAMP Server from other computers on LAN

Whenever you develop a website using the LAMP or WAMP stack, you'll want to access the website, locally, via different systems and devices solely for testing purposes.

Modify your VirtualHosts configuration

Setting up your WAMP Server for LAN access only requires you to tweak your VirtualHosts configuration file found in C:\wamp64\bin\apache\apache2.4.41\conf\extra\httpd-vhost.conf

<VirtualHost *:80>
  ServerName example.test
  ServerAlias example.test
  DocumentRoot "c:/wamp64/www/yourprojectname"
  <Directory "c:/wamp64/www/yourprojectname/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

Oh, if you're using Linux, you'll find the file 000-default.conf in /etc/apache2/sites-available directory.

Update your hosts file

If you type the URL of the website that you want to visit, the computer will first refer to the hosts file and then it'll go out to fetch DNS information. So, if you want http:\\example.test url to point to your local system, you just have add it in your hosts file:

Open the hosts file(C:\Windows\System32\drivers\etc\hosts) using a text editor and add this line to your hosts file:

127.0.0.1   example.test

Once done, save the file and restart your WAMP Server and you're all set to go!

Hope you found this tip useful!