teleren/devto huggingface dataset:
Essential Helper Functions for Your JavaScript Projects
Tags: react, nextjs, javascript, webdev
Published: 2024-06-02 03:23:44

When working on various JavaScript projects, I often find myself needing some handy helper functions to simplify repetitive tasks. Below are some of the helper functions that have proven to be very useful in my projects. These functions cover a range of tasks from string manipulation to number checks and date formatting.

**1. Capitalize the First Letter of a String**
This function takes a string and capitalizes the first letter while converting the rest of the string to lowercase. This is particularly useful for formatting names or titles.

```
export const capitalizeFirstLetter = (word?: string) => {
  return word ? word.charAt(0).toUpperCase() + word.toLocaleLowerCase().slice(1) : '';
};
```

**2. Format an Array to a Sentence**
When you have an array of strings that you need to format as a sentence, this function joins the array elements with commas and replaces the last comma with "and".

```
export const formatArrayToSentence = (stringArr: string[]) => {
  if (!stringArr?.length) return '';

  return stringArr.join(', ').replace(/, ([^,]*)$/, ' and $1.');
};
```


**3. Format Date**
This function uses the moment library to format dates. It can format a date to DD/MM/YYYY or to a time format HH:mm A based on the isTime flag.

```
import moment from 'moment';

export const formatDate = (date: string, isTime = false) => {
  if (!date) return '';
  const parsedDate = moment(date);

  if (isTime) return parsedDate.format('HH:mm A');

  return parsedDate.format('DD/MM/YYYY');
};
```


**4. Truncate Text**
To shorten a text string to a specified length and append an ellipsis (...), use this function. It ensures the text does not exceed the desired length.

```
export const truncateText = (text: string, maxLength: number) => {
  if (text.length <= maxLength) return text;
  return text.substring(0, maxLength) + '...';
};

```


**5. Check for Uppercase, Lowercase, Numbers, and Special Characters**
These functions use regular expressions to check if a string contains at least one uppercase letter, one lowercase letter, one number, or one special character. These are particularly useful for password validation.

```
export const containsAtleastOneUpperCase = (val: string) => /(?=.*?[A-Z])/.test(val);

export const containsAtleastOneLowerCase = (val: string) => val ? /(?=.*?[a-z])/.test(val) : false;

export const containsAtleastOneNumber = (val: string) => /(?=.*[0-9])/.test(val);

export const containsAtLeastOneSpecialChar = (val: string) => /(?=.*[$&+,:;=?@#|'<>.^*_()%!-])/.test(val);


```

**Conclusion**
These helper functions are designed to make common tasks easier and your code more readable. By incorporating them into your projects, you can save time and ensure consistency across your codebase. Whether it's formatting strings, validating inputs, or checking object properties, these utilities cover a broad range of use cases that are essential in everyday JavaScript development.
Percona XtraDB Multi-Master Replication cluster setup between 3 nodes
Tags: database, devops, linux, systems
Published: 2024-06-02 03:03:28

This guide describes the steps to establish a Percona XtraDB Cluster v8.0 among three Ubuntu 22.04 nodes.

Install Percona XtraDB Cluster on all hosts that you are planning to use as cluster nodes and ensure you have root access to the MySQL server on each node. In this setup, Multi-Master replication is implemented.

https://bidhankhatri.com.np/system/percona-xtradb-multi-master-replication-cluster-setup-between-3-nodes/
Site-to-Site VPN between Mikrotik router and Ubuntu 22.04 through strongSwan using IPsec IKEv2
Tags: networking, devops, beginners, linux
Published: 2024-06-02 03:02:21

We will configure a site-to-site IPsec IKEv2 tunnel between the Mikrotik Router and the StrongSwan server. This will enable secure communication between devices connected behind the Mikrotik router and the StrongSwan server.

https://bidhankhatri.com.np/vpn/site-to-site-vpn-between-mikrotik-router-and-ubuntu-22.04-through-strongswan-using-ipsec-ikev2/
HTTP request from Obsidian notes
Tags: obsidian, plugin, tutorial, productivity
Published: 2024-06-02 02:59:26

