teleren/devto huggingface dataset:
Azure DevOps YAML pipeline : Use Azure KeyVault secret as Environment Variable
Tags: azuredevops, pipeline, keyvault
Published: 2020-07-17 04:41:39

I ran into an issue on the other day, when I tried to read **Azure KeyVault** secret via **Environment Variable** for my xUnit project in **yaml pipeline**.

There are several GitHub issues, or stack overflow posts discussing this, but in fact, it was quite straight forward at the end.

This applies any language, doesn't have to be dotnet core. But as I am C# developer, I explain everything by using C#.

# Setup

I assume you already have followings.

- Azure DevOps
- dotnet core project
- Azure KeyVault 

# Sample app

I developed very simple console app to explain. It just grab **"MySecret"** environment variable and compare the result. I wanted to display the value in the screen but due to security reason, which is good, Azure DevOps won't display the value.

```csharp
using System;

namespace myconsoleapp
{
    class Program
    {
        static void Main(string[] args)
        {
            var mySecret = Environment.GetEnvironmentVariable("MySecret");
            if(mySecret == "IHave3Cats")
                Console.WriteLine("Correct Environment Variable");
            else
                Console.WriteLine("Wrong Environment Variable");
        }
    }
}
```
# Azure KeyVault

I have a secret created in my KeyVault and set the value as "IHave3Cats".

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

I also give permission to Azure DevOps project.

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

# Author pipeline

There are a couple of ways to obtain secret from Azure KeyVault, but I use pipeline task to get it this time. It should be straight forward so I won't explain how to.

This is my yaml.

```yaml
trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: AzureKeyVault@1
  inputs:
    azureSubscription: 'ConnectionToAzure'
    KeyVaultName: 'kenakamukeys'
    SecretsFilter: 'MySecret'
    RunAsPreJob: false

- task: DotNetCoreCLI@2
  displayName: 'build my app'
  inputs:
    command: 'build'
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: 'run my app'
  env:
    MySecret: $(MySecret)
  inputs:
    command: 'run'
    projects: '**/*.csproj'
```

The point is to use **env** property in task field. Once I run the pipeline, I can confirm the expected result.

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

# Summary

There is [an official document](https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#task) clearly explains this.

I can use env not only for task but also for various other types :)
Automatically testing for accessibility issues with jest-axe
Tags: a11y, react, testing
Published: 2020-07-17 04:37:20

---
title: 'Automatically testing for accessibility issues with jest-axe'
published: true
description: 'Automatically test your code for accessibility issues in the same way you catch bugs with jest-axe.'
tags: ['a11y', 'react', 'testing']
canonical_url: https://maxrozen.com/2020/07/17/automatic-a11y-testing-with-jest-axe
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/alixug1yp9fq4twmh9jq.jpg
---


Hey, you! Does your project have `jest` already installed?

Do you wish management would care more about accessibility but just can't get them to invest or pay attention?

A few design systems I've worked with had the following code to prevent app-wide accessibility regressions, and it's so simple yet powerful that I had to share.

```js
import React from 'react';
import { render } from '@testing-library/react`;
import { axe, toHaveNoViolations } from 'jest-axe';

expect.extend(toHaveNoViolations);

function AccessibleForm() {
  return (
    <form>
      <label htmlFor="email">Email</label>
      <input id="email" placeholder="email" />
    </form>
  );
}

