teleren/devto huggingface dataset:
EXPRESS JS MIDDLEWARE
Tags: javascript, node
Published: 2021-06-19 20:58:00

## What is a Middleware?:

According to [wikiperdia](https://en.wikipedia.org/wiki/Middleware), 
> *Middleware is a type of computer software that provides services to software applications beyond those available from the operating system. It can be described as "software glue".*

In our case, express js middleware is a **functionality that runs between a request to the server and the response from the server**.

----

## Types of Express Middleware:
* Built-in Middleware:

1. [express.static](https://expressjs.com/en/4x/api.html#express.static): serves static assets such as HTML files, images, and so on.
2. [express.json](https://expressjs.com/en/4x/api.html#express.json): parses incoming requests with JSON payloads.
3. [express.urlencoded](https://expressjs.com/en/4x/api.html#express.urlencoded): parses incoming requests with URL-encoded payloads.

* Third Party Middleware:

Middleware installed via npm

* Custom Middleware:

Created by you - the developer - for a project.

----

## How To Apply Middleware?:

* Application or Route Level:

```javascript
const express = require('express');

//Start express app.
const app = expree();

//Apply a single middleware
app.use(middleware);

//Apply multiple middleware
app.use(middleware1, middleware2);

//Or via an array 
const middlewareArr = [middleware1, middleware2];
app.use(middlewareArr);
```

* Endpoint Level:

```javascript
//Apply a single middleware
app.get('/', middleware, (res, req) => {};

//Apply multiple middleware
app.get('/', middleware1, middleware2, (res, req) => {};

//Or via an array 
const middlewareArr = [middleware1, middleware2];
app.get('/', middlewareArr, (res, req) => {};
```
How to learn to code FAST!
Tags: webdev, codenewbie, productivity, javascript
Published: 2021-06-19 20:39:25

Hello my gorgeous friends on the internet, hope you are doing very good, and fancy today, in today's blog, I want to give you the number one tip, that's not a dirty joke, Okay, I'm gonna give you the number one tip that I follow to become a better developer and increase our skills.

So lets just get in the blog,

The number one tip is to create project and stumped you in tutorials. That's the number one tip that you should follow. Whenever you're learning anything development related, whether that be Python, or JavaScript, or development or game development or whatever. That's the number one tip is not to follow tutorials as much as you might think. And to actually start building out the things that you want. And again, this is like so obvious that you might everybody might be like, yeah, mobile, obviously, you want this for building out your tanks. But it's actually a very fine line here. And a lot of people fall into this trap. And you never really realize that, wait, I actually done more tutorials. And I've done projects. And this happened to me a bunch of times, and it's still hard habit to break.

If you don't actually put that thing that you learned to the test. Well, it's not going to work out, right. And school, that's probably one of the biggest problems is that you learn everything in memory, you do the test, you get the good score, and then you never use it again. And you're gonna forget. So the number one tip is, again, I'm not saying that don't do tutorials, because tutorials are a great resource to get the basics down. But I'm saying don't fall into that rabbit hole of just doing tutorials because you feel like you're not good enough to start your own project. So my philosophy has always been to start from the basics, just learn from the beginning and just get a good grasp of how that technology works. And how you can put together something super simple. And after that, like literally have to concentrate and take deep breaths, yoga breaths, and be like, Okay, I'm done with the tutorial. That's it.

#####I have a [Instagram Theme Page](https://www.instagram.com/vikcodes/) related to programming, you can follow it if you want to :)

So yeah that's all I got for today, yup its my first blog and pretty small but hope you liked it and learned something :D
JKS - Salesforce
Published: 2021-06-11 14:29:15

## JKS (Java Key Store)
When you are working with JAVA applications and JAVA based server, you may need to configure a **Java key store (JKS)** file. 
**In Salesforce** certificates are used to authenticate single sign-on with an external website.

## Create Salesforce Certificate By importing JKS
*If you have existing JKS you can create certificate by:*
 - Go to setup 
 - Search for "Certificate and Key Management"
 - Click on Import from Keystore

## Generate JKS

**Generate JKS file from .key and .cert file:**
- **Prerequisite**: [OpenSSL](https://www.openssl.org/source/) & [JDK](https://www.oracle.com/in/java/technologies/javase-downloads.html)
 - Change their file extension from .key to .pem & .cert to .pem and run below command from folder directory where .key & .cert files available in **OpenSSL command prompt.**
 ```
 openssl pkcs12 -export -in certificate_pub.pem -inkey private.pem -certfile certificate_pub.pem -out testkeystore.p12
 ```
 
 - Enter any password you can easily remember.
 - Now there will **testkeystore.p12** file generated in your directory.
 - Now will Create JKS file using **keytool** following commands in **cmd**.
 ```
 keytool -importkeystore -srckeystore testkeystore.p12 -srcstoretype pkcs12 -destkeystore wso2carbon.jks -deststoretype JKS
 ```
 Now the jks file will be created as **wso2carbon.jks**.
 **Note**: By default [current alias] is set to **“1”**
 
**To change keystore password:**
```
keytool -keypasswd -alias [Alias name for private key] -keystore [path to key store]
```
e.g:
```
keytool -keypasswd -alias "1" -keystore wso2carbon.jks 
```
**To change Alias Name of keyStore:**
```
keytool -changealias -keystore [path to key store] -alias [current alias]
```
e.g: 
```
keytool -changealias -keystore wso2carbon.jks -alias "1"
```

## Screenshots:
![To create .P12](https://raw.githubusercontent.com/shivamkapasia0/JKS-Salesforce/main/JKS%20SS/createP12.png)
![to create JKS](https://raw.githubusercontent.com/shivamkapasia0/JKS-Salesforce/main/JKS%20SS/createJKS.png)

## Errors:
**you can face error while importing certificate from keystore error like**:

    Data Not Available
> The data you were trying to access could not be found. It may be due
> to another user deleting the data or a system error. If you know the
> data is not deleted but cannot access it, please look at our  support 
> page.

**To Solve this error, follow below steps:**

 - Go To Setup | Identity Provider
 - Press “Enable Identity Provider” button
Once Identity Provider is enabled in the Org, it will create a self-signed certificate in your Org under — Setup | Certificate and Key Management
 - Try to import the certificate from your JKS through “Import from
   keystore” option and it should be successful.

**Thanks for reading …!!! Also you can find more details on creating self signed KeyStore from**  **[here](http://www.javasecurity.org/2015/09/how-to-create-self-signed-keystore-jks.html)**
Day 97 of 100 Days of SwiftUI
Tags: swift, 100daysofcode
Published: 2021-06-19 19:44:10

I just completed day 97 of 100 days of swiftui. I worked on building the SnowSeeker app. SnowSeeker is a app that shows a list of snow resorts and also details about them. It does so using a master-detail design.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9p2un3yyfpwi4g2mk8k.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzvzf2dcna8a7siffbg5.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8o9nughf3tmjpok44xr.png)
Laravel 8 avec Bootstrap 5
Tags: laravel8, bootstrap5
Published: 2021-06-19 19:06:43

Je ne le cache à personne, j'aime pas Tailwind 😋
L'arrivé de Bootstrap 5 remet les pendules à l'heure, en purgeant le code d'IE et de Jquery.
Les composants CSS et JS peuvent être ajoutés au besoin.

---

Ouvrez le terminal, allez dans le dossier de l'app
`cd /path/to/your.app`

Comme on ne veut pas de *Tailwind*, on vire *postcss* :
`npm uninstall postcss`

Si vous n'allez pas utiliser *Lodash* et *Axiox*, on les vire :
`npm uninstall axios lodash`

On installe *Bootstrap* avec *Popperjs* et pour être prèt à compiler, on ajoute de suite *Sass* et les *loaders*.
`npm install @popperjs/core bootstrap resolve-url-loader sass-loader --save-dev`
`npm install sass@1.32.13 --save-dev --save-exact`
_ℹ️ j'ai forcé la version 1.32 de SASS à cause des warning ci-dessous, rencontrés quand on compile avec la version 1.33 ou supérieure.
Recommendation: math.div($spacer, 4)
1: $spacer / 4,
Recommendation: math.div($spacer, 2)
2: $spacer / 2, ..._

EDITEZ
`nano resources/js/bootstrap.js`
COMME CECI
`window._ = require('lodash');
import "bootstrap";
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';`
ENREGISTREZ, FERMEZ
`CTRL + x`
`o`
_ℹ️ si vous n'utilisez pas Lodash et/ou Axios, vous pouvez effacer les lignes les concernant._

ATTENTION, nous allons travailler sur le fichier app.Scss et non app.Css (qu'on vire)
`rm resources/css/app.css`
`nano resources/css/app.scss`

AJOUTEZ
`@import '~bootstrap/scss/bootstrap';`
ENREGISTREZ, FERMEZ
`CTRL + x`
`o`

EDITEZ
`nano webpack.mix.js`
COMME CECI
`const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
   .sass('resources/css/app.scss', 'public/css');
if (mix.inProduction()) {
   mix.version();
}`

COMPILEZ
`npx mix`

INSÉREZ LE CSS DANS LES VUES (ou mieux, dans le layout)
`<link rel="stylesheet" href="{{ mix('css/app.css') }}">`
Avant de fermer &lt;/head&gt;

ET LE JS
`<script src="{{ mix('js/app.js') }}"></script>`
Avant de fermer &lt;/body&gt;
Music Player
Tags: html, css, javascript, ux
Published: 2021-06-19 18:44:56

<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mawfz2k32nhh1hu9bl8i.png"/>

Hello friends, 
I have made an <a href="https://sanu-coder.github.io/Music-Player/">music player</a>. Please go through it and provide you feedback.

<a href="https://github.com/sanu-coder/covid-19-tracker"><h3>#Source code</h3></a>
Part 1 - Making a portfolio with SvelteKit - the beginning 1/100DaysOfCode
Published: 2021-06-19 18:35:57

Part 1 of a journey to making my portfolio. This post will be boring as hell, but hopefully it's a beginning of a fairly interesting series. 


## Finally getting it together and making a portfolio with my work.

I have been learning and playing with webdev for close to three years, but I never took it to another level. I have been (and as of the time of publishing this, still am) working a stable, boring office job. 
Working remote for over a year helped me gain some clarity and look inwards. My personal goals and plans don't align with my current employment, and it's relative safety has placated my hunger for pursuit of what I want, and what I want is TECH. I love modern technologies and am very passionate, nay - have an insatiable hunger for learning new things and solving puzzles.

## SvelteKit :heart_eyes:

At the current stage it's a very barebones page with no real content, but I have already learned so much:

- Basics of [SvelteKit](https://kit.svelte.dev/)- I have already been quite familiar with Svelte so it was quite easy to jump in. So far I'm really enjoying the framework and would strongly recommend for anyone to check it out.
- Very simple CI wiith Netlify
- setting up a domain through [Porkbun](https://porkbun.com)

Other than showcasing my work and writings, I am going to keep myself accountable and attempt to keep as close to 100 lighthouse score as possible and follow best practices.

![Lighthouse performance scores, all 100s](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ekzczmlenatftdzotg8.gif)

### It's live on (https://jerzakm.com)

Roadmap - next up:
- reviving a few of the projects from my project graveyard (AKA my github account)
- figuring out what content management system I want to use and hooking it up
- Accessibility. I can't wait to read more about it and start applying what I learned. InHuOffficial's A11y rants are awesome. 

{% user inhuofficial %}


## 100 Days of Code
This post also marks my entry and first day of progress for #100DaysOfCode
Created Covid-19 tracker
Tags: react, chartjs, javascript, css
Published: 2021-06-19 18:20:49

<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6o8j1txsnpeg09h4ah8.png" />

<b>Hello friends👋👋!!,</b>

<p>I have made a new project <a href="https://covid-19-tracker3.herokuapp.com/">Corona-virus Tracker</a>. It tells the active, recovered and death cases of covid-19 patients. </p>
<p>Do visit my site and provide your valuable feedback🙏🙏🙏</p>

<h3>Reference Materials😊😊</h3>
<a href="https://www.chartjs.org/">Chart JS documentation</a>
<a href="https://reactjs.org/docs/getting-started.html">React JS documentation</a>

<h3>My source code link 😊: </h3>
<p>For source code, please visit my <a href="https://github.com/sanu-coder">Github Profile</a></p>
Spring Initializr CLI
Tags: java, spring
Published: 2021-06-19 18:06:16

Here is a simple way to start using [spring.start.io](https://start.spring.io/) from CLI

## Simple helloworld web with gradle

```
curl https://start.spring.io/starter.zip \                                                                          
    -d type=gradle-project 
    -d dependencies=web \
    -d name=helloworld \
    -d artifactId=helloworld \
    -o helloworld.zip
unzip helloworld.zip
```

## Adding dependencies and more options

```
curl https://start.spring.io/starter.zip \
  -d type=gradle-project \
  -d javaVersion=11 \
  -d dependencies=web,native,data-rest \
  -d applicationName=NativeWebApp \
  -d description='Web app with data rest and Native support' \
  -d artifactId=nativeweb \
  -d packageName=com.test.web \
  -d baseDir=nativeweb \
  -o nativeweb.zip
unzip nativeweb.zip
```

## How to find options

```
curl  https://start.spring.io
```
Primeiros passos com Git
Tags: git, github
Published: 2021-06-19 17:40:28

## O que é o Git?

Hoje o assunto é [GIT](https://git-scm.com). O Git é a melhor ferramenta para gerenciamento e versionamento de código e também a mais utilizada atualmente.

Não importa se você é desenvolvedor Javascript, Java, Python ou C++, com certeza você vai precisar utilizar o Git. Meu objetivo neste post é mostrar o básico de Git (publicando o primeiro commit) para quem está começando na área de desenvolvimento.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8n0nckidouustxz815k5.jpg)

## Por que usar o Git?

Vamos direto ao ponto: as duas principais facilidades oferecidas para quem está começando com Git é salvar seu código em um servidor na nuvem e o controle de versionamento de todas as alterações feitas nele.

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

Você já deve ter ouvido falar do [github](https://github.com), [bitbucket](https://bitbucket.com) ou do [gitlab](https://gitlab.com). Estes são serviços de empresas que hospedam as versões dos códigos dos seus projetos utilizando a tecnologia do Git.

Com o seu código hospedado em um servidor, você tem a garantia de um backup, caso aconteça algo com seu computador e também pode compartilhar esse código para que outras pessoas possam trabalhar nele.

Já o versionamento de código te garante uma rastreabilidade das mudanças que foram feitas com o tempo, possibilitando também que você desfaça o código que você desenvolveu com facilidade.

## O primeiro repositório

Antes de mais nada, você precisa criar um repositório (que nada mais é do que um projeto). Escolha uma pasta do seu computador.

```sh
mkdir meu-projeto
cd meu-projeto
git init
```

Quando você cria um repositório em um dos serviços apresentados anteriormente, eles fornecem uma URL para hospedar seu projeto. Nesse momento, vamos adicionar a URL do projeto no repositório local.

```sh
git remote add origin http://urlDoServico.com/seuProjeto
```

O próximo passo é adicionar seus arquivos dentro dessa pasta. Para em seguida, fazer o primeiro commit (que é forma como o git grava uma versão de alteração no seu código). Primeiro, vamos adicionar os arquivos que queremos commitar.

```sh
# adicionar todos os arquivos da pasta
git add .

# deixe uma mensagem que explique o que você desenvolveu
git commit -m "Criando meu primeiro commit"
```

O último passo agora é enviar o código para o repositório online.

```sh
git push origin master
```

Este é apenas o começo. O Git oferece diversas possibilidades, as quais abordarei em próximos posts.

---

Se você gostou, me segue para novos posts e deixa o like nesse post.

Obrigado pela leitura! Espero que possa ter ajudado. 🚀
403 while being Owner
Published: 2021-06-19 17:35:36

<sub>Photo by <a href="https://unsplash.com/@kylejglenn">Kyle Glenn</a> on <a href="https://unsplash.com/s/photos/denied">Unsplash</a></sub>

Our project is using Token provided by [Microsoft.Azure.Services.AppAuthentication](https://www.nuget.org/packages/Microsoft.Azure.Services.AppAuthentication/), like in this [example](https://docs.microsoft.com/en-us/dotnet/api/overview/azure/service-to-service-authentication).


For example, if you want to access KeyVault and database


```csharp
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Azure.KeyVault;
using System.Data.SqlClient

// Use AzureServiceTokenProvider’s built-in callback for KeyVaultClient
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));

// Request an access token for SqlConnection
sqlConnection = new SqlConnection(YourConnectionString)) 
{ 
    sqlConnection.AccessToken = azureServiceTokenProvider.GetAccessTokenAsync("https://database.windows.net"); 
    sqlConnection.Open(); 
}
```

*Note*: the token is cached across AzureServiceTokenProvider instance as you can [see](https://stackoverflow.com/questions/58099706/does-azureservicetokenprovider-getaccesstokenasync-cache-tokens-across-instances).

In the example, we use the scope "https://database.windows.net". For Storage, we can use "https://storage.windows.net".
Everything went fine as long as we use Container, but we get 403 response when we download blob content.

403 ? even if i have the Owner role ! how is it possible ?

The answer is in this [blog post](https://www.schaeflein.net/understanding-azure-storage-data-access-permissions/). There are role for **Content Plane** (Owner / Contributor etc ..), and for **Data Plane** (Storage Blob Data Contributor / Storage Queue Data Reader). Once set, manipulation blob or queue was possible.

Hope this help !
Como rodar scripts paralelamente
Tags: scripts, npm, package, concurrently
Published: 2021-06-19 17:30:12

---
title: Como rodar scripts paralelamente
published: true
description: A vida é curta demais pra ter um pre-commit demorado²
tags: scripts, npm, package, concurrently
cover_image: https://images.unsplash.com/photo-1534185372994-55f9e64235c4?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80
---

Quando configuramos alguns scripts pra rodarem no pre-commit/pre-push nosso tempo de desenvolvimento pode acabar sendo afetado pela demora pra executar essas tarefas, mas a gente consegue também diminuir esse tempo de espera rodando tarefas em paralelo.


Com o pacote `concurrently` nós conseguimos rodar vários scripts paralelamente, e pra fazer isso é bem simples, primeiro instalamos o pacote:

```js
npm i concurrently
```

Com isso temos o pacote instalado no nosso projeto, agora pra rodar os scripts ao mesmo tempo é só executar o comando:

```js
concurrently "command1 arg" "command2 arg"
```

É importante colocar os comandos dentro de aspas duplas pq se não colocarmos seriam executados 4 comandos: `command1`, `arg`, `command2` e `arg`.

Podemos então configurar esse comando dentro do nosso _package.json_:

```js
{
	"start": "concurrently \"command1 arg\" \"command2 arg\""
}
```

Quando o comando que quisermos executar for um comando npm nós podemos usar flag _-n_:

```js
concurrently -n watch-js,watch-css,watch-nod
```

Isso seria equivalente a:

```js
concurrently "npm run watch-js" "npm run watch-css" "npm run watch-node"
```

Além disso, podemos também executar vários comandos que comecem com um mesmo prefixo:

```js
{
  ...
  "scripts": {
      "watch-js": "...",
      "watch-css": "...",
      "watch-node": "...",
  },
  ...
}
```

Pra rodar todos esses scripts podemos simplesmente rodar:

```js
concurrently -n "watch-*"
```

---

É importante ganharmos tempo no nosso dia a dia, e rodando alguns scripts paralelamente é uma maneira simples de fazermos isso, então se você tem algum projeto que leva muito tempo pra rodar alguns comandos, talvez valha a pena estudar se essa solução se encaixa pro seu caso!

---
#### Links úteis

- Você pode ver esses exemplos e mais alguns nessa página do pacote: [NPM concurrently](https://www.npmjs.com/package/concurrently)

- [Ver post original](https://evellynlima.com.br/como-rodar-scripts-paralelamente/)

- [Foto tirada por Adi Goldstein](https://unsplash.com/@adigold1)
What is machine learning?
Published: 2021-06-19 16:03:18

Machine learning (ML) is a type of artificial intelligence (AI) that allows software applications to become more accurate at predicting outcomes without being explicitly programmed to do so. Machine learning algorithms use historical data as input to predict new output values.

Recommendation engines are a common use case for machine learning. Other popular uses include fraud detection, spam filtering, malware threat detection, business process automation (BPA) and predictive maintenance.

Why is machine learning important?
Machine learning is important because it gives enterprises a view of trends in customer behavior and business operational patterns, as well as supports the development of new products. Many of today's leading companies, such as Facebook, Google and Uber, make machine learning a central part of their operations. Machine learning has become a significant competitive differentiator for many companies.Machine learning (ML) is a type of artificial intelligence (AI) that allows software applications to become more accurate at predicting outcomes without being explicitly programmed to do so. Machine learning algorithms use historical data as input to predict new output values.

Recommendation engines are a common use case for machine learning. Other popular uses include fraud detection, spam filtering, malware threat detection, business process automation (BPA) and predictive maintenance.
Day 116
Tags: 100daysofcode, programming
Published: 2021-06-19 16:00:39

Day 116/200 of #200DaysOfCode #100DaysOfCode #100daysofcodechallenge 

- Solved two problems on Codewars.

1 - Image host filename generator (6 kyu)
2 - Who is the killer? (7 kyu)