teleren/devto huggingface dataset:
JavaScript interview questions: step by step
Published: 2023-03-21 16:35:47



## Easy

1. What is the **DOM**?
2. What is the **“use strict”**?
3. How many **data types** are in js?
4. What is the difference between **primitive** and **non-primitive** data 
   types?
5. What is the **Symbol** data type?
6. What is the **BigInt** data type?
7. What is the difference between **strict equality** and **loose 
   equality**?
8. How many are there ways of creating an **Array**?
9. How many are there ways of creating **Objects**?
10. How many are there ways of declaring **function**?

## Medium

1. What is the **hoisting**?
2. What is the difference between **var**, **let**, and **const**?
3. What is the difference between **arrow function** and **function expression**?
4. What is the **scope** and how many are they?

## Hard

1. What is the **prototype**?
2. What is the difference between **prototype** and **__proto__**?
3. What is the **“this (call, apply, bind)”**?
4. What is the **closure**?
5. What is an **event loop**?
6. What is the **callback hell** and explain the **promise**? 
   Promise methods?
7. What is the **polyfill** in JS?
8. JS **classes**?
9. **Async awaits, try-catch, fetch**?
10. What is a **proxy**?
11. **Function generator, symbol iterator, for of, for in**?
12. **Array methods** (forEach, map, reduce, filter)?
13. **Map, Set, WeakMap, WeakSet**?
14. **Spread** vs **Rest**?
15. **Object** and **Array Destruction**?
16. **Local storage, session storage, cookies, index DB**?
Understanding *args & **kwargs
Tags: python, beginners, programming
Published: 2023-03-21 16:32:57

If you have ever needed to pass a variable number of arguments to a Python function you may have come across the *args and **kwargs syntax. These powerful tools allow you to pass a variable number of non-keyword and keyword arguments, respectively. In this post, lets dive into what *args and **kwargs are, how they work, and provide some examples to help you better understand these Python features.

**What is *args?**
It is a special syntax used in python function definition to pass a variable/unlimited number of non-keyword arguments to the function. Let’s use an example to make things more clear.

Example 1: Create a python function that takes in any number of values and sum all values passed to it.

```
def add(*args):
    sum = 0
    for arg in args:
        sum += arg
    print(f"The sum is: {sum}")

add(1,2,3,4,5,6,7,8,9)
```

Output: _The sum is: 45_


Example 2: Create a python function to display all car brand names passed to it.

```
def names(*args):
    print("The car brands are:")
    for arg in args:
        print(arg)

names('Jeep','Volkswagen','Toyota','Ford','Rivian','Tesla')

```
Output: 
_The car brands are:
Jeep
Volkswagen
Toyota
Ford
Rivian
Tesla_

**What is **kwargs?**
It is a special syntax used to pass keyword arguments to a function. These keyword arguments can be of any number just like in args. A keyword argument is where you give a name to the argument as you pass it to the function. Let’s use some examples to make things clear.

Example 1: 

```
def names(**kwargs):
    for key, value in kwargs.items():
        print(f"{key}: {value}")

names(Fname="John",Lname="Doe",work="Doctor")
```

Output: 
_Fname: John
Lname: Doe
work: Doctor_

It is important to note that args and kwargs are just names and can be replaced with whatever names you like. What is important is the * and ** operators which are called unpacking operators. These operators must be included whenever you want to create such functions. To prove this, lets rename args and kwargs in the above examples.

Example 1:

```
def names(*cars):
    print("The car brands are:")
    for x in cars:
        print(x)

names('Jeep','Volkswagen','Toyota','Ford','Rivian','Tesla')
```
Output: 
_The car brands are:
Jeep
Volkswagen
Toyota
Ford
Rivian
Tesla_

Example 2:

```
def names(**names):
    for key, value in names.items():
        print(f"{key}: {value}")

names(Fname="John",Lname="Doe",work="Doctor")
```

Output:
Fname: John
Lname: Doe
work: Doctor

**Why use *args and **kwargs.**
These two python features are very useful in creating functions which the number of arguments to be provided is not known.

**Conclusion**

