teleren/devto huggingface dataset:
Leet Code — 2315. Count Asterisks
Tags: leetcode, interviewquestions, java, string
Published: 2023-08-29 13:33:11

It’s an easy [problem](https://leetcode.com/problems/count-asterisks/) from leet code with the description being:

> You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth.

> Return the number of '*' in s, excluding the '*' between each pair of '|'.

> Note that each '|' will belong to exactly one pair.

> Example 1:

> Input: s = "l|*e*et|c**o|*de|"
> Output: 2
> Explanation: The considered characters are underlined: "l|*e*et|c**o|*de|".
> The characters between the first and second '|' are excluded from the answer.

> Also, the characters between the third and fourth '|' are excluded from the answer.

> There are 2 asterisks considered. Therefore, we return 2.

> Example 2:

> Input: s = "iamprogrammer"
> Output: 0
> Explanation: In this example, there are no asterisks in s. Therefore, we return 0.

> Example 3:

> Input: s = "yo|uar|e**|b|e***au|tifu|l"
> Output: 5
> Explanation: The considered characters are underlined: "yo|uar|e**|b|e***au|tifu|l". There are 5 asterisks considered. Therefore, we return 5.

> Constraints:

> 1 <= s.length <= 1000
> s consists of lowercase English letters, vertical bars '|', and asterisks '*'.
> s contains an even number of vertical bars '|'.

At first glance one way to get it done would be splitting the String using the vertical bars then ignoring every odd one and counting the asterisks, but actually you don’t need to do that, you can just iterate the String and count straight away (either counting the bars or using a Boolean to validate).

```java
class Solution {
    public int countAsterisks(String s) {
        
        int counter = 0;
        boolean notIgnore = true; //  flag that will swap when vertical bar found
        
        for(int i=0 ; i<s.length() ; i++) {
            
            // retrieving char
            char c = s.charAt(i);
            
            // ignoring the ones not needed
            if(c != '*' && c != '|') continue;
            
            
            // checking if is asterisk and to be ignored or not
            if(c == '*') {
                if(notIgnore) counter++;
            } else {
                notIgnore = !notIgnore;
            }
        }
            
        return counter;
    }
}
```

> Runtime: 2 ms, faster than 71.32% of Java online submissions for Count Asterisks.

> Memory Usage: 40.7 MB, less than 37.11% of Java online submissions for Count Asterisks.

Another case that can be done is use of regular expression and replacement, but that would be overkill for an easy problem, unless you want to bring to the next level, imo.

---

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! :)
Stop the Invasion of Fake Followers
Tags: spam, follower, discuss, fake
Published: 2023-08-29 13:31:46

Over the past few weeks I've been getting more and more followers on DEV.TO out of the blue. First I thought it was thanks to my last articles, but quickly I realized that almost all new followers are fakes.

Or how come that you get only 1-2 reactions on a post with 318 "followers"???

If you look at this screenshot of my follower dashboard, you can see what's going on.... "Why do they all have bw profile pictures and weird names," I thought.

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

## They steal our time, and mess up the reputation of DEV.TO, because of their greed for money.

It really annoys me, and wastes my time as a professional developer who wants to make a valuable contribution here. So here is a list of accounts that are clearly SPAM, and a list of accounts that appear to be real users. Some I leave out because I can't tell if they are real or fake.

## Here are the fakes and spammers among my followers (Report them, too!):

@influencer
@ccjsytesse
@renneford294 
@moshermax45 
@maciasver578
@realsbet 
@tenexch  
.... I am stopping here with the list.. read below.

## And here my (hopefully!) REAL Followers who deserve to be mentioned:

