teleren/devto huggingface dataset:
Criando um script de sorteio a partir de um CSV com PHP
Tags: php, csv, tutorial, braziliandevs
Published: 2024-03-28 14:31:49

No ano passado, tive a oportunidade de desenvolver um mini script para conduzir um sorteio na minha empresa. Neste artigo, vou compartilhar o código que utilizei o elefantinho.

- Primeira parte do código:

```
//Nome do arquivo CSV e a coluna que será usada para o sorteio
$nomeArquivoCSV = 'sorteio.csv';
$colunaSorteio = 'descricao'; 

// Verifica se o arquivo existe
if (!file_exists($nomeArquivoCSV)) {
    die("O arquivo CSV '{$nomeArquivoCSV}' não foi encontrado.");
}

// Lê o conteúdo do arquivo CSV
$linhas = file($nomeArquivoCSV, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Verifica se o arquivo está vazio
if (empty($linhas)) {
    die("O arquivo CSV '{$nomeArquivoCSV}' está vazio ou mal formatado.");
}
```
`FILE_IGNORE_NEW_LINES`: Cada linha do array terá quebra linha usando essa flag isso será ignorado
`FILE_SKIP_EMPTY_LINES`: Pula linhas vazias nome meio auto explicativo


- Segunda parte do código:

```
$call = function ($array) {
    return str_getcsv($array, ";");
};

$colunas = str_getcsv(array_shift($linhas), ";");
$colunaSorteioIndex = array_search($colunaSorteio, $colunas);

if ($colunaSorteioIndex === false) {
    die("A coluna '{$colunaSorteio}' não foi encontrada no arquivo CSV.");
}

// Obtém os elementos da coluna de sorteio
$elementosSorteio = array_column(array_map($call, $linhas), $colunaSorteioIndex);
```

`$call` é uma função anônima que recebe um array representando uma linha de dados CSV e o converte em um array usando o separador ponto e vírgula (`;`) através da função `str_getcsv`.

`str_getcsv(array_shift($linhas), ";")`: Esse codigo pega a primeira linha do conjunto de linhas (`$linhas`), a converte em um array onde cada elemento representa uma coluna, usando o ponto e vírgula (`;`) como separador.

`array_search($colunaSorteio, $colunas)`: Esta linha procura o índice da coluna especificada por `$colunaSorteio` dentro do array de colunas (`$colunas`). O índice é usado para localizar a coluna desejada nos dados do CSV.

- Agora vamos para parte final do script:


```
function sortearElemento(array $array)
{
    $indiceSorteado = array_rand($array);
    return $array[$indiceSorteado];
}

// Obtém os elementos da coluna de sorteio
$elementosSorteio = array_column(array_map($call, $linhas), $colunaSorteioIndex);

// Realiza o sorteio
$sorteado = sortearElemento($elementosSorteio);

// Exibe o resultado
echo "Sorte foi para : {$sorteado}";
```

 [Link para o script](https://gist.github.com/laurielylourenco/c37cc618fffc5e6caea1a8fd97d4b849)


_Espero que este artigo seja útil para quem estiver lendo :)_
Why Gutters Overflow: and How to Fix Them
Published: 2024-03-28 14:26:37

