teleren/devto huggingface dataset:
Using services in custom medusa routes
Tags: javascript, webdev, beginners
Published: 2022-09-22 07:52:31

Another cool part about medusa is that we can use services to interact with existing functionality.

For instance, we can access the `ProductService` from there. We can retrieve products but also create and update them.

Let's see how we can use these services inside our custom routes.

## Using services in Medusa routes

For this example, I'll be using the `ProductService`. First, we'll want to add a [custom route endpoint](https://daily-dev-tips.com/posts/adding-custom-routes-in-medusa/).

Inside our custom route, we can start by assigning this service like this.

```js
const productService = req.scope.resolve('productService');
```

Let's say we want to list all products. We can easily do that with the following command.

```js
router.get('/store/test', async (req, res) => {
  const productService = req.scope.resolve('productService');
  productService.list().then((products) => {
    res.json(products);
  });
});
```

If you now restart your server and query this endpoint, you should be able to see a list of your products. (My database only has one effect).

![Custom service call in medusa route](https://cdn.hashnode.com/res/hashnode/image/upload/v1662961377007/7KgvkNbvd.png)

This is, of course, not super beneficial as we already have an endpoint to retrieve precisely this information.
The cool part is that we can choose to manipulate this data.
Let's say we only want items that have stock.

```js
router.get('/store/test', async (req, res) => {
  const productService = req.scope.resolve('productService');
  productService.list({}, { relations: ['variants'] }).then((products) => {
    res.json(
      products.filter((product) =>
        product.variants.some((variant) => variant.inventory_quantity >= 0)
      )
    );
  });
});
```

We have quite a few changes here. Let's take a closer look.
The first one is that we pass arguments to the products list function.
These arguments are as follows:

- `{}`: The first option is the params to query on. In our case, nothing in particular
- `{relations:['variants']}`: This can be used to add specific options to the query. We want to add the variants

Once we have this, we filter all products and only return products where at least one variant has stock.

You can play with adjusting the stock levels in the query.

And that's it, we super powerful way of querying from service in medusa.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Interceptors
Published: 2022-09-22 04:54:51

Interceptors are the powerful mechanism that can monitor, rewrite, and retry API call.

We need to add a logger for each network call ,but by using interceptor we can add a logger once and it will work for each network calls.

Another use-case is caching the response of network calls to build an offline-first app.


**Interceptors are of two types :**

1. Interceptors added between the Application Code (our written code) and the OkHttp Core Library are referred to as application interceptors. These are the interceptors that we add with addInterceptor().
 
2. Interceptors on the network: These are interceptors placed between the OkHttp Core Library and the server. These can be added to OkHttpClient by using the addNetworkInterceptor command ().

Here’s a simple interceptor that logs the outgoing request and the incoming response.


```
class LoggingInterceptor implements Interceptor {
  @Override public Response intercept(Interceptor.Chain chain) throws IOException {
    Request request = chain.request();

    long t1 = System.nanoTime();
    logger.info(String.format("Sending request %s on %s%n%s",
        request.url(), chain.connection(), request.headers()));

    Response response = chain.proceed(request);

    long t2 = System.nanoTime();
    logger.info(String.format("Received response for %s in %.1fms%n%s",
        response.request().url(), (t2 - t1) / 1e6d, response.headers()));

    return response;
  }
}
```

**
We can add interceptor while building the OkHttpRequest object as follows :**

```
fun gfgHttpClient(): OkHttpClient {
	val builder = OkHttpClient().newBuilder()
		.addInterceptor(/*our interceptor*/)
	return builder.build()
}
```

**Keeping the response in the cache**

If we want to cache the API call response so that when we call the API again, the response will come from Cache. If we have an API call from Client to Server and the Cache-Control header is enabled on the server, OkHttp Core will respect that header and cache the response that was sent from the server for a certain amount of time.
High security of openGauss - dynamic data desensitization mechanism
Published: 2022-09-22 07:40:16

Dynamic data desensitization mechanism

⚫ Data privacy protection is one of the security capabilities required for database security. It can limit unauthorized users' access to private data to a certain extent and ensure the security of private data. 

⚫ The dynamic data desensitization mechanism is a technology that realizes the protection of private data by customizing the desensitization strategy, which can effectively solve the problem of unauthorized users' access to sensitive information on the premise of retaining the original data. 

⚫ After the administrator specifies the object to be desensitized and the customized data desensitization strategy, if the database resource queried by the user is associated with the corresponding desensitization strategy, the data desensitization will be performed according to the user identity and desensitization strategy, thereby restricting the Authorize user access to private data.

⚫ The dynamic data desensitization mechanism customizes desensitization strategies based on resource tags. Specific desensitization methods can be selected according to actual scenarios, and desensitization strategies can also be formulated for some specific users. The SQL syntax for creating a complete desensitization strategy is as follows: 

CREATE RESOURCE LABEL label_for_creditcard ADD COLUMN(user1.table1.creditcard); 

CREATE RESOURCE LABEL label_for_name ADD COLUMN(user1.table1.name); 

 CREATE MASKING POLICY msk_creditcard creditcardmasking ON LABEL(label_for_creditcard); 

 CREATE MASKING POLICY msk_name randommasking ON LABEL(label_for_name) FILTER ON IP(local), ROLES(dev);

⚫ Among them, label_for_creditcard and msk_name are the resource labels for desensitization planned for this round, which respectively contain two column objects; creditcardmasking and randommasking are preset desensitization functions; msk_creditcard defines what all users do when accessing the resources contained in the label_for_creditcard label. The desensitization strategy of creditcardmasking does not distinguish the access source; msk_name defines the desensitization strategy of randommasking when the local user dev accesses the resources contained in the label_for_name label; when the FILTER object is not specified, it means that it takes effect for all users, otherwise it only applies to the label The user of the scene takes effect.
react router explained for beginners
Tags: react, javascript, webdev
Published: 2022-09-22 07:26:27

react router explained
hi everyone this is a simple guide for react router, first things first you need to create a page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5k518hxe7il4qnfcmy0o.png)
on this example im creating a report page


after that i need to make the standard react call out, and this code.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urvuvtvp1sa8p84ln359.png)


