teleren/devto huggingface dataset:
Open Authorization (OAuth 2.0)
Tags: architecture, distributedsystems, beginners, tutorial
Published: 2023-04-02 05:40:19

OAuth 2.0 is an authorization protocol that provides consented access to the available resources on behalf of the user. No user credentials are ever shared with the Open Authorization since it provides the access to the resources such as remote APIs, user data, etc. To note, OAuth 2.0 is only an authorization protocol but no authentication protocol.

## Concepts of OAuth 2.0

- **Resources Owner** — The owner of protected resources who can provide the access to them.
- **Client** — The one who requires access to the resources.
- **Authorization Server** — The one to receive a request from the client to get an Access Token. It even issues the tokens to authenticate and consent by the Resource Owner.
- **Resource Server** — Protects the resources and gets the access requests from the client to accept and validate an Access Token and return the resources as required.
- **Scopes** — Specifies the reason why the resources need to grant. It depends on the Resource server for values and related resources.
- **Access Token** — Data token with authorization to access the resources on the behalf of the client.

## How does OAuth 2.0 work?
1. The client places an authorization request to the Authorization Server with the client ID. There are scopes and an endpoint URI to send the Access Token.

2. The Authorization Server verifies if the requested scopes are allowed while also checking the authenticity of the client.

3. The Authorization Server works with Resource Owner to grant access to the scopes.

4. The Authorization Server directs back to the client with Access Token according to the type of grant. We can also expect a Refresh Token.

5. The client can use the Access Token to request access to the resources from the Resource Server.

![OAuth 2.0](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wh8n0efr064s5govyzhf.jpg)

## Does OAuth 2.0 have any disadvantages?

There are a few disadvantages to using OAuth 2.0. Let’s list them out: -

- There are no built-in security features.
- You cannot get a common set of scopes.
- There is no standard implementation.

**_I hope this article was helpful to you._**

**_Please don’t forget to follow me!!!_**

**_Any kind of feedback or comment is welcome!!!_**

**_Thank you for your time and support!!!!_**

**_Keep Reading!! Keep Learning!!!_**
Become a VIM PRO in 2023 without having to memorize ANYTHING (ChatGPT + Warp + MacOS)
Tags: chatgpt, vim, macos, beginners
Published: 2023-04-02 05:39:17

I think we can all agree that Vim is pretty intimidating and not super intuitive - especially because you need to memorize so many keyboard shortcuts just to move around. 

In this blog, I’m going to show you how I became a Vim PRO without having to memorize anything. Let’s get started!

{% embed https://www.youtube.com/watch?v=ir4ulHPfEZg %}

# So why do people use vim? 


Here are a few reasons:

1) Vim is the default editor on any operating system in the world.

2) Vim is super fast and responsive.

3) Lastly, I think there are some developers that just enjoy the challenge of mastering Vim.

# How I mastered Vim without memorizing anything


I’m using my Warp terminal on my MacOS. You’re going to need the Warp terminal to follow along. To install it, run 

`brew install warp`

in your CLI or download [here](https://app.warp.dev/get_warp).

For the purposes of this demo, I’ve created this .txt file that you can think of as a little game loosely inspired by British TV-show Taskmaster. 

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

Each line has a task that I need to follow, and we’re going to complete all these tasks using Vim keyboard shortcuts in the MOST EFFICIENT WAY POSSIBLE. 

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

To open up Warp AI, press

`^ + Space`

and then as you try to complete these tasks, ask Warp AI the bullet point questions to learn the corresponding Vim keyboard shortcuts.

1) Remove the period from the end of this line.
_I could technically just press right to get to the end of the line, but that’s not efficient!_

- “How do I navigate to the end of the line in vim”
- “How do I edit in vim”

2) Go to the last line and fill in the blank, then come back up to this line.
_I could technically just press down to get to the end of the file, but that’s not efficient!_

- “How do I navigate 3 lines down”
- “How do I navigate by word”
- “How do I delete a word”
- “How do I navigate 3 lines up”

3) Delete this entire line.
_I could navigate to the end of the line and just press backspace, but that’s not efficient!_

- “How do I delete an entire line”

4) Find and replace all instances of the word “line” with “COOKIE”
_I could do this manually, but that’s not efficient!_

