teleren/devto huggingface dataset:
Use Python 3.8 for Azure ML Custom Image
Tags: azure, azureml, docker
Published: 2020-10-26 03:49:52

Azure Machine Learning (ML) service is great place for MLOps. As each project may require different dependencies, the service support to use custom image as its base image when running experiment.

[Create & use software environments in Azure Machine Learning](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-environments)

There is sample Dockerfile to create custom image at [Create a custom base image](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-custom-docker-image#create-a-custom-base-image) for ubuntu 16.04 and python 3.7.

If you want to use python 3.8, [Azure ML SDK 1.16 supports python 3.8](https://docs.microsoft.com/en-us/azure/machine-learning/azure-machine-learning-release-notes#2020-10-12) and you can update the Dockerfile to support it.

```Dockerfile
FROM ubuntu:16.04

ARG CONDA_VERSION=4.8.3
ARG PYTHON_VERSION=3.8
ARG AZUREML_SDK_VERSION=1.16.0
ARG INFERENCE_SCHEMA_VERSION=1.1.0

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH /opt/miniconda/bin:$PATH
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update --fix-missing && \
    apt-get install -y wget bzip2 && \
    apt-get install -y fuse && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

RUN useradd --create-home dockeruser
WORKDIR /home/dockeruser
USER dockeruser

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_${CONDA_VERSION}-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p ~/miniconda && \
    rm ~/miniconda.sh && \
    ~/miniconda/bin/conda clean -tipsy
ENV PATH="/home/dockeruser/miniconda/bin/:${PATH}"

RUN conda install -y conda=${CONDA_VERSION} python=${PYTHON_VERSION} && \
    pip install azureml-defaults==${AZUREML_SDK_VERSION} inference-schema==${INFERENCE_SCHEMA_VERSION} &&\
    conda clean -aqy && \
    rm -rf ~/miniconda/pkgs && \
    find ~/miniconda/ -type d -name __pycache__ -prune -exec rm -rf {} \;
```
One small but important change is miniconda installer address. It was Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh before, but now it's Miniconda3-**py38**_${CONDA_VERSION}-Linux-x86_64.sh for python 3.8.

The naming convention may change in the future, so checkout the valid installer download address at https://repo.anaconda.com/miniconda/
JavaScript Proxy
Tags: javascript
Published: 2020-10-26 03:32:18

I decided to take a break from the bash blogs I have been writing to cover something I recently discovered while traversing through the world of JavaScript, Proxies.

##What Are Proxies
A JavaScript Proxy is an object that wraps around another object and intercepts/redefines any operation on it. So in other words, A proxy watches what happens to an object and conducts methods defined by the programmer. To create a proxy you need an object and a handler function. An example is shown below

### Example: ###
```
const proxy1 = new Proxy(target, handler)

```   
The target is the object you are trying to control using the handler you define. A handler usually falls into four categories: lookup, assignment, enumeration, and function invocations. These functions can implement methods called traps. In this article, I will cover get() and set().

### get() Example: ###
```
const user = {
    firstName: 'John',
    lastName: 'Doe',
    email: 'john.doe@example.com',
}

const handler = {
    get(target, property) {
        return property === 'fullName' ?
            `${target.firstName} ${target.lastName}` :
            target[property];
    }
};

let proxy = new Proxy(target, handler);
console.log(proxy.fullName) //=> John Doe
```
The get trap is called when an object is accessed via the proxy item. It takes in the object and property that is being called and then returns various types of information; even that which was not originally stored in the object (e.g fullName).

### set() Example: ###
The set trap controls behavior on the object when a property is changed.
```
const triangle = {
    base: 100,
    height: 50,
}

const handler = {
    get: function (target, property){
        if(property === 'area'){
           return 0.5*target.base*target.height
        }
        return target[property]
    },
    set: function (target, property, value) {
            if (typeof value !== 'number') {
                throw new Error(`${property} must be a number.`);
            }
            if (value < 0) {
                throw new Error(`The ${property} must be 18 or older.`)
            }
        }
        target[property] = value;
    }
};

const proxyUser = new Proxy(triangle, handler);
```
#### Other Traps ####
 * apply()
 * construct 
 * getPrototypeOf 
 * setPrototypeOf 
 * isExtensible 
 * preventExtensions 
 * getOwnPropertyDescriptor 

Now I know a lot of this can be created via classes now, but I know there are [some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Examples)  places where a lightweight customizable Proxy would be a great option. If you agree with this then here is another [resource](https://hackernoon.com/introducing-javascript-es6-proxies-1327419ab413).
Thanks for reading and it's back to bash next week. See you then.
Creando un tema para Windows Terminal
Tags: bash, tutorial, coding, opensource
Published: 2020-10-26 03:30:18

Crear un tema para la nueva terminal de windows es bastante simple.

Solo necesitamos abrir la configuración del terminal, para abrir la configuración podemos hacerlo de dos formas:
1. Presionar `Ctrl + ,` 
2. Presionar el botón que se encuentra al lado de la pestaña, esto nos abrirá un menú, luego navegar hasta "configuración".

Al abrir la configuración nos mostrará un archivo `json`. Solamente utilizaremos dos campos, el campo `profiles` y el campo `schemes`.

## Creando y activando el tema 🎨 
Lo primero que debemos hacer es crear nuestro archivo `json`, si es que deseas compartir su tema con la comunidad, si no es así solamente debes agregar el esquema al campo `schemes` en `settings.json` que es el archivo de configuración del terminal. 

A continuación un ejemplo de como se ve un esquema de un tema, es bastante simple.

Ejemplo del tema "Drácula"
```json
{
  "name": "Dracula",
  "cursorColor": "#F8F8F2",
  "selectionBackground": "#44475A",
  "background": "#282A36",
  "foreground": "#F8F8F2",
  "black": "#21222C",
  "blue": "#BD93F9",
  "cyan": "#8BE9FD",
  "green": "#50FA7B",
  "purple": "#FF79C6",
  "red": "#FF5555",
  "white": "#F8F8F2",
  "yellow": "#F1FA8C",
  "brightBlack": "#6272A4",
  "brightBlue": "#D6ACFF",
  "brightCyan": "#A4FFFF",
  "brightGreen": "#69FF94",
  "brightPurple": "#FF92DF",
  "brightRed": "#FF6E6E",
  "brightWhite": "#FFFFFF",
  "brightYellow": "#FFFFA5"
}
```
Para utilizar este tema solo debes agregarlo al campo `schemes`.

Ejemplo: 
```json
{
  "schemes": [
    {
      // Aquí colocamos el 
      // esquema del tema. 
      // Por ejemplo el anterior.
    }
  ]
}
```
Una vez que al tema lo hemos agregado, tenemos que activarlo desde el campo `profiles`. 
En este campo se encuentran las configuraciones de cada Shell. 
Por ejemplo: 
* Windows Power Shell
* CMD

Y los que tu agregues, como puede ser "bash" o "zsh".
Cada sección de estos contiene un campo llamado `colorScheme` y es el que a nosotros nos interesa para activar el tema.

Ejemplo:
```json
{
  "profiles": [
    {
     "colorScheme": "Dracula"
    }
  ]
}
```
Y así de sencillo es crear y agregar un tema en windows terminal.

Solo lo que tienes que hacer es remplazar los colores en el esquema y darle un nombre y listo. 

## Links 
Algunos temas, pero puedes encontrar más en GitHub:

* [Drácula](https://github.com/dracula/windows-terminal/)
* [Night Owl](https://github.com/edurojasr/Windows-Terminal-Theme-Night-Owl)
* [Cobalt2](https://github.com/Reidond/cobalt2-windows-terminal)
* [Monokai Nigh](https://github.com/NickSeagull/windows-terminal-monokai-night)
* También puedes echarle un vistazo a mí tema: [Alive](https://github.com/Franqsanz/alive)

![Alive](https://dev-to-uploads.s3.amazonaws.com/i/n0nwmwmkjypvc8c4j2mk.png)

¡Feliz codificación!
Do you friends work with you?
Tags: discuss
Published: 2020-10-26 03:29:07

At first I thought I would be easier to work with friends because we are closed. Everything is going to be easy, we can talk through problems

Turns out, the relationship between us is the big thing that causes problems more than I think. If I'm too straight about a mistake that my friends keep doing it and cause problem I have to fix, then it will hurts the relationship which I don't want it either.

I can solve problem with code but can not use

I have working with 2 of my friends from university. Today I feel pretty depressed.


Are you facing some similar problems like me? 
Does anyone can give some advice?
AWS CDK - Coding a Virtual Machine in the Cloud
Tags: aws, devops, cloud, python
Published: 2020-10-26 03:11:42

---
title: AWS CDK - Coding a Virtual Machine in the Cloud
published: true
description: Python cdk example code that creates an ec2 instance
tags: aws, devops, cloud, python
//cover_image: https://direct_url_to_image.jpg
---

I started following AWS CDK (Cloud Development Kit) news and documentation for a while now. That's usually my lazy strategy when a new AWS product is launched, I finally decided that I wanted to start using it and create something that I'm familiar with and  also find useful.

One of my favourites AWS products is *EC2*, for multiple reason:

  - Compute is Universal, it have the potential to make many things with a server running *Linux*.
  - EC2 Administration in AWS can be much more elastic, there are some additions from AWS System Manager that I enjoy using:
    - No more SSH!, AWS SSM provides *Session Manager* instead that is Web Console, CLI and API friendly.
    - Parameter Store is handy for keeping configuration values in a safe place outside the instance.
  - User data for provisioning, because some bash script with a few commands always gets the job done.
  - Elastic IPs (also knows as Public IP), probably the most simple way to connect your application to the internet!
  - Amazon Linux 2, one less thing to worry about because AWS maintains a Redhat/Centos like distribution.
  - All the goodies of EBS and snapshots.
  - Spot Instances, because running your servers could be really affordable if your service is smart enough to handle interruptions.


So, I decided to deploy a single instance from Python code using CDK with all the AWS cool stuff to easy the management in around 60 lines of code.

This is a snippet of what you're going to find, *instance creation*:

```
        instance = ec2.Instance(self, "Instance",
            instance_type=ec2.InstanceType("t3.nano"),
            machine_image=amzn_Linux,
            vpc = vpc,
            role = role
            )
```

One common issue when using *user data* to install software is that eventually it hits a limit, CDK Assets allows me to invoke that script from a separate file and also handles the assets management in S3 for us.


```
        asset = Asset(self, "Asset", path=os.path.join(dirname, "configure.sh"))
        local_path = instance.user_data.add_s3_download_command(
            bucket=asset.bucket,
            bucket_key=asset.s3_object_key
        )

        instance.user_data.add_execute_file_command(
            file_path=local_path
            )
```

This is the full code example for getting that instance up and running:

[EC2 Instance Code Example](https://github.com/aws-samples/aws-cdk-examples/blob/master/python/ec2/instance/)

I hope this gives you an idea of how powerful CDK in terms of *describing infrastructure* and the amount of time that saves if you where using the Python SDK or Cloudformation previously.
One JWT to rule them all.
Tags: cognito, jwt, jwks, auth
Published: 2020-10-26 02:59:05

*Okay let's setup the scenario here.*

Let's say you have a Node.js API and some front end framework, and you are using AWS Cognito to handle the authentication dance 💃 via the client side SDK either through Amplify or some other means.

Now you also want to **authenticate** your API calls against the **same user**, against the **same token**. This easily done by using that JWT and a JWKS on the server side to validate the JWT signature. 

I'll show you how via a typical middleware.

First head over to [jwt.io](https://jwt.io), this amazing tool will decode your JWT into something readable like 👇

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

*On to the Node.js middleware*

Let's start with a class so we can define some protected functions. You could also just do functional programming here too. Whatever floats your boat ⛵

Using [Jose](https://github.com/panva/jose) it would look something like this to authenticate the token and either return the validated signature or fail.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/z8brq5fo3mv850o1z1fu.png)

You may need to get the token from the head in a more specific way like so.
```
    let token = context?.request?.headers().authorization || ''
    // Remove "Bearer " from start of token
    return (token = token.substring(7, token.length)) 
```

From here is just a matter of **context** depending on what language you are using.

I hope this help some one who has read the below AWS cognito guide and found that to be underwhelming.

🖖


> References
[AWS Guide](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-verifying-a-jwt.html) - [Jose](https://github.com/panva/jose)
Covariance, Correlation, and Collinearity
Tags: datascience, machinelearning, beginners, python
Published: 2020-10-26 02:53:51

###**Variance and Covariance**

When we measure the spread of the distribution of some random variable X, we calculate variance and standard deviation, as:

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


The variance between X and Y is called covariance. To find covariance of X and Y, we use the same approach as above:

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

So, the covariance of X and Y could be negative or positive.  Because covariance is not normalized, it only describes a trend between two variables.

###**Correlation and Collinearity**

To measure the strength of the trend, we need to normalize the covariance. So, covariance normalized by the standard deviations of X and Y is a correlation coefficient (or Pearson's correlation coefficient), which is defined below:

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

Thus, correlation coefficient values are between -1 and +1. 
To classify the strength of the correlation, the following ranges are commonly used:

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

Positive and negative signs indicate the trend of the correlation.

When two variables are strongly correlated with each other, they are collinear. If there are strong correlations with multiple variables, it is multicollinearity. Depending on the goal of the analysis, one can consider dropping strongly correlated features. To work with collinear features, we also can use variance inflation factors[(VIF)](https://beckmw.wordpress.com/2013/02/05/collinearity-and-stepwise-vif-selection/) and Principal Component Analysis (PCA).


###**Application**

Here I will use a London bike sharing [dataset](https://www.kaggle.com/hmavrodiev/london-bike-sharing-dataset?select=london_merged.csv) to play with covariance and correlation. 

```python
# https://www.kaggle.com/hmavrodiev/london-bike-sharing-dataset?select=london_merged.csv
df = pd.read_csv('data/london_merged.csv')
data = df.iloc[:,2:].copy()
data.head()
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y88t4sn7yrjt6gtkgp78.png)

1) Let's check covariance of features:

```python
# covariance
data.cov()
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/c6lu1agxfeo3vsw3msw9.png)

2) Correlation of features:

```python
# correlation
data.corr()
```

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

```python
# correlation
abs(data.corr()) > 0.70
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5ifbm8xep8mnx0bj2nvy.png)

Not surprisingly, we can see that temperatures t1 and t2 are strongly and positively correlated.

3) When applying PCA, we can see the number of principal components vs. Explained Variance:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/56e7n6i07dohpmww00en.png)
The new reason for creating new languages
Tags: codequality, rust, elm
Published: 2020-10-26 02:15:55

In the beginning there was binary. Binary was not human readable, so then came assembly. Then the "higher level" language. All of these tried to address the problem of human readability. Bob Martin mentions in [The Last Programming Language](https://youtu.be/P2yr-3F6PQo) that some languages even go too far towards readability. With languages like Python and Java, we've finally nailed it. There are still tweaks to be made for readability, but we don't need to focus on readability as the purpose for new languages.

# New aims

The modern language serves another purpose - guiding the developer toward smart decisions and catching tricky errors at compile time. Elm and Rust are two amazing examples of this new paradigm.

## Elm

I first heard about Elm when I was researching Rust. Rust's ideas for coherent error messages first came from Elm. In [the first video](https://youtu.be/RFrKffrKCeU) I watched, Annaia Berry said that after migrating to Elm, their portion of the product never ever broke and so never needed to be fixed. Because of this, there was no need for them to stick around. They accomplished what I have always wanted to do - create enough wealth to work yourself out of a job.

I feel like this is a significant story because it illustrates the power of a good compiler. By filtering out strange errors like race conditions, the compiler enables us to focus on features.

## Rust

Started by Mozilla, Rust was created to eliminate the stupid errors which occur in C++ code. Like Elm, the magic of Rust comes from its compiler. If the compiler sees that you are doing something which could someday cause an error, it won't even let you compile the program. Here's an excerpt from their [website](https://www.rust-lang.org/):

> Rust’s rich type system and ownership model guarantee memory-safety and thread-safety — enabling you to eliminate many classes of bugs at compile-time.

Rust also guides you to making what it thinks are good decisions. Catherine West talks about how it's really hard to create a game in a "traditional" OOP way at [her talk at RustConf](https://youtu.be/aKLntZcp27M). This is because the creators believe that creating games with deeply nested object hierarchies is not the right way to do things. Instead, it's easy to create an ECS because this follows the structure that Rust promotes.

# What this means for the future

I believe these types of super-compiler languages will increase in popularity. Because of this, interpreted languages will fall out of favor. In addition, because the languages developers use will have such helpful messages when things go wrong, the developers will also head toward friendly, informal messages in their programs. 

# Where to go from here

[Ashley Williams's video on Rust and NPM](https://youtu.be/GCsxYAxw3JQ) is an amazing starter for understanding some of the reasons behind using one of these new languages.

Are there any languages which I could have mentioned in this post? Clojure maybe?
#ChadWritesCode End of Period Log Oct 12 - 25 2020: React Context
Tags: webdev, learning, react
Published: 2020-10-25 22:56:13

So for those following along, you might be wondering what happened to last weeks update? Well I had a bit of uncertainty in my life at the time that affected my plans moving forward. Was half expecting to be knee-deep in interview prep but things didn't turn out that way and I'm just really bad at getting back on track after that. This past week I honestly didn't do too much but I felt I should acknowledge it here. Either way, I still wanted to write my log so onto the show!

{% twitter 1315655505663201281 %}

So first of all, let me talk about the re-learning those algorithms. Like I said, thought I would be starting interview prep and so I decided that getting a head start would be a good idea. I did a little bit of work in this area but I wouldn't say I re-learned these algorithms. The intention was to be able to write them from memory on a whim if I needed to and that just didn't happen. Just felt I should mention that before moving forward.

What I did accomplish was going through the React Scrimba course and covering the topic of Context in React. So in terms of state management in React, I learned to use Redux and I remember a friend implementing Redux in her own project. She ended up writing an [article](https://dev.to/saramccombs/redux-a-bigger-hammer-is-not-always-better-3jpp) about her experience and how Redux may be overkill for a small project like the one she was working on. After going through this section of the course, I kinda wish I was able to suggest to her to just React's Context API (though to be fair, there's probably a reason why she wanted to use Redux outside of needing state management).

So full disclosure, I don't understand Redux enough to know when need to use it over Context by itself but I definitely like that the same patterns that you use with Redux you can use with Context. As I messed around with it in the tutorial, it felt significantly easier to implement, understand and maintain than Redux. In fact, when I was working, that was something I constantly had a problem with. We had implemented Redux in the React project we had and I always had a hard time making changes to Redux. Looking back at it, honestly we really just had a really large store more than anything else and any of the major complexity really came from the Reducers. I'd have to look at the code again (which I don't have access to) but I'm pretty sure we could achieve the same result without Redux. I also feel it would be easier to maintain but I wonder if that's me being subjective or not.

Regardless, React Context is a welcome addition to my toolkit and makes exploring Redux or other state management tools more interesting cause know I'll have a better idea on how to judge other tools and whether they will provide value to a project I work on. Always a good thing!!

So in the week coming up I'll work on React Hooks, the real meat and potatoes of the course. Until then, see you next time!