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.

  • 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!

  • Git

    How to resolve the "fatal: refusing to merge unrelated histories" Git error?

    10.04.2021 1 minute read

    This error shows up when two different projects are merged (i.e. they both could be the same project but unaware of each other's existence and have different commit histories).If you are facing this, chances are that:You must have cloned a project and the directory must have corrupted or got deleted and at this point, Git is unaware of the changes being made and will throw this error when you try to push to or pull from the remote repository.You created a new repository, made some changes and added the commits and then you tried to pull from the remote repository.Well, you can easily resolve by passing the flag when pulling the latest updates from the remote repository:Hope you found this useful!

  • Git

    How to recover from an errorneous forced git commit?

    10.04.2021 1 minute read

    If you're the type of person who types , please don't do that as it might overwrite your entire branch. I'm saying this because I did this once and I thought I lost all the files.Luckily, I was a bit relieved as is a VCS (Version Control Software), which means the files are most likely not deleted. This is when I came across command.According to the Git manual, this is what it does:Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository.This is a life-saver especially if you wanted to return back to the previous point in time. Here's how I recovered my files back again:Type Find and make note of the previous commit hash.Create a new branch with using the previous commit hash like this: Then finally, push the files to the new branch: Checkout to the newly created branch: Delete the corrupted branch and replace it with the newly created branch that contains your restored files.If I didn't discover this, I don't really know what I would have done to recover those files.ReferencesGit reflog documentationHow can I recover from an erronous git push -f origin master?Hope this helps you out!

  • Git

    Fetch selected files from your remote repository

    10.04.2021 1 minute read

    Wanted to fetch a specific file from your Git repository except that the repository doesn't exist in your local machine?Try this out:After executing these commands, you should be able to see the selected directory/file in your project directory.Hope you found this useful!

  • Unix

    How to perform mysqldump without a password prompt?

    10.04.2021 1 minute read

    If you're performing a mass database backup using , you'll pretty much find it annoying to type in the password every single time.To get rid of it, open configuration file and add your database credentials:Once done, save the configuration file and now, you can try exporting your database without a hassle like this:Hope this trick helps you out!

  • Unix

    Find directories created within a date range

    10.04.2021 1 minute read

    Executing these commands helps me create a sorted list of files/directories created within a specific date range:Someday, these commands shall come in handy, bud! 😎

  • Unix

    How to change the character encoding of a file via Terminal?

    10.04.2021 1 minute read

    Sometimes, I face character encoding issues while making minor edits via a SFTP console connected to a Linux server. I found a quick hack to change the file encoding using on the command line.In this example, I'm changing the encoding of the file to :Hope you found this helpful!