teleren/devto huggingface dataset:
Authenticate jwt token in Apollo server express
Tags: node, apollo, express, graphql
Published: 2020-08-25 12:26:21

---
title: Authenticate jwt token in Apollo server express
published: true
description: verifying token in apollo server express. access request props in resolvers. getting the request parameter in a resolver 
tags: #node #apollo #express #graphql
cover_image: https://miro.medium.com/max/700/1*-wkWT6Xe6qXYIuSJZt1jEg.jpeg
---


The hard thing for newcomers to get familiar with the specific technology as it requests a lot of time and patience and hard work, to stay ahead in the curve we have to do that! 

Authenticate the user to log him in, we need to verify the token JSON web token(JWT), in the tradition GraphQL we had access to request argument, but in the Apollo server we have context instead, by default context doesn't give any argument, so let go ahead and create!

# context API

```javascript
import Auth from './Auth.ts'
const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: Auth,
});
```

The `Auth` is the function we haven't created yet, let jump into that!

```javascript
// Auth.ts

import jwt from "jsonwebtoken";

export default (request: any) => {
  const header = request.req.headers.authorization;

  // not found
  if (!header) return { isAuth: false };

  // token
  const token: any = header.split(" ");

  // token not found
  if (!token) return { isAuth: false };

  let decodeToken: any;

  try {
    decodeToken = jwt.verify(token[1], privateKey);
  } catch (err) {
    return { isAuth: false };
  }

  // in case any error found
  if (!!!decodeToken) return { isAuth: false };

  // token decoded successfully, and extracted data
  return { isAuth: true, userId: decodeToken.userId };
};

```

This is the logic to verify the token, does it a valid token, if so, extract the `userId` and set `isAuth` to `true` so we can then make a condition on resolver if `isAuth` is `true`, proceed the code execution, if not throw an error.

now the `isAuth` can be accessed in any resolvers:
```javascript
  login: async (parent: any, args: any, context: any, info: any) => {
    if (!context.isAuth)
      return {
        error: true,
        message: "Token doesn't find!",
      };

     // your code here....
  },
```


That's pretty much it! 

let me know if this helped you or you come with a good solution. thanks for reading coming along with me!

you can follow me on Github Profile: https://github.com/lifeeric

### Resources:

