teleren/devto huggingface dataset:
My #100DOC - Day 7
Tags: 100daysofcode, challenge, log
Published: 2020-09-02 21:56:58

#### **Today's Progress**: 
1. **[Continued with The Complete JavaScript Course](https://github.com/pablohs1986/javaScriptCompleteCourse2020_Schmedtmann)** (36min):<br>I learned about the history of JavaScript and its different standards. Also, I finished with challenge 5 and this section.
2. **[Helped on Stack Overflow](https://es.stackoverflow.com/questions/386720/como-puedo-obtener-un-nombre-aleatorio-contenido-en-un-arreglo/386723#386723)** (30min):<br>I helped a colleague to get a random name that is inside an Array, using the Math.random () method. I also edited questions from other colleagues to make them clearer.
    
#### **What I learned**: 
* Review of JavaScript loops and iteration.
* History and standards of JavaScript.
* Review of Math.random Java method.

#### **Total time**:
1h 06min.
Topics for my next post
Tags: blogging, ideas, help, writing
Published: 2020-09-02 21:50:00

---
title: Topics for my next post
published: true
description: What do you want me to write about?
tags: blogging,ideas,help,writing
cover_image: https://unsplash.com/photos/FCJYmu97tVA/download?force=true&w=1920
---

I've been encouraged by the success of last post, on [Deploy pipeline with GH Actions](https://dev.to/michaelcurrin/intro-tutorial-to-ci-cd-with-github-actions-2ba8), to keep writing more posts.

Tell me, what are you interested to learn about? Here are ideas for topics I could write about using my experience. 

## Topics

- A Python project intro for JS devs
    - how to structure a new python project using comparisons with Node.js projects
- Node to Deno
    - Side by side, Node.js vs Deno files and commands for beginners
- Writing your first GitHub Action
  - So that you and others can reuse it in workflows 
- PWAs and Service Workers intro
- How to build a docs site with [Docsify](https://github.com/MichaelCurrin/docsify-js-template)
- A breakdown of my dotfiles on Linux/Mac and how I use aliases etc. 
   - And how I version my dotfiles in a repo but also keep them symlinked in my user folder 
- How install Ruby, Rust, Go, Python and Node.js on Ubuntu
  - Comparison of multiple approaches for each and tips for configuring 
- A breakdown of GH Action workflows
   - How to schedule daily runs, how to use tokens the safe way, how to add a release flow runs after your build flow.

Let me know in the comments what you like.

I don't want to be the millionth blogger to write and intro to JS, so tell what matters to you and your context so I can make something relevant and original. So maybe I'll take ideas not on the list.

I'll include links to resources and repos of mine.

## Credits

Cover image

Thanks to @NeONBRAND for making this photo available freely on @unsplash 🎁 https://unsplash.com/photos/FCJYmu97tVA
Minimal Carousel with scroll snap, mobile & mouse friendly
Tags: codepen
Published: 2020-09-02 21:46:51

<p>A scrollable carousel in few lines of JS and CSS.
You can scroll with your fingers or click and drag. The div snaps to the center
Does not use any library like slick, owl carousel, tiny-slider, flickity, ... </p>

{% codepen https://codepen.io/fredericrous/pen/xxVXJYX %}
Quick Guide to Different Types of Function in Solidity
Published: 2020-09-02 21:41:00

**Constructor function**: A constructor function is either public or Internal. This is the first function that is automatically called only when the smart contract is deployed on the network. It cannot be called afterwards.

**View function**: A view function can only perform reading from the state or from another view function. 

**Pure function**: A pure function does not perform any reading or viewing on the state of the blockchain. 

**Function Visibility**: Who can call the function defines its visibility. Depending on who do you want your function to call, the visibility fo the function changes. There are four types of function visibility: 

**Public Visibility** (can be called externally and internally), 

**Private Visibility** (can be called only internally, only for the contract), 

**External Visibility** (can be called from other contracts and can be called externally) 

**Internal Visibility** (can be called from the contract itself or from the derived contracts, they cant be invoked by transactions)

**Fallback function**: A fallback function is always external. It is called when a transaction without a function-call is sent to the smart contract OR when the function-call in the smart contract isn't found.

**UPDATE Solidity 0.6**: There are two different types of fallback function now

The “**fallback**” function is called when no other function matches and no money is sent along.

The “**receive**” function matches when no other function matches and money is sent along.

Example:

``` 
pragma solidity ^0.6.0;
contract FunctionsExample {

 mapping(address => uint) public balanceReceived;
 address payable owner;

//Constructor function: A constructor function is either public or Internal. This is the first function that is automatically called only when the smart contract is deployed on the network. It cannot be called afterwards.
 constructor() public {
 owner = msg.sender;
 }

//Public Visibility (can be called externally and internally)
 function destroySmartContract() public {
 require(msg.sender == owner, "You are not the owner");
 selfdestruct(owner);
 }

 function receiveMoney() public payable {
 assert(balanceReceived[msg.sender] + msg.value >= balanceReceived[msg.sender]);
 balanceReceived[msg.sender] += msg.value;
 }

 function withdrawMoney(address payable _to, uint _amount) public {
 require(_amount <= balanceReceived[msg.sender], "not enough funds.");
 assert(balanceReceived[msg.sender] >= balanceReceived[msg.sender] - _amount);
 balanceReceived[msg.sender] -= _amount;
 _to.transfer(_amount);
 }

//The receive function matches when no other function matches and money is sent along
 receive () external payable {
 receiveMoney();
 }

//View function: A view function can only perform reading from the state or from another view function 
 function getOwner() public view returns(address) {
 return owner;
 }

//Pure function: A pure function does not perform any reading or viewing on the state of the blockchain
 function convertWeiToEth(uint _amountInWei) public pure returns(uint) {
 return _amountInWei / 1 ether;
 }

}
```
Quick Guide to the "Checks Effect Interactions" Pattern to Remember when writing your Smart Contracts!
Published: 2020-09-02 21:39:03

Although it is commonly understood that data in a blockchain cannot be edited or deleted once it is added (which is true!) that does not mean a blockchain network is completely secure! Knowing the vulnerability of the blockchain network and taking measures to block illicit activity is still needed.  

A possible attack vector is a re-entrancy attack, in which the malicious contract is reentering the initial contract before the first instance of the function containing the call is finished. Example is 


```
function widthdrawAllMoney(address payable _to) public {
//checking the balance of user in the network (check)
         unit balanceToSend = balanceReceived[msg.sender];             
         
//transferring the balance to the user (interaction with smart contract)
         _to.transfer(balanceToSend);                                                     
         
//setting balance of user to zero (effect on the network)
        balanceReveived[msg.sender] = 0;                                           
}
``` 

In the above simple scenario, we have to transfer all the money of the user back to the account the user passes to the function. The function then checks the balance of the user who is initiating the function, transfers the balance in his account to the requested address and then eventually sets the balance of the user to zero.

Here, we are first checking the balance, transferring the crypto and then setting the balance to zero. This is a check-interact-effect method. And this is where a malicious user can perform a re-entrancy attack in a way that the crypto can be transferred to the address multiple times - called as recursive send pattern. And this has happened in the past! You can read all about this  [here](https://hackingdistributed.com/2016/06/18/analysis-of-the-dao-exploit/). The DAO was hacked for a whopping $150M!

There is a simple and trivial way out, we can edit the code as below: 


```
function widthdrawAllMoney(address payable _to) public {
//checking the balance of user in the network (check)
         unit balanceToSend = balanceReceived[msg.sender];             
         
//setting balance of user to zero (effect on the network)
        balanceReveived[msg.sender] = 0;  

//transferring the balance to the user (interaction with smart contract)
         _to.transfer(balanceToSend);                                                     
}
``` 
The difference here is that we first perform the check (how much balance is in users account), perform the necessary effect FIRST (bring the balance of user back to zero) and THEN we interact with the blockchain to transfer the crypto!

This is the check-effect-interaction best practice. 

Found it interesting? You can read more about it  [here!](https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html)
Radiodeck - The Radio App
Tags: radio, app, ios, web
Published: 2020-09-02 20:44:01

Just released a major update of radiodeck iOS App and Website recently. So if you're a lover of radio and free music, get radiodeck for iOS or use our Website. Android will follow soon.

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

Radiodeck is your companion for all your favourite music, news, talk and sports stations from all around the world.
Find your desired station by exploring your local area, browse various genres or just call it by its name.

[radiodeck iOS](https://apps.apple.com/app/id897229345)
[radiodeck web](https://next.radiodeck.com/)

Feel free to let me know what you think.

Don't forget to vote: [radiodeck @ ProductHunt](https://www.producthunt.com/posts/radiodeck) :-)

Enjoy your radio!
Day 209: Call Me
Tags: hiphop, code, coding, lifelongdev
Published: 2020-09-02 21:36:47

_liner notes_:
- Professional : Got to sit in on a talk prep session today. Learned a little about Blazor. Seems like it could be a pretty cool alternative to JavaScript for people that like .Net. Right now, it feels like a lot of work and set up just to get something done. Definitely will keep an eye on it. Other than that, got the event listeners hooked up to my Web Components so that the React application can interact with them. Cool. Oh and I also submitted the video I recorded and edited last night of the demo to the team. They seemed to like it. Cool again. 

- Personal : So, last night, I had a friend help me record some stuff for the demo video I was submitting to work. It took longer than it should have, because she kept freezing on my end of the video call. Most likely because my hotspot is hot garbage. haha So she did a screen recording on her end and sent me the file. I did some other screen recordings and edited the footage together. I did a voice over recording. Since there was some road noise of cars passing by where I was parked, I took a blanket and covered myself and the laptop so I could record my voice. Came out surprising good. While I was in the editing mood, I edited the recording from last week's radio show and submitted it to the station to be played on air this week.

![Overlooking Mu Cang Chai, Vietnam with it's fields and mountains](https://dev-to-uploads.s3.amazonaws.com/i/w5jatct9af9w2fh8a0ch.png)

Called up the place where my package was to be shipped. They said it came in late yesterday. Guess no one thought to call me. Awesome. Went there after work. The place is a lot further than I thought. Drove to my folks place to drop it off since that's where I'll be installing the rack and solar panels to the roof of my van. Since it's pretty late, going to stay here the night and charge up my battery. Probably work on that React application with Web Components some more and get a version working using Hooks since that's the new hotness. Most likely call it a night soon because I've got a super early meeting with the team in the Tel Aviv office.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube StKVS0eI85I %}
People are using my Action :D
Tags: actionshackathon
Published: 2020-09-02 20:43:53

My GitHub Action ( [TypoCI/spellcheck-action](https://github.com/TypoCI/spellcheck-action) FYI! ) is coming along nicely, now I'm moving onto the hardest part...seeing if people will use it!

It's pretty daunting, I'm fairly certain I've caught most the show stopping bugs, but all the hard work could be for nothing if no one uses it.

Today I had a quick search on GitHub & found I had someone actually using my Action! I didn't know them or anything! It was pretty sweet!

Now I have a user, I thought I should write down some thoughts about how I intend to double, or even triple that number.

## Counting Users Is Hard!

Out of the box GitHub doesn't offer anything to tell me the amount of people using my action :/

Initially I was looking at how many Stars my repository had, but then I realised I personally don't Star stuff that often, so it could be a poor metric to track.

For now, I've been searching GitHub for instances of `typoci/spellcheck-action` which seems to show people who are using it on public repos. I think that's a solid approach to figure out who is using the GitHub Action for now. 

## The GitHub Marketplace Is _Quiet_

I submitted my [GitHub Action](https://github.com/marketplace/actions/typo-ci-spellcheck-action) to the GitHub Marketplace, but I'm not expecting a big rush of users from it.

A quick search suggests the terms "spellcheck" and "spelling" shows I already have competition (Who out rank me massively). Plus when I look at the insights from my GitHub Application which has been in the marketplace almost a year, it's suggesting less than 2,000 people visited my listing.

![Marketplace Insights](https://dev-to-uploads.s3.amazonaws.com/i/xpoyunknbttby6n5dq2p.png)

I'm not going to put much time into the Marketplace for now.

## Word of (Open Source Code) Mouth

One of the main ways I discover useful GitHub Actions by looking at their `.github/workflows` folder on GitHub. I suspect this is pretty common for others also.

My plan for my next free weekend is to open PRs on all my open source projects to add it. Assuming I don't spot any major problems, I'll use them as examples for other Open Source projects to copy.

## Adding a listing to Dev.to

I have a 10 credits on dev.to to use, I was saving for them for when I next need to find a job & want to put my portfolio out there, but I think this could be a fun way to use them.

I think a basic "Here's a GitHub Action to check your spelling" listing should be a-ok.

## Making A How To Video

The first time I saw GitHub Actions in the wild I had *zero idea* on how they worked, so I copied the sample code & once it ran...I had a lovely failure message waiting for me.

I don't want anyone to have that experience. I'm going to try and make a short video on how to install my extension & what to expect. I think that should help :)
Implementado la verificación de email en Laravel 7
Tags: php, laravel
Published: 2020-09-02 20:39:32

Bien, algunas de las cosas por las que es necesario implementar la verificación de email en nuestros proyectos son: 

- Evitar spam

- Corroborar que realmente el usuario este usando su propio correo y no el de otra persona

Por eso vamos a hacerlo facilito y rápido, lo primero es hacerse una cuenta en https://mailtrap.io/, esto sirve para testear cosas como estas, o como el reseteo de password del usuario.


Una vez registrado nos dirigimos en el menu izquierdo a >Inboxes:

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

a la derecha nos va a salir un menu, tenemos que seleccionar SMTP Settings y vamos a ver algo como esto:

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

Vamos a copiar los datos de Host, Port, Username, Password
y lo configuramos en nuestro .env

```bash
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=9hduas752d0940
MAIL_PASSWORD=d95sdd577f8cf8
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=nahuelprueba@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
```

Lo  que queda es ir a nuestro modelo User e implementar MustVerifyEmail, agregar el Middleware a HomeController y configurar nuestras rutas web para poder recibir los datos

Modelo:

```php
class User extends Authenticatable implements MustVerifyEmail
```

HomeController:

```php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware(['auth','verified']);
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('home');
    }
}
```

Rutas:

```php

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Auth::routes(['verify' => true]); /*Activando la verificación de correo*/

Route::get('/', 'IndexController@index');
Route::get('/perfil', 'PerfilController@index');

Route::get('/home', 'HomeController@index')->name('home');
```

Una vez registrado el usuario nos va a aparecer lo siguiente:

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

eso quiere decir que nuestro email de verificación ha sido enviado, así que si vamos a Mailtrap vamos a ver el correo para poder verificar nuestra cuenta:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/etlemlinjuo7ljgwzqwn.png)
Overload: A library for overloading functions in Deno
Tags: deno, typescript, javascript
Published: 2020-09-02 20:29:23

# Check it out [here](https://github.com/astro-nomize/overload)
![overloadpng](https://raw.githubusercontent.com/astro-nomize/overload/1.0.1/media/overload.png)
A type-safe way to make overloads for your functions in Deno 🚀

## Getting Started
Import the `overload` library in your file:

```ts
import { overload } from 'https://deno.land/x/overload@2.0.0/mod.ts';
```

Then, you can get started overloading your functions!

## Quick Examples
```ts
const concat = overload(
  "concat",
  {
    args: [String, String],
    func: (str1: String, str2: String) => {
      return `${str1}${str2}`;
    },
  },
  {
    args: [String, String, String],
    func: (str1: String, str2: String, str3: String) => {
      return `${str1}${str2}${str3}`;
    },
  },
);

console.log(concat("1", "2")); // 12
console.log(concat("1", "2", "3")); // 123
console.log(concat("1", "2", "3", 4)); // error
```

## API
### `overload.overload(name: String, ...functions: OverloadFunction[]): Function`
#### Parameters
##### `name`
The name of the function.

##### `...functions`
The functions that each represent an overload.

### `interface OverloadFunction`
#### Properties
##### `args: Function[]`
The list of types for each parameter of the function.

##### `func: Function`
The function.
Return Boolean or Element in .filter()?
Tags: javascript, beginners, codenewbie
Published: 2020-09-02 19:54:35

---
title: Return Boolean or Element in .filter()?
published: true
description: Returning elements in .filter() functions can cause some issues when dealing with numbers which can be interpreted as falsey
tags: javascript, beginners, codenewbie
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/xeth9hsnmn1tl50q123v.jpg
---
I have been doing [codewars](http://codewars.com) in order to improve my JS skills. I am now at 7 kyu - graduated from 8 kyu -and I have been enjoying solving programming puzzles.

My recent challenge which caused me some bother concerned arrays. The task was as follows: 

*Given an arrays a and b, return values from array a which are not present in array b.*

Seems simple at first sight. Essentially, we require a .filter() which will return an element. Such as: 

```javascript
function arrayDiff(a, b) {
  let newArray = a.filter(element => {
                      if(!b.includes(element)){
                        return element; 
                 }})
  return newArray;
}
```
However, when we run the test below, we are missing the 0 value.

```javascript
Test.assertDeepEquals(arrayDiff([-20,16,6,3,-2,0],[-2,-20,16,3]), [6,0]) 
//output is [6]
```
It took me a while to figure out why this was happening.
In JavaScript, 0 can represent false and 1 can represent true. 

By returning the value 0, we are indivertibly returning false, telling the .filter() function that there is no match and the element shouldn't be added to the new array.

Instead of returning the element, in this case, we should return a boolean.

And so the solution is:

```javascript
function arrayDiff(a,b){
    return a.filter(element => !b.includes(element));
}
```
##But when can I use element and not a boolean?

You should use "element" when you would like omit anything, which may be interpreted by JS as falsey. One of these examples could be removing undefined values from an array or empty strings. 

Values which can be interpreted as falsy are: 

* false 
* null 
* undefined
* 0 
* NaN
* ''

##Further reading: 
[CodeWars Cata](https://www.codewars.com/kata/523f5d21c841566fde000009/)
[.filter() documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
[Helpful Stack Overflow question about it](https://stackoverflow.com/questions/23089336/array-sort-filter-with-zero-in-javascript)


Hope you enjoyed!
Node js tutorial for beginners ( Hindi )
Tags: nodejstutorial, nodejstutorialforbeginners, nodejstutorialinhindi
Published: 2020-09-02 19:49:51

Node.js एक Open Source Server Side Runtime Environment है. Node.js JavaScript का उपयोग करके अत्यधिक Scalable Server Side Application बनाने के लिए एक Event Driven, Non-blocking Input Output और Cross-platform Runtime Environment प्रदान करता है.
<a href="https://www.ymento.com/home/course/node-js-tutorial-for-beginners-hindi/1">node js tutorial for beginners</a>