Open-source News

NVIDIA Gaming/GPU Performance: Windows 11 vs. Ubuntu Linux Benchmarks

Phoronix - Tue, 01/03/2023 - 00:20
Last week was a fresh look at the AMD Radeon graphics/gaming performance between Windows and Linux using the very latest drivers. Today the testing wrapped up from some holiday benchmarking looking at the NVIDIA GeForce performance under Windows 11 and Ubuntu 22.10 Linux for how the drivers on both operating systems are currently competing.

The Old Radeon "R600" Open-Source Gallium3D Driver Now Enables SPIR-V

Phoronix - Mon, 01/02/2023 - 23:13
The open-source R600 Gallium3D driver for supporting up through the Radeon HD 6000 series graphics cards on Linux has an interesting new year addition... ARB_gl_spirv!..

Ubuntu's New Installer Taking Shape Nicely For Ubuntu 23.04

Phoronix - Mon, 01/02/2023 - 22:54
A new Ubuntu desktop installer has been talked about going back many years and over the past two years has been focused on providing a rewritten installer making use of Subiquity and Flutter. With Ubuntu 23.04 "Lunar Lobster" in April that new desktop installer is poised to finally be used by default...

GNU Binutils 2.40 Branched With Zstd Support, Zen 4, New Intel Instructions

Phoronix - Mon, 01/02/2023 - 19:58
With the start of the new year also came the branching of GNU Binutils 2.40 ahead of its expected stable release around early February...

Dragonfly 0.13 Database Adds Experimental SSD-Based Data Tiering, More SIMD Work

Phoronix - Mon, 01/02/2023 - 19:25
Dragonfly, the open-source project that advertises itself as "Probably, the fastest in-memory store in the universe!" as a high speed in-memory database that is compatible with the Memcached and Redis APIs has out a big release to kick off 2023...

How to Learn dd Command in Linux [15 Useful Examples]

Tecmint - Mon, 01/02/2023 - 16:54
The post How to Learn dd Command in Linux [15 Useful Examples] first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Brief: In this advanced guide, we will discuss some practical examples of the dd command. After following this guide, advanced users will be able to work with the block devices comfortably from the command

The post How to Learn dd Command in Linux [15 Useful Examples] first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

7 Git articles every open source practitioner should read

opensource.com - Mon, 01/02/2023 - 16:00
7 Git articles every open source practitioner should read AmyJune Mon, 01/02/2023 - 03:00

Understanding the Git version control system is foundational for many open source practitioners. Whether you are an advanced user or you want 2023 be the year to get started, Opensource.com has plenty of resources for you. Here are a few recent Git articles that I recommend:

The first in a series by Dwayne McDaniels, Git concepts in less than 10 minutes, assures us that, yes, Git can seem intimidating, but knowing and understanding the basic building blocks can break down the barriers. Six basic commands and concepts are explained so you can move on to more advanced Git tools and commands.

5 Git configurations I make on Linux by Alan Formy-Duval is a straightforward guide to getting started working with Git on Linux. There are so many configuration options, and Alan suggests starting with global configuration to help make set up easier every time.

How to rename a branch, delete a branch, and find the author of a branch in Git is a straightforward article about the most common commands around Git branching.

If you tend to misuse Git or write many Git hooks like author Seth Kenlon, bringing the Git subcommand rev-parse into your bag of tricks may be a good option. Peek inside your Git repo with rev-parse reminds you that if you do scripting with Git, you need information about the Git repository. Using the rev-parse subcommand is one way to find what you're looking for.

In Evan “Hippy” Slatis’s article, How I use the Git for-each-ref command for DevOps, Evan explains that Git can be used not only to capture history across files, but also to capture metadata. The article includes a pragmatic example of how the for-each-ref command is used to discover where a bug was introduced into the repository.

More on Git What is Git? Git cheat sheet Markdown cheat sheet New Git articles

