Programming Leftovers
Rust
-
3 aspects of Rust you need to learn
Rust is consistently voted one of the languages people most want to learn. In 2022, Opensource.com had a few articles to help you get started.
Rust is a fairly new language, but it's grown quickly. The general excitement about it goes beyond interest in a new language to try. Rust has genuinely useful features, like the ability to allocate data to the heap (instead of the stack) using the Box data type. There's no separate garbage collection required, and you don't have to manually manage memory yourself. Additionally, the Crate.io infrastructure for library management and installation makes it easy to find and use functions contributed by the Rust community.
Rust is a programming language focusing on speed, concurrency, and safety. Thanks to its integration with online registries, its helpful compiler, and its almost intuitive…
Shell/Bash
-
The Bash And Condition - buildVirtual
In Bash, the && operator is used to perform a logical AND operation. It allows you to execute a command if and only if the preceding command executes successfully.
-
What Are the Different Types of Linux Shells?
The UNIX/Linux shell is a command-line program that creates a bridge between the terminal emulator and kernel to allow users to enter commands, execute programs, and perform various other tasks by typing commands at the command prompt.
Once the shell has finished executing the user assigned program, it will send the output to the user on the terminal screen, which is the standard output device.
Note that the shell is not just a program but a whole programming language like Python or C/C++. You can write your own program, utility, or script that contains the if-else logic, loop statement, functions, variables, object, etc.
Most users are familiar with the Bash shell (the successor to the traditional “sh“), but there are many other shell implementation programs that provide different features and functionality, which we will explore in this article.
-
A Guide to the Terminal, Console, and Shell
Why does Davina want her colleagues to know more about the virtual consoles, the terminal, and the shell?
I don’t know any developer who doesn’t use a terminal, a shell, and some CLIs. I definitely use them all the time. They are the central building bricks of my Mouseless Development Environment.
So, since it’s so useful, let’s look a bit deeper what’s this shell, console, and terminal. More precisely, we’ll see, in this article: [...]
Python
-
How to Generate Random String in Python - TecAdmin
Generating random strings in Python is a common task that can be useful in various scenarios, such as when you need to create unique identifiers, when you want to generate random passwords, or when you want to create random data for testing purposes. In Python, you can use the random module and the string module to generate random strings. The random module provides functions for generating random numbers, and the string module provides functions for generating random strings.
[...]
In conclusion, generating random strings in Python is a useful task that can be easily accomplished using the random module and the string module. The `random` module provides functions for generating random numbers, and the string module provides functions for generating random strings. By combining these two modules, you can generate random strings of any length and complexity. Understanding how to generate random strings in Python can be helpful in various scenarios, such as when you need to create unique identifiers, when you want to generate random passwords, or when you want to create random data for testing purposes.
-
How to Generate Random Password in Python - TecAdmin
In Python, you can generate a random password using the secrets module, which is part of the Python standard library. The secrets module provides a secure way to generate random strings, numbers, and other values that can be used for various purposes, such as generating passwords, tokens, or unique IDs.
C/C++
-
Strcpy C++
The C++ language has many inbuilt methods for programmers. We just need to access those methods by importing the required libraries. Strings play a vital role in coding and C++ provides plenty of built-in functions for strings. Strings are arrays of characters. It can store one or more than one characters. The difference between character arrays and strings is that character arrays can be of fixed size but mostly we do not define the size. And in strings, we do not need to limit the size. There are many methods used for strings. We can find the length of strings, we can concatenate two or more strings, and many more methods for strings are available for programmers to use. One of these built-in methods is string copy, denoted by the term strcpy(). This function is used to copy one string in another. These methods are pre-built in the C++ library so that we do not have to write the entire piece of code over and over again for the operations we carry out for the majority of the time when we code. To use this strcpy() function, we need to import the specific library that contains this method. For this function, we have to import any of the below command.
-
C: Connect Function System Call
In the C language, establishing a client-server connection through a socket requires several steps and functions. Some of these are used to retrieve data from the server you want to connect to, others are used to create the socket or convert addresses.
Although there is no particular order, this series of steps and function calls must be done in an order because their results are used in the input arguments of the subsequent function.
In this Linux Hint article, you will learn how to use the connect() function and create a socket from scratch to connect remotely to a server.
We begin with a description of the syntax, the input and output arguments that make up this function, and a theoretical explanation of how it works. Then, we will look at an example that shows step-by-step process on how to create and connect a socket.