teleren/devto huggingface dataset:
What is a Tensor?
Tags: tutorial, machinelearning, beginners, deeplearning
Published: 2020-09-08 15:59:19

Tensor is one of the most basic concepts to master in Machine & Deep Learning.

### Definition
* An n<sup>th</sup> rank tensor in m-dimensional space is a mathematical object that has n indices and m<sup>n</sup> components and obeys certain transformation rules.<sup>1</sup>

Tensors are invariant under a change of coordinates, and have components that change in a special, predictable way if there is a change in coordinates. The tensors in three-dimensional Euclidean space are called Cartesian tensors.

Tensors are identified by 3 parameters -
* *Rank*: It represents the number of dimensions of the tensor.
* *Shape*: Number of components in each of the dimensions represent shape of the tensor. For Example, for a 2 dimensional tensor, if it has 2 components in first index, and 3 components in the second index, then its shape would be (2,3).
* *Type*: It represents the type of data that the tensor contains.

### Popular Terminology
* **Scalars** Tensors with rank = 0, are known as scalars or Rank-0 tensors.
* **Vectors** Tensors with rank = 1, are known as scalars or Rank-1 tensors.
* **Matrices** Tensors with rank = 2, are known as scalars or Rank-2 tensors.
* **Three-Dimensional Arrays** Tensors with rank = 3, are known as scalars or Rank-3 tensors.

