teleren/devto huggingface dataset:
What is JWT ?
Published: 2021-12-28 09:46:43

JSON web token (JWT), pronounced 'jot', is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Again, JWT is a standard, meaning that all JWTs are tokens, but not all tokens are JWTs.
Because of its relatively small size, a JWT can be sent through a URL, through a POST parameter, or inside an HTTP header, and it is transmitted quickly.A JWT contains all the required information about an entity to avoid querying a database more than once.The recipient of a JWT also does not need to call a server to validate the token.
**Usage**
JWTs can be used in various ways:
Authentication: When a user successfully logs in using their credentials, an ID token is returned.According to the OpenID Connect(OIDC) specs, an ID token is always a JWT.
Authorization: Once a user is successfully logged in, an application may request to access routes, services, or resources(e.g., APIs) on behalf of that user.To do so, in every request, it must pass an Access Token, which may be in the form of a JWT.Single Sign- on(SSO) widely uses JWT because of the small overhead of the format, and its ability to easily be used across different domains.
Information Exchange: JWTs are a good way of securely transmitting information between parties because they can be signed, which means you can be sure that the senders are who they say they are.Additionally, the structure of a JWT allows you to verify that the content hasn't been tampered with.
**Security**
The information contained within the JSON object can be verified and trusted because it is digitally signed.Although JWTs can also be encrypted to provide secrecy between parties, Auth0- issued JWTs are JSON Web Signatures(JWS), meaning they are signed rather than encrypted.As such, we will focus on signed tokens, which can verify the integrity of the claims contained within them, while encrypted tokens hide those claims from other parties.
In general, JWTs can be signed using a secret(with the HMAC algorithm) or a public / private key pair using RSA or ECDSA(although Auth0 supports only HMAC and RSA).When tokens are signed using public / private key pairs, the signature also certifies that only the party holding the private key is the one that signed it.
Before a received JWT is used, it should be properly validated using its signature.Note that a successfully validated token only means that the information contained within the token has not been modified by anyone else.This doesn't mean that others weren't able to see the content, which is stored in plain text.Because of this, you should never store sensitive information inside a JWT and should take other steps to ensure that JWTs are not intercepted, such as by sending JWTs only over HTTPS, following best practices, and using only secure and up - to - date libraries.
Back to BASIC
Tags: basic, history, programming
Published: 2021-12-28 09:40:50

---
title: Back to BASIC
published: true
description: Writing BASIC for the Lynx
canonical_url: https://www.funkysi1701.com/posts/back-to-basic-3c83
tags: BASIC, History, Programming
//cover_image: https://direct_url_to_image.jpg
---

{% twitter 1475139125154037760 %}

I can't remember the syntax for BASIC, luckily I have been able to find the [Manual](http://elborg.dk/books.html).

All the commands are listed inside so lets see what we can do.

The Lynx presents you with a command prompt in which you can type text. Back in the 80s we had a tape player to load programs from tape, however I don't have one today so only programs I write can be run.

PRINT - To write Hello World, you can just type PRINT "Hello World" and Hello World appears on the screen. To Write a program that displays Hello World, you just write the line number first.
```
10 PRINT "Hello World"
```
To run this you type RUN
To view the code you type LIST

To Edit a specific Line you can use Ctrl+E and type the line number, or you can just write the line out again.

CLS - This command clears the screen

INPUT N - stores text typed by the user and stores it in the variable N

GOTO N - Execution of code continues at Line Number N

The first Program I wrote with a bit of help from my boys.
```
10 CLS
20 PRINT "What is your Age?"
30 INPUT N
40 IF N>5 AND N<41 THEN PRINT "a good age" 
50 ELSE IF N<6 THEN PRINT "a spaceman"
60 ELSE IF N>40 THEN PRINT "too old"
```
My 4yo didn't like being "too young" in the original version, so my 6yo helped me change him to be a "spaceman".

Not bad and it was fun pair programming with a 6yo, all my typos were quickly spotted, and he easily understood the logic of IF/ELSE/THEN statements.

