teleren/devto huggingface dataset:
What is Export and Import in JavaScript?
Tags: beginners, javascript, webdev, 100daysofcode
Published: 2020-12-07 03:54:54


My new post for beginners and learners. So here We'll learn about Import and Export in a very very easy way. Let's go

## Import and Export

- In JavaScript ES6, we can import and export functionalities from modules. 
- These can be functions, classes, components, constants, essentially anything assign to a JavaScript variable. 
- Modules can be single files or a whole folder with one index file as an entry point. 

## Why to use Import and Export
- The import and export statements in JavaScript help you to share code across multiple files to keep it reusable and maintainable. 
- **Encapsulation** : Since not every function needs to be exported from a file. Some of these functionalities should only be used in files where they have been defined. File exports are a public API to a file, where only the exported functionalities are available to be reused elsewhere. This follows the best practice of encapsulation. 

<hr>

### Export before declaration

```javascript
export const name = Rahul;
export function sayHi(user) {
    alert(`Hello, ${user}!`);
} // no; at the end
```

And import them in another file with a relative path to the first file. 

```javascript
import { name } from './firstfile.js';
console.log(name); // Rahul
sayHi(name); // Hello, Rahul!

import * as person from './firstfile.js'; 
console.log(person.name); // Rahul
```

Imports can have aliases, which are necessary when we import functionalities from multiple files that have the same-named export. 

```javascript
import { name as firstName, sayHi } from './firstfile.js'; 
console.log(firstName); // Rahul
```

### There is also default statement, which can be used for a few cases: 

- To export and import a single functionality
- To highlight the main funuctionality of the exported API o a module
To have a fallback import functionality

```javascript
const person = {
    firstName: 'Rahul',
    lastName: 'Singh',
};
export default person; 
```

We can leave out the curly braces to import the default export. 

```javascript
import developer from './firstfile.js';
console.log(developer); 
// { firstName: 'Rahul', lastName: 'Singh' }
```

<hr>

That was it explaining the `import` and `export` in JavaScript. Hope you have found it useful. 

<hr>
## Need Help
Need help in raising funds to buy a Mechanical Keyboard. This pandemic has affected my family badly so can't ask my DAD for it. Please Help Me. 

<a href="https://www.buymeacoffee.com/rahxuls">
![1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606540958103/otN4S9TK8.png)
</a>
😎Happy Coding | Thanks For Reading⚡
Adaptive Boosting
Published: 2020-12-07 03:48:13

**Introduction**
Adaptive Boosting or AdaBoost, like a random forest, is an ensemble learning algorithm. We can apply it to both classification and regression problems. As we know, ensemble methods combine several machine learning algorithms, and AdaBoost is commonly used with decision trees. 

The core element of the algorithm is the decision stump. Each stump represents a node (e.g., a feature with a specific condition) with two leaves: one with data points where the condition is True and another one where the condition is False. Because individual stumps are not so efficient, they are called 'weak learners'. However, when 'weak learners' combined as an ensemble, and adaptive 'magic' boosting applied, they are quite efficient.

**Algorithm**
Let's dive into the details of how AdaBoost 'magic' works. For example, we have a binary classification problem, and the dataset has N features.

1) We create N number of stumps using all initial data. Then, the most efficient stump out of N is chosen, e.g., based on Gini index. 

2)We calculate how much error (misclassifications) this stump made and using the log formula, the 'decision influence' (alpha) of this stump is calculated. 

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

This decision influence will be used for the final decision when we sum up all the points of stumps concluding that it is a class 0 and class 1 separately.  Depending on which class has more points, the final decision will be made.

3) At this step we need to prepare our initial data set for the modification. This preparation has two steps:
a) Initially all our data points(rows) have equal 'sample weight'  [1/(number of rows)].
Now we need to update the 'sample weights' of each data point (row) based on the 'weak learner' correct and incorrect classification. If the stump is correctly classified, the data point (row), the sample weight will be reduced and if incorrectly then increased.

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

b) we create a new dataset using sampling with replacement and taking into account the sample weight we updated earlier. Basically, the higher the sample weight more chances that this data point will be duplicated in the new dataset. The size of the data set is kept the same as the original.

