teleren/devto huggingface dataset:
Node Js Worker threads
Tags: node, javascript, webdev, codenewbie
Published: 2020-10-09 16:34:17

Hello everyone 👋,

Worker threads help us to perform heavy synchronous operations without blocking the main thread. 

We should not be doing the I/O operations in workers because Nodejs's main threads handle I/O operations better than workers.

> The golden rule: don’t block the event loop, try to keep it running it and pay attention and avoid anything that could block the thread like synchronous network calls or infinite loops.

Let's take a look at the example:

{% gist https://gist.github.com/Kannndev/7a0504cc6563cccbffe1a13df9c9af00 %}

In the above code in the **route "/" getPi()** is a method that loop on 10000000000. This roughly takes around **60 seconds** to complete the request.

Since this is a synchronous operation it would be blocking the main thread execution and all the other requests will not be served.

To test it out, run the above code and hit "/" first and then "/hello". We would see that the second request will not be completed until the first request is completed.

To overcome this kind of situation we need to use worker threads where we will offload the blocking operation to the worker thread and once it is processed we will send the response back to the client.

{% gist
https://gist.github.com/Kannndev/574f4795570866ba2c9667370012fca9 %}

So here we are **spawning a worker thread** here and sending a **message to the worker** thread to fetch the pi value. Once the **value is returned from the worker** we are sending the response back to the client. 

This way we **will not be blocking** the main thread and other requests can be still processed as the worker thread execute in its separate event loop.

In case you want to play around code is available in [github](https://github.com/Kannndev/node-worker-threads).

Please like and share if you find this interesting.
What are the main features of JavaScript?
Tags: javascript, java, computerscience, career
Published: 2020-10-09 16:32:00

Like many other programming languages , JavaScript is basically a language to write instructions that Computers can understand and interpret .

Those instructions are called a script and they are used to create games , calendars , cookies or controlling websites behavior , like looping an image or a banner , or writing all kinds of forms , like E-mail verification and inputs , E-commerce baskets , direct chatting with sites visitors , counting the rates of visitors , to all thoughts that you can imagine or create .

JavaScript scripts are typically and heavily associated with the HTML and its derivations like XHTML , and CSS . That’s because HTML is simply a mark up language , although you can find that in every newer versions , some changes that can replace some JavaScript functions . While CSS complete the trio if i may say , in overriding the standard behavior of Browsers .

JavaScript is basically a programming language for client side . For Server side , you need other languages like PHP .

As a conclusion , if you want to create (without any external help) a website , you’ll have to learn HTML , CSS , JavaScript and PHP .

JavaScript is an easy language to learn and factually , its main strength comes from the huge libraries associated with it , but not integrated , meaning they can expand JavaScript functionality , but you may not use them .

Meet The Experts : https://nareshit.com/javascript-online-training/
Ask Octopus - Can I make a copy of a project?
Tags: octopus, tutorial, devops
Published: 2020-10-09 16:22:11

---
title: Ask Octopus - Can I make a copy of a project?
published: true
description: You have a project that you want to copy and modify. What do you do? Find out in this Ask Octopus!
tags: octopus,tutorial,devops
series: Ask Octopus
---

You have a project that you want to copy and modify. What do you do? Find out in this Ask Octopus!

{% youtube g1srv7-rVGg %}

Do you have a question about how to use Octopus? Email advice@octopus.com and someone from our team will get you an answer. You might even see it in a future episode.

Join our community slack at https://octopus.com/slack
Learning pentesting path
Tags: kali, security, pentest, paths
Published: 2020-10-09 16:14:36

- How to start? Targets? Create or reuse?
- Read about metasploitable, we will use it as a target
- Set up a metasploitable3 environment using Vagrant/Virtualbox
- Read about nmap
- Some tutorials nmap, examples, etc..
- VPN: mullvad vpn
- Read about SQL injection
- ' OR 1=1#'
Angular 10 Online Training
Tags: angular, career, computerscience
Published: 2020-10-09 16:12:01

We are providing Angular 10 Online Training in our institute NareshIT. We are having the best and well trained experienced faculty to train you the Angular 10. By joining in this course you will get complete knowledge about Angular 10. we are giving 100% guidance in placement for our students.

Angular 10.1 Angular 10 became generally available as a production release on June 24. The major upgrade to the Google-developed, TypeScript-based framework put more emphasis on quality, tool, and ecosystem improvements than new features.

What are the Angular 10 Online Training Objectives?

INTRODUCTION TO TYPESCRIPT

Introduction to Typescript
JavaScript & Typescript

NAMESPACES AND MODULES

Namespaces and multiple files
Loading modules

OOPS IN TYPESCRIPT

Classes, Class properties, Static Properties
Constructors, getters & setters
Inheritance, Abstract classes, Interfaces
Access modifiers

GENERICS

Generic functions, classes
Generic types and arrays
Constraints

DECORATORS

Class Decorators
Decorator Factories
Method Decorators
Property Decorators
Parameter Decorators

Is angular worth learning 2020?
Yes, its really good choice for many companies, so it's worth learning in 2020. Angular is the most mature of the frameworks, has good backing in terms of contributors and is a complete package. However, the learning curve is steep and concepts of development in Angular may put off new developers.

Is angular a good choice?
Angular is a good choice for companies with large teams and developers who already use TypeScript. ... However, it has done really well in the last few years to come out as a strong competitor for Angular and React.

Why we have to choose NareshIT?

• Real Time Trainers
• 100% Placement Assistance
• Small Training Batch
• Flexible Timings
• Practical Guidance
• Excellent Lab Facility
• Resume Preparation
• Hands on Experience
• Certification Support

For Details :

• Website : https://nareshit.com/angular10-online-training/
How to Drag and Drop a file from your computer to a HTML page ?
Tags: html, webdev
Published: 2020-10-09 16:11:45


With minimal code using HTML5 you can drag and drop a file from your computer to a HTML page and display its contents.

Here is how to do it:

https://fullstackdeveloper.guru/2020/10/09/how-to-drag-and-drop-a-file-into-a-html-page-using-html5/
Explored New Platform to create SmartContract for Free
Tags: smartcontract, blockchain, xinfin, xdc
Published: 2020-10-09 16:06:44

I would like to share my today's experience on a new platform that I explore to write smartcontract for Free.

MyContract.co is a platform build on XinFin Network which writes smartcontract with simply entering the details required. Remember it's coding-free, yes no need to code on MyContract.co.

I deployed a smartcontract in just 2 minutes using MyContract.co

I will be exploring XinFin more in depth.

Let me know your suggestions and which platform I should explore
What was your win this week?
Tags: discuss, weeklyretro
Published: 2020-10-09 16:02:18

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

It's almost the weekend!


**Looking back on your week — what was something you're proud of?**

All wins count — big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Cleaning your house...or whatever else that may spark joy 😄


**Happy Friday!**

![Pokemon Relax](https://media.giphy.com/media/iIbgY9P1m0woM/giphy.gif)
DOM events, eloquent Javascript, Day 85
Tags: 100daysofcode, javascript, books
Published: 2020-10-09 15:56:27

A user interacts with a web page through several actions that may include, clicking a button, scrolling down a page or keying in a value. It is important to understand and take note of these actions to determine how to respond to them.

####What's a DOM event?
> DOM (Document Object Model) events are actions that occur as a result of the user action or as a result of state change of the elements of a DOM tree.
[Wikipedia](https://en.m.wikipedia.org/wiki/DOM_events)

In a nutshell, it is the program's interpretation of a users action on elements of a DOM. 

#### Examples of DOM events and their triggers.
`click` - when a user clicks on an element.
`keydown` - when a user presses a key.
`keyup` - when a user releases a key.
`mouseup`- when a mouse button is released.
`mousedown` - when a mouse button is pressed.
`mousemove` - when a mouse pointer moves.
`scroll ` - when a user scrolls an element.
`focus` - when an element has received focus.
`blur`- when an element loses focus. 
`load`- when a page finishes loading.
`beforeunload` - when a page is closed.

_Touch interaction events_
`touchstart` - when a finger starts touching a screen. 
 `touchmove`- when a finger is moved while touching the screen
 `touchend` - when a finger stops touching a screen

####How do we respond to DOM events?
Since you have an idea of some of the events that might be triggered, you can move ahead to listen for this events. `addEventListener()` is an inbuilt javascript method used to listen for events. It takes two parameters, the event, and a callback function. The latter is where you define how you want to respond to an event.

####Default behaviour
Events in javascript have a default behaviour that may hinder your intended response to the event. Imagine a scenario where you intend to perform a computation on form data before submitting. The submit event will automatically submit this the data when triggered. To prevent this default behaviour, you can call `event.preventDefault()`  in the callback function of an event listener.

_Done for the day_
_Day 85_
Destructuring - renaming and default value
Tags: javascript, webdev, beginners, codenewbie
Published: 2020-10-09 15:29:20

```js
const response = {
  msg: "success",
  tags: ["programming", "javascript", "computer"],
  body: {
    count: 5,
    data: ["File 1", "File 2"],
  },
};

// The key exists
const { msg: message = 'Hello' } = response;
console.log(message); // success

// The key does not exist
const { search: searchText = "programming" } = response;
console.log(searchText); // programming
```

---

**Thanks for reading 💙**  
Follow **@codedrops.tech** for daily posts.  
[Instagram](https://www.instagram.com/codedrops.tech/) ● [Twitter](https://twitter.com/codedrops_tech) ● [Facebook](https://www.facebook.com/codedrops.tech/)

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript  
**[codedrops.tech](https://www.codedrops.tech/)**
Road to getting a dev job
Tags: webdev, productivity
Published: 2020-10-09 15:26:58

Right after writing about my portfolio website, I hopped onto my Word file and started refactoring my cover letter. Yes, I have a template, but it's self-made.

The next morning, after building a mini React Progressive Web App (PWA) project, I began my job hunting journey. I spent about 6 hours of my day applying for dev jobs, and the rest learning how to increase my chance of getting a call-back.

I wrote about 25 customized cover letters in total. I know it's a numbers game and I need to 10x my productivity. My eyes hurt when I read too much on my screen, but I'll take short breaks and continue grinding.

I won't give up, and I wish you all good luck getting a job. Stay safe.
HacktoberFest - A Whole New Experience
Tags: hacktoberfest, opensource, github, dev
Published: 2020-10-09 15:26:51

#Opportunities
HacktoberFest is a great initiative by [DigitalOcean](http://hacktoberfest.digitalocean.com/). It help both contributors and maintainers to make a new product and enhance the power of **Open Source**. Open Source Products are great because firstly they are free to use and secondly you can contribute to one and also inspire from one. Even almost 70-80% of my softwares that i use are open-sourced for usage.

#My Experience
So, let's talk about my experience during open sourcing. So, this was the first time i made a pull request and contributed to a project. We will talk about my Contributions in next section. Personally, i felt great and engaged while working on the project as it gave me a sense of responsibility while working on a real-time project. And the most great part was when my work was published on that official website, that was really a proud kind of feeling. Also i get to know that how important is to contribute in open source for every developer as it help not only them or others but the generations to come and yes when your work is recognised even in a form of contribution that's the whole next level feeling.

#Project For Contribution
So, let's talk about my contributions.
I contributed in this great package like bootstrap but only for buttons. It's name is SButtons and you can check it out on [SButtons](https://sbuttons.github.io/sbuttons/). So i contributed in 3 different sections for buttons. One in social media buttons and two in Animated Buttons.Also i contributed to my college's DSC repository [DSC CIET](https://github.com/DSC-ChitkaraUniv/HacktoberFest-2020) and [Coursify](https://github.com/ishandeveloper/Coursify-hacktoberfest).

#Conclusion
In end, i will say it's never late to contribute. Even if you fix a little issue in a ongoing project that's a great headstart and from by solving these small issues can help others a lot. So, Happy Open-Sourcing
Doctave: a batteries-included documentation site generator
Tags: showdev, rust, webdev, writing
Published: 2020-10-09 15:17:46


I am very happy to announce **[Doctave](https://github.com/Doctave/doctave)**, a batteries-included documentation site generator. With built-in **[Mermaid JS diagram](https://mermaid-js.github.io/) support, full-text search, a live-reloading development server, dark mode**, and more, building documentation sites has never been easier.


* [GitHub link](https://github.com/Doctave/doctave)
* [Documentation](https://cli.doctave.com)
* [Tutorial](https://cli.doctave.com/tutorial)


## What does it look like?

Below are a couple screenshots, and you can visit the Doctave docs for a live demo (Doctave naturally eats its own dog food and self-hosts its documentation).

Light mode | Dark mode |
-----------|-----------|
![Light Mode screenshot](https://dev-to-uploads.s3.amazonaws.com/i/xcg0kxjeg0z6xg0p7n44.png)|![Dark Mode screenshot](https://dev-to-uploads.s3.amazonaws.com/i/qvilopvrhktnly6gnz65.png) |


## What makes Doctave different?

Doctave comes with everything you need out of the box.

Many teams use fully featured static site generators to build their documentation sites. While this can be a very flexible solution, it can be too much for many projects that just need a documentation site with minimal effort. And while specialized documentation site generators exist, they too, more often than not, require installing addons and custom configuration.

This is where Doctave shines - it comes batteries-included. You don’t need to install plugins, tweak templates, or spend a week in the bikeshed with your team. In fact, Doctave does not even support plugins!

All you do is run `doctave init`, and write your docs in Markdown next to your code.

## What’s next?

We have a backlog of features and tweaks we are working on for Doctave. I’d love to hear your feedback, so if you give Doctave a spin, let me know what you think! You can reach out to me directly [on Twitter](https://twitter.com/NiklasBegley) or open an issue on [GitHub](https://github.com/Doctave/doctave).

Happy documenting!
Get ready for Meteor Impact 2020
Tags: meteor, javascript, watercooler, conference
Published: 2020-10-09 15:13:39

Meteor Impact is approaching! As it does there are a few things that you should take into account and do.

## To consider
1. Meteor Impact is an international conference, this means that based on your timezone you might catch live only a few talks and other will be from recording.

2. Some events are designed to be meetups with different themes. From get together of regional developers to thematic ones like "What is your creative outlet?" designed for people to showcase what they do outside of Meteor. Consider attending them (if you do sign-up for them these are usually smaller gathering with limited capacity).

## To do
1. You need to be [registered](https://impact.meteor.com/sign-up) to access and participate in the sessions.

2. Go over the [agenda](https://impact.meteor.com/agenda) and add the talks you wish to attend to your schedule. This will reserve you a spot. It shouldn't be a problem for most sessions, but in some cases the capacity is limited.

3. Ask a question. Each talk has a poll where you can ask any question. So if you have one already feel free to ask. This will also help the speaker when preparing their talk.

4. Check out the [exhibitors](https://impact.meteor.com/exhibitors)! These are all companies that run Meteor or have people that are close to Meteor. Show them some love and who knows, maybe you might find something interesting or your next gig (quiet a few of them are hiring).

5. Keep an eye on new changes! With two weeks still to go there is still at least one week where new talks will be added and timing of some events might change, so be sure to check-in once in a while to see what is new.

6. If you appreciate what the community is doing consider [sponsoring](https://impact.meteor.com/join/sponsor) some of the community contributors!

--------
If you like my work, please consider supporting me on [GitHub Sponsors ❤️](https://github.com/sponsors/StorytellerCZ).
Problems with Using for...in on Arrays in JavaScript
Tags: beginners, javascript, todayilearned
Published: 2020-10-09 15:11:55

I've been doing a lot of algorithm practice lately, and I just came across a quirk of how for...in works.

I love using JavaScript's for...in and for...of loops when iterating because I consider the code much cleaner and readable at a glance.

In this post, I'll be discussing a problem you may run into with for...in if you're trying to take shortcuts like I was.

## What is for...in?

In case you're not familiar, here's a simple example of code side by side that will give the same console logs:

```js
arr = [1, 2, 3]
for (let i = 0; i < arr.length; i++) {
  console.log(arr[i]) // 1, 2, 3
}

for(let i in arr) {
  console.log(arr[i]) // 1, 2, 3
}

for(let el of arr) {
  console.log(el) // 1, 2, 3
}
```

Like I said earlier, I consider the second/third to be "cleaner", but the second runs into issues if you need to use `i` as a number. The following **won't** produce the same console logs:

```js
arr = [1, 2, 3]
for (let i = 0; i < arr.length; i++) {
  n = i + 5
  console.log(n) // 6, 7, 8
}

for(let i in arr) {
  n = i + 5
  console.log(n) // "05", "15", "25"
}
```

The reason for this is because `typeof i` in the for...in loop is a `"string"` rather than a `"number"`. This means you'll get weird results doing math on `i`.

## Conclusion

In summary, if you need to use the numerical value for the index as you loop over an array, you either need to use the long-form verbose/explicit for loop or add something like `i = parseInt(i)` at the top of your loop:

```js
arr = [1, 2, 3]
for (let i = 0; i < arr.length; i++) {
  n = i + 5
  console.log(n) // 6, 7, 8
}

for(let i in arr) {
  i = parseInt(i)
  n = i + 5
  console.log(n) // 6, 7, 8
}
```

Edit: There have been a few other great suggestions on how to handle this in the comments! Check them out
Build A StackOverflow Dashboard (Part 2): Crafting BigQuery Views and Superset Charts
Tags: database, datascience
Published: 2020-10-09 15:03:47

Just released this new blog post at work! I'm working on a series of blog posts that help Developer Advocates, Community Managers, etc use data to understand community health (across platforms like Slack, Github, StackOverflow, etc).

This latest one is on StackOverflow!

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

Part 1, on setting up the tools, is here [https://preset.io/blog/2020-08-04-google-bigquery/](https://preset.io/blog/2020-08-04-google-bigquery/).
Host React Library/App on a CDN
Tags: react, cdn, library, javascript
Published: 2020-10-09 14:56:08

---
title: Host React Library/App on a CDN
published: true
description: Boilerplate to build a no-config, CDN-ready react app.
tags: react, cdn, library, javascript
cover_image: https://codefluegel.com/wp-content/uploads/2020/01/react-920x480.png
---
Hello devs. Today I figured out how to make a JS library using React with the aim to host it on a CDN and use it on any website via ``<script/>`` tag. Check it out!


[https://github.com/ggcaponetto/external-react-app](https://github.com/ggcaponetto/external-react-app)
Firebase Hosting
Tags: computerscience, codenewbie, react, angular
Published: 2020-10-09 14:52:00

Firebase Hosting is not only used to deploy static websites, it is also used to deploy dynamic Node apps.
Firebase Hosting is backed by a CDN. Hence, there are many cool ways in which we can optimize our page loads.
When a user makes a request, it goes to the server. The server does all the dynamic generation and sends the response back to the user.
Sometimes, the user can be really far away from the server. In that case, it can actually take a long time to make this round trip. So it would be really good if we didn't have to send our content back this far. What if we have a server to cache the results right near the user. Well, this is how a content delivery network works.

You will notice that a cached page loads much faster than a page that is not. Why does this happen?

Imagine a user that makes a request for our website. But with a content delivery network, it is going to stop at the edge server which is close to the user. And the edge server is going to check to see if the content is in its cache. If it's not in it's cache, its going to forward the request off to the origin server. The origin server is going to do the dynamic content generation, and then it's going to send back to the edge server. The edge server is going to cache this content, which will be controlled by the cache control header that you set. It will then send that content back to the user.

Now, let's say there is another user in that same area that makes a request for the website. That request will go out to the edge server, and the edge server will recognize that it has this content in the cache. So rather than going out to the origin and doing the new dynamic generation of the page, it's going to send back the content to the user and that response time is going to be much, much faster, because it is local to the user.

Also, the other users in this area can make requests for this content, and it doesn't have to go out to the origin server. It goes right back from there local edge server for really fast page load.

After the cache process expires, the whole process will begin again, where we go out to the edge server, the edge server recognizes that the content has expired, so goes out to the origin. Origin dynamically generates, sends it back, caches it according to your cache control headers, and then back to the user, where it's cached.

You can now host Node apps on Firebase Hosting and you can take that generated result and store it into a CDN for a huge perf benefit.
What about JavaScript Frameworks?
With JavaScript frameworks, all of your content in your render is held up in JavaScript. Modern JavaScript frameworks have tooling around server-side rendering. So you can take that same client-side app, render it out on the server for a fast first paint.

Thank You!