[Gutters overflow](https://usawaterrestoration.com/why-gutters-overflow/url) when they become clogged with debris such as leaves, twigs, and dirt, preventing proper water flow. To fix them, regularly clean gutters and downspouts, ensuring water can freely flow away from your home. Installing gutter guards can also help prevent debris buildup and minimize maintenance.
Announcing Spark: an easy-to-use CSS library for complex styles.
Tags: webdev, css, html
Published: 2024-03-28 14:26:02

Today, I am unveiling a project I've had sitting in the shop for a while... Spark!
https://github.com/CalinZBaenen/Spark

What is Spark?
Spark is an easy-to-use CSS library that takes advantage ov HTML's `data-`-attributes, and some default attributes, to easily apply complex or boilerplate styling to an element, making it easier to focus on just the layout.

Here is an example ov how I made the table shown in this post's cover-image.

```html
<table>
  <caption>Colors</caption>
  <tr>
    <td data-cutout></td>
    <th scope="col">Red</th>
    <th scope="col">Green</th>
    <th scope="col">Blue</th>
  </tr>
  <tr>
    <th scope="row">Lightened</th>
    <td style="background-color:#FF8080;"></td>
    <td style="background-color:#80FF80;"></td>
    <td style="background-color:#8080FF;"></td>
  </tr>
  <tr>
    <th scope="row">Normal</th>
    <td style="background-color:#FF0000;"></td>
    <td style="background-color:#00FF00;"></td>
    <td style="background-color:#0000FF;"></td>
  </tr>
  <tr>
    <th scope="row">Darkened</th>
    <td style="background-color:#800000;"></td>
    <td style="background-color:#008000;"></td>
    <td style="background-color:#000080;"></td>
  </tr>
</table>
```

![*{An image of a table with colors in it.}*](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doz2e04xn60414egtkbb.png)

As you can see, the first cell is... well... cut out, and you notice that I am using `data-cutout`.
`data-cutout`'s job is to make a table-cell act as if it were not present by making none ov its content display and hiding itself, which allows you to do some pretty cool things, like making pixel-art ov Mario:

![*{An image of an HTML table made to resemble Mario.}*](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs7cvtkvkbkw24vvsng2.png)

(Yes, this is actually an HTML table&nbsp;&nbsp;-&nbsp;&nbsp;you can see it in [`table.html`](https://github.com/CalinZBaenen/Spark/blob/main/examples/table.html) file in the `examples` directory.)

I'm hoping my library will find some merit, somewhere and will catch on...
... or at least inspire newcomers to HTML (orwith CSS) to dive deeper.

Anyways, that's all for today.

<br/>

<b><center><b>Thanks for reading!<br/>Cheers!</b></center></b>
First dev challenge of a favorite snack
Tags: frontendchallenge, devchallenge, css
Published: 2024-03-28 14:23:38

_This is a submission for DEV Challenge v24.03.20, CSS Art: Favorite Snack._

## Inspiration
<!-- What snack are you highlighting today? -->
**Pizza**

## Demo <!-- Show us your CSS Art! You can directly embed an editor into this post (see the FAQ section of the challenge page) or you can share an image of your project and share a public link to the code. -->

{% codepen https://codepen.io/OTJ/pen/YzMxmXx %}

## Journey <!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->
It was a bit challenging positioning the pepperonis on the pizza bread. Just did a simple one slice of pizza.

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

<!-- We encourage you to consider adding a license for your code. -->

MIT License

Copyright (c) [2024] [Obiyomi Tobiloba Joshua]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


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

<!-- Thanks for participating! -->
Dezentrale Klinik in Smart Contracts: Revolution der Gesundheitsversorgung?
Published: 2024-03-28 13:49:08

 Die Vision: Eine Klinik, die transparent und demokratisch von Patienten und Ärzten mithilfe von Smart Contracts verwaltet wird.

Das Potenzial: Effizienzsteigerung, Kostensenkung und bessere Patientenbeteiligung durch Automatisierung und Blockchain-Technologie.

Die Herausforderungen: Technische Komplexität, rechtliche Grauzonen, regulatorische Hürden und die Akzeptanz der umgesetzten.

Der Weg dorthin: Festlegung der Ziele, Entwicklung und Tests der Smart Contracts, Finanzierung der DAO, Gewinnung von Mitgliedern und schrittweise Implementierung.

Die Zukunft: Dezentrale Kliniken könnten die Gesundheitsversorgung revolutionieren, indem sie die Macht von Patienten und Ärzten stärken.

Codebeispiele: Finanzverwaltung, Personalwesen, Beschaffung, Entscheidungsfindung und Patientenbeteiligung in Solidity.

Diskussion: Wie kann die Blockchain die Gesundheitsversorgung verbessern? Welche Herausforderungen müssen gemeistert werden?

Weitere Informationen: Links zu relevanten Ressourcen.

Hashtags: #DAO #Blockchain #Gesundheitswesen #SmartContracts #Zukunft


Aufruf zum Handeln: Teilen Sie Ihre Meinung in den Kommentaren!
Enhancing Testability with Dynamic Data-testid Attributes
Tags: react, testing, webdev, beginners
Published: 2024-03-28 14:21:39

We've all been faced with the challenge of choosing a better test ID for our component at some point. Why not leverage the logic we already use for CSS, like BEM (Block Element Modifier)? What is the best solution for achieving consistent and logical IDs across the board? What are the existing best practices?

✅ The Solution:
The best solution I've found with React is to create a custom hook that generates an ID, making it easier to locate them in our tests.

📚 Code Examples:

Create a custom hook useTestIdGenerator.ts:

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

Use the custom hook in your grid component:

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

Now, each element in your grid has unique "data-testid" attributes!

This approach greatly facilitates testing of dynamic components while maintaining the cleanliness and maintainability of your code. 🔥

An example test using this unique attribute:

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

Don't hesitate If you have another even better solution, to suggest it in the comments.
Ibuprofeno.py💊| #65: Explica este código Python
Tags: python, spanish, learning, beginners
Published: 2024-03-28 14:20:33

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Básico</mark></center>

```py
## Reto #65
my_dict = {"name": "John", "age": 30, "city": "New York"}
my_dict.pop("last_name")
print(my_dict)
```

👉 **A.** `TypeError`
👉 **B.** `SyntaxError`
👉 **C.** `KeyError`
👉 **D.** `{"name": "John", "age": 30, "city": "New York"}`

---

Respuesta en el primer comentario.
Geolocation Web API - explained in less than 256 chars
Tags: frontendchallenge, devchallenge, javascript, webdev
Published: 2024-03-28 14:12:46

_This is a submission for DEV Challenge v24.03.20, One Byte Explainer: Browser API or Feature._

## Explainer
#### Geolocation API: 🌍📍

- **What it does:** Reveals your coordinates.
- **How it works:** Magic (and sensors). It uses device sensors like GPS, Wi-Fi, and IP address to triangulate your position 🛰️🔍.
- **Why use it:** Maps, weather, ~~stalking~~. 😄

## Additional Context
The Geolocation API is a handy tool for web developers to access a user’s location. For privacy reasons, the user is asked for permission to report location information. It relies on device sensors like GPS, Wi-Fi, and IP addresses to triangulate the user’s position. While it’s commonly used for maps and weather apps, let’s not forget its more playful applications—like tracking down the best local coffee shop or finding that elusive food truck! 🌍📍☕🚚


Thank you for reading 😊 have a nice day!
Storytelling in speeches
Tags: softskills, learning, marketing, management
Published: 2024-03-28 14:12:19

Storytelling is a powerful tool for emotionally engaging your speech at almost any level and for any purpose. Telling a story as a pitch kickoff for investors? Great. Storytelling as a team building tool during team meetings? Builds credibility. Storytelling elements in a project report? Makes it and you more memorable.

It is great for IT conferences and any technical topic from simple to complex. Especially if your audience isn't as knowledgeable about the topic you're talking about. 

Sometimes it's not so easy to figure out how to take a story and make it coherent, interesting and deep. It might seem like an intricate art, a sea of talent and practice. And to some extent, that's true.

But in reality, a story follows clear rules: the rules of plot, empathy, contrast, and character. Understanding these rules empowers anyone to tell fantastic stories! That's why we've created this template to help you prepare and refine your own story.

So we created a page in our Handbook and a template to guide you through 4 simple steps in developing your narrative:

1. Discover the essence of your story by sketching out major events, barriers, and thrilling plot twists. Get to the heart of the main conflict right away!

2. Bring your protagonist to life by exploring their goals, motivations, and vibrant surroundings. Dive into the depths of their character and unveil the challenges they'll face.

3. Formulate the core idea of your story and consider its impact on the audience.

4. Bring it all together visually: note events, emotions, and follow the story's arc and contrast.

If you're interested, check out our [open and free Handbook](https://teamlead-handbook.addpotion.com/?utm_source=devto&utm_medium=organic&utm_campaign=comm), where you can find the [page dedicated to storytelling](https://teamlead-handbook.addpotion.com/storytelling?utm_source=devto&utm_medium=organic&utm_campaign=comm), the [template](https://miro.com/miroverse/storytelling-canvas-1/) and also the [examples of cool speeches](https://teamlead-handbook.addpotion.com/coaches-comments-on-the-pitch-examples?utm_source=devto&utm_medium=organic&utm_campaign=comm) we gathered for you. Hope you like it!
Apple and Orange
Tags: beginners, programming, tutorial, javascript
Published: 2024-03-28 14:11:30

*Prepare your favorite cup of coffee*, because we are about to enter the fantastic world of **Apple and Orange**.

## The problem

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

## The solution

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/095locmecqcqe2gjcrc4.jpeg)

To start developing the solution, the first step is to define the function that will manipulate the input data:

```js
function countApplesAndOranges(s, t, a, b, apples, oranges) {}
```

Next we will count how many apples fell in Sam's yard. To do this, we will use the `filter` function on the `apples` array and **we will only consider apples that are at a distance greater than or equal to s** (the starting point of Sam's house) **and less than or equal to t** (the end point of Sam's house). In the end, we will check the size of `apples` with the `length` method and store this value in the `appleCount` constant:

```js
const appleCount = apples.filter(apple => (a + apple >= s && a + apple <= t)).length;
```

To count the oranges we will follow the same logic, **considering the oranges that are at a distance greater than or equal to s and less than or equal to t**. After this operation, we will store this value in the constant `orangeCount`:

```js
const orangeCount = oranges.filter(orange => (b + orange >= s && b + orange <= t)).length;
```

Now that we have determined the number of apples and oranges that fell in Sam's yard (`appleCount` and `orangeCount`), let's display these values in the console:

```js
console.log(appleCount);
console.log(orangeCount);
```

## Final resolution

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

After following the step by step we have our final resolution:

```js
// Function that counts how many apples and oranges fell in Sam's yard
function countApplesAndOranges(s, t, a, b, apples, oranges) {
    // Checking how many apples fell in Sam's yard
    const appleCount = apples.filter(apple => (a + apple >= s && a + apple <= t)).length;
    // Checking how many oranges fell into Sam's yard
    const orangeCount = oranges.filter(orange => (b + orange >= s && b + orange <= t)).length;
    // Showing on the console the amount of apples and oranges that fell in Sam's yard
    console.log(appleCount);
    console.log(orangeCount);
}
```

*Share the code, spread knowledge and build the future!* 😉

> Images generated by **DALL·E 3**
Introducing Content Credentials API
Tags: contentauthenticity, contentcredentials, api
Published: 2024-03-28 14:09:40

_Use Content Credentials API to verify online media._

## What is Content Credentials API?

Content Credentials API helps you verify online media.

## Why verify online media?

Deepfakes. Voice cloning. Synthetic media. It’s hard to tell what’s accurate and authentic these days.

Content Credentials make the origin and history of content available for everyone to access, anytime. With this information at your fingertips, you have the ability to decide if you trust the content you see — understanding what it is and how much editing or manipulation it went through.

Simply provide the media URL, the Content Credentials API will return information about the content you’re viewing:

-     Authorship
-     Identity information
-     Original media
-     Types of edits
-     AI models used for editing and generation

## Supported formats

The Content Credentials API supports the following media formats:

-     Images: AVIF, DNG, HEIC, HEIF, JPG, JPEG, PNG, SVG, TIF, TIFF, WebP
-     Audio: M4A, WAV
-     Video: AVI, MP4, MOV

⭐ Get started by [signing up](https://rapidapi.com/studio-xolo-studio-xolo-api/api/content-credentials/pricing) for an API key.

Have questions or feedback? Leave your comment below, or [contact us](mailto:support@studioxolo.com).

Alternatively, schedule a [free 30-min consultation](https://cal.com/studioxolo/custom-development-consultation) for custom development.
Best B2B Webinar Marketing Tips to Boost Audience & Lead Generation
Tags: webinarmarketing, webinarmarketingservices, webinarpromotion
Published: 2024-03-28 14:03:29

Discover the best B2B webinar marketing tips to enhance audience engagement and drive lead generation. Unlock expert insights and strategies for maximizing the impact of your webinar campaigns in this informative blog from Denave.

Original Source:https://www.denave.com/blogs/best-b2b-webinar-marketing-tips-to-boost-audience-and-lead-generation/
GeolocationAPI: Your Digital Compass 🌍
Tags: frontendchallenge, devchallenge, javascript, webdev
Published: 2024-03-28 13:55:15

_This is a submission for DEV Challenge v24.03.20, One Byte Explainer: Browser API or Feature._

## Explainer
The *Geolocation API* enables web apps to access user location with their permission, vital for location-based services like **maps** or **weather apps**. It respects user privacy by prompting for consent before retrieving location data.

## Additional Context
Geolocation API works by leveraging a device's GPS, Wi-Fi, or cellular data to determine the user's location, and it's widely supported across modern web browsers.



<!-- Thanks for participating! -->
GitHub profile README
Tags: github, opensource, productivity, learning
Published: 2024-03-28 13:53:42

🚀 Exciting news!

I've just refreshed my GitHub profile README with my latest projects and skills! 🔥

Take a peek to see what I've been up to and witness my expertise in action:
[GitHub Profile](https://github.com/lassiecoder/lassiecoder)


![My Gitub README v2 preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w9a3umchxuczkbetzsz1.gif)

**_What's its significance?_**
Your GitHub README functions as a dynamic portfolio, spotlighting your talents and projects for potential collaborators and connections.

Seize this chance to leave a lasting impression! 🙂
Microsoft is now offering FREE certification courses
Tags: programming, microsoft, ai, beginners
Published: 2024-03-28 13:48:26

⚡️🌟 Exciting News! Microsoft is now offering FREE certification courses.🔥🔥
Yes, you read that right: No Fee ✔️ No Subscription ✔️ No Registration Required ✔️ Just grab your laptop and start learning!

🚀1. Microsoft Azure Fundamentals
-> Course Code: AZ-900T00
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/gDWxR3jZ ]

🚀2. Python for beginners
-> Level: Begginer 8600XP
-> Duration: 5 Hours
-> Course Link: [ https://lnkd.in/gV6ryMJY ]

🚀3. Introduction to GitHub
-> Level: Begginer 900XP
-> Duration: 1.5 Hours
-> Course Link: [ https://lnkd.in/giHnmBqP ]

🚀4. Microsoft 365 Fundamentals
-> Course Code: MS-900T01
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/gPBhDnD6 ]

🚀5. Develop Generative AI Solutions with Azure OpenAI Service
-> Course Code: AI-050T00
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/g6B-PGxR ]

🚀6. Developing Solutions for Microsoft Azure
-> Course Code: AZ-204T00
-> Duration: 5 Days
-> Course Link: [ https://lnkd.in/ggRQrnzP ]

🚀7. Microsoft Azure Administrator
-> Course Code: AZ-104T00
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/g-B8EKY9 ]

🚀8. Configuring and Operating Microsoft Azure Virtual Desktop
-> Course Code: AZ-140
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/gJihFGEy ]

🚀9. Designing Microsoft Azure Infrastructure Solutions
-> Course Code: AZ-305T00
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/gNZBWwE6 ]

🚀10. Microsoft Azure Data Fundamentals
-> Course Code: DP-900T00
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/gP-fq9UD ]

🚀11. Microsoft Azure AI Fundamentals
-> Course Code: AI-900T00
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/gSwnvSUp ]

🚀12. Designing and Implementing a Microsoft Azure AI Solution
-> Course Code: AI-102T00
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/gXpPGGqu ]

