teleren/devto huggingface dataset:
Introducing the watercooler tag (light off-topic chitchat)
Tags: watercooler, meta, changelog
Published: 2019-07-12 20:33:48

Hey folks, we're launching a new tag called "watercooler"

{% tag watercooler %}

It's a place for light off-topic chitchat.

For example:

{% link https://dev.to/rpalo/pets-of-dev-3bmj %}

It's not the end of the world if you post stuff that is loosely _on-topic_ in terms of programming, but we'll try to keep this space for posts that are not as much about coding.

We are all developers, professionally or by hobby, but we have lives outside of code. If you're interesting in chatting about anything non-code, stop by the watercooler to chat.

Of course, the [code of conduct](https://dev.to/code-of-conduct) applies the same in the watercooler tag as anywhere else.

_If you **don't** want to see too many posts from the watercooler, the way to currently do that is to first **follow** the tag and then **give it a negative weight** in [/dashboard/following](https://dev.to/dashboard/following)._

_I know that's counter-intuitive but that's currently the best way to do that._


Happy coding!
Javascript Built-in sort() method
Published: 2019-07-12 20:33:17

---
title: Javascript Built-in sort() method
published: true
description: 
tags: 
---
## How does JS built-in sort() method work?

the sort() method will sort arrays in place and return a sorted array. The default sort order is built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values. 

The sort() method accepts a compareFunction(a,b) as argument. In order to sort things propertly, we need to define what the compareFunction does.

### Examples 
```
var months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]

var array1 = [1, 30, 4, 21, 100000];
array1.sort();
console.log(array1);
// expected output: Array [1, 100000, 21, 30, 4]

//the results are not sorted correctly.
```
The default sort() compares elements as strings, so 21 is greater than 10000 because 2 is > 1 for example. In order to fix this we can use the compareFunction.

### The compareFunction

These are the rules I found from Mozilla's documentation:

1. If compareFunction(a, b) is less than 0, sort a to an index lower than b (i.e. a comes first).

2. If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behavior, thus, not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.

3. If compareFunction(a, b) is greater than 0, sort b to an index lower than a (i.e. b comes first).

4. compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned, then the sort order is undefined.

```
var numbers = [4, 2, 5, 1, 3];
numbers.sort(function(a, b) {
   return a - b;
 });
 console.log(numbers);

// [1, 2, 3, 4, 5]


//to sort by the length of strings

function lengthCompare(a,b){
    return a.length - b.length 
}

console.log(["grapefruitPlusKiwi", "apple", "pie", "orange", "pineapple", "banananananana"].sort(lengthCompare))

//["pie", "apple", "orange", "pineapple", "banananananana", "grapefruitPlusKiwi"]
```




[source from mozilla](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
My recall of Big O and how understanding it will make all development easier.
Tags: computerscience, career, beginners
Published: 2019-07-12 20:22:36

Since my last post I've been working on and off getting back into the flow of code.

Recently I dived back into Data Structures and Algorithms in Javascript Masterclass by Colt Steele. So far the concepts are starting to make sense but to really reinfore the ideas recall is needed so here it goes


In computer science, Big O is a measurment used to describe the efficiency of algorithms. There are best, worse and average cases that can come about depending on the data structures, algorithms and languages used.

Common runtimes include O(N), O(log N), O(N log N), O(N^2) and O(2^N).

Runtimes are determined by the amount of operations and memory(O(1) a constant as an example) used in programming.

Ideally taking runtimes into account could help when deploying a program. In thes case of javascript in browsers, depending on the browsers themeselves, different runtimes might occur.

With regard to memory(O(1)), also know as space complexity, can affect big O since the computer has to reserve memeory to use for operations.

Best and worst case scenarios are determined by what the algorithm is trying to do. For example of going through an array of near sorted items for bubble sort would be O(N) however in most cases the items will have to be sorted first, thus we'd be left with O(N^2) since it has to recursively go through and check each element that isn't sorted.


Anyway this was my first foray into inderstanding big O theory and constructive criticism and guidance os greatly appreciated. 

If there is anything that I'm missing or could elaborate on, please let me know.

Thanks again,
Jonathan Thomas, future Software Engineer
Get more collection in mongodb output page home ? 
Tags: node
Published: 2019-07-12 20:19:11

function index(req , res , next){

db.collection("product").find({}).toArray(function(err , product){

db.collection("banner").find({}).toArray(function(err , banner){

db.collection("newest").find({}).toArray(function(err , newest){

      return res.render("/index" , {product : product ,banner : banner , newest : newest}); 
    })
  })
})   
}

Please help me?
Functions in Kotlin
Tags: kotlin, todayilearned, beginners, codenewbie
Published: 2019-07-12 20:12:31

>***A function is a group of statements that perform a specific task.***

* Functions are mostly used to automate the repeated task. They are basically used to divide the large program into smaller chunks.

* Divide our program into smaller chunks makes it more organized and manageable. Also, it avoids repetition and makes our code reusable.

* The bad thing about function is they are famous with several names. Different programming languages name them differently. For example functions, methods, subroutines, procedures, etc. When you hear any one of them just imagine about the same concept.

There are basically two types of functions in programming.
1. Built-in functions
2. User-defined functions

* **Built-in functions —** Built-in functions are functions that is comes with language and they are ready to use. For example in kotlin `print()`, `readLine()`, `sqrt()` are built-in functions. In kotlin, there is a [kotlin standard library](https://kotlinlang.org/api/latest/jvm/stdlib/index.html), in which all built-in functions are stored. You can check it for more information.

* **User-defined functions —** User-defined functions are functions that are created by programmers according to their needs. You can also create functions according to your needs and that functions will be called user-defined functions.
* for more details about user define a function in Kotlin, please visit this.

That’s it for functions guys. Feel free to share with me if I miss something I will love to learn it from you. Please visit my next article for little bit details about the user-defined the function.

Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said **Learning is Journey and Journey never ends.** Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitate that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember **Every Master was once a Beginner.** Work hard and Give your best.

Till Then Keep Loving, Keep Coding. And just like always I’ll surely catch you up in the next article.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

- [My Site] (https://www.jaytillu.in)
- [My Blogs] (https://blogs.jaytillu.in)
- [Twitter](https://twitter.com/jay_tillu)
- [Facebook](https://www.facebook.com/jaytillu.1314/)
- [Instagram](https://www.facebook.com/jaytillu.1314/)
- [Medium](https://medium.com/jay-tillu)
- [LinkedIn](https://www.linkedin.com/in/jaytillu/)
- [Github](https://www.github.com/jay-tillu)
- [Stack overflow](https://stackoverflow.com/users/8509590/jay-tillu)
or just mail me at jd.tillu@gmail.com
Char and Boolean in Kotlin
Tags: kotlin, beginners, codenewbie, todayilearned
Published: 2019-07-12 19:43:31

##Char type
---
* Characters are represented by the ***Char*** keyword.
* They cannot be treated directly as numbers but you can perform explicit conversion functions according to your needs. Let’s understand this by example.
```
char a = 65  // Compile time error.
This code works fine in Java but will throw an error in kotlin.
```
* Character literals go in single quotes like *‘V’*, *‘J’*, etc.

* In kotlin, strings are represented by the *String* class. String literals go inside the double quotes like *“Viveki”*, *“Jay”*, etc.

* Special characters can be escaped using a backslash.

***The following escape sequences are supported:***

* \t — To print tab
* \b — To use a backslash
* \n — newline character
* \r — carriage return
* \’ — To print single quote
* \” — To print a double quote
* \\ — To print a backslash
* \$ — To print the dollar sign
* To encode any other character like hexadecimal or binary use Unicode escape sequence syntax: *‘\uFF004’*.

##Boolean Type
---
* Boolean values are represented by Boolean keyword.
* Boolean has two values either true or false. Both must be in lower case and cannot represent as 0 and 1.

So, guys, that’s it for char and boolean in kotlin. Feel free to let me know if I missed something.

Till then Keep Coding, Keep Loving. Catch you up in another article.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

- [My Site] (https://www.jaytillu.in)
- [My Blogs] (https://blogs.jaytillu.in)
- [Twitter](https://twitter.com/jay_tillu)
- [Facebook](https://www.facebook.com/jaytillu.1314/)
- [Instagram](https://www.facebook.com/jaytillu.1314/)
- [Medium](https://medium.com/jay-tillu)
- [LinkedIn](https://www.linkedin.com/in/jaytillu/)
- [Github](https://www.github.com/jay-tillu)
- [Stack overflow](https://stackoverflow.com/users/8509590/jay-tillu)
or just mail me at jd.tillu@gmail.com
Data Types in Kotlin
Tags: kotlin, todayilearned, beginners, codenewbie
Published: 2019-07-12 19:36:28

* Data type means a type of data that can be used and manipulate in the programming language.

* Kotlin is a statically typed language like Java. That means the type of variable is known during the compile time.

* Just remember that in kotlin everything is an object in the sense that we can call member functions and properties on any variable.

For example, consider the following:
```
highScore.toInt()
a + b — a.plus(b)
```

* Here `highScore` is a variable on which we are calling `toInt()` conversion function. And `a` and `b` are also variables on which `a.plus(b)` internally calls. So that is how they called everything is an object.

There are basically three types of data type in kotlin:
1. Number
2. Character
3. Boolean

* Data types are one of the foundational topics of any programming language. That’s why I’ll post three posts on each data types. So that they all cannot be mixed up with each other and will become easy to understand for you guys. Please check out for them as well. These posts also come up with the same wallpaper, so that it becomes easy for you to find them.

Till then Keep Coding, Keep Loving.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

- [My Site] (https://www.jaytillu.in)
- [My Blogs] (https://blogs.jaytillu.in)
- [Twitter](https://twitter.com/jay_tillu)
- [Facebook](https://www.facebook.com/jaytillu.1314/)
- [Instagram](https://www.facebook.com/jaytillu.1314/)
- [Medium](https://medium.com/jay-tillu)
- [LinkedIn](https://www.linkedin.com/in/jaytillu/)
- [Github](https://www.github.com/jay-tillu)
- [Stack overflow](https://stackoverflow.com/users/8509590/jay-tillu)
or just mail me at jd.tillu@gmail.com
Does anybody have an Example how can I with Mongoose, Express.js and Passport.js implement a password change endpoint?
Tags: javascript, nodejspassportjs, expressjs
Published: 2019-07-12 19:22:12

---
title: Does anybody have an Example how can I with Mongoose, Express.js and Passport.js implement a password change endpoint?
published: true
description: Does anybody have an Example how can I with Mongoose, Express.js and Passport.js implement a password change endpoint?
tags: javascript, node.js passport.js, express.js
---

The user should be able to change the password but how can I do that in NodeJS with Mongoose, Express.js and Passport.js (local-strategy)? I hope I get help here. An example/solution were great.
How is the tech industry contributing to global warming and what can we do to reduce the impact?
Tags: discuss, healthydebate, motivation
Published: 2019-07-12 19:19:01

As members of the tech industry we should be aware of how we are contributing to global warming. More then that we should talk about what we can do to reduce the impact.

For example the boom of cryptocurrency has been contributing to global warming by increased use of electricity to mine and probably wasn't the best contribution of the tech world. What are other issues that we have created or contribute to? Of course, then there is also node_modules.

Let us discuss to increase awareness
Connecting to public Wi-Fi without frustration
Tags: network, beginners, productivity, tip
Published: 2019-07-12 19:11:53

&nbsp;

You have finally arrived at your awaited destination. A cafe buzzing with lofi music, or a comfy lounge at a hotel where you lodge - wherever you are trying to access the public Wi-Fi(wifi for short) hotspots. You crack open your laptop or phone to get hooked up with the internet. you find the name of the wifi your place provides then hit connect. A few seconds later, you can see the wifi icon is filled with lines of bars. Success!😎 You then navigate to your favorite site, wait a bit, but then... nothing! You end up with an error page.

![](https://thepracticaldev.s3.amazonaws.com/i/po2b4vyk4u5erg5hsi8b.PNG)
*Default no connection error page on Chrome*

Too often, I have seen my friends and families struggle to get connected with public wifi which should be intuitive and direct. Let's get a high overview of what's happening behind the scene.

## But I am connected, what's the problem? 😔

First of all, What you are expected to see is a captive portal page. This is where you are redirected to a different URL provided by the host of your wifi so that you can read terms of use and accept its conditions which then grants you permission to freely use their network. However, most of the popular websites these days use HTTPS as a security protocol, which helps securely protect the interaction of data between you and the website. Therefore, when you try to visit a secure site, modern browsers become suspicious of this redirect activity before it securely connects with the server of the destination website. It then simply yields a no connection page as a result.


## The fix

Visit a site that doesn't use a secure protocol! A site that doesn't use encryption, authentication and is just plain good old website that uses HTTP. It is difficult to find one like that in 2019 but for this purpose, there is a website you can navigate to.

**neverssl.com**

Type this link in the URL of your browser then you will be directed to a captive portal page! 😁

&nbsp;
Type Inference in Kotlin. How things exactly work behind the scenes.
Tags: kotlin, todayilearned, beginners, codenewbie
Published: 2019-07-12 18:32:30

>***Type —*** Data Type
***Inference —*** To automatically identify something.

* kotlin is a strongly typed language that supports *Type Inference*.

* Kotlin compiler can automatically identify the data type of the variable. The compiler knows this by the initializer.

* So if you initialize the value on the declaration, you don’t need to define data type explicitly.

* Because every primitive type has a default value. The compiler will directly assume the size and type to a variable by that.

* For example, if you assign any whole number to a variable, the compiler will directly assume that the variable is of type *Int*.

* But remember if you want to initialize the value to the variable later, then, in that case, you have to define the data type explicitly. In that case, the concept of type inference won’t work.

So, guys, that’s it for type inference. This is how all the magic works behind the scenes. Feel free to ask any questions.

Till then Keep Coding, Keep Loving.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

- [My Site] (https://www.jaytillu.in)
- [My Blogs] (https://blogs.jaytillu.in)
- [Twitter](https://twitter.com/jay_tillu)
- [Facebook](https://www.facebook.com/jaytillu.1314/)
- [Instagram](https://www.facebook.com/jaytillu.1314/)
- [Medium](https://medium.com/jay-tillu)
- [LinkedIn](https://www.linkedin.com/in/jaytillu/)
- [Github](https://www.github.com/jay-tillu)
- [Stack overflow](https://stackoverflow.com/users/8509590/jay-tillu)
or just mail me at jd.tillu@gmail.com
Keywords in Kotlin
Tags: kotlin, todayilearned, beginners, codenewbie
Published: 2019-07-12 18:17:00

* Keywords are predefined, reserved words that have special meaning in the language.

* Generally, it is recommended to do not use it as identifiers.

* But in kotlin, there are some keywords which can be used as identifiers in some situations.

* There are basically four types of keywords in kotlin:
1. Hard keywords
2. Soft keywords
3. Modifier keyword
4. Special identifiers

##Hard Keywords
---
* There are 24 hard keywords in kotlin which cannot be used as identifiers in any situation.

* Below is the list of hard keywords.

![](https://miro.medium.com/max/632/1*ixXhGYb4KcekObsQRtSPfg.png)

##Soft Keywords
---
* There are 17 soft keywords in kotlin.

* These tokens act as a keyword in a certain context, but you can use them as identifiers in another context.

* Below is a list of soft keywords.

![](https://miro.medium.com/max/647/1*gWdrR6jZ47GE1V6IbR88tg.png)

##Modifier Keywords
---
* There are 29 modifier keywords in kotlin.

* These tokens act as keywords in modifier lists of declaration and can be used as identifiers in another context.
* Below is a list of modifier keywords.

![](https://miro.medium.com/max/700/1*_Gsj2PMsHGOcTp6vaT8lHA.png)

##Special Identifier
---
* Following two special identifiers are defined by the compiler in a specific context and can be used as regular identifiers in another context.
* Below is a list of those two identifiers.


![](https://miro.medium.com/max/515/1*d9jJ_6NQ6M_6UwhT2PTFFA.png)

Please, Guys, avoid them to use as identifiers. It's my best suggestion to you in just one word. Avoid Keywords as Identifiers.

So, guys, that’s it for keywords. Feel free to ask for any queries.

Till then Keep Coding, Keep Loving.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

- [My Site] (https://www.jaytillu.in)
- [My Blogs] (https://blogs.jaytillu.in)
- [Twitter](https://twitter.com/jay_tillu)
- [Facebook](https://www.facebook.com/jaytillu.1314/)
- [Instagram](https://www.facebook.com/jaytillu.1314/)
- [Medium](https://medium.com/jay-tillu)
- [LinkedIn](https://www.linkedin.com/in/jaytillu/)
- [Github](https://www.github.com/jay-tillu)
- [Stack overflow](https://stackoverflow.com/users/8509590/jay-tillu)
or just mail me at jd.tillu@gmail.com
How to learn object oriented programming
Tags: help, oop
Published: 2019-07-12 18:09:30

I am studying at Faculty of Electrical Engineering and Computing, and I have a subject OOP (object oriented programming) in Java.

That is the only subject that i did not manage to pass continuously. We have presentations and lectures, but they are (in my opinion) not so good.

My question is: How did you learn object oriented programming, what book/online course/YouTube channel did you use to learn the paradigm?

Thank you!
How to learn object oriented progarmming
Published: 2019-07-12 18:08:10

I am studying at Faculty of Electrical Engineering and Computing, and I have a subject OOP (object oriented programming) in Java.

That is the only subject that i did not manage to pass continuously. We have presentations and lectures, but they are (in my opinion) not so good.

My question is: How did you learn object oriented programming, what book/online course/YouTube channel did you use to learn the paradigm?

Thank you!
🤓 The Nerd Talk: Superhero’s Privacy
Tags: discuss, nerds
Published: 2019-07-12 17:57:39

---
title: 🤓 The Nerd Talk: Superhero’s Privacy
published: true
description: 
tags: discuss, nerds 
---
Well hello nerds, 

I have a very serious question or may be a weird one. Let’s say if the big tech giants co-existed  with Superheroes. Will they be able to crack their secret Identity. 

Which superhero will most vulnerable and which one will be most secure. 
![](https://media2.giphy.com/media/bZJif3rycbm12/giphy.gif?cid=19f5b51a5d28c7b956523174365a2b90&rid=giphy.gif)