- *args passes a variable number of non-keyword arguments.
- **kwargs passes a variable number of keyword arguments.
- Keyword arguments are arguments that have a key and value. For example, fname=”name”
- The names args and kwargs can be changed to whatever you want, the most important part are the **unpacking operators** * and **.
Passwordless Login: How to Use It & Its Benefits.
Tags: passwordlesslogin, passwordlessauthentication, multifactorauthentication, ciamsolutions
Published: 2023-03-21 16:23:16

Passwordless login eliminates the need for users to remember passwords by verifying their identity with a possession factor. The possession factor can be an object that uniquely identifies the user with an email or SMS sent to the registered email address or phone number, respectively. Once the link or OTP is verified, the consumer will be logged into the account.

Passwordless login provides a way for consumers to verify their identities without the need for passwords or any other memorized credentials. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0y42fs5acleesn42grr.png)

## **How To Use Passwordless Login?**

With [Passwordless Login](https://www.loginradius.com/passwordless-login/), you may access your favorite accounts. Passwordless Login simplifies life, which eliminates the need for several passwords by using biometrics like face and fingerprint identification.

Do you exactly recall which accounts they belong to and what their passwords are? How often do you use the same password because you can't come up with one that's special, secure, and simple to remember for each of your accounts?

Passwordless Login simplifies the login procedure and gets rid of the hassle of having to remember several passwords.

## **How To Implement Passwordless Login?**

**Passwordless Login can be implemented using two methods:**

1) Passwordless Login with Email
2) Passwordless Login with OTP (SMS)

**When you use passwordless authentication with SMS, consumers can:**

1) Provide a cell phone number instead of a user ID/password.
2) After They receive an OTP via text message (SMS)
3) Enter that OTP on the login screen to access the application.

**When you use passwordless authentication with Email, consumers can:**

1) Provide their email address or user name.
2) They will receive a one-time passcode (OTP) via email or a magic link.
3) Then, Enter that OTP on the login screen, or they can just click on the magic link to log in.

**To implement passwordless authentication, you will need to make two decisions:**

1. What type of authentication do you want to use (email/SMS with a one-time-passcode or
email with a magic link) and,
2. You want to implement authentication using Embedded Login or Standard Login.

When you decide what kind of implementation you want, you can choose any authentication solution that fits your needs.

## **Conclusion:**

Passwordless login is an excellent way to enhance security while easing the burden on your customers. Customers will be able to save their payment information so they do not have to remember a long, difficult password. This will increase their proclivity to make impulse purchases in the future.
Engineering managers have it easy, right?
Tags: programming, management, leadership
Published: 2023-03-21 16:16:24

Engineering managers have it easy, right?


Well it turns out they are some of the hardest working engineers, at least in early stage startups.


At Adadot we analysed data in 38,000 developer datasets from GitLab, GitHub, @Slack and Google Calendar.


As far as activity goes they commit 10x times more often and volume wise 50% more than juniors. Is this the true measure of a #developer? Of course not!


More importantly they are very present in collaboration activities sending over 100x more messages than non-managers.


More data to come on this.


Become a manager they said...


It will be fun they said...
Using time() and duration() in DataWeave for performance check
Tags: mulesoft, dataweave, performance, programming
Published: 2023-03-21 16:02:44

