teleren/devto huggingface dataset:
Outbox Pattern
Tags: backend, microservices, designpatterns, designsystem
Published: 2023-12-10 15:30:48

## The problem

I'm working on an OMS (Order Management System) that listens to a message queue for orders that are placed and then processes them. There are a few steps involved, as follows:

1. Get the order placement message from the message queue.
2. Process the order placement depending on business needs.
3. Save the state of the order to the database.
4. Publish a new message for the next step to the message queue.

![Steps to process an order placement](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vzakf5bwtxep0dlh3vt.png)

There is a problem since we need to save the state of the order and publish a message for the next step, and these two operations are not atomic, which means one can fail and the other will not be able to revert. We could run in a situation where the order's state is updated successfully in the database, but no message for the next step is published to the message queue due to an error or network timeout, causing the order to be stuck and not progress any further. This could make the data in our system to be inconsistent and unreliable.

![Publishing a new message could failed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztiqvxg6dhtzdnf6r18h.png)

We can try to have a condition here that if the publishing to the message queue fails, we can retry to deliver the message or revert the order back to its previous status. But what if the system crashed while trying to publish the message or that the retry/revert also failed, how can we revert the state from the database?

## The solution

The solution I came up with after some research is that we can use the outbox pattern!

We created a new table called `order_outbox` in the database, so every time we update the order state we also insert a new record into the `order_outbox` table in the same transaction making them atomic, and having a new message relay to read from the table. The message relay will then publish all unpublished messages it can get from the `order_outbox`.

![Adding a new table order_outbox](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bywvu3wqsaodctvg1ix.png)

## A caution

Using the Outbox Pattern will guarantee that our publisher/producer will be an at-least-once publisher. But it may cause duplicated message delivery. So make sure your consumer/subscriber is tolerant of duplicated messages by business requirements or by implementing the Idempotent Consumer pattern.

## References

This post is a note to myself, so if you find it interesting but hard to understand. You can follow these two links for references.

