teleren/devto huggingface dataset:
Log(N)simplified!!!
Tags: datastructures, algorithms, timecomplexity
Published: 2020-06-13 07:43:57

---
title: Log(N)simplified!!!
published: true
description: A simple explanation of a time complexity Log(N)
tags: datastructures, algorithms, timecomplexity
//cover_image: ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7xih9zxnn1uliv7xdubx.jpg)
---

In computer science, by definition, "Time Complexity" means the amount of time taken to run an algorithm. An algorithm runs on an input data and the time taken by algorithm to process the input data varies with the amount of input data. O(N) is the simplest one to understand where we know there is a linear relation of a time to the size of an input data. But things start getting confusing as soon as we introduce "Log" to the party, mathematical background of Logarithms makes people even more afraid of it. 

However, if we keep our intention to understand Log(N) only from time complexity perspective, it is not difficult at all. Let me try and explain;

####Pre-requisites: 
Input Data Size = N
Problem to solve on this data.
Algorithm to solve this problem.

Let's consider how the graph of the powers of 2 grows and then come back to understand how it relates to Log(N).

2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32 and so on.

The generalised equation becomes;

2^index = N

It is very clear from the above equation that with just the increase of 1 in the index, the result N, doubles. It is an exponential growth.

If we reverse the equation and start reducing the result to half, the index decreases only by 1.

32 = 2^5
16 = 2^4
08 = 2^3
04 = 2^2
02 = 2^1
01 = 2^0

Now, let's try and relate it back to our problem and the algorithm to solve it. If our algorithm is efficient enough to divide the input data in half every-time it processes the data in order to solve the problem, then our algorithm is said to have a time complexity of Log(N)

With all the explanation above, following equations are the different representations of the same thing.

Log(8) = 3 -> 2^3 = 8 -> Log(N) = index

To put it in a sentence, "To process the input data of size N, it will take the Log(N) i.e. 'index' amount of time."

####Importance of "2" in Log(N)
Why we took an example of 2? 
Because in order to solve the problem, we are dividing the input data in to the half (1/2) every time we process it, eliminating the need to process the half of the data. And that's why, here it's the Log to the base of 2. In computer science whenever we talk about Log, it is always to the base of 2.
MAYA by Spotify
Tags: news, codenewbie
Published: 2020-06-13 07:33:54

**Spotify** is a leading audio music,Podcast platform in the world right now with 271 million MAU(Monthly active users) and 124 million paid subscribers. This Tech giant experimented a new Concept **MAYA** with their subscribers. Today, Lets talk about that!

When Spotify was about to launch their product in the Market, They were excited with this new feature that gonna change Digital Music Market called "**Discover Weekly**". 

***Discover Weekly*** is Custom playlist of 30 new songs which you might like to listen or you might want to try new songs which are possibly endup in your curated playlist.This "**Discover Weekly**" Playlist made by Spotify Ml/AI algorithm using similar genres you like and using some magic trick. 

After Successfully lauching the product they found out that this Playlist has a bug that it was showing 8 out of 30 songs which have already been listened by the user or already loved. So as you think, they had resolved it in no time.

They thought now it's gonna take their graph higher than never. Turns out they were wrong(Oops😨!), they found out Customers actually liked the **Buggy Algorithm.** 

Company came up with name of this concept as **Mostly Advanced Yet Acceptable**(MAYA). 

I hope you guys will apply this concept in your daily decisions where you get to highly advanced yet acceptable. Like Pockmen Go, the concept is old but they came up with Virtual Reality(VR) feature[*Mostly Advanced Yet Acceptable*]

Hoping you like this post!

