<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Siva</title>
    <description>The latest articles on DEV Community by Siva (@byteshiva).</description>
    <link>https://dev.to/byteshiva</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F50541%2Fefca6bd4-1a4c-4942-a2a2-260e8e38fa40.jpeg</url>
      <title>DEV Community: Siva</title>
      <link>https://dev.to/byteshiva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/byteshiva"/>
    <language>en</language>
    <item>
      <title>Maximizing Productivity with TigerVNC: A Guide to Remote Desktop Solutions</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Sat, 06 May 2023 04:36:59 +0000</pubDate>
      <link>https://dev.to/byteshiva/maximizing-productivity-with-tigervnc-a-guide-to-remote-desktop-solutions-576n</link>
      <guid>https://dev.to/byteshiva/maximizing-productivity-with-tigervnc-a-guide-to-remote-desktop-solutions-576n</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;TigerVNC is a popular open-source remote desktop software suite that allows users to remotely access graphical desktop environments on Linux and other UNIX-like operating systems. With TigerVNC, users can remotely connect to a server and use its graphical interface as if they were physically present at the machine. In this tutorial, we'll walk through how to use TigerVNC to connect to a remote machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;To follow along with this tutorial, you'll need the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A remote machine running a Linux or UNIX-like operating system
&lt;/li&gt;
&lt;li&gt;TigerVNC installed on the remote machine
&lt;/li&gt;
&lt;li&gt;A client machine running TigerVNC or a compatible VNC viewer application&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1: Configuring TigerVNC on the Remote Machine
&lt;/h3&gt;

&lt;p&gt;Before you can connect to the remote machine, you'll need to configure TigerVNC on the remote machine to accept incoming connections. To do this, you'll need to edit the xstartup file in your user's VNC configuration directory. This file is used to specify which desktop environment and other settings should be used when a new VNC session is started.&lt;/p&gt;

&lt;p&gt;To edit the xstartup file, open a terminal on the remote machine and enter the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ nano ~/.vnc/xstartup 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open the xstartup file in the Nano text editor. By default, this file is empty, so you'll need to add some configuration settings to it.&lt;/p&gt;

&lt;p&gt;For example, if you want to use the default Xfce desktop environment, you can add the following lines to the xstartup file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the xstartup file by pressing Ctrl+X, then Y, then Enter.&lt;/p&gt;

&lt;p&gt;Next, you'll need to set a password for your VNC session. You can do this by running the vncpasswd command and entering a password when prompted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vncpasswd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Starting TigerVNC on the Remote Machine
&lt;/h3&gt;

&lt;p&gt;To start a VNC server on the remote machine, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vncserver -localhost no :1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start a new VNC session on display :1 and allow connections from remote machines. If this is your first time starting TigerVNC on the remote machine, you'll be prompted to enter a password that you'll use to connect to the session.&lt;/p&gt;

&lt;p&gt;Once the VNC server is running, you'll see output similar to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New 'X' desktop is example.com:1
Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/example.com:1.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make note of the display number (:1 in this case), as you'll need it to connect to the session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Connecting to the Remote Machine
&lt;/h3&gt;

&lt;p&gt;On your client machine, start the TigerVNC viewer application or a compatible VNC viewer application. In the connection dialog, enter the IP address or hostname of the remote machine and the display number of the VNC session you want to connect to (in our example, example.com:1).&lt;/p&gt;

&lt;p&gt;If prompted, enter the password you set earlier when configuring TigerVNC on the remote machine.&lt;/p&gt;

&lt;p&gt;Once connected, you should see the desktop environment of the remote machine on your local machine. You can now use your mouse and keyboard to interact with the desktop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this tutorial, we've learned how to use TigerVNC to remotely connect to a Linux or UNIX-like machine. By following the steps outlined above, you should now be able to start a VNC server on a remote machine and connect to it from a client machine running a VNC viewer application.&lt;/p&gt;

&lt;p&gt;Remote desktop solutions like TigerVNC are particularly useful for system administrators and developers who need to remotely access graphical desktop environments on servers or other remote machines. With TigerVNC, it's easy to connect to a remote machine and work with its graphical interface as if you were physically present at the machine.&lt;/p&gt;

&lt;p&gt;As with any remote access solution, it's important to take security into account when using TigerVNC. Be sure to use strong passwords and keep your software up-to-date to avoid vulnerabilities that could be exploited by attackers.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>remotedesktop</category>
      <category>tigervnc</category>
      <category>remotework</category>
    </item>
    <item>
      <title>Understanding Overlay Networks and How They Compare with Tailscale</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Thu, 27 Apr 2023 15:19:10 +0000</pubDate>
      <link>https://dev.to/byteshiva/understanding-overlay-networks-and-how-they-compare-with-tailscale-1d1b</link>
      <guid>https://dev.to/byteshiva/understanding-overlay-networks-and-how-they-compare-with-tailscale-1d1b</guid>
      <description>&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;In today’s world, with the increasing number of remote workers and cloud services, networking has become an essential part of our lives. One of the popular networking concepts is overlay networks, which provide an abstraction layer over the underlying network. In this article, we will explore the concept of overlay networks and how they compare with Tailscale, a popular VPN solution. We will also look at how exit nodes work in Tailscale.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an Overlay Network?
&lt;/h3&gt;

&lt;p&gt;An overlay network is a virtual network built on top of an existing network, allowing multiple devices or services to communicate with each other as if they are connected to the same local network. It is often used to provide network services such as load balancing, service discovery, and security.&lt;/p&gt;