after that on my APP.tsx i need to route the index element to the Import i wanted to be in.


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


simple guide and tip for you!
Sheetster - Custom Sheets
Tags: swift, github, opensource, ios
Published: 2022-09-22 07:15:49

The other day on a Swift discord I see people having a discussion how hard it is to set custom detents for sheets right now. And it inspired me to write a library that let's you automate and set custom detents for sheets, wether it'd be a bottom sheet like the one the maps use, or you just have a designer who places 30% 40% 70% height sheets into the UI Design.
If you find it useful, make sure to star it :)
https://github.com/admirsaheta/Sheetster
A Solution to Cutting Media Storage Costs in Half
Published: 2022-09-22 07:03:20

For media storage, Tencent Cloud’s Video-on-demand (VOD) provides a cold storage scheme that is widely applicable and can help you save storage costs. As more and more media assets are generated, storage becomes increasingly expensive. Deleting old media assets may cause inadvertent business failures; but storing old media assets will continue incurring storage fees. In addition to costly storage, there are also many different types of media assets that require complicated access management. To handle the long-standing problem of media storage, Tencent Cloud VOD launched the cold storage feature for media assets.

**1. What is a media asset?**

**Simple media:** A single media file such as a video, an audio, a subtitle file, or simply a URL.

**Complex media:** A file containing multiple media assets. In VOD, a complex media file is identified by FileID.

**2. Smart cold storage for media assets**

The smart cold storage scheme mainly applies to three scenarios: **Different levels of access frequency/ Live stream backup/ Media asset archiving**

For these common scenarios, we output the smart cold storage scheme for media assets:

End users upload files to the storage class of VOD (hot storage class, which is the standard class).

Media files are stored to the cold storage class (based on the smart cold storage policy).