@jesscsommer (Software Engineer)
@pbrodz (Microsoft Engineer)
@amin1234 (says he wants to learn PHP, that's fine...)
.... I am stopping here with the list.. read below.

## I got tired and dissapointed
So while scrolling through my follower list and checking each one, I realized with great disillusionment that **almost all of my 318 followers are fakes**, spammers or some companies that want nothing more than to generate backlinks or sales.

**This is really very sobering. I didn't continue the list...**

## I bring decent traffic to DEV.TO...

.......and it could become much more, but... I don't know.

If the statistics are correct at all, I have generated over 20.000 views from Google on the platform over the time.

DEV.TO definitely has some good ranking and that's also because it's done pretty well. I apreciate the clean and easy structure of the website.

BUT the SPAM issue is a big issue. It makes me think about 2 important things:

- should I keep trying to post quality content here?
- should I keep considering to advertise here, or will my Ads only be seen my spammers???

Maybe the @devteam can help making these decisions?
What is your opinion? Write it in the comments, if you're real!
The Art of Understanding Before Coding
Tags: developer, career, productivity, beginners
Published: 2023-08-29 13:31:45

Some developers when receives a task starts thinking about implementing the requirements, whether it will be complicated or not, the piece of the code to be refactored, or something like that. You shouldn't think about code before understanding your business.

# Split
If you're this developer, I suggest splitting the process of understanding and organizing the task to implement the requirements. 

It does not make sense to start doing something you don't understand. If you need to know if you understand something, an excellent way is to write about it or draw the task - using Excalidraw, for example. This process will force you to understand the task, think about problems, and help you ask the right questions. Some questions that would be nice to ask yourself, for example:

For features
- Why is this feature important?
   - What kind of problem this feature is solving?
- Who needs this feature?

For bugs
- Conflict the wrong and proper behavior;
- Think about what logs are saying;
- Understand the nature of the bug
   - Does it happen during some specific flow?
   - Does it happen for a wrong implemented business logic?
   - Can you reproduce it?
- If it is from a ticket, what is the customer reporting?


If you think that you understand it, try to draw it. Something like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gib2cm5porintxfawibw.png)
(image from [researchgate](https://www.researchgate.net/figure/This-process-flow-diagram-shows-the-simulation-logic-for-each-company-for-each-month-The_fig1_220250064))



# Code
Now that you think about the problem, you can start to think about the implementation. If you are doing it well, you will believe that the code is the more uncomplicated part of the process. And the crucial is to understand what to code.

With it, you can reduce the scope of code debugging and start to visualize your app in chunks instead of wasting time writing or reading something unrelated to your task. 

You will probably write less code and deliver your job faster and with more quality. Also, you will improve your knowledge about the business and the code and will be more efficient in helping others in your team.

# Conclusion
Ultimately, the deal is that you understand that you would split your task into steps and start by really understanding what and why you are doing.

Don't worry about time. This process can take some time, but the deal is always to try to understand what you are doing.


Banner from [unsplash](https://unsplash.com/photos/0E1PYojm4CY)
Hello from the Connected Side... We've Been Scanning IPs All Night
Published: 2023-08-29 13:25:33

Imagine Shodan as an online searcher, like a person who looks around the neighborhood to find interesting things. Instead of houses, it searches the internet for gadgets and devices.

Now, think of hackers as sneaky intruders, kind of like nighttime thieves. They try to find open doors or windows to get inside houses. In the online world, these hackers look for gadgets that aren't locked properly, just like thieves look for easy targets.

Shodan helps hackers find those gadgets that aren't locked up well. Just as thieves can break into houses that aren't secure, hackers can get into gadgets that aren't protected. This is why it's important to lock your gadgets with strong passwords and security tricks. When you do that, it's like making sure the doors and windows are locked tight, so the 'digital thieves' can't get in


How to protect yourself from it ?

1. Using strong passwords
2. Enabling Firewalls to prevent unauthorised access
3. Regular software updates
4. Using Network segmentation , isolate critical systems from less secure devices.
5. Strong encryption    
6. Monitoring network traffic
7. Disable remote access 
8. Utilize two-factor Authentication 
9. Regular Audits and Access
10. Hide devices behind NAT to make them less discoverable
11. Limit access to trusted IPs
12. Follow Secured practises
Real- time machine monitoring software
Tags: computerscience, performance, datascience, machinelearning
Published: 2023-08-29 13:23:37

Real-Time Insights on Emissions for Sustainable Manufacturing! ♻🌟
Track, analyze, and prevent ESG risks effortlessly with our advanced machine monitoring software, iDataOps. Learn more [
https://www.rawcubes.com/industrial-dataops/machine-monitoring.html](https://lnkd.in/dj6tnage)
Quiz Show console-based game
Tags: beginners, python
Published: 2023-08-29 13:11:54

As part of the Code Academy CS course, I chose to construct a simple console-based Quiz show to display my skills in Python.


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

It can be found here: https://github.com/Whiteloaf/Quiz-game-console
How Much Does It Cost To Create Soulbound Token (SBT)?
Tags: nft, soulboundtoken, cryptotoken, business
Published: 2023-08-29 13:02:50

Soulbound tokens (SBTs) are a novel concept in the [blockchain ](https://www.blockchain.com/explorer)world, offering exciting possibilities for ownership and verification. This article explores how startups can leverage SBTs for innovative fundraising.

## Why SBTs are ideal for Startup Fundraising

Traditional fundraising has limitations. SBTs empower startups to:

**Embrace Tokenization:** Break free from traditional methods by offering investors a stake in the company's success through [tokens](https://en.wikipedia.org/wiki/Token). This eliminates intermediaries and fosters transparency.

**Empower Investors:** SBTs incentivize investors beyond financial returns. They become stakeholders with shared interests, creating a loyal community that actively supports growth.

**Democratize Fundraising:** Tokenization allows fractional ownership, enabling even small investors to participate in exciting projects. This creates a more inclusive funding ecosystem.

**Enable Continuous Engagement:** SBTs facilitate ongoing communication with investors. They can receive exclusive benefits like early product access, voting rights, or revenue sharing.

**Navigate Regulations:** Collaborate with legal experts to ensure compliance with relevant guidelines. This protects both the startup and investors.

## The Cost of Creating an SBT

**Several factors influence SBT creation costs
**
**Gas Fees:** The cost of processing transactions on the blockchain.
**Smart Contract Development: **The cost of creating the code that governs the SBT.
**Platform-Specific Costs:** Fees associated with the chosen blockchain platform.

Costs can fluctuate as the blockchain landscape evolves. SBT development typically ranges from **$5,000 to $6,000**. Conduct thorough research and consult experts for accurate estimates before creating your SBT.

## Unlocking Your Startup's Potential with SBTs

SBTs offer a revolutionary fundraising approach for startups. With careful planning and expert guidance, you can unleash your startup's potential and embark on a successful fundraising adventure.

As the blockchain landscape evolves and new platforms emerge, these costs may continue to fluctuate. Approximately, **[Soulbound token development](https://www.coinsclone.com/soulbound-token-development/?utm_source=dev&utm_medium=SBT&utm_campaign=Udhay)** cost ranges from **$5000 to $6000**. Therefore, it is essential to conduct thorough research and consult experts to get accurate estimates before embarking on your Soulbound Token creation journey. So, why wait? It's time to unleash the potential of your startup and embark on an extraordinary fundraising adventure with a soulbound token.
SSR-Proof Effects: Control Client-Side Lifecyles /w some React Magic
Tags: react, javascript, tutorial, node
Published: 2023-08-29 13:00:00

<figure>
  <figcaption>Cover Photo by <a href="https://unsplash.com/@mildanat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Anatvida Sukchanta</a> on <a href="https://unsplash.com/photos/CFBoeNgZI3g?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
  </figcaption>
</figure>  

When working with React on a project using Sever Side Rendering (SSR), you might often encounter situations where you need to perform certain actions after your component has been rendered on the client side. However, traditional hooks like `useEffect` or `useLayoutEffect` can sometimes execute their effects both on the server and client side, leading to suboptimal behaviour during server-side rendering (SSR). 

Enter the `useClientLayoutEffect` custom hook – a solution that empowers you to control when an effect should run exclusively on the client side.

***

## The Benefits

**Client-Side Precision**
Unlike regular effects, `useClientLayoutEffect` ensures that your code is executed solely on the client side, avoiding any unnecessary server-side execution.

**Optimized Performance**
By avoiding unnecessary server-side effects, your application's performance can be enhanced, resulting in faster load times and smoother user experiences.

**Consistent Behaviour**
This custom hook maintains the familiar structure of React's effect hooks, making it easy to integrate into your existing components and workflows.

***

## Use Cases for `useClientLayoutEffect`

**DOM Measurements** 
When you need to measure elements or perform layout calculations, using `useClientLayoutEffect` guarantees that your calculations are based on the actual client-rendered DOM, eliminating inconsistencies.

**Third-Party Integrations** 
Integrating third-party libraries or widgets that depend on the window object becomes seamless, as the effects will only be triggered when the necessary client context is available.

**Animations and Transitions** 
Applying animations and transitions often requires access to the client-side rendering engine. With `useClientLayoutEffect`, you can ensure animations are smoothly initiated without SSR-related hiccups.

***

And the code:

{% gist https://gist.github.com/mike-at-redspace/788f2570d13dee17726181acdc0e628b %}

***

Whether you're measuring elements, integrating external libraries, or orchestrating animations, `useClientLayoutEffect` empowers you to craft components that are not only functional but also optimized for a smooth user experience. It just might be a tool worth adding to your React hooks.

So there you have it, a dynamic solution to ensure your effects are in sync with the client-side rendering cycle, leading to a more polished and efficient React application.

Happy Coding!
Conexión C# con Mysql
Published: 2023-08-23 20:35:41

Para realizar la conexión con una base de datos MySQL desde .NET hay que realizar lo siguiente (siguiendo una sintaxis de C#):

**Hay que hacer referencia a:**
`using MySql.Data.MySqlClient;`

**Conectarse a MySQL con .NET**

```
string connectionString = "Server=127.0.0.1;Port=3306;Database=personal;Uid=root;password=test;";
MySqlConnection conexion = new MySqlConnection(connectionString);



```
**Abrir la conexión con la base de datos**

```
conexion.Open();


MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conexion;
cmd.CommandText = "select/insert/update aqui";
```
**Consultar información de la base de datos con .NET (select)**

```
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conexion;
cmd.CommandText = $"select * from Articulo where id = ?articuloId";
cmd.Parameters.Add("?articuloId", MySqlDbType.Int32).Value = articuloId;
Articulo articulo = new Articulo();
using (var reader = cmd.ExecuteReader())
{
    while (reader.Read())
    {
        articulo.Id = Convert.ToInt32(reader["id"]);
        articulo.Titulo = reader["Titulo"].ToString();
    }
}
return articulo;
```

**Insertar valores en una base de datos con .NET (insert)**

```
using (MySqlConnection conexion = new MySqlConnection(connectionString))
{
    conexion.Open();

    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = conexion;
    cmd.CommandText = "INSERT INTO `ejemplo-conexion`.`Articulo` (`Titulo`, `Contenido`, `AutorId`, `Fecha`) VALUES (?titulo, ?contenido, ?autorid, ?fecha);";

    cmd.Parameters.Add("?titulo", MySqlDbType.VarChar).Value = $"nuevo titulo";
    cmd.Parameters.Add("?contenido", MySqlDbType.VarChar).Value = $"nuevo contenido";
    cmd.Parameters.Add("?AutorId", MySqlDbType.Int32).Value = 1;
    cmd.Parameters.Add("?fecha", MySqlDbType.DateTime).Value = DateTime.Now;

    cmd.ExecuteNonQuery();
}
```
**recoger el ID insertado**

```
cmd.ExecuteNonQuery();
var ultimoId = cmd.LastInsertedId;
```


**Actualizar valores de una base de datos con .NET (update)**

```
using (MySqlConnection conexion = new MySqlConnection(connectionString))
{
    conexion.Open();

    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = conexion;
    cmd.CommandText = "update `ejemplo-conexion`.`Articulo` SET `Titulo` = ?titulo where ID = ?id;";

    cmd.Parameters.Add("?titulo", MySqlDbType.VarChar).Value = $"titulo actualizado";
    cmd.Parameters.Add("?id", MySqlDbType.Int32).Value = 3;

    cmd.ExecuteNonQuery();
}
```
Namma Doctorvalley Pvt Ltd
Published: 2023-08-29 12:51:14

DoctorValley is India's leading medical tourism company that takes care of everything you need for a simple and stress-free stay during your medical visit to India. With a group of enthusiastic, hardworking and committed individuals. We aim to help people looking for safe, high quality and affordable healthcare options in India. We stand proudly with our goal of providing the best healthcare at reasonable prices. We at DoctorValley appreciate the opportunity you have given us to help you achieve a better and healthier lifestyle.
Our specialized Treatments

[ Cancer treatment](https://www.doctorvalley.com/cancer-treatment-in-india/)
 [Cardiology treatment](https://www.doctorvalley.com/cardiology-treatment-india/)
 [Orthopaedic treatment](https://www.doctorvalley.com/orthopedics-surgery-india/)
 [ENT treatment](https://www.doctorvalley.com/ent-treatment-india/)
 [Neuro treatment](https://www.doctorvalley.com/neurology-treatment-india/)
 Organ transplant treatment
 Bone marrow transplant
[ Bariatric Surgery and Weight Loss Surgery in India](https://www.doctorvalley.com/bariatric-and-weight-loss-surgery-in-india/)
 Neuro and Spine Surgery in India
Address / Location: 
Bangalore (Headquarters)
#63,1st floor,industrial layout,
5th Block, Koramangala,
Bangalore- 560095
Phone: +91-7975350894
Email: info@doctorvalley.com
Website: https://www.doctorvalley.com
Predictive machine maintenance
Tags: productivity, api, database, machinelearning
Published: 2023-08-29 12:47:27

Embrace Innovation, Embrace iDataOps: Your Path to Predictive Machine Maintenance! 🚀📊

⭕ Bid farewell to unexpected breakdowns that disrupt your operations.
⭕ Proactively identify and automate maintenance needs before they escalate.
⭕ Maximize uptime and productivity with digital records of service history

Learn more about iDataOps here - [https://www.rawcubes.com/industrial-dataops/machine-monitoring.html](https://lnkd.in/dg2h5gjP
)
Dev's, share something you know that most don't
Tags: discuss, programming, beginners, opensource
Published: 2023-08-29 12:45:00

Hey dev's 👋

Share anything – be it tools, hacks, techniques, or services – that you know that most don't. It can be as simple as an editor extension that helps you debug more efficiently or an API that makes fetching data a breeze.

I'll go first. Upstash Redis - Fully managed Redis database in the cloud. You get all the benefits of Redis, without the work of managing it. You can use it to store sessions, user data or some user info that you need blazing fast.⚡
Excel Add-ins: Release of New Version 2.8
Tags: exceladdins, devart, excel
Published: 2023-08-29 12:40:51

Devart released an updated version of Excel Add-ins 2.8.  

Devart, a recognized vendor of world-class data connectivity solutions for various data connection technologies and frameworks, rolled out updated [Excel Add-ins](https://www.devart.com/excel-addins/?utm_source=devto&utm_medium=referral&utm_campaign=pr_exceladdins_29.08.2023). Now, the product includes **MariaDB 10.10, PostgreSQL 15, and Zoho CRM API v4 support**. 

**The list of other improvements includes:**
- Salesforce Web Services API version 55.0 is supported.
- Custom App authorization is available for Excel Add-ins for Shopify.
- Private App authorization is available for Excel Add-ins for HubSpot.

To learn more about the recent release and download new products, visit:
https://blog.devart.com/release-excel-addins-update-ver-2-8.html?utm_source=brevo&utm_campaign=cc_digest_aug23&utm_medium=email

**Excel Add-ins** allow you to work with database and cloud data in Microsoft Excel as usual Excel spreadsheets. You can get precisely the data you need with visual Query Builder or SQL and refresh the queried external data in a workbook at any time with a single click.

**About Devart** 
 
Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration, and backup solutions. The company also implements Web and Mobile development projects. 
For additional information about Devart, visit https://www.devart.com/.
What would you do differently to build this simple form? Give your feedback!
Tags: javascript, react
Published: 2023-08-29 12:32:03

---
title: What would you do differently to build this simple form? Give your feedback!
published: true
description: I built a simple form and I am open to feedback from fellow developers.
tags: javascript, react
# cover_image: https://direct_url_to_image.jpg
---


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



It's been a while since I worked on a project from scratch. To check how things have since changed, I created a simple form project with React: https://main--vocal-moxie-c759df.netlify.app/


Check out the repo: https://github.com/dev-talha-akbar/react-recipe-form


What I have learned so far:
1. Vite is fast and hassle-free. I have not had to change a single config.
2. Bootstrap is still a great help. I could actually do way more with its well-documented and well-maintained components.
3. It's hard to maintain state in React. It becomes frustrating to do simple operations especially on arrays.
4. Since vanilla React easily becomes repetitive and frustrating, having React Query is a great addition to handle server logic.
5. i18next is great but setting it up is a tricky endeavor with automatic file scans.

If you had the chance to look at the source code or the demo, what would you have done differently? What would you do next?