Abhineet.in

unlearning the learnt

Menu
  • Home
  • About
  • CAT Preparation
Menu

Category: Coding

How to detect English/ASCII string in PHP

Posted on November 15, 2022April 5, 2023 by Abhineet Mittal

There is no direct function for this in my knowledge. But it can be done easily like so. if ( mb_strlen( $string, ‘ASCII’ ) === mb_strlen( $string, ‘utf-8’ ) ) { return true; }

Read more

How to disable translation pop-up on website in Google Chrome

Posted on July 3, 2022April 5, 2023 by Abhineet Mittal

Google Chrome on Android tries to show pages in user’s preferred language by continuously showing translation pop-up on each page load. This happens when website content is in a different language than user’s preferred language. But this creates issues in user experience by hiding bottom content on website. My site had fixed bottom navigation bar…

Read more

Restrict number of selected checkboxes in html

Posted on June 29, 2022April 5, 2023 by Abhineet Mittal

This code will restrict html multi select input to given number. document.addEventListener( “click”, function( event ) { if ( event.target.matches( ‘.input-checkbox’ ) ) { var inputCheckboxes = document.querySelectorAll( ‘.input-checkbox[type=”checkbox”]:checked’ ); if( inputCheckboxes.length > 3 ) { event.preventDefault(); alert( ‘You cannot select more than 3 categories for a post.’ ); } } } );

Read more

MySQL Disk Size Issue

Posted on June 15, 2022April 5, 2023 by Abhineet Mittal

I was facing a strange issue on one of my servers. Storage was getting full even when I did not upload any extra files. Turned out it was a MySQL logging issue and got resolved only when I disabled logging. References: https://www.christophe-casalegno.com/mysql-how-to-purge-binary-logs-when-you-have-no-space-left-on-device/ https://www.alittleofboth.com/2020/04/droplet-out-of-disk-space/ https://www.digitalocean.com/community/questions/where-did-my-disc-space-go

Read more

Why click event not working on SVG

Posted on June 15, 2022April 5, 2023 by Abhineet Mittal

I created a simple menu with SVG icons and to my surprise, clicking on the icon was not taking me to the linked url. It turned out that as SVGs are independent HTML objects, the target element is actually nested path. So, it does not match with the clicked element and thus click event listeners…

Read more

Add event listener on SVG element

Posted on June 8, 2022April 5, 2023 by Abhineet Mittal

I was facing problem while adding event listener to an svg element. Then I added event listeners to both svg and path tags, and it worked.

Read more

Resolved: TWA App not working fullscreen when downloaded from Play Store

Posted on November 11, 2021April 5, 2023 by Abhineet Mittal

To hide the address bar in a TWA app, you must have setup and asset links file on our server with valid SHA certificate fingerprint. Sometimes the app works fine when we test it by directly installing through apk, but address bar is shown when we download the app from play store. The reason for…

Read more

How to track if a web page is opened in TWA app

Posted on November 11, 2021April 5, 2023 by Abhineet Mittal

The Trusted Web Activity (TWA) in Chrome has made it so easy to package and publish any website as an app. But the problem arises when we want to track when your website was opened inside the TWA app. Usually we can easily do this in a webview app by appending a custom string to…

Read more

How to persist state through query string in url

Posted on November 10, 2021April 5, 2023 by Abhineet Mittal

In some cases when you do not have the option of cookies to manage state, query string can be a good option. In this article, I am going to use some Javascript to persist state through a query string in the url. The Javascript code is added to head section of html when the desired…

Read more

Modify page title tag in WordPress

Posted on October 4, 2021April 5, 2023 by Abhineet Mittal

To change page title tag in WordPress, use the pre_get_document_title filter. Most of the answers on web have mentioned the filter wp_title, but do not use it as wp_title function will be deprecated in future and wp_title hook will not work. At present, wp_title filter does not work when modifying the title tag.

Read more

Prevent Form Resubmission on Page Refresh

Posted on June 28, 2021April 5, 2023 by Abhineet Mittal

We face a common issue on many websites that whenever a form submits to the same page, and then we refresh the page, the form data is submitted again. Sometimes the browser asks for confirmation, sometimes it does not. It becomes really frustrating if it causes an operation to happen twice. To prevent this on…

Read more

Make Javascript sequential with “async” and “await”

Posted on April 11, 2020April 5, 2023 by Abhineet Mittal

Javascript code can be easily made sequential with the help of two simple, yet very powerful keywords “async” and “await”.

Read more
Javascript code

Javascript: Loop over querySelectorAll without error

Posted on March 27, 2020April 5, 2023 by Abhineet Mittal

In Javascript, there are a lot of instances when you want to find multiple elements on a page to apply a common operation to all of them. Suppose you want to hide elements of a particular class present on your web page. To do this, first get an array of all such elements using querySelectorAll…

Read more
How to count words in Unicode string using PHP?

How to count words in Unicode string using PHP

Posted on January 23, 2017April 5, 2023 by Abhineet Mittal

How to count words in Unicode string using PHP? This sounds too easy. After all, PHP has so many string manipulation functions. To count words, we can simply use str_word_count and we are good to go. But there is a problem. While this function works fine for English strings, developers find this function unpredictable as sometimes…

Read more

Categories

  • Business
  • CAT Preparation
  • Coding
  • Fiction
  • Finance
  • How-To-Life
  • Javascript
  • Life
  • Life at Infosys
  • Photoshop
  • Productivity
  • Publishing
  • Social Awareness
  • Startup
  • Technology
  • Uncategorized
  • Utilities
  • Visual Studio Code
  • Web Development
  • WordPress
  • Work Culture

Recent Posts

  • The Ultimate Guide to CAT Preparation: Tips and Tricks
  • Self-Publishing vs. Traditional Publishing: Which Is Right for You?
  • 7 Effective Strategies to Overcome Procrastination and Achieve Your Goals
  • How to detect English/ASCII string in PHP
  • The state of automobile dealerships in India

Recent Comments

  • Rohan George on Intermediate, Stream & Location: Luck by Chance
  • Ashika on Intermediate, Stream & Location: Luck by Chance
  • Steve on My first job, Infosys
  • SAKTHI on Finally, its Mysore…
  • Akash dhyani Akash on Training Begins…
© 2023 Abhineet.in | Powered by Minimalist Blog WordPress Theme