&lt;p&gt;Overlay networks use various technologies such as Virtual Private Networks (VPNs), Network Address Translation (NAT), and Software-Defined Networking (SDN) to create the virtual network. In an overlay network, the communication between the devices or services is encapsulated, and the data packets are transmitted through the underlying network.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Does Tailscale Compare with Overlay Networks?
&lt;/h3&gt;

&lt;p&gt;Tailscale is a popular VPN solution that provides secure networking for remote workers and teams. It uses an overlay network to connect devices securely, making it a suitable replacement for traditional VPNs. However, there are some differences between Tailscale and traditional overlay networks.&lt;/p&gt;

&lt;p&gt;Tailscale provides a simple and easy-to-use interface that allows users to set up secure connections between their devices without any configuration. It uses a peer-to-peer network topology, where all devices are connected to each other, and there is no need for a centralized server. In contrast, traditional overlay networks often use a client-server architecture, where a central server mediates the communication between the devices.&lt;/p&gt;

&lt;p&gt;Tailscale also provides additional security features such as encryption and access control, making it suitable for enterprises and teams. It uses WireGuard, a modern and secure VPN protocol that provides faster and more reliable connections than traditional VPNs. In contrast, traditional overlay networks often use OpenVPN, an older and less secure VPN protocol.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Do Exit Nodes Work in Tailscale?
&lt;/h3&gt;

&lt;p&gt;Exit nodes are a crucial part of Tailscale’s network architecture. They allow devices connected to the Tailscale network to access the Internet securely without revealing their IP addresses. When a device connected to Tailscale wants to access the Internet, the traffic is routed through an exit node, which then forwards the traffic to the destination.&lt;/p&gt;

&lt;p&gt;Tailscale provides exit nodes in various regions around the world, allowing users to choose the most suitable exit node for their needs. The exit nodes are hosted by Tailscale, and the traffic is encrypted end-to-end, ensuring that it cannot be intercepted or tampered with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;Overlay networks are a powerful concept that provides an abstraction layer over the underlying network, allowing multiple devices or services to communicate with each other securely. Tailscale is a popular VPN solution that uses an overlay network to provide secure networking for remote workers and teams.&lt;/p&gt;

&lt;p&gt;It provides a simple and easy-to-use interface, additional security features, and exit nodes that allow devices to access the Internet securely. By understanding overlay networks and how they compare with Tailscale, you can choose the right networking solution for your needs.&lt;/p&gt;

&lt;p&gt;Useful Links:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://tailscale.com/"&gt;https://tailscale.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>networking</category>
      <category>exitnode</category>
      <category>vpn</category>
      <category>overlaynetwork</category>
    </item>
    <item>
      <title>How to Create an Init Script for Tailscaled in Linux</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Wed, 26 Apr 2023 14:13:11 +0000</pubDate>
      <link>https://dev.to/byteshiva/how-to-create-an-init-script-for-tailscaled-in-linux-3lk2</link>
      <guid>https://dev.to/byteshiva/how-to-create-an-init-script-for-tailscaled-in-linux-3lk2</guid>
      <description>&lt;p&gt;If you are using a Linux distribution that does not use Systemd, you may need to create an init script to manage Tailscaled, the network daemon for the Tailscale VPN.&lt;/p&gt;

&lt;p&gt;Here are the steps to create an init script for Tailscaled:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1:
&lt;/h3&gt;

&lt;p&gt;Determine the location of the Tailscaled binary The Tailscaled binary is typically installed in /usr/bin/tailscaled. Use the which command to determine the location of the tailscaled binary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;which tailscaled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If tailscaled is not in your PATH, you may need to provide the full path to the binary in your init script.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2:
&lt;/h3&gt;

&lt;p&gt;Create the init script Create a new file in the /etc/init.d directory with a name that reflects the purpose of the script. In this case, tailscaled would be a good name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/init.d/tailscaled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following script to the tailscaled file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh
### BEGIN INIT INFO
# Provides: tailscaled
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tailscaled daemon
# Description: tailscaled daemon
### END INIT INFO

DAEMON=/sbin/tailscaled
PIDFILE=/var/run/tailscaled.pid
USER=tailscale
GROUP=tailscale
test -x $DAEMON || exit 0
case "$1" in
  start)
    echo "Starting Tailscaled"
    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --chuid $USER:$GROUP --startas $DAEMON -- start
    ;;
  stop)
    echo "Stopping Tailscaled"
    start-stop-daemon --stop --pidfile $PIDFILE --retry 10
    ;;
  *)
    echo "Usage: /etc/init.d/tailscaled {start|stop}"
    exit 1
    ;;
esac
exit 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script provides basic functionality for starting and stopping tailscaled. You may need to modify it based on your specific needs, such as adding command-line arguments to tailscaled or changing the user and group that the daemon runs under.&lt;/p&gt;

&lt;p&gt;Save the file and exit the text editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3:
&lt;/h3&gt;

&lt;p&gt;Make the init script executable Make the tailscaled init script executable with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chmod +x /etc/init.d/tailscaled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4:
&lt;/h3&gt;

&lt;p&gt;Test the init script Test the init script by starting and stopping tailscaled with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo /etc/init.d/tailscaled start
sudo /etc/init.d/tailscaled stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5:
&lt;/h3&gt;

&lt;p&gt;Configure the init script to start automatically Configure the tailscaled init script to start automatically on system boot with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo update-rc.d tailscaled defaults
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create the necessary symlinks in the /etc/rc?.d directories to start tailscaled during the boot process.&lt;/p&gt;

&lt;p&gt;You now have an init script for tailscaled that can be used on Linux distributions that do not use Systemd.&lt;/p&gt;