Are you an [Obsidian](https://obsidian.md/) user looking to elevate your note-taking experience with dynamic data integration? Look no further than APIR ([api-request](https://rooyca.github.io/obsidian-api-request/)) – an Obsidian plugin designed to streamline HTTP requests directly into your notes.


## ⚡ How to Use

With APIR, integrating HTTP requests into your notes is a breeze. Simply create a code-block within your note, specifying the language as `req`. Inside this code-block, customize parameters such as URL, method, body, headers, and more to tailor your request precisely to your needs.

### 👨🏻‍💻 Example Code-block

~~~markdown
```req
url: https://my-json-server.typicode.com/typicode/demo/comments
method: post
body: {"id":1}
headers: {"Accept": "application/json"}
format: <h1>{}</h1>
req-id: id-persona
disabled
```
~~~

This example demonstrates how to send a POST request to a server, displaying the response 'id' field within an HTML heading tag. For more info about all the `flags` you can visit [APIR docs](https://rooyca.github.io/obsidian-api-request/).

Ready to revolutionize your note-taking workflow? **Try APIR today!** 🌟

---

P.S. If you find any bug, have any problem, doubt or want to add any functionality don't hesitate to write me. (You can also leave your issue at [https://github.com/Rooyca/obsidian-api-request/issues](https://github.com/Rooyca/obsidian-api-request/issues))
Monitor HA Cluster running Pacemaker and Corosync using Prometheus and Grafana using Docker
Tags: webdev, monitoring, docker, devops
Published: 2024-06-02 02:58:57

We will use Grafana with prometheus in container to monitor High availability cluster running by Pacemaker and Corosync.

Grafana dashboard which we will be using shows the details of a HA cluster running Pacemaker/Corosync. It is built on top of ha_cluster_exporter but it also requires Prometheus node_exporter to be configured on the target nodes, and it also assumes that the target nodes in each cluster are grouped via the job label.

https://bidhankhatri.com.np/monitoring/monitor-ha-cluster-running-pacemakr-and-corosync/
Software Engineers Learn More from Failures than Wins: A Perspective
Published: 2024-06-02 00:06:08

In the world of software engineering, success stories often dominate discussions, but it’s the failures that truly shape and hone an engineer’s skills. While wins provide validation and motivation, failures offer invaluable lessons that drive growth and innovation. Here’s why failures are so crucial in the learning process for software engineers:

1. Uncovers Weaknesses: Failures expose underlying weaknesses in code, architecture, or development processes that often go unnoticed during successful projects. For instance, a failed deployment might reveal gaps in the continuous integration pipeline or highlight insufficient test coverage.

2. Encourages Problem-Solving Skills: When a project fails, engineers must dissect the issue, understand its root cause, and devise a solution. This process of troubleshooting and debugging enhances critical thinking and methodical problem-solving abilities.

3. Promotes Innovation: Failures push engineers out of their comfort zones, encouraging them to explore new technologies, tools, or methodologies. A failed approach might lead to the discovery of more efficient or effective alternatives, fostering innovation.

4. Teaches Resilience and Adaptability: The frequent uncertainties in software development teach engineers resilience. They learn to cope with setbacks and adapt quickly, which is essential in a rapidly evolving industry.

5. Enhances Understanding of Systems: Failures often provide a deeper understanding of the systems and technologies involved. For example, a memory leak issue might lead to a deeper knowledge of memory management, which is crucial for designing robust software.

6. Improves Collaboration and Communication: Resolving failures often requires collaboration, improving communication skills and teamwork. Engineers learn to articulate problems clearly, listen to diverse perspectives, and work together to find solutions.

7. Build a Culture of Continuous Improvement: Embracing failure fosters a culture of continuous improvement. Organizations that see failure as a learning opportunity encourage their engineers to take calculated risks and innovate without fear of blame.

Embracing failure not as a setback but as a stepping stone is crucial for continuous learning and growth in the ever-evolving field of software engineering. By learning from their mistakes, software engineers can improve their skills, innovate, and contribute to building more resilient and efficient systems.
Retirement Calculator
Tags: retirementcalculator, vinkalprajapati, vinkal041, calculator
Published: 2024-06-02 02:42:00


{% codepen https://codepen.io/vinkalPrajapati/pen/GRaWdbx %}

The Retirement Calculator is a web application designed to help users estimate their retirement corpus based on various financial parameters. Users input their current age, retirement age, monthly savings, and expected return rate, and the calculator provides an estimate of their retirement corpus.

Usage:

Input Parameters: Users enter their current age, retirement age, monthly savings, and expected return rate into the respective input fields.

Calculation: Upon clicking the "Calculate" button, the application computes the future value of investments over the years until retirement based on the provided parameters.

Result Display: The estimated retirement corpus is displayed below the input fields.

Chart Visualization: Additionally, a chart is generated to visually represent the monthly investment and accumulated corpus over time.

Dynamic Updates: The chart updates dynamically whenever new values are inputted, providing users with real-time visual feedback.

Benefits:

Financial Planning: Helps users plan for their retirement by providing an estimate of their future financial resources.

Visual Representation: The chart offers a clear visual representation of how their investments grow over time, aiding in better understanding and decision-making.

User-Friendly: Simple and intuitive interface makes it easy for users to input their data and interpret the results.

Future Enhancements:

Additional Features: Incorporating additional features such as expense projections, inflation adjustments, and alternative investment scenarios.

Improved Responsiveness: Enhancing the responsiveness of the application for better usability across various devices and screen sizes.

Customization Options: Adding options for users to customize their inputs and chart preferences according to their specific needs and preferences.
programming clock
Tags: codepen, javascript, webdev, html
Published: 2024-06-02 02:19:08

Hi ,
My Hour of Code with its design is easy and simple to organize an event like it.
1-Understand the importance and benefits of science
Computer in all aspects of life. 
2-Practice science concepts
Computer such as sequences, events, repetition, and debugging of code commands. 
3-Create software solutions
To successfully complete a task or solve a problem. 
4-Learn about professional fields
broad scope of computer science. 
5-Analyze and solve problems using
Algorithmic thinking and dividing the problem into parts.
**Follow all the latest news via:**
**github:** https://github.com/hussein-009
**codepen:** https://codepen.io/hussein009
**Contact me if you encounter a problem**
**instagram :** @h._.56n

{% codepen https://codepen.io/hussein009/pen/JjqWvZX %}
SIP Calculator
Tags: codepen, sipcalculator, vinkalprajapati, vinkal041
Published: 2024-06-02 01:53:11



{% codepen https://codepen.io/vinkalPrajapati/pen/RwmpyYZ %}

Plan your financial future with our easy-to-use SIP Calculator. Calculate the future value of your Systematic Investment Plan (SIP) investments by inputting your monthly investment amount, expected annual return rate, and investment duration. Our clean and intuitive interface ensures that you can quickly and accurately determine how much your investments will grow over time. Ideal for those looking to make informed decisions about their savings and investment strategies, our SIP Calculator is a must-have tool for achieving your financial goals. Start planning today and see how your regular investments can yield substantial returns over the years.
Using AWS Credits effectively as a startup.
Tags: aws
Published: 2024-06-02 01:30:17

**Introduction
**
As businesses and individuals increasingly turn to cloud computing, Amazon Web Services (AWS) has emerged as a leading provider in the industry. AWS offers a range of services, and one of the enticing perks it provides to new users is the opportunity to receive free credits. However, like any promotional offer, there are facts you need to consider before using them.

AWS credits encourage you to explore almost all the services on the platform, whiles this is a good thing it can increase your cloud spend. Consider the following scenarios when using free credits;

Research Purposes: I personally use aws credits for research purposes because I am able to play around with the services and learn more about them. I mostly do this when I want to prototype an idea or build a quick MVP.
Short term prove of concept: You can also rely on AWS credits when you want to prove that a certain concept works
I had a conversation with a few founders last month and they were complaining about how they had to move their entire infrastructure to a different service provider because they were out of AWS credits and realized that the services are expensive. The pitfall of using These credits is that you turn to spin services that you do not need. (Most startups don't need 50% of the services provided by AWS.) Most often, there are cheaper alternatives you can explore on cloud platforms but because you have “Enough” credit you really won't bother about the cost of these services.

What happens when the AWS credits expire or finish?

When you become over-reliant on AWS credits you forget to draw a budget for the services you use. In the end, you will have to pay for all the services you spin up whiles using the credit.

To avoid these pitfalls

Come up with the cost of each service you want to spin using AWS pricing calculator
Draw a budget using AWS cost management tool
Monitor your usage with AWS cost explorer
Conclusion:

While AWS free credits can be a valuable resource for new users and organisations exploring the benefits of cloud computing, it is crucial to dispel the myths surrounding them. Understanding the limitations, expiration dates, and usage restrictions associated with free credits is crucial to avoid unexpected charges and make the most of your AWS experience. By familiarising yourself with the terms and conditions, monitoring your usage, and planning accordingly, you can leverage AWS free credits effectively and take full advantage of the services they provide.
IOT Raspberry Pi using Azure
Tags: iot, raspberrypi, using, azurefunctions
Published: 2024-06-02 01:16:08

Creating an IOT Raspberry Pi using Azure 
Procedures"

1. create an IOT using the Azure portal 
-- go to Azure portal and log into your account using your username and password  
-- 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dvjbmf2uq485y4qtroo5.png)

2. after successfully logged-in search for the word "IOT hub" in the search bar on the Azure page 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgoihme8xd7yehytt1ea.png)

the image above should displayed  

3. click on add on the add button at the top left corner of the page to create a new IOT hub
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0mth5fl2j46w1m2189p.png)

4.this image should display 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2pdh644lewx1vxutmdm.png)
create a resouce group, a name and a region then click on review and create 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vc1fidf5ycy5vsr79yt.png)
then click on create give it some dew seconds for the deployment to be complete, once it is completed this image should be displayed on the screen 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j58kp0tgrl13qeuqguss.png)
then click on "go to resource" and click on device 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pd0vzqeeh0y2l4go6ipo.png) 
click on "add device" and choose a name then click save
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w78xp27g2lf9ev6ia91g.png)
click on the device bane you added
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hscz0zk275515vbry7r.png)
copy the link on the primary connection string and paste on the 15th link of a pre-installed Raspberry Pi Azure app after deleting the previous connection string on the Raspberry Pi app 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jreekwgc1cpqbdob3yl.png)

