megacolorboy

Today I Learned

A collection of short write-ups on the things that I learn on a day-to-day basis.

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

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

  • Git

    How to update your Git remote origin URL?

    10.04.2021 1 minute read

    Did you make a typo while typing out your Git remote origin URL? Is it pointing towards the wrong repository?You can easily update it using the following command:Hope you found this useful!

  • Git

    Perform Git operations using path directory

    10.04.2021 1 minute read

    The flag means the path of the directory and using this flag, you can perform any Git operations outside the project's directory without having to enter the directory all the time:Hope this tip helps you out!

  • Unix

    Get a list of directories with their sizes in the current directory

    10.04.2021 1 minute read

    If you want to sizes of each directory in a list, try the following command:And, if you wanted to find the directory that takes consumes a lot of space in your directory, you can try this:Hope these tips do come in handy! 😊

  • Unix

    Find directories older than a specific date and sorted by size

    10.04.2021 1 minute read

    Wanted to see which directories were created on an older date along with their sizes? Try this:Hope you found this tip useful!

  • VIM

    Convert string from snake case to camel case

    12.03.2021 1 minute read

    Thought of sharing a simple regular expression that I use on VIM to convert snake_case letters to camelCase letters (see what I did there) 😜Here's the pattern for you to use:Hope you found this tip useful!

  • cPanel + Email

    How to resolve the issue of not receiving emails on the same domain?

    12.03.2021 2 minutes read

    Recently, we hosted our company's redesigned website on GoDaddy, which offers cPanel to manage your website. I was dealing with an annoying email bug in which I was able to send/receive emails to any account except the ones that share the company domain.The company's current email setup makes use of Google Workspace and since we're using a Shared Hosting account, GoDaddy allows you to use their SMTP relay and prohibits the use of third-party SMTP services such as Google Workspace, Outlook, etc.After configuring it with Google's MX records in the DNS settings, I wasn't receiving any email on my own company email yet I was able to receive on other email accounts that didn't share the company's domain.I did a little R&D and ran into this documentation about email routing and figured out that there could be an issue with it's configuration.Here's what I did:Open cPanel Search or look for Email RoutingClick on Email RoutingIf your MX records are not pointing to the IP address of the hosting server, then select Remote Mail ExchangerSave changesAfter following these steps, I was able to receive mails on the same domain!So what really caused the issue?Since, we didn't have a default email address set up in cPanel, the current mode to send all unrouted emails was set to , by default. I guess, it's set up that way to prevent the server from sending/receiving spam mails from the domain.This makes sense because:The MX records are not pointing to the current serverThere are no email accounts created for the domain on cPanelBy setting the mode to , all emails with the same domain are being discarded or rejectedNot really sure if this is what caused the issue but judging from the facts, I was able to reach to this conclusion.Hope you found this tip useful.ReferenceCan't send email to addresses at my own domain

  • Laravel

    Create migrations and seeds from an existing database

    12.03.2021 1 minute read

    Up until now, I've written migrations and generated seeders for some Laravel projects that I have worked on but recently, I thought of seeing if there's a way to generate migrations and seeds from an existing database especially if it's a project that never had any migrations or seeds created before.Luckily, I found these two packages, which turned out to be quite productive:kitloong/laravel-migrations-generatororangehill/iseedExecute the following commands to install the packages mentioned above:Generate migrations using existing databaseYou can generate your migrations for all tables like this:Or, you can specify the tables you wish to generate:Generate new seeds using existing databaseYou can generate seeds for a single table like this:And for multiple tables, you can do this:Hope you find this tip useful!.

  • PHP

    Check if trait is being used in your class

    12.03.2021 1 minute read

    Want to know if a trait is being used in your current class? Try this:By any chance, if the current class is inherited, please note that the method will only return the list of traits used by the current class and won't include any traits of it's parent class.

  • PHP

    How to resolve the "file_get_contents(): SSL operation failed" error

    12.03.2021 1 minute read

    If you're facing this error while trying to download a file from your server, it's most probably the SSL certificate that has been hosted on your server isn't correctly verified or maybe, you're using OpenSSL on a server running PHP 5.6.As per the documentation, there are some changes that can be made to resolve it, like the following method:Although, I won't recommend this unless you are testing it on a environment as it's not secure and could have significant security implications because disabling verification can permit a Man in the Middle attack to take place.Use it at your own risk!

  • Bash

    Show Git branch in your Bash prompt (with colors)

    12.03.2021 1 minute read

    Do you work on a project with multiple Git branches but don't know which one you're in? Open your file and add this:Save the file and execute this command for your changes to take effect:Now, you should see your colors in your Bash prompt along with the Git branch that you're working on (Note: this will be shown if you're in a project that uses a Git repository).Hope this helps you out!

  • MySQL

    Convert string to date using MySQL

    12.03.2021 1 minute read

    Today, I was debugging a piece of code that is supposed to return a list of data based on the year, the funny thing is that the data was being returned on the development server but not on the production one.Weird, so I opened up MySQL Workbench and wrote a simple query to see if the dates were being returned because who knows maybe they weren't stored at all.The values returned were . Now, that's strange because the dates were present in the column. So, I took a deep look and figured out that the dates were stored in instead of data type! 😔Luckily, I figured that there's a way to resolve this by function:Bam! The results were coming now! 😌Hope this helps you out!

  • Laravel

    Convert to date from timestamp using Carbon

    12.03.2021 1 minute read

    Using Carbon's method is basically a wrapper for , the main difference between the two methods is that you can add a timezone to Carbon's method.Here's a sample on how you can convert to date using timestamp using Carbon:Hope you found this useful!

  • Laravel

    How to exclude certain slugs in Laravel

    12.03.2021 1 minute read

    Using plain Regular Expressions, you can exclude certain slug from your routes, try adding the following to your file:Hope you found this useful!

  • Laravel

    How to resolve the "Failed to clear cache. Make sure you have the appropriate permissions." error

    12.03.2021 1 minute read

    This error is annoying and mostly happens if the directory is missing under the directory. For some reason, this folder doesn't exist by default.To resolve it, just manually create the directory under the directory and it should fix the issue.

  • PHP

    Convert string to variable in PHP

    12.03.2021 1 minute read

    I read about variable variables in PHP's official documentation.Here's a sample:Not sure if this is a good practice but it sure gets the job done!

  • PHP

    Convert numbers from English to Arabic in PHP

    12.03.2021 1 minute read

    If you're a developer working in the Middle East, it's quite common that you'll work on a project that bilingual, in our case, it's english and arabic.In my opinion, it's not aesthetically pleasing and logical to have english numbers in arabic text, so, write a simple helper function to convert the numerals from english to arabic:And since most browsers can handle RTL, you don't have to worry about how the arabic numerals are being displayed in your application.

  • Laravel

    Clearing cache on a Shared Hosting Server

    12.03.2021 1 minute read

    Hosted your website on a Shared Hosting Server and got limited access to clear the cache on your project?Open up and create this route:Just type the URL and it will clear all existing cache from the project.Hope this helps you out!

  • MySQL

    Use MySQL 8.0 with Native Password Authentication

    12.03.2021 1 minute read

    Last month, I was configuring an Ubuntu Server to deploy a client's project that uses MySQL 8.0 and PHP 7.2. So, I installed the necessary dependencies and finally installed MySQL 8.0, created a new schema and imported the database tables required for the project.Next, I typed the project URL and ran into this error:Unable to load plugin 'cachingsha2password'If you're running PHP 7.2 and facing this error, you should know that PHP 7.2 doesn't support native password authentication by default. But it's a simple fix, all you have to do is either one of the following:Alter the current user's authentication to native passwordCreate a new user with native password authentication Alter the current user's authentication to native password Create a new user with native password authenticationFor the changes to take effect, you need to reload the privileges by typing the following:Hope this helps you out!

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

  • Laravel

    Resolve cURL error 60: SSL certificate problem on localhost

    28.09.2020 1 minute read

    You'll get this error when you're hosting a Laravel project with using HTTPS/SSL protocol on or :I read some article on trying to install 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 flag to in the file:By changing to it , 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!

  • Laravel

    Get pagination data by page number

    28.09.2020 1 minute read

    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 method takes the following parameters by default:So, if you want to fetch the pagination data of a specific page, then just write this:Hope you found this article useful!

  • Laravel

    Clear a file directory using Filesystem in Laravel

    28.09.2020 1 minute read

    I was working on a project that dealt with generating large .zip exports and as a result, the 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 package in my controller:Then simply, create a new instance and define the directory you wanted to clear:Hope this helps you out!

  • UNIX

    How to move a running process to the background?

    28.09.2020 1 minute read

    Pause the current process using , which will send it to the background and then type 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!

  • Chrome DevTools

    How to filter requests with errors on Chrome's DevTools

    19.09.2020 1 minute read

    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 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: .Another trick is, you can filter out the responses that you don't want to see by just adding a hyphen like this: .Hope this tip helps you out!

  • Laravel

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

    19.09.2020 1 minute read

    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 option in your configuration file. You should use the 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:If the error still persists, try clearing the cache by doing the following:Hope you found this article useful!

  • Apache + WAMP

    Enable HTTPS/SSL on WAMP Server

    13.09.2020 2 minutes read

    Building a website with HTTPS/SSL in mind can help resolve a lot of problems when you're going to deploy it on production server.So, here's a small tutorial on how to enable HTTPS mode and install SSL certificate on your local WAMP Server.Note: This tutorial assumes that you have a Windows PC and have installed WAMP Server 3.2.0 in your local system, if not, download it from here.Download OpenSSLBased on your system's architecture, you can download either a 32 or 64-bit installer. You can find the latest version of OpenSSL from here. While installing, please make sure all the options selected are default.Generate SSL Key and CertificateOpen your terminal or command-line prompt and navigate to the following folder:Next, you need to create a private key. While generating a private key, you'll have to enter a passphrase, it can be anything but make sure that you can remember it for the next step 😂.Execute the following command:Good, now let's generate our certificate and in this step, you'll be prompted with several questions. You can fill as per your wish or just hit "Enter" to leave it as default. The only thing that matters is Common Name and this should named as Execute the following command:Move the certificate and key to Apache's directoryCreate a folder named and move both and to this directory: .Modify your httpd.conf fileYou have to uncomment 3 lines from :Modify your httpd-ssl.conf fileGo to and modify the following parameters: is the location of where your website files are located. can be anything but preferable to use .Restart your WAMP ServerJust restart your WAMP Server for the changes to take effect. If the WAMP icon turns green, you're good else, an typo or syntax error must have occurred.Hope you found this tutorial useful! 😀

  • Apache + WAMP

    Accessing WAMP Server from other computers on LAN

    13.09.2020 1 minute read

    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 configurationSetting up your WAMP Server for LAN access only requires you to tweak your VirtualHosts configuration file found in Oh, if you're using Linux, you'll find the file in directory.Update your hosts fileIf you type the URL of the website that you want to visit, the computer will first refer to the file and then it'll go out to fetch DNS information. So, if you want url to point to your local system, you just have add it in your file:Open the hosts file() using a text editor and add this line to your file:Once done, save the file and restart your WAMP Server and you're all set to go!Hope you found this tip useful!

  • JavaScript

    Prevent loading a webpage from Back-Forward cache

    30.08.2020 1 minute read

    I'm working on an eCommerce project and I encountered a really weird problem, whenever I saved items into my cart and proceed to the checkout page and then go back to previous page, my cart isn't updated until I refresh the page.Honestly, I thought this was a bug until I came around to learn about Back-Forward Caching a.k.a bfcache, which allows the user to navigate between pages faster. That's a good thing, though!But that didn't help resolve my issue, so I thought of going around with a tiny hack:The code above will look any persistence of the event. Initially, it's set to and if the page is loaded from bfcache, it'll set to .I wouldn't really consider this as a solution as it only worked on Safari instead of Chrome or Firefox.But hey, it gets the job done! 😂

  • JavaScript

    Refresh browser window without query parameters

    29.08.2020 1 minute read

    If you want to reload the current page in your browser without any query string or parameters, here's how you can do it:By doing so, it'll preserve the HTTP/HTTPS protocols of the URL and also remove the fragments that start with a .If you want to preserve the fragments, you can try this:Hope you found this useful!

  • Python

    Extract unique characters from a string

    23.08.2020 1 minute read

    I thought of getting back into competitive programming again and started practicing my python coding-chops on Codewars.Here's a neat trick on how to extract unique characters from a string:Using allows you to preserve the order in which the keys are inserted as a normal doesn't track the order.Hope you found this useful!

  • PHP

    Increase execution time in PHP

    23.08.2020 1 minute read

    Ever process a file that's larger than 2GB and got an error that said something like this:Maximum execution time of 30 seconds exceededThough, PHP doesn't have an efficient way of processing files of large sizes, you can prevent your web application from timing out by adding this to your code:Hopefully, some day, this might come in handy for you! 😜

  • PHP

    Increase memory limit in PHP

    23.08.2020 1 minute read

    Last month, I was building a web application that collected a lot of data via form submissions. I wrote a method to export attachments and form data by zipping them all together. It worked for a smaller archives but as the records grew larger, I got a fatal error which said that I've exhausted the PHP's memory limit.So, I found an easy way to increase the memory limit to 1024MB (1GB) like this:Before you write this stub in your script, make sure you have enough resources in your system or else, it'll go splat!

  • PHP

    Input sanitization with PHP

    23.08.2020 1 minute read

    This can come in handy when you're dealing with user inputs during a form submission and in most cases, your web application will be using a database query to store the data. Using filter_var()This method uses a number of flags to validate and sanitize a string. Here are some examples I have tried:Removing special charactersWant to strip out all tags and certain characters? Try this:Integer validationYou can check if the input is an integer and if it's a value between 1 and 20:URL validationWant to check if the input is a valid URL? Try this out:Using these in-built features makes it easier for PHP developers to process data from external sources in a safer manner and also adds an extra layer of protection to your web application.Read more about this method in PHP's official documentation.

  • Go

    Hello, Go!

    01.08.2020 2 minutes read

    After reading a lot of articles about using Go as a programming language to write high-performing concurrent web applications and services yet maintain a clean codebase, I thought of starting to learn it to see what's it about and so far, it's been great!This mini-tutorial will show you how to install Go on your system and write a simple "Hello, World" program.Note: This tutorial will go through installing Go on Linux.Install GoMake sure you have the latest updates and upgrades on your Linux system before installing Go.You need to download the binary file from their official package. Find the version that suits your OS and architecture.Extract the downloaded archive and install it in the directory (as per the standards):Set up environmentNow, we need to set up three variables:: Location of where your Go package is installed.: Location of your work directory.': Tells bash on where to look for programs that are being executed.Open up your file and add these lines at the end of the file:Save your file and update the current shell session:Verify your installationType the following command to ensure that your Go installation is successful:Hello, world!As per traditions, whenever you learn a programming language, you start off with a "Hello, world!" program, so here it is:ConclusionI just started learning it today and at first, you might have the tendency to write code in Go the same way you write in any other language but beware, it doesn't work that way. It forces you to write good code including the way it formats the code using the tool.Lots of cool things are coming!Stay tuned for more.

  • Terminal

    How to delete files inside a zip file?

    21.07.2020 1 minute read

    Ever compressed your project directory but forgot to delete that useless file or folder and turns out the compresed file is larger than it's supposed to be? Here's a quick solution you can try:If you want to delete a file inside a file, try this:And if you want to delete a folder, try this:Hope this helps you out!

  • Regular Expressions

    Find the number of uppercase and lowercase letters in a string

    18.07.2020 1 minute read

    The usual approach of counting the number of uppercase and lower letters in a string is done by using a counter and a loop:That's nice but here's shorter and faster implementation:The variable is taking the difference of the lengths between the original string and the string with lowercase letters only because the method replaced the pattern of uppercase letters with empty spaces. The variable does the opposite of what the variable does.Hope you found this trick useful!

  • Regular Expressions

    Replace all occurrences found on a string using Regular Expressions

    18.07.2020 1 minute read

    Let's say you have the following string and you must replace all occurrences of "Hello" with "Bye":You may think of using the method to solve this problem:But unfortunately, it only replaces the first occurrence in the string:Using the power of Regular Expressions, you can replace all occurrences in one go:Now, when you execute the following, you'll get a string that replaced all occurrences:Until next time, then!

  • PHP

    Create a unique multidimensional array using a key index

    18.07.2020 1 minute read

    Let's say, you have a multidimensional array like this:And say, you want to be able to return unique cars by or , use this method:Call this method from anywhere in your code like this:And now, you'll get something like this:You might wonder why I tried this instead of PHP's method and the reason I didn't use it is because it doesn't support multidimensional arrays.Hope you found this useful!

  • MySQL

    How to duplicate tables in MySQL?

    18.07.2020 1 minute read

    This trick comes in handy whenever you wanted to reuse a table, perform data migrations or maybe even take a backup of the table before any of your experiments mess up your data.Executing the following query will help you create a new table with the structure of the old table:If you want the data as well, try this:You can use this query to copy tables from one schema to another schema too. Hope this helps you out! 😄

  • JavaScript

    Find the difference between two arrays

    18.07.2020 1 minute read

    Finding the difference between two sets i.e. Set A and Set B is basically returning a new set that contains values of Set A that don't exist in Set B or vice-versa.Here's an example:I wrote a shorter implementation using JavaScript's method:Once you execute this method, you'll get the following as a result:BONUS: What does the .filter() method do?This method returns a new array with elements that pass the conditions provided by a callback function.If the conditions aren't passed, you'll receive an empty array.In this article, is considered as the callback function in which the refers to the index of the current element of array A and is then used as a parameter to check if the element doesn't exist in array B.The neat thing about this method is that it doesn't mutate on the array that it's being called from.Read more about Array.prototype.filter() on Mozilla's developer documentation.

  • PHP

    Extract YouTube Channel ID from URL

    13.07.2020 1 minute read

    Using PHP's in-built function, , you can write a helper method to pull the channel ID off a YouTube URL especially if you're pulling videos using YouTube's Data API. Here's the code:Writing tiny methods like these can help save time and be reusable in more than one context. Hope you find this tip useful! 😁

  • Linux

    Using zipcloak to encrypt files within an archive

    07.07.2020 1 minute read

    Whenever you're sending a bunch of files or an archive that contains sensitive or confidential information, it's wise to encrypt before you send it to the person that you intend to.Using , you'll be able to encrypt files within your existing archive.Do the following after you've created a zip archive:Now, you'll be prompted twice to enter a new password and verify your entered password. If they match, your archive will get encrypted. So whenever, you try to unzip or open using an Archive Manager, you'll be prompted to enter the password or else, you won't be able to access it.You also have the choice of not encrypting the original archive and creating a new one instead, just like this:On the other hand, if you do wish to remove the encryption from your archive, just type the following:And you'll be prompted again to enter your password before it removes it's encryption.Hope this helps you out! 😁

  • Laravel

    How to cache your queries on your Laravel application?

    05.07.2020 1 minute read

    Although, Laravel is a good framework, it's quite heavy when it comes to executing queries especially if you're using the Eloquent ORM instead of the normal query builder.But Laravel does offer the option of caching your queries in the server and will only make calls to your database if there's a change in content.Quite handy when you're having a content-heavy website and huge amount of user traffic.Using the class, you can cache your queries like this:In the above example, is the key that stores your queries of apples forever and which will be used to obtain your cached results from the server. Oh, be sure to create distinctive names for different types of queries or else, you'll end up being confused! 😜You can also give it a time limit in milliseconds:Hope this tip helps you out! 😀

  • Algorithms

    Looping infinitely around an array

    04.07.2020 2 minutes read

    Sometimes, I find myself in a situation where I might have a fixed array of colors, text, numbers or something like that but I want to loop around infinitely like a carousel.Let's say we have an array like this:The code is an array of three colors that we want to apply to, hmmm, say a list of HTML DOM elements like containers or any element that you prefer. In this example, we'll add some colors to a bunch of elements that has the classname or we'll just call them "cards".Behold, the Modulus operator!You may think of writing different conditions or loops to achieve a solution but a more elegant one is by using the Modulus operator a.k.a the Remainder operator (). Using this operator gives you the remainder after the division of a number.Hmm, confused? Okay, here's a simple example of how a Modulus operator would be like:In plain english, if you have 10 apples and you divide them by 4 and by doing so, you'll end up with 2 sets of 4 apples and the remaining set would be 2 apples. Thus, the remainder is 2.Did that make sense? If not, then try the following code in your browser:Let's say we have 10 "cards" and we want every 3 three cards to have 3 different colors, we must just define a way to determine the index of each color while iterating through a loop of cards. So, we can easily get the index by doing so:Here's the full code:The following code will apply the colors to each "card" with respect to it's order and will reset back to the first color once it's reached it's last color based on the remainder of the next iteration in the loop.Read about Modulus Operation to know more about it.

  • Apache

    Forcing HTTP to HTTPS redirect after enabling SSL

    22.06.2020 1 minute read

    You can manually force HTTP to HTTPS after enabling your SSL certificate by adding the following condition at the beginning of your file in your directory:Save your file and restart your Apache server and now, your web application will redirect all your users to instead of URLs in the future.

  • Apache

    Enable HTTP Strict Transport Security (HSTS)

    22.06.2020 1 minute read

    As part of a project that I was working on, I learnt about HTTP Strict Transport Security protocol which tells the browser about making future web requests over HTTPS only. So, even if you attempt to use , the browser will force you to use URLs in the future.You can enable it by writing this header in your file in your directory:Please note that once you enable this protocol, your web application is committed to using SSL i.e. you won't be able to use insecure HTTP for your web application.

  • Linux

    Enable copy-paste clipboard in URxvt Terminal Emulator

    20.06.2020 1 minute read

    In my current Arch Linux installation, I decided to use a window manager called i3. It's really awesome and it comes with a really lightweight terminal emulator called urxvt. It's very minimal and I lked it but when I tried to copy-paste text from one terminal to another, I wasn't able to.However, thanks to the internet, I did some research and figured a way out.1. Install xClipFirst, you need to ensure that you have installed the package, which will be used to copy-paste text in the emulator.Type the following command to install the package:2. Activate Clipboard using PerlNow, you have to paste these custom commands into your file, which is found in directory:3. Modify your .XresourcesAdd these keybindings to your file:After adding it, refresh your settings:Reboot your terminal and try selecting some text from your terminal using your mouse and paste it using ++ and it should work! That's it! Enjoy 😃

  • Linux

    Configuring audio drivers in Arch Linux

    20.06.2020 1 minute read

    Yesterday, I thought of testing my Arch Linux system's audio and turns out, I didn't even install it yet! 😒Well, thanks to ArchWiki, it was simple enough to install to make the audio work on my old laptop. Just install the following packages:Reboot the system once you're done installing the packages. Depending on your window manager, you should be able to see your sound icon being active.Bonus: Bash script to control your volume from the terminalIn my current laptop, I still haven't mapped out the keys to control the audio volume, so I thought of writing a small method in my file, so that I can control it from my terminal.Open your favorite text editor and Add this method in your file:Save the file, close your edit and refresh your file by typing:Now, it should work when you type any of these commands:Hope this tiny script helps you out!

  • SSL

    Troubleshoot time-related SSL errors on secure websites

    14.06.2020 2 minutes read

    As I was configuring Arch Linux setup on my old HP 8460p laptop, I noticed that I wasn't able to access any site using Chrome or Firefox as I was faced with a weird error:I was quite confused and thought it might be an issue with my WiFi card or probably some server issue but turns out it was neither of them.On the side of my screen, I noticed my system time was displaying 4 hours ahead of the current local time, which is wrong. So, I did a little research and turns out my suspicions were correct, it's a time-related issue.How is time related to secure websites?Well, each website that uses SSL or that begins with are only valid for a period of time before getting expired. If the website that you're trying to visit presents a certificate with a time and date that doesn't match with your system's clock, Firefox will prevent you from accessing the page.How to fix it?Actually, the fix is quite simple. All you have to is just set the correct date and time on your system and you're good to go!If you're using Linux, just do the following:1. Set up your timezoneYou can look up for your timezones by executing the following:Once, you've found your timezone, execute the following by replacing with your timezone:2. Manually set your local timeExecute the following to set up your time, locally on your system:3. Set the hardware clock from the system clockThe following command sets the hardware clock from the system clock:Now, that you've executed them, you should be able to view the correct time on your system by executing and you should see something like this:Although, this issue was time-related, you may face the same kind of error for various other reasons. Try reading more on how to troubleshoot errors like these from Mozilla's official documentation.

  • Linux

    Transfer files remotely using SCP

    13.06.2020 1 minute read

    Do you want to transfer files remotely from one UNIX-based system to another? Try using the tool, which is a shorthand for Secure Copy Protocol. It's based off the SSH protocol using it as a means to securely transfer files from a local machine to one or more remote machines.Here's a code snippet that can help you out to transfer from computer A to computer B:And transfer from computer B to computer A:Oh, before you transfer files to another computer, make sure that you have permissions to access it first. If you don't have one, then create a new account using on your remote system.

  • Linux

    How to manually configure your WiFi on Arch Linux?

    09.06.2020 2 minutes read

    Recently, I thought of playing around with Arch Linux to learn more about Linux under-the-hood and to see if it can become my new daily driver.As I booted from live USB, I tried connecting to my WiFi using but it never worked after selecting my network name and entering the credentials.So, I did a little bit of research in ArchWiki and forums and I figured a way to set it up manually using by myself. is a network profile manager and it's apparently an Arch Linux project.1. Select your interfaceBefore you begin to set up your WiFi connection from your computer, check if your network interface is being detected:Since it's a WiFi connection, your interface most probably must be . If you see it, then set the interface up:2. Scan for networksNow, that your interface, use it to scan for your WiFi network:Once, you execute this command, you must be able to see your WiFi's SSID (or network name).Now, put your interface down for a while:3. Create a network profileAlright, go to directory and make a copy of the file to the directory:Now, go back to directory and open the file with your preferred text editor and edit the following only:After you're done editing, save the file.4. Test network profileTo test if your profile is working, do the following:In case, you get an error, try doing this:If you're able to ping, then it works. Else, edit your network profile and try connecting to it again.5. Enable network profileIf you've reached this stage that means your network profile must be working fine. Just do the following to enable the network profile to run the internet throughout the setup:Try reading more about using netctl in Arch Linux's official wikipage.

  • JavaScript

    Add search functionality to your static site

    06.06.2020 1 minute read

    If you have a static site or a blog generated using a static-site generator but want to add a simple search functionality? This could be of your interest.I'll take you through an example on how to build a simple search engine using a JSON file and AJAX requests.1. Generate a JSON dump of your siteAlthough, it's not a database but it can act as an alternative to having one. Your JSON dump can contain any metadata that you wanted your users to search in your site. In my case, I thought of allowing the user to search and . Is your site generated using Python and want to create a JSON dump? Read this article for more information.2. Build search functionalityI won't go through the aspects of UI design in this article as I feel that it's subjective and depends on one's preferences but let's keep it simple enough for this tutorial.Before you begin writing the function, place this component in your HTML template:Anyway, here's the function and you can place it directly on your template or in a separate file:That's it! Now, when you execute your script, you should be able to view your search results just like as if it were using a database.If you want to make it similar to mine, please feel free to inspect the code on the browser or go to my repository to see how it works.

  • Python

    Read and Write JSON to a file in Python

    05.06.2020 1 minute read

    You can make use of the built-in package in Python to read and write JSON data to a file.Writing JSON to a fileYou can store the information in a dictionary or object, which can contain any type of data like integers, booleans, arrays or nested objects.By using a object, the package will transform your dictionary into a serialized JSON string.Reading JSON from a fileReading is as easy as writing to a file. Using the same package again, we can parse the JSON string directly from the file.I read about different package alternatives like but I guess for now, this is a great way to get started especially, if you're working with web applications and are interacting with a serialized JSON data on a daily basis.

  • JavaScript

    Using default function parameters in Internet Explorer

    03.06.2020 1 minute read

    Today, I wrote a simple method that fetches images from the database via AJAX and also, I defined an empty object as a default parameter:The default parameter would contain extra parameters like , and , which would be then used to fetch a particular group of images, else, it'll fetch a random set of images.This method worked fine in Google Chrome and Mozilla Firefox but not in Internet Explorer. I thought of inspecting the code and I was facing weird errors like or on the IE console.Luckily, I had compared it to the other methods that didn't have any default parameters, so I did a little research and turns out that according to Mozilla's documentation, default function parameters are proposed by the ES6 syntax and at this point, I realized that Internet Explorer doesn't support ES6 syntax. What a bummer! 😒However, there's a way to prevent this from happening by rewriting the method like this:And BAM! The method worked flawlessly just as it's intended to do so. 😎Addtionally, you may refer to the ECMAScript 6 Compatibility table that you might find it quite helpful to check browser compatiblity for Internet Explorer versions 11 and under.

  • Algorithms

    Build a menu tree using recursion

    03.06.2020 1 minute read

    Hmm, what is the most efficient way to build a menu tree? 😅Most people would go for a brute force solution if it's a straightforward menu but would that be possible if we intend to create multiple levels of menu items?Sure, you could but as the number of loops increases, the complexity of time increases too. Not to forget, you'll end up writing code that'll look messy and unscalable.I always loved the idea and simplicity of using recursion. So, I thought of exercising my recursion skills by writing a method that can generate a dynamic menu with x number of parent and child menu items.The following example is written in PHP:Once you run it, you'll see something like this:There a lot of ways to achieve this same result using recursion but it sure is easier to read, scalable and extensible, ain't it?

  • JavaScript

    Allow inline elements in CKEditor

    01.06.2020 1 minute read

    Using CKEditor is awesome but I hate it when it removes inline elements like , or any DOM elements that contain attributes like classnames or ID, by default.Well, CKEditor's documentation states that you can allow it by adding this line to your configuration:After adding this line, CKEditor will stop removing those elements from your HTML content but it's also open to all tags. You can set rules to allow only specific ones like this:Hope this helps you out! 😊

  • JavaScript

    How to identify the current target of an event?

    01.06.2020 1 minute read

    Using the property which belongs to the interface can help you in many ways to identify target of the current event especially if you want to fetch attributes or modify the classname of an element that belongs to a group of elements sharing the same classname.There are many examples but I chose to write a small snippet of highlighting a tab:Read Mozilla's official documentation to know more about getting the current target of an event and it's compatibility with different web browsers.

  • Algorithms and Data Structures

    Queues & Stacks

    30.05.2020 2 minutes read

    Let's look at the differences between the two data structures:Queues: First-In First-OutStacks: Last-In Last-OutQueuesThis follows a First-In First-Out processing order i.e. the first element added to a queue will be processed first. A queue should support two operations:EnqueueDequeueEnqueueAdds the element to the tail of a queue. The tail position gets incremented.DequeueRemoves the first element of a queue i.e. the head element. Once, it's removed, the subsequent element becomes the new head element of the queue. The position of the new head element gets incremented and the previous one is assigned a negative integer like -1 or some garbage value. Implementation of a standard queue using C++:In terms of memory management, a standard Queue is quite inefficient and incapable of handling dynamic memory.StacksThis follows a Last-In First-Out processing order i.e. the last element added to a queue will be the first to be removed. Just like queues, it has two simple operations:PushPopPushEach element is pushed towards the end of the stack. Think of it as a card deck where you stack a card on top of another card.PopIt removes the most recent element i.e. the newly added element from the stack.Implementation of a stack using C++:Unlike queues, stacks are easier to implement and pretty efficient at managing dynamic memory.Oh, if you ever get to use these, don't worry about implementing them, nearly all programming languages have their own implementations of and that comes with it's own standard library.

  • Laravel

    Check if the current route exists before fetching it's parameters

    30.05.2020 1 minute read

    If you've ever come across this type of error when you're trying to fetch parameters of the current route:It's probably because the route doesn't exist, which is why it failed to call the function. It can be easily resolved by checking if the route exists before calling the function:Although, the sample code above is to fetch parameters of the current route, you can apply this before calling any method from the class.This works for version 5.2 and above.

  • jQuery

    Select all elements except the current element

    28.05.2020 1 minute read

    If you don't want the current element to be selected in an array of elements that belongs to same class or type, just use the method like the example below:The above code will change the text for all buttons except the current element.

  • Terminal

    Extract a specific folder from a zipped archive

    28.05.2020 1 minute read

    First, you need to view what's inside of the archive:Once, you've found the folder you wanted to extract, just type this:

  • Bash

    Rename extensions of multiple files

    27.05.2020 1 minute read

    In this example, we're going to change a list of files to files:You can use modify this script to rename any extension you want.

  • Terminal

    Remove patterns from multiple files

    27.05.2020 1 minute read

    If you wanted to remove a specific pattern in a list of files, like the ones below:You can simply do that using Regular Expressions and the tool:Now, the desired output should look like this:This should come in handy if you're lazy to rename each file manually! :)

  • Terminal

    Zip a file

    25.05.2020 1 minute read

    This comes in handy especially whenever you want to download multiples files from a server or take backups.For example: if you want to zip an entire directory with it's file contents, just do this:

  • Linux

    View hardware info

    25.05.2020 1 minute read

    Want to check the specs of your system? Just type this:Too long? Then type this for a shorter version:

  • Linux

    View battery status

    25.05.2020 1 minute read

    This comes in handy if you're using the terminal in full screen but still want to know your battery life. Just type the following:

  • Laravel

    Symbolic storage link in shared hosting

    25.05.2020 1 minute read

    If you're hosting a laravel project via cPanel, chances are that it could be a shared hosting server and that means you can't really use for this. But don't worry, there's another way to this. Just follow the steps below:1. Create a symlinkIn your directory, remove the folder. Next, create a file in your directory and add the following code:2. Create a custom route to access storageAlright, this is kind of a hack but it works extremely fine. Just add the following route in your file:Now, you can access your images or any other assets easily using: Hope this helps you out!

  • Laravel

    Create a symbolic storage link

    25.05.2020 1 minute read

    When using Laravel, the directory is used for files that are publicly accessible. By default, it's stored in and often stored in this directory. You can make it easily accessible by using the following command:Once, it has been created, you can use access those files using the or methods.

  • Terminal

    Using SSH with a private key

    25.05.2020 1 minute read

    Got a .pem key but don't know how to SSH to your server, just do this:BONUS: Convert .ppk to .pem keyRecently, I started working from home and as a programmer, it's pretty common to access the company server for development purposes. Back in the office, I used to access it using PuTTY but now that I'm using a linux machine, I thought of accessing it via Terminal but there's a catch, I can't use .ppk key to access it.So, I did a little research and figured that I can easily convert it using Open up your terminal and type:Now, convert your private key to PEM format:That's it and you're good to go!

  • Git

    Set up a new repository

    25.05.2020 1 minute read

    Are you new to using Git? Then this is for you.1. Set up a Git accountGo to GitHub and create your account with your email address.2. Create a repositoryJust create a new project with whatever you wanted. For this, you can just create or something like that.3. Initialize git in your project directoryNow, go to your project directory and initialize git by doing the following:4. Add your filesAdd your files to the repository by doing the following:Or if you want add selected files:5. Commit your changesBefore you push your changes, you need to write a message about what changes are done:6. Link your project to the repoDo the following to link your project to the repo that you've created in step 1:7. Push changesYou can decide which branch you wanted to push but initially, you'll have one branch, which is called :Or if you have an existing branch, just replace with .Hope that helps you out!

  • Laravel

    Set up reCaptcha in Laravel

    25.05.2020 1 minute read

    I mean, come on, you need to have a reCaptcha in your forms, no matter what.Here are the steps:1. Install using Composer2. Add provider and alias to configurationOpen your file and add this to your providers array:And this to your aliases array:3. Publish configuration4. Add sitekey and secret key to .env fileOpen your file and add this:How to use it?Now, you can use it in your validator using like this:

  • VIM

    Save a file

    25.05.2020 1 minute read

    Want to save your work? Type Type to save your file and quit VIM at the same time.

  • VIM

    Quit VIM

    25.05.2020 1 minute read

    One of the most infamous issues that new users of VIM faces when using it for the first time. Press to quit VIMIf you've worked on a file and want to save and quit? Just type .I hope that solved your quitting issue with VIM.

  • VIM

    Insert mode

    25.05.2020 1 minute read

    I get it, a lot of people are confused on how to start typing on VIM. All you have to do is press the key, the editor will be switched to insert mode.Press key to switch back to normal mode.

  • Terminal

    Including and excluding files in zip

    25.05.2020 1 minute read

    When zipping a directory or a bunch of files, there'll be a lot of stuff that you want to include and exclude.To exclude a file:Alternatively, you can choose to include files:

  • Terminal

    Find a file by extension

    25.05.2020 1 minute read

    This comes in handy whenever I want to look for files that exists with a specific extension in a computer or server:In addition, sometimes, you might want to look for a bunch of files with a specific extension but with matching keywords:BONUS: Display list of files by extension with file sizesLast month, I was trying to free up some space in our company server, so I realized that there were a lot of .zip files taking up a lot of space. So, I wrote a few commands to get me a list of zip files with their file sizes in sorting order into a .txt file:You can .zip with any extension to suit your needs! :)

  • Terminal

    Find files containing specific text

    25.05.2020 1 minute read

    This helped me a lot whenever I'm in a remote server trying to find a keyword or specific text amongst a bunch of files.This command will save you a lot of time: stands for recursion displays the line number matches the whole wordRefer to pages for more info.

  • Laravel

    Integrate Excel into your Laravel project

    25.05.2020 1 minute read

    Before you integrate Excel into your application, make sure your project meets the following requirements:PHP v7.0 or greaterLaravel v5.5 or greaterPhpSpreadsheet v1.6 or greaterDownload the packageDownload the package using Composer:Add it to service providerBy default, this will be done automatically when you're installing the package but if you want to do it yourself, add this in your file:Publish your configurationLast but not the least, run the command using to publish your configuration:Upon publishing, the configuration file will be created where you can make your changes.Hope this helps you out!

  • VIM

    Enable spellcheck

    25.05.2020 1 minute read

    This can be useful when you're writing stuff, just do the following:

  • VIM

    Clear all lines

    25.05.2020 1 minute read

    Switch to normal mode by pressing keyPress and it will take you to first line of the file.Then type and it will clear all the lines from start to the end of the file.

  • Linux

    Check Ubuntu version

    25.05.2020 1 minute read

    Want to know the current version of your Ubuntu distro? Type this:

  • Git

    Check branch status

    25.05.2020 1 minute read

    Ever wondered if you've edited or committed anything in your project before pushing it to your repository, do this:

  • Terminal

    Check RAM and disk space

    25.05.2020 1 minute read

    RAM spaceType the following command to view available memory in your system:Disk spaceType the following command to view available disk space in your system:

  • Terminal

    View the filesize in human-readable format

    25.05.2020 1 minute read

    Wanted to view the size of a file in terminal but don't understand the number of bytes displayed? No worries, just type this command and it'll display the size of the in human-readable format:

  • Git

    Checkout branch

    25.05.2020 1 minute read

    Want to create a new branch in your project? Simple, just do this:By doing this, you'll automatically be shifted to a new branch of your project. To check which branch you're working on, type this:And you should be able to see your current branch marked with a :