Docker Vs Podman

Introduction

In this blog, we will dive into the world of containerization with a focus on two powerful tools: Docker and Podman. Containerization has revolutionized the way we develop, deploy, and manage applications, providing a lightweight and scalable approach. Let’s explore the intricacies of Docker and Podman and understand how they can benefit your projects.

Understanding Docker

Docker Overview: Docker is an open-source platform that enables developers to automate the deployment of applications inside containers. Containers are lightweight, isolated environments that package an application with its dependencies, making them portable and easy to deploy across different systems.

Features of Docker: Docker provides a range of powerful features that enhance the containerization experience. These include:

  • Efficient resource utilization
  • Isolation of applications
  • Easy scalability
  • Version control and image management
  • Networking capabilities

Docker Architecture: Docker follows a client-server architecture, where the Docker client communicates with the Docker daemon to build, run, and manage containers. The architecture consists of various components, including the Docker Engine, Docker Images, and Docker Hub, which is a repository for Docker images.

Exploring Podman

Podman Overview: Podman, on the other hand, is an alternative container engine that provides a similar experience to Docker but without the need for a daemon. It offers a daemonless and rootless container engine, making it ideal for environments where security and isolation are paramount.

Key Differences between Docker and Podman: While Docker and Podman share many similarities, there are a few key differences worth noting. Unlike Docker, Podman does not require a separate daemon, allowing users to run containers as non-root. Additionally, Podman utilizes the Container Runtime Interface (CRI) to interact with various container runtimes, providing flexibility and compatibility with different tools.

Benefits of Using Podman: Podman brings several benefits to the table, such as enhanced security, improved resource management, and simplified container management. With Podman, developers can enjoy the benefits of containerization without sacrificing security or needing root access.

Use Cases for Docker and Podman

Containerization in Development Environments: Docker and Podman are valuable tools for creating consistent development environments. By packaging applications and their dependencies into containers, developers can ensure that their code runs consistently across different machines, reducing the “it works on my machine” problem.

Container Orchestration: Both Docker and Podman excel in container orchestration, allowing developers to manage and scale containers across multiple hosts. Docker provides a robust solution with its native orchestrator, Docker Swarm, while Podman integrates seamlessly with popular orchestration platforms like Kubernetes.

Continuous Integration and Deployment: Docker and Podman play a crucial role in CI/CD pipelines, enabling developers to package applications into containers and deploy them efficiently. By encapsulating the application and its dependencies, containers simplify the deployment process and promote consistent and reliable software delivery.

Conclusion

In conclusion, Docker and Podman are powerful tools that have revolutionized the way we develop, deploy, and manage applications. While Docker remains the go-to choice for many, Podman offers a compelling alternative with its daemonless and rootless approach. Whether you choose Docker or Podman, containerization brings numerous benefits, such as improved scalability, portability, and security. Stay tuned for more exciting developments in the world of containerization!

Python – A Programing Language

Since the early 1990s, there has been a constant that is happening rapidly, at least on the consumer end. There were initially websites that were used. There were companies working on software on the outskirts. However, as the smartphone market grew, there was a lot going on. There was a lot of back and forth in order to automate the entire process of implementing and conceiving app features. App features that can provide recommendations based on acute data analysis are also available.

These systems could recommend products to you in the same way that your best friend could. Despite the fact that different programming languages were used for its implementation, Python became popular and is still one of the top contenders in the field of machine learning.

The language interpreters are available for a variety of operating systems. Python’s resources are managed and directed by a non-profit organisation known as the Python Software Foundation. Also, when we talk about development, it is done by a global community of developers. They maintain CPython, an open-source reference implementation of the Python programming language.

What are the reasons for its widespread acceptance?

👉 Simple to Use
Python syntax is quite simple, and Python has chosen to eliminate more trivial issues.
When compared to other languages, the language can save you a lot of lines. It is also highly effective and makes complex software development much easier.

👉 Broad Library and Framework Support
Python’s libraries and frameworks are one of the main reasons it is preferred over other languages. All of these can be used to help with development.

👉 Neural networks
It is a subset of machine learning with a distinct application. These learning systems are inspired by the brains of humans and animals. In this case, the machine learns by acquiring task-oriented rules. Image recognition is one of the best examples of this. Python provides a number of tools to assist you with this.

👉 Community and Support
There is no doubt that the language has strong support, as it is backed by one of the best tech companies, Google. Aside from that, there are numerous forums, websites, and video tutorials where Python is discussed and taught. This creates a much more welcoming environment in which the language can be taken seriously.

CBC Encryption and Decryption | What is CBC?

CBC