End users delete files, which are then transferred to the recycle bin (deletion and backup scenarios).

The recycle bin regularly deletes the files (deletion scenario).

This scheme reduces operating costs in a more refined manner and leverages the advantage of being closer to you at the PaaS layer. VOD provides five configuration policies and three target cold storage classes to help configure refined cold storage as needed. The five policies are by time, category, video source, access count, and media file type, which can be freely combined with each other to meet different needs. To learn more about detailed configuration methods, see the smart cold storage of VOD media assets.

**3. Summary**

Compared to IaaS-like cold storage schemes, VOD offers the following:

Service scenarios that are more suitable for real business scenarios: VOD performs cold storage for complex media assets based on FileID, freeing you from complicated management of simple media assets.

More diversified dimensions of cold storage policies: VOD can move assets to cold storage according to access count, time, category, source, and media type, so that you can configure cold storage policies more easily.

More reasonable cold storage policies: VOD supports FileID-based cold storage of live streams and cold storage by playback count, helping you manage and control business costs more clearly and effectively.

Read more at: https://www.tencentcloud.com/dynamic/blogs/sample-article/100344
Will real estate agents be replaced by robots?
Tags: webdev
Published: 2022-09-22 06:51:33

It's no longer a matter of if, but rather when the real estate industry will be disrupted.
**[Find Home, Apartments, Flat, Villa in Qatar on Hapondo](https://hapondo.qa/)**

The way we sell and buy homes remains a problem

California investment advisor Ross Gerber summed up what many of us are thinking when he said, “The real estate industry desperately needs … a transparent, predictable and liquid market that not only captures the dynamics of supply and demand, but enables fast, cheap and seamless transactions. Such a market would increase activity, lower broker fees and make it easier for homeowners to unload properties.

A 2013 Oxford University study estimated that artificial intelligence has a 98% chance of replacing real estate agents.

In the US alone, $1.8 billion was invested in real estate tech startups by the end of 2016, and it hasn't slowed down since.

That said, not everyone is convinced that sales reps are on the way out

Some analysts say that most people don't buy or sell a home very often, so while it doesn't seem that hard when push comes to shove, we're not so sure about selling or buying our own homes on good terms. the stakes are so high.

It's also an emotional experience, sometimes harrowing, and it's comforting to have someone guide us through the process. It can be a little scary, with lots of legal documents, and it gets worse with significant disturbances like leaky buildings, and the added complexity of living in flats with corporations and the like.

For most people, this is by far the largest financial transaction they will make in their lives.

When we put it all together, the argument is sound, and trust comes into play

We want to be able to look a person in the eye and judge whether we trust them to help us make such a big decision.

One way technology could potentially be used to develop this trust is to allow customers to rate agents through an online service (such as Uber). UK firms such as Purplebricks already do this, but blogger Andrew Duncan thinks it could go further, with ratings aggregated across all available services and platforms to give customers a clear view of whether to trust an agent or not.

It all sounds a bit like Black Mirror, but the trust-based trading industry needs a way to show it can be trusted.

Even though human real estate agents hang around, the way they do their jobs probably won't stay the same

One thing that technology is very good at is streamlining processes and thereby improving the customer experience.

Online listings have already made it easier for buyers to find their dream homes, and now there's also a growing movement to make it as easy as possible for buyers to sign a contract.
Bgeraser has been upgraded with Lots of New Features
Tags: webdev, productivity, design, photoediting
Published: 2022-09-22 06:31:16

Hey, guys,

Recently we upgraded our old project "bgeraser" with many new features. Now you can use it to remove image background, extract unwanted elements, and delete the text watermark with our app.  

Here is a brief introduction to Bgeraser: 

BGeraser is a free online tool that allows you to remove background, unwanted objects, and watermark from an image, Simply upload your photo and select the area that you want to remove. In few clicks, Bgeraser will automatically remove the selected thing. Unlike Remove.bg or other online background eraser tools, Bgeraser can remove any objects accurately while keeping the background. More importantly, the image quality will not be damaged. 

Here are two examples: 
1. Remove image background 

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




2. Remove unwanted objects 


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


3. Remove text watermark 

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


Let me know if your website can accept my app review submission. 

Best regards,
Mary  |  https://bgeraser.com/
Frequently Asked Question to your new employer
Tags: jobbenefits, faq
Published: 2022-09-22 06:45:40

Every new job is very important to your life and your family. In this modern era, the job is not like slavery. Your job should give you fun, and motivate to work you more.

The workplace should give you more energy automatically to focus on problem-solving and issues. For this, we need to be tension free in the workplace, which only can achieve by benefits. The more benefits the company gives you, the more energy you can feel inside to give more to the company's growth. You’re the company’s one of part then.

Here I list some of the essential frequently asked questions and benefits which an employees should ask an established company in recruitment.

**FAQ**

1. Details job clarification if not mentioned on the Job description post.
2. Skill and training opportunities for staff. It is one of the vital benefits for staff. This must be asked by an employee.
3. Company objectives & Core values. What if some values conflict with my religion and my personal values?
4. What is the team leader’s expectation from me within the next 6 months?
5. What is the company’s business & products?
6. What is my work area?
7. My Stack details, the tech I will deal with
8. What position does the company want to see me within the next year?
9. Do they have any plans to move me in another team very soon or after finishing the tasks?
10. Do you give employees prayer time?

**Benefits**

1. What your company did for employees' work-life balance?
2. Do you allow flexibility in job timing?
3. Performance analysis and increment (yearly, half-yearly, based on performance)
4. Overtime work & benefits
5. Do you provide on-time salary?
6. Do you allow parental leave, how many days?
7. Do you provide accidental leave, how many days?
8. Do you provide paid and unpaid vacation, how many days?
9. Do you provide basic health benefits like health insurance, yearly Dental & Eye checkups/insurance?
10. Do you provide any job security and pensions?
11. Do you provide home workstation build support?
12. Do you provide yearly tour sponsorship?

This question list is for an employee for awareness of the right and benefits before joining the new company. You can ask all or partial depending on you. But these are the list you should aware of.

Do you have any in your mind? tell me in the comment section.
Remove Given Element from an Array - Leetcode
Published: 2022-09-22 06:35:50

[Leetcode - Remove Element](https://leetcode.com/problems/remove-element/)

The question says: 

> 
Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed.

You'll also not want to create another array as the expected Space complexity is O(1).

Here's how I tackled it:

- Store the length of the given array in a variable, nums_length


- Declare a variable length_of_nums to 0. This would later act as the counter in our loop


- Create a loop to run if length_of_nums is less than nums_length


- Create a second loop to check if the length_of_nums(counter) element in the nums array is equal to the value given to check. if the condition for the loop is not met, increment the length_of_nums by 1


- If the two elements are same, pop out the element in the array


- decrement the nums_length by 1


- Check if the nums_length is equal to the length_of_nums to break out of the inner loop. (This checks for edge cases)


- return length_of_nums


Using this approach gives you the array in memory without duplicates so you can return the new length of the array.
Netgear Orbi Login Guide
Published: 2022-09-22 06:32:18


If you own an Orbi router and looking to perform [Orbi router login](https://orbitloginnet.com/) then luckily you have stumbled upon the right place. This website wraps the whole lot you need to know about Netgear Orbi login.

Users face a range of issues while getting access to the Orbi router login page. Some approach us with a query that they can’t access orbilogin.net while others looking to know the answer for the Orbi admin login issue. No matter what issues you are facing while doing Orbi Netgear login or Orbi setup, here you will get answers to every of your query in detail.
Ethical Hacker Training
Tags: ceh, cehv12
Published: 2022-09-22 06:15:54

The Certified Ethical Hacker (C|EH v12) program is one of the most respected certifications in the cybersecurity field. It has been the world’s number one ethical hacking certification for 20 years and is continuously ranked number one in ethical hacking certification by different firms.


[Ethical Hacker Training](https://www.infosectrain.com/courses/certified-ethical-hacker-ceh-training/
)
How To Fix cURL Error 60 SSL Certificate Problem
Tags: curl, ssl, certificate, errors
Published: 2022-09-22 06:11:35

In this article, we see how to fix the cURL error 60 SSL certificate problem. cURL error 60: SSL certificate problem: unable to get local issuer certificate error occurs when we try to call the API with the secure https:// protocol in the request URL.

cURL error 60 SSL certificate problem on localhost in xampp and localhost wamp server. Also, you can face a curl 60 SSL certificate problem on windows, In the laravel guzzle SSL certificate issue.

Why does cURL Error 60 SSL certificate Occur?
Your API call tries to run the request URL with only http:// protocol. You can’t see the error anymore because secure API calls require an SSL certificate or https:// protocol.

This error occurs because the API call makes a secure connection request using the self-signed certificate. When it does not find a valid certificate, it throws an error. 

How To Fix cURL Error 60 SSL Certificate Problem?

1. Open http://curl.haxx.se/ca/cacert.pem or Download the “cacert.pem” free certificate file from the official website http://curl.haxx.se/docs/caextract.html

2. Save it as a “cacert.pem”.

3. Paste cacert.pem in WAMP user to C:\wamp64\bin\php\cacert.pem, for XAMPP user to C:\xampp\php\extras\ssl\cacert.pem path.

4. Open php.ini and find this line

```
;curl.cainfo
```

5. Now, we need to add the path of the certificate to “curl.cainfo” and remove the semicolon(;) as follows.

```
curl.cainfo = "C:\wamp64\bin\php\cacert.pem"
```

6. The most important step is to save and close your php.ini. Restart your WAMP or XAMPP server and try your request again. If you do not set the right path, then you will experience a cURL 77 error.
Tayfa ile Chrome Ana Sayfası Düzenleme
Tags: liman, tayfa, chrome
Published: 2022-09-22 06:06:01

Bu yazıda Tayfa politikaları ile istemciler üzerinde Chrome tarayıcısının ana sayfasını ayarlamayı göstereceğiz.

Öncelikle bu işlem için bir politika nesnesi oluşturmak gerekir. Politika nesnesi istenilen bir organizasyon içerisine gidilerek oluşturulur.
![1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h8ssw9pbum2wrrkj0oo.png)

![2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rui3x2mby0ws3dq8w37g.png)

Politika nesnesini oluşturduktan sonra üzerine tıklanarak **Makine** tabına gidilir ve **Chrome** ayarlarına girilir.
![3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wpvpy4g9i126oply6m0.png)

Burada bulunan **Chrome/Chromium Tarayıcı Ayarı** bölümünde ana sayfa ayarı yapılacaktır.
* **Ayar Adı** kısmına **HomepageLocation** girilerek ana sayfa ayarı yapılacağı belirtilir.
* **Ayar Değeri** kısmına ana sayfa olarak ayarlanmak istenen adres girilir.
* **Ayar Tipi** kısmında **Metin** seçilir.
Ayarlar yapıldıktan sonra kaydedilerek çıkılır.
![4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aotpthivf8h2t2i85lb6.png)

Bu aşamada politika ayarları yapılmış olup istemciler tarafından çekilmesi beklenmektedir. İstenirse istemciler üzerinde `gpupdate -v` komutu ile manuel olarak politika güncellemesi de yapılabilir. Politika güncellemesi yapıldıktan sonra istemci üzerinde Chrome veya Chromium tarayıcı açılarak ana sayfa politikası gözlemlenmiş olur.
![5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts7i5vx03d3bqkdxp9gj.png)
Big data
Published: 2022-09-22 05:38:18

Big data is a term that describes large, hard-to-manage volumes of data – both structured and unstructured – that inundate businesses on a day-to-day basis. But it’s not just the type or amount of data that’s important, it’s what organizations do with the data that matters. Big data can be analyzed for insights that improve decisions and give confidence for making strategic business moves.