[https://www.apollographql.com/docs/apollo-server/api/apollo-server/](https://www.apollographql.com/docs/apollo-server/api/apollo-server/)
[https://www.apollographql.com/docs/apollo-server/data/resolvers/](https://www.apollographql.com/docs/apollo-server/data/resolvers/)
7 Practical Tips for Better Microcopy
Tags: design, ux, writing
Published: 2020-08-25 12:25:21

---
title: 7 Practical Tips for Better Microcopy
published: true
description: Good microcopy is one of the fastest ways to improve an interface.
tags: design, ux, writing
canonical_url: https://uxtools.co/blog/7-practical-tips-for-better-microcopy/
//cover_image: https://direct_url_to_image.jpg
---

Good microcopy is one of the fastest ways to improve an interface. Try doing an audit on your UI with these tips to see how it stands up.

## 1) Use personal pronouns

Address the reader instead of just talking out loud. Use the word _you_. People pay more attention when you talk directly to them.

![Use personal pronouns](https://learnuxd.io/img/7-tips-for-better-microcopy/post1.png)

## 2) Start with a verb

Names for interactive elements should begin with an action verb. The same goes for important copy. Starting with a verb is more direct and engaging.

![Start with a verb](https://learnuxd.io/img/7-tips-for-better-microcopy/post2.png)

## 3) Prevent concerns

Point out concerning actions before your user can worry about your motives. Be transparent—make sure they understand what they’re doing and why.

![Prevent concerns](https://learnuxd.io/img/7-tips-for-better-microcopy/post3.png)

## 4) Use natural language

Write conversationally, like you’re one-on-one. Be professional but get rid of jargon. Use familiar, simple words with a friendly, relaxed tone.

![Use natural language](https://learnuxd.io/img/7-tips-for-better-microcopy/post4.png)

## 5) Default to active voice

Most of the time, active voice is the way to go. It’s easier to understand than passive voice, feels more personal, and is often shorter and stronger.

![Default to active voice](https://learnuxd.io/img/7-tips-for-better-microcopy/post5.png)

## 6) Show useful error messages

Avoid negative, threatening, or overly technical words. Be friendly, show empathy, take the time to explain what’s going on, and be helpful.

![Show useful error messages](https://learnuxd.io/img/7-tips-for-better-microcopy/post6.png)

## 7) Write iteratively

We write code iteratively, so why everything else? Things probably won’t be perfect the first time around. Test, refine, ship again. It adds up.

![Write iteratively](https://learnuxd.io/img/7-tips-for-better-microcopy/post7.png)

Thanks for reading. If you enjoyed the article, sharing on Twitter is really appreciated:

{% twitter 1298228761771552773 %}
Firefox Add-Ons - Netflix clean interface
Tags: javascript
Published: 2020-08-25 12:14:26

Hi guys,
I developed an add-on for <b>Netflix</b> users.

It offers a clean interface.
* Keep watching closes its episode.
* Closes large banners.

<h2>Example</h2>
<b>Add-Ons InActive</b>
<img src="https://addons.cdn.mozilla.net/user-media/previews/thumbs/243/243569.png"/>

<b>Add-Ons Active</b>
<img src="https://addons.cdn.mozilla.net/user-media/previews/thumbs/243/243570.png"/>

<b>Firefox add-ons Link:</b> https://addons.mozilla.org/tr/firefox/addon/netflix-clean-interface/

<b>Github link:</b> https://github.com/semihcelikol/addOnsNetflixCleanInterface
Data warehouse schema design - dimensional modeling and star schema
Tags: database, aws, tutorial, architecture
Published: 2020-08-25 12:13:59

[Original post for Data warehouse schema design - dimensional modeling and star schema in my blog](https://snir.dev/talks/data-warehouse-schema-design)

{% youtube fpquGrdgbLg %}

Introduction to data warehouse schema design: In this talk, I walk through the basics of dimensional design using the kimball group approach.

Amongst other things, I cover:

- OLAP systems vs OLTP systems
- Third normal form of operational DB
- What is a dimension
- What is a fact
- Star schema
- Dimension grain
- Surrogate keys
- Slowly changing dimensions
Daily Developer Jokes - Tuesday, Aug 25, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-08-25 12:00:27

---
title: "Daily Developer Jokes - Tuesday, Aug 25, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Tuesday%2C%20Aug%2025%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258b2d77d4.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What's the second movie about a database engineer called?

___A:___ The SQL.
 -->
Terraform CLI shortcuts
Tags: terraform, cli, automation, bash
Published: 2020-08-25 11:56:48

I want to share some CLI shortcuts I use day-to-day to simplify and speed-up my Terraform workflow.
This works for any bash-compatible interpreter.

In order to use any of described aliases of functions, you need to place it in your `~/.bashrc` or `~/.zshrc` file (or any other configuration file you have for your shell). 
Then just source this file, for example: `source ~/.zshrc`

### Function: list outputs and variables of given module
You need to provide the path to module directory and this function will list all declared variables and outputs module has. Comes very useful when you don't remember them all and just need to take a quick look.

```bash
# TerraForm MOdule Explained
function tfmoe {
  echo -e "\nOutputs:"
  grep -r "output \".*\"" $1 |awk '{print "\t",$2}' |tr -d '"'
  echo -e "\nVariables:"
  grep -r "variable \".*\"" $1 |awk '{print "\t",$2}' |tr -d '"'
}
```

Example usage:
```bash
user@localhost $: tfmoe ./module_alb

Outputs:
	 alb_arn

Variables:
	 acm_certificate_arn
	 lb_name
	 alb_sg_list
	 subnets_id_list
	 tags
```

###Function: pre-fill module directory with configuration files
You need to provide a path to the module directory and this function will create a bunch of empty 'default' .tf files in it.
```bash
#TerraForm MOdule Initialize
function tfmoi {
  touch $1/variables.tf
  touch $1/outputs.tf
  touch $1/versions.tf
  touch $1/main.tf
}
```

Example usage:
```bash
user@localhost $: mkdir ./module_foo && tfmoi $_

user@localhost $: ls ./module_foo
main.tf      outputs.tf   variables.tf versions.tf

```

### Aliases
The purpose of these aliases is just to keep you from typing long commands when you want to do a simple action.
```bash
alias tf='terraform'
```
```bash
alias tfv='terraform validate'
```
```bash
alias tfi='terraform init'
```
```bash
alias tfp='terraform plan' 
```

This one is useful because it makes format tool to go in-depth (recursively) through directories.
```bash
alias tfm='terraform fmt -recursive'
```

Example usage:
```bash
user@localhost $: tfm 
module_ecs_cluster/ecs.tf
module_alb/alb.tf
```
Power of window object in javascript
Tags: javascript, react, productivity, webdev
Published: 2020-08-25 11:47:42

Most of the time we are working on javascript framework or vanilla js and using some third party library. To debug we either use `console.log` for that library utility or use debugger to see what is the value. The problem with this is you can't really test on the go. That is you can't try different input faster. You have to do it manually in your code. For example:

Consider you are using using [date-fns](https://date-fns.org/) for your project. And you want to test its one function lets say it is: 
```
formatDistance(subDays(new Date(), 3), new Date())
//=> "3 days ago"
```

Now you want to track what will be shown if the number is `23` you have to do it manually in code to check all this thing.


Today I will let you know another way to explore these function call on the go. i.e `by accessing window object`

Things need to do:
1. Assign function to window object i.e
**Note**: For this case I am using format Distance you can set any name and any other function
```
window.formatDistance = formatDistance
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bowvv9tu49bpv8qdq6q9.png)

2. Now you can access this function using window object

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3hvo55csz0mh3emko0rr.png)

3. Now you can play with in browser console. No need to go to and from with code editor

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yivdekzmsk3w8p83x0qz.png)


If you want to test in now how it works. Here is the link. Open your browser console and play with it: [link](https://codesandbox.io/s/brave-river-5wvjb?file=/src/App.js)

**Note:** 

1. This is for debugging purpose. Do not ever deploy this to on production may lead to security threat. Apart from this remove once your debugging is done otherwise if you keep adding consistently it may cause memory overflow issue as well.
2. Also use some identifier like this `window.__identifierName__` so that you will always remember that this is your creativity. So that you can remove it later easily 😛 (Thanks @TiagoDias for mentioning this)
Microsoft Windows Automation with Ansible
Tags: microsoftwindowsautomation, ansibletrainnginkochi
Published: 2020-08-25 11:40:50

Discover ways to automate administration on Windows Server to enable your DevOps workflow using Red Hat Ansible Automation(DO417). To know more, Visit :  [STEPS KOCHI-Microsoft Windows Automation with Ansible](https://www.stepskochi.com/windows-automation-with-ansible)
How to Use Excel POWER Function in Office 365? – [with Examples]
Tags: excelfunctions, excelpowerfunctionin
Published: 2020-08-26 03:34:41

---
title: How to Use Excel POWER Function in Office 365? – [with Examples]
published: true
date: 2020-08-25 11:39:38 UTC
tags: ExcelFunctions,ExcelPOWERFunctionin
canonical_url: https://geekexcel.com/how-to-use-excel-power-function-in-office-365-with-examples/
---

## Excel POWER Function:

![POWER Function](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/POWER-Function.png)<figcaption id="caption-attachment-12580">POWER Function</figcaption>

In this tutorial, we will guide you to know the usage of **Excel POWER Function in Office 365** with its syntax, explanation, and examples. Let’s see them below!! Get an official version of **MS Excel** from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)


## POWER Function – Explanation:

- This function **returns a number that is raised to a given power**.
- For example, **POWER(2,3)** returns the value **8**.

## Syntax:

**=POWER(number, power)**

### Argument Explanation:

**Number** – The base number. It can be any real number.

**Power** – It is the exponent to which the base number is raised.

### Note:

- The exponent operator “ **^** ” can be used to raise a number. For example ( **2^2** ) returns **4**.
- If any argument is a non-numeric value (letters and special characters) and then it returns **#VALUE!** Error.

## Examples:

Let’s see some examples below.

### Example 1:

- Refer to the below example image.
- Here we have given the input numbers in **Column A** , and its powers in **Column B**. The input numbers that are raised to a given power using POWER Function are listed in **Column C**.

![Example 1](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/1-71.png)<figcaption id="caption-attachment-12578">Example 1</figcaption>

### Example 2:

- If any argument is a non-numeric value (letters and special characters), it returns **#VALUE!** Error.

![Example 2](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/2-56.png)<figcaption id="caption-attachment-12579">Example 2</figcaption>

Hence, from the examples, you can grasp the usage of **POWER**  **Function** in Excel.

## Summary:

In this tutorial, you can understand the usage of **Excel POWER Function in Office 365** with its syntax, explanation, and examples. Drop your **feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!!

### Read Also:

- [How to Use Excel GCD Function in Office 365? – with Examples](https://geekexcel.com/how-to-use-excel-gcd-function-in-office-365-with-examples/)
- [How to Use IMPOWER Function in Excel 365? – [with Examples]](https://geekexcel.com/how-to-use-impower-function-in-excel-365-with-examples/)
Best Branding and Advertising Agency in Chennai
Tags: logo
Published: 2020-08-25 11:38:36

We are an agency that provides design solutions and can serve to grow your brand identity. Experience in Branding, Logo Design, Advertising, Packaging, Web Design, and Digital Marketing.
We have many years of experience in working with an agency and prefer organized, systematic and quality work that will fulfill your requirements and helps you in promoting your business whether you are a small, medium, or corporate client.
How web developers can earn money by freelancing in India?
Tags: showdev, beginners, india, react
Published: 2020-08-25 11:18:38

First of all let me tell you about myself. My name is Harsh Vats and I am a self-taught front-end web developer from India. I am in my third year in IIT(ISM) Dhanbad while publishing this article. I am earning a good amount, ₹50,000-₹60,000 per month by doing part time freelancing.

#What are my skills??
I know html, css, javascript, python, react + redux, nodejs, express, nextjs, firebase, material-ui, bootstrap, git, etc.
To be honest the only things that i use for my freelancing most of the time is react + redux, firebase, material-ui and git. 

#Where Indian students are wasting their time??
You know what is the biggest scam in IT industry? I think it's internshala. There literally are jobs for ₹1,000 per month. Seriously??? But that's not it. The worst part is students are applying for these (even in IIT's). I was like any other student a year ago. But here i am telling you guys, if you are a student then don't waste your time applying for these creepy jobs. You are worth a lot more than this.

#Where can you actually earn???
There are many options but i have not gone to any platform other than upwork. What you need is just make 1-2 good projects and make your profile good. You will be approved to work on upwork then. I search for reactjs jobs and easily get jobs $10 per hour. My profile got rejected on upwork 2 times and finally with some good projects it got accepted after 4 months. And i got my first project on my 16th proposal which was $5 per hour. I would say don't loose hope, go make account on upwork and start your freelancing career today

#Most important
Keep learning stuff and have patience. You don't need to be in CSE to learn computer science. I am pursuing mining engineering at IIT Dhanbad.
WTF is Firebase?! 🔥
Tags: firstyearincode, webdev, webpack
Published: 2020-08-25 11:36:07

Hey,

Let's talk about Firebase!

WTF is it? Why should you care?

Let's dive right IN...

✅ First up, what IS Firebase?⁣​
​⁣​
​Firebase is a Back-end as a Service (BaaS) platform developed and provided by Google for mobile and web application development to help you build, improve, grow, and deliver richer app experiences.

It manages its own infrastructure with a set of tools to simplify the workflow of developers by providing them with dev kits and an online dashboard.⁣

The services provided by Firebase would normally have to be built by developers themselves, but Firebase eases that workflow.⁣​
​⁣​
​✅ Firebase Services⁣? ​
​⁣​
​👉 Real-time Database⁣​
​👉 Google Analytics⁣​
​👉 Authentication with Google, Facebook, Email, and even Phone⁣​
​👉 Push Notifications⁣​
​👉 Cloud Storage⁣​
​👉 Hosting⁣​
​👉 and many more...⁣​
​⁣​
​✅ What are the advantages of using Firebase⁣? What makes it so powerful? 🔥​
​⁣​
​👉 When you compare Firebase with other services like Amazon Web Service (AWS), it’s really simple to setup Firebase, but just as powerful.​
​⁣​
​👉 Because of the Firebase real-time database, it updates the applications data real-time which is REALLY beneficial if you’re building something like a Messaging app, etc.⁣​
​⁣​
​👉 Unlike AWS, with Firebase you’ve got nothing to learn in order to work with it. It has a Zero Learning-Curve.⁣​
​⁣​
​👉 You can build fully functional back-ends without anything like Nodejs or Django, just using Firebase Cloud Functions, etc.⁣​
​⁣​
​👉 You can host your application for FREE* with a nice domain.⁣(* There's a limit of course BUT that free tier is pretty generous!)

There you have it!
How to Use Excel PI Function in Office 365? – {with Examples}
Tags: excelfunctions, excelpifunctioninoff
Published: 2020-08-26 03:35:10

---
title: How to Use Excel PI Function in Office 365? – {with Examples}
published: true
date: 2020-08-25 11:34:26 UTC
tags: ExcelFunctions,ExcelPIFunctioninOff
canonical_url: https://geekexcel.com/how-to-use-excel-pi-function-in-office-365-with-examples/
---

## Excel PI Function:

![PI Function](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/Example-5.png)<figcaption id="caption-attachment-12574">PI Function</figcaption>

In this guide, you will learn the usage of **Excel PI Function in Office 365** with its syntax, description, and examples. Get an official version of **MS Excel** from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)



## PI Function – Description:

- This function **returns the value of the constant** **π (3.14159265358979)**.
- The value of PI is calculated by dividing a circumference of a circle by its diameter.

## Syntax:

**=PI()**
- PI function has no arguments.

### Note:

- If any argument is a non-numeric value (letters and special characters) and then it returns **#VALUE!** Error.

## Examples:

Let’s see some examples to know how it works.

### Example 1: Get PI value using PI() Function

- In this image, we have shown the value of PI using **PI Function**.

![Example 1](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/1-70.png)<figcaption id="caption-attachment-12572">Example 1</figcaption>

### Example 2:

- Refer to the below image.
- We have calculated the value of  **π/2** , **π/5** , and **π\*2**.

![Example 2](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/2-55.png)<figcaption id="caption-attachment-12573">Example 2</figcaption>

## Bottom-Line:

In this guide, you can understand the usage of **Excel PI Function in Office 365** with its syntax, description, and examples. Give your **suggestions** in the comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!!

### Read Also:

- [How to Use Excel MROUND Function in Office 365? – [with Examples]](https://geekexcel.com/how-to-use-excel-mround-function-in-office-365-with-examples/)
- [How to Use Excel FLOOR.PRECISE Function in Office 365?](https://geekexcel.com/how-to-use-excel-floor-precise-function-in-office-365/)
Communicate between Angular components 
Tags: angular, javascript, tutorial, webdev
Published: 2020-08-25 11:32:22

##### *Angular v10.0.9* 

The first time I had to communicate between two Angular components, it was Parent/child relation, and it's pretty easy with @output and @input.

**But** the first time I had to, without this relation, I was completely lost.

## Create a Service

We assume you have now two components, not connected by any relationship, let's create a new **service** :

`ng g service <name>`

> name it like you want !

The generated Service looks like :

```javascript
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class DataService {
  // Your code here
}
```

## Subject

We will use **Subject**, a special type of Observable that allows values to be multicasted to many Observers !

Import Subject from rxjs in your Service :

```javascript
import { Subject } from 'rxjs'
```

Now we can create a Subject to carry the data to share between our components :

```javascript
data: Subject<Type> = new Subject();
```
>Subject can be any Typescript type

## It's Done !

*Yeah, really.*

You have just to import the service into your components with :

```javascript
import { dataService } from "../services/data.service";
```
+
```javascript
constructor(
    private sharedData: dataService,
  ) {}
```

### To **get** the data

```javascript
this.sharedData.data.subscribe(data => {
     //Do what you want with data 
})
```
> data will be updated automatically

### To **set** the data :

```javascript
this.sharedData.data.next(newValue)
```
>The data will be updated in **ALL** your components wich have subscribed to the value

{% user nik0w %}

Thanks for reading! Was this article helpful for you? Any ideas that can be shared? Post a comment below!

**P.S.** This is my first Angular post, I hope you will love it !