The Lynx comes from 1983 and has just 96k of memory. I am very lucky it actually still works, however I have been able to find an emulator so I can write Lynx BASIC from the comfort of my laptop. [jynxemulator](https://jynxemulator.wordpress.com/), it is also on [github](https://github.com/jonathan-markland/Jynx) but it doesn't include the ROMs so getting from the website is a better option.

The developer experience today is so much nicer than it must have been in the 1980s, however back then distractions must have been much reduced.

- No internet or google to get answers to your questions
- No Copy/Paste of text
- No Load/Save (unless you have a working disk drive or tape player!)
- No IDE
- No Build or Release process just type RUN
learn about React Lifecycle methods both in Class components and in functional components.
Published: 2021-12-28 09:38:16

First of all, why we need to understand lifecycle methods. The main reason is, we need to understand the nature of a component. And the lifecycle can help us in this regard.

Lifecycles are in simple words, the birth of a component, then necessary updates of that component, and finally the end of that component.

To break it down let’s discuss some lifecycles in class component first.
render() is the most common used lifecycle methods in class components because render() is mandatory in class components. Generally render() has to be a pure function. It means, it we function pass same parameter it will show same answers no matter how many times we run it. That is why we can not call or use states inside this render function.

Then comes componentDidMount(). This method comes when the component is constructed and is ready to render() in the UI. 
In this phase, we can call API from outside end points. This allows us to use and set states  inside our app. And also it won’t render twice while calling the api or setting state. It happens just before it renders to the ui.

The next lifecycle is componentDidUpdate(). The most common case usage for this lifecycle is, when we update anything within our state it re-renders the dom.

Lastly when we don’t need a component componentWillUnmount() lifecycle happens where the the component will be destroyed.


For functional components, the process is same but it happens inside useEffect hook. 

When we call useEffect(arg1, arg2). Where the first argument is a callback function and the second one is an array. When we render a component in the ui, the callback function runs and this is the componentDidMount() lifecycle. 
Then, to check componentDidUpdate() lifecycle, there’s two way, firstly if we don’t use anything in the second argument. It’ll always rerender for any changes detected on the component. And secondly we can conditionally render depending on the specific states or element inside our component by adding that as an array item in the second argument.

And inside useEffect we can use return statement to see the last lifecycle componentWillUnmount().
New way to define accessors and mutators in Laravel!
Tags: laravel, php, webdev, tutorial
Published: 2021-12-28 09:34:15

As you know there is a way to define [accessor and mutator in laravel](https://laravel.com/docs/8.x/eloquent-mutators#accessors-and-mutators) like below.

For example if we are in user model (App\Models\User):
###### For 'first name' Getter

```php

 public function getFirstNameAttribute($value)
 {
        return ucfirst($value);
 }
```

###### For 'first name' Settter

```php

 public function setFirstNameAttribute($value)
 {
        $this->attribute['first_name'] = strtolower($value);
 }
```

There is a new way to achieve this scenario But I must say Taylor Otwell actually mentioned it and it is quite useful and nice.

You can define both setter and getter in one single method like below:

```php

public function firstName() :Attribute
{
    return new Attribute (
        get: fn($value, $attributes) => $attribute['first_name'],
        set: fn($value) => 'first_name' => $value
    );
}

```

and that would do it as another way to define accessors and mutators both in one attribute function. If don't want to write any of these you can simply pass a null value for get/set.

Lets see two more examples for user model to cracked it down:

```php
 public function fullName() :Attribute
 {
        return new Attribute(
            get: fn($value, $attributes) => $attributes['first_name'] . ' ' . $attributes['last_name'],
            set: function($value) {
                [$firstName, $lastName] = explode(" ", $value);

                return [
                    'first_name' => $firstName,
                    'last_name' => $lastName
                ];
            }
        );
   }

    public function password() :Attribute
    {
        return new Attribute(
            get: null,
            set: fn($value) => bcrypt($value)
        );
    }
```

That's it... any questions?
Clean Up My Tweet and Report It Weekly using MongoDB Atlas Serverless Instances
Tags: atlashackathon, mongodb, githubaction, automation
Published: 2021-12-28 09:31:34

### Overview of My Submission

Mostly to automate my task to clean up my tweet and remove most of tweets that I've liked before. The cron (Github Action schedule) will report to me about how many tweets that removed in the current week. At least, I will know how many I've clicked the like button. :) The daily clean up tweet task also using Github Action.

![Like GIF](https://media.giphy.com/media/iJP0ycADVGg6eKHhiK/giphy.gif)


### Submission Category

**Automation Innovation**


### Link to Code

{% github bervProject/tweet-cleaner %}


### Additional Resources / Info

#### Tools

* Github Action
* .NET 6
* Twitter API - using [TweetinviAPI](https://github.com/linvi/tweetinvi)
* [AWS SDK Simple Email Service](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-sdk-net.html)
* [MongoDB.Driver](https://docs.mongodb.com/drivers/csharp/)

#### Screenshot

* Clean Up (Github Action)

![Clean Up Github Action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/th75embk0n1216ua41ey.png)

* Report Log (Github Action)

![Report Log Github Action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04vvgbi9yrygl1vk7fl2.png)
 
* Email Report

![Email Report](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/moyhltxbwsu6chi9odnp.png)
 
* MongoDB Serverless Dashboard

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

* Example Data

![Example Data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qx5kx9hcpxx2v84oigaw.png)
Some Backend Topics
Published: 2021-12-28 09:24:54

**CRUD Operations**
CRUD stands for create, read, update and delete. These are the four basic functions of persistent storage. Also, each letter in the acronym can refer to all functions executed in relational database applications and mapped to a standard HTTP method, SQL statement or DDS operation.
Create: create or update operations are used to add new documents into the collection. If the collection does not exists, it creates one.
Read operation: This operation reads the documents from the collection. This operation is used to take output of a query.
Update operation: It is used to update existing collection. To change or update something we need update operations.
Delete operations: To erase the documents from the collection we have to use this operations.
**JWT**
JWT, or JSON Web Token, is an open standard used to share security information between two parties — a client and a server. 
Each JWT contains encoded JSON objects, including a set of claims. JWTs are signed using a cryptographic algorithm to ensure that the claims cannot be altered after the token is issued.
**Mongoose **
Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node. js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB
**Relational database (MySql)**
A relational database is a type of database that stores and provides access to data points that are related to one another. Relational databases are based on the relational model, an intuitive, straightforward way of representing data in tables.
**Aggregation**
Aggregation refers to the process by which entities are combined to form a single meaningful entity. The specific entities are combined because they do not make sense on their own. To establish a single entity, aggregation creates a relationship that combines these entities. The resulting entity makes sense because it enables the system to function well.
When using data in the form of numerical values, the following operations can be used to perform DBMS aggregation:
Average (AVG): This function provides the mean or average of the data values.
Sum: This provides a total value after the data values have been added.
Count: This provides the number of records.
Maximum (Max): This function provides the maximum value of a given set of data.
Minimum (Min): This provides the minimum value of a given set of data.
Standard deviation (std dev): This provides the dispersion or variation of the sets of data. Let’s take a simple example of a database of student marks. If the standard deviation is high, it means the average is obtained by lower number of students than usual, and the lowest and highest marks are higher.
**Express**
Express. js is a Node. js web application server framework, designed for building single-page, multi-page, and hybrid web applications.
How-to share geospatial data on the web
Tags: mongodb, docker, opensource, geospatial
Published: 2021-12-28 09:09:02


{% youtube ahHCCoNZIJE %}

On this tutorial we will explore how to share geospatial data on the web, in a simple and efficient way. You can use the provided dataset or use your own dataset, in order to implement the pipeline to make it available with a REST API, using a stack of free and open source software.
We will conclude by exploring the deployed service using a swagger endpoint and postman, but "sky is the limit" in terms of client applications which could consume this dataset.
In order to complete this, you will only need some basic knowledge of docker and docker-compose. The links used in the tutorial are listed bellow. Have fun!🙃


[https://www.sawcer.com/](https://www.sawcer.com/)
[https://ogcapi.org/dev/features](https://ogcapi.org/dev/features)
[https://www.w3.org/TR/sdw-bp/#spatial-things-features-and-geometry](https://www.w3.org/TR/sdw-bp/#spatial-things-features-and-geometry)
[https://pygeoapi.io/](https://pygeoapi.io/)
[https://github.com/geopython/pygeoapi](https://github.com/geopython/pygeoapi)
[https://github.com/emotional-cities/pygeoapi/tree/mongo](https://github.com/emotional-cities/pygeoapi/tree/mongo)
[https://stedolan.github.io/jq/](https://stedolan.github.io/jq/)
[http://bboxfinder.com/#0.000000,0.000000,0.000000,0.000000](http://bboxfinder.com/#0.000000,0.000000,0.000000,0.000000)
[https://features.byteroad.net/](https://features.byteroad.net/)
What Are Some Romantic Short Love Poems
Published: 2021-12-28 09:00:34

Poems are one of the finest ways to express our love to our loved ones. They are a straightforward and charming method for telling your accomplice that you give it a second thought. Steady love, backing and profound respect is something that everybody couldn't want anything more than to have in a relationship. The short love poems can be really helpful for you 

In any case, insofar as individuals have strolled the earth, journalists have been utilizing shrewdly made words to portray valuable encounters. Also maybe the most widespread encounters of all have been those of heart, sentiment and deplorability and yearning. Love sonnets, regardless of how old, mix something within you. 


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

**Some Romantic Short Poems**

Here are some short love poems for you-

For You
I won't ever be able to find the words to say
How much your giggling lights up my day.
I won't ever have the option to completely spread out
How much your essence lights up my reality.

Love of My Life
I imagined that work and difficulty
Were all I would experience throughout everyday life
Until I met a young lady
Who changed my entire world
Furthermore I made her my excellent spouse.

The Gossamer
Have you at any point seen gossamer,
On a field loaded with yellow grass,
Where dragonflies swim over
The delicate breeze of summer?

Have you at any point took note
How tempting is the gossamer?
I realize that genuine romance is such
When apparent sparkling on daylight
Also lo! It disappeared!
Do you know my affection
That affection between us
Is it more apparent than that?

All I Needed
All I at any point needed
was to sit by a fire with somebody 
who needed me to measure
something very similar to my needs. 
To need to make a fire with 
somebody, with you, was all.

Riding Mountains
My adoration for you rides mountains,
So many highs and lows, feelings take off.
In any case, one thing won't ever change,
My adoration for you, I can't disregard.
There are days I feel this is excessively,
What's more I don't have the foggiest idea what to do.
However, let's be honest, who are we joking,
I need nothing else except for you.

These **[short love poems](https://mystoryonline.org/the-best-short-love-poems-for-your-girlfriend/)** can be a very romantic way to express love. Also it can be the most heartfelt method for communicating our sentiments, that are concealing somewhere inside our heart. They don't need to be long. Simply a short love sonnet can depict everything. Be it your boyfriend or girlfriend, they will be overwhelmed by these.
MongoDB CRUD Operations
Tags: webdev, mongodb, beginners, database
Published: 2021-12-28 08:33:43

MongoDB is a NoSQL database program that is a document-oriented database program. It has gained popularity as NoSQL databases are handy for working with large sets of data. Simple CRUD operations have been described below.

**Create**
To insert a single document, the insertOne() method can be used. The document object to be inserted has to be passed as the argument. If the insertion is successful, an insertedId field is appended to the object passed in the method. This value is used as the _id in the database. 

```
      const newProduct = {
	name: ‘Flormar Lipstick’,
	price: ‘45.00’,
}
      const result = await lipsticksCollection.insertOne(newProduct);
```

**Retrieve**
To retrieve a single document, the findOne() method can be used. The document to be searched has to be queried and the query has to be passed as the argument. 

```
const id = req.params.id;
      const query = { _id: ObjectId(id) };
      const product = await lipsticksCollection.findOne(query);
```

**Update**
To update a single document, the updateOne() method can be used. A filter document and an update document has to be passed as argument. The purpose of the filter document is to find the document to be updated. A third argument named options can be passed as well to specify any other options if needed. 

```
const id = req.params.id;
      const filter = { _id: ObjectId(id) };
      const options = { upsert: true };
 
      const updateDoc = {
        $set: {
          status: "Shipped",
        },
      };
      const result = await ordersCollection.updateOne(
        filter,
        updateDoc,
        options
      );
```

**Delete**
To delete a single document, the deleteOne() method can be used. The document to be deleted has to be queried and the query has to be passed as the argument. If the deletion is successful, then the deletedCount is set to 1, which can be checked to test whether the operation was successful.

```
const id = req.params.id;
      const query = { _id: ObjectId(id) };
      const result = await lipsticksCollection.deleteOne(query);
```
Everyone should be a full-stack developer
Tags: fullstack, developer, skills, hello
Published: 2021-12-28 08:33:21

In the early 2000s, the software __industry was in dire need of workers__, so specialists appeared. Like the surface technician, it was the logical consequence of strong industrialization. It is faster to __break up a project into small tasks__ given to __low-skilled workers__ than recruit full skilled workers for a project.  
Since the 2000s, therefore sectors have emerged to meet these needs and certifications to validate the skills of these low-skilled workers.  
Gentlemen, Ladies, stop procrastinating by repeating __no one can develop an electronic system and the program that fit in__, no one can write a front-end and a backend, you are only accentuating the reflect of your incompetence, __your willingness not to learn anything__ in a domain where information and learning skills are sold.  
Please, __start improving your skills__ instead of trying to do less for more...
React Hooks
Tags: webdev, react, beginners, codenewbie
Published: 2021-12-28 08:19:29

Hooks are simply functions that allow us to add lifecycle features and states to functional components.

## Rules of Hook
There are two rules that must be followed when working with Hooks
Hooks should always be called at the top level. Hooks should not be called inside loops, conditions, or nested functions. This is to ensure that after every render of the components, the Hooks are called in the same order every time.
Hooks can only be called from React functions. Hooks cannot be called from regular JavaScript functions. Therefore, they can be called from functional components and from custom Hooks.

## Basic Hooks
**useState**

```
const [state, setState] = useState(initialState);
```
This hook is used to add states to functional components. Using the initialState argument, we can provide an initial state if needed. The hook returns the current state and a function that is used to update the state. If the state is updated, the component is re-rendered.

For naming the state and its updating function, the common convention that is followed is [something, setSomething].

**useEffect**
This hook is used to perform side functions in the components, such as fetching data, subscription set up etc. It is used to make the component do something right after rendering. It runs after every render by default.

```
useEffect(()=> {
// some code }, [])
```

The optional second argument is so that the component re-renders only if the value of that argument has changed.

**useContext**
This hook is useful in avoiding prop drilling as it allows to manage states globally. The components can be re-rendered when these global states change. 

First, the context has to be created and initialized. Then the child components have to be wrapped in the Context Provider and the state value has to be supplied.

```
const UserContext = createContext()
function Component1() {
  const [user, setUser] = useState("Jesse Hall");

  return (
    <UserContext.Provider value={user}>
      <h1>{`Hello ${user}!`}</h1>
      <Component2 user={user} />
    </UserContext.Provider>
  );
}
```
After this, the user Context will be accessible in all the components.

## Custom Hooks
React also gives us the option to create our own hooks according to our needs. We may need custom hooks when we have a reusable function. The custom Hook’s name must start with “use”. Example: useStatus.