teleren/devto huggingface dataset:
Solved: .NET Core Azure AD in Docker Container Incorrectly Uses a non-https redirect URI
Tags: azure, docker, containers, dotnetcore
Published: 2020-06-25 11:08:49

---
title: Solved: .NET Core Azure AD in Docker Container Incorrectly Uses a non-https redirect URI
published: true
date: 2020-06-18 11:00:00 UTC
tags: azure,docker,containers,dotnetcore
canonical_url: https://seankilleen.com/2020/06/solved-net-core-azure-ad-in-docker-container-incorrectly-uses-an-non-https-redirect-uri/
---

I’ve hit this problem several times and only recently figured it out.

## Problem

- I’ve created a new .NET Core MVC Web application. I’ve enabled Azure AD auth (as this app is for my employer) and I’ve added a Linux container support to the application as well.
- I configure everything as expected, and deploy to an Azure container webapp, being sure to enable https-only.
- I’ve registered my app in Azure AD and ensured the redirect URLs are set.

I’d expect to be able to authenticate, but instead I see:

> AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application

And when I look at the URL, indeed my webapp appears to be passing along a redirect URI that begins with `http`, not `https`.

## The Issue

I started [an issue in the ASP.NET Core Repository](https://github.com/dotnet/aspnetcore/issues/22572) to try to get to the bottom of it.

[Barry Dorrans](https://twitter.com/blowdart) (Thanks Barry!) aptly noted:

> Inside the container it’s likely that your app is listening on HTTP, and Azure is terminating the HTTPS at the load balancer before forwarding the requests onward.

This seems to be a templating issue more than anything. When enabling both Azure AD login and Docker support, you need to be sure to forward headers. But, this doesn’t happen out of the box with the template. (I’ve created [an issue on the templating repository](https://github.com/dotnet/templating/issues/2394) to try to address that.)

## The Fix

The fix comes in two parts.

First, in the `ConfigureServices` method of your `Startup.cs` class, add:

```csharp
services.Configure<ForwardedHeadersOptions>(options =>
{
	options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
							   ForwardedHeaders.XForwardedProto;
	// Only loopback proxies are allowed by default.
	// Clear that restriction because forwarders are enabled by explicit 
	// configuration.
	options.KnownNetworks.Clear();
	options.KnownProxies.Clear();
});

```

You’ll also need to bring in a reference: `using Microsoft.AspNetCore.HttpOverrides;`

This sets up the header forwarding for https.

Secondly, make sure you actually make use of that configuration by adding the below in the `Configure` method of your `Startup.cs`:

```csharp
app.UseForwardedHeaders();
```

I mention it because I’ve forgotten that step twice now and then been confused as to why my changes didn’t work. :laughing:

* * *

If you’ve run into a similar problem, I hope this helps. Happy coding!
Native VS Hybrid App 
Tags: reactnative
Published: 2020-06-18 10:49:07

The moment you consider investing in a mobile app, you’re immediately faced with a barrage of terminology.

What are Native apps and Hybrid apps?

More importantly, which is the most appropriate app type for you and your business?

If you’re looking for answers to these questions, then this post is for you.

One of the first decisions you’ll face is which type of app to build. And there is no single, definitive answer. Your choice will depend on a bunch of competing factors, including your budget and your deadline.

The aim of this post /discussion is to give you a sound understanding of the different types of apps available and to aid your decision as to what technology you should use to build your app.

https://ateam-texas.com/native-vs-hybrid-app-how-to-choose-which-is-the-best-for-my-product/
GitHub's repo redesign
Tags: github, ui, news
Published: 2020-06-18 10:44:09

I woke up this morning to a notification from GitHub about a new design of the repo page. It's a feature they haven't rolled out yet but everyone can test. It's also responsive which is really cool!

Here's how it looks.

![New GitHub repo design](https://dev-to-uploads.s3.amazonaws.com/i/dlf2226l6d23l6iqm5k5.png)

### How to enable it

Click on your profile in the upper right corner -> Feature Preview -> "Repository refresh" in the list -> Click the Enable button.
Send RSS Feeds to Discord Bots with WayScript
Tags: wayscript, discord, rss
Published: 2020-06-18 10:44:08

Introduction
------------

Staying informed today is capital for teams: you must be aware of market news, you must know the next moves of your competitors and be alerted of new releases.  
Many blogs exist for this purpose and we can easily get the articles via RSS.  
Today, we’ll create a script that posts the last article of Techcrunch in a Discord Channel

Prerequisites
-------------

No prerequisites but here are some contents you might find useful :

*   [Working with RSS](https://docs.wayscript.com/library/modules/rss-feed)
*   [Working with Discord](https://docs.wayscript.com/library/modules/discord)
*   [Create a variable](https://docs.wayscript.com/getting_started/variables)

Time Trigger
------------

For this example, the script will run hourly. As Techcrunch produces more than 25 articles per day, the choice of the time is fairly good.

![Configuring Time Trigger](https://cdn.wayscript.com/blog_img/108/1.png)

RSS Feed
--------

Wayscript provides a module that lets you retrieve RSS items with a given URL. You can get links to the most popular Word news RSS feed [here](https://blog.feedspot.com/world_news_rss_feeds/). We will use TechCrunch RSS feed link https://feeds.feedburner.com/TechCrunch/.

![Configuring RSS feed module](https://cdn.wayscript.com/blog_img/108/2.png)

If you've finished the configuration, you will notice new created variable.

![RSS feed struct](https://cdn.wayscript.com/blog_img/108/3.png)

Well, this variable contains a lot of information such as articles title, links, authors, etc. But here we want the latest article, so we’ll retrieve the first entry and register it in a variable.

Create a variable
-----------------

Add a new step and select add variable.

![Creating variables](https://cdn.wayscript.com/blog_img/108/4.png)

For the sake of simplicity, we will register the first entry in a new variable. Now we can easily manipulate this item.

Discord
-------

Work with Discord using Wayscript platform is ver easy. You can write or read message on a channel and seamlessly create bots. Add Discord a new step and let’s configure it.

![Discord Configuration](blog_img/5.png)

Great! We can write the message we want to post on the channel.

![Message](https://cdn.wayscript.com/blog_img/108/6.png)

I only used the RSS item link only because Discord will automatically embed the message.

![Post on channel image](https://cdn.wayscript.com/blog_img/108/7.png)

Isn't it beautiful? :)

Conclusion
----------

Questions about this script or anything else? Join our [discord](https://discord.gg/VWbXSbj). We're always around to help. If you want to work the full script template, just find it [here](https://wayscript.com/user/mangabo_kolawole/-3A-mZlp).
Questions about float-point numbers
Tags: beginners, javascript
Published: 2020-06-18 10:09:41

I roughly know how float point system works. But I don't know why the second looks normal?

If I run
```
console.log(1.01+2.05);
console.log(1.01+2.05+4.21);
```
I'll get
```
3.0599999999999996
7.27
```

Also, I see some people multiply the number by 100 and add them up, finally divide it by 100. Doesn't this solution have any problem? What if the number is really big? There's overflow concern, isn't it?
DAY 8: DICTIONARIES
Tags: python, beginners
Published: 2020-06-18 10:08:57

Things are starting to become more tough and its taking longer to solve the challenges but the positive side of that is it’s the learning journey. Nothing worth doing is ever easy and the feeling of learning something new that you did not know before is an achievement worth recognizing.

Dictionaries are part of the data structures in Python which store their values in form of key-value pairs.

**The task:**
Given *n* names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each *name* queried, print the associated entry from your phone book on a new line in the form *name=phoneNumber*; if an entry for *name* is not found, print *Not found* instead.

```python
n = int(input())

#create a dictionary variable
d = dict()

#accept input from the user and add the input into the dictionary variable
for i in range(0, n):
    name, number = input().split()
    d[name] = int(number)

#accept input by looping through the input size for names to search for in the dictionary.
for i in range(0, n):
    try:
        name = input()
        if name in d:
            print(f"{name}={d[name]}")
        else:
            print("Not found")
    except:
        break
    

'''
Sample Input:

3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry

Sample Output:

sam=99912222
Not found
harry=12299933

'''
```
7 Useful Javascript Tips
Tags: javascript, beginners
Published: 2020-06-18 09:31:56


### 7 Useful Javascript Tips

Without further ado, lets dive into it:

1.  **Filtering falsy values:**

If you have an array of values, you can filter out falsy values(`null` `undefined` `0` `""` `NaN` `false` ) with `Boolean()`

```
//Example 1
const x = ["a","",3,false,"hello",undefined]
const y = x.filter(Boolean);

console.log(y) // ["a",3,"hello"]

//Use it like this
myArray.filter(Boolean);

```

**2. Floor a decimal number instead of `Math.floor()`** 
Useful for when you want to show whole numbers
(Edit: This removes decimal numbers so it actually acts like `Math.ceil()` for negative numbers, credits to @[veljko94pesic](https://dev.to/veljko94pesic))

```
//Example 1 
const x = 1.5 
const y = ~~x   
console.log(y) // Equals 1  
```

```
//Example 2
const a = -1.5
const b = ~~a
console.log(b) // Equals -1
```

```
//Example 3 
const z = ~~2.73123 
console.log(z) // Equals 2   

```

**3. Implicit boolean coercion**
Change a value into a boolean (Instead of `Boolean(value)`)

```
const x = {} 
const y = !!x //Equals true 
console.log(y) // true

```

**4. Last items in an array**
You can use Array.slice() with negative indicies to count backwards.

```
let array = [0, 1, 2, 3, 4, 5, 6, 7, 8]  

```

```
console.log(array.slice(-1)); // Equals [8]

console.log(array.slice(-2)); // Equals [7, 8]

console.log(array.slice(-3)); // Equals [6, 7, 8]

```

**5. Implicit number coercion using `+`**

Putting a `+` in front of any value will attempt to change it to a number, similar to `Number(value)`. This can also be used for Date objects as an alternative to `Date.getTime()`

```
//Example 1 
const x = new Date() 
const y = +x 
console.log(y) //Equals 1591887393586 (gives back time in ms)

```


Useful for doing this (get time 10 seconds later) 

```
const z = new Date(+new Date() + 10 *1000)
console.log(z) //Equals 1591887403586

```

**6.Method parameter validation** 
Lets you throw an error if input not given

```
const isRequired = () => { throw new Error('param is required'); };
 
const print = (value = isRequired()) => {   
    console.log(`${value}`)  
};  

```

```
print(2);// Equals  2  
print()// Throws error  
print(null)// Equals null

```

**7.Swallow errors for promise all**

Normally, `Promise.all()` will throw if any promises inside its array rejects. We can ignore errors by using map and catch for each promise.

```
const promiseArray = [
    Promise.reject(null),
    Promise.resolve(100),
    Promise.resolve("More data"),
    Promise.reject(new Error('Throw an error here'))
];

```

```
//Map and catch for promises 
//And just console.log them 
const all = await Promise.all(
    promiseArray.map(p => p.catch(console.log))
)

```
Thats all!
Do you have any Javascript tips?
Feel free to leave them as a comment below 🙂
VS Code Account || Sync !?
Tags: vscode, webdev, javascript
Published: 2020-06-18 09:53:43

Tired of installing extensions, themes, and your VS Code preferences in all devices?

##Then have a look at this vscode extension,

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

With one-click install, you can 
>Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces, and Extensions Across Multiple Machines Using GitHub Gist.

###Steps to follow,

- Install the extension in the vscode.
- Authorize your GitHub account.
- It will create a Gist and upload all your settings, workspaces, themes and all.
- You can download / share/upload your settings to multiple devices or vscode applications.
- The extension automatically uploads the change when done in any setting.

###Shortcuts:

```sh
- Upload setting Key : Shift + Alt + U
- Download setting Key : Shift + Alt + D
```
or 

```sh
Ctrl + Shift + p then search Sync, there you can make your uploads.
```

Learn more about this extension here,

>https://github.com/shanalikhan/code-settings-sync

Also in the extension details : 

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

####Note: VScode also provides option for settings sync and its only available on VScode insiders.(https://code.visualstudio.com/docs/editor/settings-sync)

>Comment if you know any alternatives.

######Disclaimer: I am not promoting any product and using this will at your own wish and risk.
Using MySQL with Entity Framework Core and ASP.NET Core
Tags: csharp, dotnet, mysql, aspnetcore
Published: 2020-06-18 09:22:43

With the introduction of Entity Framework Core also the support of other databases then SQL got a boost. Off course there was support for MySQL in Entity Framework, but the NuGet package still had some problems and you could end up with a large variety of runtime errors when executing even the simplest of queries. Entity Framework Core added better support for database providers and you can see this in the quality and quantity of providers. [Database Providers - EF Core](https://docs.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli)

Using these providers is also a breeze. If we look at the default template of an ASP.NET Core application with EF Core and SQL. You will see something like this in the ConfigureServices method of the StartUp class.   
```csharp 
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(config.GetConnectionString("DefaultConnection")));
```
To start using MySQL the only thing needed is to configure another Database Provider. You can use the MySql.Data.EntityFrameworkCore package (or the Pomelo.EntityFrameworkCore.MySql) for this. When installed you can just change this configuration to:

```csharp
services.AddDbContext<ApplicationDbContext>(options =>
options.UseMySQL(config.GetConnectionString("DefaultConnection")));
```

After updating the connection string to your MySQL instance try running your migrations and see if it works. I had some problems with the key of the default IdentityUser that didn’t had a MaxLength. Those were all small problems that were fixed easily. After this you should be all setup to continue developing against a MySQL database.
How to start preparation for JavaScript interview
Tags: java, interview, javascript, syntax
Published: 2020-06-18 09:12:46

<b> What is JavaScript? </b>

Javascript is one of the most widely used web programming languages. It is mainly used to build interactive Web applications and games on the client-side. Even Javascript can be used as a programming language on the server-side. It is a complex, loosely typed, a high-level programming language based on prototypes and multi paradigms.

<b> What does the hiring team look for? </b>

In an interview that involves programming skills, it is not just about the Syntax. It's about realizing how to better use the concept (and syntax) of JavaScript to rectify the final problem. 
How much do you functionally understand the language? How efficiently can you use these theories to solve real problems with the work? 
How do you write the code (conventions for encoding, syntax, reusability)? Do you want to spend half of your life debugging syntax errors? 
What is your process of thinking? How do you think of the problem, find a solution, and turn it into a working code?

Apart from this, they look for your communication skills and how much confidence you have while you are answering them. So, constantly working on both technical skills and soft skills is important.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2t67yagn7teqezefyhpf.jpg)

Now, below are some of the skills that you must cover before appearing for that dream interview:
1. Javascript core concepts such as hoisting, closures, scopes (lexical, function, block), this keyword, prototypal inheritance, call-bind-apply, throttle-debounce, callback, callback-hell, etc.
2. Javascript recent trends such as ES6 syntax, typescript, classes, arrow functions, promises, async-await
3. Learn one framework out of ReactJS, Angular, VueJS
4. Development and build process such as Visual Studio IDE, npm, babel etc.

<b> Final Preparations for the Interview </b>

Lastly, once you think that you have prepared yourself extensively, then try to look at some of the <a href="https://codersera.com/blog/23-javascript-interview-questions-and-answers/"> JavaScript Questions </a> that have been asked in the interviews. These questions will help you a lot when you are in front of the interviewer and will make you seem confident. These are frequently asked questions and very basic ones too, so it’s always good to know their answers.

Moving ahead and depending upon the profile you are applying for, there might be a requirement of having extensive knowledge of <a href="https://codersera.com/blog/advanced-javascript-interview-questions/"> Advanced JavaScript Questions </a>. Preparing for one step ahead will gradually boost your confidence and make you aware of the many concepts of the language.

Have a thorough look at these questions before you step in for the interview as they will keep your memory fresh with the JavaScript concepts. Your comprehensive knowledge will reflect in the interview and will definitely help you land the job of your dreams.
Materialize CSS Buttons Palette Kit
Tags: css, html, webdev, weeklyui
Published: 2020-06-18 09:11:05

![Materialize CSS Buttons Palette Kit](https://i2.wp.com/w3hubs.com/wp-content/uploads/2020/06/Materialize-CSS-Buttons-Palette-Kit-e1592470956314.png?resize=360%2C210&ssl=1)

Materialize is a modern browser responsive Front-end CSS framework and base of google marital design. So here we made a button kit of Materialize CSS with the help of Materialize CSS background classes & also we used some basic CSS properties.

In this kit, we used background color classes of Materialize CSS and also we used btn-small & btn-large too. Here we also modify one Materialize CSS class which is lighten-5 because in this class have text color properties is white, Which is not good to show. So here we used custom color which looks like black color. We don’t use here a single line of media queries.

Make it yours now by using it, downloading it and please share it. we will design more elements for you.

[Get Source code](https://w3hubs.com/materialize-css-buttons-palette-kit/)
Uninstalling Docker From Windows 10
Published: 2020-06-18 08:46:22

I installed Docker on windows 10 pro today with virtualization enabled. After the installation, I noticed that my system has become very very slow and many apps  turned out to be unresponsive too. When I tried to uninstall it, it got stuck on uninstalling screen. I tried uninstalling it after rebooting my system but with no success at all. 

Then I tried to search this issue on google if it is a known issue or it has something to do with my system. After reading multiple issues raised on Github and docker forums I got to know that it is a known issue but I could not find any simple solution to uninstall it. 

After much thought and searching, I tried disabling docker from startup at boot in task manager and rebooted my system. Luckily everything was back to normal, and I was able to uninstall it from control panel.
Convert .ppk key for ssh connection on linux
Tags: linux, ssh, putty, ppk
Published: 2020-06-18 08:59:29

If you want to use a ssh key as a `.ppk` file (putty format) on linux, first you need to convert it.

To do it, install `putty-tools`:
```
sudo apt-get install putty-tools 
```

Now you can convert your key from `.ppk` format to `.key` format:
```
puttygen <your_key_name>.ppk -O private-openssh -o <your_key_name>.key 
```

And voilà! 😀
You can use it to open your ssh connection:
```
ssh -i <your_key_name>.key <user>@<server-ip>
```
How to Solve a AWS Lambda error - Runtime.ImportModuleError: Error: Cannot find module 'jmespath'
Published: 2020-06-18 08:56:50

---
title: How to Solve a AWS Lambda error - Runtime.ImportModuleError: Error: Cannot find module 'jmespath'
published: true
---

AWS Lambda scripts written in nodejs8 were deprecated.
You run the same scripts via AWS Lambda nodejs10 or nodejs12 environment and may hit the following error message. 

```
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'jmespath'","stack":["Runtime.ImportModuleError: Error: Cannot find module 'jmespath'","    at _loadUserApp (/var/runtime/UserFunction.js:100:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)","    at Object.<anonymous> (/var/runtime/index.js:36:30)","    at Module._compile (internal/modules/cjs/loader.js:701:30)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)","    at Module.load (internal/modules/cjs/loader.js:600:32)","    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)","    at Function.Module._load (internal/modules/cjs/loader.js:531:3)","    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)","    at startup (internal/bootstrap/node.js:283:19)"]}
```

I hit the same problem Error: Cannot find module 'jmespath' and solved it.

Do you use `aws-sdk` via node_modules? like follows

```
var aws = require('aws-sdk');
```

If so you just remove aws-sdk from node_modules.

to remove aws-sdk for yarn 
```
yarn remove aws-sdk
```

remove aws-sdk for npm
```
npm uninstall aws-sdk
```



aws-sdk has been included to lambda since nodejs10. see: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html


{% stackoverflow 62446000 %}
MediaRecorder power UP!
Published: 2020-06-18 08:51:46

After a long time fiddling with MSE(MediaSourceBuffer) and canvas to record video/audio from a HtmlVideoElement where the stream constantly change between screen sharing and camera I finally found a solution to keep recording without MediaRecording stop recording.

Luckily I was not the only one with this problem see the following references:

- https://discourse.mozilla.org/t/switch-stream-in-media-recorder/27619/3
- https://stackoverflow.com/questions/59846230/mediarecorder-switch-video-tracks

So what did I do? I used the following example:
- https://webrtc.github.io/samples/src/content/peerconnection/pc1/

I used the above sample code to create a new library that extends MediaStream functionality to change streams with the MediaRecorder breaking.

So what happens?
- Setup local PeerConnection on the same website. webcam/screen Stream -> "remote" Video
- Once the sender start sending the stream it makes an RTPSender and that has the changeTrack capability
- Save the RTPSender and use it to switch streams. This will end up in the "remote" Video
- Attach the MediaRecorder to the "remote" Video and start recording.

No you are able to switch the streams on the "local" video and it directly sends it to the "remote" Video.

I made the library open source and you can find it here [StreamSwitcher](https://github.com/meething/StreamSwitcher) also there is a demo so feel free to try out [DEMO](https://meething.github.io/StreamSwitcher/)

This library is part of [Meething](http://web.meething.space/) a privacy first browser based video conference using dweb technology. Feel free to try out.