teleren/devto huggingface dataset:
Listening to Events
Tags: javascript, beginners
Published: 2020-04-24 08:01:25

---
title: Listening to Events 
published: true
description: Event Listener 
tags: javascript, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/40cigkzjtpc2jm9tr9gx.jpg
---
The events allow us to listen for something inside our D.O.M.
Here is the list of [all avaible events (MDN)](https://developer.mozilla.org/en-US/docs/Web/Events)
that we can listen to.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/td8ss7jmhxsl3qg1x4d2.png)
In the gif down below we see the snippet of code in action.
When the button is clicked the addEventListener perform the action, in this case we add or remove the class red to our button (element).
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8ur8d3evho3fm2mkkwfe.gif)
There is also the event object but we talk about it later and more in depth.
Apps to help you with WFH
Tags: android, ios, workstations
Published: 2020-04-24 07:51:40

As the world is going through crazy situations & the majority of the workforce in the world is forced to opt for work from home & remote working. Though few organizations have this WFH policy & encourage employees to take it up occasionally, this might be tricky for first-timers. So here is a small list of apps ( Available for Android & iOS ) that can keep up with your productivity & managing activities.

###To-Do list

Tracking of tasks might get screwed at home, at one point you might be wondering what to do. This is where a To-do list helps, the start of day/week, just list out the things which you wanna do for the rest of day/week according to priority & set timely reminders.

**Apps** - Microsoft To-Do, Swipes, Engross.

###Video calling

Though we might discuss in a chat with our team members, video calls once in a day or week will fast forward things & helps to get a better idea of how things are panning out. If there is a birthday, just go out on a group video call & surprise your colleagues.

**Apps** - Skype, Microsoft Teams, Uberconference

###Project Management

Project management might create a problem if you don't have an [HRMS software](https://www.keka.com/hr-software/) in your organization. But we can alternatively use a few apps to fix it. The most popular one being Slack which doesn't need any further introduction. Just go through their guides on the site & get started.

**Apps** - Slack, Notion, Zapier

Let me know what all the apps you are using in this pandemic times to get keep up with your work & productivity.

Stay Home...Stay Safe !!
Day-12 Find all the numbers disappeared in the array
Tags: python, discuss, challenge
Published: 2020-04-24 07:47:12


This problem statement is a part of LeetCode's learning card Introduction to Data Structures Fun with Arrays-101.

##### Problem Statement
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

Find all the elements of [1, n] inclusive that do not appear in this array.

Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

##### Example 1
```
Input:
[4,3,2,7,8,2,3,1]

Output:
[5,6]
```

##### Solution Approach
1. The range of elements and the value of elements is the same.
2. List can have duplicates as well. So, converting a list to set would mean removing duplicates and having only unique elements.
3. Subtracting the set containing numbers between range [1, n] and the set formed by removing duplicates. Would return the missing elements.
4. Convert the set to list.

```
class Solution:
    def findDisappearedNumbers(self, nums: List[int]) -> List[int]:
        return list(set([x for x in range(1, len(nums)+1)]) - set(nums))
```

##### Learnings
1. Time complexity - 0(n)
2. We are still using extra space by initializing a completely new list with elements between [1,n]. 
3. Need to figure out a way to optimize space.
'filter' vs 'find': JavaScript array methods
Tags: javascript, beginners
Published: 2020-04-24 07:46:01

ES6 ships with several array methods which enable one to perform operations such as 
1. Filtering values (filter)
2. Summing up array elements (reduce)
3. Performing the same operation for each element (map)

Assuming you want to find a single value given a condition, you'd most likely use `find`. But if you always use (filter, map and reduce) above others, it's time to re-learn `find`.

## Some code to illustrate
We have an array of users
```js
const users = [
  {
    name: "Alice",
    age: 19,
    id: 1
  },
  {
    name: "Bob",
    age: 24,
    id: 2
  },
]
```
We need a user with an id of 2

### Getting the user using `filter`
```js
const user = users.filter((user) => user.id === 2)
// returns [{name: "Bob", age: 24, id: 2}]
// to resolve, we do
const user = users.filter((user) => user.id === 2)[0]
// which then returns {name: "Bob", age: 24, id: 2}
```

### Getting the user using `find`
```js
const user = users.find((user) => user.id === 2)
// returns {name: "Bob", age: 24, id: 2}
```