after pasting the copied link on the Raspberry Pi click on run the red led should blink repeatedly until you click on stop 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2c3hmul51oe89booyzy.png)
Beachcomber: A Legacy of Family Values and Global Excellence in Hot Tub Manufacturing
Published: 2024-06-01 23:52:21

Beachcomber is committed to strong family values across its entire organization, advocating for health and happiness for everyone. Much like Porsche©, Beachcomber aims to grow alongside its staff and customers, treating each one like family. The company's pride lies not only in its high-quality handcrafted hot tubs but also in the enduring family bonds and fellowship nurtured over the decades.
As a family-owned and operated multi-generational business, Beachcomber Hot Tubs is dedicated to supporting families for generations to come. This legacy is illustrated by the presence of three generations at the factory, with founder Keith, his son Blake, and grandson Frankie working together to continue the tradition of excellence.
Beachcomber Hot Tubs has built a global reputation for its zero-defects approach and rigorous quality control in hot tub manufacturing. From Norway to Argentina and Ireland to Japan, the company's dream has evolved into a trusted global brand, represented in over 40 countries worldwide.
The company maintains a full-time specialized workforce focused on producing high-quality hot tubs and providing dedicated customer care. Beachcomber's brand is available through an omni-channel marketplace, which includes an international network of factory-trained distributors and dealerships, factory outlets that test retail experience concepts, omni-channel merchants whose values align with the company's, and a user-friendly online presence that ensures seamless pricing across all platforms.

