teleren/devto huggingface dataset:
8 Design Patterns EVERY Developer Should Know
Published: 2023-04-21 20:19:12

---
title: 8 Design Patterns EVERY Developer Should Know
published: true
date: 2023-04-13 19:33:36 UTC
tags: 
canonical_url: https://harshmange.hashnode.dev/8-design-patterns-every-developer-should-know
---

Design patterns are proven solutions to common problems that software developers face in their work. There are many design patterns available, but here are the 8 design patterns that every developer should know:

1. 
### [Singleton Pattern](https://dev.to/harshmange/what-is-singleton-design-pattern-5fea-temp-slug-9674797)

Ensures that only one instance of a class is created, and provides a global point of access to it.

2. 
### [Factory Pattern](https://dev.to/harshmange/what-is-factory-design-pattern-1719-temp-slug-2694894)

Provides a way to create objects without exposing the creation logic to the client and refers to the newly created object through a common interface.

3. 
### [Adapter Pattern](https://dev.to/harshmange/what-is-the-adapter-design-pattern-3cjl-temp-slug-1892854)

Allows incompatible interfaces to work together, by converting the interface of one class into another interface that the client expects.

4. 
### [Observer Pattern](https://dev.to/harshmange/what-is-the-observer-design-pattern-2llb-temp-slug-9226591)

Defines a one-to-many dependency between objects, so that when one object changes state, all its dependents are notified and updated automatically.

5. 
### [Decorator Pattern](https://dev.to/harshmange/what-is-the-decorator-design-pattern-f9b-temp-slug-694256)

Dynamically adds or alters the behaviour of an object at run time, without affecting the behaviour of other objects in the same class.

6. 
### [Strategy Pattern](https://dev.to/harshmange/what-is-strategy-design-pattern-57eb-temp-slug-9034282)

Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

7. 
### [Command Pattern](https://dev.to/harshmange/what-is-the-command-design-pattern-40i8-temp-slug-7135030)

Encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

8. 
### [Facade Pattern](https://dev.to/harshmange/what-is-the-facade-design-pattern-ll4-temp-slug-8903752)

Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

These patterns are widely used in software development, and mastering them can make you a better developer. Understanding these patterns will not only help you to write better code but also to communicate more effectively with other developers who use these patterns.
Next.js hot-reload losing styled-components styles
Tags: nextjs, styledcomponent, react, programming
Published: 2023-04-13 19:21:10

It's been a while since I developed using React/Next.js for the last time, and I decided to start a side-project using Next.js 13 this week.

Back in time, I was used to using styled-components that in my opinion allows me to keep the styles separated from the component files (not inside the TSX) and also avoids the not desired CSS style override, which is common when you have a lot of CSS files spread all over your project.