If you found this Article, Interesting story Like it and Share it to your Devs🤞
Contact me: [LinkedIn](https://www.linkedin.com/in/maheshthedev/) · [GitHub](https://github.com/maheshthedev)
How To Do DOM Manipulation In VanillaJS
Tags: vanillajs, javascript
Published: 2020-06-13 07:28:03

Gone are the days when we used to attach those monstrous libraries like JQuery and Zepto to our Web Pages whenever we wanted to interact with the DOM. though many in-built functions were available back then too but they were not very accessible and most of the time very difficult to use.

But now things have changed and we should not use JQuery or even its so-called lightweight alternative Zepto because nearly all DOM Manipulation APIs that they used to offer, now come built-in. I Know many of you guys already know about these APIs, but the target audience of this post is the next wave of beginner Javascripters and People who want to migrate their existing projects from JQuery or create their new projects using Vanilla Javascript.

So, Today I will introduce you guys to these Vanilla JS DOM Manipulation functions and a few code snippets which can save you from using JQuery or Zepto.

### Selecting an element using document.querySelector & document.querySelectorAll

In JQuery we used the `$(selector)` function for selecting DOM Nodes using CSS Selector strings, in vanilla we can use `document.querySelector(selector)` function to select the first matching element and `document.querySelectorAll(selector)` function for selecting all of the elements that match the selector string.

**Example:**

HTML File

```html
  <div id="test">Hello World</div>

  <div id="test2">Hello Again?</div>
```
Javascript File

```javascript
  const test = document.querySelector('#test'); // div#test

  const divs = document.querySelectorAll('div'); // [div#test, div#test2]
```


### Adding, Removing, Toggling Classes 

To Add a class:-

```javascript 
  element.classList.add('class1'); // adds the class1 to the element

  element.classList.add('class1', 'class2', 'class3'); // we can add multiple class names as well
```

To Remove a class:-

```javascript
  element.classList.remove('class1'); // removes the class1 from element

  element.classList.remove('class1', 'class2'); // removes class1 and class2 from the element
```

To Toggle a class:-

```javascript
  element.classList.toggle('class1'); 
  // if the element already has the class class1 it removes it 
  // and if it doesn't it will add the class to the classList
```

To check if an element has a class or not:-

```Javascript 
  element.classList.contains('class1'); // true if it has class class1
```

### Adding styles to an element

There are multiple ways to add styles to an element but my favorite one is this one liner:- `Object.assign(element.style, { /* ... */ });`

**Example:-**

```javascript
  Object.assign(element.style, {

    color: 'red',

    background: 'blue',

    // you can add as many as you want

  });
``` 

I hope the above examples will be useful for someone who is new to JavaScript.

This is my first post on the dev.to network so please pardon me if I have made any mistake and don't hesitate to post any suggestions in the comment section.

Jai Hind!
Automate your workflow using NodeJS CLI programs
Tags: javascript, node, npm
Published: 2020-06-13 07:12:08

Automating your workflow shifts the focus from doing the unnecessary and repetitive task to a more important thing and prevents us from procrastinating. As a JS developer, I always want something that prevents fiddling for things around BASH while writing my workflows and gives me confidence and control over the task in hand.

## Steps for Writing a simple CLI program
In this, I will take one trivial task of opening the projects or run specific commands like running tests over them.

**1) Always begin your scripts with**
![Start of Script](https://dev-to-uploads.s3.amazonaws.com/i/2abswo845okvw06oov1i.png)
This is to specify that it is a node script and to be treated as CLI program.

**2) Helpers for making it more easy and fun**
This list includes 
![helper programs](https://dev-to-uploads.s3.amazonaws.com/i/1njgjcjkcr6gdolova6q.png)

**3) Breakdown your requirements in form of JSON object** 
Writing your requirements in JSON makes it easy to extend and review changes later on.
 ![Config](https://dev-to-uploads.s3.amazonaws.com/i/s879geb72264teuwzzjn.png)

**4) Writing the workflow**
Don't over complicate things and just write simple reusable functions that can be used across all your CLI tools.
 
![main flow](https://dev-to-uploads.s3.amazonaws.com/i/jydua92mk7y90tbah474.png)

**5) Making it installable and accessible from anywhere.**
Make an entry in package.json of your project specifying the initial point of the script.
 
