teleren/devto huggingface dataset:
Use regular expressions to get url parameters in JS
Tags: javascript, url, parameters
Published: 2024-01-24 02:37:58

In JavaScript, you can use regular expressions to extract URL parameters. Here's an example function that takes a URL string as input and returns an object containing all the parameters and their values:

```
function getURLParams(url) {  
  const searchParams = new URLSearchParams(url);  
  const params = {};  
  searchParams.forEach((value, key) => {  
    params[key] = value;  
  });  
  return params;  
}
```

This function uses the URLSearchParams class to parse the query parameters in the URL and returns an object containing the parameter names and their corresponding values. If you prefer to use regular expressions to parse the URL parameters, you can use the following code:

```
function getURLParamsRegex(url) {  
  const regex = /[?&]([^=]+)=([^&]+)/g;  
  const params = {};  
  let match;  
  while ((match = regex.exec(url)) !== null) {  
    params[match[1]] = match[2];  
  }  
  return params;  
}
```

This function uses the regular expression /[?&]([^=]+)=([^&]+)/g to match the URL parameters and stores each parameter name and value in an object. It then returns this object.
(Part 1/2) FullStory Digital Analytics: Getting Insights into Customer's Experience of your Products
Published: 2024-01-24 02:22:09

This podcast episode explores digital analytics tools, with a focus on FullStory. The host provides an overview of digital analytics and its importance in understanding user behavior and improving online marketing strategies. The features and configuration of FullStory are discussed, including the ability to analyze user activity, track frustrated sessions and rage clicks, and use UTM campaigns for tracking. The episode also touches on the use of DataDog for digital analytics and highlights the various aspects that can be analyzed, such as session length, user behavior, and conversion rates. The episode concludes with the importance of using digital analytics to improve business performance.

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

## Takeaways
- Digital analytics tools help gather, analyze, and interpret data from digital sources to understand user behavior and improve online marketing strategies.
- FullStory is a digital analytics tool that provides detailed insights into customer behavior, allowing for optimization of webpages, marketing campaigns, and online initiatives.
- Features of FullStory include analyzing user activity, tracking frustrated sessions and rage clicks, and using UTM campaigns for tracking.
- Session length and active time are important metrics to consider for user engagement and scalability.
- Frustrated sessions and rage clicks can provide insights into user experience issues and areas for improvement.
- UTM campaigns and sources can be used to track and analyze the performance of digital marketing campaigns.
- DataDog is another tool that can be used for digital analytics and offers features for monitoring and observability.
- Digital analytics can be customized to analyze different aspects such as user behavior, page performance, and conversion rates.
- Using digital analytics can help businesses improve their online presence, understand user needs, and make data-driven decisions for growth and optimization.

## Chapters
00:00 Introduction and Context

01:27 Overview of Digital Analytics Tools

03:49 Exploring FullStory

07:14 Configuring FullStory

09:40 Analyzing User Activity in FullStory

13:13 Additional Features of FullStory

19:00 Importance of Session Length and Active Time

20:04 Optimizing User Experience and Scalability

21:45 Frustrated Sessions and Rage Clicks

22:33 Understanding Frustrated Sessions and Rage Clicks

23:37 UTM Campaigns and Sources

26:34 Using UTM Codes for Tracking

28:38 Customizing Analysis Parameters

29:42 Exploring DataDog for Digital Analytics

31:56 Analyzing Different Aspects of Digital Analytics

38:00 Using Digital Analytics to Improve Business

39:16 Conclusion