### Examples
{% gist https://gist.github.com/rajrohanyadav/6026636b862035941229778845ba8cc2 %}

### Footnotes
* <sup>1</sup>[MathWorld Tensor Definition](https://mathworld.wolfram.com/Tensor.html)
Just Imagine: 
Installing Linux from a running Windows system, without need for a live USB.
Tags: linux, windows, devops, beginners
Published: 2020-09-08 15:59:08


Install Linux from a running Windows system, without need for a live USB.

Meet Tunic ...

What Tunic Does:
-Validates your system meets Tunic requirements.
-Asks all questions at beginning (so you don't have to babysit the install).
-Offers full disk overwrite or dual boot arrangement.
-If dual boot, shrink C: volume to make space for Linux.
-Provides tools to assist with freeing up space for Linux.
-Disables Windows fast start.
Provides Linux Mint, Ubuntu and most official Ubuntu flavors.
-Downloads the Linux .iso file for you.
-Installs Grub with Secure Boot support.
-Calculates Linux equivalent values for your Windows locale and user account.
-Reboots and runs the Ubiquity installer, automated, (fully in RAM with mounts to the iso removed).
-If custom install type choosen, will provide Ubuntu's Ubiquity disk partiton GUI.
Reboots into your final installed Linux!


You can get repo here
{% github mikeslattery/tunic  %}

######***IMP REQUEST:***

###### You are most welcome to join my team 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3qhbvg5fsrh3nt7anh36.png)

[ Click here for joining my team ]
(https://forms.gle/pSCALuEWHus3pg9F6).

###### *Also you are most welcome to join OPEN SOURCE INTELLIGENT SYSTEM (OSINT) if you can help in open source project regarding safeguarding humans from various diseases like CORONA outbreak*
######https://github.com/Manishfoodtechs/OSINTHRH/wiki

Contact email: Manishfoodtechs@gmail.com. 

If you have any problem, our team is also engaged in professional consultancy and delivery.

![](https://media2.giphy.com/media/oNrPzIy3OhHm7zrvA3/source.gif)

Imagecredit: pixabay
Daily Challenge #289 - Manhattan Distance
Tags: challenge
Published: 2020-09-08 15:51:06

---
title: Daily Challenge #289 - Manhattan Distance
published: true
series: Daily Challenge
description: Manhattan distance is the distance between two points in a grid
tags: challenge
//cover_image: https://direct_url_to_image.jpg
---
The distance formula can be used to find the distance between two points. What if we were trying to walk from point A to point B, but there were buildings in the way? We would need some other formula, but which?

**Manhattan Distance**
Manhattan distance is the distance between two points in a grid (like the grid-like street geography of the New York borough of Manhattan) calculated by only taking a vertical and/or horizontal path.

Write a function manhattanDistance that accepts two points, pointA and pointB, and returns the Manhattan Distance between the two points.

pointA and pointB are arrays containing the x and y coordinate in the grid. You can think of x as the row in the grid, and y as the column.

**Examples:**
manhattanDistance( [1, 1], [1, 1] ) // => returns 0
manhattanDistance( [5, 4], [3, 2] ) // => returns 4
manhattanDistance( [1, 1], [0, 3] ) // => returns 3

**Tests:**
manhattanDistance( [1,2], [1,3] ) 
manhattanDistance( [5,2], [7,3] ) 
manhattanDistance( [1,2], [4,4] ) 

Good luck!

***
_This [challenge](https://www.codewars.com/kata/52998bf8caa22d98b800003a) comes from xDranik on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Dica Rápida: Removendo node modules para liberar espaço
Tags: node, npm
Published: 2020-09-08 15:39:40

Conforme vamos desenvolvendo projetos e estudos, os módulos node que usamos vão se acumulando e ocupando espaço no sistema, uma forma fácil de excluir é utilizando o pacote npkill.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bdit1da0t0zzap8ucrvs.gif)
O npkill faz uma busca no seu ambiente em busca das pastas ``node_modules`` listando elas para você e permitindo que sejam facilmente excluídas.
Para usar é só rodar o comando abaixo:
```shell
$ npx npkill
```
Seleciona as pastas que deseja e seja feliz ^_^
How to make Swift's [String: Any] decodable?
Tags: swift, codable, json
Published: 2020-09-08 15:30:50

Do you need to decode your JSON to `[String: Any]`? Here is how you can do this.

# Requirements

Answer is that you cannot do this using `Any` type. You need specify something more concrete than `Any`.

> Dictionary is automatically decodable if its elements are decodable. Type `Any` is not decodable.

However if you are looking for the answer it means that you actually have some kind of JSON which needs to be handled somehow. The topic is also related to array like `[Any]`.

# Solution

You need to specify finite number of possible values of your `Any` type. For example we expect that there are two different structures like following:

```
struct Payload: Codable {
    let id: String
    let eventName: String
    let metadata: [Metadata]
}

struct Metadata: Codable {
    let name: String?
    let price: Double?
    let rating: Int?
}
```

But of course you cannot do

```
let decodedData = try JSONDecoder().decode([String: Any].self, from: json.data(using: .utf8)!)
```

because there is used type `Any`.

First of all we need to figure out how JSON for this dictionary possibly looks like. It would be sth like this:

```
{
    "keyNumber1": {
        "type": "payload",
        "data": {
            "id": "someId1",
            "eventName": "Event Name 1",
            "metadata": []
        }
    },
    "keyNumber2": {
        "type": "metadata",
        "data": {
            "name": "Metadata Name",
            "price": 123.4,
            "rating": 100
        }
    }
}
```

Then it's simple because you need to define `enum` instead of your `Any` type like follows:

```
enum DataType: String, Codable {
    case payload
    case metadata
}

enum MyValue: Decodable {
    case payload(_ payload: Payload)
    case metadata(_ metadata: Metadata)

    private enum CodingKeys: String, CodingKey {
        case `type`
        case `data`
    }

    init(from decoder: Decoder) throws {
        let map = try decoder.container(keyedBy: CodingKeys.self)
        let dataType = try map.decode(DataType.self, forKey: .type)
        switch dataType {
        case .payload:
            self = .payload(try map.decode(Payload.self, forKey: .data))
        case .metadata:
            self = .metadata(try map.decode(Metadata.self, forKey: .data))
        }
    }
}
```

And decode JSON using following code:

```
let decodedData = try JSONDecoder().decode([String: MyValue].self, from: json.data(using: .utf8)!)
```

Full Playground code:

{% gist https://gist.github.com/absoftware/880561fb8ed343304598de2c2de24a29 %}
Porque Javascript vale (muito) a pena.
Tags: javascript, iniciante
Published: 2020-09-08 12:33:40

Este post é para você que está chegando agora no desenvolvimento de software e se pergunta se vale a pena investir seu precioso tempo aprendendo Javascript.

## 1. É versátil
A versatilidade de uma linguagem é crucial para quem está iniciando porque nessa fase o estudante não está maduro o suficiente para saber se a sua praia será front-end ou back-end, mesmo tendo uma certa idéia de onde quer chegar.

A presença do Javascript é muito marcante tanto no back-end quanto no front-end e todo conhecimento adquirido a respeito da linguagem é totalmente aproveitado em ambos os times.
Isso significa que você pode se jogar nos estudos e se preocupar com o seu foco mais pra frente, mudar de foco no meio da carreira e até ser um profissional tão versátil quanto a linguagem.

Em um outro post posso te explicar o porque ser versátil vai te deixar uma caminhada a frente de seus concorrentes.

![I love JS](https://dev-to-uploads.s3.amazonaws.com/i/xi8laewd1gcoslwyxvv1.png)

## 2. É fácil
O Javascript é realmente fácil e isso se deve a duas características: tipagem fraca e multi-paradigma.

A fraca tipagem alivia e muito o processo de aprendizado. Ao contrário de Java, por exemplo, vários conceitos complexos para quem nunca teve contato com o mundo do desenvolvimento podem sim ser deixados para depois (um depois próximo, por favor!) fazendo com que os resultados apareçam rapidamente.

Se você tem pressa em entrar no mercado de trabalho, Javascript pode ser uma ótima opção para você! Mas não se esqueça do seguinte: Javascript é fácil, e é muito mais fácil fazer coisas ruins com javascript.

## 3. A comunidade é incrível
A comunidade Javascript é gigante e receptiva. Existem vários e vários tutoriais e cursos (bons e ruins) a respeito da linguagem e qualquer dúvida é rapidamente respondida.

Além disso, existe muita coisa de ótima qualidade e pronta para uso que a comunidade disponibiliza gratuitamente para quem queira usar.



-
Não perca mais tempo e comece a aprender Javascript hoje mesmo!
Unity: How to Build & Run on iPhone
Tags: unity3d, games
Published: 2020-09-08 15:27:18

Recently I started playing with Unity & wanted to create a Game for iOS. But when I try to run it on my iPhone the process was not smooth.  

I had to face some challenges (not with Unity) & here's how I fixed them:

{% youtube DzH4UODL7Dc %}
Angular Form Controls and ngModels Don't mix
Published: 2020-09-08 15:26:51

**New Discovery**
Use ngModel instead!
{% link https://dev.to/jwp/angular-validation-using-ngmodel-55gf %}


According to Angular, in [discussing the ngModel and FormControls](https://angular.io/api/forms/FormControlName#use-with-ngmodel-is-deprecated).

**ngModel and FormControls Don't Mix**

>Use with ngModel is deprecated
Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and is scheduled for removal in a future version of Angular.

**Fallout**
This means then, that use of Pipes (on HTML side) for an input element do not work any longer.  Most content on StackOverflow shows tons of examples using the two together, don't do it. 

**But Why?**
I don't know their internal architectural discussions but expect that the wave of immutable architecture took hold.

If we use Form Controls, we are being moved into the immutability pattern.  The models that we once used for bindings are now replaced with the FormControl. The models themselves are to be set only twice in a particular workflow, once at start up time and then only once again when attempting to persist content for that control.

Mutable model architecture is on the outside of current Angular architectural trends.

**What's the solution?**
The pipe was a nice idea, it farmed off control for validation and formatting to another component. Indeed the FormControl overlapped some of that function. But if we are using Form Controls we have the ability to bypass Pipes.

**FormControl Change Event Handlers**

Assume an input element with SSN numbers, entered as string values, the model having a different value than the display. The model is just numeric when valid, while the display shows dashes in the numbers and or a string of hashes like this.

```
111
111-
111-22
111-22-3
111-22-3333

//or 

###-##-####

//model only winds up as
11122333
// or a semaphore such as 
0, -1, 999
```

**Replacing the Pipe**

```typescript 
this.formGroup
  .controls.ssn.valueChanges
  .subscribe((value) => { 
     // do something with every change
     // no keyup event handlers needed 
}
```
The event handler is responsible for validation and alteration of the data being displayed. The model, on the other hand is used for persisting the change and only when valid! 

**WorkFlow**
-Initialize the FormControl with hash tags based on semaphore.
- All FormControl changes do the same thing the pipe did, but are hooked to each change of the control.
- The form control values are changed to format the SSN number as the values change until the end when all is valid, the model is updated.

**Tip**
Avoid Stack Overflow problems in the change event handler as follows:

```typescript
if (newFormat === change) return;
this.formGroup
  .controls.ssn
  .setValue(newFormat);
```

Our newFormat inserts the dashes as the user types. The problem is that each time we use setValue, we fire off another change! We have to stop the spiral-of-death and only set the newFormat once. If the newFormat is the same as the change, return!
Reducing An Array of Strings to a Single Integer
Published: 2020-09-08 14:51:44

```typescript
let nums = ["333","44","5555"];
let singleNum = nums.reduce((acc,item)=>acc+=item);
// convert "333445555"
let finalNumber = Number.parseInt(singleNum);
// outcome
333445555
```

Note this only works when the input array is a string representation of numbers, easily handled by regex validation. 

The nicety of the reduce function allows us to iterate through each item in the array and using the accumulator, we concatenate each item. From there we use the built-in string to integer function found in the Number object. Voila! 

JWP2020 Array to Integer conversion
On .NET Episode: Using Twilio to send WhatsApp Messages
Tags: twilio, dotnet, whatsapp, messaging
Published: 2020-09-08 14:41:02

Twilio enables developers to add rich communication features to their applications via HTTP APIs that can be used with any programming language.

In this episode, Corey Weathers from Twilio shows us how we can use Twilio's integration with the WhatsApp messaging platform in our .NET applications

{% youtube eCVEJToGFjo %}

If you liked this video and would like to see some more of our .NET content, please subscribe to our [.NET Developers YouTube Channel](https://www.youtube.com/channel/UCvtT19MZW8dq5Wwfu6B0oxw).


## Useful Links
<ul>
<li><a href="https://www.twilio.com/quest" target="_blank">Twilio Quest</a></li>
<li><a href="https://www.twilio.com/docs/whatsapp/api" target="_blank">Twilio API for WhatsApp</a></li>
<li><a href="https://www.twilio.com/docs/sms/quickstart/csharp-dotnet-core" target="_blank">Programmable SMS Quickstart for C# with .NET Core</a></li>
<li><a href="https://docs.microsoft.com/azure/twilio-dotnet-how-to-use-for-voice-sms?WT.mc_id=ondotnet-devto-cephilli" target="_blank">How to use Twilio for voice and SMS capabilities from Azure</a></li>
</ul>
Day 54: Completed Design and Fixed a MongoDB bug
Tags: 100daysofcode, mongodb, css, html
Published: 2020-09-08 14:40:48

I encountered an error when updating data to postman. The code was partly working, i could send a post request with data and get back the Id and version generated by mongoDB. My data was mysterious disappearing between sending the request and receiving a response.

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

I lost count of the attempted solutions, but it started working somewhere in between. I still cannot trace back which one.

####Weather App
I am finally done with the html /css bit of it. I replaced the image with a background color. The hosted link: [Weather App](https://m-tee.github.io/Weather-App/)

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

Done for the day!
_Day 54_
Ask Octopus - What are release artifacts and how can I upload them?
Tags: octopus, tutorial, api, devops
Published: 2020-09-08 14:39:27

---
title: Ask Octopus - What are release artifacts and how can I upload them?
published: true
description: You have a file you want to attach to your deployment in Octopus Deploy?  You can upload them as artifacts during a deployment using the built-in function "New-OctopusArtifact" or via the API for external tools such as a build server.
tags: octopus,tutorial,api,devops
series: Ask Octopus
---

You have a file you want to attach to your deployment in Octopus Deploy?  You can upload them as artifacts during a deployment using the built-in function "New-OctopusArtifact" or via the API for external tools such as a build server.

{% youtube 49mWe39UJp4 %}

Do you have a question about how to use Octopus? Email advice@octopus.com and someone from our team will get you an answer. You might even see it in a future episode.

Join our community slack at https://octopus.com/slack
ImportError in AWS Lambda function
Tags: python, aws, serverless, beginners
Published: 2020-09-08 14:27:18

---
title: ImportError in AWS Lambda function
published: true
description: Fixing ImportError in Python AWS Lambda function
tags: python, aws, serverless, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/xx5cs6ok5jezxfntudoo.jpg
---

I recently stumbled across an **import error** when deploying  an AWS lambda function via **SAM**.

I used the following folder structure:

```
src/lambda.py
template.yml
```

Lambda.py:
```python
def lambda_handler(event, context):
    print('hello world')
```
Template.yml:
```yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  Lambda:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src.lambda.lambda_handler
      Runtime: python3.8
      Events:
        SchedulingEvent:
          Type: Schedule
          Properties:
            Schedule: rate(5 minutes)
```

Once deployed, the following error was raised:
```python
Runtime.ImportModuleError: Unable to import module 'src.lambda': No module named 'src'
```

Since I copied the template and the lambda code from another project I was really baffled why I didn't work out of the box. Then I realized the little `__init__.py` was missing in the source folder...

Don't forget to add an empty `__init__.py` file to the src folder if you use the same project structure!
If you set Handler to `src.lambda` in your `template.yml` the lambda environment is looking for a python module called `src` therefore a `__init__.py` is required.
Exploring files inside of docker container in windows
Tags: docker, dotnet
Published: 2020-09-08 14:19:29

> Recently i got interested to explore whats inside of an docker image. How the files would have been organized?. Lets find out.

##### Prerequesite
* Running docker image
* Powershell

I have took two images for exploration, 
```
docker ps
```
![docker-ps](https://dev-to-uploads.s3.amazonaws.com/i/viougxiuccekqpfrz72v.PNG)
 
1. **firstcontainer** .Net Core mvc (.net core 2+)
2. **ctiqaui** .Net Framework mvc (Mvc 5)

```
docker exec -t -i firstContainer powershell
```
The above command will open the powershell terminal inside of docker directory.

![docker-exce](https://dev-to-uploads.s3.amazonaws.com/i/jbuypslaxs8mfls1y68i.PNG)

![docker-pw](https://dev-to-uploads.s3.amazonaws.com/i/szml54pewi1thk0clsht.PNG)

Great!. We are inside of docker!!

Now we can use regular windows commands to explore the directories.

```
ls
```
![docker ls](https://dev-to-uploads.s3.amazonaws.com/i/6ptzqstglkcix9uoelme.PNG)

so the app folder consist of all the complied codes of .net core app. 

lets explore root directory.

```
cd ..
ls
```
![docker cd](https://dev-to-uploads.s3.amazonaws.com/i/utmo4ci0q0iagsc13tsc.PNG)

We can see docker windows image files and app folder to host .net core app.

Lets open up .net framework MVC5 app container and compare with .net core.

![docker mvc](https://dev-to-uploads.s3.amazonaws.com/i/yrxvepg0aexh37qn39bb.PNG)

It contains windows server core file and IIS to host mvc 5 app.

To come out of the powershell session just press
```
ctrl + z
```
Coding Challenges
Tags: javascript
Published: 2020-09-08 14:15:37

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

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

3)Hard ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8f077n2i91ibs2ezud59.png)
JSKongress meets Mozilla SpiderMonkey 
Published: 2020-09-08 14:15:28


We are so cheerful to be able to announce episode #5!&nbsp;   Looking forward to JSKongress meets friends #5 on **September 29, 5:30 pm** (CEST). Join us when we will be talking about **SpiderMonkey, the JavaScript engine in Firefox**, with the Mozillians **Yulia Startsev and Iain Ireland**. Anything you ever wanted to know? Send us your questions to hello@js-kongress.com or comment

---

We are so cheerful to be able to announce episode #5!




**Code of Conduct**
First of all, everyone involved with JS Kongress has to agree to the Code of Conduct. You agree to comply by participating. Quick version: Be nice to each other and smile! For detailed version go to [js-kongress.com/Code-of-Conduct](http://js-kongress.com/Code-of-Conduct?fbclid=IwAR2Y9Iys59dUelvSHYZVpXvqk4tjcik5bBbAOu5PzVVP6BEyWc8i1OGHWOo)



**YOUR guests**

Please get to know **Yulia and Iain**, we are so happy that they confirmed!

![](https://js-kongress.com/wp-content/uploads/2020/09/46193940-e5e2-4da5-9ea6-728b0bc4aa0e.png)Yulia

**Yulia Startsev**
[@ioctaptceb on Twitter](https://twitter.com/ioctaptceb)

Senior Software Engineer for SpiderMonkeyJS at Mozilla, dowager chair TC39. Working on European Computer Manufacturers Association Script.

Top-level await is in her current focus for SpiderMonkey among others.



![](https://js-kongress.com/wp-content/uploads/2020/09/fe6d0025-4d5d-4039-a41b-1ab3bd2bba2f.png)Iain

**Iain Ireland**
[@Iainlreland on Twitter](https://twitter.com/Iainlreland)

Senior Software Engineer for Mozilla on SpiderMonkey, the JavaScript engine. He lives in Canada.

One of his “babies” at SpiderMonkey is the Regular Expression engine.



**SpiderMonkey** is the JavaScript engine in Firefox. Let’s talk about:

- What is SpiderMonkey? Where did it come from?
- Mozilla Internals: How does the SpiderMonkey Team work?
- Standardization & Optimization
- Garbage Collector & JIT
- byte code emitter & parser



Anything you ever wanted to know? Ask Yulia and Iain!

Join us on **September 29th, 05:30 pm** (CEST) when we discuss Mozilla SpiderMonkey. Add your topics, send us your questions to hello@js-kongress.com