teleren/devto huggingface dataset:
Tensorman: TensorFlow with CUDA made easy
Tags: tensorflow, cuda, nvidia
Published: 2024-06-22 17:26:18

Getting TensorFlow to work with CUDA can be a real headache. You have to make sure that the versions of TensorFlow, CUDA, cuDNN match up. Missing one small detail can throw everything off.

Luckly, Google provides some [pre-configured Docker images](https://hub.docker.com/r/tensorflow/tensorflow) so you don't have to deal with this hassle. But there is still a bit of a hassle in managing the container, right?

Making things even easier, the lovely folks from System76 created [Tensorman](https://github.com/pop-os/tensorman), which abstracts away all the complexity of pulling the container, running our app, stopping, removing the container, etc.

## Running TensorFlow with Tensorman

With Tensorman installed (`apt install tensorman` from PopOS), it's as easy as:

```
$ tensorman run --gpu python -- ./script.py
```

This takes care of everything, even stopping and removing the container once the process goes down.

## Testing

Here's a sample script if you want to test it out:

```
import tensorflow as tf

print("TensorFlow version:", tf.__version__)
print("CUDA support:", tf.test.is_built_with_cuda())
print("GPU available:", tf.config.list_physical_devices('GPU'))

matrix1 = tf.constant([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
matrix2 = tf.constant([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])

product = tf.matmul(matrix1, matrix2)

print("Matrix multiplication result: ", product.numpy())
```

## Removing NUMA warning messages

When running my sample script I got my output as expected:

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97k92alpse1jph57dc4u.png)

Ugh, I don't want all those NUMA warning messages on my output. Here's how I've disable it (thanks to this [gist](https://gist.github.com/zrruziev/b93e1292bf2ee39284f834ec7397ee9f)):

```
$ lspci | grep -i nvidia
10:00.0 VGA compatible controller: NVIDIA Corporation TU104 [GeForce RTX 2060] (rev a1)
10:00.1 Audio device: NVIDIA Corporation TU104 HD Audio Controller (rev a1)
10:00.2 USB controller: NVIDIA Corporation TU104 USB 3.1 Host Controller (rev a1)
10:00.3 Serial bus controller: NVIDIA Corporation TU104 USB Type-C UCSI Controller (rev a1)

$ sudo echo 0 | sudo tee -a "/sys/bus/pci/devices/0000:10:00.0/numa_node"
0
```

Running again:

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/moyo37r6zg35d6e06j75.png)

Still noisy, but much better.
Computer Science Challenge: Recursion
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 17:24:40

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

Recursion: Recursion is a programming method that involves a function calling itself to address versions of an issue until it reaches a base scenario. This technique plays a role, in activities such as navigating trees and organizing data making the code more straightforward and less complicated, by dividing challenges into easier-to-handle components.

## Additional Context

<!-- Please share any additional context you think the judges should take into consideration as it relates to your One Byte Explainer. -->

Recursion, in programming, involves a technique where a function calls itself to address instances of a problem. This method continues until it reaches a base case, which is a condition where the problem becomes simple enough to be solved stopping further recursive calls. The use of recursion is crucial in tasks such as navigating trees, where each node's subtrees are processed sequentially, and in sorting algorithms like quicksort and mergesort which divide arrays into segments for sorting. Through recursion complex problems are broken down into parts resulting in code that is often simpler and easier to understand. It is important to use recursion to prevent issues like loops and stack overflow errors, which can arise when the base case is not reached or the recursion depth becomes too high. Having a grasp of recursion aids, in developing elegant solutions for various computational challenges.

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- Don't forget to add a cover image to your post (if you want). -->

<!-- Thanks for participating! -->
🚀 Exciting Update: SimpliLearn Certifications Achieved! 🎓
Published: 2024-06-22 17:22:09

Hello Everyone,