![trick](https://dev-to-uploads.s3.amazonaws.com/i/0f7sl2ejjtzzyrjpnlj6.png)
and then running `npm link` in the directory will install it like any other CLI program in `/usr/bin`.
This little trick makes it accessible when used from anywhere like in the above example `workflow` can be invoked from CLI globally.

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

You can find the complete code for this tool at my github repo.
{% github https://github.com/curiouskaran/projectOpener %} 

Thanks for reading! Please let me know in the comments for any thoughts and improvements.
[Interview] Daragh Byrne – Debugging Coding Minds
Tags: video, interview, betterprogrammer
Published: 2020-06-13 06:31:06

{% youtube L27BWy5HPB4 %}

Interview with Daragh Byrne on how to become a better developer and how meditation and mindfulness can help. Interview with Delivery Lead (Tech) and Meditation Teacher at https://codingmindfully.com/.

{% user daraghbyrne %}

---

This is the first video interview with exceptional developers where we speak about programming wisdom and how we can become better in our craftmanship.

[Watch more videos](https://www.youtube.com/watch?v=IogvPeyLWxA&list=PLAqVLnEIlSbtkqdEcSc5YIIQoHJ36WiAe)
Top Best Free Courses to Learn Python in 2020
Tags: python, coursera, freecourse, blinkcourse
Published: 2020-06-13 06:03:42


**Python**  is in fact comparatively very easy to  **learn**  and build rapport with than other languages, but achieving expertise in it not a game.  **Python**  is actually know for being easy to code and fun. I have prepared some steps which you can follow to  **learn Python**  Easily and effectively

## [**1. Programming for Everybody (Getting Started with Python)**](https://www.blinkcourse.com/Programming-for-Everybody-(Getting-Started-with-Python)-p-11446?utm_source=devto)

This course aims to teach everyone the basics of programming computers using Python. The course has no pre-requisites and avoids all but the simplest mathematics. Anyone with moderate computer experience should be able to master the materials in this course.

## [**2. Python Data Structures**](https://www.blinkcourse.com/Python-Data-Structures-p-11441?utm_source=devto)

This course will introduce the core data structures of the Python programming language. We will move past the basics of procedural programming and explore how we can use the Python built-in data structures such as lists, dictionaries, and tuples to perform increasingly complex data analysis.

## [**3. Introduction to Data Science in Python**](https://www.blinkcourse.com/Introduction-to-Data-Science-in-Python-p-5007?utm_source=devto)

This course will introduce the learner to the basics of the python programming environment, including fundamental python programming techniques such as lambdas, reading and manipulating csv files, and the numpy library. The course will introduce data manipulation and cleaning techniques using the popular python pandas data science library and introduce the abstraction of the Series and DataFrame as the central data structures for data analysis, along with tutorials on how to use functions such as groupby, merge, and pivot tables effectively.

## [**4. Web Development**](https://www.blinkcourse.com/Web-Development-p-12270?utm_source=devto)

Starting from the basics of how the web works, this course will walk you through core web development concepts such as how internet and browsers fit together, form validations, databases, APIs, integrating with other websites, scaling issues, and more; all of which form part of the knowledge it takes to build a web application of your own.

## [**5. Full Stack Foundations**](https://www.blinkcourse.com/Full-Stack-Foundations-p-11466?utm_source=devto)

In this course you will learn the fundamentals of back-end web development! You will create your own web application that queries a database for items on restaurant menus and then dynamically generates complete menus in the form of web pages and API endpoints.


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

Source:  [https://www.blinkcourse.com/Python-Courses-s-32](https://www.blinkcourse.com/Python-Courses-s-32?utm_source=devto)

Fact: Website  [BlinkCourse.Com](https://www.blinkcourse.com/?utm_source=devto)  was developed by Python (Fast API) extremely fast (P90 latency < 50 ms). I developed the website for 5 days intensively :D
My project for GSoC 2020: A Parser Generator with Automatic Error Recovery on LPeg(Label)
Tags: gsoc, lua, parser
Published: 2020-06-13 05:33:32

This is my first post on DEV and it is the start of a series of posts about my in development proposed project that got approved for the [Google Summer of Code 2020](https://summerofcode.withgoogle.com/) for the LabLua organization. It consists of a [Parsing Expression Grammar](https://en.wikipedia.org/wiki/Parsing_expression_grammar) Parser generator, based on the Lua library [LPegLabel](https://github.com/sqmedeiros/lpeglabel/).

# Summary
The goal is to build a parser generator on top of the library LPegLabel that will automatically support error recovery and (optionally) white spaces around lexical symbols and terminal symbols. We are going to use a conservative algorithm for error labels insertion, hence avoiding insertion on wrong places and no manual intervention from the programmer is needed. If there is enough time, in the end we will improve the number of insertions using information about unique syntactical non-terminal symbols and unique paths to a lexical symbol. During the coding period, some parsers will be generated with the tool as tests and as examples.

# Source Code
The **source code** can be found [here](https://github.com/gustavoaca1997/Caribay).

# Name
The parser generator is called _Caribay_, the daughter of Zuhé (the Sun) and Chía (the Moon) from a legend of the Mirripuyes (an indigenous group from Mérida, Venezuela). Since _Lua_ means "Moon" in Portuguese, the tool being the daughter of Lua sounded nice to me. Also, the legend involves the origin of five famous peaks from Mérida, so the name is related to "generating" things.
Optimizing your SVG files with GUI tools
Tags: image, svg, svgo
Published: 2020-06-13 05:10:55

---
title: Optimizing your SVG files with GUI tools
published: true
description: 
tags: image, svg, svgo
---

The SVG output from Sketch and other tools may contain data that are not required for display. You can also use git or other tools to do version control on SVGs, but you should remove unnecessary data before you commit them.

There is a Node.js tool called [svgo](https://github.com/svg/svgo), which allows you to use an unnecessary You can apply formatting and minimization processes while removing the data.

## The need to do it with GUI tools

You don't have to use a GUI tool to do it, but it's an option for situations where you want to optimize a single file, or you want to use a text editor instead of a terminal, and you don't need a commit hook in git.

If you have the [Sketch plugin](https://github.com/sketch-hq/svgo-compressor) installed, you can get an optimized export. You can do this, so there are no leaks. Also, it's not limited to SVGs, but if it's an icon, you can adjust the size of the artboard before exporting. Align it, keep the paths outlined, and make sure the artboard name makes sense. It's a good idea to do this. By doing this, the size of the ViewBox will be unified, and unnecessary transform information will be removed from it. A meaningful name should be inserted into the `<title>` element.

## Plugins

For Figma, see [With Figma's new SVG Exports, less = more](https://www.figma.com/blog/with-figmas-new-svg-exports-less-more/), it appears that there are no tools for this.

- [1000ch/vscode-svgo](https://github.com/1000ch/vscode-svgo): Run "Install Extensions" in the command palette (`⌘` + `Shift` + `P`) and search by svgo
- [1000ch/atom-svgo](https://github.com/1000ch/atom-svgo): Run `apm install svgo` or search by svgo in "Install"
- [1000ch/Sublime-svgo](https://github.com/1000ch/Sublime-svgo): Run "Install Extensions" in the command palette (`⌘` + `Shift` + `P`) and search by svgo

VSCode and Atom have Node.js built-in, so all you have to do is install it and you're good to go! Sublime Text does not include Node.js, so you have to install it. The path to Node.js (`node`) must be in the terminal's `PATH`.
What is Ingress Controller in Kubernetes?
Tags: kubernetes, devops, beginners, opensource
Published: 2020-06-13 04:31:03

In [Deploy phpMyAdmin application on kubernetes](https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5) blog I used `NodePort` service type to expose application to external world but disadvantage with that approach is `port` needs to be exposed on each node and there is a dependency on external load balancer for load balancing requests, custom hostname and SSL/TLS encryption support etc. With the help of `Ingress` controllers I can eliminate dependency on external load balancer. In this blog I am using `Nginx Ingress` controller to expose PHPMyAdmin application to external world. Learn more about ingress controller [here](https://kubernetes.io/docs/concepts/services-networking/ingress/) 

## Architecture

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

## Prerequisites:

### Deploy PHPMyAdmin Application
Follow [Deploy phpMyAdmin application on kubernetes](https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5) blog

### Go to session_2 directory
```
cd ../session_3/
```

## Step 1: Enable Nginx ingress controller
```
minikube addons enable ingress
```
```
kubectl get pods --watch -n kube-system
```
Exit once controller pod goes into running state

This step is valid only for `Minikube`. Check steps to enable `Nginx Ingress` controller on `Kubernetes` [here](https://www.nginx.com/products/nginx/kubernetes-ingress-controller/)

## Step 2: Delete PHPMyAdmin NodePort service
```
kubectl delete svc phpmyadmin
```

## Step 3: Deploy PHPMyAdmin ClusterIP service
```
kubectl create -f phpmyadmin-service.yaml
```

## Step 4: Deploy PHPMyAdmin Ingress rule
```
kubectl create -f phpmyadmin-ingress.yaml
```
```
kubectl get ingress --watch
```
Exit once address gets populated

## Step 5: Update hosts file custome hostname
Add below entry in /etc/hosts
```
<INGRESS_ADDRESS> myapp.xyz
```
Get INGRESS_ADDRESS from `kubectl get ingress`

## Demo

{% youtube ZS1TaAmuNl4 %}
Here I come...
Tags: beginners, motivation, writing, firstpost
Published: 2020-06-13 04:12:49

# Hello everyone!

Over the past few months, I've been silently following plenty of communities related to programming, start-ups and indie development and it fascinated me to a great extent. Although, I like to think of myself as a techy guy but lately I feel that I've been missing out on a lot because I can not code.
So, I signed up on Freecodecamp and have begun my journey to be a **frontend developer**. 

My name is Sid and I'm a **designer** who loves **UI/UX** and *branding*. I'm self taught and have been doing this for over 2 years now. 
I feel being able to code is like a superpower which can be harnessed to make great impact on your personal life as well as the lives of other people. Pretty cliché, right?

One of the bigger challenges I face is being consistent and staying accountable to myself. So to solve this, I am going to be documenting my journey because I feel that interaction with others will hopefully keep my progress in check and make sure I do not slip. 

Thanks to @jmfayard for his article about writing your first post. I wouldn't have written this if I had not come across his piece.

I'll try to be active here on dev.to but you can also find me on [twitter](https://www.twitter.com/SidKadyan)
Introduction to Data Science
Tags: datascience, machinelearning, python, beginners
Published: 2020-06-13 03:39:46

Most of the people are under the misconception that data science is all about machine learning algorithms. That is not true. Data Science is a combination of mathematics, computer science and, machine learning. 

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

Data Science is a study of data, where you maintain datsets and derive insights from the dataset. Data Science uses different parts mentioned in the pattern below to solve the problems.

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

Perception - try to identify patterns with the help of the data
Planning - involves two steps:
1. Finding all possible solutions
2. Finding the best possible solution among all solutions

What do you need to know to be a successful data scientist?
1. Programming Knowledge
2. Data modelling and evaluation
3. Data Visualization and reporting
4. Probability and Statistics
5. Machine Learning techniques
6. Relational Database knowledge

Let's get started with some basic terminology used in data science:
1. Observations - data points in your dataset (rows)
2. Features - variables in your dataset (columns)
3. Target Variable - which you are trying to predict
4. Train data - data from which your algorithm learns
5. Test data - data to evaluate your model performance
6. Model - set of patterns learned from the data
7. Algorithm - specific machine learning process used to train your model
MERN - Tour Package Reservation
Tags: react, node, mongodb, atlashackathon
Published: 2020-06-13 03:24:33

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3v2pghxssg75gp930o6u.gif)

###REST API Technology
JSON Based Web Services 
Express 
Mongoose
 
###Front End Technology 
ReactJS 
     Fetch API
     React router dom 
Bootstrap CSS 
HTML
Nodejs
 
###Database 
MongoDB Atlas

Connection url: 
mongodb+srv://root:bunny@cluster0alh36.gcp.mongodb.net/Tourism?retryWrites=true&w=majority 

###Configuration

####step 1
Open terminal in VS Code in Backend Directory 

####step 3
Run `node app` to start backend server.

####step 4
Now open terminal in VS Code in Frontend Directory. 
 
####step 5
Run `npm install` 

####step 6
Run `npm start` to run the app in development mode. 

####step 7
Open http://localhost:3000 to view it in the browser. 

###Main Functionalities
1)The admin can logs into the tour package reservation system using the admin email and password.

2)Admin has the only priority to add, update and delete tour packages.

3)User can view the pages and can book their tour reservation.

###GitHub Repo📌
{% github Sewvandiii/tour-package-reservation %}