megacolorboy

Hey there,
I'm Abdush Shakoor.

A not-so-typical software engineer & designer with a knack for problem solving and building stuff for fun.

  • CSS+SCSS

    Use node-sass to minify your CSS

    07.11.2020 1 minute read

    If you want to turn your files to minified files but without using Webpack or Gulp, just install the package using package manager and then run this on your terminal:And now, you can use your file on production! 😆Hope you found this tip useful!

  • PHP

    Resolve the "General error: 1835 Malformed communication packet" error

    07.11.2020 1 minute read

    This happened like two days ago, when one of the client sites went down. Upon inspecting the error logs, I found this:If you got the same error as the one above, don't worry, it's not your fault. According to this forum, a recent MariaDB update introduced a new bug for PHP versions < 7.3 that uses PDO and MySQL connectors. You can easily resolve this by simply upgrading it to PHP 7.3.Hope this tip helps you out!

  • Laravel

    Create aliased class constants in Laravel

    07.11.2020 1 minute read

    There are many ways to define constants in Laravel but I learnt a neat technique where you can define constants using an alias.First off, create the following directory:Next, create a file named in the directory and copy-paste the following code:Then, go to the file and define your new alias:Lastly, execute the following commands to update your app's configuration:After that, you can use your new constants anywhere (Controllers, Models or Blades) like this:Learning this new technique helps me keep the code clean and makes it easier to trace the constants.Hope you find this tip useful!

  • Regular Expressions

    Find and remove duplicate lines using Regular Expressions

    07.11.2020 2 minutes read

    Open up your text editor and use the following RegEx pattern to find and remove the duplicate lines:I found this technique on Regular-Expressions.info and I'm going to quote their explanation over here:The caret will match only at the start of a line. So the regex engine will only attempt to match the remainder of the regex there. The dot and star combination simply matches an entire line, whatever its contents, if any. The parentheses store the matched line into the first backreference.Next we will match the line separator. I put the question mark into to make this regex work with both Windows and UNIX text files. So up to this point we matched a line and the following line break.Now we need to check if this combination is followed by a duplicate of that same line. We do this simply with . This is the first backreference which holds the line we matched. The backreference will match that very same text.If the backreference fails to match, the regex match and the backreference are discarded, and the regex engine tries again at the start of the next line. If the backreference succeeds, the plus symbol in the regular expression will try to match additional copies of the line. Finally, the dollar symbol forces the regex engine to check if the text matched by the backreference is a complete line. We already know the text matched by the backreference is preceded by a line break (matched by ).Therefore, we now check if it is also followed by a line break or if it is at the end of the file using the dollar sign.The entire match becomes (or etc.). Because we are doing a search and replace, the line, its duplicates, and the line breaks in between them, are all deleted from the file. Since we want to keep the original line, but not the duplicates, we use as the replacement text to put the original line back in.Hope you found this tip useful!

  • Git

    Rename a Git Branch

    04.11.2020 1 minute read

    Using branches are one of the most powerful features of Git and becomes a part of the software development process.Last night, I came across an issue where I created a new branch and committed my changes until the tool rejected it because the branch was already created by someone else in the repository.Luckily, I was able to resolve this issue by renaming my branch using command.Here's a short guide on how you can do that too!1. Switch to the remote branch you want to rename2. Rename the current remote branchProceed to the next step, if you've pushed your old branch to the remote repository.3. Push the renamed remote branch4. Delete the old remote branchIf you've come this far without any issues, you've successfully renamed your local and remote Git branch.Hope you found this useful!

  • MySQL

    Concatenate multiple rows into one field

    04.11.2020 1 minute read

    Say, you have a table named and wanted to display a list of hobbies based on , you'd probably do something like this:This would return a list of hobbies like this:That's simple but what if you wanted to display them in one row? Like this:You can make use of the method to achieve the same result by executing the following SQL query:Nice, what if you wanted to view a list of hobbies of all users? In most cases, a table like this might have a many-to-many relationship, so in order to avoid possible duplicates, you can try this:Hope this tip helps you out!

  • MySQL

    Import and Export MySQL database via Terminal

    04.11.2020 1 minute read

    Sometimes, phpMyAdmin can be painful to use especially when you want to import/export a MySQL database.If you're not afraid of using the Terminal, try these commands to save your time:Import MySQL databaseBefore you run this command, please make sure that you've created the schema in your database or else, you might get an error especially if the file doesn't have a statement.Export MySQL databaseThis command will export your database with the file name to your current path.Hope this helps you out!

  • Linux

    Find your Public IP address using the Terminal

    03.11.2020 1 minute read

    Previously, I used to determine my Public IP address on Google Search by typing "What is my IP?" and I was good with it.Until, I thought of actually viewing it via the terminal itself. So, I wrote two lines of code in my file:Alternatively, you could try this too:Save the file and apply your new configuration by typing the following command:That's it, now all you have to do is type in your terminal and it will display your Public IP address.Hope you found this useful! 😀

  • XFCE+Linux

    Fix screen tearing in XFCE desktop environment

    02.11.2020 1 minute read

    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 BeaverIf you dont have the package installed in your system, do it right now:After you're done installing, type the following command to find out which graphics you're using:If you're using an Intel Graphics Driver, you'll probably get something like this: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 and create a file for your graphics card named .Copy-paste the following configuration into the file:Save the file, reboot your system and look for any screen tearing issues. If you didn't face any, that means it worked! 😁