[](https://www.beachcomberhottubs.com/)
Procuro Devs Pleno e Senior
Published: 2024-06-01 23:41:28

Hey, galera! Procuro Devs Pleno e Senior que estão acabando projeto ou em busca de um novo desafio para assessorar como Headhunter nível Brasil (sou de SP o maior pólo no país em vagas de Tecnologia). 
Para saber mais sobre o meu trabalho, me chama no meu wapp 11 99369-0258. 
Bjs, Fe ❤️
The 8-Hour Debug: How a Silly Mistake Cost Me a Day
Tags: javascript, webdev, programming
Published: 2024-06-01 22:34:05

### The Function
```ts
function getEnrollmentByStudentIdAndCourseId(
  studentId: string,
  courseId: string
) {
  // fetch logic
  return result;
}
```

## The Mistake

Believe it or not this function caused me a day of debugging. Because of the way I was calling it like this.

```ts
const studentId = "ID";
const courseId = "ID";

const enrollment = getEnrollmentByStudentIdAndCourseId(courseId, studentId);
```

I was passing the arguments in the wrong order. The function signature was `getEnrollmentByStudentIdAndCourseId(studentId, courseId)` but I was calling it with `getEnrollmentByStudentIdAndCourseId(courseId, studentId)`.

The reason why i took so long debugging it was because function was **still returning a result even though the arguments were in the wrong order**, but it was the wrong result. I think this is ultimately a mistake i made by writing a bad prisma query that caused it.

### The Adjustment

make the argument passing more explicit by using object

```ts
type Args = {
  courseId: string;
  studentId: string;
};

function getEnrollmentByStudentIdAndCourseId({ courseId, studentId }: Args) {
  // fetch logic
  return result;
}
```

Ever since then, when I have a function that takes multiple arguments of the same type like IDs, I started to use object destructuring to make the argument passing more. And also like... made better prisma queries.

I hope this helps you avoid the same mistake I made. Happy coding!
The Start of E.V.O T
Tags: beginners, learning, programming, coding
Published: 2024-06-01 22:25:08

Hey everyone, hope all is well! I've officially started the journey now that I have all the necessary equipment to build the turret (might be missing a few things, but we'll go with the flow). I've begun creating the AutoCAD design for the base of the turret. This is just the prototype since it's my first time really freestyling this, so bear with me if it looks a bit weird.