</description>
      <category>initscript</category>
      <category>linux</category>
      <category>networkingsecurity</category>
      <category>tailscale</category>
    </item>
    <item>
      <title>Reversing a Linked List: A Hallway Analogy</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Sun, 23 Apr 2023 14:57:21 +0000</pubDate>
      <link>https://dev.to/byteshiva/reversing-a-linked-list-a-hallway-analogy-ipf</link>
      <guid>https://dev.to/byteshiva/reversing-a-linked-list-a-hallway-analogy-ipf</guid>
      <description>&lt;p&gt;Imagine that you are walking through a hallway that has several doors on either side. Each door has a name written on it, and each name is related to the one next to it in some way. You are holding a piece of paper that has the names of all the doors in the hallway, but they are in the wrong order.&lt;/p&gt;

&lt;p&gt;As you walk down the hallway, you start to feel frustrated because you are not sure which door to go through next. Suddenly, you remember that you can use the paper to help you figure out the correct order of the doors.&lt;/p&gt;

&lt;p&gt;You start at the end of the hallway, and look at the last name on the paper. You walk through the door with that name on it, and then look at the name on the previous line of the paper. You walk through the door with that name on it, and repeat the process until you reach the beginning of the hallway.&lt;/p&gt;

&lt;p&gt;As you walk through each door, you cross it off on the paper to keep track of where you have been. When you reach the end of the hallway, you realize that you have successfully reversed the order of the doors!&lt;/p&gt;

&lt;p&gt;In programming terms, the paper with the names is like a linked list, where each name is a node in the list that points to the next node. Reversing the linked list involves changing the pointers so that each node points to the previous node, instead of the next node. The hallway with the doors is just a visual representation of the linked list, where each door corresponds to a node in the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;linkedlist.jl&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module LinkedList

  export Person, reverse_list

  mutable struct Person
      name::String
      next::Union{Person, Nothing}
  end

  function reverse_hallway(person::Person)
      current_orig = person
      previous = nothing
      while current_orig != nothing
          next_person = current_orig.next
          current_orig.next = previous
          previous = current_orig
          current_orig = next_person
      end
      return previous
  end

end # end of module
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;main.jl&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;include("linkedlist.jl")

using .LinkedList: Person, reverse_hallway

# example linked list of people
person4 = Person("Alice", nothing)
person3 = Person("Bob", person4)
person2 = Person("Charlie", person3)
person1 = Person("Dave", person2)

function printoriginal_order(person1) 
  current = person1
  while current != nothing
    println(current.name)
    current = current.next
  end
end

function print_reverse_order(person1) 
  person1 = reverse_hallway(person1)
    # print new order
  current = person1
  while current != nothing
      println(current.name)
      current = current.next
  end
end

