Converting a binary number to decimal via Python script in Linux

How to convert binary number to decimal with python

In this guide, we will show you a short script that can be used to convert a binary number to a decimal number in Python on Linux. This script uses casting which is used to convert a variable from one type to another. In this case, we use Python casting to convert a string to decimal number that is an integer.

Check out the script below to use it on your own system.

In this tutorial you will learn:

  • How to convert binary number to decimal with Python

Read more

gpg-logo

How to Install Open-Source VSCode Without Telemetry on Linux

Visual Studio Code or VSCode is a text editor developed by Microsoft that supports many popular programming languages such as Go, Java, JavaScript, Node.js, Python, C and C++. It is a directory based, language agnostic source code editor which focuses on directories rather than projects and has many extensions available for it. VSCode’s feature set includes bracket matching, syntax highlighting, code folding, linting, debugging, and built in version control via Git, Subversion or Perforce. Ever since the initial release of VSCode in 2015, it has become an increasingly popular programming tool amongst users of all desktop operating systems including GNU/Linux.

Read more

woocommerce-rest-api

How to work with the Woocommerce REST API with Python

WordPress is probably the most used CMS in the world (it is estimated that almost 40% of all websites are built using the platform): it is very easy to install and use, and allows even non-developers to create website in few minutes.
Wordpress has a very large plugin ecosystem; one of the most famous is Woocommerce, which allows us to turn a website into an online store in few steps. The plugin makes use of the WordPress REST API infrastructure; in this tutorial we will see how to interact with the Woocommerce API using the Python programming language, showing how to list, create, update and delete products and categories.

In this tutorial you will learn:

  • How to generate Woocommerce REST API credentials and enable pretty permalinks
  • How to interact with the Woocommerce REST API using Python and the woocommerce package
  • How to get information about the existing Woocommerce categories, create, update and delete them
  • How to get information about the existing Woocommerce products
  • How to create simple and a variable products with variations
  • How to update and delete a product

woocommerce-rest-api

Read more

How to install Anaconda scientific computing python distribution on Linux

How to install Anaconda scientific computing python distribution on Linux

Anaconda is a distribution of python and other open source packages that are meant to be used for scientific computing. It is frequently used for data science, predictive analytics, and machine learning. Installing Anaconda is the fastest way to have all of the tools for scientific computing readily available to you. It includes the conda package manager, IPython the interactive python shell, the spyder IDE, along with the Project Jupyter interactive web based computational environments: Jupyter Notebook, and JupyterLab.

Read more

pip3 on Kali Linux

How to install pip on Kali Linux

pip is the package manager for the Python coding language. It can be installed on a Linux system and then used on the command line to download and install Python packages and their requisite dependencies.

Python is a common language to use for hacking scripts, and on Kali Linux, the biggest use for pip would be to install needed dependencies for Python hacking programs. Whether you are developing your own script or trying to execute a third party Python program, having pip on your system will allow you to install dependency packages very easily.

In this guide, we’ll show you how to install pip for Python 3 on Kali. We’ll also show you basic usage commands for pip, such as installing and removing software packages. pip operates much like Kali’s package manager, which you’re probably already familiar with.

In this tutorial you will learn:

  • How to install pip on Kali
  • Basic usage commands for pip
pip3 on Kali Linux

pip3 on Kali Linux

Read more

How to launch external processes with Python and the subprocess module

How to launch external processes with Python and the subprocess module

In our automation scripts we often need to launch and monitor external programs to accomplish our desired tasks. When working with Python, we can use the subprocess module to perform said operations. This module is part of the programming language standard library. In this tutorial we will take a quick look at it, and we will learn the basics of its usage.

In this tutorial you will learn:

  • How to use the “run” function to spawn an external process
  • How to capture a process standard output and standard error
  • How to check the exist status of a process and raise an exception if it fails
  • How to execute a process into an intermediary shell
  • How to set a timeout for a process
  • How to use the Popen class directly to pipe two processes

Read more

How to read and create csv files using Python

How to read and create csv files using Python

CSV is the acronym of “Comma Separated Values”. A csv file is a just plain text document used to represent and exchange tabular data. Each row in a csv file represents an “entity”, and each column represents an attribute of it. Columns are usually separated by a comma but other characters can be used as field separator instead of it. In this tutorial we will see how to read and create csv files using Python and specifically the csv module, which is part of the
language standard library.

In this tutorial you will learn:

  • How to read csv rows as a list of strings
  • How to read a csv as a list of dictionaries
  • How to create a csv using Python
  • How to create a csv starting from a list of dictionaries

Read more

How to connect to an FTP server using Python

How to connect to an FTP server using Python

FTP (File Transfer Protocol) needs no presentations: it is among the most used file transfer methods between one or more clients and a server. By design it supports both anonymous access and authentication, but in its most basic form it doesn’t provide data encryption, that’s why it is often secured via TLS.

A lot of FTP client applications are available on Linux, as for example Filezilla (graphical) or lftp (command line). Sometimes, however, we may want to access an FTP server programmatically, perhaps to schedule file transfers. One easy way to do this is by using a programming language like Python. In this tutorial we will learn how to use the ftplib library to interact with an FTP server.

In this tutorial you will learn:

  • How to create an instance of the ftplib.FTP class
  • How to list files on a remote FTP server
  • How to upload files in binary and “lines” mode
  • How to download files in binary and “lines” mode
  • How to create,delete and rename directories and files
  • How to change working directory

Read more

pip on Linux

Install pip on Linux

pip is the package manager for the Python coding language. It can be installed on a Linux system and then used on the command line to download and install Python packages and their requisite dependencies.

This gives developers – as well as users who are just executing Python programs but not developing them – an easy way to download software packages written in Python. It’s available for installation on any major Linux distro and operates in much the same way as a distro’s package manager, which you’re probably already familiar with.

In this guide, we’ll show you how to install pip for Python 2 and Python 3 on various Linux distributions. We’ll also show you basic usage commands for pip, such as installing and removing software packages.

In this tutorial you will learn:

  • How to install pip for Python 2 and Python 3 on major Linux distros
  • Basic usage commands for pip

Read more

Python Regular Expressions with Examples

Python Regular Expressions with Examples

A regular expression (often abbreviated to “regex”) is a technique, and a textual pattern, which defines how one wants to search or modify a given string. Regular expressions are commonly used in Bash shell scripts and in Python code, as well as in various other programming languages.

In this tutorial you will learn:

  • How to start with Regular Expressions on Python
  • How to import regex Python module
  • How to match strings and characters using Regex notation
  • How to use the most common Python Regex notations

Read more

python-logo

How to create and manipulate tar archives using Python

On Linux and other Unix-like operating systems, tar is undoubtedly one of the most used archiving utilities; it let us create archives, often called “tarballs”, we can use for source code distribution or backup purposes. In this tutorial we will see how to read, create and modify tar archives with python, using the tarfile module.

In this tutorial you will learn:

  • The modes in which a tar archive can be opened using the tarfile module
  • What are the TarInfo and TarFile classes and what they represent
  • How to list the content of a tar archive
  • How to extract the content of a tar archive
  • How to add files to a tar archive

Read more