teleren/devto huggingface dataset:
Node.js Crash Course - Part 9 - MongoDB
Tags: node
Published: 2020-11-04 10:27:01

1. Open account on mongodb atlas
2. Create cluster
3. Create collection
4. Set up connection
5. Set up and get dbURI

####Setting up connection in app.js
```
const dbURI = 'mongodb+srv://yourusername:yourpassword@nodetuts.3g4hc.mongodb.net/yourdatabasename?retryWrites=true&w=majority';
mongoose.connect(dbURI)
  .then(result=> app.listen(3000))
  .catch(err=> console.log('some error occurred'))
```
`.then(result=>app.listen(3000))` means after the database connection is made then app will start listening to the requests.

####Setting up model
Create a file called 'blog.js' inside a folder '/models'.
Then in blog.js:
```
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const blogSchema = new Schema({
    title:{
        type: String,
        required: true
    },
    snippet: {
        type: String,
        required: true
    },
    body:{
        type: String,
        required: true
    }
}, { timestamps: true });

const Blog = mongoose.model('Blog', blogSchema);
module.exports = Blog;
```

We will create a model and the model will be built on a schema. 
Creating a schema: `const Schema = mongoose.Schema`
and `const blogSchema = new Schema({})`

`const Blog = mongoose.model('Blog', blogSchema);` The second 'Blog' name is important. Mongoose will pluralize this and search a model of that name, i.e. 'Blogs' in server.

####Getting and Saving Data
We can insert by the following way using `.save()` method.
```
app.get('/add-blog', (req, res) => {
    const blog = Blog({
        title: 'Blog Post 1',
        snippet: 'you can also drag a cover image',
        body: 'MongoDB provides high availability with replica sets'
    });

    blog.save()
        .then( result => res.send(result))
        .catch(err => console.log(err));
})
```
We can retrive all the data by following way using `.find()` method
```
Blog.find()
        .then( results => res.send(results))
        .catch( err => console.log(err))
```
We can retrieve single data by the following way using `.fingById()` method:
```
app.get('/single-blog', (req, res) => {
    Blog.findById('5fa27e3d1ca6c8027cc7497b')
        .then( result => res.send(result))
        .catch( err => console.log(err))
})
```

Also we can sort the data:
```
Blog.find().sort({ createdAt: -1 })
    .then( results => res.send(results) )
    .catch( err => console.log(err) )
```
`-1` means descending order.
What newsletters are you subscribed to?
Tags: watercooler, newsletter, reading
Published: 2020-11-04 11:15:14

---
title: What newsletters are you subscribed to?
published: true
description: 
tags: watercooler, newsletter, reading
cover_image: https://helpendabuseforlife.org/wp-content/uploads/2020/06/Newsletter_templates-min.png
---
Ironically, we subscribe to most newsletters unconsciously, while registering for some service and forgetting to uncheck the subscription. 

I wonder if you know some newsletters you are subscribed to purposely and the quality is actually worth the read time? 

