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.

  • VSCode

    How to switch between integrated terminal and editor in Visual Studio Code?

    21.07.2021 1 minute read

    While, I'm trying to adjust myself to using Visual Studio Code, I found it quite annoying that there isn't a shortcut to switch focus between the editor and the integrated terminal. For a guy, like me, who makes use of the keyboard all the time, that's pretty important.I did some research and found a way on how to do it. Just type and type and add these lines:Save the file and now, you'll be able to switch between the two by pressing keys.Hope you found this tip useful!

  • VSCode

    Quick Search for file in your workspace in Visual Studio Code

    09.07.2021 1 minute read

    Recently, started using Visual Studio Code as I'm yet figure out a way to install Sublime Text on Void Linux (using it as my current daily driver).I'm always used to looking for my files using keyboard shortcuts in Sublime Text and I was kind of surprised this feature isn't enabled by default in Visual Studio Code.Anyway, after a little digging, I found out that adding this line to your file would allow you to look for files in your workspace:And, now try and you'll be able to search for your file(s) easily.Hope you found this tip useful!

  • DevOps

    Redirect from HTTP to HTTPS in Apache VirtualHosts

    09.07.2021 1 minute read

    Here's a simple technique on how I learned to redirect a site from HTTP to HTTPS automatically using Apache's VirtualHost configuration.Go to your configuration file or and modify your configuration to something like this:Save the file and check if the configuration is correct before your restart the server:If you get the message, , then go ahead and restart the server:Now, your visitors will be redirected from HTTP to HTTPS automatically!Hope you found this tip useful!

  • DevOps

    How to setup rsync with passwordless SSH on UNIX/Linux?

    03.07.2021 2 minutes read

    Tired of ensuring if whether each file in every server is synced? Planning on doing automated backups? If so, then this technique should come in handy for you.Interested? Then follow the steps below:Check if rsync over SSH worksBefore you start, please ensure that you can to your intended server over using a password. With the following example, you can just send a simple file over to the intended server and see if it works or not:Once you execute this command on the terminal, it'll prompt you for a password on the remote server, if it does, then it works.Generate SSH KeysIf you want to do a passwordless SSH, you need to generate public and private SSH keys on the local server by typing the following command on the terminal:If you're prompted to enter a passphrase, just hit and proceed until the key is generated. Once the keys are generated, they'll be in the directory on your local server.Copy public key to remote serverUsing , you can copy the public key to the remote server:Once executed, you'll be prompted to enter the password of the account on the remote server and if successful, the public key will be copied to the remote server and will be stored in it's appropriate location.Perform Rsync over passwordless SSHIf you've come this far, then you should be able to SSH to the remote server without entering the password:If it works, then perform the operation again (above) and this time, it shouldn't prompt you to enter any password.Hope you liked reading this short article!

  • VIM

    Prevent VIM from creating swapfiles

    03.07.2021 1 minute read

    I like VIM and use it regularly to write and edit code on a daily basis but I always find the creation of files really annoying.If you find them annoying too, you disable them temporarily in the editor, like this:Or if you want to disable it permanently, just add this line in your file:Don't get me wrong, I'm not saying that you should dislike files because if the editor crashes or your computer/server crashes in midway, those files can save your progress.Hope you found this tip useful!

  • Tooling

    How to install Composer manually?

    03.07.2021 1 minute read

    You may wonder "why not install Composer via apt or yum package manager?" and yes, it can be installed that way too.But what if you are using old composer packages or you wanted to skip the checks done during the interactive installation routine, this could be the way for you.I wouldn't really call it an advanced technique or something but if you know what you're doing, then you should be in the right direction.The below snippet will show you how to install it manually:Yes, that's it!By placing Composer in the directory, it will be accessible from any directory within the system and you can run it globally.To check if you've installed it correctly, just do the following:Hope you found this tip useful!

  • Graphics

    Render a simple RGB colored image in C++

    11.06.2021 1 minute read

    Recently, I started reading a book called The Graphics Codex, it's an amazing book about Computer Graphics covering a lot of content and I find it quite resourceful. I wanted to build my own toy raytracer for the sake of exploring, so that's why I started to refresh my graphics coding knowledge a bit.Just like any graphics renderer, in order to view your image. you must be able to write your image to a file, right?Below, I wrote a really simple code to generate the entire RGB colored spectrum from top to bottom:You can generate it by simply creating an executable like this:Now, when you execute it by typing , you'll get a list of numbers that's pretty much a combination and permutation of RGB color values.Lastly, to generate a colored image, like the one above, just redirect the output to an image format, in this example, I used PPM image format:And that's it, you have generated your own colored image! 😁Hope you found this useful!

  • Unix

    Zip all files that are modified on a specific date

    10.04.2021 1 minute read

    I wrote a nifty command to make an archive of the files that I have modified on a particular date. By doing so, this script comes in handy during urgent deployments, so that I don't lose track of the files that I should be updating.Here's the command at your disposal:How this works?Let's see what this command does in pieces: is the utility tool used to return the filenames that match the specified parameters in the given directory. is the flag that allows you to specify the depth of recursive searches it should perform. is the flag that determines if you're looking for file or a directory. is the flag that determines if the file has been modified on and/or after the given date.Once, the file has been found, the output is being redirected to the utility function, which would then add the files to the file. The flag would perform the operation in silent mode, flag would update the files in the archive if modified or add it as a new file if it doesn't exist and takes the list of files from the standard input.If you want to ignore certain directories or file extensions, in that case, you can exclude them like so:Or, you can even archive the modified files by specifying a date range:Hope you found this tip useful! 😁

  • Unix

    Exclude directories while searching for a pattern in files

    10.04.2021 1 minute read

    Looking for a specific text pattern in a directory but wanted to avoid some paths? Here's a quick command that you can try:Hope this helps you out!