teleren/devto huggingface dataset:
Bathroom Security
Tags: adventofcode, algorithms, programming, javascript
Published: 2022-09-01 20:12:56

## [Advent of Code 2016 Day 2](https://adventofcode.com/2016/day/2)

## Part 1
1. Setting up the data structures
2. A double-`reduce()`r to solve the puzzle

### Setting up the data structures
My map for traversing the array based on the direction:
```js
{
  'U': [-1,0],
  'R': [0,1],
  'D': [1,0],
  'L': [0,-1]
}
```

My data structure for the `keypad`:
```js
[
  [1,2,3],
  [4,5,6],
  [7,8,9]
]
```

`5` is at `[1,1]`

### A double-`reduce()`r to solve the puzzle
The iteration portion of my algorithm in pseudocode:
```
For each line from the input
  Accumulate a code - starting as an empty string
  For each character in the line
    Accumulate a 2-element array of coordinates
    If the next location is a valid cell
      Return the coordinate of the next location
    Else
      Return the coordinate of the current location
  Add the value at the final cell to the string
```

The iteration portion of my algorithm in JavaScript:
```js
input.reduce(
  (code, line) => {
    key = line.reduce(
      (coords, path) => 
        keypad[coords[0] + map[path][0]] &&
        keypad[coords[0] + map[path][0]][coords[1] + map[path][1]]
        ? [ coords[0] + map[path][0],
            coords[1] + map[path][1] ]
        : coords,
        key.slice()
    )
    return code += keypad[key[0]][key[1]]
  }, ""
)
```

Part 1: solved!

## Part 2

### Three updates and done!

#### Update 1: Expand the data structure
My data structure for the `keypad`:
```js
[
  [0,  0,  1,  0,  0],
  [0,  2,  3,  4,  0],
  [5,  6,  7,  8,  9],
  [0, 'A','B','C', 0],
  [0,  0, 'D', 0,  0]
]
```

#### Update 2: Adjust the starting location
`5` is at `[2,0]` now

#### Update 3: Add a clause to the array-cell-checking condition - checking for a value of `0`
The iteration portion of my algorithm in JavaScript:
```js
input.reduce(
  (code, line) => {
    key = line.reduce(
      (coords, path) => 
        keypad[coords[0] + map[path][0]] &&
        keypad[coords[0] + map[path][0]][coords[1] + map[path][1]] &&
        keypad[coords[0] + map[path][0]][coords[1] + map[path][1]] !== 0
        ? [ coords[0] + map[path][0],
            coords[1] + map[path][1] ]
        : coords,
        key.slice()
    )
    return code += keypad[key[0]][key[1]]
  }, ""
)
```

Part 2: solved!

## I did it!!
- I solved both parts!
- Using nested `reduce()`s again!
- And using my tried and true array traversing techniques!

Bring on Day 1...and hopefully a strong end to an overall fun and relatively fast-solved year!
JavaScript Const re-assignment in Array with full Concepts
Tags: web3, javascript, programming, webdev
Published: 2022-09-01 19:40:36

## **Variable `Const`**
As we know that the "const" keyword was included in <u>ES6(2016)</u>. The const variable cannot be reassign the value. JavaScript const variables must be assigned a value when they are declared like this...

```js
const firstName = "Sayyed Asad";
```
But this is a general rule, always declare a variable with const unless you know that the value will change.
Use const when you declare...

1. New Array
2. New Object
3. New Function
4. New Regexp

How would be re-assignment of const in an array and what's the reason about that behind the concept of this topic? 

```js
const developers = ['Sayyed Asad', 'Nisar', 'Toqeer'];
developers[2] = 'Jonas';


```


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

So, first of all as a good experience in the JavaScript. I should be inform you here is const is manipulate. But I was still able to change one element of the Array here from Toqeer to Jonas.That is only primitive value. But an Array is not a primitive value. And so we can actually always change it so we can mutate it.


_

## **If you have some knowledge from my article. So, please follow me and share this post and like and comment on bellow this post.** 
_
Enforcing 100% adoption of a Design System is an anti-pattern and a high-risk factor for the organization
Tags: design, designsystems, digita, webdev
Published: 2022-09-01 19:38:17

In the same avenue that 100% code coverage by automation tests is not possible to achieve unless depreciating quality; enforcing 100% adoption of the design system's components will prevent the team to innovate and evolve products faster. In other words, it will affect the organization's capacity to stay competitive.