There you have it. You've relearned the `find` array method.
No question is too taboo - Candidate Q&A Live Stream April 27
Tags: career, beginners
Published: 2020-04-24 07:34:06

Hi Lovelies! On Monday April 27th, I'm live streaming answers to whatever candidate questions people ask me, from getting noticed by recruiters, to acing technical and non-technical interviews, and negotiating offers. 

{% youtube XEq-3HgRlEA %}

I wanted to let y'all know. I'll post the video here afterwards, but I would love to see some friendly faces in the live stream chat. Don't be shy - no question is too taboo \o/
Pushing out an MVP
Tags: beta, mvp
Published: 2020-04-24 07:32:53

---
title: Pushing out an MVP
published: true
series: Building a chatbot with the RaMP stack (RaspberryPi, MySQL, Python)
description: MVP tech stack deviating from plans
tags: beta, MVP
---

I want to build a chatbot that answers questions about the Mahabharat.

When I started out, my intention was to build the chatbot (and, subsequently, an API) on a MySQL database with Python. Things didn't work out as planned, however :smile:. For starters, my RaspberryPi refused to play nice with MySQL through Python. Yes, I googled. No, nothing worked (yet).

Meanwhile, I was getting frustrated. Here I was, with tons of data to share with the world, and some stupid technical non-knowledge was standing in my way.

So, I decided to look for a simpler tech stack and push out an MVP. Doing so will help me in two ways:

- Gather feedback on the usefulness of my offering
- Find simpler solutions to technical challenges (did I mention I am not a coder?)

So, here's my MVP: https://mb-verse.herokuapp.com. Its tech-stack uses:
- json for storing data
- python for processing data
- heroku for hosting
(The code is in a private GitHub repo at the moment because I am not comfortable yet sharing the json files.)

Please let me know your thoughts regarding the MVP. I am looking for feedback on usability and usefulness. I started a public GitHub repo to gather issues: https://github.com/AninditaBasu/calm-wildwood

(And, if you don't know about the Mahabharat, you might want to read this summary: https://www.ancient.eu/Mahabharata/. But even if you don't know the story [and *especially* if you dont know the story], your feedback is very welcome because you represent a good user persona: someone who wants to know about a story - any story - that's much loved by some other group. For example, if I haven't seen any Star Wars and there was this chatbot...)

Let me know what you think :slightly_smiling_face:
How to upgrade Ubuntu 18.04 to 20.04
Tags: ubuntu, linux, tutorial, beginners
Published: 2020-04-24 07:25:45

So here comes Ubuntu 20.04 LTS (Focal Fossa) and the upgrading is quite simple af...
Your internet connection should be reliable and  hit the following command in the terminal and hit enter

**sudo do-release-upgrade -d**


Althought it takes time to upgrade, so be patient and do the steps it asked during along the upgrading (some of them are yes/no to install this whatever)
Move Hexo to Hugo
Tags: blog, firebase, hugo
Published: 2020-04-24 06:49:35

---
title: "Move Hexo to Hugo"
published: true
description: "Deploy hugo static site to firebase hosting by TravisCI"
tags: blog,firebase,hugo
canonical_url: https://jma.im/posts/2020-04-24-move-hexo-to-hugo/
---

[travisci]: https://travis-ci.com