Cipher Block Chaining (significantly known as CBC) is a mode of encryption used in block ciphers. It is an advanced form of block cipher encryption and also more secured when compared to ECB. This mode uses a random block of bytes known as Initialization Vector (IV) to ensure randomization of encryption. It is important to use IV only once to ensure security.

Encryption:

CBC is one of the most popularly used mode of encryption in AES. Unlike in ECB mode, in CBC mode, encryption of one block of plaintext is dependent on the previous block. Each block of plaintext is XORed with the previous block of ciphertext, for the first block it is XORed with IV(16 bytes) and then sent through the whitebox. So, change in one single byte changes the entire ciphertext. Hence, eavesdropper can’t attack the data easily.

 C[i] = E(Pt[i]  ^ C[i-1])
 C[1] = E(Pt[i] ^ IV)

Advantages over CBC:

Dependency of one block encryption over the previous one ensures that traces of similar data aren’t left behind, whereas in ECB, change in a byte changes only the corresponding block i.e encrypting 2 blocks that contain same plaintext gives the same ciphertext in ECB. This gives a pattern to the attacker whereas in CBC this doesn’t happen.

Decryption:

Decryption is just the reverse. Each block of ciphertext is sent through the whitebox and then XORed with the previous block of ciphertext to recover the plaintext. So, one need not decrypt the previous block to get the required block of plaintext.

Pt[i] = D(C[i]) ^ C[i-1]
Pt[1] = D(C[1]) ^ IV

Attacks possible:

IV reusing might lead to leakage of information regarding the first block of plaintext. However the rest are unaffected. It is also vulnerable to attacks like bit flipping attack, padding oracle attack etc.

ECB Encryption and Decryption | What is ECB?

ECB

What is ECB?

Electronic Code Book (or ECB) mode of encryption is the simplest of all the modes of encryption. This mode of encryption is the first one which was implemented under AES. But, later we’ll analyze the plus and the minus features of this mode because of which it’s popularity is reduced. Now, we’ll see how is ECB mode of encryption is applied to any of the above described data encryption algorithm.

How is the encryption done?

In this mode of encryption the plain text is divided into different blocks of equal block sizes. Then each block is encrypted in parallel.

As you can see the different blocks of the plain text are encrypted separately using any of the algorithms described above (Like AES, DES) The parallel encryption of each block is the basic essence of the ECB mode.

How is decryption done?

Similar to the encryption the cipher text is divided into different blocks depending upon the block size. Thus, decryption is done on each block, at the same time, using the algorithm with which it was encrypted.

Advantages of ECB

The advantage of ECB mode of encryption over others is that here each block is encrypted separately. Therefore, if any of the block goes corrupted it doesn’t affect the rest of the encryption. Also, because of this feature a multiprocessor can simultaneously encrypt different blocks thus saving time.

Disadvantages of ECB

The main disadvantage of ECB is that the similar part of the plain text are encrypted with the same key to the same cipher text. That is, if in block 1 the plain text character ‘e’ is encrypted as ‘f’ in block 2 also if there’s ‘e’ in the plain text it would be encrypted as ‘f’. Also, the blocks of cipher text can be rearranged which when decrypted would give deranged output which is undesirable.

Vulnerabilities of ECB

The most common attack on ECB is the “ECB byte at a time attack” which exploits the loophole in ECB encryption which would give the same cipher text when applied to the similar characters of plain text.

Manage IoT Sensor Network with ISTSOS (Open Source)

IstSOS is Free and Open Source Sensor Observation Service Data Management System (OGC SOS server implementation) written in Python. istSOS allows for managing and dispatch observations from monitoring sensors according to the Sensor Observation Service standard. It provides a Graphical user Interface that allows for easing the daily operations and a RESTFull Web api for automatizing administration procedures. istSOS is released under the GPL License, and runs on all major platforms (Windows, Linux, Mac OS X), even though it has been used in production in linux environment only.

Main Features

  • Offer your data according to the Sensor Observation Service standard from Open Geospatial Consortium.
  • Administer your sensors and your data with a comfortable interface.
  • Use a complete API for accessing functionalities to makes it easy for new clients to use istSOS application.
  • Get notified trough mail, twitter or other social when your sensor data met specific conditions.

How to Install (On Ubuntu 18.04)

Installation on Linux with the Debian package

The easiest way to install istSOS on a Debian distribution is to use the istSOS deb packages.

Download the debian file from the repository

Please go to https://sourceforge.net/projects/istsos/files to get the latest release.

Install the debian file

Open a terminal and move to the folder containing the downloaded deb file.

sudo dpkg -i python3-istsos_2.4.0-RC4.deb;sudo apt-get -f -y install

