teleren/devto huggingface dataset:
Leet Code — 1967. Number of Strings That Appear as Substrings in Word
Tags: interviewquestions, leetcode, java, string
Published: 2023-09-05 00:17:58

That’s an easy [problem](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/) with the description being:

> Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.

> A substring is a contiguous sequence of characters within a string.

> Example 1:
> Input: patterns = ["a","abc","bc","d"], word = "abc"

> Output: 3
> Explanation:
> - "a" appears as a substring in "abc".
> - "abc" appears as a substring in "abc".
> - "bc" appears as a substring in "abc".
> - "d" does not appear as a substring in "abc".
> 3 of the strings in patterns appear as a substring in word.

> Example 2:
> Input: patterns = ["a","b","c"], word = "aaaaabbbbb"

> Output: 2
> Explanation:
> - "a" appears as a substring in "aaaaabbbbb".
> - "b" appears as a substring in "aaaaabbbbb".
> - "c" does not appear as a substring in "aaaaabbbbb".
> 2 of the strings in patterns appear as a substring in word.

> Example 3:
> Input: patterns = ["a","a","a"], word = "ab"

> Output: 3
> Explanation: Each of the patterns appears as a substring in word "ab".

> Constraints:

> 1 <= patterns.length <= 100
> 1 <= patterns[i].length <= 100
> 1 <= word.length <= 100

> patterns[i] and word consist of lowercase English letters.


Looking through the problem description you understand that any pattern that is contained into the word its a match, so using contains method from String would do the trick.

A creation of a integer to count, iterating the array and comparing each if contains on the word would do the trick:

```java
class Solution {
    public int numOfStrings(String[] patterns, String word) {
        int count = 0;
        
        for(int i=0;i<patterns.length;i++){
            if(word.contains(patterns[i])) count++;
        }
        
        return count;
    }
}
```

> Runtime: 0 ms, faster than 100.00% of Java online submissions for Number of Strings That Appear as Substrings in Word.
> Memory Usage: 40.9 MB, less than 57.71% of Java online submissions for Number of Strings That Appear as Substrings in Word.

You can also get it done one liner using Stream, is not the best performance wise but still good enough:

```java
class Solution {
    public int numOfStrings(String[] patterns, String word) {
        return (int) Stream.of(patterns).filter(p -> word.contains(p)).count();
    }
}
```

> Runtime: 2 ms, faster than 7.50% of Java online submissions for Number of Strings That Appear as Substrings in Word.
> Memory Usage: 41.6 MB, less than 5.81% of Java online submissions for Number of Strings That Appear as Substrings in Word.

As you can see from runtime and memory usage its little bit heavier, so if performance might be an issue, focus on simple approach instead of using a lot of different processes.

---

That’s it! If there is anything thing else to discuss feel free to drop a comment, if I missed anything let me know so I can update accordingly.

Until next post! :)
What is RSS?
Tags: code
Published: 2023-09-05 12:09:33

---
title: What is RSS?
published: true
date: 2023-09-05 00:00:00 UTC
tags: code
canonical_url: https://hcoco1-blog.onrender.com/whats-rss/
---

