Programming Leftovers


-
This Week in Rust 392
-
Bash Arrays In-Depth – Linux Hint
In Bash, an array can be an indexed array or an associative array. An indexed array is a list whose items are numbered beginning from zero. An associative array is a list where strings have replaced the numbers. Assume a pen, an exercise book, a textbook, a ruler, $42, and a pencil on a study table.
-
A bunch of releases from the Pallets projects
May 11 marked a new major release for the Python-based Flask web microframework project, but Flask 2.0 was only part of the story. While the framework may be the most visible piece, it is one of a small handful of cooperating libraries that provide solutions for various web-development tasks; all are incorporated into the Pallets projects organization. For the first time, all six libraries that make up Pallets were released at the same time and each had a new major version number. In part, that new major version indicated that Python 2 support was being left behind, but there is plenty more that went into the coordinated release.
[...]
While Flask is pretty well-known and has even been written about here before, the Pallets umbrella organization has flown a bit under the radar, at least for me. The Jinja2 template engine, a Pallets component that is used by Flask, is also fairly high-profile, but the other pieces of the puzzle are less so. The only other Pallets library I had heard of was the Werkzeug library for supporting Web Server Gateway Interface (WSGI) applications. It is used to connect Flask applications to web servers.
There are three more libraries on the pallet, but those are smaller and more specialized: MarkupSafe, which provides a text object that escapes characters interpreted by HTML, ItsDangerous, which provides helpers to cryptographically sign data that will be moved between trusted and untrusted environments, and the Command Line Interface Creation Kit, or Click, which is used for "creating beautiful command line interfaces in a composable way with as little code as necessary". The coordinated release was announced on the Pallets blog; it is based on two years of work, though there have been other fairly substantial releases in that time span (e.g. Flask 1.1 in July 2019, Jinja 2.11 in January 2020, Werkzeug 1.0 in February 2020).
-
Processing modular and dynamic configuration files in shell
While working on a continuous integration/continuous development (CI/CD) solution for a customer, one of my first tasks was to automate the bootstrapping of a CI/CD Jenkins server in OpenShift. Following DevOps best practices, I quickly created a configuration file that drove a script to complete the job. That quickly became two configuration files when I realized I needed a separate Jenkins server for production. After that came the request that the customer needed more than one pair of engineering and production CI/CD servers for different groups, and each server had similar but slightly different configurations.
When the inevitable changes had to be made to the values common to two or more of the servers, it was very difficult and error-prone to propagate the changes across two or four files. As CI/CD environments were added for more complex testing and deployments, the number of shared and specific values for each group and environment grew.
As the changes became more frequent and the data more complex, making changes within the configuration files became more and more unmanageable. I needed a better solution to solve this age-old problem and manage changes faster and more reliably. More importantly, I needed a solution that would allow my clients to do the same after turning my completed work over to them.
-
Literals in C – Linux Hint
You must have heard about the constant variables, whose value cannot be changed. The constant values allocated towards the relentless variables are known as Literals. The literals could be a set of values that could not be changed. It still has memories. However, it has no links in the form of variables. As an illustration, Const int =10; of a constant variable statement where 10 is an int literal. C literals are mostly cast-off to simplify code to get around situations by declaring a variable is not a preference. There are different kinds of literals used in the C programming language. We will discuss each one of them separately.
-
Static Variables in C – Linux Hint
Static variables do have the ability to maintain their meaning even though they’ve been removed from their scope! As a result, static variables keep their former value in the setting mentioned above and do not need to be initialized once in the new environment. Static variables are always set up once. The compiler holds the variable until the completion of the code. Within and outside of the method, static variables may be specified. Static variables have a standard fixed value of 0. The static variables remain active until the code is over. Ordinary variables are restricted to the range in which they are specified, whereas static variables have a scope that extends within the code.
-
Unions in C – Linux Hint
A union is a very interesting user-defined data type in the C programming language. It is very much similar to structures in the C programming language. However, there are some differences due to which structures and unions are considered as the independent data types in the C programming language. In a straightforward way, you can consider a union as a conjunction or union of the different data types within one container. It means that a union can hold variables belonging to different data types within the very same container.
All this discussion will start to make more sense once we go through some relevant examples based on the usage of unions in the C programming language in Linux. However, before sharing those examples with you, we would like to discuss the working of unions and structures so that you can differentiate between these two data types before taking a look at the associated examples. So, let’s take a look at the affixed portion of our article.
-
“malloc” in C – Linux Hint
Whenever we declare a variable in the C programming language, a chunk in the memory is reserved for holding that variable whose size depends on that variable’s data type. This is referred to as automatic memory management, and it happens at the compilation time. However, at times, you do not want to allocate memory automatically because, in some situations, the exact memory size is subject to change. In such situations, you need a mechanism for allocating memory dynamically.
In the C programming language, the following four functions are used whenever we talk about dynamic memory management: malloc(), calloc(), realloc(), and free(). However, the scope of today’s article is limited to the malloc() function in C, which stands for “memory allocation.” We will take a look at its usage and try to justify why we need this function in the first place. Finally, we will conclude our article after walking you through an example of using the malloc() function in the C programming language.
-

- Login or register to post comments
Printer-friendly version- 3036 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is released
After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release.
|
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future Tech
The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world.
Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility.
|
today's howtos
|








.svg_.png)
Content (where original) is available under CC-BY-SA, copyrighted by original author/s.

Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago