teleren/devto huggingface dataset:
BinaryGap em duas linhas
Tags: computerscience, javascript
Published: 2020-02-06 19:06:21

Depois de solucionar o 1° desafio do codility: BinaryGap, resolvi postar aqui o algoritmo final que usei.

A desafio é o seguinte: Dado um número N, deve-se transforma-lo em binário e retornar o tamanho do maior número de zeros entre 1's. 
Com exemplo fica mais fácil entender, olha só:

 - O número 152 em binário fica: 1 **00** 11000 - Ele possui apenas 1 bloco com dois zeros, então o retorno seria 2.
 - O número 15 em binário fica: 1111 - Ele não possui nenhum bloco de zeros, então o retorno seria 0.
 - O número 3561 em binário fica: 11 **0** 1111 **0** 1 **00** 1- Ele possui 2 blocos com um zero e um bloco com dois zeros, o retorno então seria 2.

Dado o desafio, depois de um tempo tentando soluções com loop e contadores, cheguei a minha 1ª solução que achei aceitável:
```
function solution(N) {
    const n = "X" + N.toString(2) + "X";
    const list = n.split("1");

    let max = 0;

    list.forEach((i) => {
        if (i.indexOf("X") == -1) {
            max = i.length > max ? i.length : max;
        }
    })

    return max;
}
```

Depois dessa solução, ficou fácil, bastou alterar o forEach para um map e um reduce, olha aí:
```
function solution(N) {
    const n = "X" + N.toString(2) + "X";

    return n.split("1").map((i) => i.indexOf("X") == -1 ? i.length : 0)
        .reduce((a, b) => Math.max(a, b))

}
```
O map retorna o length de cada bloco e o reduce retorno o maior número do array.
Lembrando que embora a solução final tenha ficado mais elegante, a solução mais performática é a 1ª pois existe apenas uma iteração.

Um abraço e até a próxima.
12 tips/terms used by engineers when designing systems 🔮
Tags: todayilearned, architecture, design
Published: 2020-02-06 19:02:59


## Introduction 🎫
**Systems design** is the process of **defining the architecture, modules, interfaces, and data for a system to satisfy specified requirements**. 


## Tips/Terms you should know 📑
1) Vertical scaling 
2) Preprocessing using cron jobs 
3) Backup servers (Slave-master replications)
4) Horizontal scaling 
5) Microservices
6) Distributed Systems 
7) Load Balancing 
8) Database sharding
9) Decoupling 
10) API design
11) Logging and metrics calculation 
12) Extensibility


