opensource.com

Subscribe to opensource.com feed
Updated: 48 min 7 sec ago

Why you should try the Nemo file manager on Linux

Mon, 12/05/2022 - 16:00
Why you should try the Nemo file manager on Linux Seth Kenlon Mon, 12/05/2022 - 03:00

Computers are fancy filing cabinets, full of virtual folders and files waiting to be referenced, cross-referenced, edited, updated, saved, copied, moved, renamed, and organized. In this article, I'm taking a look at a file manager for your Linux system.

The Cinnamon project was formed as a reimplementation of GNOME 2 using the components of GNOME 3. Eventually, it diverged enough to be a true fork, and today the Cinnamon desktop uses GTK3 libraries and forked versions of key GNOME 3 applications to create a "classic" GNOME experience. One of the components contributing to the traditional GNOME experience is Nemo, a file manager based on the GNOME 2 version of Nautilus.

Install Nemo on Linux

The source code for Nemo is available online but it requires cinnamon-desktop to build, so the easiest way to install Nemo is to just install Cinnamon.

On Fedora, Mageia, and similar:

$ sudo dnf install cinnamon-desktop

On Linux Mint, Debian, and similar:

$ sudo dnf install cinnamon-desktop-environment

Of course, as the desktop's progenitor, Linux Mint is also available with Cinnamon preinstalled.

A familiar interface

If you're used to GNOME, either of the past or of today, then Nemo feels like home from the start. It's got a familiar look and feel, with buttons in similar places and options that you're likely to recognize.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles

The GNOME-ish convention of placing view control buttons in the top right is retained, and you can use the buttons to quickly switch your view of your files from large icons to a detailed list or a compact view. There's also a search function there, and the option to toggle the location bar between editable text and a button.

Editable URI bars are sometimes undervalued. It's a simple design decision, but it can be a huge feature contributing to efficiency. It's like having a one-line terminal at the top of each window, in which you can type a destination anywhere on your system and instantly be taken there. And you don't even have to type cd.

At the top right corner, there are navigation buttons: up, forward, and back. As with many Linux file managers, you can forego the use of these buttons with the Alt key plus the appropriate Arrow key.

The side pane, shows a list of important folders (Home, Documents, Downloads, and so on), can be hidden or displayed with the click of a button at the bottom of the window.

Familiarity but not the same

The comfort and familiarity of Nemo doesn't mean that it just mindlessly mimics Nautilus. Nemo has a collection of nice features that feel unique. Most of these are in Preferences, and here are just a few of my favorites:

  • Full path in window title: This is my favorite feature. Never question where you are in your filesystem again. Let your window title tell you.

  • Single or double click: If you're a longtime KDE user, you might find single-clicking to open a file refreshing. With Nemo, you have that choice.

  • Double-click to rename: If you're using a single click to open, why not repurpose the double-click to rename?

  • Open each folder in a new window: There are operating systems out there that open a new window for each folder opened.

  • Plugins: Nemo has the ability to invoke actions, scripts, and extensions. Some are included, including an action to change the desktop background, create launchers, and mount an archive. Others are yet to be created, but this kind of extensibility is vital to open source.

Everything close at hand

After using Nemo for a few weeks on Linux Mint, one interesting trait stood out to me. It seemed that Nemo had, or could have with quick configuration, everything I used most often close at hand. Many of the features, admittedly, I didn't know I needed or wanted until Nemo made it easy to click. You might argue that I was bending my usage to meet Nemo's design, and maybe that is the case. But when the experience is so pleasant and efficient, does it matter?

Nemo is a great file manager. It hearkens back to the days of GNOME 2, but with updates and design choices that make it feel fresh. If you like Thunar or Nautilus, you'll love Nemo.

Nemo feels like a refreshed version of GNOME 2. I like it and think you will, too.

Image by:

Photo by David Clode on Unsplash

Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Make your Linux computer feel faster with the Xfe file manager

Sun, 12/04/2022 - 16:00
Make your Linux computer feel faster with the Xfe file manager Seth Kenlon Sun, 12/04/2022 - 03:00

Computers are like filing cabinets, full of virtual folders and files waiting to be referenced, cross-referenced, edited, updated, saved, copied, moved, renamed, and organized. In this article, I'll look at a file manager for your Linux system.

Back before NVMe drives and 12-core processors, applications could take seconds to launch. While that wait time is fine for a big application like LibreOffice or Blender, it's a little painful when it's a tiny application you use frequently. 2 seconds times 10 file manager windows in an hour, times 12 hours a day, is 4 whole minutes of wasted time. OK, I admit that's actually not that much when you do the math, but ask anybody and they'll tell you that it felt like 4 hours. One way to make a computer, whether it's last year's model or something hot off the shelf, feel faster is to use "lightweight" applications. An application is usually considered lightweight when it's designed around minimal code libraries that don't demand much from your system's resources.

The X File Explorer (Xfe) file manager is one of those applications. It's quick to launch, it doesn't feature fancy animations or effects, and it has few dependencies beyond some basic libraries, most of which are probably already on your Linux system.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles Install on Linux

On Fedora, CentOS, Mageia, and similar, you can install Xfe from your software repository:

$ sudo dnf install xfe

On Debian, Elementary, Linux Mint, and similar:

$ sudo apt install xfe xfe-themes

Xfe is open source, so you can alternately just download the source code and compile it yourself.

Using Xfe

The first thing you're likely to notice about Xfe is that by default it's a little top-heavy. There's a menu bar, and then not one but five toolbars along the top of the window. Those toolbars aren't hard coded in position, though, and you can choose which toolbar you actually need on screen at all times in the View menu. Personally, I keep the Location toolbar on and hide the rest. But I think all Xfe users are likely to have a favorite set of toolbars all their own, so when you first try Xfe give yourself time to see which toolbar you actually end up using.

Here's a list of the toolbars and some of the important buttons they each contain:

  • General: Navigation buttons, view refresh, new file, new directory, copy, cut, paste, and other standard file manager actions. This could replace the menu bar, were there a way to hide the menu bar.

  • Tools: Launch a new Xfe window as user or root, execute a command, launch a terminal.

  • Panel: Split the Xfe window into two panes, two panes with panels, one pane with panel, or a single pane.

  • Location: Enter a path for quick navigation.

It's not just the toolbars that are configurable. You can hide most components of Xfe, including the side pane displaying your filesystem tree and the status bar. Xfe can look as minimal as its memory footprint:

Image by:

(Seth Kenlon, CC BY-SA 4.0)

Power menu

The beautiful thing about Xfe's design is that you never sacrifice features regardless of your configuration. You can hide toolbars and panels, but you still have access to every option from the menu.

From the Panel menu, for instance, you can filter files by regex strings, show hidden files, activate and deactivate thumbnails (the fewer things your computer has to render, the faster it can draw the screen), switch icon views between a list or detailed list, choose to ignore case, reverse the sort order, and more.

There's even a menu for the Trash, so you can always get to the place you need to be to rescue something you've thrown out.

Two dots

The feature I appreciate more than I'd expected I would is Xfe's inclusion of a meta folder with a name of just two dots. The .. folder isn't really a folder. It's shorthand for going "up" in your directory tree. If you don't think of folders existing in a tree configuration, that might not make immediate sense, but in computing, you can express the hierarchy of data storage in the same way you might express a family tree. If the penguins folder contains the emperor and rockhopper folders, then you can think of the penguin directory as their "parent."

Image by:

(Seth Kenlon, CC BY-SA 4.0)

Computers use two dots as an instruction to move out of the current directory and "up" the tree. When you're in the rockhopper folder, two dots mean ascend up to penguins. When you're in the emperor folder, two dots also mean ascend up to penguins, because emperor and rockhopper are both "children" of the penguins directory.

This two dot convention is common in Linux and in fact the entire Internet (you can test this out by appending /.. to the end of the URL of this article. It won't get you very far due to restricted permissions, but it does successfully take you off this page, so wait until you're done reading!) Having access to two dots in every directory of Xfe is a familiar and convenient way to navigate.

Make it quick

Running fast applications makes your computing faster. It's a secret that experienced Linux users have known for years, and it's one of the many reasons you often see Linux users with ancient computers. When you use a terminal and a handful of lightweight applications, even a computer from a decade ago doesn't feel slow. The Xfe file manager, whether you use it for speed or just because it's a reliable app that's got everything you need, is an excellent choice for a file manager.

The Xfe file manager, whether you use it for speed or just because it's a reliable app that's got everything you need, is an excellent choice for a file manager.

Image by:

Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0

Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Feel like a Linux wizard with the Thunar file manager

Sat, 12/03/2022 - 16:00
Feel like a Linux wizard with the Thunar file manager Seth Kenlon Sat, 12/03/2022 - 03:00

Computers are fancy filing cabinets, full of virtual folders and files waiting to be referenced, cross-referenced, edited, updated, saved, copied, moved, renamed, and organized. In this article, I'll take a look at a file manager for your Linux system.

The XFCE desktop is well-known and respected for its careful and methodical development cycle. It's actively maintained and has continued to evolve over the years, its focus tends to be on delivering a consistent experience with just the right amount of new features. It's a pleasure to use XFCE on everything from the old computer you've repurposed as a home server to the new PC you've just built and are too greedy to waste GPU cycles on fancy desktop effects. XFCE is a budget desktop that doesn't make you skimp on experience, and its file manager exemplifies that.

Linux Thunar file manager

The Thunar file manager is a lightweight file manager based on the GTK toolkit. If you're running GNOME already, you have most of what you need to run Thunar already installed. If you're not running GNOME, you probably still have most of what you need to run Thunar, because much of what Thunar uses is part of a typical Linux install.

The visual design of Thunar is, like much of XFCE, "normal." By that, I mean it's exactly what you'd expect from a file manager: the side pane on the left contains common places you use often, and the pane on the right lists the files and folders on your system.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

Side pane

The panel on the left contains the default folders of a conventional POSIX system: Desktop, Documents, Downloads, Music, Pictures, Videos, and so on. It also has a slot for removable devices, such as USB drives and SD cards. In addition, it has a place for Network locations, in the event that you interact with a remote computer or a file share.

Most options in Thunar are provided through its main menu, and that includes the option to change the side pane to a tree view. This view displays common places in an expandable list so you can collapse an entry you're not using at the moment.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

Menu

Much of Thunar's power is accessible through its menu bar. Sure, there's a right-click contextual menu, but you will find the most powerful functions in the main menu. From the menu, you can perform quick but meaningful actions.

  • Invert selection: Select one or more items, then go to the Edit menu and choose Invert selection. Everything you had selected is now unselected, and everything else in the directory is selected.

  • Select by pattern: Select files based on some combination of characters appearing in their names. For instance, type in jpg to select all files ending in *jpg, or *nix to select all files containing the contiguous letters nix.

  • Show hidden files: Sometimes you need to see the files you normally want out of sight.

  • Open terminal here: Open a terminal window with its working directory set to your location.

  • Make link: Make a symlink (sometimes called an "alias" or "shortcut") of the selected file or folder.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles Fast

The beautiful thing about Thunar, aside from its straight-forward simplicity, is how it defaults to immediately performing the action you've requested. There are file managers out there (including my personal favorite) that, at least without advanced knowledge of special shortcuts, interrupt a process in the interest of verification or clarification. Thunar only pauses when it absolutely needs feedback from you.

A great example is the Make link function in the Edit menu. In some file managers, when you create a symlink you're asked first whether or not you want to make a symlink, and then maybe what you'd like to name the symlink, and maybe even where you want the symlink to be created. All of that's really important information and results in a targeted and precise action. However, sometimes you don't need precision. Sometimes you just want speed, which is why Thunar just makes the symlink. No questions asked. When you tell it to create a symlink, it creates a symlink, with a name prefixed with "link to", in your current directory. If that's not what you wanted the symlink to be named, then you can rename it. If that's not where you want the symlink to exist, then you can relocate it. Your upfront investment is minimal, and you get results fast.

Bulk rename

Possibly Thunar's greatest contribution to the desktop is its bulk renaming function. How many times have you come home from vacation with a hundred photos called some variation of IMG_2022-01-04_10-55-12.JPG, which you add to a thousand other photos with similarly meaningless names? There are lots of photo managers out there that can help you organize, browse, and tag those photos, but there's nothing like a descriptive name to start out with. With Thunar, you can select hundreds of files, right-click, and select Rename for a bulk renaming interface.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

Imagine opening your ~/Pictures folder and seeing hundreds of photos with meaningful names! You probably don't even dare, but with Thunar it's actually possible!

Runic magic

It's unclear whether Thunar is the product of mortal programmers or the magical denizens of Asgard. There's a very high probability of the former, but there's also the likelihood that you'll feel like the latter when you use it. It's a humble and simple file manager with a powerful feature set. It may even be a worthy replacement for your existing GNOME file manager, or at the very least worthy of being included in your dock. Install Thunar and wield its power.

It's unclear whether Thunar is the product of mortal programmers or the magical denizens of Asgard.

Image by:

Pixabay. CC0 1.0

Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

8 ideas for measuring your open source software usage

Fri, 12/02/2022 - 16:00
8 ideas for measuring your open source software usage Georg Link Fri, 12/02/2022 - 03:00

Those of us who support open source project communities are often asked about usage metrics — a lot. The goal of these metrics is usually to demonstrate the software's importance as measured by its user base and awareness. We typically want to know: how many people use the software, how many installations are there, and how many lives are being touched.

To make a long story short: We cannot answer these questions directly.

Sorry to disappoint you if you were hoping for a definitive solution. No one has the perfect answers to questions about usage metrics. At least, no precise answers.

The good news is that there are approximations and alternative metrics that can satisfy your thirst for knowledge about the software's usage, at least partially. This article explores these alternatives including their benefits and shortcomings.

Downloads

When you visit websites that offer software, you can often see how many times the software has been downloaded. An example that comes to mind is Firefox, which used to have a download counter. It was an impressive number and gave the impression that Firefox was a popular browser—which it was for a while.