![Image by Rafay Saeed Ansari](https://wpmayor.com/wp-content/uploads/2016/02/rss-40674_960_720.png)

“Have you noticed the little RSS icons around the web? Or have you heard about RSS from friends or colleagues, but still, it remains a mystery to you? What does it mean, how does it work, and do I really need it? These are just some of the questions that usually come to people’s minds when they hear about RSS.” (Feeder Help, 2021)

## What’s RSS?

“RSS stands for “Really Simple Syndication” or “Rich Site Summary.” It’s a web feed format used to distribute frequently updated content – like blog posts, news stories, or podcasts – in a standardized format.” (OpenAI, September 5. 2023)

### Step-by-Step Guide to use RSS:

1.Find the RSS Link:

This is usually a small orange icon that looks like radio waves, or it might simply say “RSS”. Click on it. Sometimes you’ll be taken to a page full of code – don’t panic! This is the RSS feed.

2.Copy the Link:

Right-click (or tap and hold on mobile) on the page or the RSS icon, and choose ‘Copy link address’ or something similar.

3.Choose an RSS Reader:

This tool or app collects and displays content from RSS feeds. Some popular options are Feedly, Inoreader, and The Old Reader.

4.Add the RSS Link to the Reader:

Open your chosen RSS reader. Look for an option that says “Add Feed”, “Subscribe”, or something similar. Paste the RSS link you copied into the given field and hit ‘Subscribe’ or ‘Add’.

5.Voila! You’re Subscribed:

Now, every time the website you subscribed to posts new content, it’ll show up in your RSS reader. This way, you can keep track of updates from multiple websites without visiting each one individually.

6.Keep Adding Feeds: For instance, you’re reading this post on my blog (https://hcoco1-blog.onrender.com/whats-rss/) right now. If you want to keep up with my future posts, you can subscribe to my RSS feed by clicking on the orange icon in the bottom left corner of the page. You can also subscribe to my YouTube channel, Twitter feed, or my LinkedIn account.

### Why Do This?

It’s a great way to stay updated! Instead of bouncing around different websites to see if they’ve posted anything new, you can just check your RSS reader and get all the latest updates in one place.

### References:

[What is RSS, and how can you use it? - Feeder Help. (2021, March 25). Feeder Help.](https://feeder.co/help/rss/what-is-rss-and-how-can-you-use-it/)

[Growth Origin. (2017, March 12). RSS made easy [Video]. YouTube.](https://www.youtube.com/watch?v=6HNUqDL-pI8)

[The Linux Experiment. (2023, May 9). STOP using SOCIAL MEDIA for News; RSS is MUCH BETTER! [Video]. YouTube.](https://www.youtube.com/watch?v=_7LTwnAaQ3k)

[“What is RSS?” prompt. ChatGPT, August 3 version, OpenAI, September 5. 2023, chat.openai.com.](https://chat.openai.com/share/45b9f111-7650-4720-9071-e929e99c0857)
Eco-Tech in the Deep Sea:How Underwater Data Centers Are Changing the Game
Published: 2023-09-04 22:44:42

## How Underwater Data Centers Are Changing the Game

The world of technology is diving deeper than ever before, quite literally. Underwater data centers, a marvel of eco-tech innovation, are making waves in the tech industry. In this article, we'll take a deep dive into the fascinating realm of underwater data centers and explore how they are revolutionizing data storage, cooling solutions, and environmental sustainability.

## Submerged Servers: The Concept

Underwater data centers are precisely what the name suggests—data centers located beneath the ocean's surface. These submerged facilities house racks of servers and data storage equipment within specialized containers designed for submersion. But why submerge data centers underwater? The answer lies in several key advantages.

## Natural Cooling Mechanism

One of the primary benefits of underwater data centers is their natural cooling mechanism. The deep-sea environment provides a consistent and low-temperature setting, eliminating the need for energy-intensive air conditioning systems. By leveraging the cold ocean water, these data centers achieve energy efficiency that is unmatched by their land-based counterparts.

## Renewable Energy Integration

Many underwater data centers are strategically located near coastal areas, allowing them to harness renewable energy sources such as tidal and wave power. This integration of renewable energy further reduces their carbon footprint, making them environmentally friendly solutions for data storage.

## Enhanced Security and Accessibility

Submerged data centers are also known for their enhanced security. Being submerged beneath the ocean's surface adds an additional layer of protection against physical intrusions. Moreover, their proximity to coastal areas ensures low-latency access to data for users in those regions.

## Environmental Sustainability

Perhaps the most compelling aspect of underwater data centers is their contribution to environmental sustainability. These facilities have the potential to reduce the carbon footprint of data centers significantly. The cooling efficiency and use of renewable energy sources align with the global push for greener technology solutions.

## Challenges and Future Prospects

While underwater data centers offer remarkable advantages, they are not without challenges. Maintenance and repair become more complex in underwater environments, and concerns about marine ecosystem impact must be addressed. Nevertheless, tech companies and environmentalists are exploring innovative ways to overcome these hurdles.

In conclusion, eco-tech is taking a plunge into the deep sea, and the results are promising. Underwater data centers are redefining the way we approach data storage, cooling solutions, and environmental responsibility in the tech industry. As technology continues to evolve beneath the waves, we can anticipate a future where sustainability and innovation go hand in hand, even in the depths of the ocean.
🔍 "Overlooked Use Cases in Your Tasks?"
Tags: tdd, testing, agile, javascript
Published: 2023-09-04 22:32:32

Throughout my 8️⃣ years in software development, I've faced a recurring challenge: **poorly specified tasks**. 😰

How many times were use cases overlooked by the PO? And what if, during development, I forgot a crucial detail? 🤔 These oversights often only emerged during testing or, even worse, once users began interacting with the application. 😓

This scenario began to shift for the better when I was fortunate enough to work with a PO who employed **Gherkin** for specifications. 🌟 From that point on, **the responsibility to define use cases was shared between the PO and myself**. This change not only made it easier to introduce automated testing but also helped me deliver more **bug-free software**. 🛠️💡

Let's dive into a practical example. 🧐

Imagine you were given this User Story: 
```
As a user, I should be able to redeem a discount coupon at checkout. 🛍️
``` 

Translating this **User Story** to automated tests in Jest:

```javascript
describe('Coupon Redemption based on User Story', () => {
  it('should allow users to redeem a discount coupon', () => {
    // Mock checkout process
    // Insert coupon code
    expect(finalPrice).toBeDiscounted();
  });
});
```

However, this test seems quite general and lacks detail.

Now, let's see how **Gherkin** can refine this: 👇

```
Scenario: Redeeming a valid coupon
Given the user is finalizing a purchase
When they enter a valid coupon code
Then the appropriate discount should be applied to the total 🟢

Scenario Redeeming an expired coupon
Given the user is finalizing a purchase
When they enter an expired coupon code
Then no discount should be applied
And a message stating the coupon has expired should be displayed. 🔴
```

Translating the refined **Gherkin** scenarios to **Jest** tests:

```javascript
describe('Coupon Redemption based on Gherkin', () => {
  it('should apply discount for valid coupon', () => {
    // Mock checkout process
    // Input valid coupon code
    expect(finalPrice).toBeDiscounted();
  });

  it('should show error for expired coupon', () => {
    // Mock checkout process
    // Input expired coupon code
    expect(finalPrice).not.toBeDiscounted();
    expect(displayErrorMessage).toBeCalledWith('Coupon expired');
  });
});
```

The **Gherkin** specifications not only address the scenario of a valid coupon but also consider the situation of an expired coupon, which could easily be overlooked with a vaguer User Story.
Git Commit Squash
Tags: git
Published: 2023-09-04 21:05:19

Squashing commits is the act of combining a few commits into one. There are two places the term "squash" appears, in the context of git:

-   [Squash merge](https://itnext.io/git-merge-vs-rebase-938950fb218)
-   Manual squash

The squash merge is a special type of merging, that automatically takes all of the commits in one branch, squashes them together, and adds the result commit into the target branch (usually master).

Squash merge is partially addressed in the following issue of Git Weekly:

-   [Git Merge vs. Rebase: The Three Types of Merge](https://itnext.io/git-merge-vs-rebase-938950fb218)

In this issue, we're going to talk about the ways one squashes a few commits together manually.

![](https://miro.medium.com/v2/resize:fit:1400/1*aDE3rCkEHdJ7KkMsofJhYA.png)

## Manual Squash

Manual squash is possible through "interactive rebasing". Let's assume we want to squash 5 last commits together. We'll then do an interactive rebase on the last 5 commits:

```bash
git rebase -i HEAD~5
```

This command will start the interactive rebase. An editor (e.g. `nano`) with content similar to what follows will launch:

```
pick f72e7cb Feat: Resurrect flatMap
pick 1a18b1c Feat: Add list transformations
pick 3420af4 3.0.0
pick f55a9ee Docs: Add marble diagrams to README
pick 0433f9d Update README.md
```

Keep the first line as is and replace every `pick` in the following lines with an `s` (for squash):

```
pick f72e7cb Feat: Resurrect flatMap
s 1a18b1c Feat: Add list transformations
s 3420af4 3.0.0
s f55a9ee Docs: Add marble diagrams to README
s 0433f9d Update README.md
```

Save and exit. Then the editor launches once more with the commit messages of all 5 commits. Feel free to delete it all and rewrite the whole message. Save and exit. And that would conclude the interactive rebase.

To verify that the squash was complete, do a git log:

```bash
git log
```

After the squash is done, if you want to push to your remote branch and any of the 5 commits were already pushed, you have to force it:

```
git push --force-with-lease
```

## Notes

- Always push with [`--force-with-lease`](https://itnext.io/git-force-vs-force-with-lease-9d0e753e8c41). Never use `--force`.
- In the interactive rebase commit picker, you can write `squash` instead of `s`. But I guess a simple `s` would be easier to write down.
- To learn more about auto-squash, please refer to my "[16 Git Tips and Tricks](https://itnext.io/16-git-tips-and-tricks-bf08d0602d3b)". I'll write more about it in detail.
- [Subscribe](https://medium.com/subscribe/@aerabi) to my Medium publishes to get notified when a new Git Weekly issue is published.
- Follow [me on Twitter](https://twitter.com/MohammadAliEN) for weekly articles and daily tweets on git.
🎨 Diving Deep into the Colorful World of 'State of CSS' 2023: Trends, Tools, and More! 🚀
Tags: webdev, css, programming, discuss
Published: 2023-09-04 20:52:40

## Hello dev.to community! ✨

Today, I want to share with you something about the "State of CSS" 🎨, an annual survey I've been closely following for some time. For those unfamiliar, State of CSS collects data on trends, technologies, and techniques we web developers use, focusing specifically on our beloved CSS.

Ever heard of "State of JS"? 📊 Well, "State of CSS" is its counterpart, zooming in on the world of stylesheets. I find these surveys incredibly helpful for pinpointing emerging trends within our community 🌐. They help me grasp which tools are gaining traction and which might be fading away.

In the "State of CSS" reports, I've discovered:

- CSS features my fellow developers are using or wanting to learn 📚.
- Info on preprocessing tools I adore, like Sass and LESS ❤️.
- Insights on trending CSS frameworks and libraries 🛠️.
- And about CSS writing methodologies, such as BEM and OOCSS 🔍.
- Plus, there's always a segment on opinions (sometimes controversial ones!) around trends like CSS in JS 💬.

If you're someone keen on staying updated with the best practices and most popular tools in web design and development, I'd definitely recommend giving it a look 🔥.

Catch you next time, devs! 🚀👩‍💻👨‍💻

[https://2023.stateofcss.com/en-US/](https://2023.stateofcss.com/en-US/)
Challenges with SMOTE Oversampling for Bankruptcy Prediction
Tags: python, machinelearning, smote, scikit
Published: 2023-09-04 20:45:03

Hello members,

I'm working on a supervised machine learning project that aims to predict company bankruptcy based on a dataset I have. I'd like to share the context and the challenges I am facing, hoping for your guidance.

**Dataset & Initial Approach:

1/The dataset has a significant imbalance: 96% of the companies are not bankrupt, whereas only 4% are.

2/ In my initial approach, we tackled this imbalance through undersampling, which meant we randomly removed non-bankrupt companies to achieve a 50-50 proportion.

3/Using this balanced dataset, we trained several models - logistic regression, random forest, and decision trees. The results were encouraging as we achieved a good predictive capacity.

**New Requirement & Issue:

Now, for a class project, I need to utilize oversampling instead of undersampling. The technique we've been guided to use is SMOTE (Synthetic Minority Oversampling TEchnique), which generates synthetic samples based on the k-nearest neighbors from instances in the minority class.

However, after applying SMOTE and then running my models (logistic regression, random forest, decision trees), the predictive performance has drastically diminished. The models, which previously were performing well with undersampling, now seem to have little to no predictive capacity post SMOTE.

I've reviewed my Python code multiple times and am confident about the implementation. This leads me to question if SMOTE or oversampling, in general, might not be the right approach for this specific dataset. Considering it was a recommended method from our professor, I'm a bit puzzled.

**Seeking Guidance:

Has anyone else faced challenges with SMOTE specifically in similar contexts?

Is there a fundamental reason why SMOTE might not be suitable for certain datasets or problems?

Are there any tips or adjustments you would recommend when using SMOTE?

Last question: Is SGD (Stochastic Gradient Descend) a type of logistic regrreession?

Any insights or suggestions would be greatly appreciated. Thanks in advance for your time and expertise.
Create a superuser in Django with custom user model attributes
Published: 2023-09-04 20:39:05

If you create a custom User model, inherited from AbstractUser and add custom attributes, it will be difficult to create a superuser with command `python manage.py createsuperuser` in terminal. 

An example custom User model inherited by AbstractUser:

```python 
# accounts/models.py

from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils.translation import gettext_lazy as _


class User(AbstractUser):
    """create User instance with additional attributes"""

    age = models.PositiveSmallIntegerField(
        default=15, validators=[MinValueValidator(15)], verbose_name=_("age")
    )
    can_be_contacted = models.BooleanField(verbose_name=_("contact consent"))
    can_data_be_shared = models.BooleanField(verbose_name=_("share consent"))
```

In order to be able to create a superuser, you need to pass the additional attributes.

One simple solution is to create a superuser in django shell:

```python
$ python3 manage.py shell
```

```python 
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from accounts.models import User
>>> from django.contrib.auth import get_user_model
>>> User = get_user_model()
>>> User.objects.create_superuser(username='Admin', email='admin@mail.com', password='custom_passW', age=30, can_be_contacted=True, can_data_be_shared=True)
<User: Admin>
```

_from accounts.models import User_: You import the custom User model from the app: "accounts" and the file: "models.py"
_User = get_user_model()_: This method will return the currently active user model, says :[Django docs](https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#referencing-the-user-model)
_User.objects.create_superuser(username='Admin', email='admin@mail.com', password='custom_passW', age=30, can_be_contacted=True, can_data_be_shared=True)_: you use the create_superuser method with all attributes to create a superuser.
_User: Admin_: with this confirmation you have created a superuser with username Admin.
The Digital Services Act package
Tags: law
Published: 2023-09-04 20:22:17

---
title: The Digital Services Act package
published: true
description: The Digital Services Act package
tags: #law 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-09-04 20:17 +0000
---


The EU passes a new law that will affect developers not only in the EU, but worldwide. 

The law provides for many mechanisms that are primarily intended to protect the rights of consumers. But I also see a lot of potential for abuse in this law.

I know that developers don't have that much to do with laws, but if you offer certain services or are responsible for implementing them, you also have to deal with that.

https://digital-strategy.ec.europa.eu/en/policies/digital-services-act-package

Have you heard about the set and what do you think?
How do I Hire an Angular Developer in Latin America
Tags: howtohire, recruitinginsights, remotework, angulardevelopers
Published: 2024-06-28 15:45:44

---
title: How do I Hire an Angular Developer in Latin America
published: true
date: 2023-09-04 20:04:00 UTC
tags: HowtoHire,RecruitingInsights,RemoteWork,angulardevelopers
canonical_url: 
---

In this guide, you’ll learn about the key skills you should look for when hiring Angular developers from Latin America.

The post [How do I Hire an Angular Developer in Latin America](https://blog.nextideatech.com/how-do-i-hire-an-angular-developer-in-latin-america%ef%bf%bc/) appeared first on [Next Idea Tech Blog](https://blog.nextideatech.com).
I Made Hangman Without using AI
Tags: python, programming, learning, ai
Published: 2023-09-04 19:55:27


![Image of a completed game of hangman](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjmyq6r1hz4wa5qxi1vy.png)

I am a hobbist programmer. As in I don’t get paid to program in anyway, shape, or form. That said, I have been taking the computer science course on https://codecademy.com, and I am here to tell you, Github Copilot can make a man lazy.

I’ve been hacking away at shoddy program an games for a few years now and one thing is for sure; As much as I have learned from AI, it doesn’t do one justice to rely on it. This simple program took me a whole two afternoons to complete. And even then, I left some algorithmic redundancies in there, simply because I used so much brain power having to think for myself.

There was a lot to learn here. I had considered myself to be a pretty “okay” Python programmer. Turns out Copilot is a crutch for me. From the moment I first saw the dude go and tabbed that complete, I thought to myself “You know, I am supposed to be learning.” So I took the initiative to write the program out long form in an attempt to get better.

I had choice to write any console game that I wanted, so I chose hang-man.

I have it linked below, if you would like to try it out for yourself and see what nooby programming looks like in 2023:

https://github.com/BradGaddis/python_hangman/

The rules are simple:

There are two players. Player one types 5 words and one is chosen at random. Player two must guess the random word. They get 3 extra guesses. If the hangman is drawn all the way in, player two loses and player one wins. Conversely, if player two guesses all of the correct letters, they win.

In conclusion, I learned a lot from this assignment. Take the time to detach from the tools you use sometimes. It might expose you to your weaknesses.