## References 📚
[Scalability Basics](https://youtu.be/xpDnVSmNFX0) 
[Load Balancing](https://youtu.be/K0Ta65OqQkY)
[Microservices](https://youtu.be/qYhRvH9tJKw)
[Single Point of Failure](https://youtu.be/-BOysyYErLY)
[Backups](https://youtu.be/GeGxgmPTe4c)
[Health checks](https://youtu.be/lWE_UIbm8NA)
[Database Sharding](https://www.youtube.com/watch?v=5faMjKuB9bc)

![](https://media.giphy.com/media/wWtIzEr2tZdyE/giphy.gif)
Laravel 6 curl request example using ixudra/curl package
Tags: laravel, curl, php, request
Published: 2020-02-06 18:50:27

cURL is software which you can use to make various requests using different protocols. PHP has the option to use cURL and in this article, we’ll show several examples. In this tutorial we are going to see how we can get api data using curl get request. 

There will be times that you will need to pull out data from a web service using PHP’s GET method. In this tutorial I will be demonstrating how you can make a GET Request using cURL.

If you know about php curl then you can simply run get, post request and get data from url. php curl is very interesting things. if you know and use in with php then you have to do curl_ini(), curl_setopt(), curl_exec() and curl_close() etc that way we can simply run request.

https://www.codechief.org/article/laravel-6-curl-request-example-using-ixudracurl-package
Help us squash bugs in DEV with Honeybadger! 🐛
Tags: meta, opensource
Published: 2020-02-06 18:34:32

We have some exciting news: thanks to our friends at [Honeybadger](https://www.honeybadger.io/), we now have a [public dashboard](https://app.honeybadger.io/project/Pl5JzZB5ax) that collects runtime bugs on DEV!

![honeybadger public dashboard](https://user-images.githubusercontent.com/146201/73952956-f73c3580-48ff-11ea-9c48-e8368eb9557c.png)

**If you'd like to help us out squash those bugs, check out [the GitHub issues](https://github.com/thepracticaldev/dev.to/issues?q=is%3Aissue+label%3Ahoneybadger+is%3Aopen) with the `honeybadger` label**. Don't forget to "claim" your issue by leaving a comment, so that other won't be working on the same one!

The DEV team recently started using Honeybadger for monitoring bugs on our platform. We like this service for a few different reasons! It gives us the ability to neatly separate frontend errors from backend ones, and it includes great features for supporting deploy tracking. We also like its filtering tools, which are super useful when it comes to sorting and searching through errors, and we appreciate its very smart defaults, like the ability to ignore errors in our test and development environments!

Although we have been using Honeybadger internally to help us track errors for a couple of months, we've decided to make this information public to the community so that our contributors can help jump in and help us keep DEV more stable! To see it in action, head over to our [public dashboard](https://app.honeybadger.io/project/Pl5JzZB5ax).

If you find new errors in our dashboard that aren't recorded anywhere, you can open a GitHub issue following [this template](https://github.com/thepracticaldev/dev.to/issues/5508) as an example. We also recommend reading up on DEV's [contributing guide](https://github.com/thepracticaldev/dev.to/blob/master/CONTRIBUTING.md) and [developer documentation](https://docs.dev.to/) before making your contribution!

The Honeybadger team also plans to release public dashboards as a standard feature for all open source projects in the near future based on community feedback, so if you are a maintainer we recommend checking them out! :-)
ReduxJs Advanced Design Pattern.
Tags: react, reduxjs
Published: 2020-02-06 18:07:12

---
title:
published: true
description:
tags: reactjs, reduxjs
---
ReduxJs Advanced Design Pattern.

Advanced thinking of reduxjs, action ---> middleware ---> produce new action.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oe5lvx9od5548x424s02.png)
Connecting Shiv Apps with Ansible - Building SaaS #26
Tags: python, django, saas, ansible
Published: 2020-02-06 18:02:54

{% youtube F-IRf1dmy10 %}

In this episode, we finished connecting the Django Shiv app into Ansible.  This required messing with file permissions and copying settings files to their proper place.

Show notes for this stream are at [Episode 26 Show Notes](https://www.mattlayman.com/building-saas/connecting-shiv-apps-with-ansible/).

To learn more about the stream, please check out [Building SaaS with Python and Django](https://www.mattlayman.com/building-saas/).
Search a String by matching against a regex in JavaScript
Tags: javascript, react, node, codenewbie
Published: 2020-02-06 18:00:12

---
canonical_url: https://bonsaiilabs.com/javascript-regex-match-strings/
---

Learn to match a String pattern inside another String using Regular Expression in JavaScript.

This video teaches a use case on where this scenario might be useful and how regular expressions can help solve the problem
We will use the `String.match` API in combination with regular expression in this video.

We will also look at the API documentation available on Mozilla Developer Network (MDN)

The code sample is available at https://bonsaiilabs.com/javascript-regex-match-strings/


{% youtube bAb32scBwaA %}
NEW VIDEO STATUS WHATSAPP
Tags: videostatus
Published: 2020-02-06 18:00:10

Best new and latest video status for whatsapp facebook and instagram. you can download new mp4 and 30 sec videos for you whatsapp and facebook also for instagram. newvideostatus.in website is provide free video status. you can download and share in your social account here is love video status, sad video status, birthday video status, boys and Girls attitude status video and more.
https://vipstatusvideo.com/
Methods
Tags: javascript, beginners, webdev, codenewbie
Published: 2020-02-06 17:57:28

## So what are methods?

Methods are basically functions that are defined inside an object.

Let's see that with an example: :grinning:

> To scroll to a particular position we use `window.scrollTo(x)` right?
>Here `window` is an object and `scrollTo` is a function. ie.. scrollTo is a method.

>Similarly, `console` is an object and `log` is a function and since it lives inside a function, we call it a method.


## Creating our own methods: :grin:

- The regular way:

```javascript
const batman = {
	alias: function(){
		return "BRUCE WAYNE";
	}
}

batman.alias() // BRUCE WAYNE
```

- Shorthand method:

```javascript
const batman = {
	alias() {
		return "BRUCE WAYNE";
	}
}

batman.alias() // BRUCE WAYNE
```

- Arrow function: 

```javascript
const batman = { alias: () => `BRUCE WAYNE`};

batman.alias() // BRUCE WAYNE
```

**Generally,** shorthand methods are preferred, arrow functions are best used when you know that you don't need the scope of `this` since arrow functions don't have the scope of `this`.

**Why and when not to use arrow functions?**

I have explained that in the previous post in this series "Arrow Functions".

## Things you must know about methods :satisfied:

> Methods are not constructors, and we cannot instantiate them like constructors.
It will throw a TypeError. :frowning:

```javascript
new batman.alias() //TypeError: batman.alias is not a constructor
```

**Async methods:** 

- Using short-hand syntax:

```javascript
const batman = {
	async alias() {
		await somePromiseToResolve;
	}
}
```

- Using arrow functions: 

```javascript
const batman = { alias: async () => {
    await do_something;
  } 
};
```

The same way we can use methods in `Generator functions` as well which we will see in the upcoming posts in this series.

## Wrapping up

Well, we just understood what methods are and how to use them in different and efficient ways.

Stay tuned for further posts in this series. :+1:

See you in the next post `Immediately invoked function expressions`. :smiley:

Thank you!
Recomendação de Livro: The Software Craftsman
Published: 2020-02-06 17:57:09

Já havia ouvido falar desse livro algumas vezes, e comecei a ler alguns dias atrás. Ainda não terminei, mas gostei bastante do que li. Gostaria de tê-lo lido quando tava no início da minha carreira. 
O autor dá vários conselhos que você pode usar na sua empresa, projetos e na sua carreira. A leitura é leve e interessante. Indico principalmente pra quem quer conseguir um estágio ou pra quem tá começando a estagiar com programação, mas também pode ser muito interessante pra quem já tem um bom tempo escrevendo código. ;) Se você é super iniciante e tá super perdido ou frustado com a área, a leitura desse livro é extremamente importante.

Link na Amazon:
https://www.amazon.com.br/Software-Craftsman-Professionalism-Pragmatism-English-ebook/dp/B00QXAGIDO/ref=sr_1_1?__mk_pt_BR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=KGF4Z854RWKE&keywords=the+software+craftsman&qid=1581011822&sprefix=the+softwar%2Caps%2C241&sr=8-1
Recomendação de artigo: Vai se candidatar pra emprego/estágio? Fuja das apresentações genéricas.
Published: 2020-02-06 17:53:42

Nesse post do Gabs Ferreira, ele argumenta um pouco sobre a necessidade de escrever uma apresentação personalizada para cada vaga de emprego que você se candidata. E eu sempre faço isso: ao me candidatar, escrevo, mesmo que brevemente, sobre a minha relação com a empresa, o porquê que eu a admiro, e o porquê de eu querer trabalhar lá. Leiam! http://gabsferreira.com/vai-se-candidatar-a-uma-vaga-fuja-de-apresentacoes-genericas/
Recomendação de Livro: Pratical Object Oriented Design in Ruby
Published: 2020-02-06 17:52:48

Recomendação de livro que serve tanto pra quem está começando quanto pra quem já tem experiência com programação: Pratical Object Oriented Design, da Sandi Metz. O livro explica conceitos de Orientação a Objetos de uma forma fantástica, que tanto iniciantes em programação conseguem pegar quanto aqueles mais experientes vão finalmente entender conceitos que antes apenas fingiam que entendiam (eu me incluo aí!).

Orientação a Objetos é um dos vários paradigmas de programação, e um dos mais usados/cobrados pelo mercado. Que tal tirar meia horinha do seu fim de semana pra dar uma lida em um dos capítulos dele?
Arrays for Days
Tags: arrays, loops, count
Published: 2020-02-06 17:33:28

Swift supports a collection of objects of the same type in order to write safe code that only works with properties and methods on the type declared in the array definition. 

If one wants to access all the objects in an array one at a time, one could use a loop to do this, more specifically, one might use the for…in loop to accomplish this. 

To check if an array is empty, one might could use the .isEmpty property, otherwise, one might check the .count == 0, if it does not, then the array is not empty.
Jack of all trades vs master of one
Tags: skills, learning
Published: 2020-02-06 16:59:11

No matter how we'd like to argue at the end of the day there are two types of people - those who are experts in one (relatively) narrow field and those who are capable/good at doing a lot of things but they don't shine in any.

During school we are taught generic education - they throw everything at you from literature, art to math and physics. By the time we get to university we start getting specialization. You already have some of the subjects fading away and with each year you get narrower in your field. This specialization happens also in programming - and it might seem a bit more subtle than you'd think at first. But it slowly creeps in day by day.

I've been meaning to expand my view on programming, try new things and learn a new language. And in this decision I found myself in a very much stuck in my narrow skill-set. You see - after spending 10k hours working with web, working with PHP, working with Laravel-like platforms I've trapped myself in thinking in certain directions, always thinking about certain issues.

I like learning by doing, code by building a prototype solution. For web its easy - I already have 5 ideas in my head for what I want to do and once I start pulling on one it tangles itself into another 5. But trying to do something else, something I am not familiar with, appears to be a lot more difficult. It is not only difficult to formulate the concept, but on top of it it is in a new language with new techniques, new processes. Every step comes slowly - even the point of setting up the environment to start writing code appears to be a lot trickier when its not something you've spent years to optimise.

It might seem better to be on the other side of the table. But its not - whilst having wide general knowledge is good, it is very limiting. Not only job opportunities will be more difficult because expert will do the job better but balancing this status quo in long term is very difficult. 

In fairness I do believe that being a master of one field is a lot better than being jack of all - at least in long term. You just need to remember to try something else and different now and then.
File System access through Web Browsers
Tags: webdev, security
Published: 2020-02-06 16:55:49

Web browsers (with the exception of Internet Explorer) can access a computer's file system. By typing "c:/" or File:///C:/ in a browser's search bar, the browser will start searching through an OS's file system. 

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

This is a faster way to explore the (C:/) drive for example compared to using the traditional file explorer in Windows 10.

By typing in the browser address bar file:///C:/ and pressing "enter", all files and folders on the C:/ drive will be displayed with file sizes, modified dates and time in the browser window, including files set to hidden.

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

However, many features in the default file explorer can’t be done with the web browser. Web browsers can’t access the file system without direct user permission. Consequently, web apps that use browser-side JavaScript don’t have permission to write to the client SSD without a lot of security options having to be disabled.

Furthermore, web browsers do not have the ability to manipulate the data on the file system, they can only display the content.





resources: https://cdn.pixabay.com/photo/2019/05/23/14/40/binders-4224085_1280.jpg
Should I switch to Zeit Now
Tags: webdev, help, discuss, jamstack
Published: 2020-02-06 16:53:38

---
title: Should I switch to Zeit Now
published: true
tags: webdev, help, discuss, jamstack
canonical_url: https://waylonwalker.com/blog/should-i-switch-to-zeit-now/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/qmqbegh93nsu2m6hq73m.png
series: [waylonwalker.com redesign 2020]
---

# Netlify

I have happily had my personal site [waylonwalker.com](https://waylonwalker.com) hosted on netlify for nearly 2 years now. In fact I have hosted about a dozen different toy projects to play with on there, 4 of which have gone far enough to get a custom domain name. They are fast to deploy and consistently do so on every `git push` to master.

## Zeit

I have recently started playing with zeit again. I really like their cli tool, its dead simple and makes sense. I tried the netlify one early on and dont think I really gave it much of a chance. I was able to backup a site we were modifying by saving everything locally (literally control+s) and running `now` in the command line.

While I was on the site I realized that when switching to gatsby v2 I had deployed it to now.sh while testing, before cutting over to the updated one on netlify. It has been building every version since without issue!

> It has been building every version since without issue!

## What I am using

- gatsby
- forestry.io

I am using gatsby to build my site, and I do use forestry.io as a cms to be able to edit/manage posts online. I think forestry is part of my problem in that it has added extra builds. Every time I upload an image or save a post, even a draft, it pushes to production.

## Why Switch

This is just a side hobby for me. I do not make any $$ off of it, and I do not want to pay for anything I do not have to. As I am stepping up my blogging I have already hit 50% of my build quota only 1 week into the month on netlify. I really like what netlify is doing for the JAMstack community, but I would rather build everything locally and push to GHPages for this project than have to pay for it.

## Check out the second part of this series

{% post waylonwalker/i-finally-fixed-my-styled-components-in-gatsby-js-56g0%}

## What Are your suggestions

Do you use Zeit?

Where do you host your gatsby.js site?
What is the best (free) way to monitor twitter hashtags/posts?
Tags: codenewbie, help, advice
Published: 2020-02-06 16:45:00

---
title: What is the best (free) way to monitor twitter hashtags/posts?
published: true
description: Free way to monitor twitter hashtags/posts
tags: #codenewbie #explainlikeimfive #help #advice
---


Hello everyone,

I am looking for a free tool that can monitor twitter post for particular users

For example, lets say want to monitor @PlayStation, @NintendoAmerica @xbox, etc.. and be notified ( via email or some other way) every time they mention "Resident Evil remake" or #Overcooked.

Is there a simple tool to do that and have it send me a notification? 


Thanks!
QlockTwo in your browser!
Tags: codepen, vanilla
Published: 2020-02-06 16:33:01

---
title: QlockTwo in your browser!
published: true
tags: codepen, vanilla
---

Have you seen the [QlockTwo](https://qlocktwo.com/en/qlocktwo-classic/)? It's pretty cool. Here's a version with HTML and Javascript.

{% codepen https://codepen.io/tillysinteriors/pen/GRJKjNd %}
Django Riffs, a podcast for learning Django
Tags: python, django, podcast
Published: 2020-02-06 16:14:24

I've started a podcast!  The podcast is called Django Riffs, and my goal is to help beginners learn how to use [Django](https://www.djangoproject.com/).  You can find the show at [djangoriffs.com](https://djangoriffs.com/) or check iTunes, Spotify, or wherever you get podcasts.

Each episode of the podcast will be a topical exploration of one facet of the Django web framework.  With many years of Django under my belt, I believe I have the experience to help beginners on their journey into learning Django.  More experienced Djangonauts may benefit from a refresher on the subjects that we cover.

With this launch announcement, I am releasing the first two episodes.

* The first episode, [Get To Know Django](https://www.mattlayman.com/django-riffs/get-to-know-django/), gets us situated with where Django exists in the context of the internet and web application development.
* In the second episode, [Enter With URLs](https://www.mattlayman.com/django-riffs/enter-with-urls/), we start our exploration of Django's features by focusing on how Django sets up URLs.

These episodes take quite a while to produce because of the research, preparation, and production of each one.  My aim is to get out a new show every couple of weeks if I can.

If you would like, you can follow the show on [djangoriffs.com](https://djangoriffs.com).  Or follow me or the show on Twitter at [@mblayman](https://twitter.com/mblayman) or [@djangoriffs](https://twitter.com/djangoriffs).

I hope you enjoy this.  Please feel free to reach out to me with comments or feedback.  My mission is to make a great Django learning experience for new developers and grow the Django community.

This article first appeared on [mattlayman.com](https://www.mattlayman.com/blog/2020/django-riffs-podcast/).
Easy Authentication in Xamarin Apps with Auth0
Tags: xamarin, ios, android
Published: 2020-02-06 16:14:17

---
title: Easy Authentication in Xamarin Apps with Auth0
published: true
description: Learn how to add authentication to iOS and Android apps with Xamarin and Auth0.
tags: #xamarin #iOS #android
canonical_url: https://auth0.com/blog/easy-authentication-xamarin-auth0/
---
TL;DR: With Xamarin, developers can build native cross-platform mobile applications using C# on .NET. Also, authentication and authorization are a significant part of application architecture since they allow users to access specific functionalities and resources selectively. In this tutorial, we will learn how to use Xamarin together with the Auth0 OpenID Connect (OIDC) Client for .NET library to enable authentication in our iOS and Android mobile applications.

[Read on 📖]( https://auth0.com/blog/easy-authentication-xamarin-auth0/?utm_source=dev&utm_medium=sc&utm_campaign=authentication_xamarin)
Elegant Typescript Data Validation With Decorators
Tags: typescript, decorators, validation, joi
Published: 2020-02-06 16:12:53

---
title: Elegant Typescript Data Validation With Decorators
published: true
description: Typescript class, parameter and property decorators, as well as reflect-metadata are perfect tools to help helping validate typescript objects
tags: Typescript, Decorators, validation, Joi
---


Hi all :) 

I have released a npm package to easily validate your ts objects using decorators and Joi schemas: 
`npm i ts-decorator-validator`

I have also published an article about the rationale behind the package as well as what's happening under the hood. Here is a link:
* http://bit.ly/2S3FXTB

Enjoy :smile:
#CodepenChallenge Line & Direction: Border Button
Tags: codepen, vue, javascript, design
Published: 2020-02-06 16:11:02

<p>A VueJS component for ghost button (border button). The border will be shown when hovered on it. The border is an animated SVG path.</p>

<p>The component is written in #VueJS while the animation is written in #GSAP</p>

{% codepen https://codepen.io/takaneichinose/pen/GRJKJKL %}