Cogito ergo sum

Latest stories

How to check/uncheck all checkboxes on a web page using vanilla Javascript

A couple of years ago I wrote this short post about checking/selecting all checkboxes on a web page using jQuery. However, how would we do that if we can’t included jQuery on the page or if we want to do it only with Javascript! To uncheck all checked checkboxes on a web page using only Javascript: document.querySelectorAll("input[type='checkbox']:checked").forEach((element) => { element...

How to trigger a specific code after a new product is created via WooCommerce REST API

I ran yesterday into a situation where I needed WordPress to perform a specific action after a product is inserted into WooCommerce database using the REST API endpoint POST /wp-json/wc/v3/products I have searched online for a couple of hours and I found multiple solutions, but non of them worked in my case. Almost all of them work fine when you add a product from within the WordPress backend...

How to make Windows the default OS to boot into instead of Ubuntu Linux on a computer with dual-boot

Like many developers, I run Windows 10 alongside Ubuntu 20.04. I use both of them regularly, but I use Windows most of the time since I work with a couple of programs that are only available on Windows. When I boot up my computer, the following screen is being displayed on the monitor. As you can see , Ubuntu is the default boot option. If I don’t touch the keyboard (moving the arrow keys...

How to reduce the size of wp_icl_strings table in my wordpress database

Just like a lot of WordPress users, I use for a client WPML to make the website multilingual. The plugin is a magical plugin, and it enables you to translate everything on your website. To make the translation process more easier for the user, WPML just tracks down every single added string to the database, which is not always necessary. This tracking leads to huge database usage and an...

How to install TP-Link Archer T2U mini wireless adapter on Ubuntu 20.04

I haven’t had  a PC for the last 10 years. I’ve always used laptops because it’s much easier and they give you freedom to work everywhere without almost no limitation except the battery life. Last week, I got a PC, and I have installed it in my workroom where I work, study and make music (I have been working from home just like everyone else in the world since the outbreak of...

How to perform SQL queries with WooCommerce?

This post will be updated regularly. This is a work in progress 🙂 DISCLAIMER: Maybe the title is a bit misleading, but this blog post is meant to be as a reference for people just like me who are forced to google everytime how to get a or to manipulate product, product category and all other stuff related to WooCommerce using SQL. Some useful SQL queries to fetch/edit data in your WP database...

How to speed up Vagrant on Windows 10 using NFS

Background At work (FlexKids) I have a Windows 10 machine (at home I use both Ubuntu and Windows). We don’t only Windows, we use OSX and Linux as well. To overcome this (not the only reason) we use Vagrant, Virtual box (CentOs 7) as a development environment. Thus we can ensure we all have the same dev-env. All OSX users in my team don’t experience any performance issues, while I and...

How to use Fabric to deploy a flask web application

Lately, I have been busy making a deploy script for a Flask API. I have never worked before with Flask and I just got to know Flask a couple of months ago. I have to admit, there are not a lot of resources online explaining how to work exactly with Fabric. Although, the website of fabric (fabfile) has good and detailed documentation, some idea’s aren’t documented or explained quite...

How to save a base64 encoded image on hard disk in Python

In some cases you receive an image as bas64 encoded string and you need to save it first on disk before you can reopen it and use it!
First of all you have to import base64 package.
import base64
decoded_image= base64.b64decode(YOUR_BASE64_ENCODED_IMAGE)
with open('your_image.jpg', 'wb') as f:
f.write(decoded_image)
YOUR_BASE64_ENCODED_IMAGE is the base64 encoded string of the image.

Cogito ergo sum