teleren/devto huggingface dataset:
6-Nodejs Course 2023: Http Verbs
Tags: node, typescript, mongodb, fastify
Published: 2022-10-28 11:58:23

---
title: 6-Nodejs Course 2023: Http Verbs
published: true
description: 
series: Nodejs Course 2023
tags: nodejs, typescript, mongodb, fastify
#cover_image: 
# Use a ratio of 100:42 for best results.
---

## HTTP Verbs

HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs. Each of them implements a different semantic, but some common features are shared by a group of them: e.g. a request method can be safe, idempotent, or cacheable.

HTTP verbs are the methods that are used to perform different actions on the server, the most common ones are `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`.

### GET

The `GET` method is used to `retrieve data` from the server, it's the most common method used in the web, and it's used to retrieve data from the server.

### POST

The `POST` method is used to `create new data` on the server.

### PUT

The `PUT` method is used to `full/partial update` data on the server.

### PATCH

The `PATCH` method is used to `partial update` data on the server.

### DELETE

The `DELETE` method is used to `delete data` from the server.

### OPTIONS

The OPTIONS method describes the communication options for server, in simple words to know what are the available methods to connect with, usually this is used by the browser not us.

## Common usage of HTTP Verbs

The most common one is the `GET` method, it's used to retrieve data from the server, any data you might think, this is the default method when you hit a url in your browser, this request is a `GET` request.

The `POST` method is used to create new data on the server, this is the default method when you submit a form, this request is a `POST` request, its best practices when you create some sort of new resources, for example create a new post, register account, but also can be used to update or validate data for example, when submitting login form, its usually a  `POST` request.

The `PUT` method is used to full/partial update data on the server, its best practices when you make minor updates of the resource that you're updating, for example enabling or disabling account, change only name or email.

## 🎨 Project Repository

