Posts

Showing posts from July, 2021

How to create a SQLite Database for your Project and why it is the Perfect Choice for a $5 VPS Hosting

Image
  If you are looking to create a Database of your own for your own side project, or a hobby project on the World Wide Web, there are many options available. The really common ones are using a MySQL database, or some Tech Gurus will tell you to use Cloud based databases. Now, technically all that is fine, but in reality that costs money! $$ is the thing that you need to pull out of your pockets if you want a decent database up and running for your project. Why? Because, a decent database requires an installation and a fair amount of RAM needs to be allocated to it in order for it to be running successfully. Now, if your project is a small or hobby project, there are fair chances that you are using a cost effective hosting solution for it. The reason that these hosting solutions are cost effective is, they are not very high on power.  Again, if you are using a $5 VPS (i.e. the lowest end Virtual Machine available or most hosting providers) on a Digital Ocean, Google Cloud, Azure or AWS p

Using Java Hashmap to Find the Biggest Number in an Array which Occurs the Same times as the Number Itself

Image
  Today we'll touch-base on an Interview Question that involves multiple important Java concepts. You deal with Arrays, For loops, If statements, While Statement, Iterators, Java Collections and Function re-usability.  So, with one single question, your Interviewer can actually assess your expertise in all these areas! Let's check it out! Today we'll try to find the Biggest Number in an Array, which is occurring the Same number of times as the number itself.  So, just being the biggest number is not sufficient! If that was what is asked, you can find the max and/or min number of an array with this article. But this is not the question. In order to qualify for an answer, the number should occur the same number of times as the number itself and be the biggest such number. Quite complicated, we should say! If you follow our blog, we have already published one article on the usage of HashMaps to find if two strings are Anagrams . We'll reuse the Hashmap concept here to seg

Improve your Google CLS Score by Optimizing Image Sizes Using Plain CSS

Image
  Cumulative Layout Shift (CLS) is an important, user-centric metric for measuring  visual stability  because it helps quantify how often users experience unexpected layout shifts—a low CLS helps ensure that the page is  delightful . Above is the definition of CLS from Google web.dev.  Google has included CLS (cumulative layout shift) as an important metric for measuring a page and a forthcoming metric for ranking a page as it evaluates the user experience of a website. You can measure your website's score here . Simply put, a high CLS score means that your ranking will be low. Ideally, CLS should be 0 for a webpage. There are many elements on a page which can contribute to increase in CLS, the biggest contributor as per our experience, are the Images that are displayed on a Webpage.  If images are not loaded properly, then they can cause the page elements to shift or pushed when they load, impacting the CLS score.  Today, we'll see an very easy and efficient way to reduce the

Java Program to Find a List of Prime Numbers (Step by Step)

Image
  A Prime number is a Number whose only factors are 1 and the Number itself. A good problem to solve using Java code is to find the list of all numbers which are Prime till, let's say 100.  Now, that's a bit difficult to find by hand, and we can use the crunching power of loops to do this calculation for us easily.  The problem itself is a bit complicated and we can't solve it in one shot. We have to break it down into steps. Let's list down the steps required: Find the Factors of a Number Find if a Number is Prime (Factors should be 1 and Number itself) Find the list of Prime numbers Cool! So, as we have seen, we need to perform three operations in order to reach our final output.  One approach can be to write one really big function to do this calculation. The second, and better approach, is to break it down into separate functions, like we have broken down the problem. That makes the code reusable and showcases to the Interviewer that you have a grasp on different co

Java Program to Sort an Integer Array in either Ascending or Descending Order using Java For Loops and a Function Parameter

Image
  When you're learning Java to prepare for an Interview, Arrays is a really important concept. Sorting of an array using for loops is basic concept which everyone should understand.  We've written an article earlier to teach you how to use inbuilt Java functions to sort the characters of a string . But, if you're asked to write an algorithm yourself that can achieve this, you're at the right place! We'll show how to do the sorting, and for an icing on the cake, we'll also show how to control the sorting order i.e. ascending or descending! This makes our function reusable for both purposes. So, let's get started! In order to sort an Array, we'll have to traverse through it twice. We'll do it using for loops.  The first loop will traverse the total length of the array for ( int i = 0 ; i < a . length ; i + + ) And, the second for loop will be incrementally traversing the array for the sorting for ( int j = i + 1 ; j < a . length ; j + + ) See

Find All the Factors of a Number using Java For and If loops

Image
What are the factors of a Number? A factor is a Number that does not leave a remainder when it divides the number.  So Factors of 4 can be 1, 2, 4. Easy right? What about 20? 1,2,4,5,10,20. Now, What about factors of 859? That's difficult right? You might have to do a lot of calculations to find that one.  That's why its an easy but popular Interview Question. We are going to write some simple Java code today to find out all the factors of a number.  It's really easy if you grasped the basic concept correctly.  The Factor of a Number, is a Number which does not leave a remainder. Which Operator can help us to find the Remainder? Simple its the % operator. (Number % factor) will give us a Remainder.  So, the heart of our code is going to be: //if remainder is 0, means the number is a factor if ( num % i = = 0 ) We will be checking the Remainder for all Numbers starting from 1 to the Number itself and store the factors (where Remainder is 0).  ArrayList is a good Collection

Reduce Server Load from Dynamic Page Search - Create a Dynamic JavaScript based Table filter

Image
  When we are building a website, and need to create a searchable list of web pages, performance is one of the key concerns. Frequent searches can put unnecessary load on the server. In this case, there is a cool alternate approach where you load the search page only once, and the search itself is done using Javascript! What is needed for this implementation? Not much, and we'll walk you through it! We will also have the flexibility to Search on different columns of a table.  First, let's create a table.  < table id = " list_table " style = " border-collapse: separate; border-spacing: 10px; " > < tbody > < tr > < th style = " text-align: left; " > SNo < / th > < th style = " text-align: left; " > Tool Name < / th > < th style = " text-align: left; " > Type Tags < / th > < / tr > < tr > < td s