However, individual behavior can directly impact the accuracy of this number. For example, when a person wipes their machine regularly, each rebuild incurs a separate download. To account for this reality, there needs to be a way to subtract a few dozen (maybe hundreds) downloads from the number because of that one person.

Not only can downloads overestimate usage, but they can also underestimate usage. For instance, a system administrator may download a new version of Firefox once to a flash drive and then install it on hundreds of devices.

Download metrics are easy to collect because you can log each download request on the server. The problem is that you don't know what happens to the software after it is downloaded. Was the person able to use the software as anticipated? Or did the person run into issues and abandon the software?

For open source projects, you can consider a variety of download metrics, such as the number of binaries downloaded from:

  • the project website
  • package managers such as npm, PyPi, and Maven
  • code repositories like GitHub, GitLab, and Gitee

You may also be interested in downloads of the source code because downstream projects are most likely to use this format (also read How to measure the impact of your open source project). Relevant download metrics include:

  • The number of clones (source code downloads) from code repositories like GitHub, GitLab, and Gitee
  • The number of archives (tar, zip) downloaded from the website
  • The number of source code downloads through package managers like npm, PyPi, and Maven

Download metrics for source code are an even less reliable measure than binary downloads (although there is no research to demonstrate this). Just imagine that a developer wants to use the most recent version of your source code and has configured their build pipeline to always clone your repository for every build. Now imagine that an automated build process was failing and retrying to build, constantly cloning your repository. You can also imagine a scenario where the metric is lower than expected—say the repository is cached somewhere, and downloads are served by the cache.

[ Related read 5 metrics to track in your open source community ]

In conclusion, download metrics are good proxies for detecting trends and providing context around current usage. We cannot define specifically how a download translates to usage. But we can say that an increase in downloads is an indicator of more potential users. For example, if you advertise your software and see that download numbers are higher during the campaign, it would be fair to assume that the advertisement prompted more people to download the software. The source and metadata of the download can also provide additional context for usage patterns. What versions of your software are still in use? What operating system or language-specific versions are more popular? This helps the community prioritize which platforms to support and test.

More on data science What is data science? What is Python? How to become a data scientist Data scientist: A day in the life Use JupyterLab in the Red Hat OpenShift Data Science sandbox Whitepaper: Data-intensive intelligent applications in a hybrid cloud blueprint MariaDB and MySQL cheat sheet Latest data science articles Issues

As an open source project, you probably have an issue tracker. When someone opens an issue, two common goals are to report a bug or request a feature. The issue author has likely used your software. As a user, they would have found a bug or identified the need for a new feature.

Obviously, most users don't take the extra step to file an issue. Issue authors are dedicated users and we are thankful for them. Also, by opening an issue, they have become a non-code contributor. They may become a code contributor. A rule of thumb is that for every 10,000 users, you may get 100 who open an issue and one who contributes code. Depending on the type of user, these ratios may differ.

With regard to metrics, you can count the number of issue authors as a lower-bound estimation for usage. Related metrics can include:

  • The number of issue authors
  • The number of active issue authors (opened an issue in the last 6 months)
  • The number of issue authors who also contribute code
  • The number of issues opened
  • The number of issue comments written
User mailing lists, forums, and Q&A sites

Many open source projects have mailing lists for users, a forum, and presence on a Q&A site, such as Stack Overflow. Similar to issue authors, people who post there can be considered the tip of the iceberg of users. Metrics around how active a community is in these mailing lists, forums, and Q&A sites can also be used as a proxy for increasing or decreasing the user base. Related metrics can focus on the activity in these places, including:

  • The number of user mailing list subscribers
  • The number of forum users
  • The number of questions asked
  • The number of answers provided
  • The number of messages created
Call-home feature

To get accurate counts of users, one idea is to have your software report back when it is in use.

This can be creepy. Imagine a system administrator whose firewall reports an unexpected connection to your server. Not only could the report never reach you (it was blocked), but your software may be banned from future use.

Responsible ways to have a call-home feature is an optional service to look for updates and let the user know to use the latest version. Another optional feature can focus on usage telemetry where you ask the user whether your software may, anonymously, report back how the software is used. When implemented thoughtfully, this approach can allow users to help improve the software by their style of using it. A user may have the opinion: "I often don't allow this usage information sharing but for some software I do because I hope the developers will make it better for me in the long term."

Stars and forks

Stars and forks are features on social coding platforms like GitHub, GitLab, and Gitee. Users on these platforms can star a project. Why do they star projects? GitHub's documentation explains, "You can star repositories and topics to keep track of projects you find interesting and discover related content in your news feed." Starring is the equivalent of bookmarking and also provides a way to show appreciation to a repository maintainer. Stars have been used as an indicator of the popularity of a project. When a project has a big announcement that attracts considerable attention, the star count tends to increase. The star metric does not indicate the usage of the software.

Forks on these social coding platforms are clones of a repository. Non-maintainers can make changes in their fork and submit them for review through a pull request. Forks are more a reflection of community size than stars. Developers may also fork a project to save a copy they can access even after the original repository has disappeared. Due to the use of forks in the contribution workflow, the metric is a good indicator for the developer community. Forks do not typically indicate usage by non-developers because non-developers usually do not create forks.

Social media

Social media platforms provide gathering places for people with shared interests, including Facebook, Instagram, LinkedIn, Reddit, Twitter, and more. Using a social media strategy, open source projects can attract people with interest and affinity for their projects by setting up respective gathering spaces on these platforms. Through these social media channels, open source projects can share news and updates and highlight contributors and users. They can also be used to meet people who would not otherwise interact with your project.

We are hesitant to suggest the following metrics because they have no clear connection to actual usage of your software and often require analysis for positive, negative, and neutral sentiment. People may be excited about your project for many different reasons and want to follow it without actually using it. However, like other metrics already discussed, showing that you are able to draw a crowd in social media spaces is an indicator of the interest in your project overall. Metrics for different social media platforms may include:

  • The number of followers or subscribers
  • The number of messages
  • The number of active message authors
  • The number of likes, shares, reactions, and other interactions
Web analytics and documentation

Website traffic is a useful metric as well. This metric is influenced more by your outreach and marketing activities than your number of users. However, we have an ace up our sleeve: our user documentation, tutorials, handbooks, and API documentation. We can see what topics on our website draw attention, including documentation. The number of visitors to the documentation would arguably increase with an increase in the number of discrete users of the software. We can therefore detect general interest in the project with visitors to the website and more specifically observe user trends by observing visitors to the documentation. Metrics may include:

  • The number of website visitors
  • The number of documentation visitors
  • The duration visitors spend on your website or in documentation
Events

Event metrics are available if you are hosting events around your project. This is a great way to build community. How many people submit abstracts to speak at your events? How many people show up to your events? This can be interesting for both in-person and virtual events. Of course, how you advertise your event strongly influences how many people show up. Also, you may co-locate your event with a larger event where people travel anyway, and thus, are in town and can easily attend your event. As long as you use a consistent event strategy, you can make a case that a rise in speaker submissions and attendee registrations are indicative of increasing popularity and user base.

You don't need to host your own event to collect insightful metrics. If you host talks about your project at open source events, you can measure how many people show up to your session focused on your project. At events like FOSDEM, some talks are specifically focused on updates or announcements of open source projects and the rooms are filled to the brim (like almost all sessions at FOSDEM).

Metrics you might consider:

  • The number of attendees at your project-centric event
  • The number of talks submitted to your project-centric event
  • The number of attendees at your project-centric talks
Conclusion about approximating usage of open source software

As we've illustrated, there are many metrics that can indicate trends around the usage of your software, and all are imperfect. In most cases, these metrics can be heavily influenced by individual behavior, system design, and noise. As such, we suggest that you never use any of these metrics in isolation, given the relative uncertainty of each one. But if you collect a set of metrics from a variety of sources, you should be able to detect trends in behavior and usage. If you have the means to compare the same set of metrics across multiple open source projects with commonalities—such as similar functionality, strong interdependencies, hosted under the same foundation, and other characteristics—you can improve your sense of behavioral baselines.

Note that in this overview, we've also chosen to highlight metrics that evaluate direct usage. As most software depends on a variety of other software packages, we would be remiss if we did not mention that usage and behavior can also be heavily impacted by indirect usage as part of a dependency chain. As such, we recommend incorporating the count of upstream and downstream dependencies as another layer of context in your analysis.

In closing, as the wielder of data and metrics, we encourage you to recognize the power and responsibility that you have for your stakeholders. Any metric that you publish has the potential to influence behavior. It is a best practice to always share your context—bases, sources, estimations, and other critical contextual information—as this will help others to interpret your results.

We thank the CHAOSS Community for the insightful conversation at CHAOSScon EU 2022 in Dublin, Ireland that sparked the idea for this blog post and to the CHAOSS Community members who reviewed and helped improve this article.

Wondering how to collect usage metrics for your open source software project? Consider the pros and cons of using these alternatives.

Community management Data Science What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. 32 points Open Enthusiast Author Register or Login to post a comment.

Try this Java file manager on Linux

Fri, 12/02/2022 - 16:00
Try this Java file manager on Linux Seth Kenlon Fri, 12/02/2022 - 03:00

Computers are fancy filing cabinets, full of virtual folders and files waiting to be referenced, cross-referenced, edited, updated, saved, copied, moved, renamed, and organized. In this article, we're taking a look at a file manager for your Linux system.

At the tail end of the Sun Microsystem days, there was something called the Java Desktop System, which was strangely not written in Java. Instead, it was a (according to sun.com at the time) "judicious selection of integrated and tuned desktop software, most based on open source and open standards." It was based on GNOME, with an office suite, email and calendaring apps, instant messaging, "and Java technology." I found myself musing about what it would take to create a desktop in Java. Objectively, a desktop doesn't actually consist of all that much. The general consensus seems to be that a desktop is made up of a panel, a system tray, an application menu, and a file manager.

It's an interesting thought exercise to imagine an actual Java desktop. Not enough to start an open source project with that as its aim, but enough for a quick web search for the necessary components. And as it turns out, someone has written and maintains a file manager in Java.

JFileProcessor

The Java file manager I found is called JFileProcessor, or JFP for short. It's a fascinating exercise not just in Java, but specifically in Groovy, a popular scripting language for Java.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

As a file manager, JFileProcessor takes a minimal approach to both design and function. It lets you view, open, move, copy, cut, or delete files on your local system and on remote systems. It's not particularly customizable, it doesn't have extra features like split panels or movable panes. It's not built around any central theme aside from managing files. JFileProcessor is refreshing, in a way, because of its simplicity. This is a file manager, and that's all. And sometimes that's all you want in a file manager.

I've written about options to theme Java Swing before, and that technique is technically an option for this open source application. However, I think part of the charm of this application is what OpenSolaris called its "Blueprint" theme. It's a nostalgic look of Java, and I've enjoyed running it in its native GUI appearance as a callback to my OpenSolaris (now OpenIndiana) laptop.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles User experience

Design aside, what really matters is user experience. JFileProcessor has just three buttons that you use on a daily basis: Up, back, and forward. They aren't bound to keyboard shortcuts, so you do have to click the buttons to navigate (or use the Tab key to select a button). I do a lot with keyboard shortcuts when using graphical applications, so this slowed me down a lot as I tried to navigate my system. However, there are times when I'm actually just lazily browsing files, and for that JFileProcessor worked exactly as I needed it.

There's a search component to JFileProcessor, too. As long as you set a reasonable starting folder, the search is quick and intelligent, allowing for both search globs and regex patterns. I used this feature regularly when searching for a specific e-book or comic archive or game rulebook, for instance, or any time that I had a rough idea that directory contained an item but couldn't be bothered to click all the way through to the destination. A quick search through the subdirectories inevitably returned the obvious result, and a double-click opened the file to whatever XDG preference I had set (Evince for PDFs, Foliate for eBooks, and so on.)

A right-click on any file or directory brings up a context menu. It's got most of the common tasks you'd expect: Copy, Cut, Paste, Delete, Rename, New. It's got some nice additions, too.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

For instance, you can copy just the filename to your clipboard or save a path to a file. You can also run some scripts, including one to batch rename files, one to run a command on selected files, one to create a ZIP or TAR archive, and many more. And of course, there are several options for the coder, including opening a terminal at your current location and opening a new coding window.

Install

I'm a real fan of Java. It's a clear language with sensible delimiters and a firm stance on cross-platform compatibility. I enjoy it as a language, and I love seeing what programmers create with it.

JFileProcessor is aptly named. It's an effective way to process files, in the sense that JFileProcessor gives you a simple window into the files of data on your system and allows you to interact with them, graphically, in the same way you're likely to interact with them from a terminal. It's not the most efficient file manager I've used, nor the one with the most features. However, it's a pleasant application that provides you with the basic tools you need for file management with a relatively small codebase that makes for some stellar afternoon reading.

JFileProcessor takes a minimal approach to both design and function as a Linux file manager.

Image by:

Pixabay. CC0.

Linux Java What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Learn JavaScript in 2023

Thu, 12/01/2022 - 16:00
Learn JavaScript in 2023 Opensource.com Thu, 12/01/2022 - 03:00

With JavaScript’s 27th anniversary approaching in just a few days, we at Opensource.com are reflecting on how it has evolved into one of the most commonly-used programming language in the world. Why is it so popular? JavaScript is a universal language beloved by developers of all levels from beginners to advanced users. It can run anywhere from your phone to your server. And of course, there are the frameworks. From ReactJS to AureliaJS, there’s a framework for nearly every use case. Best of all, JavaScript is supported by a thriving open source community. 

To celebrate JavaScript’s milestone, we’ve put together a collection of JavaScript tutorials to help you continue your development journey. Authors Mandy Kendall, Seth Kenlon, Jessica Cherry, Sachin Samal, Ajay Pratap, and Ramakrishna Pattnaik contributed to this downloadable eBook. With it, you’ll have a chance to practice your JavaScript code by writing a guessing game. Then get familiar with React and even build your own app. This JavaScript guide gives you quick access to more than 165 terms you need to know to level up your skills. 

Download our new JavaScript programming guide in honor of the popular programming language's 27th anniversary.

Image by:

Opensource.com