🚀13. Microsoft Security, Compliance, and Identity Fundamentals
-> Course Code: SC-900T00
-> Duration: 1 Day
-> Course Link: [ https://lnkd.in/g4zs5Hmz ]

🚀14 .Data Engineering on Microsoft Azure
-> Course Code: DP-203T00
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/gfTwKMxS ]

🚀15. Microsoft Security Operations Analyst
-> Course Code: SC-200T00
-> Duration: 4 Days
-> Course Link: [ https://lnkd.in/gMzRHb8H ]

That's a wrap!

Hope this was helpful for you.
A Localized Digital Demand Generation Playbook for Hybrid Cloud Service Providers in the APAC
Tags: demandgenerationsolution, leadgenerationservice
Published: 2024-03-28 13:46:48

Explore a localized digital demand generation playbook tailored specifically for hybrid cloud service providers in the APAC region. Gain valuable insights and actionable strategies to effectively reach and engage target audiences in this dynamic market.

Original source:https://www.denave.com/blogs/a-localized-digital-demand-generation-playbook-for-hybrid-cloud-service-providers-in-the-apac/
PASS With IF ELSE In PYTHON
Tags: python, tutorial
Published: 2024-03-28 13:42:37

## PYTHON UNLEASH'D 02

As discussed in prev blog, conditional statement can make use of pass.

## What is Pass?

Pass is used as placeholder inside if statement.
When pass is encountered no action is taken, but program will not generate any error as there is one statement i.e, pass written there, which tells it is not empty.

Also we can write pass, when we want to add the code later, after some time depending on next parts of program. To escape from error, we can write pass.

**Note that in all cases, the pass statement is followed by a colon (:) to indicate the start of a code block, but there is no code inside the block. This is what makes it a placeholder statement.**

The below snippet from Geeks For Geeks show a good example on how we can use pass in if statement, function and class.

```
# Using pass as a placeholder inside an if statement
x = 5
if x > 10:
	pass
else:
	print("x is less than or equal to 10")

# Using pass in a function definition as a 
# placeholder for implementation
def my_function():
	pass

# Using pass in a class definition as
# a placeholder for implementation

class MyClass:
	def __init__(self):
		pass

```