WordPress: Disable REST API – Restrict Access

According to the official WordPress recommendations you should not disable the WordPress REST API as this will break the “WordPress Admin” functionality.

For example, the WordPress Block Editor requires the WordPress REST API and if you disable it you won’t be able to publish or update your posts anymore.

However, you can use a filter to require that API consumers be authenticated, which effectively prevents anonymous external access. (more…)

WordPress: Enable REST API (rest_disabled: 401/403)

The WordPress REST API has become a part of the WordPress core starting from the version 4.7.

It is, for example, required by the WordPress Block Editor, and if the WordPress REST API is disabled, you won’t be able to publish or update your posts: “Updating failed. REST API disabled.“.

Normally, the WordPress REST API should be enabled by default and doesn’t require installation of any additional plugins for this.

If the WordPress REST API on your website is still disabled this may be caused by the “W3 Total Cache” plugin (if it is installed and active).

This note shows how to enable the WordPress REST API if it has been disabled by the “W3 Total Cache”. (more…)

WordPress: Auto-Post to Telegram Channel (No Plugin)

You can easily increase visitor traffic to your WordPress website by integrating it with a Telegram channel.

However, manually sharing every blog post to the Telegram channel can become a time-consuming task – especially if you publish an article every day.

In this note i will show how to create a callback function that will automatically publish new posts from your WordPress website to the Telegram channel without any plugins. (more…)

Python Requests ‘User-Agent’ – Web Scraping

A ‘User-Agent’ HTTP request header is a string that a web browser is sending to a web server along with each request to identify itself.

The ‘User-Agent’ string contains information about which browser is being used, what version and on which operating system.

Some websites block access from non-web browser ‘User-Agents’ to prevent web scraping, including from the default Python’s requests ‘User-Agent’.

In this note i will show how to set the ‘User-Agent’ HTTP request header while using the Python’s requests library. (more…)

Indexed by Google: Pages Checker on Python

To check if a webpage has been indexed by Google, you can manually search for site:<webpage> in a Google Search, for example: site:https://www.shellhacks.com/indexed-by-google-pages-checker-on-python.

If the page is indexed by Google, you will see the URL in the result of the Google Search, otherwise you will see the message as follows:

Your search – site:https://www.shellhacks.com/indexed-by-google-pages-checker-on-python – did not match any documents.

If you need to check multiple pages, it will be much more efficient to create a Python script for checking the pages indexed by Google.

This note shows an example of the minimal Python script for checking the pages indexed by Google, that can be used as a base and improved according to your needs. (more…)

Windows: `lsusb` Equivalent – PowerShell

The lsusb command in Linux, known as the “List USB” command, is widely used to list the connected USB devices and display the information about them.

One of the quickest ways to list the connected USB devices in Windows is by using the “Device Manger”: simply press the ⊞ Win key to open the “Start Menu” and type “device manager” to search for the app.

You can also open the “Device Manager” through the “Run” dialog, by pressing the ⊞ Win + R and executing the devmgmt.msc command.

Although there is no direct equivalent to the lsusb command in Windows, you can use the PowerShell’s Get-PnpDevice command to list the connected USB devices and display the information about them. (more…)

Arduino: Change Device’s VID/PID/Name

Vendor IDs (VID) and product IDs (PID) are 16-bit numbers used to identify USB devices.

By these numbers a computer identifies what USB device is plugged in and what drivers to use with it.

If you are developing for example some Arduino-based USB HID keyboard, you may want to change the device’s VID/PID and the name, so the computer or any other host identifies and displays it as a standard keyboard.

In this note i will show how to change the VID/PID and the name of the Arduino-based device on the example of the Arduino Pro Micro. (more…)

Arduino: /dev/ttyACM0 – Permission Denied [SOLVED]

If you use an Arduino IDE on Linux (e.g. Ubuntu, Linux Mint, etc.), you may get the following errors while trying to upload a sketch to the Arduino broad:

Caused by: processing.app.SerialException: Error touching serial port ‘/dev/ttyACM0’.
– and –
Caused by: jssc.SerialPortException: Port name – /dev/ttyACM0; Method name – openPort(); Exception type – Permission denied.

In this note i am showing how to permanently fix the “Permission denied” error on the serial port /dev/ttyACM0 while uploading the Arduino sketch. (more…)