To start off, some I am aware of include [UX Design Weekly](https://uxdesignweekly.com), [Frontend Focus](https://frontendfoc.us/), [JavaScript Weekly](https://javascriptweekly.com/), [Smashing Newsletter](https://www.smashingmagazine.com/the-smashing-newsletter/), [Responsive Design Weekly](https://responsivedesign.is/newsletter/).
Voice Enable Pacman App with JavaScript using Alan AI (video)
Tags: tutorial, javascript, gamedev
Published: 2020-11-04 11:13:57

Hello Everyone! In this video, I voice enable the PacMan App using Alan AI (http://voice.alan.app/AniaKubowJavaScriptGames)

This is a great tutorial for those of you wishing to learn about how to invoke functions with voice commands using Alan AI

What you’ll learn:
- Implementing Voice Commands into JavaScript Projects
- Setting up SDK Keys
- Understanding Scripts

Are there any course requirements or prerequisites?
- Basic understanding of JavaScript, HTML and CSS is required.
- Understanding of SDK/API Keys.

IMPORTANT: When working with Alan AI's SDK Keys, please hide your Key and do not publish onto GitHub or share on the internet. This project is for your own local use only and not to be published onto your GitHub with your Key visible to others. This is advise for your own benefit. You can hide your Key by converting this project to use packages such as .dotenv. For those of you interested, I will be releasing a video on how to do this soon.

Useful links:
Alan AI : http://voice.alan.app/AniaKubowJavaScriptGames
Start code: https://github.com/kubowania/pacman-with-voice-AI
Final code: https://github.com/kubowania/pacman-with-voice-AI-final
Deployed code with Alan Key kept safe: https://github.com/kubowania/pacman-AI-live

Play Pacman AI Live here: https://kubowania.github.io/pacman-AI-live/

If you did like this video, please hit the Like and Subscribe button so I know to make more!

For some free interactions please use Alan Studio Promo Code: ANIAKUBOW

Twitter: https://twitter.com/ania_kubow
YouTube: https://youtube.com/aniakubow
Instagram: https://instagram.com/aniakubow

#AlanAI #PacmanAI #VoiceGaming

{% youtube kBVaH3D92H8 %}
Immutable class in Java
Tags: java, immutable
Published: 2020-11-04 11:05:06

In this article, we'll define the typical steps for creating an immutable class in Java and also shed light on the common mistakes which are made by developers while creating immutable classes.

visit the original article: https://www.java8net.com/2020/11/immutable-class-in-java.html


**Steps to create Immutable class in java**

1. Make your class final, so that no other classes can extend it.
2. Make all fields private so that direct access is not allowed.
3. Don’t provide “setter” methods — methods that modify fields or objects referred to by fields.
4. Special attention when having mutable instance variables
4.1) Inside the constructor, make sure to use a clone copy of the passed argument and never set your mutable field to the real instance passed through the constructor.
4.2) Make sure to always return a clone copy of the field and never return the real object instance.


**Implementation of Immutable class in java**
```
class Address{
	private String houseNumber;
	private String street;
	private String city;
}

final class User {
	private final int id;
	private final String name;
	private final String email;
	private final Address address;
    
	/*
	 * To clone the address.
	 */
	private static Address cloneAddress(Address address) {
		return new ObjectMapper().convertValue(address, Address.class);
	}

	User(int id, String name, String email, Address address) {
		this.id = id;
		this.name = name;
		this.email = email;
		/*
		 * Any field contains reference of any mutable 
                 * object must be
		 * initialized with the cloned object
		 */
		this.address = cloneAddress(address);
	}
	public int getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public String getEmail() {
		return email;
	}
	public Address getAddress() {
		/*
		 * Getter method must return the reference of cloned object.
		 */
		return cloneAddress(address);
	}
}
```


**Pre-defined Immutable class in java**

1. The string class represents the immutable object for the sequence of characters.
2. Wrapper classes like Integer, Float, Long, etc. all represent the immutable object for the corresponding primitive type.
3. `java.util.UUID` represents a unique 128-bit hexadecimal string.


**Benefits of making an Immutable class in java**

1. Immutable objects are by default thread-safe. 
2. Immutable objects can easily be cached.
3. Immutable objects are the best options to use as a key object in any map like HashMap.

visit the original article: https://www.java8net.com/2020/11/immutable-class-in-java.html
Have you built any projects with Svelte?
Tags: webdev, discuss, svelte
Published: 2020-11-04 10:46:41

---
title: Have you built any projects with Svelte?
published: true
description: 
tags: webdev, discuss, svelte
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--be3eR7Dm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nunomalex.me/svelte-logo.png
---
Svelte has been around for quite a while now. It's pretty lightweight, fast, concise, and is essentially a compiler, which means there is no virtual DOM and all the other unnecessary stuff.

As far as I have played around in the sandbox mode, it felt like it would be an awesome tool for smaller apps to get you up and running quickly.

The syntax reminded me of a bit of Vue and the HTML, CSS, and Javascript approach in `.svelte` files reminded me of the good old classic design we used decades ago, while still using components. 

Have you built any projects with Svelte and did you like it?
2020-11-03 | Existing Knowledge, Meta Skills, Student Progress
Tags: learninpublic, beginners, webdev, career
Published: 2020-11-04 10:19:37

---
title: "2020-11-03 | Existing Knowledge, Meta Skills, Student Progress"
description: "Summary of my day"
published: true
description: "Summary of my day"
tags: ["LearnInPublic", "Beginners", "Webdev", "Career"]
series: "miku86 Diary"
canonical_url: "https://miku86.com/blog/day-2020-11-03"
---

Busy, monotonous day. I worked on my JavaScript course. I try to explain the concepts with a lot of everyday concepts. I think this is one of the best approaches to learning: learning the fundamental concepts by connecting new information with existing personal knowledge. Every person has existing knowledge so I want to use it.

This is also about meta skills, e.g. focusing, reading, logical thinking etc. When working with beginners, like 95% of the problems come from:

- focusing: students don't work focused, so they make typos
- reading: students don't read error messages or documentations
- logical thinking: students throw syntax they already know at the problem, watching what sticks - instead of thinking in [pseudo code](https://en.wikipedia.org/wiki/Pseudocode)

---

In the evening I hosted a workshop on JavaScript. We created a small shopping list from scratch. I did this with exactly the same students some months ago, this time we just needed 1h instead of ~10h. Seems they are making some progress.
Week 4 Day 1: Front End, Old Friend
Tags: beginners, html, css, webdev
Published: 2020-11-04 10:12:05

I'm back to HTML and CSS after a month or so of not touching it. Having picked it up and put it down a few times in the last couple of years I felt comfortable with the syntax. Easy to learn and hard to master. Certainly the case with **position: fixed/absolute**. I'm sure that every time I figure out whether the parent or child is relative, W3C has an emergency meeting and switches it up just to spite me. Maybe I just haven't grokked yet. 
We made personal landing pages today. Very dry stuff: "Hi I'm Will. Likes and interests: dog walking, programming, photography". A bit of a snooze-fest for the first day of the "creative" part of the bootcamp. I jazzed mine up a little to keep myself interested. The page content is absurdist nonsense but the links to my blog and github are live and legit. It's only half finished, barely responsive and various viewports do wacky things to the layout. I was mainly interested in contrasts of color and lack thereof as well as which elements worked well in a fixed position.
As you can see in the link below, my background image remains fixed whilst the splash of pink paint scrolls with the view (you may have to resize the browser to see this). The page is by no means finished, some parts are broken and I can't think of an elegent presentation for the **h1** title yet. I'm going to work on it during the week and post again for a during and after comparison. Watch this space.
(https://willhmartin.github.io/profile/)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cs5ysi2cfsx4h6slcwvk.JPG)

A lot of the afternoon was spent on a particular problem: my splashes of paint had background colors. My search query was "paint splash transparent background", however everything I downloaded looked like this: 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/260b2a1ow2luiau786mj.png)
which translated to this:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6rgottmik3wvl9lrhonv.JPG)

It seems that most sites are wise to the value of a transparent background and only give out samples, a little DRM'd freebie to get you hooked. Then I found a neat little trick with the Google Image criteria:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gudjcdrui22yjggrbk7z.JPG)
selecting "transparent" in tools under the color options returns only photos available and transparent! Knowing this would have saved me a lot of time trying to solve this issue in both CSS and MS:Paint, so let's hope it helps someone else (who against all odds knows less than me).
The design is fun, I don't think of myself as visually artistic but I like experimenting disparate elements together. Check back to see if I make any progress.
CSS Là Gì- Vai Trò & Ưu Điểm Của CSS Trên Website
Published: 2020-11-04 09:54:05

Để những trang web, những email của bạn chuyên nghiệp hơn, hãy cùng tìm hiểu CSS là gì hay ngôn ngữ CSS là gì qua bài viết sau của ITNavi nhé.Xem chi tiết tại: https://blog.itnavi.com.vn/css-la-gi/
Backend Là Gì- Điều Kiện Cần & Đủ Để Làm Backend Developer
Published: 2020-11-04 09:30:48

Backend là gì chắc hẳn là câu hỏi khiến không ít bạn trẻ đi theo chuyên ngành công nghệ thông tin còn băn khoăn trong việc tìm lời giải. Xem chi tiết tại: https://blog.itnavi.com.vn/nhung-ky-nang-quan-trong-de-tro-thanh-mot-backend-developer/
The one source that replaces them all
Tags: productivity
Published: 2020-11-04 09:27:37

I use daily.dev at least twice a day and Now it's time to repay them by letting the ones that didn't get the amazing opportunity to know it, so here you got it, do your self a favor and download their extension and then refer your friends

https://api.daily.dev/get?r=youssefrabeiii
Tester Là Gì- Vai Trò & Nhiệm Vụ Của Tester Trong 1 Dự Án 
Published: 2020-11-04 09:14:57

Tester là gì, công việc chính của họ bao gồm những gì? Các kỹ năng mà một tester chuyên nghiệp cần phải có? Cùng tìm hiểu với ITNavi nhé! Xem chi tiết tại: https://blog.itnavi.com.vn/tester-la-gi/
what is html
Tags: html
Published: 2020-11-04 09:10:47

https://htmldecode.blogspot.com/2020/10/what-is-html.html

HTML is a computer language devised to allow website creation. These websites can then be viewed by anyone else connected to the Internet. It is relatively easy to learn, with the basics being accessible to most people in one sitting; and quite powerful in what it allows you to create. It is constantly undergoing revision and evolution to meet the demands and requirements of the growing Internet audience under the direction of the » W3C, the organisation charged with designing and maintaining the language.
4 Handy Features of a Browser Console
Tags: javascript, webdev, development
Published: 2020-11-03 23:41:24

Although `console.log()` is by far the most used console function in the development tools of all modern web browsers. There is more to it.

###Console Output
The browser console has four different output functions. You can use different functions to distinguish the type of generated output.

- `console.log(‘simple log message’)`
- `console.info(‘info: important information’)`
- `console.warn(‘warning: something might go wrong’)`
- `console.error(‘error: something went wrong’)`

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

###Console Style
A lot of messages in the browser console can be overwhelming sometimes and you might lose track of the message you are looking for. Console styles help you style your output messages so you can distinguish them easily.

You can use the %c directive to apply CSS styles.

`console.log("Styles help you distinguish %c between different texts", "color: orange; background-color:green;")`;

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

###Console Grouping
Console groups are a good way to group identical console messages together. It increases the console messages' readability. You can group different types of console messages together.

`console.log("outside group")`;
`console.group("Group starts")`;
`console.log("first group message")`;
`console.log("second group message")`;
`console.warn("group warning")`;
`console.error("group error")`;
`console.groupEnd()`;
`console.log("outside group again")`;

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

###Console Timers
Console timers are helpful when debugging your code and you want to check how long does your code takes to run.

`console.time("timer”)`;
`console.timeLog("timer”)`;
`// Do your stuff here.`
`console.timeEnd("timer”)`;
Excel Formulas to Count the Values that appear in a List!!
Tags: excelformula, excelformulas
Published: 2020-11-04 11:37:49

---
title: Excel Formulas to Count the Values that appear in a List!!
published: true
date: 2020-11-04 09:02:25 UTC
tags: ExcelFormula,Excelformulas
canonical_url: https://geekexcel.com/excel-formulas-to-count-the-values-that-appear-in-a-list/
---

In this article, we will guide you to learn the **Formulas to count the values that appear in a List or Table in Excel Office 365**. Let’s get started!! Get an official version of ** MS Excel**  from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