4) We repeat steps 1-3.
Note: in step 3a, we need to normalize 'sample weights', such that the sum of the weights equals 1.

**Summary**

AdaBoost's 'weak learners' (stumps) have a different influence on the final decision compared to Random Forest, where all trees have the same importance.

Also, AdaBoost has an iterative learning process, where each next learner 'influenced' by the previous leaner through the changed dataset. Whereas, Random Forest uses just random with replacement datasets without implying weight for each row during the process.
Run VirtualBox on BigSur
Tags: macos, virtualbox, bigsur
Published: 2020-12-07 03:38:27

Recently Oracle has released the new version of VirtualBox and I installed it on Bigsur. Finally, I could run VirtualBox on BigSur.

The following are what I got when I tried to install Ubuntu on VirtualBox.

![Image for post](https://miro.medium.com/max/60/1*YeXoqBks0xrnYFuMHtGS4w.png?q=20)

<noscript><img alt="Image for post" class="ev el eh ic w" src="https://miro.medium.com/max/1684/1*YeXoqBks0xrnYFuMHtGS4w.png" width="842" height="504" srcSet="https://miro.medium.com/max/552/1*YeXoqBks0xrnYFuMHtGS4w.png 276w, https://miro.medium.com/max/1104/1*YeXoqBks0xrnYFuMHtGS4w.png 552w, https://miro.medium.com/max/1280/1*YeXoqBks0xrnYFuMHtGS4w.png 640w, https://miro.medium.com/max/1400/1*YeXoqBks0xrnYFuMHtGS4w.png 700w" sizes="700px"/></noscript>

![Image for post](https://miro.medium.com/max/56/1*AjuaZ6fLqLrHW4EZtz65kQ.png?q=20)

<noscript><img alt="Image for post" class="ev el eh ic w" src="https://miro.medium.com/max/1520/1*AjuaZ6fLqLrHW4EZtz65kQ.png" width="760" height="806" srcSet="https://miro.medium.com/max/552/1*AjuaZ6fLqLrHW4EZtz65kQ.png 276w, https://miro.medium.com/max/1104/1*AjuaZ6fLqLrHW4EZtz65kQ.png 552w, https://miro.medium.com/max/1280/1*AjuaZ6fLqLrHW4EZtz65kQ.png 640w, https://miro.medium.com/max/1400/1*AjuaZ6fLqLrHW4EZtz65kQ.png 700w" sizes="700px"/></noscript>

In my case, the issue was the security settings. As you know, macOS gets more and more strict.

Here are what I did to work out the issue I had.

## Step 1 Run the command


```
$ sudo kmutil load -b org.virtualbox.kext.VBoxDrv</span>
```


## Step 2 Allow VirtualBox/Oracle to have permissions

System Preferences > Security & Privacy
Unlock and Click Details and checked Oracle

Privacy tab > Full Disk Access
Add VirtualBox

## Step 3 Reboot macOS

Just restart macOS and run VirtualBox
Introducing the official instascrape website
Tags: python, showdev, webdev, blogging
Published: 2020-12-07 03:31:52

Check out the newly launched, official `instascrape` [site](https://chris-greening.github.io/instascrape/)!

---

Over the last few months, I've been spending a _ton_ of time working on my open source Instagram scraping library: [`instascrape`](https://github.com/chris-greening/instascrape).

{% github chris-greening/instascrape %}

Now that the lib is starting to build a bit of a cult following, I figured it would be a great time to launch an official website! 

[Check it out](https://chris-greening.github.io/instascrape/) and feel free to drop some feedback, would love to see what people are interested in seeing :heart:
Logical 'OR' Operator | Shell Scripting 
Tags: linux, bash, tutorial, beginners
Published: 2020-12-07 02:58:53

**This is a multipart blog article series where I am going to explain the concepts of shell scripting and how to write a shell script in Linux, UNIX or Mac based systems. You can also follow this tutorial blog using windows but for that you have to install a bash from.**

_In this article we will see that how can we use ‘OR operator with the help of if condition. We will also see that different ways to use ‘OR’ operator._

We are going to use OR operator with if condition to solve a problem.
- If the age is greater than `18` **OR** less than ``30`, then it will be true/ successful and we will print “valid age”
- Otherwise it will give false.
- The syntax of if condition for this problem will be `if [ “$<variable_name>” –gt ] || [ “$<variable_name>” –lt 30 ]`
- If `OR` operator is used then if only one condition is true, then also it will return true.
- Another way to use `OR` operator is like this `if [ “$<variable_name>” –gt –o “$<variable_name>” –lt 30 ]`
- In this way we use `-o` flag and it work same as `||` but the syntax to write the if condition is changed little bit.
- If you want to use `||` operator then there is one more way to do and that is by using double square brackets like this `if [[ “$<variable_name>” –gt 18 || “$<variable_name>” –lt 30 ]]`

[Reference code file for this article](https://github.com/rahulMishra05/shell-scripting/blob/main/video9.sh)

_So this was all about **logical OR operator** with if condition. Hope you liked it and learned something new from it._

If you have any doubt, questions, quires related to this topic or just want to share something with me, than please feel free to contact me. 

### 📱 Contact Me

[Twitter](https://twitter.com/r_mishra10)
[LinkedIn](https://www.linkedin.com/in/rahul-mishra-66210b185)
[Telegram](https://t.me/rahul_mishra10)
[Instagram](https://www.instagram.com/rahul_mishra10/?hl=en)

### 📧 Write a mail
<rahulmishra102000@gmail.com>

#### 🚀 Other links

[GitHub](https://github.com/rahulMishra05)
[HackerRank](https://www.hackerrank.com/rahulmishra10201)
Install PHP 8 on AWS 
Amazon Linux 2
Tags: php, aws
Published: 2020-12-07 02:54:39

PHP 8 is finally here, and it's time to upgrade our DEV environments to start resolving all those Warnings :)

At Lnk.Bio we use the official [AWS Amazon Linux 2 AMI](https://aws.amazon.com/amazon-linux-2/), and usually rely on the library **Amazon Linux Extras** to update/switch php version, but PHP 8 is yet to be included (and I couldn't find any timeline anywhere).

Therefore, I found the best way to install PHP 8 is to rely on [Remi's RPM repository](https://rpms.remirepo.net/) which features all major PHP versions for RHEL/Centos (on which Amazon Linux 2 AMI is sort of based). 

The steps are quite easy:
1. Remove current PHP versions
2. Add Remi's RPM repo for Centos 7
3. Install PHP 8
4. Install PHP 8 additional libraries
5. Paths/Configuration Notes

> Please note that this guide is not intended for those who want to run multiple PHP versions at the same time. It will replace the current PHP version with PHP 8.

Let's go

## 1. Remove current PHP version

If you don't have a formal documentation (you should!) of which additional PHP packages you need for your app, you can get a list by running.

```
sudo yum list installed | grep php
```

Once you're confident you can reinstall everything, start by removing old PHP packages.

```
sudo yum remove php*
```

## 2. Add Remi's RPM repo for Centos 7

You will also need EPEL for Centos 7 for dependencies. I guess most people have this already enabled on Amazon Linux 2 AMI, but I am adding it anyway for clarity:

```
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php80
```

## 3. Install PHP 8

Now this is quite easy:

```
sudo yum install php80
```

Verify PHP is installed correctly by running

```
php80 -v
```


## 4. Install PHP 8 Additional libraries

If you use additional modules/libraries, you can now install them. Naming convention remained the same, but they have the prefix php80-php-{library}

For example, if you use php-fpm you'll run `sudo yum install php80-php-fpm`; if you need mysqlnd you'll run `sudo yum install php80-php-mysqlnd` etc...

## 5. Paths/Configuration notes

Please note that Remi's PHP will be installed under /opt and the binary is `php80`. Here are a few locations you need to know:
- PHP configuration files (php.ini, php-fpm.d etc..): /etc/opt/remi/php80/
- PHP logs: /var/opt/remi/php80/log/
- PHP Binary: /usr/bin/php80

You can of course create symlinks if you prefer.
JavaScript: Difference between = vs == vs ===
Published: 2020-12-07 02:24:14

Why is the purpose of using = in JavaScript?

As you're programming, when you want to assign value to a variable to use or change throughout the code, you use the = operator. The = operator is called the assignment operator, and there are many ways you can assign values to variables.

Example:

    let x = 10;
    let name = "Jhonny";
    let nameList = [ "Lisa", "Mona", "Tim"]


If = means assigning values, what does == mean?

Now think if you want to compare *x* to *name*, how would you compare them to evaluate if the variables are of the same value. That is where the == operator comes in handy, this operator called the equality operator. The return value when using it is a Boolean(true or false), it is not strict so if you compare 

    1 == "1";   // true
    x == "10";  // true
    name == x;  // false

the return values vary. Not strict equality means that the equality operator will try to convert the values datatype before comparison happens.


What is strict equality?

Similar to the == equality operator, we have === strict equality operator. This works similarly except without trying to implicitly convert the variables values, it compares it strictly to the value and the value datatype and also returns a Boolean.

For example:

    x === 10;        //true
    x === "10"       // false
    name === "Lisa"  //false
 
If the values are not similar, it will not convert them therefore the result will false. 


I hope this helps, I wanted to make it very simple and down to the basics.
A Zoom bot for a CRM application using AWS Lambda and Deployed via Jenkins
Tags: aws, jenkins, zoom, devops
Published: 2020-12-07 02:12:01

Recently Zoom has become very popular with many companies as a go-to means for communications. During the Covid period this year, Zoom has become a primary communication mode as many companies switched to remote work. Since Zoom is already an integrated part of the companies now, I thought why not integrate it to the Sales processes too. Sales users who are already using Zoom should be able to to use it to operate on their CRM too.
This is when I came across Zoom bots. I will go through details below regarding what actually is a Zoom bot. So to give the Sales user an ease of working on their CRM without leaving the already-logged-in Zoom app, I developed a Zoom bot through which user can work with a CRM application via Zoom chat.

In this post I will explaining about my Zoom bot and how I integrated with a CRM application(I am using SFDC here). I will be explaining a high level general overview of building a Zoom bot and how it can be deployed via a CI/CD pipeline. Hope this will also help you on building your own Zoom bot.  

The post can be found here: https://amlanscloud.com/zoombot  
Also here is a short video showing the bot in action: https://youtu.be/823fzNxCGgk
How and Why I switch the Windows 10 to Linux (Ubuntu 18.0 LTS) 
Tags: linux, opensource, os
Published: 2020-12-07 02:07:44

I bought my first computer when I started the journey of my B.Tech education. I didn’t know anything about linux and also much more about operating systems. I bought Dell vostro 15 which is a very low-end pc for me. And windows 10 is not good for intel i3 5th gen. It's very slow and takes a lot of time to update. Update package is very high in data. I have to give all of my internet data plan to Windows 10 for update. But I see the computers in my college, lot of computers have Linux based os ubuntu and it was very simple to use. Then I started to collect the information about Linux based operating systems and decided to install Linux on my laptop.

I download Linux based os Ubuntu 18.0 LTS which is completely Free and Open-Source and then installed besides Windows 10. I experienced a lot of features on Ubuntu and don’t need to install any kind of antivirus because it is hard to get viruses on linux. 

But linux is not simple to use until you don't know about coding and basic programming. Because in linux we have to use code on terminal to get any new software or feature. But it is best for computer science students.
|JavaScript| JavaScript: Newer Features
Tags: javascript, html, css, webdev
Published: 2020-12-07 01:48:07

---
title: |JavaScript| JavaScript: Newer Features
published: true
description: 
tags: javascript, html, css, webdev
//cover_image: https://direct_url_to_image.jpg
---



              -Default Params
              -Spread in Function Calls
              -Spread with Array Literals
              -Spread with Objects
              -Rest Params 
         
    


###Default Params




```javascript 

function multiply(a, b = 1) {
 return a * b; 
}

multiply(4); 
multiply(4, 5); 

```
In the code, a has no default value, therefore, a will be whatever you pass in as the first argument. 
Meanwhile, b does have a default value. If you leave it off, it will default to one. 



###Spread in Function Calls
Spread syntax allows an iterable such as an array to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. 

spread is used for function calls. 
Expands an iterable array, string into a list of arguments. 

```javascript 

const nums = [ 9, 3, 2, 8 ];
Math.max(nums); 
Math.max(...nums); 

```

###Spread with Array Literals

Create a new array using an existing array. Spreads the elements from one array into a new array. 

```javascript 

const nums1 = [ 1, 2, 3 ]; 
const nums2 = 4, 5, 6 ]; 

[ ...nums1, ...nums2 ]; 

[ 'a', 'b', ...nums2 ];

[ ...nums1, ...nums2, 7, 8, 9 ];

```




###Spread with Objects
Copies properties from one object into another object literal. 

```javascript 

const feline = { legs: 4, family: 'Felidae' };
const canine = { family: 'Caninae', furry: true }; 

const dog = { ...canine, isPet: true }; 

const lion = { ...feline, genus: 'Panthera' };

const catDog = { ...feline, ...canine }; 

```
 
We can spread properties from an object into a new object. 



###Rest Params 

The arguments object is available inside every function. 
Its an array-like object that has a length property but does not have array methods like push or pop. 
Contains all the arguments passed to the function. Not available inside of arrow functions. 

```javascript 


function sumAll() {
 let total = 0; 
 for (let i = 0; i < arguments.length; i++)
{ total += arguments[i];
}
return total; 

}

sumAll(8, 4, 3, 2); 
sumAll(2, 3); 

```
Its called an array like object because we can use the indices to access elements outs. It works exactly like an array, except we don't have to access array methods like push or pop.
|JavaScript| JavaScript: Callbacks and Arrays
Tags: javascript, html, css, webdev
Published: 2020-12-07 01:46:14

---
title: |JavaScript| JavaScript: Callbacks and Arrays
published: true
description: 
tags: javascript, html, css, webdev
//cover_image: https://direct_url_to_image.jpg
---

           

              -The forEach Method
              -The map Method
              -Intro to Arrow Functions
              -Arrow Function Implicit Returns
              -The filter Method
              -Some and Every Methods
 


###The forEach Method
forEach accepts a callback function. 
Calls the function once per element in the array. 

```javascript 

const nums = [9, 8, 7, 6, 5, 4, 3, 2, 1];

nums.forEach(function (n) {
 console.log(n * n) 
}); 

nums.forEach(function (el) {
 if (el % 2 === 0) {
 console.log(el)
  }
})

```


###The map Method
The Map creates a new array with the results of calling a callback on every element in the array. 
Map is similar to forEach in the sense that it accepts a callback function and it runs that function once per element in the array. 

The major difference is that Map generates a new array using the result, using the return value of the callback. 

It is a way to map an array from one state to another. 


```javascript 

const texts = ['rofl', 'lol', 'omg', 'ttyl'];
const caps = texts.map(function (t) {
 return t.toUpperCase(); 
})

texts; 
caps; 

```

###Intro to Arrow Functions
Arrow functions are syntactocally compact alternative to a regular function expression. 

```javascript 

const sqaure = (x) => {
 return x * x; 
}

const sum = (x, y) => {
 return x + y; 
}

```

Arrow functions allow us to write functions without having to write the keyword function. 






###Arrow Function Implicit Returns
Implicit returns allows us to shrink arrow functions down even more. 



```javascript 

const isEven = function (num) {
 return num % 2 === 0; 
}
const isEven = (num) => {
 return num % 2 === 0; 
}
const isEven = num => {
 return num % 2 === 0; 
}
const isEven = num => {
num % 2 === 0; 
}

```
implicit returns removes the word return but the function of retuning is still occurring. 


###The filter Method
The filter method creates a new array with all elements that pass the test implemented by the provided function. 


```javascript 


const nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]; 

const odds = nums.filter(n => {
return n % 2 === 1; 

})

const smallNums = nums.filter(n => n < 5); 

```




###Some and Every Methods

Every method test whether all elements in the array pass the provided function. It returns a boolean value. 

```javascript 

const words = ["dog", "dig", "log", "bag", "wag"];

words.every(word => {
 return word.length === 3; 
})

words.every(word => word[0] === 'd'); 

words.every(w => {
  let last_letter = w[w.length - 1];
  return last_letter === 'g'
})

```

Some method is similar to every, but returns true if any of the array elements pass the test function. 

```javascript

const words = ['dog', 'jello', 'log', 'cupcake', 'bag', 'wag'];

words.some(word => {
 return word.length > 4; 
})

words.some(word => word[0] === 'Z'); 

words.some(w => w.includes('cake'))

```