printoriginal_order(person1)
println("---")
print_reverse_order(person1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Demo — Code Walkthrough&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/824c9cb1a26e885f224810682dd19253/href"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/824c9cb1a26e885f224810682dd19253/href"&gt;https://medium.com/media/824c9cb1a26e885f224810682dd19253/href&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linkedlists</category>
      <category>pointers</category>
      <category>reverse</category>
      <category>modules</category>
    </item>
    <item>
      <title>Navigate the World: A Guide to Calculating Distances Between Points on Earth using Python and the…</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Tue, 18 Apr 2023 14:55:03 +0000</pubDate>
      <link>https://dev.to/byteshiva/navigate-the-world-a-guide-to-calculating-distances-between-points-on-earth-using-python-and-the-5a68</link>
      <guid>https://dev.to/byteshiva/navigate-the-world-a-guide-to-calculating-distances-between-points-on-earth-using-python-and-the-5a68</guid>
      <description>&lt;h3&gt;
  
  
  Navigate the World: A Guide to Calculating Distances Between Points on Earth using Python and the Haversine Formula
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;C&lt;/strong&gt; alculating distances between points on Earth is an important problem in many fields, including navigation, transportation, and geology. In this blog post, we will show you how to use NumPy, a popular Python library for scientific computing, to calculate distances between pairs of latitude and longitude coordinates on Earth.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;To understand how to calculate distances between points on Earth, we first need to understand some basic concepts in geography and mathematics. The Earth is roughly spherical in shape, and its surface can be divided into a grid of latitude and longitude lines.&lt;/p&gt;

&lt;p&gt;Latitude measures the north-south position of a point on the Earth’s surface, with the equator being at 0 degrees latitude, and the poles being at 90 degrees north and south latitude. Longitude measures the east-west position of a point on the Earth’s surface, with the prime meridian being at 0 degrees longitude, and the international date line being at 180 degrees east or west longitude.&lt;/p&gt;

&lt;p&gt;To calculate the distance between two points on a sphere, we need to find the shortest distance along the surface of the sphere between the two points. This distance is called the great-circle distance, and it can be calculated using the Haversine formula, which is an approximation based on the law of cosines. The formula is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = sin²(Δlat/2) + cos(lat1) * cos(lat2) * sin²(Δlon/2)
c = 2 * atan2( √a, √(1−a) )
d = R * c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;lat1 and lat2 are the latitudes of the two points, in radians&lt;/li&gt;
&lt;li&gt;lon1 and lon2 are the longitudes of the two points, in radians&lt;/li&gt;
&lt;li&gt;Δlat and Δlon are the differences between the latitudes and longitudes, respectively&lt;/li&gt;
&lt;li&gt;R is the radius of the Earth (mean radius = 6,371km)&lt;/li&gt;
&lt;li&gt;sin and cos are the trigonometric functions&lt;/li&gt;
&lt;li&gt;√ and atan2 are the square root and the two-argument inverse tangent functions, respectively&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Data representation
&lt;/h3&gt;

&lt;p&gt;To use NumPy to calculate distances between points on Earth, we need to represent the latitude and longitude coordinates as arrays of numbers. We also need to convert the coordinates from degrees to radians, as required by the Haversine formula. Here’s an example of how to represent the coordinates of two points, A and B:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np

# Define the coordinates of point A and B
lat_a = 48.8566 # Paris, France
lon_a = 2.3522
lat_b = 51.5072 # London, UK
lon_b = -0.1276

# Convert the coordinates to radians
lat_a, lon_a = np.radians([lat_a, lon_a])
lat_b, lon_b = np.radians([lat_b, lon_b])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Calculation of distances
&lt;/h3&gt;

&lt;p&gt;Once we have the latitude and longitude coordinates in radians, we can use NumPy functions to calculate the Haversine formula. Here’s an example of how to calculate the great-circle distance between points A and B:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Calculate the differences in latitude and longitude
dlat = lat_b - lat_a
dlon = lon_b - lon_a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After we have calculated the difference in latitude and longitude between the two points, we can apply the Haversine formula to calculate the distance between the two points.&lt;/p&gt;

&lt;p&gt;The Haversine formula is a mathematical formula that gives the distance between two points on the surface of a sphere. It takes into account the curvature of the Earth’s surface and provides more accurate results than simply calculating the Euclidean distance between two points.&lt;/p&gt;

&lt;p&gt;Here is the implementation of the Haversine formula in Python:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Apply the Haversine formula
a = np.sin(dlat/2)**2 + np.cos(lat_a) * np.cos(lat_b) * np.sin(dlon/2)**2
c = 2 * np.arctan2(np.sqrt(a), np.sqrt(1-a))
distance = R * c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this formula, a is the square of half the chord length between the two points, c is the angular distance between the two points, and R is the radius of the Earth (in kilometers). The np.arctan2() function returns the angle whose tangent is the quotient of two specified numbers, and distance is the final result.&lt;/p&gt;

&lt;p&gt;Finally, we can put all the pieces together and create a function to calculate the distance between two points on Earth:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def calculate_distance(lat_a, lon_a, lat_b, lon_b):
    R = 6371 # Radius of the Earth in kilometers

    # Convert latitude and longitude to radians
    lat_a, lon_a, lat_b, lon_b = np.radians([lat_a, lon_a, lat_b, lon_b])

    # Calculate the difference in latitude and longitude
    dlat = lat_b - lat_a
    dlon = lon_b - lon_a

    # Apply the Haversine formula
    a = np.sin(dlat/2)**2 + np.cos(lat_a) * np.cos(lat_b) * np.sin(dlon/2)**2
    c = 2 * np.arctan2(np.sqrt(a), np.sqrt(1-a))
    distance = R * c

    return distance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We can use this function to calculate the distance between two points on Earth:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Calculate the distance between New York and Los Angeles
distance = calculate_distance(40.7128, -74.0060, 34.0522, -118.2437)
print(distance) # Output: 3935.3281658175647
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The output shows that the distance between New York and Los Angeles is approximately 3935 kilometers.&lt;/p&gt;
&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Calculating the distance between two points on Earth is an important task in many applications, such as navigation, geolocation, and surveying. The Haversine formula is a reliable method for calculating the distance between two points on the surface of a sphere, and the NumPy library provides a convenient way to perform the necessary calculations in Python.&lt;/p&gt;
&lt;h3&gt;
  
  
  Bonus:
&lt;/h3&gt;

&lt;p&gt;Below is the modularized code which includes additional code that uses Folium to visualize the calculated distances on a map.&lt;/p&gt;
&lt;h3&gt;
  
  
  Demo — Code Walkthrough
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



</description>
      <category>navigation</category>
      <category>numpy</category>
      <category>haversineformula</category>
      <category>geolocation</category>
    </item>
    <item>
      <title>Introduction to Generic Programming in Go: Filtering and Summing Numeric Types</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Mon, 17 Apr 2023 15:56:26 +0000</pubDate>
      <link>https://dev.to/byteshiva/introduction-to-generic-programming-in-go-filtering-and-summing-numeric-types-4flf</link>
      <guid>https://dev.to/byteshiva/introduction-to-generic-programming-in-go-filtering-and-summing-numeric-types-4flf</guid>
      <description>&lt;p&gt;Go is a statically typed language with a strict type system, which means that each variable and function parameter must have a specific type defined at compile-time. While this makes Go programs fast and efficient, it can also make them less flexible and harder to write. To address this issue, Go 1.18 introduced support for generics, allowing programmers to write code that can work with a wide range of types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this tutorial&lt;/strong&gt; , we’ll explore how to use generics to implement a filter function that works with numeric types. Our filter function will take a list of values and a predicate function that returns true or false based on whether a value should be included in the filtered list. Additionally, our filter function will return the sum of the filtered values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Defining the Numeric Interface
&lt;/h3&gt;

&lt;p&gt;To implement our filter function, we’ll define a Numeric interface that all numeric types must satisfy. The Numeric interface will have two methods: Add and IsZero. The Add method will take another value and return the sum of the two values, while the IsZero method will return true if the value is zero.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Numeric interface {
    Add(x interface{}) Numeric
    IsZero() bool
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We’ll use the interface{} type to define the parameter type of the Add method, which will allow us to pass in any type of value to the method.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Implementing Numeric Types
&lt;/h3&gt;

&lt;p&gt;Next, we’ll implement two numeric types that satisfy the Numeric interface: Int and Float. The Int type will be an integer type that implements the Add and IsZero methods, while the Float type will be a floating-point type that also implements the Add and IsZero methods.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Int int

func (i Int) Add(x interface{}) Numeric {
    switch x := x.(type) {
    case Int:
        return i + x
    }
    return nil
}

func (i Int) IsZero() bool {
    return i == 0
}

type Float float64

func (f Float) Add(x interface{}) Numeric {
    switch x := x.(type) {
    case Float:
        return f + x
    }
    return nil
}

func (f Float) IsZero() bool {
    return f == 0.0
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The Add method for both types uses a type switch to determine the type of the parameter and returns the sum of the two values if the parameter is of the same type as the receiver. Otherwise, it returns nil.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Implementing the Filter Function
&lt;/h3&gt;

&lt;p&gt;Now that we’ve defined the Numeric interface and implemented the Int and Float types, we can use them to implement our filter function. The Filter function takes a list of values and a predicate function as input and returns a filtered list and the sum of the filtered values.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func Filter[T Numeric](list []T, predicate func(T) bool) ([]T, T) {
    var result []T
    var sum T
    for _, item := range list {
        if predicate(item) {
            result = append(result, item)
            if sum.IsZero() {
                sum = item
            } else {
                sum = sum.Add(item).(T)
            }
        }
    }
    return result, sum
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The Filter function uses a type parameter T, which is constrained by the Numeric interface, to specify the type of values in the list parameter. The predicate function takes a single value of type T as input and returns true or false.&lt;/p&gt;

&lt;p&gt;Inside the function, we initialize two variables: result, which is an empty slice of T, and sum, which is initialized to the zero value of type T. We then loop through each item in the list and check whether the predicate function returns true for that item.&lt;/p&gt;

&lt;p&gt;If the predicate function returns true, we append the item to the result slice and add it to the current value of sum using the Add method defined in the Numeric interface.&lt;/p&gt;

&lt;p&gt;We also use the IsZero method to check whether the current value of sum is the initial zero value of type T or has been updated with a non-zero value. Finally, we return the filtered result slice and the total sum of the filtered items. This implementation allows us to use the Filter function with any type that implements the Numeric interface, providing a flexible and reusable solution for filtering and summing elements of a list.&lt;/p&gt;
&lt;h3&gt;
  
  
  Extra’s
&lt;/h3&gt;
&lt;h3&gt;
  
  
  A Simpler Explanation
&lt;/h3&gt;

&lt;p&gt;So imagine you have a bunch of numbers and you want to find which ones are even (divisible by 2) and also find the total sum of those even numbers.&lt;/p&gt;

&lt;p&gt;In our program, we have created a function called Filter that takes in a list of numbers and a condition to filter those numbers. The Filter function returns two things: the filtered list of numbers that meet the condition, and the sum of those filtered numbers.&lt;/p&gt;

&lt;p&gt;We have also created a type called Numeric that represents any numeric data type like int, float, etc. This type has two methods: Add and IsZero. The Add method takes in another Numeric value and returns the sum of the two values. The IsZero method checks if the value is equal to zero.&lt;/p&gt;

&lt;p&gt;Now let’s go back to the Filter function. Inside the function, we initialize two variables: result which is an empty list of the same type as the input list, and sum which is initialized to the zero value of the same type as the input list. We then loop through each item in the input list and check whether the item meets the condition specified by the predicate function. If it does, we add it to our result list and also add it to our sum variable using the Add method.&lt;/p&gt;

&lt;p&gt;At the end of the loop, we return the result list and the sum variable, which gives us the filtered list and the sum of the filtered numbers respectively.&lt;/p&gt;
&lt;h3&gt;
  
  
  DEMO — Code Walkthrough
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



</description>
      <category>genericsprogramming</category>
      <category>go</category>
      <category>generics</category>
      <category>linux</category>
    </item>
    <item>
      <title>Converting PNG to SVG in Golang using Potrace and Convert Tool</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Sun, 16 Apr 2023 13:31:20 +0000</pubDate>
      <link>https://dev.to/byteshiva/converting-png-to-svg-in-golang-using-potrace-and-convert-tool-2fc8</link>
      <guid>https://dev.to/byteshiva/converting-png-to-svg-in-golang-using-potrace-and-convert-tool-2fc8</guid>
      <description>&lt;p&gt;Converting a PNG image to an SVG file using Potrace is a common task in image processing. Potrace is a free and open-source tool for converting bitmap images to vector graphics. In this blog, we will see how to use Convert and Potrace to convert a PNG file to SVG format in Golang.&lt;/p&gt;

&lt;p&gt;Prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Golang installed on your system&lt;/li&gt;
&lt;li&gt;Potrace installed on your system&lt;/li&gt;
&lt;li&gt;ImageMagick installed on your system
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install potrace imagemagick
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Import Required Packages First, we need to import the necessary packages for our program. We will use the os/exec package to execute the Potrace command in our program.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "os"
    "os/exec"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Define Input and Output Paths Next, we need to define the input PNG file path and the output SVG file path. In this example, we will use the file paths "input.png" and "output.svg", respectively.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func main() {
   // Input and output file paths
   pngPath := "./input.png"
   bmpPath := "./input.bmp"
   svgPath := "./output.svg"
   ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Execute Potrace Command Now, we can execute the Potrace command using the os/exec package. We need to create a new exec.Cmd variable and pass the Potrace command and arguments as its arguments. In this example, we will use the following command to convert the PNG file to BMP, and BMP to SVG:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmdBmp := exec.Command("convert", pngPath, bmpPath)
cmd := exec.Command("potrace", "-s", bmpPath, "-o", svgPath)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The -s flag is used to suppress the output of statistics, -o flag is used to specify the output file path, and the input PNG file path is passed as an argument.&lt;/p&gt;

&lt;p&gt;We can then use the Run() method of the cmd variable to execute the Potrace command. This method will block until the command has completed.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;err := cmd.Run()
if err != nil {
    panic(err)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Step 4: Check Output File Finally, we need to check if the output SVG file exists. We can use the os.Stat() function to check the file's existence. If the file does not exist, we can panic and print an error message.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if _, err := os.Stat(svgPath); os.IsNotExist(err) {
    panic("Output file does not exist")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Here’s the complete code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
 "os"
 "os/exec"
)

func main() {
 // Input and output file paths
   pngPath := "./input.png"
   bmpPath := "./input.bmp"
   svgPath := "./output.svg"

   // Convert PNG to BMP
   cmdBmp := exec.Command("convert", pngPath, bmpPath)
   errBmp := cmdBmp.Run()
   if errBmp != nil {
      panic(errBmp)
   }
   // defer os.Remove(bmpPath)

   // Convert BMP to SVG using Potrace
   cmdSvg := exec.Command("potrace", "-s", bmpPath, "-o", svgPath)
   errSvg := cmdSvg.Run()
   if errSvg != nil {
      panic(errSvg)
   }

   // Check if the output file exists
   if _, err := os.Stat(svgPath); os.IsNotExist(err) {
      panic("Output file does not exist")
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To run the program, save the above code in a file named main.go and run the following command in the terminal:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will convert the PNG file "input.png" to SVG format and save it as "output.svg". You can change the input and output file paths to suit your requirements.&lt;/p&gt;

&lt;p&gt;In conclusion, Potrace is a useful tool for converting bitmap images to vector graphics. By using Potrace in Golang, we can automate the process of converting PNG files to SVG format.&lt;/p&gt;
&lt;h3&gt;
  
  
  Demo — Code Walkthrough
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



</description>
      <category>png</category>
      <category>linux</category>
      <category>go</category>
      <category>svg</category>
    </item>
    <item>
      <title>Building a Basic Web Service with Flask</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Thu, 13 Apr 2023 14:52:42 +0000</pubDate>
      <link>https://dev.to/byteshiva/building-a-basic-web-service-with-flask-5504</link>
      <guid>https://dev.to/byteshiva/building-a-basic-web-service-with-flask-5504</guid>
      <description>&lt;p&gt;Flask is a popular Python web framework that is used to develop web applications. It is simple, lightweight, and flexible, making it an excellent choice for building small to medium-sized web applications. In this blog post, we’ll walk through the steps to create a basic web service using Flask.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Flask
&lt;/h3&gt;

&lt;p&gt;To use Flask, you’ll first need to install it. You can do this using pip, the Python package installer, by running the following command in your terminal or command prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install flask
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create a Flask Application
&lt;/h3&gt;

&lt;p&gt;Once Flask is installed, create a new Python file for your application. In this example, we’ll call the file app.py. At the top of the file, you'll need to import Flask and create a new instance of the Flask class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask

app = Flask( __name__ )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The __name__ parameter tells Flask where to find resources such as templates and static files. In this case, we're telling Flask to use the current module as the source of these resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Define a Route
&lt;/h3&gt;

&lt;p&gt;Routes are used to map URLs to functions in your application. To create a new route, use the route() decorator and specify the URL that you want to map to the function. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route('/')
def home():
    return 'Hello, world!'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’ve created a route for the root URL (/) and defined a function home() that returns the string 'Hello, world!'. This function will be called whenever a user navigates to the root URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Run the Application
&lt;/h3&gt;

&lt;p&gt;To run your Flask application, add the following code to the bottom of your app.py file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if __name__ == ' __main__':
    app.run()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will start the Flask development server and allow you to access your application by visiting &lt;a href="http://localhost:5000"&gt;http://localhost:5000&lt;/a&gt; in your web browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Add Functionality
&lt;/h3&gt;

&lt;p&gt;With your Flask application up and running, you can start adding functionality to it. For example, you might want to create a form that allows users to submit data to your application. Here’s an example of how you might create a simple form in Flask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── main.py
└── templates
    └── home.html

from flask import Flask, request, render_template

app = Flask( __name__ )

@app.route('/', methods=['GET', 'POST'])
def home():
    if request.method == 'POST':
        name = request.form['name']
        return f'Hello, {name}!'
    else:
        return render_template('home.html')

curl -X POST -d "name=John King" http://localhost:5000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’ve added a new route accepting GET and POST requests. If the request method is POST, we retrieve the value of the name field from the submitted form and return a personalized greeting. If the request method is GET, we render a template called home.html that contains the form.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Deploy Your Application
&lt;/h3&gt;

&lt;p&gt;Once you’ve built your Flask application, you’ll need to deploy it to a web server so that others can access it. There are many ways to deploy a Flask application, including using a cloud hosting provider or a dedicated server. Some popular options for deploying Flask applications include Heroku, Google Cloud Platform, and Amazon Web Services.&lt;/p&gt;

&lt;p&gt;In conclusion, Flask is a powerful and flexible web framework that makes it easy to build and deploy web services in Python. By following the steps outlined in this blog post, you can create a simple Flask application that accepts user input and returns the personalized output. With a little bit of creativity and ingenuity, you can use Flask to build powerful and scalable web services that can be used by&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo — Code Walkthrough
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/cb60d778c7a01553339430f6fbc3c1f1/href"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/cb60d778c7a01553339430f6fbc3c1f1/href"&gt;https://medium.com/media/cb60d778c7a01553339430f6fbc3c1f1/href&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdevelopmentservic</category>
      <category>python</category>
      <category>webservices</category>
    </item>
    <item>
      <title>Mastering LaTeX Formatting: A Guide with Examples</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Wed, 12 Apr 2023 15:58:09 +0000</pubDate>
      <link>https://dev.to/byteshiva/mastering-latex-formatting-a-guide-with-examples-1gnb</link>
      <guid>https://dev.to/byteshiva/mastering-latex-formatting-a-guide-with-examples-1gnb</guid>
      <description>&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;LaTeX is a powerful tool for document preparation, but mastering its formatting capabilities can be a challenge. In this guide, I’ll walk you through some of the essential LaTeX formatting techniques, complete with examples that you can try out for yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Section 1: Basic Formatting Techniques
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Bold and Italic Text: Use \textbf{} for bold and \textit{} for italicized text. Example: This is \textbf{bold} and this is \textit{italicized} text.&lt;/li&gt;
&lt;li&gt;Underlined Text: Use \underline{}. Example: This is \underline{underlined} text.&lt;/li&gt;
&lt;li&gt;Superscript and Subscript: Use ^{}for superscripts and _{} for subscripts. Example: H\textsubscript{2}O and E = mc\textsuperscript{2}.&lt;/li&gt;
&lt;li&gt;Font Size: Use \fontsize{}{} for custom font sizes. Example: This text is {\fontsize{16}{18}\selectfont larger}than this text.&lt;/li&gt;
&lt;li&gt;Bullet Points: Use \begin{itemize}and \itemfor bullet points. Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\begin{itemize} \item First item \item Second item \item Third item \end{itemize}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Section 2: Advanced Formatting Techniques
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tables:&lt;/strong&gt; Use the tabular environment for tables. Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\begin{tabular}{|c|c|} \hline Column 1 &amp;amp; Column 2 \ \hline Row 1, Column 1 &amp;amp; Row 1, Column 2 \ \hline Row 2, Column 1 &amp;amp; Row 2, Column 2 \ \hline \end{tabular}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Figures:&lt;/strong&gt; Use the graphicx package for figures. Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{example-image} \caption{This is a caption for the figure.} \label{fig:example} \end{figure}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Equations:&lt;/strong&gt; Use the equation environment for equations. Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\begin{equation} E=mc\textsuperscript{2} \end{equation}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;References:&lt;/strong&gt; Use \cite{} for references. Example: According to \cite{example}, LaTeX is a powerful tool for document preparation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;With these LaTeX formatting techniques and examples, you can create professional-looking documents with ease. Whether you’re a student, researcher, or professional, LaTeX can help you take your documents to the next level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sample Latex Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\documentclass[a4paper,12pt]{article}
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{itemize} \item First item \item Second item \item Third item \end{itemize}

\thinspace

\begin{tabular}{|c|c|} \hline Column 1 &amp;amp; Column 2 \\ \hline Row 1, Column 1 &amp;amp; Row 1, Column 2 \\ \hline Row 2, Column 1 &amp;amp; Row 2, Column 2 \\ \hline \end{tabular}

\begin{equation} E=mc\textsuperscript{2} \end{equation}

\end{document}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MyZDAWfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/870/1%2A_iznYLRE5DPnrjBfgUsr8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MyZDAWfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/870/1%2A_iznYLRE5DPnrjBfgUsr8w.png" alt="Sample PDF Preview" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Extra’s
&lt;/h3&gt;

&lt;p&gt;Here are the steps to install LaTeX:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the following link: &lt;a href="https://tug.org/texlive/"&gt;https://tug.org/texlive/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on the “Download” button on the top-right corner of the page.&lt;/li&gt;
&lt;li&gt;Choose the appropriate operating system and follow the instructions to download the installer.&lt;/li&gt;
&lt;li&gt;Once the installer is downloaded, run it and follow the instructions to install LaTeX.&lt;/li&gt;
&lt;li&gt;During the installation process, you will be prompted to select packages to install. You can choose to install the complete set of packages or only the packages you need.&lt;/li&gt;
&lt;li&gt;Once the installation is complete, you can start using LaTeX to create your documents.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: The installation steps may vary depending on the operating system you are using.&lt;/p&gt;

</description>
      <category>documentpreparation</category>
      <category>typesetting</category>
      <category>latex</category>
      <category>typography</category>
    </item>
    <item>
      <title>Converting MKV Files for Compatibility with Older Devices and Software</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Tue, 11 Apr 2023 09:48:33 +0000</pubDate>
      <link>https://dev.to/byteshiva/converting-mkv-files-for-compatibility-with-older-devices-and-software-4ghk</link>
      <guid>https://dev.to/byteshiva/converting-mkv-files-for-compatibility-with-older-devices-and-software-4ghk</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;MKV is a popular video format that supports multiple audio and video codecs. However, some older devices or software may not support the newer codecs used in MKV files, which can cause playback issues. To address this, you can convert your MKV files to an older video codec and audio codec that is more widely supported. In this tutorial, I’ll show you how to convert MKV files to an older video codec and audio codec, with a focus on using MP3 as the audio codec.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we begin, you’ll need to have the following software installed on your system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FFmpeg: a powerful command-line tool for converting and manipulating video and audio files. You can download FFmpeg from the official website: &lt;a href="https://ffmpeg.org/"&gt;https://ffmpeg.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install the libmp3lame codec:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install libmp3lame-dev -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Steps to Convert MKV Files to Older Video Codec and Audio Codec
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open a terminal window on your system.&lt;/li&gt;
&lt;li&gt;Navigate to the directory where your MKV file is located.&lt;/li&gt;
&lt;li&gt;Run the following command to convert the MKV file to an AVI file with MPEG-4 Part 2 video codec and MP3 audio codec:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ffmpeg -i input.mkv -c:v mpeg4 -b:v 5M -c:a libmp3lame output.avi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In this command, we are using the -i option to specify the input file (replace input.mkv with the name of your input file), the -c:v mpeg4 option to specify the MPEG-4 Part 2 video codec, the -b:v 5M option to set the video bitrate to 5Mbps (you can adjust this value as needed), and the -c:a libmp3lame option to specify the MP3 audio codec.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait for FFmpeg to finish the conversion process. This may take some time, depending on the length and size of your input file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the conversion is complete, you will have a new file named output.avi in the same directory as your input file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test the output file to ensure that it plays back correctly on your target device or software.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Converting MKV files to an older video codec and audio codec can help ensure compatibility with older devices and software that may not support newer codecs. By following the steps in this tutorial, you can easily convert your MKV files to MPEG-4 Part 2 video codec and MP3 audio codec using FFmpeg. Remember to experiment with different video and audio bitrates to find a balance between file size and quality that works for your needs.&lt;/p&gt;
&lt;h3&gt;
  
  
  Demo — Code Walkthrough
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



</description>
      <category>mp3codec</category>
      <category>videocodec</category>
      <category>audiocodec</category>
      <category>mpeg4</category>
    </item>
    <item>
      <title>Unlocking the Power of Linux Capabilities: Exposing Port 80 without Root Access</title>
      <dc:creator>Siva</dc:creator>
      <pubDate>Mon, 10 Apr 2023 10:14:53 +0000</pubDate>
      <link>https://dev.to/byteshiva/unlocking-the-power-of-linux-capabilities-exposing-port-80-without-root-access-418o</link>
      <guid>https://dev.to/byteshiva/unlocking-the-power-of-linux-capabilities-exposing-port-80-without-root-access-418o</guid>
      <description>&lt;p&gt;When running a web server or any other program that requires listening on a low port (below 1024) in Linux, it is common to run it as a privileged user, usually as root. Running as root, however, can pose a security risk as any vulnerability in the program or its dependencies can lead to full system compromise.&lt;/p&gt;

&lt;p&gt;One alternative to running as root is to use &lt;strong&gt;&lt;em&gt;Linux capabilities&lt;/em&gt;&lt;/strong&gt;. Linux capabilities provide a fine-grained way to grant specific privileges to a program without granting full root access. One such capability is CAP_NET_BIND_SERVICE, which allows a program to bind to any network port without requiring root privileges.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will learn how to use CAP_NET_BIND_SERVICE to run a web server listening on port 80 without requiring root privileges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we get started, we need to ensure that the setcap command is available on our system. This command is typically included in the libcap2-bin package, which can be installed using the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo apt-get install libcap2-bin


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Setting CAP_NET_BIND_SERVICE Capability
&lt;/h3&gt;

&lt;p&gt;The first step is to compile our program and set the CAP_NET_BIND_SERVICE capability on it. Here is a sample Go program that listens on port 80 and serves a "Hello, world!" message:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

package main

import (
    "fmt"
    "log"
    "net/http"
)

func main() {
    // Define the handler function
    handler := func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, "Hello, world!")
    }

    // Register the handler with the http server
    http.HandleFunc("/", handler)

    // Start the http server
    log.Fatal(http.ListenAndServe(":80", nil))
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To set the CAP_NET_BIND_SERVICE capability on this program, we can use the setcap command as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

sudo setcap 'cap_net_bind_service=+ep' port80server


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AlN5b01DMrSkQHaeOLFFw0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AlN5b01DMrSkQHaeOLFFw0w.png" alt="sudo setcap ‘cap_net_bind_service=+ep’ port80server"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;sudo setcap ‘cap_net_bind_service=+ep’ port80server&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F904%2F1%2AXT4a-0VRRlzo9SLLapxaXA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F904%2F1%2AXT4a-0VRRlzo9SLLapxaXA.png" alt="getcap ./port80server"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;getcap ./port80server&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This command grants the CAP_NET_BIND_SERVICE capability to the port80service program, allowing it to bind to any network port without requiring root privileges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running the Program
&lt;/h3&gt;

&lt;p&gt;Now that we have set the CAP_NET_BIND_SERVICE capability on our program, we can run it without root privileges. Here is how we can run our program:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

./port80server


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AK35kl_cAatRPAs-NVkq7bw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AK35kl_cAatRPAs-NVkq7bw.png" alt="curl -v http://localhost/"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;curl -v &lt;a href="http://localhost/" rel="noopener noreferrer"&gt;http://localhost/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AQOJmZg-pvfoe6ijmKoKeJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AQOJmZg-pvfoe6ijmKoKeJQ.png" alt="Visit localhost"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The program should start running and listening on port 80. To verify that it is running correctly, open a web browser and visit &lt;a href="http://localhost/" rel="noopener noreferrer"&gt;http://localhost/&lt;/a&gt;. You should see the "Hello, world!" message displayed in the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this tutorial, we learned how to use Linux capabilities to run a program that listens on port 80 without requiring root privileges. By using CAP_NET_BIND_SERVICE, we were able to grant the necessary privileges to our program without granting full root access, which helps to reduce the security risk.&lt;/p&gt;

&lt;p&gt;While this tutorial focuses on running a web server on port 80, the same technique can be used for any other program that requires binding to a low port. Just remember to set the appropriate capability and test that the program is running correctly&lt;/p&gt;




</description>
      <category>networking</category>
      <category>linuxcapabilities</category>
      <category>linux</category>
      <category>security</category>
    </item>
  </channel>
</rss>