You can use [`duration()`](https://docs.mulesoft.com/dataweave/latest/dw-timer-functions-duration) to get the total number of milliseconds it took to execute a function.

Script:

```dataweave
%dw 2.0
output application/json
import duration from dw::util::Timer
fun myFunc() = [1, 2, 3] reduce $+$$
---
duration(() -> myFunc())
```

Output:

```json
{
  "time": 0,
  "result": 6
}
```

You can use [`time()`](https://docs.mulesoft.com/dataweave/latest/dw-timer-functions-time) to get an even more detailed result of when the function started and ended. This will give you more insight into the total time it took to execute.

Script:

```dataweave
%dw 2.0
output application/json
import time from dw::util::Timer
fun myFunc() = [1, 2, 3] reduce $+$$
---
time(() -> myFunc())
```

Output:

```json
{
  "start": "2023-03-21T16:00:21.487377Z",
  "result": 6,
  "end": "2023-03-21T16:00:21.487408Z"
}
```

This way you can use `-` to get the total number of time.

Script:

```dataweave
%dw 2.0
output application/json
import time from dw::util::Timer
fun myFunc() = [1, 2, 3] reduce $+$$
var funcResult = time(() -> myFunc())
---
funcResult.end - funcResult.start
```

Output:

```json
"PT0.000024S"
```
TIL that you can use asterisks in systemctl status
Tags: todayilearned, linux, systemd
Published: 2023-05-19 20:36:06

---
title: TIL that you can use asterisks in systemctl status
published: true
date: 2023-03-21 15:55:00 UTC
tags: TIL,linux,systemd
canonical_url: https://www.zufallsheld.de/2023/03/21/til-that-you-can-use-asterisks-in-systemctl-status/
---

I wanted to check if some services where running on a machine. The names of the services all start with `integration@`, e.g. `integration@foobar`.

So to check for all the services, I simply ran `systemctl status integration@*` and it worked:

```
● integration@identity.service - integration App identity
   Loaded: loaded (/etc/systemd/system/integration@identity.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-03-21 14:52:48 CET; 1h 54min ago
 Main PID: 262723 (node)
    Tasks: 20 (limit: 24707)
   Memory: 112.2M
   CGroup: /system.slice/system-integration.slice/integration@identity.service
           ├─262723 /usr/bin/node lib/main.js run health,identity

● integration@crypto.service - integration App crypto
   Loaded: loaded (/etc/systemd/system/integration@crypto.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-03-21 14:32:19 CET; 2h 14min ago
 Main PID: 242900 (node)
    Tasks: 20 (limit: 24707)
   Memory: 107.7M
   CGroup: /system.slice/system-integration.slice/integration@crypto.service
           ├─242900 /usr/bin/node lib/main.js run health,crypto

```

Pretty nice of systemd. I also learned about systemd-escape, but that’s for another blog-post.
Productivity equals developer happiness
Published: 2023-03-21 15:54:21

I just read a blog how to avoid burnout in developers which included a survey to determine whether a developer is happy. I did not compete the survey since I am currently in school to become a full stack developer, but I was curious on these tips to increase productivity and how it can lead to developer happiness. They ensure they have not defined developer happiness but I assuming this blog is hoping these tips can help. Do you think improving developer productivity will lead to software developer happiness?
Migrating a Vite / React app from JavaScript to TypeScript
Tags: vite, typescript, javascript, tutorial
Published: 2023-03-21 15:50:17

When you first make a React app with Vite, you have the option to choose either JavaScript or TypeScript as your preferred language. but what if you start your app in JavaScript and midway through, change your mind and want to use TypeScript instead? well in that case you have two options:

## 1. Make a new TypeScript app and copy everything from your old app to the new one

- Copy any changes you've made and the lines for any package you've installed under `dependencies` and `devDependencies` from the `package.json` file in your old app to your new app's `package.json` file and run `npm install` to install them.

- Copy your `App.jsx` and `main.jsx` files to your new app and change the extension to `.tsx`

- In `main.tsx` add `as HTMLElement` after `document.getElementById('root')`
```typescript
...
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
...
```
- Copy everything else like utility functions and static resources to the new app

- Copy all the changes you've made to the config files of any other package you've installed over to the config files in your new project

- Copy the component files, change the file extension from `.jsx` to `.tsx`, and modify them to work with TypeScript

## 2. Make a new TypeScript app but copy the needed files back to your old app instead

- Change the extension of your `App.jsx` and `main.jsx` to `.tsx`

- In `main.tsx` add `as HTMLElement` after `document.getElementById('root')`
```typescript
...
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
...
```
- In the `index.html` file, find the line `<script type="module" src="/src/main.jsx"></script>` and change `main.jsx` to `main.tsx`

- Install TypeScript packages
```
npm install -D typescript @types/react @types/react-dom
```
- Copy these files from your new app to your old one
```
tsconfig.json
tsconfig.node.json
src/vite-env.d.ts
```
- Change the extension of the `vite.config.js` file from `.js` to `.ts`

- Change the extension of your components from `.jsx` to `.tsx` and modify them to work with TypeScript

🎉 In the end, cross your fingers, run your app, and hope everything works!

Source: [Discussion on Vite GitHub](https://github.com/vitejs/vite/discussions/6799)
Generate Sanitized Email Hash (as Integer)
Tags: cfml, coldfusion, java
Published: 2023-03-21 15:50:07

While reviewing the logs of failed contact form submissions, I identified a couple email address variations that were exploiting some [Gmail features](https://gmail.googleblog.com/2008/03/2-hidden-ways-to-get-more-from-your.html) in an attempt to bypass our filters.  (Gmail has a "plus" feature and ignores periods in addresses.)  A SQL query using `REPLACE` to remove all periods revealed that this comment form spammer had performed 279 attempts using 162 variations of their 15 character gmail username in an effort to circumvent our filters.  We log the full email address that was posted and, when matching via SQL solely using the email addresses, it appeared as each email address was only used 2-4 times... versus the 279 obfuscated attempts.

To better identify & highlight abusers via SQL queries, an `EmailHash (INT)` column has been added to the database table. When searching or logging the email address, the value is sanitized (remove `+` string and `.` from the username) and then a java [hashCode](https://www.w3schools.com/java/ref_string_hashcode.asp) is generated. Using integers to join database records is much faster than using varchar and has lower storage requirements.

While there's a very slight risk of collision, I'm not aware of any other numeric hashing solution. I've tested this on multiple ColdFusion/Lucee installations and Java's hashCode has returned consistent results regardless of platform and/or JDK. I've used `hashCode` in some other ColdFusion applications and even have some other blog posts regarding it:
- [Hash strings to INT using Java](https://dev.to/gamesover/hash-strings-to-int-using-java-n9i)
- [Caching Repetitive UDF Access to Request Scope Using Argument Stringified+Hashed Key](https://dev.to/gamesover/caching-repetitive-udf-access-to-request-scope-using-argument-stringifiedhashed-key-4fd6)

## Here's the source code.  Enjoy!

https://gist.github.com/JamoCA/b02a8e86f8f082b28ecb494d910e092d

{% gist https://gist.github.com/JamoCA/b02a8e86f8f082b28ecb494d910e092d %}
Live on Mar 30 | Containerization 102, Security, Optimization and Speed
Tags: containers, eventsinyourcity, devops, security
Published: 2023-03-21 14:59:18

Containers and Microservices are now the primary platform for many organizations, but complexity and adoptions continue to be a challenge. This month we are discussing security concerns through the lens of the platform and network because the options are vast and sometimes unclear.

**Join us live on Thursday, March 30 at 10 AM PT / 1 PM ET**, as we continue our series on containerization, diving a bit deeper to discuss the key areas to ensure container optimization and speed, such as:

- What are the security ramifications of containers?
How have platforms enabled the rise of containers and microservices?
What challenges have been introduced by containers and platforms?
What are some of the enhancements to networking, and why this improves the speed of delivery


Featuring:

Marino Wijay, Ambassador, EddieHub, Platform Advocate, Solo.io

Robert Sirchia, Head of Community Evangelism, SUSE

Moderated by Sean O'Dell, Head of Dev Rel, Cloudsmith

Register here: [https://bit.ly/402s2xv
](https://bit.ly/402s2xv)
The Price of Open Source
Tags: engineering, programming, architecture
Published: 2023-03-21 14:46:41

**_What is Open Source Software Development_**?
Open source refers to software that is made freely available to the public, along with its source code (the instructions that tell a computer how to run the software). This means that anyone can access, use, modify, and distribute the software without paying for it or asking permission from the original creator. With anyone contributing to the development of open source software, it often evolves more quickly than proprietary (closed source) software.

**_Debunking the Myth of 'Free'_**
Understanding the risk and maintainability of open source project is key while considering for custom development. The thing that excites the developer community is the easy of access / acquisition of the open source projects. Things to keep in mind with open source projects are as below

- **Maintainability** of software component as for commercial packages this would be managed on your behalf

- **Policy adherence** to ensure that compliance of managing and usage of open source projects

- **Exposure appraisal** to ensure that product team understand the risk when using the open source project and also having a close eye on the licensing term 
   
- **Patching** to keep the integrated code up to date and ensure that functionality, security, or performance are not compromised 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gd7p8lw75sxyuhihbp9f.png)


**Consideration**:
1. If building a software with multiple open source components, then effectively the legal should be having contract with the # of open source components. 
2. Copyleft Effect, forces you to distribute your whole product or service under the respective Open Source Software License (for example, see the GPLv3 License).
3. License Incompatibilities, that force you to swap out conflicting Open Source Software components to avoid license violations.
4. Security issues, that may come with Open Source Software.

Overall, open source is a powerful and important concept that helps to promote collaboration, innovation, and accessibility in the world of technology. By making software freely available and encouraging collaboration and contributions, open source helps to level the playing field and empower people around the world to use and build upon technology in new and exciting ways.

**<u>Further Reads</u>**:
1. TLDR - One of the best quick guide to understand the Do's and Dont with different licensing terms.
https://tldrlegal.com/

2. Github - State of Open Source 
https://octoverse.github.com/?ref=hackernoon.com

3. S/w Bill of Material report (SBoM)
https://www.linuxfoundation.org/research/the-state-of-software-bill-of-materials-sbom-and-cybersecurity-readiness

4. Log4J example : https://thenewstack.io/log4j-is-one-big-i-told-you-so-for-open-source-communities/
03 berufliches Vorwärtskommen: Warum möchtest du beruflich Vorwärtskommen
Tags: discuss, austausch, motivation, job
Published: 2023-03-21 14:15:38

Moin Moin,
du möchtest also beruflich Vorwärtskommen, [Karriere↗](https://www.dwds.de/wb/Karriere) machen, warum eigentlich ?

> „Warum möchtest du beruflich Vorwärtskommen“

Mich treibt unter anderem die Weiterentwicklung an. Mich stets bessern. Neu gelerntes in der Praxis anwenden. Neue Herausforderungen.

Wie sieht es bei dir aus ?
Warum möchtest du beruflich Vorwärtskommen ?

Beste Grüße,
Mustafa
How to force update a mobile app when a new version is available?
Tags: ios
Published: 2023-03-21 13:51:28

This is one of the frequently asked questions by mobile developers. And still, we find it helpful to share our experience and recommendation for this case.

First of all, let’s understand the problem. Many users may argue that you need to release the new version and App Store and Google Play will handle the distribution for all users. And users will automatically get new updates installed if the appropriate settings are ON. While in most cases this is true and you should not force your users to upgrade to every new version, there still can be cases when you have to get rid of older versions.

https://www.inconceptlabs.com/blog/force-update-mobile-app-when-new-version-available
Bitcoin Era - Results, Benefits, Reviews, Price & Where To Buy?
Tags: webdev, javascript, beginners, programming
Published: 2023-03-21 13:51:28

[Bitcoin Era](url) is very famous these days because more and simple, more are suffering from obesity or a cinch . of being too fat. Taking these supplements in the regarding a pill is the foremost method that people can do to be able to lose weight competently. When you look around, you notice there are a lot of kinds of fat burning agents in the market which are more advanced than one [](https://www.outlookindia.com/business-spotlight/bitcoin-era-reviews-2023-crypto-trading-app-bitcoinera-robot-dark-truth-exposed--news-271594)
https://melaninterest.com/pin/bitcoin-era-results-benefits-reviews-price-where-to-buy/
https://public.flourish.studio/story/1864818/ 
https://soundcloud.com/bitcoin-era-538180933/bitcoineraprice
https://www.facebook.com/events/1398171794343320/
https://www.pinterest.com/pin/1001839879587609153/
https://www.scoop.it/topic/bitcoin-era-by-bitcoin-era-9
https://twitter.com/bitcoinera21682
OSDC-2023-second-assignment
Tags: beginners, osdc
Published: 2023-03-21 13:45:27

The issues I have learned In The Second Lesson are:
 
- Dev.to - navigation using tags
-  Opening issues in git
-  Issues and pull requests
-  Sample for real project interaction for Forem
-  Git project concepts, Forking and comminting
-  Locking files - pros and cons
-  Following a project and notifications in Git
-  Ranking mechanizm of projects
-  Sturcture of Git URLs, projects/ organizations/ repos
-  3rd party packages registry
-  Open source by orgznizations
-  YAML file format

##  Adding new organizations using YAML

## Examples

- [Add links to github issues #569](https://github.com/OSDC-Code-Maven/open-source-by-organizations/pull/45)
- [Create Honolulu.yaml #57](https://github.com/OSDC-Code-Maven/open-source-by-organizations/pull/57)
- [Create govph.yaml #56](https://github.com/OSDC-Code-Maven/open-source-by-organizations/pull/56)