You can find the latest updates of this project on [Github](https://github.com/hassanzohdy/nodejs-2023)

## 😍 Join our community

Join our community on [Discord](https://discord.gg/vtZE9YzaFz) to get help and support (Node Js 2023 Channel).
Event-driven Microservices architecture
Tags: microservices, java
Published: 2022-10-28 11:48:11

Event-driven architecture (EDA) is a software design pattern that enables an organization to detect “events” or important business moments (such as a transaction, site visit, shopping cart abandonment, etc) and act on them in real-time or near real time.

Event-driven architecture is often referred to as “asynchronous” communication. This means that the sender and recipient don’t have to wait for each other to move on to their next task. Systems are not dependent on that one message.

An event-driven data management system is mainly practiced to drive microservices. As part of this system, one microservice broadcasts an event when anything notable happens, and then other microservices subscribe to it. This is done through an intermediary event broker, to satisfy the rising expectations of modern companies and make microservices more secure.

After receiving an event, a microservice can change its business entities, resulting in new events being published. This design pattern can be used by applications developed in any language and on any platform.

For more info: https://skolaparthi.com/event-driven-architecture/
Looking for a job in Amsterdam? 🕵️‍♂️
Tags: career, amsterdam, aws, softwareengineer
Published: 2022-10-28 11:46:08

## Looking for an exciting opportunity in the heart of Amsterdam? 
Or are you an experienced software engineer looking for a new adventure? 🕵️‍♂️

Then you're at the right address! We're currently looking for a **dutch speaking Software Engineer located in Amsterdam or willing to relocate with approx. 5 years of experience**. Experience with AWS or GCP is valued!

**Want to know more? Feel free to reach out!** **>>> zoe@pro-contact.nl**
Ultimate GoLang Beginner's Cheat Sheet
Tags: go, beginners, programming, tutorial
Published: 2022-10-28 11:29:24

When I first learned GoLang 5 years ago, I remember constantly looking up its syntax and things like printing, which was much different than Python 3's way of doing things.

So, I've put together the things I looked up the **most** during my first few months with GoLang in a handy cheat sheet. 

![ultimate-golang-beginners-cheat-sheet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jsb03g34n6kgnp69o3z.jpg)

But don't worry, I'll provide it in text for those who like blog posts. 

## Control Flow

### switch
The GoLang switch is a little different in that it must always have a `default` value. 
```
t := time.Now()
switch {
case t.Hour() < 12:
   fmt.Println("It's before twelve")
default:
   fmt.Println("It's after twelve")
}
```
### else if 
There's no `elif` here, like in Python. 

You have to write it out.

```
// else if
if num := 0; num < 0 {
   fmt.Println(num, "is negative")
} else if num < 10 {
   fmt.Printf("%d has one digit", num)
} else {
   fmt.Println(num, "has multiple digits")
}
```
## Conversions
There's no `int()` or `str()`, but here are a few ways of going about it. Personally, when going to string, I tend to use `Sprintf`

### golang bytes array to string
```
s := string([]byte{65, 66, 67, 226, 130, 172})
fmt.Println(s)
```
### golang bool to string 
```
var b bool = true
fmt.Println(reflect.TypeOf(b))
```
#### strconv
```
var S string = strconv.FormatBool(true)
fmt.Println(reflect.TypeOf(S))

```
#### Sprintf
```
B := true
str := fmt.Sprintf("%v", B)
fmt.Println(str)
fmt.Println(reflect.TypeOf(s))
```
### golang string to int
```
strVar := "100"
intVar, err := strconv.Atoi(strVar)
fmt.Println(intVar, err, reflect.TypeOf(intVar))
```
### int to string 
```
i := 10
s1 := strconv.FormatInt(int64(i), 10)
s2 := strconv.Itoa(i)
fmt.Printf("%v, %v\n", s1, s2)

```

## golang while Loops 

In GoLang there is no `while` keyword, only `for`, so to emulate the behavior of while-loops, here's how it is done.

### Like a for loop
```
// while
i := 0
for i < 10 {
   // ...
}

```

### Endless loop
```
// Endless while loop
for {
   // ...
}

```

### While true
```
// while true
for true {
   // ...
}

```

### do-while
```
// do-while
for {
   if !condition {
      break
   }
}
```

## golang Print a Struct
Thankfully there's built-in `struct` printing from the standard library. 
```
// Printing struct
type employee struct {
   name   string
   age    int
   salary int
}
emp := &employee{
   name:   "Toul",
   age:    24,
   salary: 500000, // a writer can dream
}
```
### Print without fields 
```
fmt.Printf("%v", emp)  // {Toul 24 500000}
```
### Print with fields 
```
fmt.Printf("%+v", emp) // {name:Toul age:24 salary:500000}
```

## Conclusion

Hopefully, these help you on your GoLang journey!
Timezone aware Lambda cron schedule
Tags: cloudskills, aws, serverless
Published: 2022-10-28 11:22:07

The most straightforward way to trigger Lambda function on schedule is to create scheduled Eventbridge Rule. With Eventbridge Rule, one caveat is that all scheduled events are triggered using `UTC +0` time zone. In many use cases that does not matter but there are tasks like:

* Scheduled data loading
* Backups
* Environment scans and other "housekeeping tasks"

Where working with static `UTC +0` is at least little bit annoying. You know how it goes, Lambda task that used to trigger 8:00 local time is one morning triggering 9:00 local time. 

To implement timezone aware cron scheduled Lambda, [Systems Manager Maintenance Window](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-maintenance.html) can be used. Maintenance Window is a technology overkill for such a simple task and I recommend to also check other features it offers for task scheduling. However, for now we are happy with just basic Lambda triggering.

## How to

Full Cloudformation with timezone aware Lambda trigger can be downloaded [HERE](https://github.com/markymarkus/cloudformation/blob/master/tz-lambda-cron/tz-lambda-cron.yml)

Main resources for implementation are described as follows:

```yaml
  StartWindow:
    Type: AWS::SSM::MaintenanceWindow
    Properties: 
      AllowUnassociatedTargets: true
      Cutoff: 0
      Duration: 1
      Name: CronTrigger
      Schedule: 'cron(0 18 ? * MON-FRI *)'
      ScheduleTimezone: 'Europe/Helsinki'
```
Minimum precision of `Schedule` is one minute and scheduled tasks are using `ScheduleTimezone` (here Europe/Helsinki).

```yaml
  StartTask:
    Type: AWS::SSM::MaintenanceWindowTask
    Properties: 
      Name: StartTask
      Priority: 5
      TaskArn: [__LAMBDA_FUNCTION_ARN__]
      WindowId: !Ref StartWindow
      ServiceRoleArn: !GetAtt AutomationExecutionRole.Arn
      TaskType: LAMBDA    # also STEP_FUNCTIONS
      TaskInvocationParameters:
        MaintenanceWindowLambdaParameters:
          Payload: !Base64 '{"message": "Hello World!"}'
```
`MaintenanceWindowTask` defines a task that is performed on `MaintenanceWindow` cron schedule. Outside of Systems Manager automations, `TaskType` covers integrations to **LAMBDA** and **STEP_FUNCTIONS**. Other AWS or external services can be triggered with [Systems Manager automation runbooks](https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-documents.html).

- Lambda function `Payload` must be Base64 encoded string.

## Conclusion

That's it! As Finland sets clocks back one hour in 30.10.2022, so does my Lambda cron schedule.
This Week In Python
Tags: python
Published: 2022-10-28 11:10:33


**Fri, October 28, 2022**


This Week in Python is a concise reading list about what happened in the past week in the Python universe. 


## Python Articles


- [Python 3.11.0 is now available](https://blog.python.org/2022/10/python-3110-is-now-available.html) – The release announcement of the new Python version
- [Python 3.11: Cool New Features for You to Try](https://realpython.com/python311-new-features/) – The new features in Python 3.11 with examples
- [Python 3.11 is much faster than 3.8](https://jott.live/markdown/py3.11_vs_3.8) – (but still slow compared to JavaScript or C++)
- [Build a Python Program to Fetch Data About Any Country](https://www.makeuseof.com/python-country-data-program-fetch/) – article about the countryinfo package
- [Python Charts](https://python-charts.com/) – examples of Python graphs made with matplotlib, seaborn, plotly and other packages




## Projects


- [koda-validate](https://github.com/keithasaurus/koda-validate) – Typesafe Validation
- [Twitter_Banner_Autoupdater](https://github.com/Susllike/Twitter_Banner_Autoupdater) – Twitter banner autoupdater using Tweepy Python module and the Twitter API
- [django-pgtransaction](https://github.com/Opus10/django-pgtransaction) – A context manager/decorator which extends Django's atomic function with the ability to set isolation level and retries for a given transaction
- [katara](https://github.com/hydro-project/katara) – Synthesize CRDTs from classic data types with verified lifting
- [puff](https://github.com/hansonkd/puff) – run (and extend) Python code as Rust greenlet (on Tokio)
Installing EndeavourOS on a USB flash drive that saves the changes
Tags: linux, ubuntu, tutorial, opensource
Published: 2022-10-28 11:07:29

So today I wanted to figure out how to install a linux distro onto my usb but I wanted it to be persistent(meaning it would save the changes/installations) that I would add. 

If you have any questions feel free to ask!



Firstly I had to figure out what distro I was going to install. Since I wanted something that I could customise a lot I decided to go for something arch based. I had a look at manjaro but there's a lot of controversy going on right now about manjaro so I skipped that. I also had a look at gardua but it looked to gamery for a linux setup I wanted for on the go productivity.

In the end, I chose Endeavour OS as it looked nice, user friendly, and was also arch based.

To start the preparations plug your usb flash drive into your current computer and install [rufus](https://rufus.ie/en/)(be careful though there are many fake websites with rufus)

I then installed the [Endeavour OS ISO ](https://endeavouros.com/latest-release/) and selected that as the file I wanted to flash onto the usb. I selected gpt as the partition scheme, maxed out the persistent memory, and changed the volume label to Endeavour OS and started it. After it finished(which can take a while)

Then search "boot" in the windows search thing and it should come up with "change advanced startup options" and open that. Under advanced startup press restart now. After a while there should be some options on your screen now you need to click "use a device" and then click on your usbs name.

At this point its basically the same as setting up linux normally but there is a twist. When you go to the install part once you're in the live boot(or you could just stick to the live boot if you want) be sure to select the usb instead of your actual disk as the thing you want to install onto. 

After a while you should be setup and you can enjoy your persistent usb with Endeavour OS on it!
Tips to remember latitude and longitude
Tags: map, d3, beginners
Published: 2022-10-28 11:03:05


I like coding maps, but I would always forget how to remember latitude and longitude. I would always mix them up. I tried some mnemonic techniques (like, latitudes = ladder) but none of them ever worked.

Here are a couple of tips to remember latitude and longitude.

## 1. X/Y coordinates

Tip #1: The simplest, but not the easiest, is to memorise this:

**Latitude is y and longitude is x.**


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



That’s it, Latitude is the y axis and longitude is the x axis.

I tried that but would still mix them up at times. So I came up with the next tip.

## 2. The long side of a world map

Tip #2: If you think of a world map, usually it’s a rectangle.

**The _long_ side (the largest side) is the longitude.**


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



## Orientation

The point at 0,0 is the intersection of the Equator and the Meridian of Greenwich. The greater the distance to them, the greater the latitude/longitude. East of the meridian gives you a positive longitude value, and west gives you a negative one. Same for north/south of the Equator.

For example:
Prague has a larger longitude (14.43) than Paris (2.35) because it's further east. Ergo for San Francisco having a larger value (-122) than Washington DC (-77) because it's further west.


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



Here are the rounded coordinates (in the order latitude, longitude) of some popular cities to help you.

- **London**: 51.501, -0.118. (Greenwich is in London, hence the zero longitude)
- **Sydney**: -33.865, 151.210
- **Tokyo**: 35.653, 139.839
- **Singapore**: 1.290, 103.852
- **Los Angeles**: 34.052, -118.244
- **Oslo**: 59.911, 10.758

Here's a bonus factoid for people in the UK, Edinburgh's main train station is _further west_ (55.95, -3.18) than Liverpool's (53.40, -2.97).

I hope it helps, good luck!
How to find all the symbolic links and the full path of the source?
Tags: find, symlinks, bash
Published: 2022-10-28 10:40:43

---
title: How to find all the symbolic links and the full path of the source?
published: true
description: Shell script recipe to find all the symbolic links
tags: find, symlinks, bash
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-28 10:39 +0000
---
```
for i in $(find . -type l); do 
	printf "%s;%s\n" $(readlink -f $i) $i; 
done

# To collect the output in a file
for i in $(find . -type l); do printf "%s;%s\n" $(readlink -f $i) $i; done | tee symlinks.txt
```
Advanced search dropdown
Tags: react, javascript, webdev, html
Published: 2022-10-28 10:25:42

Anyone know of a libary for advanced search dropdown something similar to image below, where you can categorize your search, searching for different subjects (tables). Thanks
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30iy5ir9nd42cadhdqq9.png)
Db2 backup & restore from AWS s3 bucket
Published: 2022-10-28 10:16:05

Take DB2 backup

```
SET BACKUP_DIR=X:\TOOLKIT
SET BACKUP_DB_NAME=<db-name>
db2 connect to %BACKUP_DB_NAME% user db2admin using db2admin
db2 backup database %BACKUP_DB_NAME% to %BACKUP_DIR% compress
db2 connect to %BACKUP_DB_NAME% user db2admin using db2admin

```

Upload it to S3 bucket 

Copy these commands into your CMD window in your toolkit to setup temporary AWS credentials
```
SET AWS_ACCESS_KEY_ID=ASIAX5DQBNBCHJH3ACFPG
SET AWS_SECRET_ACCESS_KEY=A1FmVbLlSUbjhc/ICpBAYbltPxqt+xxZUVEWzuMg
SET AWS_SESSION_TOKEN=IQoJb3JpZ2luX2VjEBIaCXVzLWVhc3QtMSJHMEUCIQC5FPRnY21VeN7IXRfHXyiiVtLAJkMV1GIVpwiR6+XZhAIgVK00+RGemL13BnCMIA4Hdxz5z0Ay2dDHg16AObSLG0UqqQMI6///////////A769869M1NDgzNjU0MDIiDPrXNyLoMHygXdKzpCr9AnrZhVF+Vgj1XR21Vl9exJjIa3txskpu1tpEPYdn7xp+mRShrpWg+a4sJxqNeFo++HwXmEDHGVa/O5UiUfLI8SdP+fYuOVDFLUXvPqwUJ7jHyd9QS8JF/RZszOjtORVpCvFFr11tYpu7DILMfMaoJh80D9sl/eu0qCPQIcp5L/J1Xa1estZotK6AOEyoHGLu0JEOzLvPF/d29LQVxZrz9Mi8lyncnsQd08kHTUIp1TtXorCYySfAwa1Gd6ZujzUIsbqOVVN94bw/v01H2An1UATVfNGbzyRILTyy/Sva+nP7F0XBC/Sje0Zngv6lj146cQ2LJkcr0dNF7IjoM7+XKNheeBzxQ4TdUQjjcVQpXV1BAwDMrfOBrfrnc9NjIf1dVTDfkIrCZNvPZ9aXi2S7usU/4Uw3lxRSwx/2x//mXHP2c/Bq0uy0XIo4tJ5c62RaEf5ZKEnX1tu5J2rPjMA3YfBkeG4jnZbWeRJZDd0dxqBB5PpCJwYspnqeL5YueDCQguSaBjrdAcwZX43xyaXp0tgC093b8Y+Ul/otqKDSG5vnhrKyJDeH5yFXGnXx+y7olsBmRne8CL4e+QfU8axi5zBzOGaP/2xf3AQpHW4jP/cHn9gxZj5kJ6+C0vHe50s8Q9mzIkZBHb1uQ18rAYKHC4n1hKiT/dmdRVS9xCG9N5Cyn1Eo5nNADMG4VNNj1d0MkZ5nI1ObPn0EnbAtLb0ShNGKeXwBZg6NHNchGzmgLk0/0CM1GTfmXbfab0dXdzvhYdbvlxniLNo7sU0vMR2cFjOChIxMUvXnuoLnbXIGGki/SpTr
REM Credentials Expiration: October 26, 2022 at 10:42:40 PM
```
Copy it from S3 bucket

```
X:
mkdir DBREST
cd DBREST
aws s3 cp s3://543548365402-ben-king/<DB2>.0.DB2.DBPART000.20221026103340.001 <DB2>.0.DB2.DBPART000.20221026103340.001
```
Restore the DB2 

```
db2 force application all
db2stop
db2start
db2 connect to <dbname> user <username> using <password>

DB2 RESTORE DATABASE WCDEV9 FROM X:\DBREST TO E: INTO WCDEV9 WITH 2 BUFFERS BUFFER 1024 WITHOUT ROLLING FORWARD WITHOUT PROMPTING
```
Array Destructuring
Tags: react, javascript
Published: 2022-10-28 10:00:00

# Introduction

I really want to create a written programming tutorial, but I don't know where to start since programming is **a big playground**. Yes, I can start *anywhere* but this is also being my problem: I can't describe *any* and *where*. The idea is just spinning around in my head for months 🤕.
I finally decided to start by defined my goal: **building MERN (MongoDB, Express.js, React.js, and Node.js) stack app**. It made me easier to create tutorial structure later.

This tutorial covers the following lessons:

1. JavaScript Refreshment for Building React App
2. React.js as frontend library/framework
3. Express.js as backend library/framework
4. MongoDB as database to store our data
5. Integrating Express.js and MongoDB

We will learn those things one by one. So this tutorial, we are not going to build ***a really*** MERN app. We only want to learn everything we need to build a MERN app. Later after we learn together in this tutorial, we are ready to build MERN app without any fundamental knowledge issues.

If you have any thoughts, feel free to catch me at

- 📧[Email](mailto:estolagi@gmail.com)
- 📱[LinkedIn](https://www.linkedin.com/in/estotriramdani)

# Array Destructuring
Desctruturing is an important concept we should know before starts building app with React.
For example, we create a function that returns an array.

```jsx
const getRandomTwoNumbers = () => {
	const numbers = [Math.random(), Math.random()];
	return numbers;
};
```

We can call this function and get each items like this:

```jsx
const numbs = getRandomTwoNumbers();
const numberOne = numbs[0];
const numberTwo = numbs[1];
console.log(numberOne, numberTwo);
```

But there is a short way to do that.

```jsx
const [numberOne, numberTwo] = getRandomTwoNumbers();
console.log(numberOne, numberTwo);
```

It is more simple, right?
You can treat `numberOne` and `numberTwo` as constant: you can name it anything you want.

So, let's do it in 👨🏻‍💻 React

You might have seen or familiar with this code snippet.

```jsx
const [name, setName] = useState('Esto');
```

We can also wrote code above like this.

```jsx
const nameState = useState('Esto');
const name = nameState[0];
const setName = nameState[1];
```

... because useState returns an array that has two lengths (it's guaranted by React). 
Array destructuring syntax made our code simplier and it can save 2 lines.

Keep code 💻 and see you in the next post! 🍻
AWS Amplify how to set user session manually
Tags: aws, amplify, angular, typescript
Published: 2022-10-28 09:50:40

Here's how I solved this problem using amazon-cognito-identity-js

const userPool = new CognitoUserPool({
      UserPoolId: 'userPoolId',
      ClientId: 'userPoolWebClientId',
    });

    const cognitoIdToken = new CognitoIdToken({
      IdToken: idToken,
    });
    const cognitoAccessToken = new CognitoAccessToken({
      AccessToken: accessToken,
    });
    const cognitoRefreshToken = new CognitoRefreshToken({
      RefreshToken: refreshToken,
    });
    const username = (cognitoIdToken.payload as any).email;

    const user = new CognitoUser({
      Username: username,
      Pool: userPool,
    });
    user.setSignInUserSession(
      new CognitoUserSession({
        AccessToken: cognitoAccessToken,
        IdToken: cognitoIdToken,
        RefreshToken: cognitoRefreshToken,
      })
    );