teleren/devto huggingface dataset:
C# 9: Records Revisited
Tags: csharp, dotnet
Published: 2020-10-19 15:47:03

---
title: C# 9: Records Revisited
published: true
date: 2020-08-14 00:00:00 UTC
tags: csharp,dotnet
canonical_url: https://daveabrock.com/2020/08/14/records-spec
---

We had a lot of fun [playing with](https://daveabrock.com/2020/06/29/c-sharp-9-deep-dive-inits) the [new C# 9 features](https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/) over the last few months. As with learning anything brand new, we had to decipher the info the best we could: we went off the [announcement in May during Build](https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/), meeting minutes and GitHub issues from the team, and good old trial and error.

With .NET 5 [fast approaching](https://devblogs.microsoft.com/dotnet/announcing-net-5-0-preview-7/) this fall, things have taken shape and Microsoft has released the set of [C# 9 specification proposals](https://docs.microsoft.com/dotnet/csharp/language-reference/proposals/csharp-9.0/records). These proposals offer clarity on the new features and help to reinforce things I’ve heard or saw, and also allowed me to learn a thing or two.

I wanted to quickly share with you some new things I came across while scanning the records proposal.

## What are records?

What are records?

Short-ish answer: a record is a construct that allows you to encapsulate property state by providing immutable behavior without the need for extensive boilerplate (like for readonly structs). Record types are reference types, like class declarations, but allow you to implement value-like behaviors.

Long answer: [check out last month’s post for a deep dive on the topic](https://daveabrock.com/2020/07/06/c-sharp-9-deep-dive-records).

## Random facts that I assumed but am glad are in writing

- Record parameters can’t use `ref`, `out`, or `this`, but can use `in` and `params`
- Records can inherit from other records, but _cannot_ inherit from classes (unless it’s `object`) and classes can’t inherit from records

## Print a record’s members

It looks like, as long as the record derives from `object`, records do include a synthesized method that allows you to inspect all the members for that record:

```csharp
bool PrintMembers(System.StringBuilder builder);
```

From the spec, they note that it’ll iterate through a records `public` field and property members and take the format of `this.firstName = "Dave", this.lastName = "Brock"` and so on. You can declare this method explicitly.

I think using `PrintMembers` will definitely come in handy when you are working with complex records/inheritance and don’t want to override `ToString`. Quick and easy—I like it.

(It looks like the synthesized `ToString` method that ships with records invokes the `PrintMembers` method.)

## Wrap up

This was a quick post to show a few things I came across while reading the specification. Take [a look yourself](https://docs.microsoft.com/dotnet/csharp/language-reference/proposals/csharp-9.0/records) to check out details on how it works.
Automatically Deploy Your Ansible Galaxy Collections
Tags: actionshackathon, ansible
Published: 2020-08-13 22:49:58

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)

From a comment on the announcement article:

> For this contest, you'll only be able to submit projects that you started after this announcement post was published.

Well, I guess I am disqualified. But, leaving this post up as a resource for anyone that may like it.

### My Workflow

[Ansible Galaxy Collections](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html) were released in late 2019 as a modern method of sharing Ansible roles, plugins, and other snippets of a playbook. Deploying a Collection involves several `ansible-galaxy collection` commands.

I created a GitHub Action to simplify the process of publishing and updating a Collection to [Ansible Galaxy](https://galaxy.ansible.com/).

The custom Action also provides some conveniences, such as allowing the Action workflow to assign a version to the Galaxy Collection.

For example:

```yml
- name: Get the version from the tag
  run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF/refs\/tags\//

- name: Injecting a dynamic Collection version
  uses: artis3n/ansible_galaxy_collection@v2
  with:
    api_key: '${{ secrets.GALAXY_API_KEY }}'
    galaxy_version: '${{ env.RELEASE_VERSION }}'
```

### Submission Category: 

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)

DIY Deployments

### Yaml File or Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

I use this in a small personal collection:

<https://github.com/artis3n/ansible-collection-github/blob/master/.github/workflows/deploy.yml#L14>

Such a simple workflow, so convenient!

The full Action code (Typescript published into a Docker-based GitHub Action) is here:

{% github artis3n/ansible_galaxy_collection %}

### Additional Resources / Info

[Note]: # (Be sure to link to any open source projects that are using your workflow!)

I wrote about how I created this action and some of the philosophy behind GitHub Actions here:

{% link artis3n/galaxy-collections-part-2-automatically-update-your-collection-with-github-actions-8na %}

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. )

[Reminder]: # (Submissions are due on September 12th (11:59 PM PDT) and winners will be announced on September 23!)
I Was Nominated Hacker Noon Contributor of the Year - SECURITY
Tags: noonies, noonies2020, hackernoon, security
Published: 2020-08-13 23:58:38

I was nominated by HackerNoon for some of my cryptography and security content for the Security category in this year's Noonies awards :)

Feel free to give me an upvote if you've liked my content so far!

[VOTE HERE](https://noonies.tech/award/hacker-noon-contributor-of-the-year-security)

Some of my most popular posts have been:

* [SHA-2 Step by Step](https://qvault.io/2020/07/08/how-sha-2-works-step-by-step-sha-256/)
* [(Very Basic Intro to Elliptic Curve Cryptography)](https://qvault.io/2020/07/21/very-basic-intro-to-elliptic-curve-cryptography/)
* [Intro to PGP](https://qvault.io/2020/07/27/very-basic-intro-to-pgp-gpg/)
* [Lattices in Cryptography](https://qvault.io/2020/01/23/very-basic-intro-to-lattices-in-cryptography/)
Azure Functions with WSL2 and Visual Studio Code
Tags: azure, serverless, vscode, beginners
Published: 2020-08-13 23:47:49

---
title: Azure Functions with WSL2 and Visual Studio Code
published: true
description: 
tags: azure, serverless, vscode, beginners
//cover_image: https://direct_url_to_image.jpg
---

When executing [Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=devto-blog-alvidela) through [WSL2](https://docs.microsoft.com/windows/wsl/about?WT.mc_id=devto-blog-alvidela) we might find some problems when running [Azure Functions](https://docs.microsoft.com/azure/azure-functions/?WT.mc_id=devto-blog-alvidela) locally. While those problems are easy to fix, they might leave you puzzled trying to find the solutions for them. In this article we'll look into that.

## Azure Functions Core Tools are not installed

Once you have an Azure Functions project on Visual Studio Code, you might want to run it locally for debugging it by pressing `F5`. Here's an error you might encounter:

>You must have Azure Functions Core Tools installed to debug your local functions

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

So the problem here is clearly that we don't have [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?WT.mc_id=devto-blog-alvidela), now the question is where to install it. 

Since we are running Visual Studio Code from WSL2 we need to install the Azure Functions Core Tools on the WSL2 side. Installing them on Windows 10 won't solve this issue.

Here's how to install them on Ubuntu 18.04:

```
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
```

For a full set of installation instructions take a look to this article [Work with Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?WT.mc_id=devto-blog-alvidela)

## Could not connect to debug target

The second problem I've found was Visual Studio Code telling me it wasn't able to attach the debugger:

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

In this case my problem was that while I did have node.js installed, I didn't have the supported version which is v12. Here's how to solve that problem:

```
npm install -g n
n lts
```

`n` is a program that you can use to install various versions of node.js on your system. As of this writing the LTS version (12.18.3) is the one we want, so by running `n lts` we can get that version running on our system.

And that's it! Two very quick solutions for problems you might find when running Azure Functions locally on WSL2 on Windows 10. Until next time!
Aplicaciones móviles con NativeScript
Tags: nativescript, angular, typescript
Published: 2020-08-13 23:25:25

![NativeScript](https://dev-to-uploads.s3.amazonaws.com/i/6tst5rjo1nrlo3n7r3gb.png)
# Mi peregrinaje
Durante mucho intente crear aplicaciones para móviles pero no tenia mucho tiempo para aprender un lenguaje nativo o dos que son Java para Android y Objetive-C o Swift para IOS. Así que empece a buscar alguna librería o framework donde pudiera aplicar mis conocimientos de programación web, pero los que probé me daban una aplicación híbrida, en pocas palabras una pagina corriendo en el WebView del dispositivo, esto como que no me convencía. Seguí en mi búsqueda hasta que gracias a los genios de [desarrolloweb.com](http://desarrolloweb.com) conocí Nativescript.

# Que es Nativescript
La definición en su [pagina web](https://nativescript.org/) dice que Nativescript es un framework de código abierto para crear verdaderas aplicaciones nativas con Angular, Typecript o Javascript. Me parece que es una buena definición y me dice claramente lo que puedo hacer con este framework, que tiene una mayor performance ante las aplicaciones híbridas y una igual o en ocasiones mejor ante las aplicaciones nativas.
Lo he probado y tengo una app sencilla en producción en mi trabajo.

# Ventajas de Nativescript
Una de las grandes ventajas es que con un mismo código puedo crear apps para dos plataformas, esto implica un ahorro de recursos y tiempo.
Que si cuento con conocimientos de Javascript, HTML y CSS puedo aplicarlos para desarrollar una app.
Las apps desarrolladas bajo este framework son nativas, esto quiere decir que el uso de componentes como por ejemplo la cámara del dispositivo son directas sin capas intermedias, así como la interfaz de usuario tambien es nativa.

# Conclusiones
Los invito a probar este genial framework y para no extender mucho este post voy a continuar en otro la instalación y la demo del framework, espero les guste y no se olviden de compartir, hasta la próxima.
React-Express Boilerplate
Tags: react, express
Published: 2020-08-13 23:18:40

Hello guys!
I am new here and I just made a repo with some boilerplate code to start a react-express web app.
Can you guys tell me if it is any good?
I am kinda new to express and react so I'd like the opinion of someone who is more experienced.
I made it because everyone online had different suggestions and I could not find one that was clean-ish and easy to understand what is going on.

Any way here is the link to the repo. 
https://github.com/OfficialPedroDimasPortfolio/React-Express-start

Thanks in advance!
Show Dev: One Million Words
Tags: showdev, elixir, writing
Published: 2020-08-13 22:56:52

For the readers of my [website](josephlozano.xyz) (which doesn't always get cross-posted to Dev.to), you will know that for this month (as well as following months), I am going to attempt to write a blog post every weekday, inspired by TreTuna's 1000 words for 1000 days challenge.

{% twitter 1292693591513419777 %}

Now, the spirit of the challenge isn't to write 1000 public words (private notes also count), but I was thinking about how awesome it would be to have a blog with one million words.

Inspired by this, I am setting out to write at least one million words in my blog (though not necessarily in 1000 days). To help me reach this goal, I built a tool that takes an RSS feed and counts the number of words written. Accordingly, I have named it One Million Words.

This project is still very much a work in progress (for example, it expects your posts to be in a `<main>` tag), but I wanted to give this community a first peek.

The code is [open source](https://github.com/joseph-lozano/One-Million-Words). I am very much open to feedback!

Without further ado: [One Million Words](onemillionwords.net)

Some work I'd like to do:

* Save requests to the database
* Work on the design.
* Automatically update when feeds are updated.
* Support content in any arbitrary HTML tag, not just `<main>`

In future posts, I will walk through the code, the design decisions I made, and how I deployed it.

PS: If you are looking for a feed to try, and have at least one post on Dev.to, try `https://dev.to/feed/username`, eg: https://dev.to/feed/joseph_lozano
Is it just me or...
Tags: codenewbie, beginners, javascript
Published: 2020-08-13 22:55:14

_Is it just me, or does the beginning of the new journey towards coding and development feel like a futile uphill battle, where you never quite feel comfortable with anything you're doing??_ **(AHHHRRGGHHH!!)** 

Over the past 2 weeks, I've been tasked with undertaking a series of _coding challenges_, including selecting three small "fun" project builds in Javascript for the [vestibule training program](https://www.theknowledgehouse.org/) I am hoping to become a fellow of in the Fall. 

The projects I've selected all use **vanilla JS, HTML and CSS**; _(all of which I am a complete novice)_

1. A [basic calculator](https://www.youtube.com/watch?v=j59qQ7YWLxw&amp;t=1977s) 
2. A [to-do list](https://data-flair.training/blogs/javascript-project-to-do-list/) 
3. A [meditation app](https://www.youtube.com/watch?v=oMBXdZzYqEk&feature=youtu.be) 

I'm not gonna lie, even though coding along with the tutorials is seemingly "simple", and the content is excellent and the instructors are like lightening fast ninjas, I'm just **so flustered** at the amount of concepts, terminology and deep understanding that I am just unaware and aloof to.

And I notice these tutorials are deceptively succinct, but because there are so many concepts that are new and unfamiliar to me, they definitely take 2-3x's the amount of time to complete.

I suppose that this is just a part of the process-- and that it is normal to feel completely oblivious and insecure... it's just difficult to accept that there is no shortcut-- only time and practice and working on projects that will hopefully increase my knowledge and confidence on this journey.

Well... to another week of grinding away at this coding, even through the uncertainty and discomfort.
Adding a runtime dependency to run gems in your gem
Tags: ruby, rails
Published: 2020-08-13 22:32:17

If you are having trouble getting a gem to run in your own gem here is a quick troubleshooting guide.  

Is the gem you want to use showing up in your `Gemfile.lock`?  Your `Gemfile.lock` file will display gems that are being called by your `Gemfile` and `your_gem.gemspec`.  If the gem you want to use is not being shown here we will need to get it to show up here.  

First, check your `Gemfile` to see if the gem you want to be used has been put in this file.  

Second, check your gem.gemspec to `add_runtime_dependency`

```
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
      s.add_runtime_dependency(%q<gem_name>.freeze, [">= 0"])
end
```

The `your_gem.gemspec` file is pretty much a readme for your gem, [here is more info about gemspecs](https://guides.rubygems.org/specification-reference/#add_runtime_dependency).  

Third, make sure to `require "gem_name"` in the file you want to use the gem. 

This should allow you to use another gem in your gem.
Two Weeks In
Tags: webdev, womenintech, 100daysofcode
Published: 2020-08-13 22:18:44

Hoje é o meu décimo quinto dia do desafio, mas como hoje eu ainda não comecei a estudar, vou falar de tudo que acabou se passando nesse meu tempo sem postar por aqui.
Durante esse período embora eu tenha tido uma **grande** desanimada, eu continuei estudando e embora eu não tivesse um grande conteúdo para postar aqui, o pouco que eu fazia eu continuei a postar no twitter. Porém, como ontem fez duas semanas eu acredito que deva ter informação o suficiente para pelo menos o post de hoje.

Dentro dessa segunda semana eu acabei mergulhando mais um pouco dentro de CSS, tentei deixar "as cores" de fundo localizadas nos lugares que eu queria, mas ainda assim não está tudo funcionando direito. Dentro das minhas notas percebi que responsividade realmente é muito importante, o que me leva, é a próxima coisa que eu tenho/quero estudar.
A questão dentro disso é bem simples, embora conceitualmente eu tenha entendido como as Divs e os Containers funcionam, na prática eu ainda não estou sabendo usar eles da maneira que eu deveria/gostaria.
Eu sou muito agradecida porque eu tenho alguns amigos me ajudando durante o processo e sinceramente sem eles eu acho que ainda estaria batendo cabeça em relação a algumas coisas.
Então assim que eu me acertar com as Dvis e os Containers devidamente eu devo trabalhar na questão da responsividade.
Fora isso um amigo meu me ensinou a linkar meus outros repositórios como parte do meu site, e estou bem feliz com isso, porque agora todos os outros projetos que eu fizer já vão ficar linkados diretamente ao meu site (os que derem pra executar em site estático né).
Então gente, se preparem porque meu próximo projeto pós o site pessoal vai ser o clone de um joguinho, claramente com propósitos de estudo, mas também para exposição e demonstração das habilidades que eu possuo.
Quem está acompanhando, obrigadinha! **<3**
Churn Prediction Pt. 2
Tags: beginners, python
Published: 2020-08-13 22:06:58

This is a continuation of my last post (https://dev.to/mayankp/churn-prediction-c75). For this blog, I will talk about how well a random forest model did. 

## Random Forest

I tested out different types of criterion for determining the better model.

<img src = "https://dev-to-uploads.s3.amazonaws.com/i/w14i9lkz07fk4acb7vto.png" alt="drawing" width="500"/>

This model ended up being my best one with an roc_auc of 91.5%, which is pretty good.

<img src = "https://dev-to-uploads.s3.amazonaws.com/i/z69w7jnii2z53wg391si.png" alt="drawing" width="500"/>

The random forest model also find international plan, customer service calls, and total day minutes to be the most important factors.This somewhat makes sense because the people who are charged the most usually talk a lot more or have to make expensive calls (like international calls). Also, going back to my last blog, people generally like the status quo until they become irritated enough to change it, and high charges fall into that category. 

## Imbalances

While dealing with this data set, I realized that there was an imbalance between churns and non-churns. Approximately 15-20% of the data resulted in a churn, while the rest did not. This could cause problems for the data because it didn't learn from the churn data points enough. So in order to balance the data out, I employed the use of Smote. Smote creates new data based on the information it has from the existing data set. By doing this, you can give the model your training more information to learn from, which is always good. 

<img src = "https://dev-to-uploads.s3.amazonaws.com/i/udulcn7w7y2cdjo8d0lp.png" alt="drawing" width="500"/>

Surely enough this increased my roc_auc to 96.1%.
Add JSDoc to your JavaScript Code
Tags: javascript, documentation, bestpractices, beginners
Published: 2020-08-13 22:04:45

Documentation is important to keeping a codebase understandable as it grows in size, complexity, and innovation.

JSDOC is a documentation tool to help structure your documentation.


# A Simple Example

A func definition that is annotated with JSDoc...

```JS
/**
@func
split a str composed of words into an arr of words

@tags
nlp

@notes
strips away single quotes that exist at the beginning or end of a word

@param {string} words
@return {string[]} the space-split words
*/
export const splitWord = words => words.match(/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g) || [];

```




A func that uses that splitWord func...
```JS

/**
@func
turns str into a URI conforming slug

@param {string} s - the str to be slugified
@return {string} the slugified str
*/
const getSlug = s => {
  return pipeStr(
    removeByRegex(/[\u0300-\u036f]/g), // removes diacritics, e.g. è -> e
    removeByRegex(/[^a-zA-Z0-9\s]/g), // only keep numbers and alphabet
    splitWord,
    joinByDash,
    getLowerCase,
  )(s);
};

```


# Example Hover Tip

After the func's documentation is added, wherever you use the func, hit the hover tooltip shortcut and you'll get this JSDoc informative popup:




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



# Set Shortcut Key
To activate the hover popup (called showDefinitionPreviewHover in VSC), first place your cursor on the func name, then hit the default shortcut keybinding (or you can create a custom keybinding). I have my custom binding set to cmd-n (ctrl-n)...

```JS
{
    "key": "cmd+n",
    "command": "editor.action.showDefinitionPreviewHover"
  },
```


# What the Hover Popup informs you of

The Hover dialog will...
- show you the function source code itself
- the parameter types
- the return type
- the natural language documentation of the function, explaining what it does



# How to set up JSDoc

See my prior post here...
https://dev.to/functional_js/quick-tip-setup-typescript-type-checking-with-your-pure-javascript-19ma


# More coming soon

Stay tuned for more!