In a recent research, we found that on average highly effective design systems have 74% of adoption when compared to custom components. Also, the average lifetime of a custom component is about 1.5 months, until it's either incorporated into the design system or removed.

Well-executed design systems share common factors such as:

1. Product teams have the freedom to create custom components, experiment, measure results, and report back to the design system team

2. The design system makes the tokens available to product teams, so they still can be on-brand even building custom components

3. The Design System project adopts continuous delivery, allowing incremental improvements and frequent releases

At Rangle, we help organizations of all sizes and complexities to plan, implement and adopt Design Systems in the right way. We focus on enabling product teams to build better products faster and generate more value.

Reach out and let's talk about how to unlock your design system to generate more value and justify the investment.
What you need know to get a job with .NET 👨‍💻💜
Tags: dotnet, beginners, career, programming
Published: 2022-09-01 19:20:57

I have been working with .NET since 2017 and today I hold the position of Senior Developer in a consultancy located in Brazil.

Over the course of 6 years, I have noticed that many subjects are repeated regardless of the company, not only based on my own experiences but also by talking to friends and people I know.

That's why I decided to create the list below to help people who want to start programming with the .NET platform. I would like to make it clear that there are exceptions but overall, if you learn the concepts listed below, the chances of you passing a trainee, junior or senior interview (why not?) are very high.

## C# Basics 🍂

C# (C-Sharp) is an object-oriented programming language and it is through it that .NET applications are implemented.

C# Main Topics:

- Variables
- Conditional
- Data types
- Classes
- Interfaces
- Methods
- Encapsulation
- Polymorphism
- Heritage
- Loops
- LINQ