This fun article was crowdsourced from Opensource.com's writer’s list. Happy anniversary, Git! Here are our favorite Git commands has some Git fan favorites along with some new ones that everyone is sure to appreciate and enjoy.

In Seth Kenlon’s article, Make your own Git subcommands, Seth demonstrates how to make your own Git command using custom scripts. It’s easier than it might at first seem, and it’s a great way for intermediate or advanced users of Git to extend Git’s capabilities based on their own requirements.

Get started with Git in 2023 with these helpful articles.

Image by:

Opensource.com

Best of Opensource.com Git 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 to read and write files in Rust

opensource.com - Mon, 01/02/2023 - 16:00
How to read and write files in Rust hANSIc99 Mon, 01/02/2023 - 03:00

Knowing how to read and write files can be useful for various purposes. In Rust, this task is done using the file system module (std::fs) in the standard library. In this article, I'll give you an overview on how to use this module.

To demonstrate this task, I prepared example code which is also available on GitHub.

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 Preparation

When using Rust, a function that fails returns the Result type. The file system module in particular returns the specialized type std::io::Result. With this knowledge, you can return the same type from the main() function:

fn  main() ->  std::io::Result<()> {
/* ...code comes here... */Writing Rust files

Performing file I/O-operations in Rust is relatively easy. Writing to a file can be simplified to one line:

use  std::fs;
fs::write("favorite_websites.txt", b"opensource.com")?;
Ok(())

Using the error propagation operator (?), the error information gets passed on to the calling function where the error can subsequently be handled. As main() is the only other function in the call stack, the error information gets passed on to the console output in case the write operation failed.

The syntax of the fs::write function is quite forward. The first argument is the file path, which must be the type std::path::Path. The second argument is the content, which is actually a slice of bytes ([u8]). Rust converts the arguments passed into the correct type. Luckily, these types are basically the only types dealt with in the following examples.

A more concise access of the write operation can be achieved using the file descriptor type std::fs::File:

let mut file = fs::File::create("favorite_websites.txt")?;
file.write_all(b"opensource.com\n")?;
Ok(())

As the file type implements the Write trait, it is possible to use the associated methods to write to the file. However, the create method can overwrite an already existing file.

To get even more control of the file descriptor, the type std::fs::OpenOptions must be used. This provides opening modes similar to the ones in other languages:

let mut file = fs::OpenOptions::new()
                            .append(true)
                            .open("favorite_websites.txt")?;
                           
file.write_all(b"sourceforge.net\n")?;Reading Rust files

What applies to writing also applies to reading. Reading can also be done with a simple one-line of code:

let websites = fs::read_to_string("favorite_websites.txt")?;

The above line reads the content of the file and returns a string. In addition to reading a string, there is also the std::fs::read function which reads the data into a vector of bytes if the file contains binary data.

The next example shows how to read the content of the file into memory and subsequently print it line by line to a console:

let file = fs::File::open("favorite_websites.txt")?;
let lines = io::BufReader::new(file).lines();

for line in lines {
    if let Ok(_line) = line {
        println!(">>> {}", _line);
    }
}Summary

If you are already familiar with other programming languages, you may have noticed that there is no close-function (or something similar) that releases the file handle. In Rust, the file handle is released as soon as the related variable goes out of scope. To define the closing behavior, a scope ({ }) around the file representation can be applied. I recommend that you get familiar with Read and Write trait as you can find this trait implemented in many other types.

Follow along with this demo to learn how to use the file system module in Rust.

Image by:

Opensource.com

Rust 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.

Steam On Linux Metrics End Out 2022 With Some Odd Numbers

Phoronix - Mon, 01/02/2023 - 10:09
Valve has just published the Steam Survey results for December 2022 that come in at a bit of a surprise...

Linux 6.2-rc2 Released Following The Holiday Slowdown

Phoronix - Mon, 01/02/2023 - 06:24
Linus Torvalds just released Linux 6.2-rc2 as the second weekly release candidate for Linux 6.2 following the merge window's closure last week on Christmas...

Pages