Author: Daniel

  • When WP CLI fails, Use SQL

    WP-CLI is a powerful tool, but when you’re dealing with a huge volume of comments, it might not always behave as expected.

    Recently, I tried to use WP-CLI to move all pending comments to spam. The list includes over 67,000 unapproved comments. When I tried to list all the comments, WP-CLI returned odd outputs like 67844%. Here’s how I solved it using direct SQL commands.

    The Problem

    Running the following command returned a strange output 67844%

    wp comment list --status=hold --format=count

    When I debugged with the help of ChatGPT, I realized that WP CLI may not behave as expected when working with large number of results.

    So I chose to get the job done using SQL query. All I had to do was to run the following query.

    UPDATE wp_comments SET comment_approved = 'spam' WHERE comment_approved = '0';
    
    // To verify the result, run
    SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '0';

    Next time, when WP CLI lets you down, don’t hesitate to hit the SQL query.

    Today, I’m grateful for my consulting gig, which allows me to work from my home office and spend quality time with my family.

  • Beginning 2025 With Blessings

    We chose to attend the night mass for the new year. My son loves the decorations at the church in the night.

    The decorations in the Church, unlike the last couple of years, weren’t very delightful to the eyes. Also, it was painful to see people from other religions treating the Church as a tourist spot.

    Selfies and the midnight countdown in the Church isn’t the behaviour one would appreciate while the mass is on. Since the Church is a public place, there is nothing much we can do.

    We spent the first hour of the New Year, for the Lord and returned home for a good night’s sleep. The morning was filled with play, food and movies. Later, in the evening, we as a family received blessings from both our parents. We ended the day with Polar Bear Ice creams.

    I’m grateful to the Almighty for adding another year to my life.

  • Eyeball Exercises To Improve Eyesight

    If you spend a lot of time in front of screens (computer, tablet, phone, etc.), these eye exercises can help keep your vision healthy.

  • My 5 Month Beard Growth Journey

    Beard is a symbol of strength. But in India, beards are associated with dullness and sickness, at least in the region where I live.

    I’ve always wanted to grow a beard since my childhood. I neither had the patience nor the resources to grow a healthy beard.

    Ever since I watched Eric Bandholz talk about the power beard I wanted to grow my beard. So I decided to give it a try. On April 21, 2024 I trimmed my beard to 0.5mm and began from there.

    Five months have passed and I’m happy with my commitment. Over time, I learnt to avoid harmful chemicals and included only organic coconut oil in my beard care routine.

    With essentials oils, I make my own beard scent that not only smells great but also helps beard nourished. My wife loves the scent of my beard.

    If you’re looking to grow out a beard I suggest you give it a try.

    Live bearded!

    Beard growth stages
  • List Global Git Aliases

    Here is a quick & easy way to list all Git global aliases.

    git config --list | grep alias
  • WordPress: Underscore And Lodash Conflict

    In one of the projects that I’m working on, I recently encountered a conflict between Underscore library used within WordPress and the Lodash library used with the Theme I was working on.

    I knew from the console errors that the conflict arises because both use _. syntax. I knew that I must use _.noConflict() but I didn’t know where to.

    One of my fellow developers came up with the following solution to solve the issue.

    wp_enqueue_script( 'et-onboarding', $BUNDLE_URI, $BUNDLE_DEPS, (string) $cache_buster, true );
    
    wp_add_inline_script( 'et-onboarding', '_.noConflict(); _.noConflict();', 'after' );
    
    wp_localize_script( 'et-onboarding', 'et_onboarding_data', self::get_onboarding_helpers() );

    I’m fortunate to be part of a team of brilliant folks.

  • Javascript: Remove Duplicates From Arrays — A Simple Way

    Let us dive right away with an example.

    const urls = [
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg",
        "https://example.com/premade/wp-content/uploads/sites/4/2023/11/800x800.jpg"
    ];
    
    const uniqueUrls = [...new Set(urls)];
    
    console.log(uniqueUrls);
    

    Now the question is — how does a Set object remove duplicates? Set objects are collections of values. A value in the set may only occur once; it is unique in the set’s collection.

    Note that our array urls must be converted to set and then back to array. The conversion is very simple.

    const myArray = ["value1", "value2", "value3"];
    
    // Use the regular Set constructor to transform an Array into a Set
    const mySet = new Set(myArray);
    
    mySet.has("value1"); // returns true
    
    // Use the spread syntax to transform a set into an Array.
    console.log([...mySet]); // Will show you exactly the same Array as myArray
    
  • Bearded Vs. Clean Shaved: What’s The Right Choice For You?

    Some people look great with beard. Some look handsome when clean shaved. How do you know which one will make your more attractive?

    One way to figure out is to click pictures and compare your looks side-by-side. But what if there’s a guideline that you can simply lean to.

    Well, a study by Dixson outlines that when you’ve a well defined jawline, you can pull off with a clean shaven look. On the contrary, if a strong jawline isn’t your strength, you can look great with a full beard.

  • The 16/8 Eating Method: Why You Should Give it a Try

    What is 16/8 Eating Method?

    The 16/8 method, also known as intermittent fasting or Time Restricted Feeding (TRF), is a popular eating pattern that involves fasting for 16 hours each day and restricting eating to an 8-hour window. An ideal eating window shall be 11 AM to 7 PM. During the fasting window, you can consume water or black coffee (ideally, without sugar). However, you can get away with sugar as well.

    I’ve been following the 16/8 eating method since a few days. Sugar cravings have gone down. My energy levels stopped crashing too often unlike before.

    Benefits Of 16/8 Eating Method

    Weight loss: Thinking of reducing your body weight? Before you think of hitting the gym, consider the 16/8 eating method because you can significantly reduce your body weight just by restricting your feeding time.

    Cardiovascular health: TRF can effectively improve your cardiovascular healthy by reducing your blood pressure, cholesterol levels, and inflammation. (Effectiveness of Intermittent Fasting and Time-Restricted Feeding Compared to Continuous Energy Restriction for Weight Loss)

    Blood Sugar Regulation: TRF improves glucose tolerance and insulin sensitivity. Thereby, reducing type 2 diabetes. (Time-restricted feeding is a preventative and therapeutic intervention against diverse nutritional challenges)

    Cancer Therapy: When you increase the fasting window, your body attains Autophagy. Autophagy is a natural cellular process that occurs in the body, involving the degradation and recycling of unnecessary or dysfunctional cellular components. (The Roles of Autophagy in Cancer)

    If you are new to the 16/8 eating method, you should definitely give it a try. Your will love your body once you being to see you body transform into a new “you”.

    Today, I’m thankful to the Internet for allowing me to learn so much for FREE right from the comfort of my home.

  • Thirty Five

    No, today is not my birthday. But I will be celebrating it on September 2nd this year.

    Every time I play with my three-year-old son, I realize that I cannot keep up with his energy. For one, kids are obviously energetic. The other reason is that I’m not taking care of my body and health to keep up with the energy my kid demands.

    For almost three decades, I took little to no care of my body. I realized that the next three decades of my life will be much harder if I don’t take care of my health. I don’t know when I will take my last breath. No one does. But I like to be in my best health as long as I live. I assume you’d like to be too.

    Two weeks ago, the above realization struck my mind. Since then, I’ve made a few lifestyle changes that make me feel anew. And hence this post.

    Lifestyle Changes

    Glucose Goddess (Jessie) 10 core glucose hacks are what I’ve been following for the past couple of days. I can already see the benefits of keeping my glucose spikes to a minimum.

    I strongly recommend you listen to what Jessie has to say and implement what you see fit into your life. And you will thank me later.

    Starting this year, my wife and I emphasize and offer experiences to our kid rather than acquiring toys and other material possessions. We choose swimming sessions, dining out, and hiking over the next big car toy.

    It Is About Being And Not Having

    Until the last couple of weeks, I used to worry a lot about saving for retirement. But the summary of the book “Die With Zero” shifted my perspective. While it is still important to accumulate wealth for retirement, we must not forget to live life.

    You can be bedridden and wealthy. You can be healthy, on the pursuit of money, while living your life gathering memories. Choose what you want to be.

    Having the above understanding is quite important to steer the next three decades (God willing) of my life. I hope there was something as a takeaway for you from this blog post.

    Today, I express my gratitude to my parents and teachers whose inspiration has guided me to delve deeper into the philosophy of life. It is through their teachings that I’ve come to understand the importance of embracing knowledge and wisdom as I navigate the journey ahead.