This command will install all the required dependencies, with the exception of PostgreSQL and PostGIS. In fact it could reside on other servers.

If everything has gone well, you should see the administration page at this address: http://localhost/istsos/admin/

NodeMCU ESP8266 Over The Air (OTA) Programming In Arduino IDE

A fantastic feature of any WiFi-enabled microcontroller like ESP8266 NodeMCU is the ability to update its firmware wirelessly. This is known as Over-The-Air (OTA) programming.

The OTA programming allows updating/uploading a new program to ESP8266 using Wi-Fi instead of requiring the user to connect the ESP8266 to a computer via USB to perform the update.

OTA functionality is extremely useful in case of no physical access to the ESP module. It helps reduce the amount of time spent for updating each ESP module at the time of maintenance.

One important feature of OTA is that one central location can send an update to multiple ESPs sharing same network.

The only disadvantage is that you have to add an extra code for OTA with every sketch you upload, so that you’re able to use OTA in the next update.

The factory image in ESP8266 doesn’t have an OTA Upgrade capability. So, you need to load the OTA firmware on the ESP8266 through serial interface first.

It’s a mandatory step to initially update the firmware, so that you’re able to do the next updates/uploads over-the-air.

The ESP8266 add-on for the Arduino IDE comes with a OTA library & BasicOTA example. You can access it through File > Examples > ArduinoOTA > BasicOTA.

The following code should load. But, before you head for uploading the sketch, you need to make some changes to make it work for you. You need to modify the following two variables with your network credentials, so that ESP8266 can establish a connection with existing network.

const char* ssid = "..........";
const char* password = "..........";

Once you are done, go ahead and upload the sketch.

 

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "..........";
const char* password = "..........";

void setup() {
  Serial.begin(115200);
  Serial.println("Booting NodeMCU");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Sorry, Connection Failed! Rebooting NodeMCU...");
    delay(5000);
    ESP.restart();
  }
  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else 
      type = "filesystem";

    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connecting Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receiving Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();
}

Now, open the Serial Monitor at a baud rate of 115200. And press the RST button on ESP8266. If everything is OK, it will output the dynamic IP address obtained from your router. Note it down.

Upload New Sketch Over-The-Air

Now, let’s upload a new sketch over-the-air.

Remember! you need to add the code for OTA in every sketch you upload. Otherwise, you’ll loose OTA capability and will not be able to do next uploads over-the-air. So, it’s recommended to modify the above code to include your new code.

As an example we will include a simple Blink sketch in the Basic OTA code. Remember to modify the SSID and password variables with your network credentials.

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "..........";
const char* password = "..........";

//variabls for blinking an LED with Millis
const int led = D0; // ESP8266 Pin to which onboard LED is connected
unsigned long previousMillis = 0;  // will store last time LED was updated
const long interval = 1000;  // interval at which to blink (milliseconds)
int ledState = LOW;  // ledState used to set the LED
void setup() {
pinMode(led, OUTPUT);
    
  Serial.begin(115200);
  Serial.println("Booting NodeMCU");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting NodeMCU...");
    delay(5000);
    ESP.restart();
  }
  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else
      type = "filesystem";

    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connecting Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receiving Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {

  previousMillis = currentMillis;
  ledState = not(ledState);
  digitalWrite(led,  ledState);
  }
}

Once you copy above sketch to your Arduino IDE, go to Tools > Port option and you should see something like this: esp8266-xxxxxx at your_esp_ip_address If you can’t find it, you may need to restart your IDE.

Select the port and click Upload button. Within a few seconds, the new sketch will be uploaded. And you should see the on-board LED blinking.

Toroidal Transformers

Transformers are made from a pair of solenoids wrapped around a metal core that is usually a ferrite. Toroidal transformers are two coils wrapped around a metal, such as a ferrite or silicon steel, that is doughnut shaped. The coils are either wrapped in different areas or placed one over the other. They are preferred for RF or radio frequency transformers, where they are used to increase or decrease voltages from power sources, and to isolate different parts in a circuit. RF transformers are also used for impedance matching, which means they help connect input and output parts of different circuits.

Here are five other reasons why toroidal transformers are used for many industrial applications:

  1. Low noise and low stray field – The field generated by magnetization, also known as the stray field, is lower in a toroidal transformer, due to the uniform core windings. Less magnetic interference in toroids results in higher performance.

  2. Easy to mount – Using just one screw, toroidal transformers can be easily mounted in a short time. This convenience helps limit maintenance and downtime.

  3. Low operating temperature – Toroidal transformers operate at lower temperatures than transformers with similar specifications.

  4. Light weight core – The core of a toroidal transformer weighs less than typical transformers due to it being comprised of less raw materials.

  5. More economical – Since toroidal transformer cores are manufactured from fewer materials, they weigh less than conventional transformers and use less energy, providing better cost savings and higher return on investment.

