teleren/devto huggingface dataset:
How to Setup Neovim with Python Provider using Conda
Tags: vim, python
Published: 2020-05-02 00:35:48

---
title: How to Setup Neovim with Python Provider using Conda
published: true
description: Setup Neovim with Python provider using Conda
tags: vim, python
---

*This post is cross posted from my own blog at [hassanaskary.com](https://www.hassanaskary.com/writing/how-to-setup-neovim-with-python-provider-using-conda)*

In this post I will go over the steps to setup Neovim with Python provider which is the Python language tool for Neovim. It is required by many Python specific plugins. I'll be using Conda environments to do this.

Firstly, if you don't have Neovim installed then install it. On Ubuntu type:

    sudo apt install neovim

Neovim requires the pynvim Python package to enable Python support. It can be downloaded from PyPI using pip. If you use Python environments you will have to install pynvim for every environment in which you want to use Neovim. Fortunately, there is a work around, we can create a Python environment and install pynvim in it. Then in our init.vim we will tell Neovim to look for the Python provider in that environment.

I'll use Conda to create the environments. Of course you'll need Conda to be installed on your system. To create a Conda environment type:

    conda create -n pynvim python=3.7

I named the environment pynvim and installed Python 3.7 in it. Now activate the environment by typing:

    conda activate pynvim

Lets install pynvim. Type:

    pip install pynvim

pynvim is installed in pynvim conda environment. We need to know the location of the environment. To do that type:

    which python

Note the returned path we will need it. Now open your init.vim and add this line in it:

    let g:python3_host_prog='/path/to/conda/environment'

Put the result of `which python` inside the single quotes `''`.

This is it. You've now configured Neovim for Python. You can now go ahead and install plugins. One really cool plugin is [Semshi](https://github.com/numirias/semshi) it does semantic syntax highlighting for Python.

I hope this was helpful for you.
May 2020 Quarantine Self Challenge
Published: 2020-10-07 15:44:45

---
title: May 2020 Quarantine Self Challenge
published: true
date: 2020-05-02 00:00:00 UTC
tags: 
canonical_url: https://sznm.dev/blog/quarantine-self-challenge
---

Recently I challenged myself to make a web app as soon as possible in two days. Managed to make two. One is a simple Food Recipe App and the other is COVID-19 Data App. Turned out it was so fun.

## 1. Le Cook

Fun food recipe catalog app powered by [RecipePuppy](https://recipepuppy.com) API....

[https://le-cook.now.sh/](https://le-cook.now.sh/)

![Le Cook (1)](https://sznm.dev/images/2020-05-02-self-challenge/le-cook_1.jpg) ![Le Cook (2)](https://sznm.dev/images/2020-05-02-self-challenge/le-cook_2.jpg) ![Le Cook (3)](https://sznm.dev/images/2020-05-02-self-challenge/le-cook_3.jpg)

## 2. COVID-19 Data

presenting COVID-19 statistics powered by [@mathdroid](https://github.com/mathdroid/covid-19-api/)'s covid-19-api. I made a vanilla JS version of this app several days ago and I decided to re-develop it using Gatsby (React).

[https://covid19data.now.sh/](https://covid19data.now.sh/)

![COVID-19 Data App (1)](https://sznm.dev/images/2020-05-02-self-challenge/covid19data_1.jpg) ![COVID-19 Data App (2)](https://sznm.dev/images/2020-05-02-self-challenge/covid19data_2.jpg) ![COVID-19 Data App (3)](https://sznm.dev/images/2020-05-02-self-challenge/covid19data_3.jpg)

Both [Le Cook](https://le-cook.now.sh/) and [COVID-19 Data](https://covid19data.now.sh/) app were developed using Segment's Evergreen UI. Just discovered this React UI Framework and turns out it's so convenient to implement it on these projects.

When developing COVID-19 Data app, I realized Evergreen UI have no opinionated way to construct responsive layouts. So, I decided to combine it with TailwindCSS which I already tried to use at this personal site. It worked.

![Evergreen UI (1)](https://sznm.dev/images/2020-05-02-self-challenge/evergreen-ui_1.jpg) ![Evergreen UI (2)](https://sznm.dev/images/2020-05-02-self-challenge/evergreen-ui_2.jpg) ![Evergreen UI (3)](https://sznm.dev/images/2020-05-02-self-challenge/evergreen-ui_3.jpg) ![Evergreen UI (4)](https://sznm.dev/images/2020-05-02-self-challenge/evergreen-ui_4.jpg)

I decided to deploy it using [Vercel](https://vercel.com) and I'm so shocked by how fast it is compared to [Netlify](https://netlify.com). I'm considering to migrate to Vercel from Netlify for my previous projects, including this site.

I posted my recent projects [here](https://sznm.dev/projects). You can access the project and the project's GitHub repository link from this [page](https://sznm.dev/projects).
Validating phone numbers: a developers primer
Published: 2020-05-01 23:09:22

For developers, validating phone numbers is just another form of validation, like dates and emails, until you try actually validating an international phone number, then you find out its a real pain in the butt!

International numbers dont follow any pattern. Each country has its own numbering plan with different number of digits. What makes matters worst is that in most coutries, not all numbers ranges are in use. So its easy to accept non-existing numbers even if you validate the pattern (using a regex for example).

The good news is that Google already did the heavy lifting for us. They compiled all the international patterns into one awesome library called libphonenumber.

That being said, there are basically two ways to validate international phone numbers:
1. By embedding Google's library in your own code
2. Using an API which will itself use libphonenumber or other more advanced validations

If you choose the first method make sure to update the library with every new release. If you go for API's, this page [https://veriphone.io/docs/code-example] has an extensive list of code examples (Diclaimer: I work for Veriphone)

Conclusion: no regex nor any piece of magic code you can come up with will validate phone numbers effectively. Stop trying implementing your own and use either Google's library or an API.
20 days into learning how to code 👨🏾‍💻
Tags: codenewbie, frontend, html, css
Published: 2020-05-01 22:54:18

<figure> <img src="https://miro.medium.com/max/764/0*t568JC4LFMMjxbE_" alt="hanging festive flags where it reads 'everybody can code'">
<figcaption>Photo by <a href="https://unsplash.com/@adigold1?utm_source=medium&utm_medium=referral" target="_blank">Adi Goldstein</a> on Unsplash</figcaption>
</figure>
<p>It was April 8 when I finished the LinkedIn Learning course <a href="https://www.linkedin.com/learning/html-essential-training-4" target="_blank">HTML Essential Training</a>. To be completely honest, I don’t even know why I started it in the first place. Maybe it was due the boredom COVID-19 brought into our lives with the social isolation measures, or maybe it was something else, who knows. One thing is sure though, I stayed because of the enthusiasms and passion with which <a href="https://twitter.com/jensimmons" target="_blank">Jen Simmons</a> teach the course.</p>
<p>From there, I jump right into the <a href="https://www.linkedin.com/learning/css-essential-training-3/introduction-to-flexbox?u=2218586" target="_blank">CSS Essential Training</a> from <a href="https://twitter.com/christinatruong" target="_blank">Christina Truong</a>, and that was it for me. I was hooked! The avalanche of information I’m being exposed is overwhelming only by the same degree it is fascinating. Seven to ten hours of my day are being dedicated to becoming a front-end developer. Shifting between learning, practicing, and interacting with other developers online, I’m more and more in love with coding each day.</p>I have much more to say about those 20 days, and that’s why I decided to write about it. Not only about them but also the many other days to come in this crazy journey. Hoping to inspire others, but mostly help me keep focus and track of my studies.<p>Come along! Fasten your seat belt, because this is going to be a crazy ride.</p><p>See some of the projects I’ve been working on at <a href="https://www.frontendmentor.io/profile/diegomouradev" targe="_blank">Frontend Mentor</a>, or pick into my <a href="https://github.com/diegomouradev" target="_blank">Github</a> repository. Also, find me on <a href="https://twitter.com/_DiegoMoura" target="_blank">Twitter</a>, and <a href="https://codepen.io/diegomoura" targe="_blank">Codepen</a>.</p>
Web Dev Bootcamp ∙ Introduction
Tags: javascript, webdev, beginners, react
Published: 2020-05-08 15:09:19

---
title: Web Dev Bootcamp ∙ Introduction
published: true
date: 2020-05-08 22:40:02 UTC
tags: javascript, webdev, beginners, react
canonical_url: https://www.devsurvival.com/web-dev-bootcamp/introduction/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/twrcfymcyvgnbqmx6qbs.png
---

### Introduction

Welcome to the [Web Dev Bootcamp](https://www.devsurvival.com/web-dev-bootcamp/introduction/)!

If you have an interest in web development or are trying something new, then you are in the right place.

### Curriculum

#### Introduction

1. Learn the standard web technologies - HTML, CSS, and Javascript
2. Advanced Javascript ES5 and ES6 features
3. Bash Commands
4. Overview of Git

#### Backend

1. Introduction to NodeJS and ExpressJS
2. Understand how API and requests works
3. Database with MongoDB and Mongoose
4. Authentication in Node

#### Frontend

1. Learning React - components, states, styling
2. Connecting React with Redux
3. Connecting React client to API

#### Deploying App

1. Learn how to deploy web app to heroku

#### Conclusion

1. Review
2. What to do after completing the course

### Getting Help

You can get help by:

- following me on [twitter](https://twitter.com/HieuNgu11332621)
- submitting a github [issue](https://github.com/htnguy/webdevbootcamp/issues/new)
- join the Devsurvival discord [server](https://discordservers.com/server/706606099444400220)
- post your question in the discussion section below each post

### Getting Source Code

You will find all relevant source code for this bootcamp [here](https://github.com/htnguy/webdevbootcamp)

#### Good Luck and Have Fun 😄

### [Start Learning](https://www.devsurvival.com/courses/web-dev-bootcamp/)
Redmi Note 9 with 6.53-inch display announced
Published: 2020-05-01 22:35:09

Xiaomi announced the Redmi Notice 9 for its worldwide markets now. This mobile sports a 6.53-inch Full HD+ LCD display with Corning Gorilla Glass 5 Protection. This mobile would be the very first Smartphone to be powered with the MediaTek Helio G85 8nm SoC with upto 4GB RAM and operates Android 10 using MIUI 11. The mobile includes a rear-mounted fingerprint scanner and also package a 5020mAh battery using 18W fast-charging with fast charger at the package. 

Do check out [All about unlocking bootloader, TWRP and rooting Redmi Note 8/8T](https://techlustt.com/2020/03/all-about-unlocking-bootloader-twrp-and-rooting-redmi-note-8-8t/), you'll love it.

The Redmi Notice 9 mobile includes quad back camera that a 48MP primary camera, 8MP 120° Ultrawide angle lens, 2-MP macro detector and also a 2-MP thickness detector. On the other hand it's a 13-mp front facing camera.

Display

The cellphone sport a 6.53-inch (2340 × 1080 pixels) FUll HD+ display using 450nit(typ) brightness, and Corning Gorilla Glass 5 protection.

Platform

It's powered by OctaCore MediaTek Helio G80 12nm chip (Dual 2GHz Cortex-A75 + Hex A 2GHz 6x Cortex-A55 CPUs) up to 1000MHz ARM Mali-G52 2EEMC2 GPU and operates Android 10 using MIUI 1-1.

Storage

The gadget includes 3GB LPPDDR4x RAM using 64GB (eMMC 5.1) / / 4GB LPPDDR4x RAM using 128GB (eMMC 5.1) storage, expandable memory as much as 512GB using micro-sd.

Camera

On the other hand it's 13-mp front camera using f/2.25 aperture.

Pairing and Sensors

It's dual-sim, 3.5millimeter audio jack, radio splash-resistant (Pi coating) and comes equipped with Fingerprint detector, IR detector.

Dimensions and battery

The cellphone packs 5020mAh (average ) / / 4920mAh (minimum) battery using 18W charging. ) The device includes a size dimension of 162.38×77.2×8.95millimeter and weight has been 199g.

Prices and Availability

To your 3GB RAM using 64GB storage. To your 4GB RAM using 128GB storage versions. The telephone comes from Forest-green, Polar White and Midnight Gray shades.
VSCode: Setting line lengths in the Black Python code formatter
Tags: vscode, python, webdev, tutorial
Published: 2020-05-01 22:28:14

---
title: VSCode: Setting line lengths in the Black Python code formatter
published: true
description: How to set Black Python code formatter line lengths in VSCode
tags: vscode, python, webdev, tutorial
---

The docs for the [Black](https://black.readthedocs.io/en/stable/index.html) Python code formatter say that the formatter ["is not configurable"](https://black.readthedocs.io/en/stable/the_black_code_style.html?highlight=length#the-black-code-style). This is largely true, but if you have Black [set up to work in VSCode](https://dev.to/adamlombard/how-to-use-the-black-python-code-formatter-in-vscode-3lo0), you _can_ configure the line length.

In VSCode, go 'Code -> Preferences -> Settings' and search for "python formatting black args".

Add two separate arguments, in this order: `--line-length` and `n`, where "n" is your desired number of allowed characters per line:

![Interface for adding Black formatting arguments in VSCode](https://dev-to-uploads.s3.amazonaws.com/i/6sb8161hjqscv8frvzs8.png)

A few notes about line lengths in Python:
- PEP8 recommends a line length of [79 characters](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) (72 for docstrings)
- Black sets line lengths to [88 characters by default](https://black.readthedocs.io/en/stable/the_black_code_style.html?highlight=length#line-length)
- The Django docs recommend a maximum line length of [119 characters](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/) (79 for docstrings)

---
If you are working on a shared project with a team, consider bypassing the VSCode settings entirely, and setting line lengths via the project's `pyproject.toml`:

```toml
[tool.black]
line-length = 119
```
---

Was this helpful? Did I save you some time?

## {% cta https://www.adamlombard.com/support-me %} 🫖 Buy Me A Tea! ☕️ {% endcta %}

---
Day 129 : Peace of Mind
Tags: hiphop, code, coding, lifelongdev
Published: 2020-05-01 22:28:05

_liner notes_:
- Professional : Really great way to start the weekend. Finished and demoed the CLI tool I built. Had another team member test out the tutorial I've been reworking. She was able to get it working. That was cool. Had out team meeting and caught up with everyone. Ended the day in a video call hanging out with more team members talking about all sort of stuff (not work related, haha).

- Personal : Spent last night working on the the CLI demo and listening to tracks for the radio show. Pretty much it.

![Rugged mountain tops of Puez Geisler, Italy](https://dev-to-uploads.s3.amazonaws.com/i/0vro6onbas6abvpqk2m7.png)

My brain is tired, but also have a peace of mind. haha. Going to finish up the radio show for tomorrow. Maybe watch some anime and play video games. Friday night during a quarantine. 

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube Z_GR_l5QtdM %}
ReEntrant Locks
Tags: java, multithreading, concurrency
Published: 2020-05-01 22:19:13

How many of you still need to use (for non-ownership lock release) or have a code base which uses semaphores (shorturl.at/fjzPW)  ?  At least, I have not seen a code base in last 8+ years with semaphores in it. Based on my discussion with few fresh dev interview candidates in the past , I thought it might be a good idea to share some light on the term reentrant locks. The word itself is self explanatory. A lock which can be entered again or acquired again. The only conditions is - "by the same thread". Can be better described with a code example 

    private Lock lock = new ReentrantLock(true);

    private void lockMyselfWithoutDeadLock(int counter){
        if (counter <= 0){
            return;
        }
        lock.lock();
        System.out.println("Call Myself");
        lockMyselfWithoutDeadLock(counter-1);
        lock.unlock();
    }

    public static void main(String[] args){
        ReEntrantLock reEntrantLock = new ReEntrantLock();
        reEntrantLock.lockMyselfWithoutDeadLock(5);
    }

 Any thread which calls above method with a positive number and is able to acquire lock once, will be able to call itself, until returned and thus re-acquiring the lock multiple times. 

TO explain a non-reentrant lock,I would use an example of Semaphore. Think of it like a ticketed entry point which can allow a certain number of permits. A thread which has a valid permit can use that permit once to enter. If a thread can get one more permit, it can enter the lock one more time. Main point is that there is a limit. Its not like re-entrant locks where same thread can gain the lock any number of times. Following example will showcase the scenario 

       private Semaphore lock = new Semaphore(2); // 2 Permits

       private void lockMyselfWithDeadLock(int counter) throws 
                                            InterruptedException 
       {
         if (counter <= 0){
             return;
         }
         lock.acquire();
         System.out.println("Call Myself");
         lockMyselfWithDeadLock(counter-1);
         lock.release();
       }

       public static void main(String[] args) throws InterruptedException {
         NonReEntrantLock nonReEntrantLock = new NonReEntrantLock();
         nonReEntrantLock.lockMyselfWithDeadLock(5);
       }

The above program will be in a deadlock if called with an argument greater than 2 as semaphore holds only 2 permits. I hope this will help someone trying to learn concurrency !!
Tracking Rails changed attributes
Tags: rails, ruby
Published: 2020-05-01 21:33:23

On today's "*What did i want to achieve/how i achieved it*", I had to fix this weird bug where one form field was triggering changes in the DB regardless of any user interaction.

Take your typical rails form and add a map component(we deal a lot with location data at Georepublic). 

The bug was that, when a user edits one record's attribute and save, this would also update the location attributes(Latitude & Longitude) automatically by 1/1000000000 which isn't meaningful TBH but the issue was emailing subscribed users on such minimal changes!

PS: *The purpose of this post is not fixing that value-change bug, but detecting and ignoring those small changes*

**Meet [ActiveModel::Dirty](https://api.rubyonrails.org/classes/ActiveModel/Dirty.html)**

Rails comes with *ActiveModel::Dirty* module that, as it's described, 
>Provides a way to track changes in your object in the same way as Active Record does.

This allows you to perform various operations whenever your attributes changes.

Going back to my bug, i had to make sure the location changes were  "valid enough" to trigger our notification services.

### Step 1: Add callback

Since our notification service is called on every update, it makes sense to check for these changes "before updating"
```rb
before_update: ignore_small_changes
```

### Step 2: Track changes

As mentioned earlier, this was a location attribute saved as a `geometry point` in the db (cfr [Rgeo](https://github.com/rgeo/rgeo-activerecord)) which basically mean that it's a collection of points a.k.a `[140.1250590699026,35.6097256061325]`

Using Rails `ActiveModel::Dirty` you can detect changes on any attribute using the following ways:

```rb
class User < ApplicationRecord
end

user = User.first
user.update(address: "new address")
user.address_changed? #returns true if user address has changed

user.address_change # returns an array of [oldvalue, newvalue] or [nil] if there's no change
```

### Step 3: Ignoring small changes

Since we are dealing with a location point i.e *[lat,lng]* calling `address_change` on this would return a collection of this kind `[[lat, lng],[lat, lng]]`

Thus, comparing changes(and ignoring small ones) in these two collections become a lot easier with [Ruby#Zip](https://apidock.com/ruby/Array/zip)

```rb
def ignore_small_changes
  unless address_change[0].nil?
    old_value = address_change[0].coordinates
    new_value = address_change[1].coordinates
#Ignore changes if the difference is minimal
    self.address = address_change[0] if new_value.zip(old_value).map { |a, b| (a-b).abs }.map {|x| x < 0.00000001}.all?
  end
end
```
### Conclusion

Although this was used to fix a bug in my case, you can always leverage these methods by using it as callbacks to performing different actions only when certain attributes have changed.
Top Edpresso shots-April 2020
Tags: computerscience
Published: 2020-05-01 21:16:15

Happy May 1st! 

Edpresso is a database of byte-sized dev knowledge that just keeps on growing! 

Today, we've taken a moment to reflect on our most trafficked shots from April. Give them a read, see what you think, and show them some love! 😃

1. [What is complex event processing?](https://www.educative.io/edpresso/what-is-complex-event-processing)
“Complex event processing (CEP) is an approach to searching patterns in a real-time stream of events.” This shot by [Siddarth Singh](https://www.educative.io/profile/view/5197204423704576) uses the example of building a fraud detection system for a bank that can detect fraudulent transactions in real-time to show how CEP systems use event streams and pattern queries. 

2. [How to create a shopping car app using BLoC pattern in Flutter](https://www.educative.io/edpresso/how-to-create-a-shopping-cart-app-using-bloc-pattern-in-flutter)
Two of this month’s top shots were written by [Chukwujama Osinachi Victor](https://www.educative.io/profile/view/5890939820179456). His first, “How to create a shopping cart app using BLoC pattern in Flutter” shows users how to build a simple shopping cart app that uses the BLoC pattern as a way to explain the BloC pattern, which is a mature way to manage state in a Flutter app.

 

3. [Strategies for solving bugs](https://www.educative.io/edpresso/strategies-for-solving-bugs)
[His](https://www.educative.io/profile/view/589093) second, “Strategies for solving bugs” goes through a checklist of the effects that frustration at not being able to find a bug can have such as, “loss of motivation to go further,” “many hours lost trying to track the given bug,” etc. His shot goes over these effects and explains ways that he has found to be beneficial when solving bugs like, keeping an anti-bug checklist in your brain or writing about your bug to avoid repeating the mistake. 

4. [Learn dynamic programming in 10 minutes!](https://www.educative.io/edpresso/learn-dynamic-programming-in-10-minutes)
“Those who cannot remember the past are condemned to repeat it.” This shot by [Harsh Jain](https://www.educative.io/profile/view/5084051834667008) goes over why we need dynamic programming (the act of “remembering answers to the sub-problem you’ve already solved, and not solving them again.”), dynamic programming and recursion, and how to identify a dynamic programming problem.

5. [Find the integer that appears once in an array](https://www.educative.io/edpresso/find-the-integer-that-appears-once-in-an-array) 
Last but not least is our top shot this month, according to our users. In this shot, [Benjamin Chibuzor-Orie](https://www.educative.io/profile/view/6631408564961280) deals with how to find the integer that appears once in an array. He starts with the problem and then moves on to several approaches that could be used as well as the optimal solution (i.e., The XOR operator).
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j6ipgve22yaj15pa6iu5.png)