test('accessible forms pass axe', async () => {
  const { container } = render(<AccessibleForm />);
  expect(await axe(container)).toHaveNoViolations();
});
```

Credit to Kent C. Dodds' [TestingJavaScript.com](https://testingjavascript.com) course for the above snippet

With a few lines of code, auditing your entire design system for accessibility issues suddenly becomes surprisingly doable.

Without `@testing-library/react`, the code is more or less the same. Using Enzyme, you `mount()` your component, and pass it to `jest-axe` to validate.

It's worth noting that while this can find issues with inaccessible HTML, it <b>doesn't guarantee</b> your components are actually accessible. To do that, you'll want to involve actual people with disabilities involved in your research. For more information about jest-axe, see the [GitHub repo](https://github.com/nickcolley/jest-axe).

## Further reading

Google's actually has a pretty comprehensive article on auditing accessibility at https://web.dev/accessibility-auditing-react/ - however it mainly touches on catching issues via eslint or while running the application in development, rather than using your test suite.
How to Build an Alexa Skill using Python
Tags: alexa, python, tutorial, bot
Published: 2020-07-17 04:31:51

{% youtube wIhpPQv0QDg %}
In this video, we will build an Alexa random facts skill using an existing template using AWS Lambda python fact application repository. Please subscribe and stay tuned, I will come up with next video on how to build a custom Alexa skill from scratch.

Follow on:
Github: https://github.com/codingx01
Twitter: https://twitter.com/TechParida
Linkedin: https://www.linkedin.com/company/codingx/
Facebook: https://www.facebook.com/codingx
Instagram: https://www.instagram.com/coding.x/

Leave any questions in the comments section and don't forget to subscribe to be notified of new content! :)
Please Subscribe to my Youtube Channel https://www.youtube.com/c/codingx?sub_confirmation=1
Deploy Ruby on Rails App on AWS Part 1
Tags: ruby, rails, aws, nginx
Published: 2020-07-17 04:27:59

Part 1: Setting up ec2 instance: https://youtu.be/-abUqrmB7Ns?list=PL3tDRmVst0DdgRzuIuN5dVb9uZtslUlLB


More parts to come.
Experimental Support For Decorators?
Tags: angular
Published: 2020-07-17 04:14:28

Have you ever seen this warning message? 
 
>Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning?
 

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

Everything seems to be doing fine in our project until all of a sudden this error shows up.  What's going on?

Turns out this message is wrong. If we click on Problems in the Terminal section of VSCode we'll see issues needing attention. After fixing them, this message goes away!
July 17th, 2020: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2020-07-17 04:00:07

It's that time of the week again.

So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![Carmen Sandiego saying "Let's find out!"](https://media.giphy.com/media/yvqRaXlOsc068DDTzt/giphy.gif)

</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remember, if something you learnt was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{% link https://dev.to/devteam/what-was-your-win-this-week-46km %}

<center>

![Kid riding flying animal in the Neverending Story movie](https://media.giphy.com/media/cOB8cDnKM6eyY/giphy-downsized-large.gif)

</center>
JavaScript: For Loop
Tags: javascript, codenewbie, 100daysofcode, beginners
Published: 2020-07-17 03:57:11


## Introduction

We learned about while and do-while loops in the previous blog posts. Loops allow us to repeat the same action multiple times. They have three requirements:

1. Start condition
2. End condition
3. Counter

The for-loop combines all three requirements on one line, unlike a while or do-while.

```javascript
for (start; condition; counter) {
  // body
}
```

Example: If we would like to print numbers from 1 to 10 on the console.

```javascript
for (let i = 1; i <= 10; i++) {
  console.log(i); // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
}
```

We **start** at 1 (that is the initial value of `i`), you **end** at 10 (that is the final value of `i` in evaluation), and you increment `i` by one each time (using `i++`). We can skip any part of the for-loop requirements, and it still works.

## Exiting for loop

There are situations when we loop over a data structure, but if a condition is met, we do not want to do any more iterations. This is where the `break` keyword comes in.

```javascript
for (let i = 1; i <= 10; i++) {
    if (i === 3) { // As soon as i reaches 3 the looping ends
        break;
    }
  console.log(i); // 1, 2
}
```

The example above is relatively simple. We can achieve it by changing the exit condition from `i <= 10` to `i < 3`. There is no need to use the `break` keyword. We did an example to illustrate the keyword. We could be iterating over an array of person's names, and once we find a person, exit the loop.

## Skipping an iteration

`continue` keyword allows us to skip a single iteration of the loop. It will not end looping like `break` does, but it will not execute a single repetition.

Example: print numbers from 1 to 10 but do not print 3 or 6.

```javascript
for (let i = 1; i <= 10; i++) {
    if (i === 3 || i === 6) { // when i is 3 or 6, skip console log and go to next value of i (next iteration)
        continue;
    }
    console.log(i); // 1 2 4 5 7 8 9 10
}
```

🚨 `continue` or `break` does not work with a ternary operator like `?`. We have to use `if...else` statement.
production mode in angular
Published: 2020-07-17 03:30:03

Disabling Angulars development mode turns off assertions and other checks. The syntax is

enablePrMode(): void with no parameters required. and it Retuns void.

This is how i enable it in production mode in Angular 6, Angular 7 or Angular 8, in  Angular Project’s main.ts file, you can write following code:

import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
 
Read more at kodlogs.com
Day 46 : #100DaysofCode - Still reviewing form_for
Tags: 100daysofcode, codenewbie
Published: 2020-07-17 03:13:10

I am still going over forms in Ruby on Rails. Something that I learned today is how to create a form to add comments to a profile page. I think something that resonated with me today is that you can build from a ``form_for`` tag. For example, if you wanted to create a new profile with comments you could add ``@profile.comments.build`` to the ``form_for`` tag. That will essentially return a new object with the profile.comments attributes and link it to the object without saving it. For example, after setting up your associations so that a profile and user can have many comments you would add the following to the profile show page:

```
<%= form_for @profile.comments.build do |f| %>
  <%= f.hidden_field :profile_id %>
  <p>
    <%= f.collection_select :user_id, User.all, :id, :username %>
  </p>  
  <p>
    <%= f.label :content, "New Comment" %><br>
    <%= f.text_area :content %>
  </p>
  <br/>
  <%= f.submit %>