[![Formulas to count values that appear in a list](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/11/Formulas-to-count-values-that-appear-in-a-list.png)](https://geekexcel.com/excel-formulas-to-count-the-values-that-appear-in-a-list/formulas-to-count-values-that-appear-in-a-list/#main)<figcaption id="caption-attachment-16882">Formulas to count values that appear in a list</figcaption>
## General Formula:

- To count the values that appear in a list or table in Excel, use the below formula.

**=COUNTIFS(A:A,A1,B:B,B1)**

## Syntax Explanations:

- **COUNTIFS** – The Excel COUNTIFS Function will help to count the number of cells that match multiple criteria or conditions.
- **Range (A: A, B: B)** – It represents the input ranges given in a worksheet.
- **Criteria (A1, B1)-** It is the condition which helps to count the cells.
- **Comma symbol (,)** – It is a separator which helps to separate a list of values.
- **Parenthesis ()** – The main purpose of this symbol is to group the elements.

## Example:

-  In the below image, we will give the input ranges in **Column C** and **Column D**.
- Then, enter the given formula in the selected field.
- Finally, we get the output in **Cell F5** as shown below.

![Example](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/11/Example-17.png)<figcaption id="caption-attachment-16881">Example</figcaption>

## Wind-Up:

Here, you can learn the **Formulas used for counting the values that appear in a List or Table in Excel Office 365** with brief explanations. Hope that this article is useful to you. Don’t forget to share your worthwhile **feedback.** Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

### Read Ahead:

- **[Excel Formulas to Count Cells Equal to Case Sensitive Values!!](https://geekexcel.com/excel-formulas-to-count-cells-equal-to-case-sensitive-values/)**
- [**Formulas for Counting the Cells that are Blank in Excel Office 365!!**](https://geekexcel.com/formulas-for-counting-the-cells-that-are-blank-in-excel/)
Hệ Điều Hành IOS Là Gì- Cách Cài Đặt Hệ Điều Hành IOS
Published: 2020-11-04 09:02:22

Hệ điều hành iOS là gì - Đây là hệ điều hành được Apple phát triển và cài đặt trên các sản phầm iphone, Ipad với nhiều tính năng mới lạ và thú vị.. Xem chi tiết tại: https://blog.itnavi.com.vn/he-dieu-hanh-ios-dieu-cot-loi-trong-su-thanh-cong-vang-doi-cua-apple/
NEW VIDEO: Landing your dream job with Emma Bostian
Tags: career, programming, watercooler
Published: 2020-11-04 09:02:14

Have you seen **[our latest mini-doc]((https://cult.honeypot.io/originals/dream-developer-job-with-emma-bostian))** with Emma Bostian yet? 

In this Honeypot mini-doc, we follow Emma Bostian as she relocates to Stockholm to start her dream job at Spotify. 

She talks about her journey from the early days as an uncertain college graduate, to her work at IBM, to what she’s doing now as a tech influencer, podcaster and Spotify engineer. 

Plus, Emma opens up about **her personal career struggles** and how her new move has changed things. If you love Emma (and Max Stoiber), you're gonna love them even more after watching this mini-doc.

<center>[Check it out here!](https://cult.honeypot.io/originals/dream-developer-job-with-emma-bostian)</center>
I made a scripting language in Rust for fun
Tags: rust, pest, beginners
Published: 2020-11-04 08:48:34

I wouldn't say my code is beautiful but you can see all the code in the github repository.
https://github.com/lechatthecat/oran

I made a scripting language in Rust. You can try this language by
```
$ git clone https://github.com/lechatthecat/oran.git
$ cd oran
$ cargo build --release
$ ./target/release/oran -f ./examples/hello.orn
```
Please note that you need to install git and Rust in your PC beforehand.

Then you can see 'Hello World' is printed as follows:
```
$ ./target/release/oran -f  ./examples/hello.orn 
Hello World.
```
In this language, you can define functions as follows:
```rust
fn test () {
    println('hello');
}

test();
```
You can copy-and-paste the above in ./examples/hello.orn and run it. If you run this script, you can see the function is called as follows:
```
$ ./target/release/oran -f  ./examples/hello.orn 
hello
```

Of course you can define variables as follows:
```rust
fn test () {
    let test = 'hey';
    println(test);
}

test();
```
```
$ ./target/release/oran -f  ./examples/hello.orn 
hey
```
But variables are immutable by default. You can't substitute other values to the variable.
```rust
fn test () {
    let test = 'hey';
    test = 'hello'; // error!
    println(test);
}

test();
```
You must define it as a mutable variable to substitute other values:
```rust
fn test () {
    let mut test = 'hey';
    test = 'hello'; // Now it runs
    println(test);
}

test();
```
You can also use for-loop in this language.
```rust
fn test () {
    let test = ' test';
    for i in 0..5 {
        println(i << test);
    }
}

test();
```
Result:
```
$ ./target/release/oran -f  ./examples/hello.orn 
0 test
1 test
2 test
3 test
4 test
```
If you want to do inclusive for-loop, you can write as follows:
```rust
fn test () {
    let test = ' test';
    for i in 0..=5 {
        println(i << test);
    }
}

test();
```
Result:
```
$ ./target/release/oran -f  ./examples/hello.orn 
0 test
1 test
2 test
3 test
4 test
5 test
```
You can also use 'if':
```rust
fn test (test1, test2) {
    return test1 + test2;
}

if test(5,5) == 10 {
   println('it is ten!');
}
```
Result:
```
$ ./target/release/oran -f  ./examples/hello.orn
it is ten!
```
Escaping is also implemented:
```rust
fn test (test1, test2) {
    test1 + test2
}
let t = 10;
if t == test(5,5) {
   println("variable \"t\" is " << t);
}
```
Result:
```
$ ./target/release/oran -f  ./examples/hello.orn 
variable "t" is 10
```
Also, as you could see, you can omit 'return' in function just like in Rust:
```rust
/*  both functions work  */
fn test (test1, test2) {
    test1 + test2
}
fn test2 (test1, test2) {
    return test1 * test2;
}

println(test(5,5));
println(test2(5,5));
```
You can see many other random dirty examples in 
https://github.com/lechatthecat/oran/blob/master/examples/example.orn
You can run it by:
```
$ ./target/release/oran -f  ./examples/example.orn 
```