- “How do I find and replace all instances of a word”

5) Please like and _____ to this channel for more tech and terminal tips!

# Conclusion

And that’s it! Hopefully this helped.
Pwoli.js - A Yii2-like framework for Node.js
Published: 2023-04-02 05:26:39

Hello all,

Introducing Pwoli.js - a NodeJS/Typescript framework that can work independently or in coordination with frameworks like ExpressJS, Hapi, etc.

The main features of Pwoli are:

- ActiveRecord ORM Pattern.

- DataProviders which facilitate providing collections of data sorted/filtered/paginated according to the current request and context.

- Widgets like GridView, ListView, etc. which are already filterable/sortable/paginatable.

- ActiveForm which is already validatable according to the Model(s) connected to it via - client-side, ajax, or page submit.

- HTML helpers for rendering dynamic UI elements in one-liners.

- Easy to set up REST APIs that are already filterable/sortable/paginatable.

- Support for ORM Adapters for connecting to any kind of Database(with SequelizeAdapter(MySQL, PostgreSQL, MSSQL, SQLite) and MongooseAdapter(MongoDB) ready out of the box)

You can understand most of the features by seeing the how-to-use GIF animations we've displayed here: https://codespede.github.io/pwoli

We are also inviting contributions to this framework in the form of Unit Tests, Bug Reports/Fixes, Feature Implementations, etc. so that you too can become a part of Pwoli!

https://github.com/codespede/pwoli

Please don't forget to 'star' the repo if you like it!
What If ... we could learn Soroban by watching a story? [Video + Blog]
Tags: soroban, stellar, smartcontract, rust
Published: 2023-04-02 04:31:20

In this post we want to explore how by giving more power to the storytelling and by showing code sections we are able to spread the word on what Soroban is and how it works. 

**Characters:**

- Bee: A brave and funny girl who dreams of finding the Golden Soroban.
- Roscoe: An adventurous and smart guy who wants to help Bee understand the ancient aliens and how Soroban changed the world.

**Story:**
Bee and Roscoe embark on an adventure to search for the Golden Soroban. Legend has it that there is a temple where ancient aliens hid the Golden Soroban. During their journey, our characters learn how this great technology changed the world for these aliens and begin to understand how it works.

**Concepts:**
In this first video, we explore what Soroban is and how a simple "Hello, World!" function works.

**Code**

Hello world function

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


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

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

Invoking Soroban function

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


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


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

**Video**

