teleren/devto huggingface dataset:
In 48 hours, I’ve created License Key APIs using Supabase.
Tags: api, backend, postgres, sql
Published: 2022-05-25 10:58:19

Background — TL;DR

I have business use cases around license keys for my macOS app so I went with Paddle who has both license keys + payments, for no reason, they’ve suspended my account. Literally, the next step I had taken was to build my own(not a fun thing to do because it is like reinventing the wheel) using Supabase.

> This is the app where I am using the License key use-cases: https://zenmode.carrd.co/

### Day 1: I scoped down my business use cases as follows:

1. License generation
2. License activation
3. License de-activation
4. License verification
5. License re-activation
6. License revocation


**License generation:**

- Basically generate unique license keys, so I simply went with UUID and in Supabase you can find the property.

**License activation:**

- Since this is a macOS app, validate the license key with user details + some magic to ensure the license is activated for the first time user.

**License de-activation:**

- If a user wants to deactivate the license temporarily or switching to a new device then user has to deactivate the license key first before activating to a new device.

**License verification:**

- Basically X number of times per week the backend validates with frontend whether the license key is valid or not.

**License re-activation:**

- When a user needs to use the app on their new device, they have to unregister first on their old device and re-activate on new device.

**License revocation:**

- For any bad reason, revoke the license


### Day 2: Build tables based on the use-cases and write procedural functions to handle backend logic

Tables

- Table to maintain user information
- Table to maintain user license information and activities

Procedural functions

- Translated each business use-case as function or functions, behind the scenes Supabase converts each function as an API.

--

Pros:

- I’ve pretty much created all the APIs using procedural functions which is just like writing sql queries.
- All functions are automagically converted to APIs

Cons:

- There is more error prone using procedural functions than writing down in server less functions(hoping supabase launches as soon as they can)
- Because supabase functions are still wip, I can’t integrate with email services to send license keys so I had to manually send license keys to the user email.

> You can checkout my app here https://zenmode.carrd.co/
Backend vs Frontend vs Full-Stack?
Tags: discuss
Published: 2022-05-25 10:50:06

---
title: Backend vs Frontend vs Full-Stack?
published: true
description: The shy Full-Stack developers
tags: #discuss
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3t5l3q3wxmtgujnnlole.png
---

Which one are you: backend, frontend or full-stack developer?

I've been a developer for the past 10 years, and along this time, I came in contact with many developers who cannot answer this question for one reason or another. 

Clearly, a full-stack developer is much more appreciated than the rest for the obvious reason that a full-stack dev can do both backend and frontend, which makes them more appreciated by their employer and by their colleagues.

But I came to realize that most of the devs I worked with had a preference: either backend or frontend. Also, you gotta be better, even if slightly, at one more than the other.

Long ago, I realized that I preferred backend over frontend, which wasn't a surprise since my "main" languages were PHP and Python, although I used JavaScript since the beginning of my career.

Sadly, till this day I see a lot of full-stack jobs (such as Laravel/Vue.js). 