JavaScript Download the eBook Learn JavaScript: 6 tutorials This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. 57 points Pittsburgh, Pennsylvania

Mandy Kendall is a front-end web developer, educator, and award-winning photographer with a focus on web accessibility and environmental issues. She currently teaches User-Centered Design for the School of Computing and Information at the University of Pittsburgh. In addition to programming and photography, she also enjoys going on adventures and finding all the quirky attractions her home state of Pennsylvania has to offer.

Open Enthusiast Author 28112 points New Zealand (South Island)

Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time. He is one of the maintainers of the Slackware-based multimedia production project Slackermedia.

User Attributes Team Open Source Super Star Moderator's Choice Award 2011 100+ Contributions Club Best Interview Award 2017 Author Columnist Contributor Club 189 points Irving, Texas

Sachin Samal is a web designer and developer with an experience in design, development, and implementation of strategic architectures of web and mobile applications at an enterprise level. He is an open-source enthusiast and contributor. He believes in exchange of knowledge of programming.

I love trekking, hiking and camping with my wife. I am down for that any day of the week…

*/ /*-->*/ /*-->*/ | Follow SachinSamal6 Open Minded Author Contributor Club 1718 points Durham NC

Tech nomad, working in about anything I can find.
Evangelist of silo prevention in the IT space, the importance of information sharing with all teams.
Believer in educating all and open source development.
Lover of all things tech.

All about K8s, chaos and anything new and shiny I can find!

Mastodon ID

Take my card with you: https://jessicacherry.carrd.co/

| Follow alynderthered1 User Attributes Correspondent Open Source Champion People's Choice Award DevOps Author Correspondent Contributor Club 55 points India

Ajay Pratap is a Full-Stack developer from Agra, Uttar Pradesh, India. Currently working as an Senior Software Engineer at Red Hat India. He has contributed on Red Hat AMQ Online and currently contributing on Red Hat Managed Kafka Services Micro Frontends application. An open source enthusiast and contributor.

| Follow ajaypratap003 Open Enthusiast Author 140 points Bhubaneswar

Ramakrishna Pattnaik is a web developer from Bhubaneswar currently working as an Associate Software Engineer with the Red Hat Middleware team in Bangalore. An open source enthusiast and contributor. Loves fiction.

| Follow rkpattnaik_780 Open Minded Author Contributor Club Register or Login to post a comment.

Intangible gift ideas with open source in mind

Thu, 12/01/2022 - 16:00
Intangible gift ideas with open source in mind Phil Shapiro Thu, 12/01/2022 - 03:00

When the holidays roll around each year, you'll encounter some wonderful gift-giving guides for physical gifts. But how about intangible gifts? Some of the most meaningful gifts are intangible ones. Let me plant some ideas in your head in that regard, and explain how intangible gifts fit in perfectly with the open source way.

Growing up, my parents established an ethic for our family: "We fix things, build things, and take agency upon the world," became our family's motto. My dad, a trained pharmacist and the chief medical supply officer for UNICEF, would routinely do carpentry, car maintenance, plumbing, and electrical work at our house. My dad once used a paper clip to fix his broken-down VW car, stalled in heavy Parisian traffic in 1952.

Mom, she could sew anything, whip up a great meal with leftovers, and exercise her creativity in a thousand other ways. I loved watching my parents' resolve when they decided to undertake a project. They would literally chortle as they rolled up their sleeves, figuring out what they needed to do first, second, and third.

In the vein of do-it-yourself, back in 2005, when I was unemployed, I wanted to send a birthday gift to my niece, turning seven. Without funds to buy her a gift, I sat down and composed When I Was Seven. She adored receiving this gift and remembers it fondly seventeen years later. What could be more valuable than a gift that is remembered fondly seventeen years later? Incidentally, the graphics in this YouTube video were created using LibreOffice Draw. (Back then, LibreOffice was called OpenOffice.)

More great content Free online course: RHEL technical overview Learn advanced Linux commands Download cheat sheets Find an open source alternative Explore open source resources Give wonder

Did you know that wondering can be a gift? I work at a public library, so I know all about the value of wondering. You too can bump up the wonderings in your life—and pass along that wondering as an intangible gift in the conversations you have with others. For example, this past week I've been wondering where would be a good location to set up a large, rural makerspace. Some YouTube videos about wood-powered trucks, cars, and bicycles got my synapses thinking. Wood is a renewable resource. Maybe we ought be using it more.

"Hmmmm," I thought to myself. "What's the most forested state in the United States?" I recall that 90 percent of Maine is covered in forests. So I did a web search for how many trees there are in Maine. I was prepared to encounter a large number—such as 5 or 10 million. I wasn't prepared to encounter the actual number—23 billion.

So with 23 billion trees, you could have a large, rural makerspace powered by wood-powered gasifiers, along with solar, wind and micro-hydro power (as long as the property has a fast-flowing stream or river on it.) People traveling to such a place could have their electrical vehicles recharged at the makerspace, reducing their travel costs. Trees are a renewable resource, and if used wisely (not wastefully) could provide heating, cooking, and electrical power to a rural makerspace. People could learn all about sustainability at this rural makerspace, too.

As you can see, wondering takes your mind places. My wonderings allowed me to be one of the first persons in the world to see the bicycle treehouse elevator, in Idaho, back in August, 2013. I was also one of the first to see the trivia vending machine (Raspberry Pi powered), originating from Southern Methodist University and the Dallas Makerspace.

Wondering is contagious. At your family's dinner table, make it a practice to use the phrase, "I was wondering..." That's an intangible gift you can give others. Wonder together with friends, too. Back in 2007, I got together with some friends to create a spoof YouTube video—which was chosen as a YouTube Editor's Choice and featured on the front page of YouTube. This particular video was created using proprietary software, but I knew in 2007 that similar videos could be created using open source software in coming years. Today, I'd be using OpenShot, Blender, KDEnlive to create this video.

In terms of intangible gifts you give others, find fun small projects where you're exploring something that nobody in the world has ever done before. Before the pandemic, I decided to upload an 8K digital storytelling video to YouTube, created using LibreOffice Draw. Of the 8 billion people living on planet Earth, there's (roughly speaking) one person using LibreOffice Draw to create 8K videos on YouTube. That would be me. And, in the process of doing so, I teach others how they can do so, too.

Final thought

Let me leave you with one last thought. Open source is not only a software creation method, it is an approach to living one's life. I find it an enriching way to live one's life—and this enrichment can be given to others.

Gratis.

Give that gift, in multiple ways, to loved ones in your life. Do it for the holidays and maybe the process will become a family habit. A year-round family habit. Spread it around the neighborhood. See what happens.

Consider giving the priceless gift of wonder, curiosity, or heartfelt art this holiday season.

Image by:

Photo by Aaron Haley, CC BY-SA 4.0

Art and design Video editing LibreOffice What to read next 7 maker gifts for kids and teens This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. 1 Comment Register or Login to post a comment. Phil Shapiro | December 1, 2022 Register or Login to like

Max Jarrell, of Los Altos, California, once asked his parents to install Inkscape as his Christmas present. That is all he wanted for Christmas. This anecdote is reported in this PCWorld article https://www.pcworld.com/article/494626/inkscape-3.html For that Christmas, his parents learned the deep value of non-monetary gifts.

5 reasons I use the Dolphin file manager on Linux

Thu, 12/01/2022 - 16:00
5 reasons I use the Dolphin file manager on Linux Seth Kenlon Thu, 12/01/2022 - 03:00

Computers are basically fancy file cabinets, full of folders and files waiting to be referenced, cross-referenced, edited, updated, saved, copied, moved, renamed, and organized. Of course, the files and folders are only virtual, and so software developers came up with the modern "desktop" user interface. Your screen is the top of your "desk," which you can use as a surface for taking out files from their folders so you can review and work on them. The analogy seems almost quaint these days because computers are so much more than just a filing cabinet. And yet the model remains, for many of us, as the primary way we interact with data on our personal computers, which makes humble file manager software some of the most important applications you use.

Dolphin on Linux Image by:

(Seth Kenlon, CC BY-SA 4.0)

The KDE Plasma Desktop provides Dolphin as its file manager. At first glance, it's a simple and almost minimal application. Don't let that fool you, though. There's a lot of potential in how you interact with the files on your computer, and Dolphin recognizes that. Here are five of my favorite Dolphin features.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles 1. Fast launches

Dolphin is quick to launch, and I don't mean that Dolphin itself launches quickly, but that the files you use within Dolphin can be opened quickly. A longtime KDE convention is that a single click of the mouse opens a file. That's admittedly counter-intuitive at first. After all, everybody knows you use a single click to select something and a double-click to open. But think about it. When you're selecting something, you're probably engaged in something relatively ponderous. You select files to then do something with them. The act of selection isn't the main action, it's the prep work for the action. There's no immediacy to selection.

But when you open something, you've already made up your mind. You want the file opened so you can start working. There's immediacy to opening a file.

If you look at it that way, it makes sense to require fewer clicks to open a file. So with Dolphin, by default at least, a single click opens a file in its default application. To select a file, you can either click on a Selection button overlaid over the icon, or click and drag to make a group selection. None of this is what you're used to, maybe, and it may seem unnatural, but after you've tried it you won't be able to tolerate a less efficient system.

Faster launch (the other kind)

This isn't a Dolphin feature specifically, but it deserves recognition. Thanks to the kdeinit subsystem of the KDE Plasma Desktop, Dolphin and many other KDE applications benefit from function pre-loading. Essentially, processes are launched by forking and loading a dynamic library containing a ''kdemain()'' function, which gives the typical KDE application a boost to launch time (I haven't timed it myself, but they say it's 2.5 times faster than without) and a reduction in memory consumption.

2. Contextual actions

One of the most basic and most common actions you do with a file manager is move and copy files. In fact, for many people, that's all a file manager is for.

In Dolphin, when you drag-and-drop a file from one place to another, you're given a pop-up contextual menu so you can quickly choose whether you're copying, moving, or symlinking the file. If that slows you down, you can press a modifier key while dragging: Shift to move, Ctrl to copy, or Ctrl+Shift to link. It's fast, efficient, and friendly.

Image by:

​(Seth Kenlon, CC BY-SA 4.0)

3. Power of Qt

The KDE Framework is based on the Qt framework, a famously flexible graphical toolkit. Not all KDE applications have the opportunity to take advantage of that, but Dolphin has several features that draw upon Qt's modular design. For instance, if you don't like the Places panel on the left of the window, you can move it to the right side of the window, or remove it entirely. Move the toolbar, remove the menu bar and status bar. Qt stops short of letting you redesign Dolphin entirely, but there's enough malleability for you to be able to change its layout to what works best for you.

Here's my personal Dolphin configuration:

Image by:

(Seth Kenlon, CC BY-SA 4.0)

4. Plugins

Dolphin isn't just Dolphin. It's Dolphin plus any number of plugins you choose to enable. There are plugins for several version control systems, including Git. There are lots of ways to interact with Git, and Dolphin adds one more way for convenience. I don't often think that I'm going to use Dolphin as my Git interface, but with Dolphin version control plugins enabled, it's too easy not to use Dolphin as my Git interface. Nothing could be more natural than adding a file to staging, or adding a commit message, or even pushing to a remote repository, with the file manager that you're using to browse through the files anyway.

5. Options

They're not technically plugins because they're built along with the application, but Dolphin has a staggering number of optional features. You don't have to activate them all at once, but there's plenty of features in Dolphin for you to discover over years of use. For instance, there's an option to show a filter bar, which you can use as a kind of instant find command. You can use tabs in Dolphin, or split the Dolphin window into panes, you can enable expandable folders or choose to click into them, you can open archives as folders, you can choose to view thumbnail previews of certain files or deactivate them for other filetypes, and much more.

Dolphin and the modern Linux desktop