## Video
{% embed https://youtu.be/JsRzdWLgZZA %}

## Transcript
https://products.snowpal.com/api/v1/file/da13bc2d-93a6-46bd-8a5e-26ab09350a20.pdf
How would you reprocess Lambda dead-letter queue messages on demand?
Tags: aws, serverless
Published: 2024-02-21 09:30:04

---
title: How would you reprocess Lambda dead-letter queue messages on demand?
published: true
date: 2024-01-24 01:21:43 UTC
tags: AWS,Serverless
canonical_url: https://theburningmonk.com/2024/01/how-would-you-reprocess-lambda-dead-letter-queue-messages-on-demand/
---

Imagine this… 

You have followed AWS best practices and set up a dead-letter queue (DLQ) or an OnFailure destination for every async Lambda function.

(sidebar: you should prefer Lambda Destination over DLQs, [here’s why](https://youtu.be/hOetf6YN3zo))

A message arrives in your DLQ. You are alerted right away because you have alarms on all of your DLQs.

You investigate the problem and determine that it was temporary and the message should be re-processed.

But now what?

Do you extract the payload and invoke the original function manually? What if there are hundreds of similar messages? This manual approach doesn’t scale well.

Do you use SQS’s [StartMessageMoveTask](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_StartMessageMoveTask.html) API to redrive messages back to the source queue? But this API doesn’t support source queues that are **not** DLQs of other SQS queues. So you can’t use it with a Lambda function’s DLQ or OnFailure destination.

A good approach is to subscribe another function to the DLQ but leave the event source mapping disabled.

![](https://theburningmonk.com/wp-content/uploads/2024/01/img_65b065c19cf23.png)

This way, messages would not be automatically reprocessed – that wouldn’t make sense. Instead, it can be enabled on demand if and when you decide to reprocess them.

The `reprocess-function` can share the same business logic as the initial `processor-function`.

If the queue is an OnFailure destination, then the SQS messages would contain additional wrapping (see below). The `reprocess-function` would unwrap the message before reprocessing the original payload.

![](https://theburningmonk.com/wp-content/uploads/2024/01/img_65b065fa680a6.png)

I like this approach because it’s a simple setup and it’s a repeatable pattern.

For CDK users, you can even turn it into a L3 construct so it can be scaled to large event-driven architectures with many async functions.

What do you think of this approach? Do you have other approaches that you prefer over this?


The post [How would you reprocess Lambda dead-letter queue messages on demand?](https://theburningmonk.com/2024/01/how-would-you-reprocess-lambda-dead-letter-queue-messages-on-demand/) appeared first on [theburningmonk.com](https://theburningmonk.com).
Що необхідно для виробництва молочних та м'ясних продуктів?
Published: 2024-01-24 01:04:10

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

Виробництво молочних та м'ясних продуктів – це складний процес, який вимагає не лише високоякісної сировини, але й суворого дотримання технологій, стандартів якості та безпеки. Розглянемо ключові аспекти, які необхідно враховувати для успішного ведення такого виду бізнесу.

Перш за все, основою якісних молочних та м'ясних продуктів є сировина. Для молочної промисловості це свіже молоко від здорових корів, кіз або овець, яке повинно бути зібране з дотриманням усіх санітарних норм. У м'ясній промисловості ключовим фактором є якість м'яса, яке повинно бути отримане від здорових тварин, вирощених в хороших умовах та забитих з мінімальним стресом. 

Другим важливим елементом є дотримання технологій виробництва, що включає правильне зберігання, обробку сировини та використання сучасного обладнання для виробництва продуктів. Також необхідно слідкувати за чистотою виробничих ліній, щоб запобігти будь-якому ризику контамінації продуктів.

Третій аспект – це використання харчових добавок та інгредієнтів, які можуть покращити смак, аромат, текстуру продуктів, а також збільшити термін їх зберігання. Важливо вибирати високоякісні добавки, що відповідають усім стандартам безпеки та якості.

Четверте – це дотримання стандартів якості та безпеки продукції, що передбачає регулярні лабораторні дослідження продуктів на предмет відповідності нормам та вимогам. 

На завершення, хочу порекомендувати компанію Prodservis https://www.prodservis.com/, яка є надійним постачальником сертифікованих харчових добавок в Україні. Завдяки великому асортименту продукції, що охоплює понад 350 позицій, ви зможете знайти необхідні інгредієнти для виробництва молочних та м'ясних продуктів високої якості. Співпраця з Prodservis дозволить вам підвищити стандарти ваших продуктів, забезпечивши їхню безпеку та відмінні смакові якості.
L'abito è abbinato ad un bouquet da sposa oversize con fiori colorati
Published: 2024-01-24 00:59:41


Dato che l'estate è alle porte, abbiamo un piccolo articolo editoriale che ti farà venire voglia di un matrimonio sulla spiaggia in pochissimo tempo Spiagge sabbiose del mio bellissimo Messico.

​


L'immagine di Isabella Rodríguez Photography è meravigliosa e la cancelleria è l'epitome dell'arte abiti da sposa 2020 prezzi, ma l'inizio di questo stile è il look subacqueo di Brima. La modella/sposa indossa un bellissimo [abito da sposa](http://www.gillne.it) che è in parti uguali fashion e bohémien. L'abito è abbinato a un bouquet da sposa oversize con fiori colorati, verde ed erba di pampa per portare le vibrazioni boho a un nuovo livello di Be Beud Auty. Ma forse la mia parte preferita è la tiara così solare con un disegno di vite e floreale nei toni dell'oro e dell'argento.

Il copricapo era perfettamente completato da graziosi orecchini e da un velo dorato sulla coda che rendeva alcune delle immagini.

Siamo particolarmente ossessionati dal tramonto che mostra Isla Blanca, un bellissimo luogo tranquillo fuori Caancun.
Trova qui sotto una raccolta Curant delle nostre foto preferite di matrimonio sulla spiaggia, quindi salta nella galleria per nasconderti da questa calamita.
Concurrency in Rust: Understanding Ownership and Borrowing
Tags: rust, beginners, programming, tutorial
Published: 2024-01-24 00:31:49

## Introduction

Rust has gained popularity for its ability to handle concurrency in a safe and efficient manner. Unlike other programming languages, Rust uses a unique concept of ownership and borrowing to handle concurrency. In this article, we will delve deeper into understanding ownership and borrowing in Rust and how it contributes to its powerful concurrency support.

## Advantages of Ownership and Borrowing

In Rust, every value has an owner who is responsible for its memory management. This approach allows for greater control over the allocation and deallocation of memory, preventing common issues like memory leaks and dangling pointers. Additionally, the concept of borrowing allows for multiple threads to access and manipulate a value without causing data races, as only one thread can have mutable access to it at a time.

### Example of Ownership

```rust
fn main() {
    let v = vec![1, 2, 3]; // 'v' owns the vector
    // 'v' is dropped here, and the memory is deallocated safely
}
```

This code snippet demonstrates Rust's ownership model where the variable **v** owns the vector. When **v** goes out of scope, Rust automatically deallocates the memory, ensuring no memory leak occurs.

## Example of Borrowing

```rust
fn main() {
    let v = vec![1, 2, 3];
    let borrow = &v; // borrowing 'v'
    println!("{:?}", borrow);
    // 'v' and 'borrow' go out of scope here, no dangling pointer
}
```

Here, **borrow** is a reference to **v**, demonstrating Rust's borrowing mechanism. This allows **borrow** to access the value of **v** without taking ownership, ensuring safe memory access.

## Disadvantages of Ownership and Borrowing

While ownership and borrowing provide great benefits, they also come with a learning curve and strict rules that must be followed when coding. This can be challenging for beginners and may require extra effort to fully understand and implement.

## Notable Features

Apart from creating a safe and efficient environment for concurrency, ownership and borrowing in Rust also allow for improved error handling. With the help of the borrow checker, Rust detects and prevents potential errors at compile time, significantly reducing the possibility of bugs and crashes in production.

## Conclusion

In conclusion, the concept of ownership and borrowing in Rust offers unique and valuable benefits for handling concurrency. While there may be a slight learning curve and strict rules to follow, the rewards of safe and efficient code make it worth the effort. With its powerful features, Rust continues to be a popular choice for developers looking to write robust and high-performing concurrent programs.
How to implement Single Responsibility in React
Tags: react, reactnative, typescript, solidprinciples
Published: 2024-01-24 00:08:52

## Overview
The Single Responsibility Principle (SRP) is a key concept in software design that advocates for a component or module to have only one reason to change. In the context of React components, this principle becomes crucial for creating modular, maintainable, and scalable code.


## What is Single Responsibility?
In React, the Single Responsibility Principle suggests that a component should have a singular purpose or responsibility. This means that a component should be responsible for one specific aspect of the application's functionality. When a component adheres to the SRP, it becomes easier to understand, test, and maintain.


## Benefits of Single Responsibility in React Components
1. **Clarity and Readability**
    - Components with a single responsibility are easier to read and understand.
    - Each component's purpose is clear, leading to more maintainable code.
2. **Reusability**
    - Components with well-defined responsibilities can be reused in different parts of the application.
    - Encourages the creation of modular and portable code.
3. **Testability**
    - Unit testing becomes more straightforward when a component has a single responsibility.
    - Tests can focus on the specific functionality without interference from unrelated concerns.
4. **Scalability**
    - Components that follow SRP are more adaptable to changes in requirements.
    - Scalability is improved as new features can be added without affecting unrelated code.

## Example
Imagine that we have the following file: `userScreen.tsx`
![userScreen.tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oej3j20cwoxcyddvrs4w.png)


As we can see it takes care of too many things, so we are going to refactor it in the following files:

`src/types/userType.tsx`: here we will put the user type
![userTypes.ts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8x8wo6tkpx3qi7lipsj.png)

`src/services/fetchUser.tsx`: in this file we will put the service of fetch user
![fetchUser.tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4wxx5wzyqf48hszyh58.png)

`src/hooks/useFetchUser.tsx`: we will put here a custom hook to fetch the user and return the user state
![useFetchUser.tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucob6l1tqokg915t0ks1.png)

`src/components/errorFetching.tsx`: here we will create a component for render the error component
![errorFetching.tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2fsbn85hmpv1szu5dwat.png)


And finally the `userScreen.tsx` looks like:
![final userScreen.tsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi9z9wljs5e9zdk9d9pe.png)


## Conclusion
By adhering to the Single Responsibility Principle in React components, developers can create more modular, maintainable, and scalable applications. Each component focuses on a specific aspect of the application's functionality, leading to improved code quality and ease of development.
Selenium and it's usage for the python script
Published: 2024-01-24 00:04:27

! Selenium is a powerful tool commonly used for automating web browsers. In Python, the Selenium library provides a convenient interface for interacting with web pages, filling out forms, and navigating through websites.

With Selenium, you can write scripts that simulate user interactions with a web browser, allowing you to automate tasks like form submission, button clicks, and data extraction from web pages. It's widely used for web scraping, testing web applications, and automating repetitive tasks that involve web interactions.

By leveraging the WebDriver component of Selenium, you can control various web browsers like Chrome, Firefox, or Safari programmatically, making it a versatile tool for web automation in Python.



User
Can you explain it with an example 

ChatGPT
Certainly! Let's take a simple example where we use Selenium in Python to automate opening a website, entering text into a search bar, and clicking the search button.

First, you need to install the Selenium library if you haven't already. You can do this using:

bash
Copy code
pip install selenium
Now, here's a basic example script using Selenium:

python
Copy code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

# Set the path to your web driver executable (download from the respective browser's website)
driver_path = 'path/to/chromedriver'

# Create a new instance of the Chrome driver
driver = webdriver.Chrome(executable_path=driver_path)

# Open the website
driver.get('https://www.example.com')

# Find the search bar element by its name attribute
search_bar = driver.find_element('name', 'q')

# Type 'Selenium' into the search bar
search_bar.send_keys('Selenium')

# Press Enter to submit the search
search_bar.send_keys(Keys.RETURN)

# Wait for a few seconds to see the results (you might want to use WebDriverWait for better practices)
driver.implicitly_wait(5)

# Close the browser window
driver.quit()
In this example, we use the Chrome browser, so you would need to download the ChromeDriver executable and provide its path. Adjust the code according to the web browser you intend to use.

This script opens the example.com website, locates the search bar by its name attribute ('q'), enters 'Selenium' into the search bar, presses Enter, waits for a few seconds, and then closes the browser.

Remember to replace 'path/to/chromedriver' with the actual path to your ChromeDriver execut
distance between player and designer
Tags: gamedev, writing
Published: 2024-02-25 21:28:03

---
title: distance between player and designer
published: true
date: 2024-01-24 00:00:00 UTC
tags: [ 'gamedev', 'writing' ]
canonical_url: https://onwriting.games/daily/20240124-2039-distance-between-player-and-designer/
---

There is a problem that I haven't seen solved yet, and I don't even know if it's solvable:

There is a disconnect between what the player intends to do when choosing an option (horizon of intention) and what the designer has defined will happen when choosing the option (horizon of action).

This disconnect can be minor if there is a strong enough sense of construction and the designer **knows with certainty** what the player intends to do when choosing an option.

But it can also not be, and the player may have an intention that is opposed to what the designer thinks.

Many games use 'flags' to solve this:

```
SHOPKEEPER: Here's your bag sir.
 * Thanks for your service (sincere)
 * Thanks for your service (ironic)

```

In my opinion, these types of solutions are sub-par.

I don't think it's a good option to take the player out of immersion with these flags.

But at the same time, the risk of falling into a very large gap between intention and outcome is very high, and generally generates more rejection than a simple flag.

What do you think? Have you seen this problem solved in a different way?
Defining Ubiquitous language
Published: 2024-01-26 20:34:25

---
title: Defining Ubiquitous language
published: true
date: 2024-01-24 00:00:00 UTC
tags: 
canonical_url: https://www.oliverdavies.uk/archive/2024/01/24/defining-ubiquitous-language
---

A key takeaway from Rob Allen's Domain-Driven Design talk was defining ubiquitous language and avoiding the phrase "That's not what I meant".

Even a simple table or glossary that lists business and domain-specific terms and their agreed meaning is very helpful to ensure everyone in the discussion is on the same page and means the same thing.

Rob's example was using the words "policy" and "risk" when dealing with insurance clients.

A common issue I've seen is where people are referred to as customers by the business and users within the software.

Ideally, these should be consistent, and the code should match the business terminology.

This can be complicated further by different areas of the business, such as a marketing team that may refer to people as subscribers.

Without the ubiquitous language being defined, the requirements are more likely to be misunderstood and the wrong solution delivered, resulting in "that's not what I meant.".

This then means the work needs to be re-done and delayed, which can be expensive and time-consuming.

Another approach is to work in small batches, which is something I've written about before, and getting feedback from customers as early and often as possible so, if there is a misunderstanding, the minimum amount of time has been spent before it's realised and rectified.

Rob, of course, covered a lot more about DDD in his talk, and I'm looking forward to re-watching it once the video from the meetup is released.

 P.S. Need help or want another pair of eyes on your code? Book a [1-on-1 consulting call](https://www.oliverdavies.uk/call) or an [online pair programming session](https://www.oliverdavies.uk/pair) with a 100% money-back guarantee.
2024-01-19: Refocusing
Tags: devjournal
Published: 2024-01-23 05:21:28

I once again forgot to write a blog post on Friday. I guess it's become a habit by now...

Last week, we hit a big roadbump in funding. Because the app's launch had been delayed so significantly (almost a month late), some of the initial investors pulled their funding. So we're working overtime to get it pushed out as soon possible. The CEO thought it would be a good idea to stop wasting my LLM talents on putting out random fires leftover from the offshore team, and he wanted me to prioritize improving the chatbot functionality so that we can push to launch.

So this week has been dedicated to me creating a new overhaul for the system to have a decision tree sort of system for our activities. We want the bot to be able to take input from the user to choose from all the various activities that we have on the website. Like the other week when I added the "cognitive restructuring" exercise, we want the bot to automatically pick up on what the user is saying to start that activity and start that chain of prompting for that.

Likewise, one of the first extra exercises we want to add beyond that is some MP3-based breathing/meditation exercises. We delegated the setup of that to the offshore team, but I will be the one to make the bot actually direct itself to that.

We are also exploring options for RAG and long-term memory, which is definitely a very open-ended question in this field. I will be doing research to figure out the best thing to do.

I think all these features will help flesh out Comigo and make it into a real powerhouse of an app and be very helpful for our users in the future. We just need to keep rolling with the punches and never give up.

Until next time (hopefully on time this time), cheers.
Welcome Thread - v260
Tags: welcome
Published: 2024-01-24 00:00:00

---
published_at : 2024-01-24 00:00 +0000
---
![Fran Dresser in The Nanny saying hello](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v322nr994t4k26quz6sq.gif)

---

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

3. Elevate your writing skills on DEV using our [Best Practices](https://dev.to/devteam/best-practices-for-writing-on-dev-creating-a-series-2bgj) series!