Coding

Ever since I advanced beyond the “hello worlds” of Java, I had never stopped coding. This section is for documenting code usages that I had employed while solving the technological problems that I had encountered.

How to detect keyboard presses made to the browser screen with JavaScript

When you are building a browser-based game, being able to track key presses is helpful.

For this purpose, you can register a JavaScript function that gets called when the browser detects a key is being pressed.

After the browser detects a key press, it will send information about the key to your function.

When your function is able to get the key that is pressed, it can then use this information to update the game state.

In this post, let’s look at how we can detect keyboard presses made to the browser screen with JavaScript.

How to control a SG90 servo motor with the ESP8266 NodeMCU LUA Development Board

When you are looking to operate remote-controlled or radio-controlled toy cars, robots and airplanes, you will need to use servo motors.

Since the ESP8266 NodeMCU LUA Development Board is cost efficient for IOT solutions, it can be used for controlling servo motors.

So how can we control a servo motor with the ESP8266 NodeMCU LUA Development Board?

This post discusses how we can control the SG90 servo motor, with the ESP8266 NodeMCU LUA Development Board.

Getting the environment variables supplied to your Cloud Foundry application with Python 3 Flask

When I was trying to build a Python 3 Flask application on Cloud Foundry, I wanted to quickly check the environment variables that Cloud Foundry will supply to my application.

As a result of that, I created a Python 3 Flask application that will probe the environment variables that it receives from Cloud Foundry.

This post lists the files that constitute that Python 3 Flask application.

How to download a file via HTTP GET and HTTP POST in Java without using any external libraries

Apart from uploading a file to a HTTP server endpoint, another common task for a Java HTTP client is to download a file from a HTTP server. Even though there are many Java external libraries to help us do so, using the facilities in the Java standard runtime installation is not difficult. Furthermore, we will be able to keep our Java application leaner if we can download files without additional dependencies.

In case you need a reference, this is how to download a file via HTTP GET and HTTP POST in Java without using any external libraries.

How to send an HTTP request to a HTTP Basic Authentication endpoint in Python 3 with requests library

When you are building a Python 3 application for the Internet, you could encounter API endpoints that use HTTP Basic Authentication as the authentication mechanism.

In such a situation, using the requests library in your Python 3 code makes it easier to communicate with those endpoints.

In case you need to build a Python 3 application that sends HTTP request to a HTTP Basic Authentication endpoint, this is how you can do so with the requests library.

How to download a file via HTTP POST and HTTP GET with Python 3 requests library

When you are building a HTTP client with Python 3, you could be coding it to upload a file to a HTTP server or download a file from a HTTP server.

Previously, we discussed how to upload a file and some data through HTTP multipart in Python 3 using the requests library. In this post, let’s see how we can download a file via HTTP POST and HTTP GET.

How to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request

When you build an API endpoint that serves HTTP requests to work on long-running tasks, consider using a scheduler. Instead of holding up a HTTP client until a task is completed, you can return an identifier for the client to query the task status later. In the meantime, your HTTP server can offload the task to a scheduler which will complete it and update the status.

When you are building your HTTP server with Python 3 Flask, Flask-APScheduler gives you the facilities to schedule tasks to be executed in the background.

In this post, we look at how we can get Flask-APScheduler to run multiple tasks in parallel, from a single HTTP request.

How to use Java to check whether a domain exists without any external libraries

You wanted to buy a domain for your personal website. You found a whois service and it told you that your domain is available. You are elated and tried to acquire the domain through your favourite registrar. However, your registrar told you that the domain had already been taken.

Isn’t that frustrating? Well, it happened to me once and I was determined never to use the whois service of those unscrupulous sites ever again.

So how can you check whether a domain name is available by yourself? When you have a computer at hand, you can find several ways to do so. In this post, I share how you can check whether a domain exists with the Java programming without using any external libraries.