![Hugo in TravisCI](https://jma.im/images/hugo-in-travisci.jpg)

## What is Hugo?

Hugo is a static site generator written in Go. It is optimized for speed, easy use and configurability. Hugo takes a directory with content and templates and renders them into a full html website. Hugo makes use of markdown files with front matter for meta data.

## Hexo vs Hugo

Hexo is also fast and simple, it is a static blog generator, and Hugo is more like for a site not only blog. Hexo is written in Node.js. Since I am a Golang developer now. I think it is good to move to Hugo.

## Prepare Hugo

Check the Hugo official page [Migrate to Hugo](https://gohugo.io/tools/migrations/) before you do it by yourself.

Hugo has different content structure than Hexo. 

First of all, remove any unrelated files like themes, submodules, hexo config file...

for removing submodules from https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218

```bash
# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule
```

Then, Install Hugo and run `hugo new site --force` in the current folder, it will generate the mandatory files for the site. 

Add theme you like and do configuration.

Move all posts to the new content folder, I put mine into the `content/posts`. Update the front matter of the posts to avoid compile error in the Hugo.

That’s almost done, it is easy because I moved my site from Jekyll to Hexo, then to Hugo, they all use markdown files and front matter for the post.

## Continuous Delivery (CD)

I switched from Github to Firebase hosting after I moved from Jekyll to Hexo. Firebase hosting will give you a free SSL. 

### TravisCI

I use [Travis CI][travisci] to build pages and deploy to Firebase hosting. You can check mine [`.travis.yml` ](https://github.com/imjma/blog/blob/master/.travis.yml) file.

### Firebase hosting

You need a token to deploy to Firebase hosting from ci, following the doc [Firebase CLI reference](https://firebase.google.com/docs/cli#cli-ci-systems). Then Add the token to [Travis CI][travisci] .

## Last

So now, once TravisCI detects your master branch of repository has been changed, it will trigger the build in TravisCI, and build the static site and publish to firebase hosting.
Tactics to Build Your Own Uber Like App
Tags: uberclone, ubercloneapp, uberclonescript
Published: 2020-04-24 06:16:33

If you are planning to begin your own Taxi Business and build an app like Uber, you need to invest in a trusted company that has a seasoned group of app developers. They must use the latest technology stack to develop an Uber clone app that will compete against Uber.

4 Method to build your own <a href="https://www.apporio.com/product/apporio-taxi-uber-clone-script/">Uber Clone</a> App
Plan the Structure
You have to focus on taxi app development and other important functionality as well like User App, Driver App, Admin / God Panel.

Technology Integration
There are lot of technology work going behind the app to support the system.
Technology that is used in <a href="https://www.apporio.com/product/apporio-taxi-uber-clone-script/">Uber Clone</a> like Google Location Service, Google Location Service APIs, Stripe PayPal’s SDK Google Wallet, etc.

Fare Calculation Algorithm
Another major function you need to understand is how uber clone app calculates ride fare. Uber clone taxi app combines time and distance, it means that if the driver driving speed is less than 19 km per hour, the rider is charged for per minute.
Base Rate: Charges are based on time and distance of a trip.
Booking Charges : Flat charges to support operational, managing, and safety costs.
Dynamic Charges : Dynamic Charges are applied when there is less supply of the driver in the area. These times are also known as peak hours. Every taxi business charges high in peak time.
Functionality and Feature of Application
Passenger App : Easy Registration, Easy Taxi Booking Process( Inbuilt map feature allows to mark pickup and drop location), Booking Confirmation, Option of Ride Cancellation, Ride Tracking, Push Notification, Sos Service, Payment.

Driver App : Drivers partner with Uber. Driver app include Profile, Trip Notification/Alert, Push Notification, Messaging Option, Route Map.

Admin / God Panel : Admin manages the business, Admin have full control. Some key function include :
Ride Management, Fare Charges Management, User Management, Driver Management, Rating and Review Management, Support Management.
New php router is 25 times faster then klein router
Tags: php, rest, router, klein
Published: 2020-04-24 06:42:12

Hi, all! Recently I have decided to measure speed of my [router](https://github.com/alexdodonov/mezon-router)

And results were quite interesting.

I have measured the productivity in two tests:

1. Static routes without any regexp parsing or variables in URI

2. URI with variables

The first test for the Mezon/Router:

```php
// static routes

$routerTest1 = new \Mezon\Router\Router();

$routerTest1->addRoute('/static', function () {
  return 'static';
}, 'GET');

$iterationCount1 = 100000;

$startTime1 = microtime(true);

for ($i = 0; $i < $iterationCount1; $i ++) {
  $routerTest1->callRoute('/static');
}

$endTime1 = microtime(true);
```

And the second test:

```php
// parametrized routes

$routerTest2 = new \Mezon\Router\Router();

$routerTest2->addRoute('/[i:id]', function () {
  return 'param';
}, 'GET');

$iterationCount2 = 100000;

$startTime2 = microtime(true);

for ($i = 0; $i < $iterationCount2; $i ++) {
  $routerTest2->callRoute('/1');
}

$endTime2 = microtime(true);
```

For the klein/klein router it is almost the same:

```php
// static routes

$_SERVER['REQUEST_URI'] = '/static';

$routerTest1 = new \Klein\Klein();

$routerTest1->respond('GET', '/static', **function** () {
  return 'static';
});

$iterationCount1 = 10000;

$startTime1 = microtime(true);

for ($i = 0; $i < $iterationCount1; $i ++) {
  $routerTest1->dispatch(null,null,true,\Klein\Klein::DISPATCH_CAPTURE_AND_RETURN);
}

$endTime1 = microtime(true);
```

And the second one:

```php
// parametrized routes

$_SERVER['REQUEST_URI'] = '/1';

$routerTest2 = new \Klein\Klein();

$routerTest2->respond('GET', '/[i:id]', function () {
  return 'static';
});

$iterationCount2 = 10000;

$startTime2 = microtime(true);

for ($i = 0; $i < $iterationCount2; $i ++) {
  $routerTest2->dispatch(null,null,true,\Klein\Klein::*DISPATCH_CAPTURE_AND_RETURN*);
}

$endTime2 = *microtime(true);
```

I have got the following results:

![table](https://dev-to-uploads.s3.amazonaws.com/i/8gtxdbi5khgfa28b2ilp.png)

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

As you can see - Mezon router is up to 25 times faster than Klein router.

# Learn more

More information can be found here:

[Twitter](https://twitter.com/mezonphp)
[Mezon Framework](https://github.com/alexdodonov/mezon)

# What is mezon/router?

mezon/router now is:

- framework for routing with **100% code coverage**
- **10.0 points** on scrutinizer-ci.com
- router is a part of the [Mezon Project](https://github.com/alexdodonov/mezon)

Repo on github.com: https://github.com/alexdodonov/mezon-router

# It will be great if you will contribute something to this project. Documentation, sharing the project in your social media, bug fixing, refactoring, or even **[submitting issue with question or feature request](https://github.com/alexdodonov/mezon-router/issues)**. Thanks anyway )
Python Tuples
Tags: python, webdev, django
Published: 2020-04-24 06:04:38

In Python, Tuples can be formed by placing a sequence of elements side by side separated by comma(,) inside parentheses.

The difference between a `tuple` and `list` is that tuples are immutable(they cannot be altered or modified) whereas list can be changed and sorted.

Tuples are useful when you want to protect values from updating or changing.

#### Creating Tuples

**Example**: Creating tuples using parentheses.

    t = (25, 13.12, "This is a tuple")
    print(t)
    
    #PYTHON OUTPUT
    (25, 13.12, 'This is a tuple')

**Example**: Creating tuples using constructors.

    t = tuple((25, 13.12, "This is a tuple"))
    print(t)
    
    #PYTHON OUTPUT
    (25, 13.12, 'This is a tuple')

#### Accessing tuples

This is same as accessing the list. We need to specify the index of the value we want.

**Example**

    t = tuple((25, 13.12, "This is a tuple"))
    print(t[2])
    
    #PYTHON OUTPUT
    This is a tuple

#### Accessing nested tuples

**Example**

    t = tuple((
        (1,2,3,4),
        (10.25,12.10,14.33),
        ('a','b',)
    ))
    print(t)
    
    #PYTHON OUTPUT
    ((1, 2, 3, 4), (10.25, 12.1, 14.33), ('a', 'b'))

**Example**: Accessing nested tuples

    t = tuple((
        (1,2,3,4),
        (10.25,12.10,14.33),
        ('a','b',)
    ))
    
    print("Accessing tuple inside a tuple")
    print(t[1])
    
    print("Accessing 1st indexed tuples 2nd indexed value. ")
    print(t[1][2])
    
    #PYTHON OUTPUT
    Accessing tuple inside a tuple
    (10.25, 12.1, 14.33)
    
    Accessing 1st indexed tuple 2nd indexed value. 
    14.33

To count the elements in tuple use python's built-in method 'len()'

**Example**

    t=tuple((1,2,3,))
    print(len(t))
    
    #PYTHON OUTPUT
    3

To check if the value present in the tuple.

**Example**

    t=tuple((1,2,3,))
    
    if 3 in t:
        print("Yes exists")
    else:
        print("Does not exists")
    
    #PYTHON OUTPUT
    Yes exists

**Example**

    t=tuple((1,2,3,))
    
    if 31 in t:
        print("Yes exists")
    else:
        print("Does not exists")
    
    #PYTHON OUTPUT
    Does not exists

To check whether the index exists in tuple use `try...except` block.

**Example**

    t=tuple((1,2,3,))
    
    try:
        t[5]
        print("Index exists")
    except IndexError:
        print("Index does not exists.")
    
    #PYTHON OUTPUT
    Index does not exists.

As tuples are immutables their values cannot be updated nor you can remove items from the tuple.

**Example**

    t=tuple((1,2,3,))
    t[1]=222
    print(t)
    
    #PYTHON ERROR OUTPUT
    TypeError: 'tuple' object does not support item assignment

To delete a tuple completely.

**Example**

        t=tuple((1,2,3,))
        del t
        print(t)
        #PYTHON ERROR OUTPUT
        name 't' is not defined #because the tuple as already deleted.
Top Python Posts
----------------

*   [Python List](https://dev.to/pavanbaddi/python-lists-hcb)
*   [Python Dictionary](https://dev.to/pavanbaddi/understanding-python-dictionary-23o3)
Iniciando primeiro projeto com Gatsby e Sass.
Tags: gatsby, saas, javascript
Published: 2020-04-24 06:00:24

- Instalando o Gatsby em modo Global.
```javascript
sudo npm install -g gatsby-cli
```

- Criando um novo projeto pré configurado.
```javascript
gatsby new <nome do projeto>
```

- Criando um projeto com uma página em branco.
```javascript
gatsby new tutorial-part-two https://github.com/gatsbyjs/gatsby-starter-hello-world
```
- Acessando a pasta do projeto.
```javascript
cd tutorial-part-two
```

- Iniciando o Servidor de desenvolvimento.
```javascript
gatsby develop
```
- Instalação dos plugins do Gatsby se necessário.
```javascript
npm install gatsby-plugin-google-fonts --save

npm install --save node-sass gatsby-plugin-sass

npm install gatsby-plugin-google-fonts --save
```

- Instalando o Sass no Gatsby.
```javascript
npm install --save node-sass gatsby-plugin-sass
```

- Depois da Instalação do Sass você deve incluir um plugin no "gatsby-config.js"
```javascript
plugins: [`gatsby-plugin-sass`]
```
How data science courses can help you become a data scientist?
Published: 2020-04-24 05:53:20

Introduction
You might have heard about a data scientist from one of your friends and after doing a little research on the same, you might want to become one too. But only making up your mind will not help you become a data scientist, right? This article tries to help you discover the world of data science and how taking courses in Data Science will help you achieve your dream better and quicker.
Who is a Data Scientist?
If you are remotely interested in this area, you might know roughly what Data Science is all about and what exactly, does a Data Scientist do.
Basically a Data Scientist extracts useful information from a huge volume of data in order to draw informative conclusions and help the connected organization achieve its set goals and prospects within the stipulated time period. In other words, they help the organization gain more profits and more customers and use their information to come up with better products that are in accordance with the interests of these customers.
Joining a Data Science Course is a Smart Choice
Here are some of the reasons which justify the enrollment in a Data Science Course to help you achieve your dream of becoming a Data Scientist:
Unbelievable growth in Career: If you enroll in a data science course, you are certified on the completion of the course. This not only helps you validate your knowledge, but also helps you get high paying jobs.
Freedom to choose from a set of flexible classes: There are both online and offline courses available for Data Science. You can choose either according to your profession and availability. Working professionals usually choose an online course while the candidates just kick-starting their careers opt for offline courses. The timings of the class are also flexible and the staff cooperates to suit your preferences, every single time.
Structured Syllabus so that you are never left behind: The syllabus of such courses is updated constantly, so that the candidates have the option to learn or at least get introduced to every new technology available in the market.
Practical Implementation: With the help of these courses, one can constantly implement the theory that they are learning in the class to real-life scenarios. The tradition of these courses is to offer a situation to the students where every theory and every principle can be applied.
Validation of Knowledge and Justification of your worth: Many companies like to interview only those candidates who have credibility. If you are enrolled in a Data Science course, you are considered credible and the probability of getting the job increases incredibly.
Resource Box
We hope that this article was able to inform you well about the different data science courses and also tell you how these courses can help you achieve the dream career of that of a data scientist. We hope you share this article with someone who also aspires to be a data scientist.