The toroidal transformers efficiency makes them useful for a wide array of machines such as audio/visual equipment, security systems, telecommunication systems, industrial control equipment and power distribution equipment. Cost efficiency is an important key to the widespread use of toroidal transformers, as well as the fact that they can be customized for any diameter and height.

Salt Water Batteries

Saltwater batteries are not similar to lithium-ion batteries or lead acid batteries for use in portable devices or any automobiles. This is because they can’t hold as much charge in the same size and weight, or putting it another way, they are less energy-dense. But they hold some powerful advantages in applications in which size and weight are less important.

The electrolyte for a saltwater battery is nothing more than — salt water — hence the device’s name comes from it. The anode can be carbon, and the cathode can be a material such as manganese oxide. (Or anode can be copper and cathode can be zinc or aluminum).

With no hazardous materials in their construction, unlike lithium-ion batteries, they are non-toxic and they cannot explode. There is no need for the complex and troublesome electronic circuitry that every lithium-ion battery needs to ensure that they charge and discharge only within safe parameters. In addition, unlike their lithium-based cousins, saltwater batteries can be more deeply discharged (drained of electrical energy) with no damage to the battery.

The biggest disadvantage of all forms of salt-water batteries is that, to store a given amount of electricity, they are bulkier and heavier than other commercially available batteries. As it turns out, there is one huge potential use for these devices in which that will be no issue at all — smoothing out power from large-scale renewable-energy-generation plants.

Get selected location’s coordinates using Google’s Javascript API

To get the coordinates from a selected location on the map (Latitude and Longitude) to input fields, we can use Google’s Javascript MAP API. Here i have used a search field to search locations by name. Therefor i had to use Places API too.

How it works

I have used simple Bootstrap4 html page to place map. According to the Google’s documentation guide we can use below Javascript codes to get selected location’s coordinates in to two input fields at the bottom.

 

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAcr__t5RD7E40Yz6rgEVHQOAI4kcsMrIA&libraries=places&callback=initialize" async defer></script>
<script>
function initialize() {
	var myLatlng = new google.maps.LatLng(7.873053999999999,80.77179699999999);
	var myOptions = {
		zoom: 8,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	var map = new google.maps.Map(document.getElementById('map-canvas'), myOptions);

	// Create the search box and link it to the UI element.
	var input = document.getElementById('pac-input');
	var searchBox = new google.maps.places.SearchBox(input);
	map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);

	var marker = new google.maps.Marker({
		draggable:true,
		position: myLatlng,
		map: map
	});

	// Bias the SearchBox results towards current map's viewport.
	map.addListener('bounds_changed', function() {
		searchBox.setBounds(map.getBounds());
	});

	google.maps.event.addListener(marker, 'dragend', function (event) {
		var poiLat = this.getPosition().lat();
		var poiLon = this.getPosition().lng();
		$('#latitude').val(poiLat);
		$('#longitude').val(poiLon);
	});

	var markers = [];
	// Listen for the event fired when the user selects a prediction and retrieve
	// more details for that place.
	searchBox.addListener('places_changed', function() {
		var places = searchBox.getPlaces();

		if (places.length == 0) {
			return;
		}

		// Clear out the old markers.
		markers.forEach(function(marker) {
			marker.setMap(null);
		});
		markers = [];

		// For each place, get the icon, name and location.
		var bounds = new google.maps.LatLngBounds();
		places.forEach(function(place) {
			if (!place.geometry) {
				console.log("Returned place contains no geometry");
				return;
			}

			var icon = {
				url: place.icon,
				size: new google.maps.Size(71, 71),
				origin: new google.maps.Point(0, 0),
				anchor: new google.maps.Point(17, 34),
				scaledSize: new google.maps.Size(25, 25)
			};

			// Create a marker for each place.
			marker.setPosition( place.geometry.location );
			map.panTo( place.geometry.location );
			$('#latitude').val(place.geometry.location.lat());
			$('#longitude').val(place.geometry.location.lng());

			if (place.geometry.viewport) {
			// Only geocodes have viewport.
				bounds.union(place.geometry.viewport);
			} else {
				bounds.extend(place.geometry.location);
			}
		});

		map.fitBounds(bounds);
	});
}

</script>

Here is the final output.

You can download the source code from my Github: https://github.com/lahirutm/Get-coordinates-using-Google-s-Javascript-API