<% end %>

```

If you noticed, ``<%= f.hidden_field :profile_id %>`` is added to the form_for tag as well. That piece of code is gold, it allows us to send the ``profile_id`` over to a controller as a hidden param so that it can be referenced in your create method.

The ``@profile.comments.build`` allows rails to know that we want to reroute to the comments controller and from there you can save the params and create a new comment and reroute to that profile page. Like this:
 
The controller:
```
  def create
    @comment = Comment.create(comment_params)
    redirect_to @comment.profile
  end

  private

  def comment_params
    params.require(:comment).permit(:content, :profile_id, :user_id, user_attributes:[:username])
  end
```

I can definitely see why people love rails. It is simple once you learn all the syntax. I look forward to create projects using Ruby on Rails.

As always, thanks for reading!

Sincerely, 
Brittany
Rspec: too many failing tests → `--fail-fast`
Tags: ruby, testing, rails
Published: 2020-07-17 03:13:09

A simple solution is to fix them one by one and stop Rspec.

Of course there's an option for that: `rspec --fail-fast`


You can use the configuration file:
```ruby
RSpec.configure do |c|
  c.fail_fast = true
end
```
@nxtend/ionic-react 3.0.3
Tags: ionic, react, nx, webdev
Published: 2020-07-17 03:13:08

---
published: true
title: '@nxtend/ionic-react 3.0.3'
cover_image:
description:
tags: ionic, react, nx, webdev
series:
canonical_url: https://nxtend.dev/blog/ionic-react-3.0.3/
---

This version of the `@nxtend/ionic-react` plugin includes a few quality of life improvements regarding dependency management.

## Bug Fixes

- add `@nrwl/react` version based on the users Nx version
- don't unnecessarily add `@nxtend/ionic-react` dependency in `init` schematic
- add `@nxtend/capacitor` 1.0.0 instead of `*`

Previously, `@nxtend/ionic-react` would add the latest version of `@nrwl/react` to the users `package.json` which could cause issues if the user was using an older version of Nx. Now, the plugin will look at the users local version of Nx and will install the same version of `@nrwl/react`.

An update has also been made that avoids adding `@nxtend/ionic-react` unnecessarily when using `ng add`.

Finally, the plugin will install version 1.0.0 of `@nxtend/capacitor` instead of version `*`.

For information on upgrading the plugin, visit the [nxtend upgrades documentation](https://nxtend.dev/docs/nxtend/upgrades).
Como criar um blog com Gatsby.js e Prismic
Tags: video, gatsby, prismic, jamstack
Published: 2020-07-17 02:46:47

[PT-BR]

> Dessa vez não é um post, foi mal para os *read > watch*, mas se você quiser dar uma olhada no que fiz no vídeo, o repositório tá aqui: https://github.com/lucis/blog-do-lucis


Esse foi o meu primeiro vídeo em um longo tempo, e é sem edição, com bugs ao vivo, e contando um pouco da história do Gatsby.js. Espero que vocês gostem.

{% youtube qtsvV4H98mg %}

**Disclaimers**

- Caso você queira construir um blog com o Prismic, e já tenha entendido como o Gatsby.js funciona, recomendo **usar o Gatsby Prismic Starter** ([https://www.gatsbyjs.org/starters/LekoArts/gatsby-starter-prismic/](https://www.gatsbyjs.org/starters/LekoArts/gatsby-starter-prismic/)) que já vai vir com toda estrutura pronta para você.
- Há um plugin mais moderno para integrar com o Prismic, o `gatsby-source-prismic-graphql` ([https://github.com/birkir/gatsby-source-prismic-graphql](https://github.com/birkir/gatsby-source-prismic-graphql)), mas o meu intuito no vídeo foi mais explicar um fluxo básico do Gatsby, e o plugin que usei era o mais simples

**Fontes:**

- [https://www.gatsbyjs.org/docs/sourcing-from-prismic/](https://www.gatsbyjs.org/docs/sourcing-from-prismic/)
I finished my first portfolio website!! 🤩
Tags: webdev, showdev, womenintech, portfolio
Published: 2020-07-17 02:22:49

https://lorna.dev [](https://lorna.dev)

As a typical developer, I have a few projects where I've made a good start with full of motivation and drive... But ultimately I stop due to distractions and/or other commitments. The cycle continues. 

# Redundant?

It's a very difficult time across the world, and has been for a while due to Covid-19. I started my job as a .NET developer end of March as we (in Leeds, UK) just started lock-down and therefore have been working remotely. Not even stepped foot in the office. It's now near the end of July and I could be potentially redundant - seems very likely. 

# I'm doing me

I've been looking for new opportunities and wanted to boost myself further by providing my portfolio website on my CV. My website at this point was nearly done as it had been several times before but then I'm always completely redesigning the site - again and again. When I heard the news about being made potentially redundant (not a situation I've been in before) I tidied up my CV and made sure it was up to date.

# The website

I've lost count of the amount of hours I've spent on this website. Again, it's had so many redesigns. I didn't think I'd finish it - ever, gotten use to the fact it would be a 'nice to have'. Due to my current situation, it provided me with much needed motivation and drive to finish it once and for all.

# I finished it

I'm so proud of myself for actually finishing a personal project and in turn I'm feeling motivated to get a wiggle on with my other ones on the to-do list. A few tweaks here and there needed but other than that, I'm over the moon.

![Alt Text](https://media.giphy.com/media/oO8TIuoxAb9Lzw6VGi/giphy.gif)
Portfolio Review
Tags: showdev, webdev, css, javascript
Published: 2020-07-17 02:15:47

Hey everyone! My name is Thomas and I am a Mobile Applications Developer working with Ionic/Angular for 1st Phorm. Over the past few years I have been slowing tweaking and adding items to my portfolio and I was wondering what y'all think and if there's anything I should add/change? I want to make this a very interactive, and in-depth portfolio (and I also love software Easter Eggs so there are a few in there). Thanks for any constructive critism.

You can find my portfolio below:

http://thethomasgeorge.com

-Thomas
Github Arctic Code Vault Contributor 2020
Tags: contributorswanted, github, opensource, githunt
Published: 2020-07-17 02:06:37

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

{% github coolanant/Data_Structures_Crash_Course %}

Follow me - https://github.com/coolanant
Follow me - https://github.com/anant016
WebdriverIO - Reusable Functions
Tags: testing, javascript, tutorial, beginners
Published: 2020-07-17 01:24:13

As you start expanding your test framework, you may often find yourself reusing the same code in multiple places causing test maintenance to become difficult in the long run.

You can optimize many of your tests by reusing your code and taking advantage of helper functions. Let's take a look at some examples below: 

❌ **Wrong Way** 
Repeating same code multiple times all over the place - 
```javascript
it('should update the search category', () => {
    browser.waitUntil(
      function () {
        return SearchPage.category.getText() === 'PC Laptops & Netbooks';
      },
      { timeout: 3000 }
    );
    expect(SearchPage.category).toHaveText('PC Laptops & Netbooks');
  });