{% embed https://youtu.be/uVH3p4HjaQY %}
I need help 😵‍💫 with a 🚨coding problem. I can't seems to get it to console log the string...😩 Am I missing something here? 🤔🧐
Tags: help, javascript, beginners, jokes
Published: 2023-04-02 03:02:22


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


The code:

```
const str = 'QXByaWwncyBGb29sIQ==';

function decodeStr(str) {
  const result = atob(str);
  console.log(result)
  return result;
}


decodeStr(str);
```
Extract Ease : Extract, Compare, and Simplify CSS Styling
Tags: scrapping, webscrapping, css, stylesscrapper
Published: 2023-04-02 02:03:51

**Extract Ease** - a powerful _web scraping_ tool designed to _extract_ and _compare_ _CSS properties_ based on specific _ID_, _class name_, or _tag name_ with ease.

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

Site url : https://extractease.in/
Free 🎉 Google Certifications
Tags: webdev, beginners, python, programming
Published: 2023-04-02 01:35:37

## Introduction

- Google has recently launched a series of data science courses in order to help developers better understand the fundamentals and best practices for working with data. 

- The courses are designed to provide an introduction to the world of data science, as well as teach developers how to use Google's tools and services related to this field. 

- The first course, Introduction To Data Science With Google Cloud Platform, covers topics such as machine learning basics, big-data analytics techniques on GCP (Google Cloud Platform), SQL databases & NoSQL databases on GCP. 

- It also teaches students about cloud computing concepts like scalability & distributed systems that are essential for handling large datasets efficiently. Additionally it provides hands-on experience by using various open source libraries supported by GCP including TensorFlow & BigQuery ML (Machine Learning). 

- The second course is Advanced Data Science With Google Cloud Platform which focuses more on advanced topics such as natural language processing (NLP) algorithms; deep learning models computer vision methods time series analysis techniques etc. 

- All while leveraging existing tools available within the platform like AutoML Vision/Natural Language/Translation APIs or AI Hubs Notebooks etc.

- This will enable developers with skillset required for building sophisticated applications that can process massive amounts of structured/unstructured datasets quickly and accurately without having them write complex code from scratch. 

- Overall these two new courses from Google offer an excellent opportunity for aspiring data scientists or experienced professionals looking forward into advancing their knowledge in this rapidly growing field . 

- So if you’re interested in exploring what modern day technology offers when it comes down tackling real life problems then these two offerings should definitely be considered worth your time!


###### Google Launched 5 Free 🎉 Data Science Courses 🔥‍

🎥 {% youtube 7WL3PBEIF-0%}


### Connect with Me 😊

#### 🔗 Links

[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/mahmoud-el-kariouny-822719149/)

[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/Mahmoud42275)
Animation -21 : Solar System CSS Loading Animation
Tags: css, beginners, design, animation
Published: 2023-04-02 01:31:00

Free CSS Loading Animation for your website 

#### Solar System CSS Loading Animation 

---

{% youtube u-ksPCPcN3c %}

 ---
### [Source code](https://democoding.netlify.app/loaders/solar-system-css-loading-animation)


---

## For more information
 

1. Subscribe my Youtube Channel 
[https://www.youtube.com/@democode](https://www.youtube.com/@democode) 

2. Check out my Fiver profile if you need any freelancing work
[https://www.fiverr.com/amit_sharma77](https://www.fiverr.com/amit_sharma77)

3. Follow me on Instagram
[https://www.instagram.com/fromgoodthings/](https://www.instagram.com/fromgoodthings/)

4. Check out my Facebook Page 
[Programming memes by Coder](https://www.facebook.com/programmingmemesbycoders)

5. Linktree
[https://linktr.ee/jonSnow77](https://linktr.ee/jonSnow77)

 
---
---

{% twitter 1642235382074064896 %}
Decrement operator
Published: 2023-03-17 09:51:14

**Kamaytirish operatorining asosiy vazifasi o'zgaruvchining sonli sonini 1 qiymatiga kamaytirishdan iborat. Dasturlash tilida kamaytirish operatori “– –” belgisi bilan belgilanadi.**


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

**rule **

`Prefiks va Postfix Decrement operator pozitsiyalari bir xil funktsional qiymatlarga ega va agar ular hech qanday ifoda formatida ishlatilmasa, bir xil natijalarni beradi.`

**Example**

```
#include <iostream>
using namespace std;


int main()

{

int x = 20 ; int y = 40;

--x;

y--;

cout << x << endl << y;

return 0;
}
```

**The result**

```
19
39
```

**rule**

`O'stirish operatorlari kabi, kamaytirish operatori ham har qanday iborada operator ishlatilsa, boshqacha ishlaydi.

Agar dekrement operatori Prefiks pozitsiyasida ishlatilayotgan bo'lsa, u holda Increment funktsiyasi ifodadan oldin bajariladi.

Agar pasaytirish operatori Postfix pozitsiyasida ishlatilayotgan bo'lsa, u holda Increment funktsiyasi ifodani baholashdan keyinamalga oshiriladi.`


```
#include <iostream>
using namespace std;

int main()
{
int x =  90;
int a;
cout <<"Value of x = "<< --x << endl;

a = x--;

cout <<"Value of a = "<< a << endl;

cout <<"New Value of x = "<< x << endl;

return 0;
```

**The result**

```
89
89
88
```

**Tushuntirish**

Birinchi "cout" bayonotimizda Pre-Decrement operatori ishlatiladi. Shunday qilib, "x" qiymati 1 ga kamayadi, ya'ni x = x - 1 = 90 - 1 = 89

Keyin ‘a = x — —’ ifodasidagi “a” o‘zgaruvchisiga qiymat beramiz.

Bu shuni anglatadiki, avval "x" qiymati "a" ga tayinlanadi, keyin esa "x" 1 ga kamayadi. Demak, a = 9 chiqish, x = 88 ning yangi qiymati.
How to get the most out of your MacBook battery life?
Tags: macbook, battery
Published: 2023-04-03 15:32:35

---
title: How to get the most out of your MacBook battery life?
published: true
date: 2023-04-02 00:00:00 UTC
tags: macbook, battery
canonical_url: https://kevinhq.com/how-to-get-the-most-out-of-your-macbook-battery-life/
---

Here are the tips based on my experience to get the most out of your MacBook battery life. I’ve been doing them since eight years ago. Here’s the result: my old MacBook air battery can hold a charge after eight years. Keep your MacBook cool all the time. It is the most important. It is similar to any other electronic device. MacBook also doesn’t like hot temperatures. If you’re in a tropical zone, please use your MacBook with running air conditioning.
Credentials substitution at runtime in Python
Tags: python, codequality, security, programming
Published: 2023-04-01 23:14:24

## Introduction

Often we hear that credentials should not be hardcoded in the code or Version Control (like git). You can leverage the dynamic substitution of such credentials using Environment variables tied to the code as a variable.

## Pre-requisite
- Python 3.8 or up
- PyYaml - To read YAML configuration file

## Steps
- Create a `yaml` file as the following
```yaml
# credentials.yml

aws:
  access_key_id: "${AWS_ACCESS_KEY_ID}"
  secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
```

- We will read this `yaml` file and get the python dictionary object
```python
# main.py
from typing import Dict
import yaml

def read_credentials_file() -> Dict:
  try:
    with open("credentials.yml", mode="r", encoding="utf-8") as cred_file:
      return yaml.safe_load(cred_file)
  except yaml.YAMLError as yaml_err:
    print(f"Unable to read the file. Error: {yaml_err}")
    raise

```

- We will use the `string.Template` from the standard library to substitute the value from the environment variables
```python
# main.py
import string
import os

def substitute_creds(creds: Dict) -> None:
  creds["aws"]["access_key_id"] = string.Template(
    creds["aws"]["access_key_id"]
  ).substitute(
    {"AWS_ACCESS_KEY_ID": os.getenv("AWS_ACCESS_KEY_ID")}
  )

  creds["aws"]["secret_access_key"] = string.Template(
    creds["aws"]["secret_access_key"]
  ).substitute(
    {"AWS_SECRET_ACCESS_KEY": os.getenv("AWS_SECRET_ACCESS_KEY")}
  )
```

- Add the following two variables as part of the environment. They can be added in the `.env` file as well
```bash
$ export AWS_ACCESS_KEY_ID="abcd1234"
$ export AWS_SECRET_ACCESS_KEY="secret123"
```

## Complete Program
```python
# main.py
from typing import Dict
import string
import yaml
import os

def read_credentials_file() -> Dict:
  try:
    with open("credentials.yml", mode="r", encoding="utf-8") as cred_file:
      return yaml.safe_load(cred_file)
  except yaml.YAMLError as yaml_err:
    print(f"Unable to read the file. Error: {yaml_err}")
    raise

def substitute_creds(creds: Dict) -> None:
  creds["aws"]["access_key_id"] = string.Template(
    creds["aws"]["access_key_id"]
  ).substitute(
    {"AWS_ACCESS_KEY_ID": os.getenv("AWS_ACCESS_KEY_ID")}
  )

  creds["aws"]["secret_access_key"] = string.Template(
    creds["aws"]["secret_access_key"]
  ).substitute(
    {"AWS_SECRET_ACCESS_KEY": os.getenv("AWS_SECRET_ACCESS_KEY")}
  )

if __name__ == "__main__":
  credentials = read_credentials_file()
  substitute_creds(credentials)

  # WARNING: Never print or log credentials or any sensitive information
  print(f"Credentials: {credentials}")
```

- The above code when run should produce the following output
```bash
$ python3 main.py
Credentials: {"aws": {"access_key_id": "abcd1234", "secret_access_key": "secret123"}}
```
Create an Angular app with ESLint & Tailwind CSS in seconds
Tags: angular, tailwindcss
Published: 2023-04-01 22:53:45

## Introduction

I've started a couple of personal projects recently and have noticed just how long it takes to configure my Angular projects exactly how I want them. Installing and configuring things like Tailwind and ESLint should be quick and easy, but that's never the case. Enter [`create-angular-app`](https://github.com/joshuahills/create-angular-app).

## Why?

Nobody likes switching between projects with different TypeScript compiler options, linting rules, styling frameworks and so on, but these things are important. The process for getting a project set up with them should be frictionless. I rarely deviate from my normal project configuration of ESLint, Tailwind, removing Karma & Jasmine dependencies, and adding environment files. All of these require at least one step each after using `ng new`.

[`create-angular-app`](https://github.com/joshuahills/create-angular-app) solves this problem. It contains a template, where I've configured all of this for the last time. Now, when I want to create a new Angular application, I simply do

```bash
npm create @chimpbyte/angular-app@latest
```
and follow the simple prompts:

![create-angular-app prompts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucxs3qi5iq56y5ea72h8.png)

Easy!

## What's included?

Out of the box, you get:

- Tailwind CSS
- ESLint with the rules I find most useful
- Angular routing
- Scss for custom styling if Tailwind doesn't cover it
- No automatically generated test files when running `ng generate`
- No Karma/Jasmine dependencies installed. If you're going to unit test your application, I'd recommend [`jest-preset-angular`](https://www.npmjs.com/package/jest-preset-angular)

## Sounds cool, but can I tweak it how I like?

Yes, but not currently through the CLI. You can manually amend the angular.json file etc. I do plan to make certain elements optional (e.g. Tailwind) but feel free to [open an issue on GitHub](https://github.com/joshuahills/create-angular-app/issues) if you've got any suggestions.

I also plan to add more templates for other configurations I occasionally use. Again, please open an issue with any questions/suggestions.

## Credits

Brandon Roberts for his [create-angular-project](https://www.npmjs.com/package/create-angular-project) package which I used as a starting point.
Why Do Websites Ask for Cookies When I Open Them?
Tags: webdev, computerscience, programming
Published: 2023-04-01 22:45:19


![Website cookie meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yf813drqgag5d466c516.png)

Have you ever noticed how many websites display a pop-up message  asking you to accept their cookie policy? These prompts have become ever-present in today's online environment, but have you ever wondered why they are necessary?

First of all, cookies are small text files that a website stores on your computer or mobile device when you visit it.

Cookies are used to remember your preferences, login information, and other details about your visit to the website. They can also be used for advertising purposes, tracking your behavior, and analyzing website traffic.

![Website Cookie Meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/878b3lagd11tgev67iek.png)

When you see a cookie prompt, you are being asked to give your consent to the website's use of cookies. By giving your consent, you are agreeing to the website's terms of use and allowing it to collect your data for specific purposes.

In summary, cookies are why you can exit your browser, reopen it, and revisit a previous website without needing to log in once more.
Huge changes in Java and C# planned for April 1st!
Tags: csharp, java, design, april
Published: 2023-04-01 22:35:07

Finally, after a long discussion between C# language team and Java language team, they have decided to drop the support for the famous keyword: `new`.

```csharp
// Not a valid code anymore.  
Person p = new Person();
 
// New dependency injection syntax.  
Person p = new.Resolve<Person>();
```

**Anders Hejlsberg** and **James Gosling** both have told they are very happy about this, as it is the first time Java and C# language teams collaborate on a huge decision like this.

It is interesting to know that **Jon Skeet** has already started answering the related question on StackOverflow and gained another 200K even before the spec is fully finalized. After all, he is the only one who is a little familiar with both languages!

Rumors say that **Eric Lippert** is unhappy with this feature and is preparing a post on FAIC to describe why this was not a good decision to take.

BTW, as it is a huge breaking change and it's so difficult to notify all developers about it, **Scott Hanselman** is going to notify all developers on all planets by a tweet with his account.

As this decision is made on April 1st, the plan to deliver this feature is going to be as fast as possible for each language:

- **C#:** As Visual Studio 2023 is going to ship on April 2nd, **Mads Torgersen** himself has added this feature to the compiler and it would be shipped with Visual Studio 2023. So, you can start using it tomorrow.
- **Java:** As the compiler source code is in C++ it would take so much longer to implement. According to the plans, this feature will be released as a part of Java 25 which is planned to release somewhere in 2025.

For more detail on how this huge change would be applied on April 1st, Check this wiki page:

[New spec for 'new' keyword on C# and Java](https://en.wikipedia.org/wiki/April_Fools%27_Day)