- [Microservices Pattern: Transactional outbox - microservices.io](https://microservices.io/patterns/data/transactional-outbox.html)
- [Outbox Pattern: Reliably Save State & Publish Events - codeopinion.com](https://codeopinion.com/outbox-pattern-reliably-save-state-publish-events/)
Cloud Code Signing: The Futuristic Code Signing Platform
Tags: cybersecurity, cloud, programming, developer
Published: 2023-12-13 08:02:23


![cloud-code-signing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wb7hyex4kzqdrhs2t8jt.jpg)
In the world of software development, code signing certificates are one of the pivotal security tools assisting developers to secure their software, apps, executables, drivers, etc from unauthorized tampering or alteration.

Furthermore, post-June 2023, physical tokens like Hardware Security Modules(HSMs) are mandatory for obtaining code signing certificates from CAs as per the CA/B Forum. To evade using HSM or physical tokens cloud code signing is the best available option.

Cloud code signing offers a platform for developers to digitally sign the code remotely using cryptographic keys managed by the service provider in a secured cloud-based environment. The cloud code signing technology helps developers to streamline the software signing procedure by eliminating the usage of physical hardware token devices for issuing and maintaining signing certificates.

Explore more about facts and insights of [Cloud Code Signing](https://signmycode.com/cloud-code-signing) for enhancing software security.
CAMduct warning: The material/tool combinations listed below do not have any required tool data values set up
Tags: camduct, adobe, autocad
Published: 2023-12-13 08:01:38

```
The material/tool combinations listed below do not have any required tool data values set up.

Default-Air Plasma: Ductwork: SUS304 x 1.000
Default-Air Plasma: Ductwork: SUS201 x 1.000
```

# TL;DR
File -> Setup -> Installed Machines -> Select the machine name -> Check

Deal with any problem that it warns.
Nodejs with NGINX
Tags: webdev, node, javascript, beginners
Published: 2023-12-13 08:00:00

Node.js and Nginx are commonly used together to create a scalable and efficient web application infrastructure. Node.js is a JavaScript runtime used for server-side programming, while Nginx is a powerful web server and reverse proxy that can also act as a load balancer, handling various tasks including serving static files, SSL termination, and routing requests to Node.js applications.

Here's a basic setup using Node.js with Nginx acting as a reverse proxy:

**Install Node.js:**

- You can download and install Node.js from the official website. Follow the installation instructions for your specific operating system.

**Write a Node.js application:**

- Develop your Node.js application. Here's a simple example using Express.js:

```
// File: app.js
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello, this is your Node.js app!');
});

app.listen(3000, () => {
  console.log('App listening on port 3000');
});
```

**Install and configure Nginx:**

- Install Nginx on your server. The configuration file for your Node.js app could look something like this:

```
# File: /etc/nginx/sites-available/your-app-name

upstream nodejs_app {
  server 127.0.0.1:3000; # Node.js app running on localhost:3000
  # Add more servers here if you're running multiple Node.js instances
}

server {
  listen 80;
  server_name yourdomain.com; # Your domain name or server IP

  location / {
    proxy_pass http://nodejs_app;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
}
```

**Enable the Nginx configuration:**

- Create a symbolic link to enable the site and restart Nginx.

```
sudo ln -s /etc/nginx/sites-available/your-app-name /etc/nginx/sites-enabled/
sudo systemctl restart nginx
```

**Run your Node.js application:**

- Start your Node.js application by running node app.js (or whatever your Node.js entry file is named). Ensure it's running on the port specified in the Nginx configuration (in this case, port 3000).

**Adjust firewall settings if needed:**

- Make sure your firewall settings allow traffic on the ports you're using (e.g., port 80 for HTTP).

This basic setup demonstrates how Nginx can act as a reverse proxy, forwarding incoming requests to your Node.js application. Adjust configurations according to your specific requirements, like SSL termination, load balancing multiple Node.js instances, or serving static files.
What is Endpoint Detection and Response? – The Ultimate Guide
Published: 2023-12-13 07:48:25

![What is Endpoint Detection and Response? – The Ultimate Guide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi6cm4fjdjfitkk6nhpd.png)

Endpoint Detection and Response (EDR) stands as a critical security solution, intricately designed to monitor and analyze real-time data on endpoint devices within a network. Endpoints encompass a range of devices, including laptops, smartphones, servers, and IoT devices. The relevance of EDR is underscored by the escalating landscape of cybersecurity threats, with figures like Federal Reserve chairman Jerome Powell highlighting the gravity of cyber risks.

In essence, EDR solutions play a pivotal role in detecting and responding to malicious activities occurring on network endpoints. The term "endpoint" encompasses any device engaged in communication within a network. EDR becomes imperative as cyber threats grow in complexity, addressing the identification and prevention of harmful behaviors, particularly recognizing the vulnerability of human users in the cybersecurity landscape.

The significance of EDR solutions lies in their capacity to automate security processes and furnish comprehensive analysis of endpoint traffic. This capability empowers security teams to focus on the identification and response to threats with efficiency. EDR solutions encapsulate five fundamental components:

1. **Activity Detection:** Discerning malicious activities through contextual analysis of behaviors.
2. **Activity Investigation:** Scrutinizing potential threats to ascertain whether end-users are acting against security systems.
3. **Automated Response:** Executing pre-programmed responses to specific behaviors to thwart malicious processes.
4. **Activity Alerts:** Notifying security teams of identified malicious behavior for subsequent investigation.
5. **Post-Threat Analysis:** Logging data from resolved threats for analysis and future threat detection.

It is imperative to differentiate EDR from antivirus and endpoint protection platform (EPP). While EDR concentrates on detecting malicious behaviors, antivirus specifically addresses viruses, and EPP strives to prevent malicious activities. The recommended approach involves a collaborative utilization of all three tools for comprehensive endpoint security.

In the selection of an EDR solution, precision assumes paramount importance, with false positives risking user dissatisfaction and attempts to circumvent security controls. Human input retains its critical role, as EDR systems are not infallible, and investing in the training of security teams enhances detection capabilities. It is crucial to view EDR as a supplement rather than a replacement for existing security infrastructure, emphasizing the requisite multi-layered approach for effective cybersecurity.
Game Programming Basics
Published: 2023-12-13 07:33:15


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4foij12qgdjrfgpt7r7j.jpg)Photo by <a href="https://unsplash.com/@ingvar_erik?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Igor Karimov 🇺🇦</a> on <a href="https://unsplash.com/photos/white-sony-ps-4-controller-59MGmlUiqwA?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>
  
**Game programming** involves the creation of the underlying logic and mechanics that power video games. This includes designing and implementing gameplay mechanics, creating artificial intelligence for non-player characters, optimizing graphics and animation, and integrating user interfaces. 

Game programmers use a variety of programming languages and tools, such as C++, Java, and Unity, to bring their ideas to life and provide players with engaging and immersive experiences. 

The field of game programming is constantly evolving as new technologies emerge, presenting exciting opportunities for innovation and creativity in the world of gaming.
Youtube adblocker does not work? Solve it with 6 lines of code (December 2023)
Published: 2023-12-13 07:28:10

I used to have a chrome extension Adblock to block YouTube video's but somwhere november 2023 it stopped working. YouTube noticed its activity and blocked the full experience whatsoever. 

So I tried to code it myself and it turned out to be just 6 lines of code that does the trick:

```
setInterval(async () => {
    if(!document.querySelector('.ad-showing')) return;
    document.querySelector('video').currentTime = 1000;
    await (async () => new Promise(r => setTimeout(r, 100)))();
    document.querySelector('.ytp-ad-skip-button-slot')?.click();
}, 300);
```

This is what it does
- checks if an ad is displayed
- skips advertisement to 1000 seconds
- waits 0,1 sec
- clicks skip button

Around this you will find the setInterval that executes the function every 0,3 sec

## Create a Chrome Extension

This is the ChatGPT prompt:

> Create a chrome extension that executes the following script on a youtube page. No pop up. No background script. Manifest version 3.
> setInterval(async () => {
    if(!document.querySelector('.ad-showing')) return;
    document.querySelector('video').currentTime = 1000;
    await (async () => new Promise(r => setTimeout(r, 100)))();"


Click this link to find [ChatGPT's instruction](https://chat.openai.com/share/4ccd22e1-9ef2-40a8-89ac-231ab3ad2239) how to create and install the Chrome Extension. It's really simple!
Unlocking the Power of ChatGPT: A Guide to Maximizing Conversational Potential
Tags: webdev, javascript, programming, beginners
Published: 2023-12-13 07:27:09

**Introduction:**

As OpenAI introduces the world to ChatGPT, a revolutionary language model, a new chapter in conversational artificial intelligence unfolds. This guide aims to empower users, developers, and businesses alike to harness the full potential of ChatGPT, offering insights and strategies to unlock its capabilities for dynamic and meaningful interactions.

**I. Understanding ChatGPT's Architecture:**

**A. GPT-3.5: Core Features and Enhancements**

- Exploring the architecture that powers ChatGPT.
- Key features that set it apart from previous iterations.

**B. Contextual Awareness and Dynamic Responses**

- Grasping how ChatGPT maintains context in conversations.
- Leveraging its adaptability for dynamic and engaging interactions.

**II. Strategies for Effective Interaction:**

**A. Contextual Prompts and Continuations**

- Crafting prompts that maximize context retention.
- Techniques for managing ongoing conversations seamlessly.

**B. Fine-Tuning Responses for Specific Use Cases**

- Tailoring ChatGPT's output to align with specific industry or user needs.
- Balancing customization with natural language generation.

**III. Practical Implementations Across Industries:**

**A. Customer Support and Engagement**

- Implementing ChatGPT for personalized and efficient customer interactions.
- Best practices for integrating ChatGPT into customer service platforms.

**B. Education and Training**

- Enhancing e-learning experiences through ChatGPT.
- Strategies for utilizing ChatGPT in personalized tutoring scenarios.

**IV. Overcoming Challenges and Ethical Considerations:**

**A. Mitigating Bias in Conversational AI**

- Identifying and addressing potential biases in language generation.
- Techniques for ensuring fairness and cultural sensitivity.

**B. Transparency and User Empowerment**

- Promoting transparency in AI interactions for user understanding.
- Providing users with controls to shape their interactions responsibly.

**V. Future Trends and Continuous Learning:**

**A. OpenAI's Commitment to Improvement**

- Staying informed about updates and enhancements from OpenAI.
- Embracing a mindset of continuous learning for optimal utilization.

**Conclusion:**

As users embark on the journey of unlocking the power of ChatGPT, this guide serves as a companion, offering strategies to navigate its capabilities effectively. By understanding its architecture, implementing practical use cases, and addressing ethical considerations, users can harness ChatGPT's potential to revolutionize the landscape of conversational AI.
Issues in mocking dispatching event in Jest
Tags: webdev, react, typescript, javascript
Published: 2023-12-13 07:26:44

We are currently in the process of developing a single-page package that involves the dynamic hiding and displaying of components based on specific conditions. To implement this functionality, we have employed the use of useReducer and useContext. Through the context, we dispatch events to the reducer.
As part of our testing strategy, we need to create a unit test case for a particular scenario. In this case, the requirement is to dispatch an event that loads the second component, and subsequently, we must verify the presence of a specific element.
However, we are encountering challenges in effectively mocking the dispatch event for this scenario.

Do we have a any solution for this?

**PageContext.tsx**:

export const PageContext = React.createContext<PageContextType>({} as PageContextType);

export const PageContextProvider = ({ children }: PageContextProviderProps) => {
  const [pages, pagesDispatch] = useReducer(pageReducer, pageState);

  return (
    <PageContext.Provider value={{ currentPage: pages, pagesDispatch: pagesDispatch }}>{children}</PageContext.Provider>
  );
};

**Reducerfile** :

export const pageState = {
  currentPage: <componentDefault />
};

export const pageReducer = (state, action) => {
  switch (action.type) {
    case "component1":
      return {
        ...state,
        currentPage: <component1 {...action.payload} />
      };
    case "component2":
      return {
        ...state,
        currentPage: <component2 {...action.payload} />
      }
    case "componentDefault":
      return {
        ...state,
        currentPage: <componentDefault />
      };
    default:
      return state;
  }
};


**Dispatchevent**:

const pageContext = React.useContext(PageContext);

pageContext?.pagesDispatch &&
          pageContext.pagesDispatch({
            type: "{component2}",
            payload: { text, text2 }
          });
		  
**Testingfile**:

const mockDispatch = jest.fn();

jest.mock("../../context/PageContext", () => ({
  ...jest.requireActual("../../context/PageContext"),
  PageContext: {
    Consumer: ({ children }) => children({ pagesDispatch: mockDispatch })
  }
}));

describe("testcomponent2", () => {
  test("should dispatch component2 when onClickContinue is called", () => {
    //const addItem = jest.fn();
    render(
      <PageContextProvider>
        <component2 />
      </PageContextProvider>
    );
    fireEvent.click(screen.getByText("Continue"));
    expect(mockDispatch).toHaveBeenCalledTimes(1);
  });
 });
ChatGPT: Bridging the Gap Between Human Communication and Artificial Intelligence
Tags: javascript, webdev, programming, beginners
Published: 2023-12-13 07:24:05

**Introduction:**

In the realm of artificial intelligence, ChatGPT emerges as a transformative force, seamlessly weaving the threads of human communication and machine intelligence. This exploration delves into how ChatGPT serves as a bridge, narrowing the gap between human expression and the capabilities of artificial intelligence, forging a path toward more natural and meaningful interactions.

**I. Human-Like Conversations:**

**A. Contextual Understanding**

- Unpacking ChatGPT's ability to grasp and retain context in conversations.
- Real-world scenarios showcasing the model's contextual acumen.

**B. Dynamic Interaction**

- Moving beyond scripted responses to dynamic, evolving conversations.
- The role of adaptability in mirroring human-like communication.

**II. Empathy and Emotional Intelligence:**

**A. Generating Emotionally Nuanced Responses**

- Examining how ChatGPT responds to and generates emotionally charged language.
- Applications in providing empathetic interactions and support.

**B. Cultural Sensitivity**

- Navigating diverse linguistic and cultural nuances in conversations.
- Mitigating biases and ensuring culturally aware interactions.

**III. Multimodal Communication:**

**A. Beyond Text: Incorporating Images and Context**

- Integration of visual elements into conversational AI for a richer experience.
- Enhancing communication through a multimodal approach.

**B. Voice Interaction**

- Exploring ChatGPT's potential in understanding and responding to spoken language.
- Advancements and challenges in voice-based interactions.

**IV. Practical Applications:**

**A. Enhancing Customer Support**

- ChatGPT's role in delivering more personalized and efficient customer interactions.
- Success stories in the integration of ChatGPT in customer service platforms.

**B. Collaborative Creativity**

- Engaging ChatGPT as a creative collaborator in content generation and ideation.
- The intersection of human creativity and AI assistance.

**V. Ethical Dimensions:**

**A. Transparency and Explainability**

- OpenAI's commitment to transparency in the functioning of ChatGPT.
- Addressing the challenge of explaining complex AI decisions.

**B. User Empowerment and Control**

- Providing users with tools to shape and control their interactions with ChatGPT.
- Balancing customization and responsible AI usage.

**Conclusion:**

ChatGPT stands as a remarkable innovation, not merely as a language model but as a bridge connecting the nuanced world of human communication with the vast capabilities of artificial intelligence. As this bridge continues to evolve, the ethical considerations surrounding transparency, empathy, and user control become crucial in fostering a harmonious and empowering integration of ChatGPT into our daily interactions.
How to Get the List of SAP BusinessObjects Schedules using Query Builder
Tags: python, sap, sapbo, querybuilder
Published: 2023-12-13 07:22:10

## Introduction
To retrieve a list of SAP Business Objects schedules using Query Builder, you can execute a query against the repository database where the scheduling information is stored. The repository database typically contains tables with information about schedules, jobs, and other related objects. Here are the general steps:

## **Access and Log in to Query Builder:**

To access Query Builder directly, log in to Query Builder using your SAP Business Objects credentials by entering the following URL in your web browser: 

```
http://localhost:port/AdminTools/querybuilder/ie.jsp
```

After replacing `localhost:host` you will see the login page:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijz91082jrurr5emfnx0.png)


## **Build Query:**

```sql
SELECT 
    SI_ID, 
    SI_NAME, 
    SI_SCHEDULEINFO.SI_SCHEDULE_TYPE, 
    SI_SCHEDULEINFO.SI_SCHEDULE_INTERVAL_NDAYS, 
    SI_SCHEDULEINFO.SI_SCHEDULE_INTERVAL_NTHDAY, 
    SI_SCHEDULEINFO.SI_SCHEDULE_INTERVAL_MONTHS 
FROM 
    CI_INFOOBJECTS 
WHERE 
    SI_SCHEDULE_STATUS != 8 AND SI_RECURRING = 1
```

the script retrieves specific columns (**`SI_ID`**, **`SI_NAME`**, and scheduling-related information) from the **`CI_INFOOBJECTS`** table for objects that meet the specified conditions. The conditions filter out objects with a schedule status of 8 and include only recurring objects.

## **Execute Query:**

Copy and Paste the SQL Script, Then Submit the Query

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

## **Review Results:**

After the query execution is complete, the results will be displayed in the Query Builder interface.


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

---

## Explore more

{% embed https://dev.to/luca1iu %}


Thank you for taking the time to explore data-related insights with me. I appreciate your engagement.

{% cta https://www.linkedin.com/in/lucaliu-data %} 🚀 Connect with me on LinkedIn {% endcta %}

{% cta https://twitter.com/Luca_DataTeam %} 🎃 Connect with me on X {% endcta %}


{% cta https://www.instagram.com/luca1iu?igsh=MmJneDFpdjNtYWU1&utm_source=qr %} 🌍 Connect with me on Instagram {% endcta %}