I want to make a nice, sturdy base with some vents on the sides to let the components inside breathe. I want the turret to look like a railgun cannon, taking inspiration from the image below (Image 1) but with some tweaks. I have an idea for the base—here's a quick look at what I've got(image2). I want the Arduino to stay in this section of the turret, with the other bulkier equipment here. Once I have this part down, I'll start working on the actual movement of the turret.

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

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

I'm still deciding what kind of motor to use. If you have any suggestions, that would be awesome, and I'm always happy to hear your ideas and talk more about it.

This is the main update I have for you. I'll try to keep you updated every 3-4 days with good progress each time. Just wanted to let you know I haven't abandoned this project and will see it through to the end. Thank you all for the support and have a great one!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1d7xb4zm0dyhb26acn1.JPG)
Quick pic of my Guinea Pig Yoshi
HOW TO RECOVER YOUR CRYPTOCURRENCY FROM SUSPICIOUS INVESTMENTS AND ONLINE TRADING
Tags: general, beginners, bitcoin, tutorial
Published: 2024-06-01 20:45:56

my experience with Trust Geeks Hack Expert was transformative. They recovered my lost funds and provided invaluable support during a tumultuous period. Their professionalism, expertise, and dedication to helping victims of fraud are commendable. While I hope no one else endures what I did, knowing that services like Trust Geeks Hack Expert offer a beacon of light for those in similar predicaments like crypto theft or investment scams. Send a DM to Trust Geeks Hack Expert through the email: info@trustgeekshackexpert.com   $  TelegramID: Trustgeekshackexper
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j96bcbcltz6g6rh5qiyd.jpg)
Need Suggestion
Tags: javascript, webdev, beginners, career
Published: 2024-06-01 20:38:50

**visit my portfolio website at
https://abdullahs-portfolio.vercel.app/**

Hi so its not one of the reading article i needed suggestion.

so i was creating an project for my profolio that is like an simple blogging website using mern 

it already have 

- login signup  logout (jwt)
- create blog 
- view blog
- search blog
- display blog ( pagination) 
- profile view and edit

apart from theese suggest me what should i add more into website of **ML OR AI **
so that my project can be good for portfolio

_visit my portfolio website at
https://abdullahs-portfolio.vercel.app/_