**Certifications Link :** [SimpliLearn-Certifications](https://github.com/Vidhey012/My-Certifications/tree/main/SimpliLearn)

I'm excited to announce that I've successfully completed certifications with SimpliLearn! These certifications have been instrumental in enhancing my skills and expertise in [mention the field or specialization]. I've gained valuable insights and hands-on experience that I'm eager to apply in my professional endeavors.

I extend my gratitude to everyone who has supported me throughout this journey. Your encouragement has been invaluable.

Here's to continuous learning and leveraging these certifications to unlock new opportunities in my career!
🎓 Exciting News: GreatLearning Certifications Achieved! 🚀
Published: 2024-06-22 17:19:44

Hello Everyone,

**Certification Link :** [GreatLearning-Certifications](https://github.com/Vidhey012/My-Certifications/tree/main/GreatLearning)

I am thrilled to share that I have successfully completed certification programs with GreatLearning! These certifications signify my commitment to enhancing my skills and knowledge in Computer Sciences. The courses have equipped me with valuable insights and practical skills that I'm eager to apply in my professional journey.

Thank you to everyone who has supported me along the way. Your encouragement means a lot.

Here's to continuous growth and leveraging these certifications to achieve new milestones in my career!
🎓 Exciting News: Cisco Certifications Achieved! 🌟
Published: 2024-06-22 17:15:26

Dear Friends and Colleagues,

**Certifications Link :** [Cisco-Certifications](https://github.com/Vidhey012/My-Certifications/tree/main/Cisco)
I'm thrilled to announce a significant milestone in my career journey – I have successfully earned Cisco certifications! 🚀 These certifications represent my commitment to advancing my knowledge and expertise in networking and cybersecurity, two crucial pillars in today's digital landscape.

Cisco's rigorous training programs have equipped me with industry-leading skills, empowering me to tackle complex networking challenges and enhance cybersecurity measures. This achievement wouldn't have been possible without the support of mentors, colleagues, and my relentless pursuit of knowledge.

I'm excited to apply these newfound skills to drive innovation, efficiency, and security in our digital environments. Thank you to Cisco for their exceptional training programs and to everyone who supported me along this journey.

Here's to continuous learning, growth, and embracing new opportunities in the ever-evolving world of technology!
🎓 Proud Moment: EduSkills Code Riders 2021 Certificate Achievement! 🚀
Published: 2024-06-22 17:13:47

Dear Friends,

I'm thrilled to share a significant achievement with you all – I've successfully completed the EduSkills Code Riders 2021 program! 🌟 This journey has been an incredible opportunity to delve deeper into the world of coding, sharpen my skills, and collaborate with passionate individuals from diverse backgrounds.

Throughout the program, we explored various facets of programming, tackled challenging projects, and learned from industry experts. It's been a rewarding experience that has enriched my knowledge and passion for technology.

A heartfelt thanks to the EduSkills team for organizing this enriching initiative and to my peers for their constant support and collaboration. I'm excited to leverage the skills gained here to contribute meaningfully to future projects and continue my journey of growth in the tech world.

Here's to continuous learning, exploration, and the pursuit of excellence! 🎓🚀
Visualize and explain byte sequences with byte-diagram
Tags: cli, tools, asciiart
Published: 2024-06-22 17:11:24

Hey everyone!

I'm excited to introduce you to a new command-line tool I've been working on called byte-diagram. This tool allows you to visualize byte sequences using ASCII art, making it easier to understand and analyze hexadecimal data.

**What is `byte-diagram`?**

`byte-diagram` is a Python-based command-line utility designed for visualizing byte sequences. It takes a hexadecimal string as input and generates an ASCII diagram that represents each byte and its position in the sequence.

**How does it work?**
Using byte-diagram is straightforward. You simply provide it with a hexadecimal string as an argument, and it will generate a diagram showing each byte's position and value in a sequential manner. Here's an example:

```
$./byte-diagram.py -s "00 01 02" -d "Field 0" "Field 1" "Field 2"
   ------------> Field 0
  /     -------> Field 1
 |     /     --> Field 2
 |    |     /     
 |    |    |        
0x00 0x01 0x02 
```

**Where do you find it?**
You can find `byte-diagram` on GitHub [here](https://github.com/Yanujz/byte-diagram).


**Contribution**
Contributions to `byte-diagram` are welcome! Whether you want to add new features, improve documentation, or fix bugs, feel free to fork the repository and submit a pull request.
🎉 Celebrating Cisco Codathon 2020! 🚀
Published: 2024-06-22 17:02:38

Hey Everyone!

I'm excited to share some amazing news – I participated in and successfully completed Cisco Codathon 2020! 🌟 It was an exhilarating experience where I collaborated with brilliant minds to tackle real-world challenges using innovative tech solutions.

During the Codathon, we explored cutting-edge technologies, honed our problem-solving skills, and built solutions that could make a meaningful impact in today's digital landscape.

A heartfelt thanks to my team members for their dedication and teamwork, as well as to Cisco for organizing such an incredible event. This journey has been nothing short of inspiring, and I'm eager to continue pushing boundaries and exploring new opportunities in the tech world.

Cheers to innovation, collaboration, and the thrill of coding! 🎉
AWS Certifications
Tags: aws, awschallenge
Published: 2024-06-22 16:59:41

🚀 Exciting Announcement: Celebrating AWS Certifications! 🌟

Hey Dev Community!

**Certificates Link :** [AWS-Certifications](https://github.com/Vidhey012/My-Certifications/tree/main/Aws)

I'm thrilled to share a major milestone in my journey – I've recently earned several AWS certifications! 🎉 These certifications represent countless hours of dedication and a deep dive into cloud technologies.

Each certification has broadened my expertise in AWS services, infrastructure management, and cloud security. It's a testament to my commitment to mastering cloud computing and advancing in my career as a developer.

I owe a huge thanks to my mentors, peers, and this amazing community for their support and guidance throughout this journey. 🙌

Let's continue to learn, grow, and innovate together! 💪
Who Am I? 🚀
Published: 2024-06-22 16:46:35

Hello Dev Community! 👋

My name is Vidhey Bhogadi, and I am thrilled to be part of this amazing community. Let me take a moment to introduce myself.

My Background 🌐
I am a full-stack developer and a self-taught tech enthusiast. Over the years, I have immersed myself in the world of technology, constantly learning and evolving. My journey in tech started with curiosity and has blossomed into a passion for building innovative solutions.

What I Do 💻
As a full-stack developer, I work with a variety of technologies to create comprehensive and efficient applications. My skill set includes:

Frontend: HTML, CSS, JavaScript, React, Angular
Backend: Node.js, Express, Django
Databases: MySQL, PostgreSQL, MongoDB
Others: Git, Docker, CI/CD, Cloud Services (AWS, Azure)
I enjoy working on projects that challenge me and allow me to grow. Whether it's developing a responsive web application or optimizing backend performance, I am always up for the task.

My Passion 🌟
I am passionate about:

Learning New Technologies: The tech field is always evolving, and I love staying updated with the latest trends.
Collaborating: I believe that great things are built through teamwork. I am always open to collaborating on exciting projects.
Problem-Solving: I enjoy tackling complex problems and finding efficient solutions.
Looking Forward 🚀
I am excited to connect with fellow developers, share my knowledge, and learn from this vibrant community. If you're working on interesting projects or looking for a collaborator, feel free to reach out. Let's build something amazing together!

Thank you for taking the time to read about me. Looking forward to engaging with you all!

Best,
Vidhey Bhogadi.
Excited to Join and Learn: My Journey in Tech
Tags: letsconnect, beginners, programming, java
Published: 2024-06-22 16:24:26

Hi everyone!

I'm thrilled to join this vibrant community. My name is Ruturaj Jadhav, and I wanted to share a bit about my journey in tech.

I started with Java, and over time, I developed a strong interest in Data Structures and Algorithms (DSA) and Artificial Intelligence (AI). Currently, I'm focusing on enhancing my skills in these areas and exploring the exciting potential of AI.

I'm eager to learn from all of you, share my experiences, and collaborate on innovative projects. If you're working on anything interesting, I would love to learn from you all.

Looking forward to connecting with you all,
Enable Touch ID Authentication for sudo on macOS Sonoma 14.x
Tags: macos, touchid, security, productivity
Published: 2024-06-22 16:22:46

### Operating Environment:
- **OS:** MacOS Sonoma 14.5
- **Device:** M1 MacBook Pro

## Explanation

In macOS Sonoma, a new method has been introduced to enable Touch ID when running `sudo` commands, making it more persistent across system updates. Previously, editing the `/etc/pam.d/sudo` file was necessary, but these changes would often revert after an update, requiring reconfiguration. With Sonoma, the settings can be added to a separate file `/etc/pam.d/sudo_local`, which isn't overwritten during updates, allowing Touch ID to remain enabled for `sudo` commands consistently.

## Steps to Enable Touch ID for `sudo`

### 1. Create and Edit the Configuration File

Create a new configuration file based on the template provided in macOS Sonoma.

```sh
sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
```

Edit the newly created file with your preferred text editor:

```sh
sudo vim /etc/pam.d/sudo_local
```

In the file, locate the following line, Uncomment it by removing the `#`:

```diff
- #auth       sufficient     pam_tid.so
+ auth       sufficient     pam_tid.so
```

### Alternative Method Using `sed` and `tee`

You can achieve the same result with a single command using `sed` and `tee`:

```sh
sed -e 's/^#auth/auth/' /etc/pam.d/sudo_local.template | sudo tee /etc/pam.d/sudo_local
```

### 2. Confirm the Operation

Open a new terminal session and run a `sudo` command to test the setup:

```sh
sudo ls
```

You should be prompted to authenticate using Touch ID. If the command executes after Touch ID authentication, the setup is complete.

<img width="270" alt="Screenshot 2024-06-22 at 4 48 00 PM" src="https://gist.github.com/assets/55068936/ce9c32f4-a1e2-44bb-99e2-7a31af15309f">


### Background

Previously, enabling Touch ID for `sudo` required modifying `/etc/pam.d/sudo`, but these changes did not persist through macOS updates. By leveraging the new `/etc/pam.d/sudo_local` configuration in macOS Sonoma, we can ensure that Touch ID settings for `sudo` remain intact even after system updates.

The `/etc/pam.d/sudo` file now includes the following:

```plaintext
# sudo: auth account password session
auth       include        sudo_local
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
```

This configuration ensures that the settings in `/etc/pam.d/sudo_local` are loaded and used, maintaining Touch ID functionality for `sudo` commands.

Please note that for macOS versions earlier than Sonoma, manual editing of `/etc/pam.d/sudo` is still required to enable Touch ID for `sudo` commands.
If to be or not to be is the question, ternary operator is the answer
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 16:18:13

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

Do I jump or duck? If the obstacle is high, jump, if it's low, duck. You need a quick decision. That's what the ternary operator does. Instead of pausing to think, it quickly chooses between two actions based on a condition.

Also huge shoutout to my team member @vedangit !!
Code Checkpoint: Memoisation and its magic
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 16:14:31

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

Memoization stores the results of expensive operations and returns them quickly when needed, saving time and effort. Think of a video game save point! Instead of replaying the same level every time you lose, you save your progress. Don't hate your cache!


Also huge shoutout to my team member @vedangit !!
PHP: yes, it's possible
Tags: php, beginners, programming
Published: 2024-06-22 16:11:43

Let's see if that's possible, then we'll see when to use it.

## Is is possible?

### Can enumerations implement interfaces?

Yes.

[Source: enumeration PHP](https://www.php.net/manual/en/language.types.enumerations.php)

### Is it possible to "Multi catch" in PHP?

Yes.

Instead of doing that:

```PHP
try {
} catch(MyException $e) {
} catch(AnotherException $e) {
}
```

Do that:

```PHP
try {
} catch(MyException | AnotherException $e) {
}
```

[Source: PHP - exceptions](https://www.php.net/manual/en/language.exceptions.php)

### Can an interface extend another interface?

Yes.

Unlike with classes, you can even have multiple inheritance:

```php
interface A
{
  public function foo();
}

interface B
{
  public function bar();
}

interface C extends A, B
{
  public function baz();
}
```

[Source: object interfaces](https://www.php.net/manual/en/language.oop5.interfaces.php)

## Do you need it?

### Does your enum need an interface? 

It's usually a good practice, as you can type check for that interface quite conveniently:

```PHP
interface Colorful {
  public function color(): string;
}

enum Suit implements Colorful {
  case Hearts;
  case Diamonds;
  case Clubs;
  case Spades;

  public function color(): string {
    return match($this) {
      Suit::Hearts, Suit::Diamonds => 'Red',
      Suit::Clubs, Suit::Spades => 'Black',
    };
  }
}

function paint(Colorful $c) { ... }

paint(Suit::Clubs);
```

[Source: RFC - enumerations](https://wiki.php.net/rfc/enumerations)

### Do you need Multi catch blocks?

It depends.

This syntax works:

```PHP
try {
} catch(MyException | AnotherException $e) {
   echo $e->getMessage();
}
```

However, ensure your exceptions implement the same methods.

In contrast, using several catch blocks can be handy to catch different classes of exceptions.

Although, if you need to group your exceptions, avoid the following:

```PHP
try {
} catch(AnException | AnotherException2 | AnotherException3 | AnotherException4 | AnotherException5 | AnotherException6 | AnotherException7 | AnotherException8 | AnotherException9 $e) {
   echo $e->getMessage();
}
```

While it's valid, it can give the false impression of clean code. Having too much exceptions is not a good [de]sign.

### Inheritance with interfaces

I must admit I rarely use that one, but it's good to know:

```PHP
interface Writable
{
    public function write();
}

interface Document extends Writable
{
    public function edit();
}
```

Do you need it?

It depends. If your interface contains too much methods, it probably means you are breaking the Interface Segregation Principle.
Computer Science under 125 characters.
Tags: devchallenge, cschallenge, computerscience, beginners
Published: 2024-06-22 16:10:30

*This is a submission for [DEV Computer Science Challenge v24.06.12: One Byte Explainer](https://dev.to/challenges/cs).*

## Explainer

Assigning multiple complex tasks to metals, plastics,0's,1's, and electricity because we were too lazy to do it on pen and paper.

## Additional Context
We saw the gap of no one explaining the title of the challenge and ended up doing something raw.


## Team Submissions:
Also a huge shoutout to my team member @vedangit !!
Dashboard Estratégico X Dashboard Operacional
Tags: dashboard, estratgico, operacional, bi
Published: 2024-06-22 16:08:48

Nesse pequeno artigo vou tentar trazer de forma bem resumida as principais características de um Dashboard Estratégico e um Dashboard Operacional.

## Dashboards operacionais

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtwmxz0mgmg54zoy91jw.png)

Tem como finalidade dar uma visão em tempo real (real time) do desempenho de determinada operação, apresenta métricas bem definidas que garantem a tomada de decisão mais adequada para o momento. Sendo assim, é normal termos um número grande de informações, como por exemplo:

- Painéis com informações real-time sobre ligações recebidas/realizadas;
- Monitoramento de ligações atendidas/perdidas de um call center;
- Chamados acumulados para determinada área;
- Google Analystics com informações de trafego de um site;

## Dashboard Estratégicos

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b01psxba7zbgcyaev22q.png)

Tem como principal característica apresentar informações de uma forma simples e rápida, para que os tomadores de decisão possam acompanhar o seu negócio;

Para Few (2006, p. 41), “O uso primários de Dashboards nos dias de hoje é para propósitos estratégicos (…), [pois eles] oferecem uma rápida visão que os tomadores de decisão precisam para monitorar a saúde e as oportunidades de um negócio (…)”.
Best time to buy sell 1
Tags: go, interview, programming, career
Published: 2024-06-22 16:06:38

Here we address the original best stock buy-sell question.

Given an array of stock prices on different days, find the maximum profit when only one buy and one sell is allowed.

This is pretty straightforward and an online search provides a number of examples.

```
func FindSingleBestBuySell(prices []float64) float64 {
	buy := prices[0]
	maxProfit := 0.0
	for i := 0; i < len(prices); i++ {
		if buy > prices[i] {
			buy = prices[i]
		} else if prices[i]- buy > maxProfit {
			maxProfit = prices[i] - buy
		}
	}
	return maxProfit
}
```
The solution is to maintain a buy price and a profit. Start by assuming a buy at the initial price, then step through the array. If you find a lower price, then that becomes the new buy price. Otherwise we can check potential profit; so if the potential profit is greater than that seen previously, we can sell at the current price.

Are there any gotchas here? Post your thoughts in the comments.

Thanks!

_The code for this post and all posts in this series can be found [here](https://github.com/johnscode/gocodingchallenges)_