teleren/devto huggingface dataset:
KART DISCOUNT
Published: 2023-09-01 18:34:11

**[KartDiscount](https://apps.shopify.com/discount-coupon-field-in-cart-page?search_id=f34d6045-e9b3-4cfc-8941-08bd57b7b5ae&surface_detail=kart+discount&surface_inter_position=1&surface_intra_position=4&surface_type=search&utm_source=DEVCOMMUNITY&utm_medium=POST)** lets your customer apply discount codes early during the checkout process which helps the store in increasing conversions and reducing cart abandonment. You can instantly set up this discount field with the help of automatic set up inside the app on any theme. This app also provides features like stack discount, automatic discounts, discount finder, estimated shipping calculator, free shipping bar and much more. To know more about each feature please watch the featured video.
The 2023 Developer Relations compensation & culture report
Tags: devrel, devex, career, resources
Published: 2023-09-01 18:33:31

🥑 It's ripe! I'm back as promised with results from our 2023 Developer Relations compensation & culture survey.

**Now presenting: [The 2023 Developer Relations compensation & culture report](https://www.commonroom.io/resources/2023-developer-relations-compensation-and-culture-report/)!**

This year's report is produced with thanks to inimitable collaboration from industry leaders around the globe and builders like you and your peers in communities like this one. 

It highlights the lived experiences of 136 Developer Relations professionals and it offers data focused on compensation, roles and responsibilities, expectations, and personal wellbeing in the industry in an effort to present a more holistic view of a career in DevRel. With it, we hope to empower more informed conversations for everyone in the community.

**5 highlights from the report:**

1️⃣ Across all industries and geographies, the median total gross compensation, pre-tax, for Developer Relations professionals is equivalent to $175,000 USD.
2️⃣ Developer Relations professionals most commonly report into marketing or Developer Relations/community departments.
3️⃣ According to 61.5% of respondents, the primary responsibility for Developer Relations professionals is creating educational content and resources.
4️⃣ A notable majority of DevRel professionals, 58.6%, are tasked with delivering on a primary business objective: product awareness.
5️⃣ When asked what would improve their physical, mental, or emotional wellbeing the most, 53.8% of respondents seek access to data that allows them to show the impact of their role on business objectives.

**There are many ways to consume its contents. I invite you to try them all:**

- Read the [blog post](https://www.commonroom.io/blog/2023-developer-relations-compensation-and-culture-report-overview/)
- Download the [full report](https://www.commonroom.io/resources/2023-developer-relations-compensation-and-culture-report/) for free
- Share the synopsis on [LinkedIn](https://www.linkedin.com/posts/common-room-hq_read-the-2023-developer-relations-compensation-activity-7103043130618220545-tz-y?utm_source=share&utm_medium=member_desktop)
- Or on [Twxtter](https://twitter.com/CommonRoomHQ/status/1697273223833113053)
- Circle your favorite parts and discuss with a friend under the shade of a 🌳

...

Last year, DevRel professionals gave us some great ideas for improving the report. So if you have feedback for how we can level up next year's report too, I'd love to hear it!

With great admiration,
Rebecca and all the cats at Common Room
How to Access the HttpContext in a Class Library in ASP.NET Core?
Tags: csharp, dotnet, dotnetcore
Published: 2023-09-02 08:07:57

---
title: How to Access the HttpContext in a Class Library in ASP.NET Core?
published: true
date: 2023-09-01 18:30:00 UTC
tags: CSharp,DOTNET,DOTNETCore
canonical_url: http://www.codetolive.in//c%23/.net/How-to-Access-the-HttpContext-in-a-Class-Library-in-ASP-NET-Core/
---

# INDEX

- Context
- Using the IHttpContextAccessor
- Accessing HttpContext via Dependency Injection
- Accessing HttpContext via Dependency Injection in a static class
- Considerations

## 1. Context

In ASP.NET Core, the HTTP context cannot be accessed directly in the class library because it is a transient object that is available in the context of an HTTP request.

## 2. Using the IHttpContextAccessor

You can use the HTTPContext in a class library by injecting the **_IHttpContextAccessor_** to your class via the dependency injection from your startup class. Once you have injected the IHttpContextAccessor service into your class library, the HttpContext can be accessed from any method in your class.

## 3. Accessing HttpContext via Dependency Injection

Inject the HttpContextAccessor from the startup class and access it in the class library constructor.

### 3.1 Startup class

```
public void ConfigureServices(IServiceCollection services) {
    services.AddHttpContextAccessor();
}

```

### 3.2 Class library (user.cs)

```
public class User {
    private readonly IHttpContextAccessor _httpContextAccessor;

    public User(IHttpContextAccessor httpContextAccessor) {
        _httpContextAccessor = httpContextAccessor;
    }

    public void GetUserList() {
        // Get the current HttpContext from the IHttpContextAccessor
        var httpContext = _httpContextAccessor.HttpContext;

        // Use the httpContext to access the stored items etc.
    }
}

```

## 4. Accessing HttpContext via Dependency Injection in static class

In a static class, the class is not instantiated and doesn’t create a new instance so it won’t call the constructor; hence, we can directly access the HttpContextAccessor within the static class.

### 4.1 Startup class

```
public void ConfigureServices(IServiceCollection services) {
    services.AddHttpContextAccessor();
}

```

### 4.2 Static class library (user.cs)

```
public static class User{

private HttpContext _httpContext => new HttpContextAccessor().HttpContext;

    public void GetUserList(){
        // You can access the HttpContext from _httpContext here.
    }
}

```

## 5. Considerations

1. HttpContext is a huge object and accessing it can have a negative impact in the performance. Inject the IHttpContextAccessor when you need to access the HttpContext.
2. Dispose of the IHttpContextAccessor when you are finished with it.

Thanks for reading the article about accessing the HttpContext in the class library via dependency injection. Please feel free to drop your comments below, and you can follow us on Twitter ([@Codetoliveblog](https://twitter.com/codetoliveblog)) to receive the latest updates from this blog.
Today I learned: appsync and description fields.
Tags: appsync, aws, graphql, eslint
Published: 2023-09-01 18:29:46

## TLDR
 Appsync does not support triple quotes description.
Install eslint and plugins:
```shell
npm install -D eslint eslint-plugin-graphql
```
Add to your eslint settings =>
```json
"overrides": [
    {
      "files": ["schema.graphql"],
      "extends": "plugin:@graphql-eslint/schema-recommended",
      "rules": {
        "@graphql-eslint/description-style": [1,{"style": "inline"}],
        "@graphql-eslint/no-hashtag-description": 0
      }
    }
  ]
```
Add to parser options
```json
"parserOptions": {
    "schema": ["./schema.graphql"]//  <= ADD THIS LINE
  },
```

## Appsync and description fields
Appsync does not recognize modern field descriptions in GraphQL schema. For example, it does not recognize triple quotes.
```graphql
  """
  This is usename description! BUT APPSYNC does not catch this description
  """
  name: String!
```

Coming to the rescue, I installed the ESLint plugin, which can check descriptions.

```shell
npm install -D eslint eslint-plugin-graphql
```
Create file .eslintrc.json with eslint settings in root directory. With this content
```json
{
  "env": {
    "browser": false,
    "es6": true,
    "node": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "tsconfig.json",
    "sourceType": "module",
    "schema": ["./schema.graphql"],
    "ecmaVersion": 2022
  },
  "plugins": ["@typescript-eslint", "jest", "prettier","unicorn","json-format"],
  "extends": [
    "eslint:recommended"
  ],
  "overrides": [
    {
      "files": ["schema.graphql"],
      "extends": "plugin:@graphql-eslint/schema-recommended",
      "rules": {
        "@graphql-eslint/description-style": [1,{"style": "inline"}],
        "@graphql-eslint/no-hashtag-description": 0,
        "@graphql-eslint/require-description": 0
      }
    }
  ]
}
```
The most important part of overriding this row


```json
"@graphql-eslint/description-style": [1,{"style": "inline"}],
```
And this
```json
"@graphql-eslint/no-hashtag-description": 0,
```
```json
"overrides": [
    {
      "files": ["schema.graphql"],
      "extends": "plugin:@graphql-eslint/schema-recommended",
      "rules": {
        "@graphql-eslint/description-style": [1,{"style": "inline"}],
        "@graphql-eslint/no-hashtag-description": 0,
        "@graphql-eslint/no-unreachable-types": 0,
        "@graphql-eslint/strict-id-in-types": 0,
        "@graphql-eslint/no-typename-prefix": 0,
        "@graphql-eslint/naming-convention": 0,
        "@graphql-eslint/require-description": 0
      }
    }
  ]
```
Scaling serverless development without losing health due to segregation 😎
Tags: serverless, techinnovation, scalability, development
Published: 2023-09-01 18:29:43

Unveil the Secrets of Serverless Development in this short post. 🔍✨
Have you ever pondered over seemingly 'trivial' aspects of serverless applications, such as how to manage and scale such segregation in development without losing your sanity? 🤔

It's a question with multiple nuances, colors, and flavors...😊

And what if I told you there are ways to approach serverless development that emulate a monolithic project using a clean architecture framework, all while allowing the deployment of each function individually?

Imagine having complete control and the ability to scale without losing your sanity. 💡💪 Our latest research has led us to discover innovative approaches: practicing scaled development using the clean architecture structure and individually deploying each function—a fusion of the best of both worlds. 🏗️🌐

Curious to learn more? Don't miss the chance to see how you can achieve monolithic-like development efficiency along with the flexibility of serverless. Get ready for an enlightening small demo that will shift your perspective! 🎥

![Demo video](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1m2fbrakompfichh09l.gif)
The Power of the Square Root in Factorization
Published: 2023-09-01 18:28:45

When dealing with numbers and their factors, you may have wondered why mathematicians often focus their attention on the square root of a number. The concept may seem mysterious, but there's a method to this mathematical madness that significantly simplifies the task of finding factors. In this article, we'll unravel the magic behind the square root when it comes to factorization.

## A **Traditional Approach**

Before we into into the square root method, let's consider the more traditional approach to finding factors. Suppose we want to find the factors of the number 9. The common instinct might be to start with the smallest positive integer, 2, and check if it divides evenly into 9. Then, we move on to 3, 4, and so on until we reach 8. This process seems reasonable but quickly becomes inefficient for larger numbers.

## Using the **N/2 Approach**

Well, let's break it down. If we examine numbers greater than half of 9 (which is 4.5), we quickly realize something crucial. For instance, let's consider the number 6. If we try to divide 9 by 6 (9 % 6), the quotient can't be greater than or equal to 2 because 6 multiplied by 2 equals 12, which is greater than 9. Therefore, it's impossible for a number greater than half of 9 to be a factor of 9.

## **The Square Root Advantage**

However, we can be even more efficient. Instead of considering numbers up to half of 9 (i.e., 4.5), we can narrow our search down to the square root of 9, which is 3. This revelation stems from a fundamental property of factors: if a number has a factor greater than its square root, it must also have a corresponding factor smaller than the square root that multiplies together to give the original number.

Let's illustrate this with another example: 16. The square root of 16 is 4. When we look at the factors of 16, we can see a pattern:

- 1 * 16
- 2 * 8
- 4 * 4
- 8 * 2
- 16 * 1

By examining factors up to 4 (which is the square root of 16), we can rest assured that we've covered all the possible factor combinations for 16. We don't need to explore numbers beyond the square root.
Season 1 Episode 1
Tags: sicp, beginners, productivity
Published: 2023-09-01 17:55:12

 Perfection vs Productivity



Reading this book has not been a walk in the park ,it's more  of a walk in a landmine , from learning the centenarian language of lisp , to creating procedures to attempt the examples at the end of the subchapters, but looking at it now I was working with a 
an unrealistic "Perfection " mindset . 

Perfection is akin to infinity the move you strive the harder it gets to attain it.

Soon after I came across  this quote ::

"Everyday it get's easier but you have to do it everyday that's the hard part"  ~ BojackHorseman

Having a perfection mindset was leading (Recursively) me to the same  wall of wanting to exceed an unattainable goal and it led me to states of  inaction .

Adopting the Pomodoro Technique and having a continuous improvement mindset has largely helped me remain consistent and "loyal" to the course



To my fellow developers reading this resilience and consistency is more important than perfection.

~~~
ExpressoTS vs Nest vs Expressjs vs Fastify (Benchmark)
Tags: javascript, typescript, api, performance
Published: 2023-09-01 17:48:03

Hey folks, the ExpressoTS team just dropped their latest Benchmark report! 🎉 We put ExpressoTS head-to-head with some of the big names like Nest, Fastify, and Express to see how it stacks up. And guess what? We've got some interesting data to share.

Though the source code also includes other frameworks like Hapi for comparison, we mainly focused on the ones mentioned above.

Our dev team has been grinding to make ExpressoTS as efficient as possible, and this Benchmark report showcases that dedication. Definitely worth a read!

Don't just skim through it—make sure to check out the conclusion. It's not about saying X is better than Y; it's about understanding why we stand where we do in the TypeScript ecosystem.

Happy coding! 🚀

https://github.com/expressots/expressots/wiki/Benchmark
Adding different Pelican themes to your static website
Tags: python, staticwebsite, pelican
Published: 2023-09-01 17:42:26

## TL;DR

In order to add a different theme to your static website generated with Pelican, do the following:

- Clone one of these [community-managed theme repos](https://github.com/getpelican/pelican-themes)
- Run the following command on the terminal `pelican content -t /path/to/theme -r -l` 

---

# What is a Pelican theme? 

When you create your first static website using Pelican, you'll notice the design looks like it hasn't been updated since the 90s:

![pelican-website](https://felipearcaro.github.io/images/pelican-website.png)

That's exactly where Pelican themes come into play. There is a community-managed repository of [Pelican Themes](https://github.com/getpelican/pelican-themes) for people to share and use.

# Can I create my own Pelican theme?

You can obviously [create your own Pelican theme](https://docs.getpelican.com/en/latest/themes.html#creating-themes) but if you want to get up and running fast with a not-so-bad-looking website, the easiest path is to pick [a Pelican theme that already exists](https://pelicanthemes.com/). 

# How to use a Pelican theme

Although it hasn't been updated in 7 years, I really like the simplicity/responsiveness of the Alchemy theme, so that's what we're using for this example.

## Clone the repository

Navigate to the [Alchemy Pelican theme repository](https://github.com/nairobilug/pelican-alchemy/tree/f235c81bf323e6134b01915fc9a46b5e89ac238b) and clone it. You'll normally find more information about a theme by looking at the [README.md file](https://github.com/nairobilug/pelican-alchemy/blob/master/README.md) in the repository.

## Change your configs

There are two ways you can tell Pelican to use your new theme when creating your static website:

Reference it with the `-t` flag when running your `pelican` command
```
pelican content -t path/to/the/theme/pelican-alchemy/alchemy -r -l
```

Reference it in the `pelicanconf.py` file adding the following line to it
```
THEME = 'path/to/the/theme/pelican-alchemy/alchemy'
```

And then running the following command:
```
pelican content -s pelicanconf.py path/to/the/theme/pelican-alchemy/alchemy -r -l
```

> Make sure you're specifying the right path – in this example, we need to specify `pelican-alchemy/alchemy` and not just `pelican-alchemy`)

Here's how your static website will look like with the new Alchemy theme:

![pelican-website-alchemy-theme](https://felipearcaro.github.io/images/pelican-website-alchemy-theme.png)
Widely disliked technologies you like (or don't mind)
Tags: discuss, aem, webdev
Published: 2023-09-01 17:24:58

Are there any technologies (languages, frameworks, databases, tech stacks, etc.) which are criticized heavily by other developers, but which you either like or don't have a major problem with?

In my last job, I worked with Adobe Experience Manager (AEM), a content management system. It's proprietary and expensive to use, so it doesn't have as much online info or commentary as many CMSes, but when I do see developers talking about it, it seems far from loved. Personally, while it was annoying looking up problems due to its lack of popularity online, I didn't really mind using it. Sure, it was frustrating at times, but I at least appreciated that it was easy for developers to make different components and define the interface that the content writers/assemblers would interact with. It seems like a rather robust system overall...probably a little over-complicated, ultimately. But all things considered, I enjoyed working with it well enough and wouldn't mind doing another job using it.

So, what hated technology do you think is fine (or better)?
My name is
Published: 2023-09-01 17:23:05

My name is [[attallah]](https://redditreddit17.blogspot.com/) and I am interested in making profits from the internet, affiliate marketing, and artificial intelligence. I have experience in the field of online marketing and earning profits through affiliate programs. I have developed my skills in digital marketing and gained knowledge in using artificial intelligence for data analysis and improving marketing strategies.

I am familiar with the latest developments in technology and digital marketing, and I utilize this knowledge to develop effective strategies for online marketing and increase revenue through affiliate programs. I have the ability to analyze data, identify trends, and opportunities in the online marketing market.

I am enthusiastic about achieving success in this field and working towards building a strong network of partners and clients. I am creative and innovative in finding new ways to achieve success and increase revenue. I believe that artificial intelligence can be a powerful tool in achieving these goals and enhancing business performance.

I look forward to working in an environment that fosters creativity, motivation, and provides opportunities for professional growth. I am ready to develop my skills and keep up with the changes in this dynamic field.
WordPress plugin needs code review and improvement
Tags: woocommerce, api
Published: 2023-09-01 17:18:04

Closed. This question is opinion-based. It is not currently accepting answers.
Update the question so it can be answered with facts and citations. This will help others answer the question. You can edit the question or post a new one.

Closed 39 mins ago.

I have a WordPress plugin that communicate with shipping company API and sends orders details:

Client name, address, phone, order price …

Then the user could print the shipping label from the WooCommerce order page.

The code is bloated and needs a lot of optimisations, anyone could join the GitHub repo and help me ?

https://github.com/mhazgui/shiparon
useEffect Explained
Published: 2023-09-01 17:14:05

##<u>What is useEffect?
</u>

The ‘useEffect’ hook is a fundamental feature in React that handles the management of side effects within functional components. Side effects are actions such as data fetching, interacting with external APIs, and updating the DOM. These actions are critical for building a complex and dynamic application. “useEffect” allows developers to include side effect logic within a function that’s executed after the component renders. This function can also return a cleanup function that handles necessary cleanup tasks. “useEffect” provides a smooth way to integrate side effects, reduces the risk of memory leaks and enhances overall performance of the  application.



##<u>Side Effects</u>

A side effect is any effect that is responsible for changing the state of a component, when the state changes, the component re-renders. For example, accessing databases, fetching data from servers,  updating the DOM, or subscribing to events. The useEffect helps isolate side effects from the rendering logic. 


##<u>useEffect Dependencies</u>

React’s “useEffect” dependencies allow control of when the side-effect runs. Dependencies is an optional array of variables, useEffect execute a callback function depending on if the dependencies have changed between each rendering.


<u>Example</u>


- This is the default case, there is no dependency array attach at the end. The call back function will executes every on single render. 


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

- Passing an empty array as the second argument, the useEffect hook run the side effect once after the initial render. It would be useful in cases for fetching data from APIs and storing it just once.


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

- In this case, the state variable is passed into the dependency array, the side effect will run every time the value of the state variables updates. 


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


You can add multiple state variables that influence the side effect.


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


- Similarly we can also use props to pass as dependency. The side effect runs every time there is a change to the props.


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

<u>_Cleanup_
</u>
Cleaning up side effect is essential to the application's performance. To clean up the side effect, a function must be returned in the callback function we pass in the hook. The cleanup function gets invoked every time when the component unmount.


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