teleren/devto huggingface dataset:
Series: Implementing OpenID with Node.js, TypeScript, and MongoDB - A Step-by-Step Guide
Tags: node, mongodb, typescript, openid
Published: 2022-02-17 17:38:21

## Introduction

In this tutorial series, we will explore how to implement OpenID with Node.js, TypeScript, and MongoDB. The focus of this guide is to provide a comprehensive, step-by-step approach to building an OIDC ([OpenID Connect 1.0](https://openid.net/specs/openid-connect-core-1_0.html)) authorization server along with a web application and an API service. Through this tutorial we are going to use [panava/node-oidc-provider](https://github.com/panva/node-oidc-provider) library, which is an OpenID Certified™ OAuth 2.0 Authorization Server implementation for Node.js.

## Source Code

You can find the complete source code for this tutorial series at [ebrahimmfadae/openid-connect-app](https://github.com/ebrahimmfadae/openid-connect-app) on GitHub.

## Requirements

To follow along with this tutorial series, you should have a good understanding of **JavaScript** and be familiar with the concepts of **OpenID** or **OAuth 2.0**. Additionally, basic knowledge of **CSS**, **HTML**, **TypeScript**, and **Docker** will be beneficial.

## Setup

Before getting started, ensure that you have the following versions installed:

```
$ node -v
v18.17.1

$ yarn -v
v3.6.3

$ docker --version
Docker version 20.10.7, build f0df350

$ docker-compose --version
Docker Compose version v2.15.1
```

## Goals

- Create an authorization server based on **OpenID** protocol.
- Create an **web application** that acts as a client for authorization server.
- Create an API (**resource server**) to demonstrate accessing restricted resources by authenticated users.

## USAGE WARNING!

Please note that the code provided in this tutorial series should not be used in production without ensuring proper security measures and suitability for your specific use case.

## Ask for help or give feedback

If you need any assistance or have feedback to share, you can reach out to me through the following channels:

- Email: ebrahimmfadae@gmail.com
- GitHub: [ebrahimmfadae](https://github.com/ebrahimmfadae)
- LinkedIn: [ebrahimmfadae](https://linkedin.com/in/ebrahimmfadae)

### UPDATE #1 - 8 October 2022

> Please note that the [panava/node-oidc-provider](https://github.com/panva/node-oidc-provider) repository has disabled its issue section, which raises concerns about the project's maintenance. Additionally, critical bugs have been observed that require delving into the source code for resolution. While the repository may still serve the purpose of learning the OIDC protocol, caution is advised when using it.
DevBox 1.4.0 & 1.5.0 🎉
Tags: webdev, programming, tutorial, startup
Published: 2022-02-17 17:31:27

Hi 👋

It's been a while since I posted an update here, so I'm excited to announce that [DevBox](www.dev-box.app) 1.4.0 and 1.5.0 is out! 

> DevBox is a desktop application / browser extension / web application of useful tools for developers. If you are curious, check out the [introductory post](https://dev.to/gdotdesign/devutils-everyday-utilities-for-the-everyday-developer-4m) and [website](www.dev-box.app).

## Syntax Highlighting

All content in textareas are syntax highlighted (using Monaco Editor) when appropriate 🎉

![Syntax Highlighting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnu14h4q5fnf57w1xr16.png)

The old plain textareas are still an option which can be toggled in the settings page.

## New Dashboard

The dashboard has been redesigned, instead of colors there are now icons for each tool:

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

This gives the dashboard a modern unifined look.

## New Tools

There are **3 new tools** in these releases:

- Added **CSS Formatter** tool.
- Added **CSS Minifier** tool.
- Added **Unit Converter** tool.

![Unit Converter Tool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npe8bmgsto8gchm525s8.png)

## Behind the Scenes

Development wise, the hardest part here was to implement Monaco Editor. Since it uses its own loader, there was a conflict with third party JavaScript.

There is no good way of resolving this unless we use ECMAScript modules, which is not really an option for DevBox.

The solution here was to manually patch the third party JavaScript.

------

Let me know your feedback in the comments 🗨️ 🙏
Python
Published: 2022-02-17 17:27:45

**Sumário**
<a href="#text1">- Consulta CEP</a>
<a href="#text2">- Editor PDF</a>

---

**Consulta CEP**<a name="text1"></a>

O código abaixo interage com o navegador Chrome ao relizar a consulta do CEP dentro do site dos correios, colando e clicando nos botões da página.

E com o Resultado as informações são inseridas em uma planilha.

Nesse exemplo consulto 25 cep's, que trouxe o resultado em 18s
```
from playwright.sync_api import sync_playwright
import openpyxl

# Carregando arquivo
book = openpyxl.load_workbook('base_cep.xlsx')
# Selecionando uma página
planilha = book['Planilha1']
cep = []

for rows in planilha.iter_rows(min_row=2,max_row=26,min_col=1,max_col=1):
    cep.append(rows[0].value)


with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    j = 2
    for i in cep: 

        page.goto("https://buscacepinter.correios.com.br/app/endereco/index.php")
        # page.wait_for_timeout(1000)
        # Colar o CEP name = "endereco"
        page.fill("input[name='endereco']",i)
        # page.wait_for_timeout(1000)
        # Clicar no botão buscar name="btn_pesquisar"
        page.click("button[name='btn_pesquisar']")
        # page.wait_for_timeout(1000)
        planilha['B' + str(j)] = page.text_content("td[data-th='Logradouro/Nome']")
        planilha['C' + str(j)] = page.text_content("td[data-th='Bairro/Distrito']")
        planilha['D' + str(j)] = page.text_content("td[data-th='Localidade/UF']")

        print(page.text_content("td[data-th='Logradouro/Nome']"))
        print(page.text_content("td[data-th='Bairro/Distrito']"))
        print(page.text_content("td[data-th='Localidade/UF']"))

        j = j + 1
book.save('base2.xlsx')
```

Planilha que é utilizada:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezfcqj6rifs0e7qqbhhi.png)
VBA
Published: 2022-02-17 17:27:00

**Transformação de TXT em Excel**

Existia um código vba que realizava o tratamento de arquivo TXT e transformava em Excel. Porém como existiam vários TXT denominados com UF era necessário executar o código em cada UF repetindo os passos cerca de 15 vezes.

Foi aproveitado e modificado de outro código vba que realizava o mesmo trabalho só que para estrutura de arquivos diferentes.

Em resumo o arquivo TXT em análise era separado por quantidade de caracteres já ou outro separado por ;. Então modifiquei a estrutura do código e adicionei também os formatos de colunas.

Com isso o código agora com um loop já faz o trabalho nos 15 arquivos e já empilha.

Veja como o código ficou:
What exactly is NFT? Begginer intro to NFT.
Published: 2022-02-17 17:10:56

You all have been heard about NFT, right?
If not, Don't worry. This post is for you. In this post You can know more about NFT. But before that, we need to know about Crypto Currency.

Crypto currency is a digital currency which doesn't rely on banks. It is monitored and organised by using peer-to-peer network called BlockChain.
For ex. - Buying, selling and trading Bitcoin, Ether, Litecoin, Dogecoin etc.

Now you know CrytoCurrency. But what about NFT? NFT is also known as Non-fungible Token. It is the trading and selling of Images, Videos and Audios online. It is also a type of Cryptocurrency. It is maintained by Blockchain UI/UX. It is mostly like a image museum online. It is published in websites like Openseas etc.

**I am talking as a begginer friendly method. I am not saying the whole concept but many people don't know the concept. I am writing this for those people.**

          _The danger part!?!_
We can upload, Sell and trade NFT's but If it's on Web browsers, You can just right click and save the image and re-upload for a greater price. EASY!!!. But here comes the BlockChain UI/UX. 

It ensures that nothing like that happen.
It's mostly like a security system. So that's the concept. I am not talking the full NFT. It's just the concept.
Blog post 12 Compound & Complex Conditions
Published: 2022-02-17 17:10:46

In today's blog, I decided with the help of my mentor Gino, I needed to go back to understanding Ruby a bit more because I was having a very difficult time with Ruby on Rails.  Sometimes you have to take a step back...

The learning goals for this specific lesson I was working on were as follows,

1. Explore the Truth Table & the Precedence
2. Practice expressing & evaluating complex conditions
3. Practice making parse trees

The truth table was easy to understand in the ADA curriculum because of an example they gave.  I flipped that using my own experience in Djing.  If I need to dj at an event I would need my turntables and mixer. This is an && (and) example. Understanding the truth table and precedence is like understanding what goes in order as far as executing a math equation, well that is how I try to comprehend.

I have learned that operations that have a higher precedence in the operations are evaluated before the operations with the lower precedence.  This list from highest to lowest in precedence form helped in understanding how this operates.  

```true && true   # => true and true is true
true && false  # => true and false is false
false && true  # => false and true is false
false && false # => false and false is false

true || true   # => true or true is true
true || false  # => true or false is true
false || true  # => false or true is true
false || false # => false or false is false```
Target#5 CSS Battle
Tags: javascript, webdev, beginners, css
Published: 2022-02-17 17:02:31

_Hey guys👋,
  I am back with the **CSSBattle** Series✨!_

This article is for [Target#5 "Acid Rain"](https://cssbattle.dev/play/5) on [CSSBattle](https://cssbattle.dev/)

![Target5 Acid Rain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9ky8r3fiznzukt0xmg5.png)
 

####The best approach I could come up till now is stated below.

```css
<p id="a"><p><p id="b">
<style>
body{margin:74 20;background:#0B2429;
display:flex}
p{
width:120;height:120;
background:#998235;
border-radius:50% 0 50% 50%}
#a,#b{
background:#F3AC3C;
transform:translate(60px,60px)}
#b{
transform:translate(-60px,-60px) rotate(180deg);z-index:-1
```

**This was my shortest solution condensing to 267 characters.**

Comment down your way of doing the same.
Stay Tuned for daily updates regarding all the challenges on CSSBattle.


###Want to connect?
[You can connect with me here](https://linktr.ee/prakhartandon)
Latest Govt Jobs Online in India
Tags: job, governmentjobs, jobsalert
Published: 2022-02-17 16:59:03

Hello
If you searching a job posting website then you can visit [Government Jobs](https://governmentjobonline.in) or [Government Job Alert](https://play.google.com/store/apps/details?id=com.governmentjobonline)
This Websites is best and fastest update job posting website.
Here you see Latest Job, Result, Admit Card, Answer Key, Admission Section and so on.
Ability Is Nothing Without Opportunity.
Thanks You🙂
Find a Farmers Insurance Agent Near Me via Hitting single click
Tags: insurance
Published: 2022-02-17 16:58:30

Find the closest Farmers Insurance Agent Near me to help with all your insurance needs. For questions, filing claims, or picking policies. If you are consistently finding the best [farmers' insurance agent near me](https://www.insurancedesire.com/insurance-agent-near-me/
) Just click on the link that we have provided in this section and get in touch with the farmers' insurance agent near me instantly
https://www.insurancedesire.com/insurance-agent-near-me/
Just find out Freeway Insurance Near Me Clicking single click
Tags: insurance
Published: 2022-02-17 16:56:21

Are you finding Freeway Insurance Near Me but still did not get anyone? Then do not worry about it here in this section you can reach with best [Freeway Insurance agent](https://www.insurancedesire.com/freeway-insurance/). Car insurance quotes from Freeway Insurance are fast, free, and easy.  It provides services in Hundred of Locations. Hundreds of Locations with bilingual agents to serve you. Just follow out the link that we have provided here to get in touch with Freeway Insurance Near Me.
https://www.insurancedesire.com/freeway-insurance/
Compare rust vs nodejs script runtime
Tags: rust, node, javascript
Published: 2022-02-17 16:54:45

Hello my folks
Nice to see your eye[s] :)
I am graduate at communication engineer, now for near 2 years I am Nodejs and Python developer. Recently I had a thought that is If I learn a low level language among a those high level languages, may help me to extend my insight to computer science. SO I started to learn Rust.
In one of my nodejs program, I read a file include 5131 hexadecimal string and convert them to binary, then the bin number split to 5 separate bin noms and convert each one to decimal.

No for my first rust program, I implement this with rust and compare the runtime of bot javascript and rust program.

this is the rust program:

```
use std::fs;
use to_binary::BinaryString;

pub struct ParsedEpc {
    pub header: u64,
    pub partition: u64,
    pub filter: u64,
    pub item_number: u64,
    pub serial_number: u64,
    pub company_name: u64,
}

fn main() {
    let contents = fs::read_to_string("splitted.txt")
        .expect("Wrong to read from file")
        .replace("\"", "");
    let splitted: Vec<&str> = contents.split(",").collect();

    println!("{} epcs found", splitted.len());

    for epc in splitted {
        parse_data(epc);
    }
}

fn parse_data(epc: &str) -> ParsedEpc {
    let decoded_str = BinaryString::from_hex(epc).unwrap().to_string();
    let radix: u32 = 2;
    ParsedEpc {
        header: u64::from_str_radix(&decoded_str[0..8], radix).unwrap(),
        partition: u64::from_str_radix(&decoded_str[8..11], radix).unwrap(),
        filter: u64::from_str_radix(&decoded_str[11..14], radix).unwrap(),
        company_name: u64::from_str_radix(&decoded_str[14..26], radix).unwrap(),
        item_number: u64::from_str_radix(&decoded_str[26..58], radix).unwrap(),
        serial_number: u64::from_str_radix(&decoded_str[58..], radix).unwrap(),
    }
}
```


this is the js program:

```
const fs = require('fs');

fs.readFile('splitted.txt',"utf-8", (err, data) => {
  if(err) throw err;

  const epcList = data.split(",");
  
  console.log(epcList.length,"epcs found");
  
  epcList.forEach(epc => {
    parseEpc(epc);
  });
});

function parseEpc(epc) {
  const bin = parseInt(epc, 16).toString(2);
  return {
      header: parseInt(bin.slice(0, 8), 2).toString(10),
      partition: parseInt(bin.slice(8, 11), 2).toString(10),
      filter: parseInt(bin.slice(11,14), 2).toString(10),
      itemNumber: parseInt(bin.slice(14, 26), 2).toString(10),
      serialNumber: parseInt(bin.slice(26, 58), 2).toString(10),
      companyName: parseInt(bin.slice(58), 2).toString(10),
    }
}
```

this is the runtime result:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lvk8x61lyblci3z77rf.jpeg)


the rust is faster about 4x.
That is so interesting for me to create a lib in rust and use them in nodejs program.
Nested requirements.txt in python
Tags: python
Published: 2022-02-17 16:46:19

---
canonical_url: https://waylonwalker.com/til/python-nested-requires/
published: true
tags:
- python
series: til
title: Nested requirements.txt in python
---

python requirements text files can in fact depend on each other due to the fact that you can pass pip install arguments right into your
`requirements.txt` file.  The trick is to just prefix the file with a
`-r` flag, just like you would if you were installing it with `pip
install`

## try it out
Lets create two requirements files in a new directory to play with.

``` bash
mkdir requirements-nest cd requirements-nest touch requirements.txt requirements_dev.txt
```

Then add the following to each requirements file.

``` txt
# requirements.txt
kedro[pandas.ParquetDataSet]
```

```txt
# requirements_dev.txt
-r requirements.txt
ipython
```

## Installing

Installing requirements_dev.txt will install both ipython and pandas since it includes the base requirements file.

``` bash
# this will install only pandas
pip install -r requirements.txt

# this will install both ipython and pandas
pip install -r requirements_dev.txt
```

## Links

This is covered in the [pip user guide](https://pip.pypa.io/en/stable/user_guide/), but it is not obvious that this can be done in a requirements.txt file.
How to run Node app in Kubernetes
Tags: tutorial, kubernetes, docker, node
Published: 2022-02-17 16:24:10

## Summary

We can follow these main steps to run our Node app in [Kubernetes](https://kubernetes.io/). In this post, I use [Docker](https://www.docker.com/) as the container runtime for Kubernetes.
 1. Write the app in Node.js.
 2. Write a Dockerfile and build a Docker image from it.
 3. Push the image to Docker Hub.
 4. Use the image above to create a Kubernetes Deployment.

## Step 1: Write the app in Node.js

To make it simple, I wrote a web app using Express, which has only one API Endpoint:

```javascript
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;

app.use(express.json());
app.get("/greeting", (req, res) => res.send({ message: "hello" }));

app.listen(port, () => console.log(`server listens on port ${port}`));
```

## Step 2: Build a Docker image

We can use the `Dockerfile` below to instruct Docker to build a container image for our app:

```dockerfile
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "node", "server.js" ]
```
We also need a `.dockerignore` file so Docker will not copy unnecessary files to our image.

```
node_modules
.DS_Store
npm-debug.log
```

Now let's build the image by running this command. (`<your username>` is your username on Docker Hub)

```
> docker build . -t <your username>/myapp
```

## Step 3: Push the image to Docker Hub

The image is now created. Assume you have already had a [Docker Hub](https://hub.docker.com/) account. You can log in using:
```
> docker login
```

We can now push it to Docker Hub:

```
> docker push <your username>/myapp
```

## Step 4: Run the app in Kubernetes

I use [minikube](https://minikube.sigs.k8s.io/docs/) to set up a local Kubernetes cluster for testing purposes. If you are interested, you can follow the instruction on its homepage to set up on your machine.
So now we have a Docker image on Docker Hub, we can use it to create a Deployment:

```yaml
# file deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: myapp
          image: <your username>/myapp
          ports:
            - containerPort: 3000
```
Create the deployment by executing

```
> kubectl create -f deployment.yml            
```
Check if your pod is running
```
> kubectl get pod -l app=myapp
NAME                                READY   STATUS    RESTARTS   AGE
myapp-deployment-54865d44bf-h8t9r   1/1     Running   0          18m
myapp-deployment-54865d44bf-llsfs   1/1     Running   0          18m
myapp-deployment-54865d44bf-p7dkq   1/1     Running   0          18m
```
Check the log:
```
> kubectl logs myapp-deployment-54865d44bf-h8t9r myapp
server listens on port 3000
```
I'm here for some reason ...
Published: 2022-02-17 16:22:36

Hay all,
When I was a degree student in 2017, I created my first project using C# for my academic proposal, and I also created another one for my friends. Actually, that was my first and last project I did in my programming life.
After I successfully "failed out" of my degree course, I tried a lot to get a job in the IT sector. Unfortunately, every company rejects my applications because I don't have a degree certificate to showcase on my resume and because I don't have good communication skills in English. Finally, I was placed in an automobile showroom as a sales executive.

Now I quit my job at that company two months ago to finish my graduation, and I want to try new things in programming and learn more.
Creating custom cursors for your website
Tags: css, beginners, design, webdev
Published: 2022-02-17 16:12:46

Hi!

In this quick tutorial, I'll show you how you can create custom cursors with just images and a few lines of CSS code.

**Screenshot:**
![Example Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u1puhtm5o7thc93smde.png)

## The Cursors:

We need at least one custom cursor image. You can literally use any image in a format the browser supports. For example, I've used the SVG format.

![The three cursor images](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdtfg3msfg3ntdq0eiel.png)

**I've got three images:**

* default.svg
* pointer.svg
* text.svg

**These will replace the following states:**

* Default.
* Pointer.
* Text.

## The HTML code:

For this example, I have chosen three places to use my custom cursors:

* The body: <body>
* A heading: <h1>
* A button: <button>

**In the HTML code, you can add the following:**

```html
   <body>
      <h1>CSS Custom Cursor Demo<h1>
      <button>Custom Button</button>
   </body>
```

**NB:** The text within the tags can be literally anything.

## The CSS Code:

The CSS code is where everything really happens. We only need one property for each element, as follows:

```css
body {
   cursor: url('default.svg'), auto;
}

h1 {
   cursor: url('text.svg'), text;
}

button {
   cursor: url('pointer.svg'), pointer;
}
```

And that's it! Check out a recorded demo of this tutorial in action below:

{% embed: https://youtu.be/DQyclZvOL7g %}
How to set up Typescript with Express JS
Tags: typescript, node, beginners, tutorial
Published: 2022-02-17 16:08:13

Today I'm going to show you how to create an Express js project with Typescript as fast as possible.

follow these steps: 

- Create the project folder and navigate to it by running the following commands:
`mkdir express-typescript`
`cd express-typescript`


- Initiate the project:
`npm init -y`

- Install these dev dependencies (Note the `-D` flag)
`npm i typescript ts-node @types/node @types/express -D`

Your `package.json` should have this inside: 

```json
"devDependencies": {
    "@types/express": "^4.17.9",
    "@types/node": "^14.14.20",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3"
  },
```

- Now initialize typescript:
`npx tsc --init`
the command will create a `tsconfig.json` file. The file will contain the configuration for typescript. The ones we're interested in are:

- **target**: this specifies wich ECMAScript version is used in your project, default to `es2016`

- **module**: specifies which module is used to generate javascript code, defaults to `commonjs`, You can choose each of this:  `none`, `commonjs`, `es2015`, `es2020`, or `ESNext`.
- **outDir**: specifies the output location of the vanilla javascript code. It's commonly used to place it inside the `build` folder: `"outDir": "/build/"`
- **rootDir**: specifies the location of the typescript code, default to `./`
- **strict**: enable/disable the strict mode, default to true

You're now done ! after you finish your project you can run the command `npx tsc`. 

Alternatively , You can create a script to run the command, In your `package.json` inside the `scripts` object type: 
```json
"scripts": {
	"build": "npx tsc"
}
```



I hope this post was helpful. Happy coding!
Thoughts on NFTs?
Published: 2022-02-17 15:35:20

I've been following the NFT scene loosely since September and I have a basic understanding of what it has to offer, the advantages, and of course the disadvantages that the mainstream internet user base always talk about (they are very passionate I'll tell you that). I'm not a NFT maximalist by any means. I'm just someone who is very intrigued by the technology and its current and future uses.
Curious what my fellow developers think about the it.
Let's have an educated back and forth!