Dolphin, like KDE, thrives on providing you, the user, options, by letting you decide what you want activated and what you want to ignore. Dolphin isn't the minimal lightweight file manager you compile and install on a 10-year old computer you've rescued from the bin (although I've run it as a file manager for Fluxbox on some surprisingly old computers with success), it's the one you feature on your latest PC build. In short, Dolphin is the high tech desktop experience you'd expect from an advanced operating system like Linux. Dive in!

The KDE Plasma Desktop provides the Dolphin file manager on Linux. It may appear minimal, but its useful features make a splash.

Image by:

(WordPress, CC0 License)

Linux What to read next 24 Linux desktops you need to try This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Is sustainability still a thing in open source?

Wed, 11/30/2022 - 16:00
Is sustainability still a thing in open source? Daniel Curto-Millet Wed, 11/30/2022 - 03:00

Eugen Rochko just reported that the social service Mastodon had "hit 1,028,362 monthly active users […] 1,124 new Mastodon servers since Oct 27 and 489,003 new users". Known mainly by open source developers, Mastodon has suddenly become mainstream, promising to take inclusive, open, and free values to social media. If Mastodon was sustainable, it is now thriving, attracting both users and developers, and able to launch more than 1,000 servers in a matter of days. How can this increase in users and infrastructure be explained? In this article, we want to suggest that there are different kinds of sustainability in open source and that these can have interesting interactions.

We know intuitively open source is sustainable: It's been around for decades, its importance keeps growing in the digital economy, and public institutions actively try to participate in open source ventures. Still, open source sustainability remains a key concern for both practitioners and academics. On the practice side, recent projects like Bitergia and Augur are identifying holistic measures of sustainability and project health. An entire group meets to discuss open source sustainability. For academics, a recent call for papers from IEEE asks for contributions on how public bodies can improve the long-term sustainability of open source projects.

3 types of sustainability

A recent article argues that there are three kinds of sustainability: Resource-based, interactional, and infrastructural. Resource-based sustainability has historically attracted the most concern. This sustainability refers to the capacity of open source actors to attract resources such as developers or value such as knowledge. A large part of the world used to be bewildered by the ability to attract contributors. One question asked by economists back in the day was, "Why should thousands of top-notch programmers contribute freely to the provision of a public good? Any explanation based on altruism only goes so far" (Lerner and Tirole, 2000, p. 2). Although the sustainability of open source no longer hangs on its ability to attract people, large numbers of contributors are still needed. Those projects that no longer attract them risk maintenance and security issues.

Interactional sustainability concerns what kinds of relations are created and sustained in open source. What value do certain interactions bring? How do developers collaborate to make the best software possible? For example, the historical debates between Free software and open source deal with what kind of interactions should be favored in open source, with whom, and for what purpose. The existence of mentorship programs, such as Red Hat's, shows the importance of passing down 'open' and reciprocal values. More recently, the introduction of codes of conduct has also aimed at better defining desired values of interaction, ones that are inclusive.

More great content Free online course: RHEL technical overview Learn advanced Linux commands Download cheat sheets Find an open source alternative Explore open source resources

The final kind of sustainability is about the infrastructures needed for any work to be carried out. A lot of open source development depends on infrastructures. Without GitLab, GitHub, or even Git, open source development would be much costlier and more complicated to set up. These kinds of projects act as platforms that enable many open source projects to develop and collaborate. They also create an underlying basis for how open source projects coordinate. Developers can more rapidly get to speed and start contributing to other projects when they share versioning systems.

Sustainability strategies in open source

When thinking of sustainability as being of multiple kinds, start analyzing how they interact. A recent Opensource.com article showcases one such example of sustainability relations. The article notes that it may seem paradoxical that firms must get involved in projects they don't control and collaborate with competitors. A firm's sustainability depends on its ability to foster a sustainable community. This is a hierarchical relationship: the sustainability of one leads to the sustainability of the other. But you may also question this hierarchical relation: do the different actors have different priorities or values of sustainability? Does the community have different sustainability goals than firms?

These questions lead you to think strategically about open source sustainability. Strategizing sustainability has a direct consequence: "achieving" sustainability in open source may not be possible. Actors take a calculative—though potentially mutually-beneficial—approach to sustainability. For example, an organization might want to quickly grow a project, while the community might prefer to focus on infrastructural sustainability. Further, sustainable priorities may evolve and become contested. Indeed, that there may be different kinds of sustainability means that you can also find yourself with contradictory sustainability objectives held by different actors (e.g., community, core developers, organizations, etc.). These objectives may independently be worthwhile but together, may incur trade-offs instead.

[ Related read 5 open source tips to reduce waste in web design ]

I'll look at one historic event in the Linux Kernel that shows how understanding sustainability was contingent on circumstances. In 2002, as the Linux Kernel was growing, Linus decided to change versioning systems to better accommodate increasing changes (infrastructural sustainability) since growing numbers of developers were contributing to the project. Having looked at the existing systems available, he finally chose BitKeeper because it fit best with development practices in Linux. That BitKeeper was a proprietary project did not bother Linus. Yet the decision to migrate to this versioning system annoyed many developers, with the risk that some might stop contributing (a decrease in resource-based sustainability). How could the open source flagship project rely on a proprietary system (a decrease in interactional sustainability)? Could the owners of the VC system cut access to it and take the community hostage (infrastructural sustainability risk)? Despite an email from the founder of BitKeeper promising not to do that, an attempt to reverse engineer BitKeeper (using developer resources and prioritizing interactional sustainability) ended the collaboration between Linux and BitKeeper.

The more recent example of Mastodon shows a synergistic growth scenario. The social platform could exponentially grow infrastructural sustainability by adding new servers and connecting new instances around topics, interests, or any kind of group. In contrast, its interactional sustainability was defined very well in clear codes of conduct and adapted per instance, thus being ready to increase its resource-based sustainability.

A sustainable future

These are brief examples, but they are enough to see that different kinds of sustainability influence each other, and not always positively. If there are multiple kinds of sustainability, then can you maximize all of them? Or should you maximize one as long as it does not negatively influence others? What type of sustainability should be prioritized? Or should you look for some sort of balance? These strategic questions are important for future, newly established, and mature open source projects since they face different sustainability struggles, and also for funding agencies that may want to evaluate how projects understand their sustainability priorities.

These examples show how different kinds of sustainability influence each other in open source.

Image by:

Photo by Roman Synkevych on Unsplash

Sustainability What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Get to know Lua for loops in 4 minutes

Wed, 11/30/2022 - 16:00
Get to know Lua for loops in 4 minutes Seth Kenlon Wed, 11/30/2022 - 03:00

In programming, iteration is an important concept because code often must scan over a set of data several times so that it can process each item individually. Control structures enable you to direct the flow of the program based on conditions that are often established dynamically as the program is running. Different languages provide different controls, and in Lua, there's the while loop, for loop, and repeat until loop. This article covers for loops. I will cover while and repeat until loops in a separate article.

For loop

A for loop takes a known quantity of items and ensures that each item is processed. An "item" can be a number. It can also be a table containing several entries or any Lua data type. The syntax and logic are a little flexible, but the syntax allows for these parameters, each of which essentially describes a counter:

  • Starting value of the counter
  • Stop value
  • The increment you want the counter to advance

For instance, suppose you have three items and want Lua to process each. Your counter could start at 3 and last until 1, at an increment of -1. That renders the count of 3, 2, 1.

mytable = { "zombie", "Halloween", "apocalypse" }

for count = 3, 1, -1 do
  print(count .. ": " .. mytable[count])
end

Run the code to ensure all three items are getting processed:

$ lua ./for.lua
3: apocalypse
2: Halloween
1: zombie

This code effectively processed the table in "reverse" because it was a countdown. You can count up, instead:

for count = 1, 3, 1 do
  print(mytable[count])
end

This example processes the table from lowest index to highest:

$ lua ./for.lua
1: zombie
2: Halloween
3: apocalypseIncrements

You can change the increment, too. For instance, maybe you want a zombie apocalypse without all the pomp and circumstance of Halloween:

mytable = { "zombie", "Halloween", "apocalypse" }

for count = 1, 3, 2 do
  print(mytable[count])
end

Run the code:

$ lua ./for.lua
zombie
apocalypse

The example printed 1 and 3 because the first count was 1, which was then incremented by 2 (for a total of 3).

Counter

Sometimes you don't know the number of times you need Lua to iterate over data. In this case, you can set your counter to a variable populated by some other process.

Also, the word count isn't a keyword. It's just what I'm using in my sample code for clarity. It's common for programmers to use something shorter, such as i or c.

var = os.time()

if var%2 == 0 then
  mytable = { var }
else
  mytable = { "foo", "bar", "baz" }
end

for c = 1, #mytable, 1 do
  print(mytable[c])
end

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java An open source developer's guide to building applications

This code creates a variable containing the timestamp of when it was launched. If the timestamp is even (it has a modulo of 0 when divided by 2), then just the timestamp is placed into a table. If the timestamp is odd, it puts three strings into a table.

Now you can't be sure how many times your for loop needs to run. It's either once or thrice, but there's no way to be sure. The solution is to set the starting count to 1 and the final count to the length of the table (#mytable is the built-in shortcut to determine the length of a table).

It might take a few times of running the script to see both results, but eventually, you end up with something like this:

$ lua ./dynamic.lua
1665447960

$ lua ./dynamic.lua
foo
bar
bazFor loops with pairs and ipairs

If you've already read my article on table iteration, then you're already familiar with one of the most common for loops in Lua. This one uses the pairs or ipairs function to iterate over a table:

mytable = { "zombie", "Halloween", "apocalypse" }

for i,v in ipairs(mytable) do
  print(i .. ": " v)
end

The pairs and ipairs functions "unpack" the table and dump the values into the variables you provide. In this example, I use i for index and v for value, but the variables' names don't matter.

$ lua ./for.lua
1: zombie
2: Halloween
3: apocalypseFor loop

The for loop structure is common in programming and very common in Lua due to its frequent use of tables and the pairs function. Understanding the for loop structure and the options you have when controlling it means you can make clever decisions about how to process data in Lua.

Understanding the for loop structure and the options you have when controlling it means you can make clever decisions about how to process data in Lua.

Image by:

Opensource.com

Programming What to read next How to use loops in awk This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Build test scripts for your IoT platform

Wed, 11/30/2022 - 16:00
Build test scripts for your IoT platform Chongyuan Yin Wed, 11/30/2022 - 03:00

In my previous article, I introduced the open source test tool JMeter and used a simple HTTP test as an example to demonstrate its capabilities. This article shows you how to build test scripts for complex test scenarios.

The user interface displays a JMeter test script in the "tree" format. The saved test script (in the .jmx format) is XML. The JMeter script tree treats a test plan as the root node, and the test plan includes all test components. In the test plan, you can configure user-defined variables called by components throughout the entire test plan. Variables can also thread group behavior, library files used in the test, and so on. You can build rich test scenarios using various test components in the test plan.

Test components in JMeter generally have the following categories:

  • Thread group
  • Sampler
  • Logic controller
  • Listener
  • Configuration element
  • Assertion
  • Timer
  • Pre-processor
  • Post-processor
Thread groups

A thread group is the beginning point for all test plans (so all samplers and controllers must be placed under a thread group). A thread group can be regarded as a virtual user pool in which each thread is essentially a virtual user, and multiple virtual users perform the same batch of tasks simultaneously. Each thread is independent and doesn't affect the others. During the execution of one thread, the variable of the current thread doesn't affect the variable value of other threads.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

More on edge computing Understanding edge computing Why Linux is critical to edge computing eBook: Running Kubernetes on your Raspberry Pi Download now: The automated enterprise eBook eBook: A practical guide to home automation using open source tools eBook: 7 examples of automation on the edge What is edge machine learning? The latest on edge

In this interface, the thread group can be configured in various ways.

1. Action to be taken after a sampler error

The following configuration items control whether a test continues when an error is encountered:

  • Continue: Ignore errors and continue execution.
  • Start Next Thread Loop: Ignore the error, terminate the current loop of the thread, and execute the next loop.
  • Stop Thread: Stop executing the current thread without affecting the normal execution of other threads.
  • Stop Test: Stop the entire thread after executing threads have finished the current sampling.
  • Stop Test Now: The entire test execution stops immediately, even if it interrupts currently executing samplers.
2. Number of threads

This is the number of concurrent (virtual) users. Each thread runs the test plan completely independently without interfering with any others. The test uses multiple threads to simulate concurrent access to the server.

3. Ramp-up period

The Ramp-up time sets the time required to start all threads. For example, if the number of threads is set to 10 and the ramp-up time is set to 100 seconds, then JMeter uses 100 seconds to start and runs 10 threads (each thread begins 10 seconds after the previous thread was started).

If the ramp-up value is set small and the number of threads is set large, there's a lot of stress on the server at the beginning of the test.

4. Loop count

Sets the number of loops per thread in the thread group before ending.

5. Delay thread creation until needed

By default, all threads are created when the test starts. If this option is checked, threads are created when they are needed.

6. Specify thread lifetime

Control the execution time of thread groups. You can set the duration and startup delay (in seconds).

Samplers

A sampler simulates user operations. It's a running unit that sends requests to the server and receives response data from the server. A sampler is a component inside a thread group, so it must be added to the thread group. JMeter natively supports a variety of samplers, including a TCP Sampler, HTTP Request, FTP Request, JDBC Request, Java Request, and so on. Each type of sampler sends different requests to the server according to the set parameters.

TCP Sampler

The TCP Sampler connects to the specified server over TCP/IP, sends a message to the server after the connection is successful, and then waits for the server to reply.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

The properties that can be set in the TCP Sampler are as follows:

TCPClient classname

This represents the implementation class that handles the request. By default, org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl is used, and plain text is used for transmission. In addition, JMeter also has built-in support for BinaryTCPClientImpl and LengthPrefixedBinaryTCPClientImpl. The former uses hexadecimal packets, and the latter adds a 2-byte length prefix to BinaryTCPClientImpl.

You can also provide custom implementation classes by extending org.apache.jmeter.protocol.tcp.sampler.TCPClient.

  • Target server settings: Server Name or IP and Port Number specify the hostname or IP address and port number of the server application.
  • Connection Options: Determines how you connect to the server.
    • Re-use connection: If enabled, this connection is always open; otherwise, it's closed after reading data.
    • Close Connection: If enabled, this connection is closed after the TCP sampler has finished running.
    • Set No-Delay: If enabled, the Nagle algorithm is disabled, and the sending of small packets is allowed.
    • SO_LINGER: Controls whether to wait for data in the buffer to complete transmission before closing the connection.
    • End of line (EOL) byte value: Determines the byte value at the end of the line. The EOL check is skipped if the specified value is greater than 127 or less than -128. For example, if a string returned by the server ends with a carriage return, you can set this option to 10.
  • Timeouts: Set the connect timeout and response timeout.
  • Text to send: Contains the payload you want to send.
  • Login configuration: Sets the username and password used for the connection.
HTTP Request Sampler

The HTTP Sampler sends HTTP and HTTPS requests to the web server.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Here are the settings available:

  • Name and comments
  • Protocol: Set the protocol to send the request to the target server, which can be HTTP, HTTPS, or FILE. The default is HTTP.
  • Server name or IP address: The hostname or IP address of the target server to which the request is sent.
  • Port number: The port number that the web service listens on. The default port is 80 for HTTP and 443 for HTTPS.
  • Request method: The method for sending the request, commonly including GET, POST, DELETE, PUT, TRACE, HEAD, OPTIONS, and so on.
  • Path: The target URL (excluding server address and port) to request.
  • Content encoding: How to encode the request (applicable to POST, PUT, PATCH, and FILE).
  • Advanced request options: A few extra options, including:
    • Redirect Automatically: Redirection is not treated as a separate request and is not recorded by JMeter.
    • Follow Redirects: Each redirection is treated as a separate request and is recorded by JMeter.
    • Use KeepAlive: If enabled, Connection: keep-alive is added to the request header when JMeter communicates with the target server.
    • Use multipart/form-data for POST: If enabled, requests are sent using multipart/form-data or application/x-www-form-urlencoded.
  • Parameters: JMeter uses parameter key-value pairs to generate request parameters and send these request parameters in different ways depending on the request method. For example, for GET, DELETE requests, parameters are appended to the request URL.
  • Message body data: If you want to pass parameters in JSON format, you must configure the Content-Type as application/json in the request header.
  • File upload: Send a file in the request. The HTTP file upload behavior can be simulated in this way (usually).
Logic Controllers

The JMeter Logic Controller controls the execution logic of components. The JMeter website explains it like this: "Logic Controllers determine the order in which Samplers are processed."

The Logic Controller can control the execution order of the samplers. Therefore, the controller needs to be used together with the sampler. Except for the once-only controller, other logic controllers can be nested within each other.

Logic controllers in JMeter are mainly divided into two categories. They can control the logical execution order of nodes during the execution of the test plan (a loop or conditional controller), or they can act in response to specific throughput or transaction count.

Transaction Controller

Sometimes, you want to count the overall response time of a group of related requests. In this case, you need to use a Transaction Controller.

The Transaction Controller counts the sampler execution time of all child nodes under the controller. If multiple samplers are defined under the Transaction Controller, then the transaction is considered successful only when all samplers run successfully.

Add a transaction controller using the contextual menu:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Generate parent sample: If enabled, the Transaction Controller is used as a parent sample for other samplers. Otherwise, the Transaction Controller is only used as an independent sample.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

For example, the unchecked Summary Report is as follows:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

If checked, the Summary Report is as follows:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Include duration of timer: If enabled, include a timer (a delay is added before and after the sampler runs).

Once Only Controller

The Once Only Controller, as its name implies, is a controller that executes only once. The request under the controller is executed only once during the loop execution process under the thread group. For tests that require a login, you can consider putting the login request in a Once Only Controller because the login request only needs to be executed once to establish a session.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

If you set the loop count to 2 and check the result tree after running, you can see that the HTTP request 3 under the Once Only Controller is only executed once, and other requests are executed twice.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Listeners

A listener is a series of components that process and visualize test result data. View Results Tree, Graph Results, and Aggregate Report are common listener components.

View Results Tree

This component displays the result, request content, response time, response code, and response content of each sampler in a tree structure. Viewing the information can assist in analyzing whether there is a problem. It provides various viewing formats and filtering methods and can also write the results to specified files for batch analysis and processing.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Configuration element

Configuration element provides support for static data configuration. It can be defined at the test plan level, or at the thread group or sampler level, with different scopes for different levels. Configuration elements mainly include User Defined Variables, CSV Data Set Config, TCP Sampler Config, HTTP Cookie Manager, etc.

User-Defined Variables Image by:

(Chongyuan Yin, CC BY-SA 4.0)

By setting a series of variables, you cause a random selection of values to be used in the performance test. Variable names can be referenced within the scope, and variables can be referenced as ${variable name}.

In addition to the User Defined Variables component, variables can also be defined in other components, such as Test Plans and HTTP Requests:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

For example, a defined variable is referenced in an HTTP Request:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Viewing the execution results, you can see that the value of the variable has been obtained:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

CSV Data Set Config

During a performance test, you may need parameterized input, such as the username and password, in the login operation. When the amount of concurrency is relatively large, the data generation at runtime causes a heavy burden on the CPU and memory. The CSV Data Set Config can be used as the source of parameters required in this scenario.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

The descriptions of some parameters in the CSV Data Set Config:

  • Variable name: Defines the parameter name in the CSV file, which the script can reference as ${variable name}.
  • Recycle on EOF: If set to True, this allows looping again from the beginning when reaching the end of the CSV file.
  • Stop thread on EOF: If set to True, this stops running after reading the last record in the CSV file.
  • Sharing mode: Sets the mode shared between threads and thread groups.
Assertions

The Assertion checks whether the request is returned as expected. Assertions are an important part of automated test scripts, so you should pay great attention to it.

JMeter commonly used assertions include Response Assertion, JSON Assertion, Size Assertion, Duration Assertion, Beanshell Assertion, etc. Below I introduce the frequently-used JSON Assertion.

JSON Assertion

This is used to assert the content of the response in JSON format. A JSON Assertion is added on an HTTP Sampler in this example, as shown in the following image:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

The root of the JSON path is always called $, which can be represented by two different styles: dot-notation (.) or bracket-notation ([]). For example; $.message[0].name or $['message'][0]['name'].

Here's an example of a request made to https://www.google.com/doodles/json/2022/11. The $[0].name value represents the 'name' part in the first array element in the response.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

The Additionally assert value specifies that the value of 'name' is to be verified, and the Expected value is expected to be '2022-world-cup-opening-day'.

Run the script and look at the results. You can see that the assertion has passed.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Here are the possible conditions and how they're treated:

  • If a response result is not in JSON format, it's treated as a failure.
  • If the JSON path cannot find the element, it fails.
  • If the JSON path finds the element, but no conditions are set, it passes.
  • If the JSON path finds an element that does not meet the conditions, it fails.
  • If the JSON path finds the element that meets the conditions, it passes.
  • If the JSON path returns an array, it iterates to determine whether any elements meet the conditions. If yes, it passes. If not, it fails.

Go back to JSON Assertion and check the Invert assertion.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Run the script, check the results, and you can see that the assertion failed:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Timers

The pause time between requests in the performance test is called "thinking time." In the real world, the pause time can be spent on content search or reading, and the Timer simulates this pause.

All timers in the same scope are executed before the samplers.

If you want the timer to be applied to only one of the samplers, add the timer to the child node of the sampler.

JMeter timers mainly include Constant Timer, Uniform Random Timer, Precise Throughput Timer, Constant Throughput Timer, Gaussian Random Timer, JSR223 Timer, Poisson Random Timer, Synchronizing Timer, and BeanShell Timer.

Constant Timer

A Constant Timer means that the interval between each request is a fixed value.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

After configuring the thread delay to 100 and 1000, respectively, run the script:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Check the data in the table, where #1 and #2 are the running results when the configuration is 100 milliseconds, and #4 and #5 are the running results when the configuration is 1000 milliseconds. You can see that the interval between #4 and #5 is significantly greater than that between #1 and #2:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Constant Throughput Timer

The Constant Throughput Timer controls the execution of requests according to the specified throughput.

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Configure the target throughput as 120 (note that the unit is minutes), and then select All active threads in current thread group (shared) based on the calculated throughput:

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Run the script, check the results, and observe that the throughput is approximately 2/second (120/60).

Image by:

(Chongyuan Yin, CC BY-SA 4.0)

Pre-processors and post-processors

A pre-processor performs some operations before the sampler request. It's often used to modify parameters, set environment variables, or update variables.

Similarly, a post-processor performs some operations after the sampler request. Sometimes, the response data needs to be used in subsequent requests, and you need to process the response data. For example, if the jwt token in the response is obtained and used for authentication in subsequent requests, the post-processor is used.

Using JMeter

The above is the introduction to the main test components of JMeter, and now you can feel confident in starting your own tests. In another article, I will explain using the MQTT plugin in JMeter.

Use JMeter to build test scripts for complex test scenarios in your IoT environment.

Image by:

CC BY 3.0 US Mapbox Uncharted ERG

Edge computing Internet of Things (IoT) What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Parse arguments with Lua

Tue, 11/29/2022 - 16:00
Parse arguments with Lua Seth Kenlon Tue, 11/29/2022 - 03:00

Most computer commands consist of two parts: The command and arguments. The command is the program meant to be executed, while the arguments might be command options or user input. Without this structure, a user would have to edit the command's code just to change the data that the command processes. Imagine rewriting the printf command just to get your computer to greet you with a "hello world" message. Arguments are vital to interactive computing, and the Lua programming language provides the {…​} expression to encapsulate varargs given at the time of launching a Lua script.

Use arguments in Lua

Almost every command given to a computer assumes an argument, even if it expects the argument to be an empty list. Lua records what's written after it launches, even though you may do nothing with those arguments. To use arguments provided by the user when Lua starts, iterate over the {…​} table:

local args = {...}

for i,v in ipairs(args) do
    print(v)
end

Run the code:

$ lua ./myargs.lua
$ lua ./myargs.lua foo --bar baz
foo
--bar
baz
----

Having no arguments is safe, and Lua prints all arguments exactly as entered.

Parse arguments

For simple commands, the basic Lua faculties are sufficient to parse and process arguments. Here's a simple example:

-- setup

local args = {...}

-- engine

function echo(p)
   print(p)
end

-- go

for i,v in ipairs(args) do
  print(i .. ": " .. v)
end

for i,v in ipairs(args) do
  if args[i] == "--say" then
    echo("echo: " .. args[i+1])
  end
end

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java An open source developer's guide to building applications

In the setup section, dump all command arguments into a variable called args.

In the engine section, create a function called echo that prints whatever you "feed" into it.

Finally, in the go section, parse the index and values in the args variable (the arguments provided by the user at launch). In this sample code, the first for loop just prints each index and value for clarity.

The second for loop uses the index to examine the first argument, which is assumed to be an option. The only valid option in this sample code is --say. If the loop finds the string --say, it calls the echo function, and the index of the current argument plus 1 (the next argument) is provided as the function parameter.

The delimiter for command arguments is one or more empty spaces. Run the code to see the result:

$ lua ./echo.lua --say zombie apocalypse
1: --say
2: zombie
3: apocalypse
echo: zombie

Most users learn that spaces are significant when giving commands to a computer, so dropping the third argument, in this case, is expected behavior. Here's a variation to demonstrate two valid "escape" methods:

$ lua ./echo.lua --say "zombie apocalypse"
1: --say
2: zombie apocalypse
echo: zombie apocalypse

$ lua ./echo.lua --say zombie\ apocalypse
1: --say
2: zombie apocalypse
echo: zombie apocalypseParse arguments

Parsing arguments manually is simple and dependency-free. However, there are details you must consider. Most modern commands allow for short options (for instance, -f) and long options (--foo), and most offer a help menu with -h or --help or when a required argument isn't supplied.

Using LuaRocks makes it easy to install additional libraries. There are some very good ones, such as alt-getopt, that provide additional infrastructure for parsing arguments.

Arguments are vital to interactive computing, and the Lua programming language provides the {…​} expression to encapsulate varargs given at the time of launching a Lua script.

Image by:

WOCinTech Chat. Modified by Opensource.com. CC BY-SA 4.0

Programming What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Give back to open source on Giving Tuesday

Tue, 11/29/2022 - 15:00
Give back to open source on Giving Tuesday Jason Hibbets Tue, 11/29/2022 - 02:00

Giving Tuesday is always a reminder to me to consider how to give back to open source projects, communities, and organizations. In 2012, GivingTuesday was created to encourage people to simply do good. "Since then, it has grown into a year-round global movement that inspires hundreds of millions of people to give, collaborate, and celebrate generosity."

When I think about all the ways I have benefited from "standing on the shoulder of giants," both professionally and personally. I start to think about all the individuals and organizations that have made being part of the open source community such a rewarding experience. Many have used an open source project or joined an open source community and immediately benefited from the contributions of past and current members.

When you dig a little deeper, you’ll find that many of the organizations listed below have volunteer opportunities, ways to get involved with their community, and simple things like sharing information about why you support the organization or joining a newsletter to stay updated. They offer a variety of ways to support them beyond just financial donations.

The list below is not an endorsement from myself or my employer, it is a collection of organizations for you to consider as you look at groups to support and ways to donate time, money, expertise, and other skills you might offer. I would encourage you to do your own research before making a donation, particularly if you are looking for any tax deductions.

18 free and open source organizations to consider for Giving Tuesday Black Girls Code

"We build pathways for young women of color to embrace the current tech marketplace as builders and creators by introducing them to skills in computer programming and technology."

ChickTech

"ChickTech is a national nonprofit organization empowering people of marginalized genders through tech programs and events." (See several options under the "Support us" tab.)

Creative Commons

"Creative Commons is a nonprofit organization that helps overcome legal obstacles to the sharing of knowledge and creativity to address the world’s most pressing challenges." 

Drupal Association

"The Drupal Association is a nonprofit 501©3 organization serving the international Drupal community." 

Electronic Frontier Foundation (EFF)

"The Electronic Frontier Foundation mission is to support and defend civil liberties and human rights online, they are a 501©3 organization."

Free Software Foundation (FSF)

"The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom."

Fosstodon and other Mastodon servers

"Fosstodon is part of the decentralized ActivityPub social network. “It’s open to anyone interested in free and open source technology."

Note: There are many instances of Mastodon servers creating a decentralized social network. This is just one example supporting open source and technology enthusiasts.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles Linux Foundation

"The Linux Foundation provides critical services to promote sustainable open source. Individual Supporter donations go directly into programs and resources that support growing communities."

Note: Donations to The Linux Foundation are not generally deductible by US taxpayers.

Let’s Encrypt

"Let’s Encrypt is a free, automated, and open certificate authority brought to you by the nonprofit Internet Security Research Group (ISRG) supporting a secure and privacy-respecting Web."

LibreOffice (The Document Foundation)

"The Document Foundation is a charitable foundation whose objective is the promotion and development of office software available for use by anyone free of charge. The foundation promotes a sustainable, independent, and meritocratic community for the international development of free and open source software based on open standards."

Open source hardware association

"The Open Source Hardware Association (OSHWA) aims to foster technological knowledge and encourage research that is accessible, collaborative, and respects user freedom."

Open Source Initiative (OSI)

"The Open Source Initiative (OSI) is a non-profit corporation with global scope formed to educate about and advocate for the benefits of open source and to build bridges among different constituencies in the open source community."

Note: Their membership drive begins on November 29.

Raspberry Pi Foundation

"The Raspberry Pi Foundation is a United Kingdom-based charity with the mission to enable young people to realize their full potential through the power of computing and digital technologies."

Software Freedom Conservancy

"Software Freedom Conservancy is a nonprofit organization centered around ethical technology whose mission is to ensure the right to repair, improve and reinstall software."

TransTech

"TransTech is an incubator for LGBTQ Talent with a focus on economically empowering the T, transgender people, in our community. TransTech is fiscally sponsored by Allied Media Projects making all donations tax-deductible."

PHP Foundation (Open Collective)

"We support, promote, and advance the PHP language."

Python Software Foundation

"The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to support and facilitate the growth of a diverse and international community of Python programmers."

The Wikimedia Foundation

"The Wikimedia Foundation is the nonprofit organization that supports Wikipedia, the other Wikimedia free knowledge projects, and our mission of free knowledge for every single person."

I’m almost certain that I did not list a group that you are passionate about. If you feel so inclined, please share an open source community that you think should be on this list in the comments below.

I hope this article inspires you to give something back, no matter how big or small, to an open source community or organization to help keep open source more sustainable.

Here are 18 ways to support and donate to free and open source organizations for Giving Tuesday.

Image by:

Opensource.com

Diversity and inclusion Tools Programming Linux Raspberry Pi Python Hardware LibreOffice What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

How open source is revitalizing the payphone

Mon, 11/28/2022 - 16:00
How open source is revitalizing the payphone Klaatu Mon, 11/28/2022 - 03:00

Phones used to act as the host for computer communication. Modems sent signals from computer to computer by utilizing the phone network. In today's world, though, computers have become the host for telephony apps. Phones aren't really phones any more, they're literal computers. This has enabled some amazing technology, but many people wonder whether we've lost something by giving up the concept of public phones. The PhilTel project in Philadelphia is seeking to change the trajectory of phone communication by reviving some old concepts. I was intrigued, so I spoke to Mike Dank about this exciting and unexpected development.

Klaatu: What's PhilTel?

Mike Dank: PhilTel is a telephone collective based in Philadelphia, Pennsylvania, focusing on making communications accessible to everyone by installing free-to-use payphones. While you'll be able to make standard telephone calls through our phones, we're also focusing on offering interesting services or experiences. We don't want to only facilitate human-to-human interaction but also human-to-machine interaction and give people an environment where they can explore the telephone network and learn from it.

Klaatu: Why are you installing free-to-use payphones? Surely everyone has a mobile phone these days.

Mike: Surprisingly, there are more people out there without mobile phones than you may think! While there are many that won't have a mobile phone due to socioeconomic disparities, others choose not to have them because of concerns about privacy, health, and the effects of being "plugged in" or reachable 24/7. My co-founder on this project does not own a mobile phone himself, so we have first-hand experience with what it is like to not have a phone on your person at all times and how important it is for there to be access to public telephones.

Philadelphia in particular has a lot of payphone use, even as payphone companies have been steadily removing phones from service year after year. Residents who rely on these phones are being increasingly marginalized and if this trend continues, many will be left without a communication platform they need to carry out their lives. At PhilTel, we are committed to increase access to telephone-mediated services through the preservation of public, free-to-use telephone infrastructure.

Klaatu: You obviously know a lot about phones. It makes me think of the phone phreaking scene in the 1950s.

Mike: Yes, "phone phreaking" is a term used to describe the culture and activities of people who explore the phone system and equipment connected to it. While people have been phreaking since the 1950s, it rose to prominence in the 1970s with the advent of the "blue box": a hobbyist-built, pocket sized device that could produce tones which would allow the user to place free long-distance calls. Later phreaking devices such as the "red box," commonly made by modifying a pocket tone dialer, would allow the user to imitate coin tones at a payphone so calls could be made for free. It's important to note that phone phreaking is still alive and well today, but the focus is on discovery and gaining an understanding of how the phone system works while communications fraud is now widely frowned upon.

In many ways, hacking and hacker culture can be seen as an offshoot of phreaking, and it is undeniable that phreaking had a direct influence on hacking as we know it today. With the advent of personal computing in the 1980s, many curious and tech-savvy people would communicate over bulletin board systems to share information about exploring the phone system and, increasingly, the computers that were connected to it.

Anyone who identifies as a hacker these days can trace the culture back to those early days of phone phreaking where the curious spent days or months or weeks doing experiments with the phone system. PhilTel is a "phreak-friendly" network, and we not only encourage exploration but also have resources to emulate aspects of the phone network of a bygone era. Do you want to use your vintage (or modern recreational) "blue box" or "red box" today? We have ways for you to do that!

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles

Klaatu: How did you get involved with PhilTel?

Mike: Well, I'm one of the PhilTel co-founders! PhilTel draws direct inspiration from a similar project known as Futel, based out of Portland, Oregon. My co-founder and I met a few years back and bonded over our love of telephone infrastructure, including visiting old telephone buildings and finding payphones scattered throughout the city. We had discussions about how it could be beneficial to start a project where we installed and operated payphones and we realized the only thing holding us back was simply sitting down and working out the details for how to do it!

Klaatu: Do you have a background in telephony?

Mike: I don't have any background in telephony myself, but I've had an interest in it since I bought my first Raspberry Pi in 2012 and went about setting up my own PBX so I could give extensions to different phones in my house and allow them to call one another. While I have a formal background in software engineering, I identify more as a hacker who likes to tinker and learn as I go. I'm very lucky to be working with my co-founder as he became interested in telephony in high school and gradually became interested in phreaking as well as VoIP. Nowadays, he primarily does telecom-related software development, including freelance Asterisk development for businesses and development of features and capabilities for telephone hobbyists.

Klaatu: Speaking of Asterisk, what other open source technologies are you using to make this project happen?

Mike: We strive to use as much open source technology as we can with PhilTel! Each payphone site that we will set up has a router running OpenWRT and WireGuard to get a secure VPN connection to our server. Our Linux-based server runs Asterisk, an open source PBX (private branch exchange) toolkit, to connect our phones to the PSTN and other internal services or hobbyist or collector phone networks. We are very fortunate in that my co-founder has an in-depth knowledge with Asterisk as he is a regular code contributor.

Klaatu: How can people get involved with PhilTel?

Mike: There are numerous ways to get involved! If you're a hacker, artist, or engineer with an interest in payphones and things that can be done with and through them, we'd love to hear from you (especially if you're an artist working with audio.) We're always looking for new things to add or new perspectives! If you're local to the Philadelphia area and have ownership of a physical location where we may put a phone, we're always looking for installation sites! If anything about PhilTel interests you, be sure to visit our website for more information and ways to contact us!

One of the founders of the PhilTel open source project shares why free-to-use payphones are critical to social infrastructure.

Image by:

Photo by Jonathan Chng on Unsplash

Mobile Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

3 open source audio tools for creators

Mon, 11/28/2022 - 16:00
3 open source audio tools for creators Ruth Cheesley Mon, 11/28/2022 - 03:00

Finding good quality, open source audio samples can be a challenge. I've been getting increasingly into composition and creating music in my spare time, using the open source tool Ardour and the creator-focused distribution Ubuntu Studio. I've been looking for samples of specific sounds or loops to include.

I'm familiar with many tools to find images, but until recently, I hadn't come across a similar option for audio resources.

Open source sound samples

Finding specific sounds can be challenging if you can't record them yourself. Several resources are available, but not many provide sounds under an open source license.

Freesound

Enter the incredible treasure trove that is Freesound, a collaborative database of Creative Commons licensed sounds where you can browse, download, and even contribute.

You can find pretty much anything on Freesound, from the sounds of a sleepy tour bus on the road to a door opening and closing or a ghostly shriek. While Freesound mainly focuses on sound samples, there are also some loops on the site. Many sounds are licensed under Creative Commons 0, so you can do whatever you like with them from a licensing perspective. However, that's not true for all of them, so check the license before you use anything, as you may need to credit the creator.

The site allows you to check out the sample rate, bit depth, and channels so you can be sure that the sample will work with your composition, and it has a built-in rating system and download count. A waveform display allows you to get some insight into the character of the sound sample before you preview it.

The search filters on Freesound are not as strong as other sites. Sounds will sometimes be grouped into packs of similar sounds, like this one for scary noises. This can help you quickly grab a bunch of similar sounds to play with. The quality of the samples is variable, so you might need to clean up the audio on some samples. If you're feeling bored, there's even an option to select a random sound from the database—and trust me, some are very random! Freesound also has a community forum where you can participate and learn from others.

Nasa space sounds

If you are looking for some otherworldly sounds or want to snoop on the conversations between Earth and space, the Nasa Space Sounds database might be a great place to look. It's fascinating to explore the recordings from the various missions and listen in on the communications back and forth, some of which are narrated. Several recordings have different sounds from different space missions, from the Sounds of Mars from Perseverance Rover to audio from the Apollo missions.

Sounds from the Nasa site are released under the Creative Commons category Public Domain Mark 1.0, meaning that it is free of known restrictions under copyright law.

Audio and video The current state of Linux video editing 23 open source audio-visual production tools How to make a low-cost guitar amp with Linux Blender Cheat Sheet Latest audio and music articles Latest video editing articles Loops for music creation

If your focus is more on creating music, you might be looking for loops: short recordings of music that you can alter and tweak in your own compositions.

There are all kinds of sample packs out there from commercial sources, but there are also a lot of royalty-free loops available on Looperman. With over 200,000 loops uploaded by musicians, DJs, producers, and creators, there's everything from electronic dance music and trap to classical. There are also over 12,000 a cappella and spoken-word loops, and it's a great resource for finding things like bass lines or drum beats. You need to have an account to download, and you must download tracks before you can upload anything.

Looperman resources are not Creative Commons, but the site defaults to a similar concept: "All samples and loops are free to use in commercial and noncommercial projects," according to the site license, but "you can NOT claim copyright of those loops." A cappella and vocal samples are in a separate category, so checking the specific terms for any loop you consider using is important.

Each loop tells you the beats-per-minute, key signature (where relevant), and software it was created in. A waveform shows the character of the loop, which gives you a good idea of whether it is likely to work with your project. You can preview loops within the browser and leave comments for the creator. There is a lively community and many great resources to help you create your own loops.

Get creative

I hope this gives you some ideas of where to find audio resources for your next project, and I look forward to hearing what you have created!

I came across these helpful open source tools for sampling sounds and creating loops for music.

Image by:

Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0

Audio and music Open Studio What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Create a holiday light display with your Raspberry Pi and ping pong balls

Sat, 11/26/2022 - 16:00
Create a holiday light display with your Raspberry Pi and ping pong balls Brian McCafferty Sat, 11/26/2022 - 03:00

I love Christmas decorations and lights, and I'd been wanting to do an programmable LED project for a long time. Recently, I built a light array made of LED lights, ping pong balls, and a Raspberry Pi Zero. I thought it was worth sharing, because it ended up being relatively easy but also educational.

It's mostly my own design, with some inspiration from YouTube videos. You can find the source code and build instructions in my Git repository.

Shopping list
  • Raspberry Pi Zero
  • Pibow Case
  • 5v 2A USB power supply
  • Poster frame
  • 255 ping pong balls
  • Hot glue gun and LOTS of hot glue sticks
  • Soldering iron
  • Solder
  • 22 AWG 0.35mm solid core wiring
  • 10 meters of WS2812(B) LED strip lights (30 pixels per meter)
  • Multimeter
  • Wire cutters
  • Wire strippers
Design the Raspberry Pi light display

My design was driven by the size of the poster frame I happened to have available. I got 30 pixel per meter tape from Ali Express, which cut nicely into 0.5m sections, so that gave me 15 LEDs across. Ping pong balls are 40mm, so I measured and placed the lines 40mm apart, with the LED Strip in the middle of each 40mm section. This gave me 17 lines down in total. My array was therefore 15×17. If you try this yourself, yours can be a different size.

To get power to the array and the Raspberry Pi, I placed the open connections for both data and power at the bottom of the board. I didn't have that many LEDs needing power, so I was able to use the 5v out GPIO from the Raspberry Pi Zero to power them. I run them at 50% brightness, which is easily bright enough to see in the day and at night through my window.

Wiring

In my design, I started at the bottom of the board and wired up in an S-curve. This made soldering easier because loops at the end of each row didn't have to return all the way back to the start of each line. The WS2812 data lines do require you to wire the data the correct way: power can be fed from either side of the strip, but data must be fed from the side with the arrows pointing away.

My wiring looks like this (this is abbreviated for clarity, in real life it's 17 lines deep):

<---------------\
                |
/---------------/
|
\---------------< # Pi connected hereBuild the display with your Raspberry Pi

Once the design and wiring plan was sorted, it was time to get started on the build.

I measured and drew my lines in pencil on the poster backboard. The WS2812 strips I got came with sticky tape on the back, so I just removed the backing and attached that directly to the backboard. I was sure to position each strip so that the data arrows went one way, then back the other, to ensure that the lights could be daisy-chained correctly for the Pi's instructions.

Once all light strips were attached, I cut three similar lengths of wire and connected the 5v, data, and ground lines from the end of each light section to the one above it.

Image by:

(Brian McCafferty, CC BY-SA 4.0)

More on Raspberry Pi What is Raspberry Pi? eBook: Guide to Raspberry Pi Getting started with Raspberry Pi cheat sheet eBook: Running Kubernetes on your Raspberry Pi Whitepaper: Data-intensive intelligent applications in a hybrid cloud blueprint Understanding edge computing Our latest on Raspberry Pi

After completing each row, I checked continuity between the 5v and ground lines between each strip to ensure my joins were correct. I also checked that I had not accidentally bridged any connections, so I verified that there was no continuity between the 5v and ground lines (in other words, a 5v wire on one line didn't bridge to the ground on the next line.) I also ran some tests to ensure everything was lighting up correctly (see the code section for my strand tests.)

Once this was complete, I started to cut holes in the ping pong balls by stabbing scissors into the bottom of them, and cutting a small hole for the LED to shine into. There was no exact science to this, and each one was different, but the effect really worked. I was working with 30 pixels per meter, so my lighting had about 30mm between each LED. A ping pong ball is 40mm across, but I wasn't about to start soldering each LED individually! First of all, I'm not that good at soldering (as my photos show), and anyway, I thought "Well, they're ping pong balls. I can just squash them together!"

And that's what I did.

I placed a hot glue blob around each LED and then placed a ping pong ball onto the LED, held it for about five seconds, and moved on to the next one. I held onto the previous ping pong ball as I slid the next one in, pushing it against the first before "folding" it into its neighbor. The effect worked really well. I was happy with what it was looking like straight away. It also had the nice bonus of hiding my bad soldering job ;)

Image by:

(Brian McCafferty, CC BY-SA 4.0)

I continued doing this for 255 LEDs and ping pong balls. There were a few crushed ping pong balls in the process, but in the end, I got there.

Image by:

(Brian McCafferty, CC BY-SA 4.0)

Test the code

For the test code to ensure that everything was working, I used this Adafruit guide which lights each LED in red, green, and blue, and then does a rainbow cycle. I used this when I was building to ensure my connections were correct and that everything was soldered correctly.

After that, I designed a grid in a spreadsheet to map each pixel to a grid position. This helped to make building the images easier. Since my pixel numbers run in a zig-zag pattern, it would have been hard to keep track of each LED (e.g. LED A1 was 256 and B1 was 226). 

Once this was all set, it was time to design some images on paper and in the spreadsheet. Then it was time to code! It got a bit addictive and I started adding some animation (using loops and turning pixels onto one color and then another color). 

The end result was everything I'd hoped it would be.

Image by:

(Brian McCafferty, CC BY-SA 4.0)

Image by:

(Brian McCafferty, CC BY-SA 4.0)

Image by:

(Brian McCafferty, CC BY-SA 4.0)

A Raspberry Pi light display all year

I am not sure this will ever be truly finished. Nearly every night since it's been up in the window, I've added some new images and animations. I'm already thinking about what to do for New Year's Eve. I also won't be putting this back in storage with my Christmas decorations in January. I just need to think of other things to draw on it to make it a year-round project! A friend of mine suggested a pixel Mario and I love that idea!

My code also needs a little work. For example, I do some scrolling text, but I redraw the whole board for each position of the text, so it took quite a bit of time to do. I think I can do something with loops, or perhaps the image library can help scroll the letters easier, and make it easier to add text rather than turning each pixel on and off at every step.

I've got a photo record of my progress from start to finish: LED Ping Pong Wall.

You can also see a video of it in action here: XMas light display.

I'm really pleased with how this turned out, and I think it looks amazing. I'm very excited to try some other LED projects in the future. I encourage you to try a light array of your own even as your first project. It's easier than it looks!

This Raspberry Pi tutorial for building a programmable LED light display is perfect for all skill levels.

Image by:

Dwight Sipler on Flickr

Raspberry Pi What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

9 holiday gift ideas for open source enthusiasts in 2022

Fri, 11/25/2022 - 16:00
9 holiday gift ideas for open source enthusiasts in 2022 Opensource.com Fri, 11/25/2022 - 03:00

What do you get the open source enthusiast that has everything? More open source, of course! We asked our community of contributors to share their favorite gift ideas. The end of the year is full of holiday spirit, but these gifts are perfect for any reason or season.

Programmable hardware

I would love to recommend the Digirule2. I want one for myself! Unfortunately, they are out of stock.

The Digirule2 is an 8-bit programmable minimal instruction set computer in the style of the Altair 8800, where you enter a program in machine code. It’s a great way to explore programming, or to teach others how programming works at the hardware level with machine code. Every program instruction is an 8-bit binary code that you enter via switches and LEDs on the ruler. You can enter programs with up to 256 instructions.

Since I was unable to buy one, I wrote an 8-bit programmable minimal instruction set computer for Linux, called the Toy CPU

Jim Hall

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles Linux screensavers for Windows machines

Give the gift of one of these two Linux distributions that run as screensavers for Microsoft Windows systems.

Price is $0. Download them here:

https://people.redhat.com/chward/QemuSaverOpen/QemuSaverOpen-1-6.zip
https://people.redhat.com/chward/QemuSaverOpen/QemuSaverOpenGames-1-4.zip

—Chris Ward

For java lovers

For the open source developer who loves coffee, the Spinn is amazing.

John E. Picozzi

Raspberry pi alternative

The ODROID-H3 is a single board computer billed as a Raspberry Pi killer. It’s selling for $165.

Don Watkins

Mastodon

If you've made the leap to Mastodon, set up a monthly donation to your home server.

Deb Richardson

Open source router

The open source router Turris Omnio.

  • OpenWRT based
  • Performant hardware
  • Not quite cheap though

Stephan Avenwedde

Books

Standard Ebooks produces new editions of public domain ebooks with really nice formatting, an open source workflow, have no DRM, and cost $0 to download. They essentially provide the finishing touches for the work started by Project Gutenberg. One of these ebooks could be a nice $0 gift (in the event that you’re strapped for cash) for somebody who loves reading the classics or obscure.

Seth Kenlon

Every open source enthusiast needs a copy of Virus Bomb and Bullseye Breach. Enjoy the fiction. Use the education. Jerry Barkley is just an IT contractor trying to earn a living and feed his family. He never worked for the government. He’s no superhero. But reactions to the cyberattack scenarios he runs up against and the solutions he comes up with are as real as can be. Maybe real superheroes are ordinary people who step up when called.

Greg Scott

Music

Music makes a great gift. Think about buying interesting music in open formats - FLAC, or vinyl(!!!) for example - for your friends and loved ones.

Chris Hermansen

Open source essentials

Open source swag from projects like the Open Source Initiative and Freewear would make an excellent gift. Freewear donates proceeds from each t-shirt purchase back to the project.

  • A Raspberry Pi
  • Stickers from your favorite conference or project
  • Project donations and memberships

Another idea is to finally make that code contribution you’ve been putting off. That's a gift to a loved one who uses the software (and to the project’s maintainers).

If you're still unsure of what to get, download and print one of our many eBooks or cheat sheets for that special someone in your life.

Our community contributors share their gift ideas for fellow fans of open source.

Image by:

Opensource.com

Opensource.com community Downloadable gift ideas Cheat sheet: Git A guide to implementing DevSecOps A guide to installing applications on Linux Rust cheat sheet Chaos engineering for Kubernetes A guide to Java serverless functions 30 hidden gems in Python 3 A practical guide to home automation using open source tools Containers and Pods 101 eBook This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. 5051 points Minnesota

Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder + project coordinator of FreeDOS. At work, Jim is CEO of Hallmentum, an IT executive consulting company that provides hands-on IT Leadership training, workshops, and coaching.

| Connect jimfhall User Attributes Correspondent Open Sourcerer People's Choice Award People's Choice Award 2018 Author Correspondent Contributor Club 62 points Providence RI

My official role is Solution Architect at EPAM working from home in Rhode Island. My unofficial role at any organization I work for is resident Drupal fanatic; I believe strongly in contributing to the Drupal community and supporting open source in any way I can.

I’m the organizer of the Drupal Providence Meetup, an Acquia-certified Site Builder, a co-host on Talking Drupal, and a co-organizer of the New England Drupal Camp. I hold a bachelor degree in Web Management and Internet Commerce, as well as an associate degree in Web Development from Johnson & Wales University. Throughout my career I have crafted Drupal solutions for organizations like CVS Caremark, Leica Geosystems, Blue Cross Blue Shield, Marriott International, Rhode Island School of Design, and Getty Images.

When I’m not immersed in the world of Drupal, I enjoy spending time with my family, traveling, drinking craft beer, coffee, and cooking!

| Follow johnpicozzi Open Enthusiast Author 16264 points Franklinville, New York

Educator, entrepreneur, open source advocate, life long learner, Python teacher. M.A. in Educational Psychology, MSED in Educational Leadership, Linux system administrator, Follow me at @Don_Watkins .

Mastodon ID

| Follow Don_Watkins | Connect donwatkins User Attributes Correspondent Open Source Star 100+ Contributions Club Best Interview Award 2016 Best Interview Award 2017 Moderator's Choice Award 2018 Moderator's Choice Award 2019 People's Choice Award Social Sharer Award 2014 Conversation Starter Award 2015 Open education Author Comment Gardener Correspondent Contributor Club 31 points Open Enthusiast 1260 points D-33415 Verl

Stephan is a technology enthusiast who appreciates open source for the deep insight of how things work.
Stephan works as a full time support engineer in the mostly proprietary area of industrial automation software. If possible, he works on his Python-based open source projects, writing articles, or driving motorbike.

User Attributes Correspondent Open Source Champion People's Choice Award Author Correspondent Contributor Club 28006 points New Zealand (South Island)

Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time. He is one of the maintainers of the Slackware-based multimedia production project Slackermedia.

User Attributes Team Open Source Super Star Moderator's Choice Award 2011 100+ Contributions Club Best Interview Award 2017 Author Columnist Contributor Club 197 points Minnesota

After surviving multiple layoff rounds at Digital Equipment Corporation, a large computer company in its day, I started Scott Consulting in 1994. A larger firm bought Scott Consulting in 1999, just as the dot com bust devastated the IT Service industry. A glutton for punishment, I went out on my own again in late 1999 and started Infrasupport Corporation, this time with a laser focus on infrastructure and security. I accepted a job offer with Red Hat, Inc. in 2015 as a Senior Technical Account Manager.

I'm also a published author. Jerry Barkley is an IT contractor, not a superhero. But after he uncovers a cyberattack that could lead to millions dead and nobody believes his warnings, if he doesn't act then who will? Real superheroes are ordinary people who step up when called. "Virus Bomb" and "Bullseye Breach" are available everywhere books are sold. More info at https://www.dgregscott.com/books. Enjoy the fiction. Use the education.

My family and I live near St. Paul, Minnesota.

| Follow dgregscott Open Minded Author Contributor Club 6946 points Vancouver, Canada

Seldom without a computer of some sort since graduating from the University of British Columbia in 1978, I have been a full-time Linux user since 2005, a full-time Solaris and SunOS user from 1986 through 2005, and UNIX System V user before that.

On the technical side of things, I have spent a great deal of my career as a consultant, doing data analysis and visualization; especially spatial data analysis. I have a substantial amount of related programming experience, using C, awk, Java, Python, PostgreSQL, PostGIS and lately Groovy. I'm looking at Julia with great interest. I have also built a few desktop and web-based applications, primarily in Java and lately in Grails with lots of JavaScript on the front end and PostgreSQL as my database of choice.

Aside from that, I spend a considerable amount of time writing proposals, technical reports and - of course - stuff on https://www.opensource.com.

User Attributes Correspondent Open Sourcerer People's Choice Award 100+ Contributions Club Emerging Contributor Award 2016 Author Comment Gardener Correspondent Columnist Contributor Club Register or Login to post a comment.

Write a C++ extension module for Python

Thu, 11/24/2022 - 16:00
Write a C++ extension module for Python Stephan Avenwedde Thu, 11/24/2022 - 03:00

In a previous article, I gave an overview of six Python interpreters. On most systems, the CPython interpreter is the default, and also the poll in my last article showed that CPython is the most popular one. Specific to CPython is the ability to write Python modules in C using CPythons extensions API. Writing Python modules in C allows you to move computation-intensive code to C while preserving the ease of access of Python.

In this article, I’ll show you how to write an extension module. Instead of plain C, I use C++ because most compilers usually understand both. I have to mention one major drawback in advance: Python modules built this way are not portable to other interpreters. They only work in conjunction with the CPython interpreter. So if you are looking for a more portable way of interacting with C libraries, consider using the ctypes module.

Source code

As usual, you can find the related source code on GitHub. The C++ files in the repository have the following purpose:

  • my_py_module.cpp: Definition of the Python module MyModule
  • my_cpp_class.h: A header-only C++ class which gets exposed to Python
  • my_class_py_type.h/cpp: Python representation of our C++ class
  • pydbg.cpp: Separate application for debugging purpose

The Python module you build in this article won’t have any meaningful use, but is a good example.

Build the module

Before looking into the source code, you can check whether the module compiles on your system. I use CMake for creating the build configuration, so CMake must be installed on your system. In order to configure and build the module, you can either let Python run the process:

$ python3 setup.py build

Or run the process manually:

$ cmake -B build $ cmake --build build

After that, you have a file called MyModule.so in the /build subdirectory.

Defining an extension module

First, take a look on my_py_module.cpp, in particular, the function PyInit_MyModule:

PyMODINIT_FUNC PyInit_MyModule(void) { PyObject* module = PyModule_Create(&my_module); PyObject *myclass = PyType_FromSpec(&spec_myclass); if (myclass == NULL){ return NULL; } Py_INCREF(myclass); if(PyModule_AddObject(module, "MyClass", myclass) < 0){ Py_DECREF(myclass); Py_DECREF(module); return NULL; } return module; }

This is the most important code in this example because it acts as the entry point for CPython. In general, when a Python C extension is compiled and made available as a shared object binary, CPython searches for the function PyInit_ in the eponymous binary (.so) and executes it when attempting to import it.

All Python types, whether declarations or instances, are exposed as pointers to PyObject. In the first part of this function, the root definition of the module is created by running PyModule_Create(...). As you can see in the module specification (my_module, same file), it doesn’t have any special functionality.

Afterward, PyType_FromSpec is called to create a Python heap type definition for the custom type MyClass. A heap type corresponds to a Python class. The type definition is then assigned to the module MyModule.

Note that if one of the functions fails, the reference count of previously created PyObjects must be decremented so that they get deleted by the interpreter.

More Python resources What is an IDE? Cheat sheet: Python 3.7 for beginners Top Python GUI frameworks Download: 7 essential PyPI libraries Red Hat Developers Latest Python articles Specifying a Python type

The specification for the type MyClass is found inside my_class_py_type.h as an instance of PyType_Spec:

static PyType_Spec spec_myclass = { "MyClass", // name sizeof(MyClassObject) + sizeof(MyClass), // basicsize 0, // itemsize Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // flags MyClass_slots // slots };

This structure defines some basic type information for the class. The value passed for the size consists of the size of the Python representation (MyClassObject) and the size of the plain C++ class (MyClass). The MyClassObject is defined as follows:

typedef struct { PyObject_HEAD int m_value; MyClass* m_myclass; } MyClassObject;

The Python representation is basically of type PyObject, defined by the macro PyObject_HEAD, and some additional members. The member m_value is exposed as ordinary class member while the member m_myclass is only accessible from inside C++ code.

The PyType_Slot defines some additional functionality:

static PyType_Slot MyClass_slots[] = { {Py_tp_new, (void*)MyClass_new}, {Py_tp_init, (void*)MyClass_init}, {Py_tp_dealloc, (void*)MyClass_Dealloc}, {Py_tp_members, MyClass_members}, {Py_tp_methods, MyClass_methods}, {0, 0} /* Sentinel */ };

Here, the jump addressed for some initialization and de-initialization functions are set as well as ordinary class methods and members. Additional functionality, like assigning an initial attribute dictionary, could also be set, but this is optional. Those definitions usually end with a sentinel, consisting of NULL values.

To complete the type specification, here is the method and member table:

static PyMethodDef MyClass_methods[] = { {"addOne", (PyCFunction)MyClass_addOne, METH_NOARGS, PyDoc_STR("Return an incrmented integer")}, {NULL, NULL} /* Sentinel */ }; static struct PyMemberDef MyClass_members[] = { {"value", T_INT, offsetof(MyClassObject, m_value)}, {NULL} /* Sentinel */ };

In the method table, the Python method addOne is defined, and it points to the related function MyClass_addOne. This function acts as a wrapper. It invokes the addOne() method in the C++ class.

In the member table, there is just one member defined for demonstration purposes. Unfortunately, the use of offsetof in PyMemberDef doesn’t allow C++ specific types to be added to MyClassObject. If you try to place some C++ type container (such as std::optional), the compiler complains about it in the form of warnings related to memory layout.

Initialization and de-initialization

The method MyClass_new acts only to provide initial values for MyClassObject and allocates memory for the base type:

PyObject *MyClass_new(PyTypeObject *type, PyObject *args, PyObject *kwds){ std::cout << "MtClass_new() called!" << std::endl; MyClassObject *self; self = (MyClassObject*) type->tp_alloc(type, 0); if(self != NULL){ // -> allocation successfull // assign initial values self->m_value = 0; self->m_myclass = NULL; } return (PyObject*) self; }

Actual initialization takes place in MyClass_init, which corresponds to the __init__() method in Python:

int MyClass_init(PyObject *self, PyObject *args, PyObject *kwds){ ((MyClassObject *)self)->m_value = 123; MyClassObject* m = (MyClassObject*)self; m->m_myclass = (MyClass*)PyObject_Malloc(sizeof(MyClass)); if(!m->m_myclass){ PyErr_SetString(PyExc_RuntimeError, "Memory allocation failed"); return -1; } try { new (m->m_myclass) MyClass(); } catch (const std::exception& ex) { PyObject_Free(m->m_myclass); m->m_myclass = NULL; m->m_value = 0; PyErr_SetString(PyExc_RuntimeError, ex.what()); return -1; } catch(...) { PyObject_Free(m->m_myclass); m->m_myclass = NULL; m->m_value = 0; PyErr_SetString(PyExc_RuntimeError, "Initialization failed"); return -1; } return 0; }

If you want to have arguments passed during initialization, you must call PyArg_ParseTuple at this point. For the sake of simplicity, all arguments passed during initialization are ignored in this example. In the first part of the function, the PyObject pointer (self) is reinterpreted to a pointer to MyClassObject in order to get access to our additional members. Additionally, the memory for the C++ class is allocated and its constructor is executed.

Note that exception handling and memory allocation (and de-allocation) must be carefully done in order to prevent memory leaks. When the reference count drops to zero, the MyClass_dealloc function takes care of freeing all related heap memory. There’s a dedicated chapter in the documentation about memory management for C and C++ extensions.

Method wrapper

Calling a related C++ class method from the Python class is easy:

PyObject* MyClass_addOne(PyObject *self, PyObject *args){ assert(self); MyClassObject* _self = reinterpret_cast(self); unsigned long val = _self->m_myclass->addOne(); return PyLong_FromUnsignedLong(val); }

Again, the PyObject* argument (self) is casted to MyClassObject* in order to get access to m_myclass, a pointer to the C++ class instance. With this information, the classes method addOne() is called and the result is returned in form of a Python integer object.

3 ways to debug

For debugging purposes, it can be valuable to compile the CPython interpreter in debugging configuration. A detailed description can be found in the official documentation. It’s possible to follow the next steps, as long as additional debug symbols for the pre-installed interpreter are downloaded.

GNU Debugger

Good old GNU Debugger (GDB) is, of course, also useful here. I include a gdbinit file, defining some options and breakpoints. There’s also the gdb.sh script, which creates a debug build and initiates a GDB session:

Image by:

(Stephan Avenwedde, CC BY-SA 4.0)

GDB invokes the CPython interpreter with the script file main.py. The script file allows you to easily define all the actions you want to perform with the Python extension module.

C++ application

Another approach is to embed the CPython interpreter in a separate C++ application. In the repository, this can be found in the file pydbg.cpp:

int main(int argc, char *argv[], char *envp[]) { Py_SetProgramName(L"DbgPythonCppExtension"); Py_Initialize(); PyObject *pmodule = PyImport_ImportModule("MyModule"); if (!pmodule) { PyErr_Print(); std::cerr << "Failed to import module MyModule" << std::endl; return -1; } PyObject *myClassType = PyObject_GetAttrString(pmodule, "MyClass"); if (!myClassType) { std::cerr << "Unable to get type MyClass from MyModule" << std::endl; return -1; } PyObject *myClassInstance = PyObject_CallObject(myClassType, NULL); if (!myClassInstance) { std::cerr << "Instantioation of MyClass failed" << std::endl; return -1; } Py_DecRef(myClassInstance); // invoke deallocation return 0; }

Using the high level interface, it’s possible to include the extension module and perform actions on it. This allows you to debug in the native IDE environment. It also gives you finer control of the variables passed from and to the extension module.

The drawback is the high expense of creating an extra application.

VSCode and VSCodium LLDB extension

Using a debugger extension like CodeLLDB is probably the most convenient debugging option. The repository includes the VSCode or VSCodium configuration files for building the extension (task.json, CMake Tools) and invoking the debugger (launch.json). This approach combines the advantages of the previous ones: Debugging in an graphical IDE, defining actions in a Python script file or even dynamically in the interpreter prompt.

Image by:

(Stephan Avenwedde, CC BY-SA 4.0)

Extend C++ with Python

All functionality available from Python code is also available from within a C or C++ extension. While coding in Python is often considered as an easy win, extending Python in C or C++ can also be a pain. On the other hand, while native Python code is slower than C++, a C or C++ extension makes it possible to elevate a computation-intensive task to the speed of native machine code.

You must also consider the usage of an ABI. The stable ABI provides a way to maintain backwards compatibility to older versions of CPython as described in the documentation.

In the end, you must weigh the advantages and disadvantages yourself. Should you decide to use C extensions to make certain functionality available to you in Python, you’ve seen how it can be done.

Use C extensions to make certain functionality available to you in Python.

Python What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Use arrays in Java

Thu, 11/24/2022 - 16:00
Use arrays in Java Seth Kenlon Thu, 11/24/2022 - 03:00

In the Java programming language, an array is an ordered collection of data. You can use an array to store information in a structured way. It's useful to know the various ways you can retrieve that data when you need it. It's worth noting that in Java, an associative array (also called a dictionary in some languages) is called a hashmap. This article doesn't cover hashmaps, but you can read all about them in my Using a hashmap in Java article.

Creating a string array

The simplest array in Java is a one-dimensional array. It's essentially a list. For an array of strings:

package com.opensource.example;

public class Example {

    public static void main(String[] args) {
        String[] myArray = {"foo", "bar", "baz"};

        // retrieval
        System.out.println(myArray[0]);
        System.out.println(myArray[1]);
        System.out.println(myArray[2]);
    }
}

Notice that when you retrieve the data from an array, the index starts at 0, not 1. In other words, an array containing three values is numbered 0 to 2.

Alternatively, you can create an array and populate it later. When you do this, however, you must also tell Java the length of the array. The "length", in this context, refers to the number of items an array can hold.

package com.opensource.example;

public class Example {
    public static void main(String[] args) {
        String[] myArray = new String[3];

        System.out.println("Empty myArray created.");

        // populate the array
        myArray[0] = "foo";
        myArray[1] = "bar";
        myArray[2] = "baz";

        // retrieval
        System.out.println(myArray[0]);
        System.out.println(myArray[1]);
        System.out.println(myArray[2]);
    }
}

Assuming the code is saved in a file called main.java, run it using the java command:

$ java ./main.java
foo
bar
baz

To create an array of integers, define the data type as int instead of String:

package com.opensource.example;

public class Example {
    public static void main(String[] args) {
      int[] myArray = { 1, 2, 3 };

      System.out.println(myArray[0]);
      System.out.println(myArray[1]);
      System.out.println(myArray[2]);
    }
}

Run the code:

$ java ./main.java
1
2
3

More on Java What is enterprise Java programming? An open source alternative to Oracle JDK Java cheat sheet Red Hat build of OpenJDK Free online course: Developing cloud-native applications with microservices Fresh Java articles Iterating over an array

Once you've stored data in an array, you probably intend to retrieve it at some point. The most direct way to see all data in an array is to create a for loop that gets the length of the array using the .length method, and then loops over the array a number of times equal to the length:

package com.opensource.example;

public class Example {
    public static void main(String[] args) {

        String[] myArray = { "foo", "bar", "baz" };

        for (int i=0; i < myArray.length; i++) {
            System.out.println(myArray[i]);
        }
    }
}

Run the code:

$ java ./main.java
foo
bar
bazMultidimensional arrays

An array doesn't have to be just a simple list. It can also be a list of lists. This is called a multidimensional array, and it's pretty intuitive as long as you think of it as an array of arrays:

package com.opensource.example;

public class Example {
    public static void main(String[] args) {
        String[][] myArray = {{ "zombie", "apocalypse" }, { "happy", "halloween" }};
        }
    }
}

To see the contents of the array, you can use a nested for loop. In a one-dimensional array, you had to obtain the length of myArray so your for loop knew when to stop iterating over the array. This time, you must obtain the length of each array within myArray. For simplicity, I call these two arrays outer and inner, with the former being myArray, and the inner representing each nested array:

int outer = myArray.length;
int inner = myArray[1].length;

Once you have both lengths, you use them as the limits of your for loop:

for (int i = 0; i < outer; i++) {
  for (int j = 0; j < inner; j++) {
    System.out.println(myArray[i][j]);
    }
  }

Here's the full code sample:

package com.opensource.example;

  public class Example {
      String[][] myArray = {{ "foo", "bar" }, { "baz", "qux" }};

      int outer = myArray.length;
      int inner = myArray[1].length;

      for (int i = 0; i < outer; i++) {
         for (int j = 0; j < inner; j++) {
            System.out.println(myArray[i][j]);
            }
        }
    }
}

Run the code:

$ java ./main.java
zombie
apocalypse
happy
halloweenArrays of data

Sometimes it makes more sense to use a Java array than to track dozens of individual variables. Once you understand how to structure and retrieve data in a language, you can generate complex data in an organized and convenient way.

Instead of tracking dozens of individual variables, use an array in Java to collect and store data in a structured way.

Image by:

Pixabay. CC0.

Programming Java What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Set up automated software testing with this open source platform

Wed, 11/23/2022 - 16:00
Set up automated software testing with this open source platform Antoine Craske Wed, 11/23/2022 - 03:00

Automated testing is an important stage of development. It helps you ensure code quality, discover bugs before they ship, and guarantee that an application works the way it's intended to work. Deployment of automated tests is rapidly becoming a top priority for companies all over the world.

The latest release of the Cerberus Testing platform offers a series of new features and improvements to allow you to easily set up automated tests for your software engineering team.

Intuitive design

The philosophy of Cerberus Testing is to facilitate cross-functional collaboration on automated tests around a shared interface. Usability has been a major focus of the latest version, with an emphasis on making onboarding simple. The vision of the Cerberus experience is a one-click setup. You can create, execute, and visualize an automated test in less than 30 seconds, whether you're familiar with Cerberus or not.

Image by:

(Antoine Craske, CC BY-SA 4.0)

This new version realizes this promise for web application testing thanks to the new design, and Cerberus's automation library. Future enhancements will support more advanced use cases, such as mobile and API testing working directly in the cloud.

Apache Kafka

There's a need for massive data processing in event-driven architecture. This asynchronism, however, must be designed and implemented. Apache Kafka is the preeminent platform supporting massive connectivity of producers and consumers, exchanging messages without defined structures, or else defined by Avro schemas.

Image by:

(Antoine Craske, CC BY-SA 4.0)

For several years, Cerberus Testing has supported the testing of event-driven and microservices components with Apache Kafka. Cerberus Testing now also supports Avro schemas.

That's not all the latest release does for Apache Kafka, though. Other improvements are also available, including centralized management of your Kafka configurations to facilitate maintainability, and the ability to search and test elements present in the "headers" of messages.

More on automation Download now: The automated enterprise eBook Free online course: Ansible essentials Ansible cheat sheet eBook: A practical guide to home automation using open source tools A quickstart guide to Ansible eBook: 7 examples of automation on the edge More articles about open source automation Advanced use cases

Anyone who designs test automation knows that the old adage "the devil is in the details" is as relevant as ever in this business. There is no "normal" use case for a test suite. Every challenge is unique, but Cerberus Testing provides a toolkit that includes image recognition, file manipulation, multi-criteria validation, and more.

The image recognition available in Cerberus Testing now allows you to target a specific offset on the screen. You can activate a delay for keypress actions, or even utilize character recognition.

There are also improvements for test cases that require uploading and downloading files, new checks for lists of numeric values, and batch test execution relaunch from the interface.

A new and improved website

This new version follows a complete redesign of the Cerberus Testing website for better readability and access to the platform's documentation and resources. There, you can also browse training opportunities and explore partners.

Try Cerberus Testing

The latest version of Cerberus Testing provides a scalable test automation platform that supports Agile and DevOps approaches. To try it for yourself, or to contribute to the project, visit our Git repository.

Cerberus Testing offers a series of new features and improvements to allow you to easily set up automated tests for your software engineering team.

CI/CD Automation DevOps What to read next An open source solution for continuous testing at scale This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Pages