After defining the base layout of my application and starting my app with `next dev` everything looked as usual. Although, after my first change, all my styles had gone when the application got hot-reloaded. I got confused, but I did remember to have heard something about some style changes in Next.js due to ServerSideRendering feature so I started googling. In my first search, I found a [official link](https://beta.nextjs.org/docs/styling/css-in-js#styled-components) that explained how to fix that. Let's go to the solution:

Create the file `lib/registry.tsx` with the following content:
```typescript
'use client';

import React, { useState } from 'react';
import { useServerInsertedHTML } from 'next/navigation';
import { ServerStyleSheet, StyleSheetManager } from 'styled-components';

export default function StyledComponentsRegistry({
  children,
}: {
  children: React.ReactNode;
}) {
  // Only create stylesheet once with lazy initial state
  // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
  const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet());

  useServerInsertedHTML(() => {
    const styles = styledComponentsStyleSheet.getStyleElement();
    styledComponentsStyleSheet.instance.clearTag();
    return <>{styles}</>;
  });

  if (typeof window !== 'undefined') return <>{children}</>;

  return (
    <StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
      {children}
    </StyleSheetManager>
  );
}
```

After that, open your `pages/_app.tsx` file and make the following changes:
1. Import the registry you've just created.
```typescript
import StyledComponentsRegistry from '../lib/registry';
```

2. Wrap up the `<Component {...pageProps} />` like below:
```typescript
<StyledComponentsRegistry>
  <Component {...pageProps} />
</StyledComponentsRegistry>
```

Finally, just stop your application and run `next dev` again.

### Conclusion

Since I'm working in a side project that I know isn't going to use SSR I think that solution might be enough for me. Although, if you're working in a production application that uses a lot of SSR, please be careful.
Rapyd Launches Bug Bounty Program: Earn Rewards for Finding Security Vulnerabilities
Tags: bugbounty, hackforgood, hackathon, hacktoearn
Published: 2023-04-13 19:20:20

*“If the wall is breached, Helm's Deep will fall”*- Sauruman, LOTR: The Two Towers, 2002. In the movie The Lord of the Rings: The Two Towers by: Peter Jackson, even the greatest fortified stronghold is breached by the evil orcs exposing a weak point in the sewer drain of the wall. It is hard to believe anything so strong could be vulnerable to attacks, but we often see breaches of known companies in the news: Twitter, Facebook/Meta, Linkedin, LastPass, Crypto.com, Coinbase, the list goes on.

Nir Rothenberg, CISO at Rapyd says *“Security is an endless practice…It’s changing, it’s shifting, there's always new attacks…someone is getting hacked right now. It’s better if it’s not you…if you focus on a few simple things, the attackers are going to focus on somebody else.”*

Rapyd has been a leader in API security and IT maintenance. As a fintech as a service, Rapyd provides one API integration to accept, hold, and disburse funds in various currencies. The Rapyd API has multiple layers of protection against interception and tampering. Previously, Rapyd has worked with developers to test API security privately for a set time with Hacker0ne and Bugcrowd. Now Rapyd is looking to empower developers directly to openly test the Rapyd API and platforms, and directly report any vulnerabilities.

On April 12, 2023, Rapyd is opening up its bounty to pressure test the API, its security and systems. You can sign up in the Client Portal, grab your API keys to begin any integration, and start hacking. Different testing tiers of importance are explained further on the [project page](https://bugcrowd.com/rapyd-og) on Bugcrowd. The tiers developers are testing are separated between the Rapyd API, Rapyd Hosted Solutions, Rapyd platforms and portals. This includes Rapyd Checkout, Rapyd Verify Hosted Page, and the Client Portal Dashboard.

For each API call, Rapyd uses a signature calculation, or combination of a chain of strings. This signature process helps secure requests by verifying authorized users, protecting data in transition, and rejecting unauthorized persons.

Begin testing the API, where you can find all endpoints at [docs.rapyd.net/reference](https://docs.rapyd.net/build-with-rapyd/reference/api-reference)

* `https://sandboxapi.rapyd.net/v1`
* `https://api.rapyd.net/v1`

Hosted Pages can be found at the following API calls:

* https://docs.rapyd.net/build-with-rapyd/reference/subscription-hosted-page
* https://docs.rapyd.net/build-with-rapyd/reference/checkout-page
* https://docs.rapyd.net/build-with-rapyd/docs/hosted-checkout-page-integration-steps

Rapyd is on mission to liberate global commerce with all the tools you need for payments, payouts and business everywhere. To learn more about rewards and guidelines, go to [https://bugcrowd.com/rapyd-og](https://bugcrowd.com/rapyd-og).
Why On-Chain is the New On-Line
Tags: web3, blockchain, fullyonchaingaming, onchain
Published: 2023-04-13 19:03:03

The Internet has come a long way since the days of dial-up connections and static HTML websites. Today, we live in a world where we’re constantly connected, and online experiences have become an integral part of our daily lives. But as the world becomes increasingly digital, the concept of being “on-line” is evolving. The new standard for digital experiences is “on-chain”.

On-chain refers to data that is stored on a blockchain, a decentralized and distributed digital ledger that records transactions across a network of computers. The benefits of on-chain technology are numerous, from increased transparency and security to improved efficiency and cost-effectiveness. But perhaps the most exciting potential of on-chain technology is its ability to transform the way we interact with digital content.

With the rise of non-fungible tokens (NFTs), we’re seeing the beginning of a new era of digital ownership. NFTs are unique digital assets that are stored on a blockchain, and they have the potential to transform the way we think about digital ownership. By creating a new standard for digital assets, NFTs are enabling creators to monetize their work in ways that were previously impossible. And as the technology continues to evolve, we’re likely to see even more exciting applications of on-chain technology.

One of the most exciting areas for on-chain technology is gaming. Fully on-chain games offer a level of transparency and security that traditional games can’t match. By storing game assets on a blockchain, players have true ownership over their digital assets. This opens up new possibilities for in-game economies and trading, and can create new revenue streams for game developers. In addition, on-chain gaming can create a level playing field for players, with no possibility of cheating or unfair advantage.

But it’s not just gaming that’s being transformed by on-chain technology. From finance to supply chain management, on-chain technology has the potential to revolutionize virtually every industry. By providing a more secure, transparent, and efficient way to store and transfer data, on-chain technology can help to reduce fraud, increase trust, and streamline operations. And as the technology continues to mature, we’re likely to see even more innovative applications emerge.

In conclusion, on-chain is the new on-line. As blockchain technology continues to evolve, we’re seeing a new era of digital ownership and transparency. From gaming to finance, on-chain technology has the potential to revolutionize virtually every industry, creating new opportunities for innovation and growth. So if you’re not already exploring the potential of on-chain technology, now is the time to start. The future is on-chain.
Opinion: Is it necessary or feasible to put a six-month moratorium on AI development?
Tags: ai, elon, webdev, discuss
Published: 2023-04-13 18:44:35

Elon Musk, the CEO of Tesla, SpaceX and Twitter, signed an [open letter](https://futureoflife.org/open-letter/pause-giant-ai-experiments/) calling for a six-month pause on AI systems more powerful than GPT-4. 

Personally, I think that a moratorium could slow down progress in AI development, hindering the potential benefits the technology could bring, such as increased efficiency, productivity, and innovation. Additionally, it would be difficult to enforce and could result in a loss of competitiveness for countries that continue to invest in AI development.

Would it be a beneficial pause for reflection, or a hindrance to progress? What alternatives could be implemented to ensure that AI development proceeds in a responsible and ethical manner?

I'd love to hear your thoughts on this, so please leave them in the comments!
Why you shouldn't create chatgpt based products
Tags: chatgpt, ai, discuss
Published: 2023-04-13 18:14:01

My Thoughts on ChatGPT-Based Products

While ChatGPT is undoubtedly a trending technology, it poses a challenge for creating sustainable products that rely on its API as the backbone.

The issue stems from the fact that it's difficult to rely on APIs provided by big tech companies. Take Twitter, for example. Many developers had built successful products on top of Twitter's API or leveraged it to generate substantial revenue. However, overnight, Twitter made the decision to charge $42,000 per month for its previously free API, resulting in the disappearance of many of those products.

As members of the tech community, we must acknowledge the risks of building products on top of third-party APIs. While they may provide a convenient solution in the short term, there's always the possibility that the provider will alter their pricing or policies, potentially putting our products at risk. 

Looking forward to hear more from community.
VMClarity: Virtual Machine Security
Tags: sbom, opensource, appsec
Published: 2023-04-13 17:06:26


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

## Project VMClarity 

Do you have virtual machines in your environment? Do you care about their security? Are you looking for a new open-source project to contribute to? Well then, today is your lucky day! 
 
Introducing [VMClarity](https://github.com/openclarity/vmclarity)!  
 
## Overview 

VMClarity is an open source tool for agentless detection and management of Virtual Machine (VM) Software Bill Of Materials (SBOM) and security threats such as vulnerabilities, exploits, malware, rootkits, misconfigurations, and leaked secrets. 
 
VMClarity uses pluggable scanning infrastructure to provide the following: 

-     Software Bill of Materials analysis 
-     Package & OS vulnerability detection 
-     Exploit detection 
-     Leaked secret detection 
-     Malware detection 
-     Misconfiguration detection 
-     Rootkit detection 
 
Check out this quick video walk-through of what VMClarity is about: 

{% embed https://youtu.be/0v0v7Oxjwzc %}

---

## Getting Started 
 
Now that you have a basic understanding of what the VMClarity project is about let's check out how you can quickly get started with it: 

{% embed https://youtu.be/o2_lwHvB-3w %} 
 
Follow along with the video and get started today by visiting the project repo: 

https://github.com/openclarity/vmclarity 

Stay tuned for more information on VMClarity. We will have demos, feature walk-throughs, and detailed architecture posts in the future. 

---

## Learn More & Join the Community!

You can also learn more about the other Clarity projects, such as APIClarity (API security) and KubeClarity (K8s SBOM/Supply chain security) here:

- https://github.com/openclarity/apiclarity

- https://github.com/openclarity/kubeclarity

And several blogs about both projects are here:
https://techblog.cisco.com/

---------------------------------- 

Shannon McFarland is a Distinguished Engineer and open source advocate in Cisco’s Emerging Technology & Incubation organization. You can follow him on Twitter @eyepv6.
Hackers Hate Him! Learn This One Weird Trick to Secure Your Online Accounts
Published: 2023-04-13 17:49:25


Are you tired of worrying about hackers stealing your personal information and identity? Do you want to protect yourself from cyber attacks, but don’t know where to start? Well, you’re in luck, because we’ve got the ultimate cybersecurity hack that will keep those pesky hackers at bay. Read on to learn more!

**_Step 1: Use a Strong Password_**

This might seem like a no-brainer, but you’d be surprised how many people still use weak passwords like “123456” or “password”. Your password should be at least 12 characters long and include a mix of uppercase and lowercase letters, numbers, and special characters.

**_Step 2: Enable Two-Factor Authentication_**

Two-factor authentication is an extra layer of security that requires you to enter a code in addition to your password when logging into an account. This helps prevent unauthorized access even if someone knows your password.

**_Step 3: Keep Your Software Updated_**

Software updates often contain security patches that fix vulnerabilities that hackers could exploit. By keeping your software up to date, you’re minimizing the chances of a successful attack.

**_Step 4: Use a VPN_**

AVPN, or virtual private network, encrypts your internet traffic and hides your IP address, making it more difficult for hackers to intercept your data. This is especially important if you frequently use public Wi-Fi networks, which are often insecure.

**_Step 5: Don’t Click on Suspicious Links_**

Hackers often use phishing emails and fake websites to trick people into giving up their personal information. Be wary of emails or links that seem too good to be true, and always double-check the URL before entering any sensitive information.

**_Conclusion;_**

Byfollowing these simple steps, you can significantly reduce your risk of falling victim to cyber attacks. Don’t wait until it’s too late — start securing your online accounts today!
C++ University Project
Tags: beginners, showdev
Published: 2023-04-13 17:47:46

Hello everyone! 

We are a team of students from the University of Glasgow and as part of our Real-time Embedded Programming course, we would love to share our C++ GitHub project with you!

If any of you have a moment, we would greatly appreciate if you could stop by and check out our project!

https://github.com/patrickbrawley/gymBuddi

Thank you all!
Delete an element in array
Tags: arraymanipulation, webdev, dsa, javascript
Published: 2023-04-13 17:44:20

**Theory :**
Consider a Array declared as
`let arr=[1,2,3,4,5]`

Suppose we want to delete the element at index 2, that means we have to replace the element at index 3 to position at index 2 and same for all other elements .

Suppose we want to delete the element at index n. We will do this by replacing the element at index n+1 to n, replacing the element at index n+2 to n+1, similarly for all other elements. And once the element is deleted and all other elements are at new place, then we will decrease the length the of array by 1

```
let data  =[30,20,45,76,20,80];
      //    let position =3;
      //    for(let i=position; i<data.length-1;i++){
      //     data[i]=data[i+1];
      //    }
      //    data.length= data.length-1;
```
Take It Slow & Say Hello: A Sloth’s Guide to Making Friends Online
Tags: community, meta, codenewbie
Published: 2023-04-13 17:14:27

Introducing yourself to a new online community is exciting, but it can also be intimidating. Here are some ideas for intros that will help you connect with other members of the DEV and CodeNewbie communities:

1. **Share your background and interests.** This can help others get to know you and find common ground for conversation.
2. **Talk about why you joined the community and what you hope to gain from being a part of it.** This can help you find others who have similar goals or interests.
3. **Ask for advice or recommendations.** This can help you build relationships and learn more about the community.
4. **Share a fun fact about yourself.** It’s a great ice-breaker and conversation starter.
5. **Talk about your favorite hobby or activity.** This can help you find common ground and build relationships.
6. **Say Hi! to others in the thread.** If you see somebody introducing themselves, consider dropping a like or a response to show them some appreciation. Enthusiasm is contagious!

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

7. **Participate in discussions and leave comments.** This can help you start on a positive note and build enthusiasm for future interactions. Check out these recent posts and get involved:

{% link https://dev.to/codenewbieteam/what-are-some-hobbies-that-are-beneficial-to-coders-and-developers-15n5 %}

{% link https://dev.to/devteam/devdiscuss-the-future-of-ai-45f2 %}

{% link https://dev.to/codenewbieteam/which-programming-language-did-you-start-with-and-why-did-you-choose-it-5c28 %}



**And don’t forget to follow our [CodeNewbie](https://dev.to/codenewbieteam) and [DEVteam](https://dev.to/devteam) Orgs** for more convos and content like this.
36 berufliches Vorwärtskommen: Der eigentliche Weg – unausreichende emotionale Intelligenz.
Tags: deutsch, career, motivation, 1min
Published: 2023-04-13 17:12:56

Moin Moin,

machen wir uns wieder nichts vor. Ein weiterer wichtiger Grund für Misserfolg kann unausreichende [emotionale Intelligenz→](https://dev.to/amustafa16421/10-berufliches-vorwartskommen-die-wohl-wichtigste-charakter-eigenschaft-4n4i) sein – also soziale **In**kompetenz. Auch die beste fachliche Bildung allein macht einen nicht zu einem guten Kollegen – zumindest nicht von der menschlichen Seite.

Für großen Erfolg, an denen Menschen direkt oder indirekt beteiligt sind, wird man wohl ein gewisses Maß an emotionaler Intelligenz benötigen. Unter anderem also folgende Fähigkeiten und Eigenschaften:
- Selbstwahrnehmung
- Moralkompass
- Gefühlsverwaltung
- Empathie ( Mitgefühl / Einfühlungsvermögen )
- Beziehungspflege

Wie haben diese Fähigkeiten und Eigenschaften dein Leben beeinflusst?
( Erlebnisse, ein Mangel an, … )
Hast du einfache Tipps für eine gute Beziehungspflege?
Wie verbesserst du dein Einfühlungsvermögen?

Siehe auch: „[10 berufliches Vorwärtskommen: Die wohl wichtigste Charakter-Eigenschaft…→](https://dev.to/amustafa16421/10-berufliches-vorwartskommen-die-wohl-wichtigste-charakter-eigenschaft-4n4i)

Beste Grüße,
Mustafa
Austausch mittels E-Mail: [mustafa.kevin.dwenger@posteo.de↗](mailto:mustafa.kevin.dwenger@posteo.de)
GetBlock Launches Affiliate Program: How to Benefit from It
Tags: affiliate, web3, referral, devops
Published: 2023-04-13 16:56:57

GetBlock has recently introduced an affiliate marketing program that enables crypto enthusiasts to monetize their social media presence by referring top-tier RPC node providers to the next generation of developers. This is an opportunity for everyone to earn rewards by promoting our services to their audience.

GetBlock is now offering an affiliate program with no limit on payouts. Starting in mid-April 2023, both new and existing users can easily become GetBlock Affiliates by following a few simple steps.

With the affiliate program, anyone who shares their unique referral link can earn up to 20% of fees paid by their referrals. The minimum payout threshold is set at $50, and once the referral balance reaches this amount, affiliates can immediately withdraw their earnings.


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


To become a GetBlock referral, users must first log into their account and navigate to the 'Account settings' menu.

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

From there, they can select the '**‘Affiliate program’ tab **and click the 'Become an Affiliate' button after accepting the Terms and Conditions. Upon doing so, the user will receive an affiliate link to track the performance and payout status of their referrals.

The affiliate partner can view the status and payments of their referrals online in their account. This allows partners to monitor their program performance and easily request payouts with just one click.

Create your account and start earning: https://account.getblock.io/ .