// I'm repeating pretty much exact same code below
// for a similar scenario
it('should update text after clicking button', () => {
    browser.waitUntil(
      function () {
        return OtherPage.selector.getText() === 'Some text';
      },
      { timeout: 3000 }
    );
    expect(OtherPage.selector).toHaveText('Some text');
  });
```

✔️ **Right Way** 
Reusing code by creating a helper function

```javascript
// create a helper file ex: helper.js
// In that file, create a reusable function with generic params for your scenario
export const waitForTextChange = (el, text, timeout) => {
  browser.waitUntil(
    function () {
      return el.getText() === text;
    },
    { timeout }
  );
};
```

```javascript
// Import the reusable function in your tests
it('should update the search category', () => {
    waitForTextChange(SearchPage.category, 'PC Laptops & Netbooks', 3000);
    expect(SearchPage.category).toHaveText('PC Laptops & Netbooks');
  });

it('should update text after clicking button', () => {
   waitForTextChange(OtherPage.selector, 'Some Text', 3000);
   expect(OtherPage.selector).toHaveText('Some text');
  });
```
As you can see, we reduced multiple lines of code into a single line using reusable functions by simply taking advantage of plain JavaScript. 🙌 

---

#### Check out the video below for a detailed explanation of the code above, as well as some other quick tips on how to optimize your test framework.

{% youtube XEqbOMc0hf0 %}

💎 This code is also available on [GitHub](https://github.com/automationbro/webdriverio-tutorial/tree/optimize-test-framework-12) for you to access and play around with.

---

#### To learn more about WebdriverIO, check out my free tutorial series on Youtube -
https://www.youtube.com/watch?v=e8goAKb6CC0&list=PL6AdzyjjD5HBbt9amjf3wIVMaobb28ZYN.
Don’t play stupid with the security of your app
Tags: security
Published: 2020-07-17 23:08:34

---
title: Don’t play stupid with the security of your app
published: true
date: 2020-07-17 01:09:00 UTC
tags: Security
canonical_url: https://boobo94.xyz/security/dont-play-stupid-with-the-security-of-your-app/
---

These days I had a very big issue which leads me to write 3 articles, so I think this was a big plus because I had a long time with no posts. Trying to understand, how from nowhere, one of our servers is not properly working I discovered a huge problem related to permissions on the EC2 instance.  
  
Our server has exposed the 22 port and some good boys figure this out and tried to brute force the access. I canceled immediately the public access for that port and I think this maybe is helpful for you.

## How it looks like in logs

```
Jul 15 07:11:42 ip-X-X-X-X sshd[9037]: Disconnected from invalid user user1 111.229.196.130 port 42312 [preauth]
Jul 15 07:11:42 ip-X-X-X-X sshd[9037]: Received disconnect from 111.229.196.130 port 42312:11: Bye Bye [preauth]
Jul 15 07:11:41 ip-X-X-X-X sshd[9037]: Invalid user user1 from 111.229.196.130 port 42312
10:14
Jul 15 07:11:57 ip-X-X-X-X sshd[9039]: Disconnected from invalid user uat 139.155.93.180 port 43756 [preauth]
Jul 15 07:11:57 ip-X-X-X-X sshd[9039]: Received disconnect from 139.155.93.180 port 43756:11: Bye Bye [preauth]
10:14
Jul 15 07:12:29 ip-X-X-X-X sshd[9042]: Disconnected from invalid user henry 106.12.111.201 port 36280 [preauth]
Jul 15 07:12:29 ip-X-X-X-X sshd[9042]: Received disconnect from 106.12.111.201 port 36280:11: Bye Bye [preauth]
Jul 15 07:12:28 ip-X-X-X-X sshd[9042]: Invalid user henry from 106.12.111.201 port 36280
10:14
Jul 15 07:13:02 ip-X-X-X-X sshd[9044]: Disconnected from invalid user jojo 49.233.197.193 port 39912 [preauth]
Jul 15 07:13:02 ip-X-X-X-X sshd[9044]: Received disconnect from 49.233.197.193 port 39912:11: Bye Bye [preauth]
Jul 15 07:13:01 ip-X-X-X-X sshd[9044]: Invalid user jojo from 49.233.197.193 port 39912
```

The post [Don’t play stupid with the security of your app](https://boobo94.xyz/security/dont-play-stupid-with-the-security-of-your-app/) appeared first on [boobo94](https://boobo94.xyz).