📌Microsoft reference: [Learn C#](https://dotnet.microsoft.com/en-us/learn/csharp)

## Rest APIs 🥏

Used for communication between servers and clients, Rest APIs are present in the vast majority of systems for Internet.

📌Microsoft reference: [Tutorial: Create a web API with ASP.NET Core
](https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-6.0&tabs=visual-studio)

## Authentication and Authorization 🔐

🙋‍♂️ Authentication (Proving that you are who you say you are)
🔓 Authorization (Permission to do something after authenticating)

📌Microsoft reference: [Authentication vs. authorization](https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-vs-authorization)

## ORM (Object-relational mapping) 🌚➡🌝 

ORM is an ever-present subject in .NET development, through which we map relational database entities to .NET objects.

The **Entity Framework Core** is the best known ORM and one of the most used in the .NET environment, it is maintained by Microsoft itself.

📌Microsoft reference: [Entity Framework documentation
](https://docs.microsoft.com/en-us/ef/)

## Messaging 📩 

A concept that defines that distributed systems can communicate through the exchange of messages (event), which are managed through a Message Broker (server).

📌Microsoft reference: [Modern .NET Messaging using MassTransit
] (https://docs.microsoft.com/en-us/events/dotnetconf-2021/modern-net-messaging-using-masstransit)

## Unit Tests 🧪

Unit tests are fast compared to functional tests, can be run at the press of a button, and don't necessarily require any knowledge of business rules. Passing or failing the test rests with the test performer, not the individual.

📌Microsoft reference: [Unit test basics](https://docs.microsoft.com/en-us/visualstudio/test/unit-test-basics?view=vs-2022)

## Conclusion 🔚

As I said above, these are some of the main subjects that can help anyone looking to get a job with .NET.

Remembered something that could help? Please don't forget to comment!🙋‍♂️
Cover image by [Canva](https://www.canva.com/)
Progress! - Week 8 Develop Carolina
Published: 2022-09-01 18:35:06

Last week we had to demo progress on our umbrella projects in the Develop Carolina apprenticeship. The few workshops previously were geared towards scaffolding a project and how to pick tech stacks for your project. This demo was just the 'hello world' version of our project just to demo the tech stack working on a base level. 

Shaun and I decided to go with the ReactJS for the frontend, Node/Express for our backend/api and MongoDB for our database. We felt this was a smart move due to the fact most of our experience has been with Javascript so keeping the language across the stack was a no brainer. Considering we still have to learn the tech used on our teams at our host companies, didn't want to have any information overload 😄. However, we did decide to go with mongodb because we both wanted to learn about NoSQL databases. 

So MERN is pretty much our 'foundation' stack. There are a few other technologies we decided that will play a critical role in our app. One of those is Socket.IO. Our app requires real time communication and thats what socket.io provides,it'ss a library that enables real time communication between clients in the browser and the server. Again, this is a pretty new tool for us and we both have to dive in and research this. I feel like this will probably be the most challenging aspect of the project because the whole app is based around this 'real time' communication and we are both really new to this. Although I feel this is challenging, I am super excited about learning about real time communication and more importantly the socket.io library.

So far, I'm happy with the progress that my partner Shaun and I have made so far in our project. We still have a lot to learn and more progress to make but i'm excited to start writing features for our project!
Xent.fx Devblog 1
Published: 2022-09-01 17:53:05

'ello everyone!

I know not a lot of people follow my dev.to or even are interested in Xent/Xent.fx at the moment, so I decided im going to make a devblog to keep people up to date on progress.

as of now, Xent.fx has its main code about 2%ish done.

With Xent.fx being back on my schedule, I'd like to give some code examples of Xent.fx so... here you go!


```XFX
$DEFINES
@use[core] %%Core is a typespace and cannot be used directly.
%%&sudo[core](in) "in" %%You would uncomment this and use it if you wanted console inputs or a general input stream
&sudo[core](out) "out" %% provides you with basically the javascript console
$MAINSPACE
cspace _[]{
  in#log(`hello world`);
}
```
When to use Server-to-Server OAuth app and when to use OAuth app ?
Tags: programming, api, oauth, zoom
Published: 2022-09-01 17:26:10

If you are asking yourself should I use a Server-to-Server OAuth app or a “standard” OAuth app? 🤔 

I would suggest you to start by asking yourself the following:


![Who will use use my app? People or Programs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdn1itq0j0tybakf5s8v.png)

So,  if you are planning on developing an app that is going be used by **_people_** you should definitely be looking into an **[OAuth app. ](https://marketplace.zoom.us/docs/guides/build/oauth-app/)**

And what I mean by this is that if you want your application to make _API calls to the Zoom endpoints_ on behalf of 3rd party users, you will need an **OAuth app** that the end user will authorize to grant your application permission to access their data.

Now, if your application is going to be used by _**programs**_ and if it is going to make API calls on behalf of the account and has **NO**  user interaction, then you are looking into a **[Server-to-Server OAuth app](https://marketplace.zoom.us/docs/guides/build/server-to-server-oauth-app/)**





Let’s put it in simple words now:

📝 **Server-to-Server OAuth**:
* If your application calls the Zoom APIs on behalf of the account without users interaction
* Internal applications that work with own data rather than a users data
* Use cases: Internal reporting tools, Managing internal users, Managing accounts.


👥 **OAuth app**:
* Applications created for 3rd party users
* Applications authorized and used by people
* Use cases: Scheduling apps, Tele-health apps, Learning Management system apps.


Learn more about the different app types available in the Zoom Marketplace here: https://marketplace.zoom.us/

For more questions about this topic, join us at the Zoom Developer Forum: https://devforum.zoom.us/

Happy coding! 😀
React Native Interview Questions
Tags: reactnative, javascript
Published: 2022-09-01 17:11:48

---
title: React Native Interview Questions
published: true
description: Commonly asked react native interview questions
tags: reactnative, javascript
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

> **How to build Custom Native Modules?**

* Create module class extending ReactContextBaseJavaModule
* Export module name and functions annotated as @ReactMethod 
* In MainPackage file, add newly created module into module list. 
* Import NativeModule from react-native package in JS file. 
* More Info [here](https://reactnative.dev/docs/native-modules-android#create-a-calendar-native-module)




> **How to build Custom Native UI Components?**

* Create ViewManager Subclass
* Expose properties annotated as @ReactProps 
* Register your ViewManager Class
* Create your View Class
* More Info [here](https://reactnative.dev/docs/native-components-android)


> **Number of threads in React Native?**

* Javascript thread which handles business logic, api calls, touch events
* Main thread which handles Native logic


> **What are common Performance bottleneck or issues?**

* Usage of large ScrollView instead of ListView or FlatList 
* Unnecessary rerendering without UI changes
* Improper usage of Keys. Read more [here](https://dev.to/rv90904/importance-of-key-in-react-3l2n)
* Heavy Animation (Animation are calculated on Javascript thread). Use `useNativeDriver` as true to use native apis and move computation to main thread


> **How to Improve Performance?**

* use hermes engine
* use inline requires for expensive or large module 
for eg : 
```
let VeryExpensive = null;
const Home = () => {
    const onClickHandler = () => {
        if (VeryExpensive == null) {
            VeryExpensive = require('./VeryExpensive').default;
        }
    }
}
```


> **What is hermes?**

* Opensource JS engine optimized for React Native
* Help in improved App startup time, decreased memory usage and smaller app size
* More info [here](https://reactnative.dev/docs/hermes)


> **What is Turbomodules?**

* Rearchitecture of Native Module system
* Will help in facilitate more efficient typesafe Communication between JS and Native without React Native bridge


> **How to Animated stuff?**

* Use inbuild Animated apis for declarative animation between Input and Output
* Use LayoutAnimation API for all animating Views in next render cycle. Mostly used for flexbox layout update
How to get phone number information using Python ?
Tags: python, opensource, programming, machinelearning
Published: 2022-09-01 17:00:16

In order to get details of any mobile number. We can use an inbuilt library of python i.e "phonenumbers". And modules present inside this library are "geocoder", "carrier" and "timezone".



**Step 1**: install the library "phonenumbers"
```python
!pip install phonenumbers
```
<br>
**Step 2**: import library

```python
import phonenumbers
```
<br>
**Step 3**: take user's phone number and parse it

```python
a = input("Enter Phone Number: ")
# Parsing
ph_no = phonenumbers.parse(a)
```
<br>
**Step 4**: 
geocoder : this module is used to get the location of your number.

```python
from phonenumbers import geocoder
# Location Of Number
print(geocoder.description_for_number(ph_no,"en"))
```
<br>
**Step 5**:
carrier : this module is used to get the service_provider's name of your number.

```python
from phonenumbers import carrier
# Service_Provider's Name
print(carrier.name_for_number(ph_no,"en"))
```
<br>
**Step 6**:
timezone : this module tells the timezone of the phone number.

```python
from phonenumbers import timezone
# Timezone
print(timezone.time_zones_for_number(ph_no))
```
<br>

Full Code : [Click Here](https://github.com/CatalystsReachOut/python/blob/master/PythonScripts/GetPhoneNumberDetails/main.py)
What is the use of Mixins?
Tags: dart, flutter, programming, beginners
Published: 2022-09-01 16:54:30

Hi guys, today I am going to share the use of mixins in dart programming. So before going to make any delay let’s start.

## What is Mixins?

Dart does not support multiple inheritances, but Maxins gives us the ability to achieve multiple inheritances. To put it simply, mixins are classes that allow us to borrow methods and variables without extending the class. Dart uses a keyword called `with `for this purpose.

**For example,**
We have a Car class and we want to access Brand and Model both clasess methods in Car class at this situation mixins give us the opportunity to achieve this using the keyword `with`.


![Mixins example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgp0xe8uqcjbej6vrbog.jpg)

```dart
class Brand {
  void getBrand({required String carBrand}) {
    print("Brand name : $carBrand");
  }
}

class Model {
  void getModel({required String carModel}) {
    print("Model : $carModel");
  }
}

class Car extends Brand with Model { //calling Brand and Model both classes at the same time 
  void getCarDetails({required String carBrand, required String carModel}) {
    print("Hey, here is my car details");
    getBrand(carBrand: carBrand);
    getModel(carModel: carModel);
    
  }
}

void main() {
  Car car = Car();
  car.getCarDetails(carBrand: 'Tex', carModel: '1976 Cadillac Coupe DeVille');
}

```

It is my hope that you now understand the concept of mixins in Dart, thank you for reading.
asdf Basics & Cheat Sheet
Tags: asdf, rvm, nvmrc, webdev
Published: 2022-09-01 16:42:38

---
title: asdf Basics & Cheat Sheet
published: true
description: Cheat sheet for asdf
tags: asdf, rvm, nvmrc, webdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--tqOUF28J--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsoe2kzsjjr826ajxh91.png
---

**One tool to rule them all.**

***`asdf`*** is a tool version manager. Manage each of your project runtimes with a single CLI tool and command interface.

### Features:
- Large ecosystem of existing runtimes & tools. Simple API to add support for new tools as you need!
- Support for existing config files .nvmrc, .node-versions, .ruby-version for smooth migration!
- .tool-versions to manage all your tools, runtimes and their versions in a single, sharable place.
- Supports Bash, ZSH, Fish & Elvish with completions available.
- Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows.

### Install ASDF
```sh
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
```

#### Add to ~/.bashrc
```sh
. $HOME/.asdf/asdf.sh
```

```sh
. $HOME/.asdf/completions/asdf.bash
```

### Basic commands

* Update asdf

```sh
asdf update
```

* Add plugin (eg.: ruby)

```sh
asdf plugin add ruby
```

* List all languages plugin:

```sh
asdf plugin list
```
or
```sh
asdf plugin list --urls
```

* Update plugins

```sh
asdf plugin update --all
```
or
```sh
asdf plugin update ruby
```

* Remove plugin
```sh
asdf plugin remove ruby
```

* List all possible ruby versions

```sh
asdf list-all ruby
```

* Install a ruby version using ruby plugin
```sh
asdf install ruby 3.0.0
```

* List all installed ruby versions
```sh
asdf list ruby
```

* Check current version of language plugin

```sh
asdf current ruby
```

* Check current version of all languages plugin

```sh
asdf current
```

* Check installation path of plugin version

```sh
asdf where
```

* Change plugin version locally/globally

```sh
asdf local ruby 3.0.0
```
or
```sh
asdf global ruby 2.7.2
```

### Remove asdf

* Remove following from `~/.bashrc`

```sh
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
```

* Run: 

```sh
rm -rf ${ASDF_DATA_DIR:-$HOME/.asdf} ~/.tool-versions
```
The easiest way to understanding Quick Sort🔥
Tags: algorithms, dsa, sorting, quicksort
Published: 2022-09-01 16:14:18

Quick sort has been an algorithm I was afraid of learning😢, pretending that it is too hard and require too much time to understand it, but now here I am explaining to you how straight forward it is using a short article written for it. Simple recursive function is required to fully understand quick sort.

The first thing to know is that we use pivot point while comparing to other items in order to get the left side and right side of pivot and repeat the process. With that information we can get started.

Here I use  pivotIndex variable to compare item on that index with other items, swapIndex variable to track index which will be swapped with small item found on the left side of pivot, and variable i to loop through all items and know which current item we are comparing to the pivot.

swapIndex is initially set at the same index of pivotIndex. Whenever item smaller than pivot item is found, we increment 1 to swapIndex and swap item on swap index with current item we are on while looping with i. After that we swap pivot item with item on swap index.

# Swap function

```
function swapFn(array, firstIndex, secondIndex) {
    let temp = array[firstIndex]
    array[firstIndex] = array[secondIndex]
    array[secondIndex] = temp
}
```

Below is the algorithm that we use recursively to sort elements with Quick sort.
Quick Sort algorithm
Step 1: Start 
Step 2: Declare variables pivotIndex, swapIndex and i. 
Step 3: Initialize variables pivotIndex←0 swapIndex← pivotIndex, i= pivotIndex +1

Step 4: Repeat the steps until i≤array.length-1 
		if array[i] is less than array[pivotIndex] then
			swapIndex++
			swapFn(array[swap], array[i])
	swapFn(array[swapIndex], array[pivotIndex])
Step 5: OUTPUT swapIndex
Step 6: Stop

# Swap Index where pivot will be swapped function

```
function pivotFn(array, pivotIndex=0, endIndex=array.length-1) { 
    let swapIndex = pivotIndex
    for (let i = pivotIndex + 1; i <= endIndex; i++) {
        if (array[i] < array[pivotIndex]) {
            swapIndex++
            swapFn(array, swapIndex, i)
        }
    }
    swapFn(array, pivotIndex, swapIndex)
    return swapIndex
}
```
Follow along this diagram to see how it works.



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


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

**function quickSort(array, left=0, right=array.length-1) {
    if(left < right) {
        let pivotIndex = pivot(array, left, right)
        quickSort(array, left, pivotIndex-1)
        quickSort(array, pivotIndex+1, right)
    }
    return array
}**

Test Quick sort by calling this function: quickSort([4,6,1,7,3,2,5])

To sum up, We’ve got the left side with red color and the right side with green color. We do the same above process to both sides by comparing items with the pivot and swap if item is less than the pivot and then swap the pivot with the swap index.