Percentages:
![backend vs frontend vs FullStack percentages](https://cdn.utorontobootcamp.com/wp-content/uploads/sites/97/2020/10/percentage-of-full-stack-developers.jpg)

As you see, the backend and full-stack percentages are almost identical, because it is a common misconception that "if you can do the backend part then how hard is it to also do a bit of JS/HTML/CSS (frontend) to finish up the application/task?"


Hence:
![backend vs frontend vs FullStack](https://media-exp1.licdn.com/dms/image/C5622AQGxXIVhlC9DNg/feedshare-shrink_2048_1536/0/1640706052143?e=2147483647&v=beta&t=-VVs5l1a6U4DaHNdi11Vbjs4UMR5dz_2_s3nXBFkBSQ)

This picture explains it very well: 
Backend: kitchen
Backend Devs: chefs, sous-chefs
Frontend: the restaurant hall, tables, chairs..
Frontend Devs: waiters, manager, receptionist, cleaners..
Full-Stack: Fast food truck
Full-Stack Devs: Fast food truck operator (drives it, cleans it, prepares food, greets customer, serves food, gets paid, gives back change!)

So next time an employer offers you a Full-Stack job, remember this picture.

Personally, I'm pushing towards the dismantle of Full-Stack mentality. In my last 10 interviews throughout the last couple of years, I pushed for the segregation of backend from frontend (reminds me of the SOLID principles I). I managed to do backend with a TINY bit frontend in my current gig, and I am pushing currently with couple of future employers with the same result.

I implore you all, if you agree with me, then let's push employers to understand, that backend and frontend are different things and need to be done by different people. Some companies understood this, mostly big companies. But the medium and even smaller ones need to adapt this mentality as well.

In case you enjoy Full-Stack development, then ignore this article :)
Context API & State Managers
Published: 2022-05-25 10:39:46

For some reason libraries like **Redux** are built using **Context API**. And when someone in the React world gets to know tools like _Context API_, _Redux_, _Zustand_, _Recoil_ and so on, a lot of times they get stuck in the very common doubt (at least I've been through it), which is **When should I use the Context API instead of a State Manager?**. Well here's what I think about it.

Before answering, let's go through some definitions.

## What's Context API?

The Context API represents a way of sharing variables or global states with its internal components (avoiding situations like [**Prop drilling**](https://blog.logrocket.com/solving-prop-drilling-react-apps/#:~:text=Prop%20drilling%20is%20the%20unofficial,actual%20need%20for%20this%20data.)). 

## What're State Managers?

They are tools that help us manage the most complex states of an application. Controlling how data can be mutated.

According to [Open Replay](https://blog.openreplay.com/top-6-react-state-management-libraries-for-2022), in the React ecosystem the most popular State Managers are: **Redux* *, **Recoil**, **Zustand**, **Jotai**, **Rematch** and the **Hookstate**.

## And now?

OK, now that you know what **Context API** is and what **State Managers** are, let me just say that anything you can do with **State Managers** you can do with **Context API**, but the point is: **Is it worth it?** or **Should I spend time on this?**.

And I tell you no, it's not worth it, after all, **why reinvent the wheel?**

What going on, is that the **State Managers** already provide a well-elaborated tool to be able to manage our states as efficiently as possible and if we use the **Context API** instead of libs like _Redux_, we would have to worry about handling the states to avoid unnecessary rendering affecting the performance of our application.

## When we should Context API?

- **Theming** — Swipe down the app theme
- **i18n** — Transmit translation messages
- **Authentication** — Pass the current authenticated user
- **Atomic Component Globalization**: When we have a component with some states that need to be used by more internal components.

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

## References

- [Picking From 20 React State Managers](https://www.youtube.com/watch?v=P95DuIBwnqw).

- [WATCH LATER ADD TO QUEUE NextJS + State Management = Good Idea???](https://www.youtube.com/watch?v=_gRxCvDjWjs).

- [Top 6 React state management libraries for 2022](https://blog.openreplay.com/top-6-react-state-management-libraries-for-2022).
Wednesday Links - Edition 2022-05-25
Tags: java, jvm, sprin, gradle
Published: 2022-05-25 10:34:04

Gazillion Virtual Threads (6 min)🧵
https://javaspecialists.eu/archive/Issue301-Gazillion-Virtual-Threads.html

Preparing for Spring Boot 3.0 (4 min)👜
https://spring.io/blog/2022/05/24/preparing-for-spring-boot-3-0

Spring Boot 2.7 adds native support for Jackson Mixins with `@JsonMixin` annotation (30 sec)🌀
https://twitter.com/maciejwalkowiak/status/1525730129871355905

Debugging a JVM Crash for LinkedIn – Part 2 (5 min)💥
https://devblogs.microsoft.com/java/debugging-a-jvm-crash-for-linkedin-part-2/

JFR Event Stream (2 min)🚰
https://inside.java/2022/05/12/sip49/

Gradle quickie: laziness (2 min)🦥
https://melix.github.io/blog//2022/05/gradle-laziness.html

Using Linux's memfd_secret syscall from the JVM with JEP-419 (8 min)🙊
https://blog.arkey.fr/2022/05/16/linux_memfd_secret_with_jep-419/

cache2k Java Caching (1 min)🧽
https://cache2k.org/

Java data access technology survey results (3 min)🗄️
https://vladmihalcea.com/java-data-access-technology/

What happens to TLDs when their country stops existing? (6 min)🤔
https://astrid.tech/2022/04/05/1/dead-tlds/

Stack under attack: what we learned about handling DDoS attacks (6 min)🛡️
https://stackoverflow.blog/2022/05/16/stack-under-attack-what-we-learned-about-handling-ddos-attacks/

Unfinished Business with Postgres (14 min)👔
https://www.craigkerstiens.com/2022/05/18/unfinished-business-with-postgres/
How to Quickly Play with PostgreSQL 15 Beta using Docker
Tags: docker, postgres
Published: 2022-05-25 10:32:57

The [first beta of Postgres 15](https://www.postgresql.org/about/news/postgresql-15-beta-1-released-2453/) is out now and the official Docker image for it has also just gone live, making it easy for you to take it for a quick spin without destroying your production systems.

Assuming you have Docker running, here's the quickest way to get going:

```
docker network create pgnetwork
docker run --name pg15beta1 --network pgnetwork -e POSTGRES_PASSWORD=whatever -d postgres:15beta1 
```

This creates a network called `pgnetwork` so that other containers can communicate with Postgres easily. A container is then run based on the `postgres:15beta1` image, a default password is set for the `postgres` user (you can change this to whatever you like), and the container is given the name of `pg15beta1`.

Then to run `psql`:

```
docker run -it --rm --network pgnetwork postgres:15beta1 psql -h pg15beta1 -U postgres
```

This spins up *another* container (which is deleted after you quit `psql` thanks to the `--rm` option) which uses the same Postgres image but to run `psql` instead. Enter the password you provided in the first step and you're in.

![Everything is working with psql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4u0xvc9l2o6y9ffehhj.png)

To clean up:

```
docker stop pg15beta1
docker rm pg15beta1
```

If you have `psql` locally and want to experiment with Postgres 15 with apps on your local system, you could expose its port on localhost like so:

```
docker run --name pg15beta1 -e POSTGRES_PASSWORD=whatever -p 1234:5432 -d postgres:15beta1
```

This then makes the Postgres 15 server accessible at port `1234` on localhost. Tweak to suit your use case.
Am I the only one who finds this frustrating about generics?
Tags: typescript, help
Published: 2022-05-25 10:30:33

## The problem
Here is my problem, when a class/function has multiple generic types that are not mandatory to specify it often happens that the code looks like this:

```typescript
const instance = new GenericClass<any, any, number>();
```
or

```typescript
const result = genericFunction<string, any, any, number>();
```
Basically what I am looking for is to avoid specifying all the generic types where I want to leave the default type.

## My solution
I had studied this problem a lot, but I am not able to find a solution that doesn't become a problem too.

This is what I come up with after a sleepless night:

First I specify which properties have a generic type and create a utility type _GetGeneric_ which returns the specified type or, in case the type has been omitted for that property, the default type.

```typescript
type GenericProps = 'input' | 'output';
type AcceptedGenerics = { [Property in GenericProps]: any };

type GetGeneric<T extends Partial<AcceptedGenerics>, Prop extends keyof AcceptedGenerics, TDefault = any> = T extends Pick<AcceptedGenerics, Prop> ? T[Prop] : TDefault
```
Then here is how I use this method for classes:

```typescript
class Obj<T extends Partial<AcceptedGenerics>> {
    input: GetGeneric<T, 'input', string>
    output: GetGeneric<T, 'output', string>
}

const instance = new Obj<{ output: number }>();

/*
    instance = {
       input: string,
       output: number,
    }
*/
```
And here the function version:

```typescript
function Func<T extends Partial<AcceptedGenerics>>(
    input: GetGeneric<T, 'input'>
): GetGeneric<T, 'output', {}> {
  return { } as GetGeneric<T, 'output', {}>; 
}

const result = Func<{ input: number, output: { prop: string } }>(2);

/*
    Func<{ input: number, output: { prop: string } }>() = (input: number) => { prop: string }
*/
```

I also noticed that in case the extended use of the _GetGeneric_ utility type make the code look messy, it is possible to define all the generic type like so:

```typescript
function Func<T extends Partial<AcceptedGenerics>, TInput = GetGeneric<T, 'input'>, TOutput = GetGeneric<T, 'output', {}>>(
    input: TInput 
): TOutput {
  return { } as TOutput; 
}
```
But I am not sure if this solution is better or worst.

## Conclusions
I am asking you what you think about this solution, if you have any suggestions and if you think this was a problem to solve in the first place.
Canny | Made with React JS
Published: 2022-05-25 10:29:55

![Canny | Made with Javascript | React JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1652850533/large_canny_made_with_react_js_052b39249b.png "Canny | Made with Javascript | React JS")


### Canny helps you collect and organize feature requests to better understand customer needs and prioritize your roadmap.

> ### Build better products with customer feedback
> Capture, organize, and analyze product feedback in one place to inform your product decisions.
> 
> ### Collect feedback from customers and teammates
> Stop letting ideas slip through the cracks. Collect, analyze, and organize feedback and feature requests in a dedicated customer feedback tool.
> 
> ### Make better product decisions
> See which features are most requested, filter feedback by segment and impact, and clarify use cases up front. Don’t waste time building the wrong things.
> 
> ### Prioritize feature requests and build a product roadmap
> Score feedback and feature requests based on priority, add them to your roadmap, and integrate with project management tools like Jira.
> 
> ### Keep everyone engaged with product updates
> Automatically follow up with people when you release a feature. Keep the feedback loop going strong.
> 
> 

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [Canny on Twitter](https://twitter.com/withjavascript/status/1529408050196533251?s=20&t=irzPIOUbqgFUK0xvo3uXTA)
 |
| Medium | [Canny on Medium](https://medium.com/@madewithjavascript/canny-made-with-react-js-535370117505)
 |
| Facebook | [Canny on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid0GhmH755nroC5nqvcxCJih9tafwjfmY4yUEzkiwJAPDWgJbg2mw7wpESSzfxLpS5El)
 |
| Tumblr | [Canny on Tumblr](https://madewithjavascript.tumblr.com/post/685217656408866816/canny-made-with-react-js-canny-helps-you)
 |
| LinkedIn | [Canny on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6935174145441771521)
 |


Filled Under:

 - [Made with Javascript](https://madewithjavascript.club)    
 - [Made with React JS](https://madewithjavascript.club/categories/react-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Read an image from an Internet URL in Python3 cv2
Tags: opencv, python3, imageread, cv2
Published: 2022-05-25 10:20:18

By this piece of code we can read image from URL in opencv python3.

Make sure you have installed opencv in system. 
```bash 
pip install opencv-python
```

```py
import cv2
import urllib.request
import numpy as np

req = urllib.request.urlopen('https://variety.com/wp-content/uploads/2021/12/doctor-strange.jpg?w=681&h=383&crop=1&resize=681%2C383')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
img = cv2.imdecode(arr, -1) # 'Load it as it is'

cv2.imshow('random_title', img)
if cv2.waitKey() & 0xff == 27: quit()
```
Context API & State Managers
Tags: contextapi, react, redux
Published: 2022-05-25 10:19:54

Por alguma razão bibliotecas como **Redux** são construidas usando **Context API**. E quando alguém no mundo React passa a conhecer ferramentas como _Context API_, _Redux_, _Zustand_, _Recoil_ e por aí, muita das vezes fica preso na duvida muito comum (pelo menos eu já passei por isso), que é **Quando devo usar o Context API ao invés de um State Manager?**. Pois bem aqui vai o que penso sobre isso.

Antes de responde-lo vamos a algumas definições.

## O que é o Context API?

O Context API representa uma forma de partilhar variaveis ou estados globais com componentes internos do mesmo (evitando situações como [**Prop drilling**](https://blog.logrocket.com/solving-prop-drilling-react-apps/#:~:text=Prop%20drilling%20is%20the%20unofficial,actual%20need%20for%20this%20data.)). 

## O que são State Managers?

São ferramentas que nos ajudam a gerenciar os estados mais complexos de uma aplicação. Controlando a forma que os dados podem ser modificadas, quando devem ser modificadas, porque, e por a´´i vai.

De acordo com o [Open Replay](https://blog.openreplay.com/top-6-react-state-management-libraries-for-2022), no ecossistema React os State Managers mais populares são: **Redux**, **Recoil**, **Zustand**, **Jotai**, **Rematch** e o **Hookstate**.

## E então?

OK, agora que sabes o que é **Context API** e o que são **State Managers**, deixe-me dize-lo que tudo que consegues fazer com os **State Managers** consegues faze-lo com o **Context API**, mais o ponto é: **Vale a pena?** ou **Devo perder tempo com isso?**.

E eu digo-te que não, não vale a pena, afinal **porque  reinventar a roda?**

O que acontece é que os **State Managers** já fornecem consigo um ferramental bem elaborado para podermos gerenciar os nossos estados de forma mais eficiente possível e o que acontece é que se tivéssemos que usar o **Context API** no lugar de libs como _Redux_, teriamos que nos preocupar em tratar os estados de forma a evitar renderizações desnecessárias afetando a perfomace da nossa aplicação.

## Quando usar o Context API?

- **Temas** — Passe para baixo o tema do aplicativo
- **i18n** — Transmitir mensagens de tradução
- **Autenticação** — Passar o usuário autenticado atual
- **Atomic Component Globalization**: Quando temos um componente com alguns estados que precisam ser usados por componentes mais internos.

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

## References


 - [Top 6 React state management libraries for 2022](https://blog.openreplay.com/top-6-react-state-management-libraries-for-2022)

- [Picking From 20 React State Managers](https://www.youtube.com/watch?v=P95DuIBwnqw)

- [WATCH LATER ADD TO QUEUE NextJS + State Management = Good Idea???](https://www.youtube.com/watch?v=_gRxCvDjWjs)
What is your one big tip you'd tell yourself starting out becoming a developer?
Tags: discuss, programming, learning, productivity
Published: 2022-05-25 10:07:57

**we all started somewhere** in this big world of development.

I wish I wish I wish! I had told myself that :

> it is OK to not know the answer & ask questions, lots of them.

There are many devs on Dev.To just starting out in their journey, and are looking for any tips no matter big or small. 

So what is your **ONE BIG TIP** that you wish _you_ had told 
yourself?

_Credit to [The Amp Channel](https://www.youtube.com/watch?v=f02mOEt11OQ) for the cover image._
Steel Shots
Tags: steelshots, sandblastingmachin, shotsblastingmachine
Published: 2022-05-25 10:02:48

[Steel shots](https://steelshotsupplier.in/) is the most widely used method in sand & shot blasting industries for cleaning, stripping, and improving a metal surface. The grade or size of the steel shot will determine the finishing done on the surface of the metal.

A smaller steel shot exporter will appear on a smoother and more polished surface. A larger steel shot exporter will clean more aggressively but produce a more uneven surface. Both breaths of air-powered and wheel blast machine can be used to stimulate the steel shot manufacturer in India onto the surface of the part. Due to the hardness and density of steel shot manufacturer in India, it can be reused as much as 3000 times before replacement. Since steel shot supplier does not use an abrasives process, a minimal amount of dust is created in the blasting process.

Steel Shot Supplier in India
Steel abrasives (cast steel shot) are essentially used to clean metal surfaces and parts like Desanding and cleaning foundry castings, Descaling metal sheets, billets, and profiles provided by the steel industry, Surface preparation in steelworks previous to coating. Our cast steel shot manufacturer in India proceed to find broad and growing applications in diverse markets such as automotive, aerospace,agriculture, construction, foundry, mining, railroad, shipyard, stone cutting, office machines, petrochemical, and other major industries. Steel shot supplier is the perfect cleaning process prior to forming, shearing, rolling, painting, or galvanizing. Shot Blasting uses fine steel media to clean, descale, and remove rust from parts. Parts are "sprayed" with a shot, similar to sand blasting, revealing the original bright metallic appearance. The reconstructed surface has a uniform luster, optimized for lube Adhesion.

steel shot supplier in India
Blast cleaned steel decreases wear on shears, punches, and roll-formers by removing abrasive mill scale. This can allow immediate painting. Blast cleaning also excludes the need for the post-fabrication cleaning process. Shot blasting consists of attacking the surface of a material with one of many types of steel shot exporter. Usually, this is done to remove something on the surface such as scale, but it is also done sometimes to impart a particular surface to the object being shot blasted, such as the rolls used to make a 2D finish. The shot can be sand, small steel balls of various diameters, granules, etc. The device that throws the shot is either a large air gun or spinning paddles which hurl the shot of their blades.