teleren/devto huggingface dataset:
Sorting Array In Different Languages JavaScript, Ruby, Python
Tags: javascript, python, ruby, webdev
Published: 2022-06-05 17:48:17

Some time when we solve any kind of problem we need to sort the data before perform the operation on the data every programming language provide some predefined methods to sort the data or element in ascending or descending order.

```javascript
arr[] = {4,2,5,7,3,8,1}
```

Sort in Ascending Order

```javascript
arr[] = {1,2,3,4,5,7,8};
```

Sort in Descending Order

```javascript
arr[] = {8,7,5,4,3,2,1};
```

##### Javascript

To sort number and string in JavaScript both have different manner.Sort the number in JavaScript.

```javascript
let arr = [4,2,5,7,3,8,1]

arr.sort((a,b)=>{return a-b})

console.log(arr)

//1,2,3,4,5,7,8
```

Sort the string in JavaScript is too easy you just have to call sort method.

```javascript
let string_arr = ['ad', 'ds', 'ar', 'ee']

string_arr.sort( ( a, b )  => a.localeCompare( b ) );

console.log(string_arr);

//'ad', 'ar', 'ds', 'ee'
```


##### Ruby

Sort numbers in the ruby with the help of sort method.

```ruby
arr = [3,5,4,66,22,34,12]

arr.sort!

#[3, 4, 5, 12, 22, 34, 66]

string_arr = ['ad', 'ds', 'ar', 'ee']

string_arr.sort!

#["ad", "ar", "ds", "ee"]

```


##### Python

Sort numbers in the python with the help of sort method.

```python
arr = [3,5,4,66,22,34,12]

arr.sort()

#[3, 4, 5, 12, 22, 34, 66]

string_arr = ['ad', 'ds', 'ar', 'ee']

string_arr.sort()

#["ad", "ar", "ds", "ee"]

```
How to add Fathom Analytics to your Remix.run app
Tags: tutorial, webdev, react, remix
Published: 2022-06-05 17:35:55

Building a website using the Remix.run web app framework? This tutorial will teach you how to add privacy-first analytics to your Remix site with Fathom.

{% embed https://youtu.be/AbtoSbPUx9o %}

## Try out Fathom - it's great!

I've been using Fathom for years, and am a happy paying customer. If you'd like to give it a shot, you can get $10 off of Fathom when you **use my referral link [https://usefathom.com/ref/DPSSYB](https://usefathom.com/ref/DPSSYB)** to get started.

## If you enjoyed this video

- I wrote a post when I initially adopted fathom, called [Why I switched to Fathom for analytics](https://mikebifulco.com/posts/why-fathom-analytics)
- Make sure to [subscribe to my YouTube channel](https://www.youtube.com/channel/mikebifulco)
Error: listen EADDRINUSE: address already in use XXXX
Tags: webdev, javascript, node, help
Published: 2022-06-05 17:32:26

while running the npm script (**npm start**) you may encounter the command, this basically occurs when we have previously run the file in same port, to avoid this what we have to do is----

go to the **server.js** file then
update this
Server.HTTP_PORT = WXYZ;
Server.HTTPS_PORT = ABCD;
i.e.  change WXYZ to something else and ABCD to something else

then again run **npm start**
then it will successfully get started in the updated port address.
Range Addition II
Tags: leetcode, dsa, theabbie
Published: 2022-06-05 17:30:36

You are given an `m x n` matrix `M` initialized with all `0`'s and an array of operations `ops`, where `ops[i] = [ai, bi]` means `M[x][y]` should be incremented by one for all `0 <= x < ai` and `0 <= y < bi`.

Count and return _the number of maximum integers in the matrix after performing all the operations_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/10/02/ex1.jpg)

**Input:** m = 3, n = 3, ops = \[\[2,2\],\[3,3\]\]
**Output:** 4
**Explanation:** The maximum integer in M is 2, and there are four of it in M. So return 4.

**Example 2:**

**Input:** m = 3, n = 3, ops = \[\[2,2\],\[3,3\],\[3,3\],\[3,3\],\[2,2\],\[3,3\],\[3,3\],\[3,3\],\[2,2\],\[3,3\],\[3,3\],\[3,3\]\]
**Output:** 4

**Example 3:**

**Input:** m = 3, n = 3, ops = \[\]
**Output:** 9

**Constraints:**

*   `1 <= m, n <= 4 * 104`
*   `0 <= ops.length <= 104`
*   `ops[i].length == 2`
*   `1 <= ai <= m`
*   `1 <= bi <= n`

**SOLUTION:**

    import bisect
    
    class Solution:
        def maxCount(self, m: int, n: int, ops: List[List[int]]) -> int:
            rowctr = [0 for i in range(m)]
            colctr = [0 for i in range(n)]
            for a, b in ops:
                for i in range(a):
                    rowctr[m - i - 1] += 1
                for i in range(b):
                    colctr[n - i - 1] += 1
            return (m - bisect.bisect_left(rowctr, rowctr[-1])) * (n - bisect.bisect_left(colctr, colctr[-1]))
Tunnel between hosts without public IPs
Tags: go, tunnel, vpn, p2p
Published: 2022-06-05 17:26:28

There is Teonet news.

The Teotun packet and application was published today by [Teonet](https://github.com/teonet-go).

The Teotun creates secret tunnel between hosts without public IPs using Teonet. The connection based on [TRU](https://github.com/teonet-go/tru) transport and create reliable, low latency, encrypted P2P channels between connected peers.

See the project code and description on Github:  
https://github.com/teonet-go/teotun

We are waiting your support! Please give stars to our [Teotun](https://github.com/teonet-go/teotun) and [Teonet](https://github.com/teonet-go/teonet) projects in Github.

Best regards,
Kirill Scherba
https://github.com/kirill-scherba
Python daily exercise 4: separate a string
Tags: beginners, python, string
Published: 2022-06-05 17:21:26

## Question
- Write a program to split a given string on hyphens and display each substring.

**Given**:

```python
str1 = "Emma-is-a-data-scientist"
```

**Expected Output**:
```
Displaying each substring

Emma
is
a
data
scientist
```

## My attempt
- don't know what to do, look at the hint and it ask me to use split method
- After looking up the split syntax, my first try

### Fail
```python 
str1 = "Emma-is-a-data-scientist"  
  
new_str = str1.split()
print("Displaying each substring") 
for word in new_str:  
    print(word)
```
- First, I thought that the split method will return a list, i can just iterate over it. However the output is still the original list Emma-is-a-data-scientist.
- Then I look to the [syntax](https://docs.python.org/3/library/stdtypes.html#str.split) carefully, the split method is default to separate by whitespace and now there is no white space, so the separator needs to be "-".

### Success
```python
str1 = "Emma-is-a-data-scientist"  
  
new_str = str1.split("-")  
print("Displaying each substring")  
for word in new_str:  
    print(word)
```
Exercise from [Pynative](https://pynative.com/python-string-exercise/)
10 phrases a good manager never says:
Tags: career, leadership, productivity, motivation
Published: 2022-06-05 17:13:30

(1)
"Because I say so!"

(2)
"We've always done it that way."

(3)
"That's not my problem."

(4)
"I would like your job."

(5)
"I have no feedback for you"

(6)
"You don't need to know why."

(7)
"Don't do anything without asking me first."

(8th)
"Then I'll just do it myself."

(9)
"We can't afford any mistakes here."

(10)
"I've thought of everything."


Any additions?

------------
Photo by Nick Fewings on Unsplash
How to configure Vercel deploys for a monorepo package
Tags: nextjs, vercel, monorepo, github
Published: 2022-06-05 17:08:28

Without configuration, Vercel will create a new deployment any time your repository updates, which is not ideal for monorepos.

With multiple packages, you're probably only hosting one or two on Vercel. So deploying every time any package is changed is unnecessary and might eat up your deployment quota ([100/day](https://vercel.com/docs/concepts/limits/overview) for the free plan). Luckily, Vercel makes it easy to configure deployments to only happen when a specific package is changed.

## Step 1: Navigate to Git settings

Open your Vercel project's dashboard, go to "Settings" > "Git", and scroll to "Ignored Build Step".

## Step 2: Add a Git command

If you've configured the Root Directory in Vercel to be the same package you want to trigger deploys, add the following command:

```bash
git diff HEAD^ HEAD --quiet ./
```

But if you've for some reason left the Root Directory as its default value `./`, you''ll need to use the package's absolute path instead:

```bash
git diff HEAD^ HEAD --quiet ./packages/your-package/
```

*Tip: If you're unsure what your Vercel project's Root Directory is, go to "Settings" > "General" and scroll to "Root Directory".*

## Step 3: Enjoy fewer deploys

Success! When pushing a change to *outside* of `packages/your-package`, Vercel will no longer create a new deployment.

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

But if you push a change to `packages/your-package`, Vercel will build and deploy as usual.

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

May you stay on the free plan for a little bit longer ;)
Smallest Value of the Rearranged Number
Tags: leetcode, dsa, theabbie
Published: 2022-06-05 17:00:42

You are given an integer `num.` **Rearrange** the digits of `num` such that its value is **minimized** and it does not contain **any** leading zeros.

Return _the rearranged number with minimal value_.

Note that the sign of the number does not change after rearranging the digits.

**Example 1:**

**Input:** num = 310
**Output:** 103
**Explanation:** The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. 
The arrangement with the smallest value that does not contain any leading zeros is 103.

**Example 2:**

**Input:** num = -7605
**Output:** -7650
**Explanation:** Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
The arrangement with the smallest value that does not contain any leading zeros is -7650.

**Constraints:**

*   `-1015 <= num <= 1015`

**SOLUTION:**

    class Solution:
        def smallestNumber(self, num: int) -> int:
            if num == 0:
                return num
            negative = num < 0
            num = abs(num)
            num = list(str(num))
            if negative:
                return -int("".join(sorted(num, reverse = True)))
            minDigit = min(d for d in num if d != "0")
            num.remove(minDigit)
            return int(minDigit + "".join(sorted(num)))
[Solved] Module not found: Error: Can't resolve 'react-dom/client' in ''
Tags: react, reactdom, debug, versioning
Published: 2022-06-05 16:37:36


### Problem:

Running into the following error when trying to start the development server of a `create-react-app` via `npm start`:

```
Module not found: Error: Can't resolve 'react-dom/client' in '<local_path>'
```

### Solution:

One potential issue that might be causing this issue could be versioning issues. The `index.js` file created after running `npx create-react-app` uses React version 18 but I had downgraded to React version 17 afterwards without making the necessary changes to the `index.js` file.

This issue's resolution called for having to make the following modifications to the `index.js` file:

```
import React from 'react';
// import ReactDOM from 'react-dom/client'; <- This import is only for React version 18
import { render } from 'react-dom'; // <- This is the correct import statement for React version 17
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

// const root = ReactDOM.createRoot(document.getElementById('root'));
const root = document.getElementById('root'); // <- This is the correct method call for React version 17
render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  root
);
```

Making the above changes should resolve your issue if you followed the same approach I did.

Hope this helps.

## Conclusion

Thanks for reading this blog post!

If you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.

If you found this article helpful please share it and make sure to follow me on [Twitter](https://twitter.com/Shehan_Atuk) and [GitHub](https://github.com/ShehanAT), connect with me on [LinkedIn](https://www.linkedin.com/in/shehan-atukorala-8631491a5/) and subscribe to my [YouTube channel](https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ).
Count Artifacts That Can Be Extracted
Tags: leetcode, dsa, theabbie
Published: 2022-06-05 16:30:41

There is an `n x n` **0-indexed** grid with some artifacts buried in it. You are given the integer `n` and a **0-indexed** 2D integer array `artifacts` describing the positions of the rectangular artifacts where `artifacts[i] = [r1i, c1i, r2i, c2i]` denotes that the `ith` artifact is buried in the subgrid where:

*   `(r1i, c1i)` is the coordinate of the **top-left** cell of the `ith` artifact and
*   `(r2i, c2i)` is the coordinate of the **bottom-right** cell of the `ith` artifact.

You will excavate some cells of the grid and remove all the mud from them. If the cell has a part of an artifact buried underneath, it will be uncovered. If all the parts of an artifact are uncovered, you can extract it.

Given a **0-indexed** 2D integer array `dig` where `dig[i] = [ri, ci]` indicates that you will excavate the cell `(ri, ci)`, return _the number of artifacts that you can extract_.

The test cases are generated such that:

*   No two artifacts overlap.
*   Each artifact only covers at most `4` cells.
*   The entries of `dig` are unique.

**Example 1:**

![](https://assets.leetcode.com/uploads/2019/09/16/untitled-diagram.jpg)

**Input:** n = 2, artifacts = \[\[0,0,0,0\],\[0,1,1,1\]\], dig = \[\[0,0\],\[0,1\]\]
**Output:** 1
**Explanation:** 
The different colors represent different artifacts. Excavated cells are labeled with a 'D' in the grid.
There is 1 artifact that can be extracted, namely the red artifact.
The blue artifact has one part in cell (1,1) which remains uncovered, so we cannot extract it.
Thus, we return 1.

**Example 2:**

![](https://assets.leetcode.com/uploads/2019/09/16/untitled-diagram-1.jpg)

**Input:** n = 2, artifacts = \[\[0,0,0,0\],\[0,1,1,1\]\], dig = \[\[0,0\],\[0,1\],\[1,1\]\]
**Output:** 2
**Explanation:** Both the red and blue artifacts have all parts uncovered (labeled with a 'D') and can be extracted, so we return 2. 

**Constraints:**

*   `1 <= n <= 1000`
*   `1 <= artifacts.length, dig.length <= min(n2, 105)`
*   `artifacts[i].length == 4`
*   `dig[i].length == 2`
*   `0 <= r1i, c1i, r2i, c2i, ri, ci <= n - 1`
*   `r1i <= r2i`
*   `c1i <= c2i`
*   No two artifacts will overlap.
*   The number of cells covered by an artifact is **at most** `4`.
*   The entries of `dig` are unique.

**SOLUTION:**

    class Solution:
        def digArtifacts(self, n: int, artifacts: List[List[int]], dig: List[List[int]]) -> int:
            ogctr = {}
            currctr = {}
            afmap = {}
            for i, af in enumerate(artifacts):
                a, b, c, d = af
                for x in range(a, c + 1):
                    for y in range(b, d + 1):
                        ogctr[i] = ogctr.get(i, 0) + 1
                        afmap[(x, y)] = i
            for x, y in dig:
                if (x, y) in afmap:
                    af = afmap[(x, y)]
                    currctr[af] = currctr.get(af, 0) + 1
            ctr = 0
            for af in currctr:
                if currctr.get(af, 0) == ogctr.get(af, 0):
                    ctr += 1
            return ctr
I made a 3D game in 1 LINE of CODE!
Tags: gamedev, beginners, discuss, tutorial
Published: 2022-06-05 16:22:21

I made Flappy Bird in 3D in just 1 line of code!

{% youtube ecBLWxjbwnc %}

[Subscribe](https://youtube.com/virej) for more videos!

Languages like C#, unlike Python, require basically no indentation or new lines. This allows for code, no matter how long, to be written in 1 line!
.net framework
Tags: c, charp
Published: 2022-06-05 16:20:56

---
title: .net framework
published: true
description: Just a review and note on .net framework
tags: c#, charp
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

Just revisiting the .net framework; it is a framework that allows you to build software applications across different systems, including mobile, desktop and web.

supports c#, f#, as well as c++.
but the .net core framework does the same thing but is opensource but does not support c++ yet.
I scraped the tech stacks of 2000 companies
Tags: techstacks, languages, frameworks
Published: 2022-06-05 16:14:57

I was curious about what the most common tech stacks are, specifically which languages & frameworks tech companies use. So I wrote a simple Python script that went through 2000 listings of https://himalayas.app/companies.

These are the top 10 languages and frameworks:

1. JavaScript 
2. HTML5
3. CSS 3
4. Python
5. TypeScript
6. Node.js
7. GraphQL
8. PHP
9. Java
10. Ruby

Worth mentioning might also be Go, which was on position 12 as a relative newcomer. I guess there are not many surprises here, although I was surprised how high on the list Ruby is (Ruby on Rails as a framework was number 11). I also found it interesting how popular GraphQL is as none of the companies I worked at uses it. I should take another look at the advantages and discuss it with the team.

You can view the Python code and all results at https://github.com/artisanphil/techstacks
5 cool Programming/Management links
Tags: programming
Published: 2022-06-05 16:11:09

#### 1. [Hard to work with](https://lethain.com/hard-to-work-with/)
#### 2. [We don’t have a staging environment](https://squeaky.ai/blog/development/why-we-dont-use-a-staging-environment)
#### 3. [About building Blog DB](https://modfoss.com/building-blogdb.html)
#### 4. [If you commit to nothing, you will be distracted by everything](https://jamesclear.com/mental-toughness-marathon-monks)
#### 5. [Play as a team](https://critter.blog/2022/04/15/i-know-what-is-expected-of-me-at-work/)
Convert 1D Array Into 2D Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-05 16:00:46

You are given a **0-indexed** 1-dimensional (1D) integer array `original`, and two integers, `m` and `n`. You are tasked with creating a 2-dimensional (2D) array with `m` rows and `n` columns using **all** the elements from `original`.

The elements from indices `0` to `n - 1` (**inclusive**) of `original` should form the first row of the constructed 2D array, the elements from indices `n` to `2 * n - 1` (**inclusive**) should form the second row of the constructed 2D array, and so on.

Return _an_ `m x n` _2D array constructed according to the above procedure, or an empty 2D array if it is impossible_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/08/26/image-20210826114243-1.png)

**Input:** original = \[1,2,3,4\], m = 2, n = 2
**Output:** \[\[1,2\],\[3,4\]\]
**Explanation:** The constructed 2D array should contain 2 rows and 2 columns.
The first group of n=2 elements in original, \[1,2\], becomes the first row in the constructed 2D array.
The second group of n=2 elements in original, \[3,4\], becomes the second row in the constructed 2D array.

**Example 2:**

**Input:** original = \[1,2,3\], m = 1, n = 3
**Output:** \[\[1,2,3\]\]
**Explanation:** The constructed 2D array should contain 1 row and 3 columns.
Put all three elements in original into the first row of the constructed 2D array.

**Example 3:**

**Input:** original = \[1,2\], m = 1, n = 1
**Output:** \[\]
**Explanation:** There are 2 elements in original.
It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.

**Constraints:**

*   `1 <= original.length <= 5 * 104`
*   `1 <= original[i] <= 105`
*   `1 <= m, n <= 4 * 104`

**SOLUTION:**

    class Solution:
        def construct2DArray(self, original: List[int], m: int, n: int) -> List[List[int]]:
            k = len(original)
            if k != m * n:
                return []
            for i in range(m):
                original.extend([original[i * n : (i + 1) * n]])
            return original[k:]
COVID Ruined Freelancing
Tags: freelance, opinion, discuss, career
Published: 2022-06-05 15:54:25

Is it just me or has anyone else noticed the decline in freelancing platforms since the pandemic started?

It's not even because of the massive layoffs and influx of new talent. The problem, as I see it, is that companies now see work-from-home as such a normative thing that they do not understand the difference between an employee and a contractor. 90% of the jobs I see posted read more like something you would see on a typical job board, here's a few notable gems that I've come across in just the last 24 hours alone :

- "The ideal **candidate for this position** is someone who... "
- "Candidate should be able to work on remote computer"
- "If selected, would you be comfortable working on your personal laptop?"
- "Due to state laws, our employees must have proof of vaccination (for remote contractors in another country???)"
- "...join me on becoming a founding member in my start-up."
- "...**join** our dynamic team. As a **lead** developer..."

The other 10% simply want too much for too little return. There's no middle ground anymore. I used to bang out three to five small jobs per month in my specific niche (web component development). But now jobs like these are rarely even posted, and the ones I do find are either hammered with bids in the first hour, or my obvious expertise is ignored because the client thinks they know more than the guy who's been writing code for 30 years... Some of these posts just blow my mind, here are a few stand outs :

- "Build my website ... Salary start from $550/Month ... Bachelor’s degree in computer science required"
- "Continuous self-improvement and be aware of new technologies ... (tagged with WordPress)"
- "This is not a job position, rather an idea I would like to discuss..."
- "We are looking for someone interested in working with us long term and to become part of our team ... The first job you will get will be under a contract of 5$"
- "I'm a developer ... build me a portfolio site ... I could do it myself but don't have time"
- "What is a Full Stack Developer? (proceeds to describe my own career to me in layman's terms with no project goals...)"

There has always been a certain amount of cruft to sift through when looking for jobs to bid on, but this is getting ridiculous. How is a senior-level specialist supposed to survive in this ecosystem? I don't know... maybe I'm being too picky/critical/indignant... How do you folks feel about the current state of things?
create table from array of objects in one line of code
Tags: javascript, html
Published: 2022-06-05 15:42:25

```html
<html lang=de>
  <meta charset=UTF-8>
  <title>Document</title>
 <link rel="stylesheet" 
href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
<body class=container>
  <h1>Array of objects to table</h1>
<script>
  let cities = [
  {"city": "Berlin","country": "Germany"},
  {"city": "Paris","country": "France"}]
  document.querySelector('h1').insertAdjacentHTML('afterend',
  `<table><thead><tr><th>
   ${Object.keys(cities[0]).join('<th>')}
  </thead><tbody><tr><td>${cities.map(e=>Object.values(e)
.join('<td>')).join('<tr><td>')}</table>`)
</script>
```
{% codepen https://codepen.io/FrankWisniewski/pen/bGLjoEp %}
Binary Tree Preorder Traversal
Tags: leetcode, dsa, theabbie
Published: 2022-06-05 15:30:38

Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/09/15/inorder_1.jpg)

**Input:** root = \[1,null,2,3\]
**Output:** \[1,2,3\]

**Example 2:**

**Input:** root = \[\]
**Output:** \[\]

**Example 3:**

**Input:** root = \[1\]
**Output:** \[1\]

**Constraints:**

*   The number of nodes in the tree is in the range `[0, 100]`.
*   `-100 <= Node.val <= 100`

**Follow up:** Recursive solution is trivial, could you do it iteratively?

**SOLUTION:**

    # Definition for a binary tree node.
    # class TreeNode:
    #     def __init__(self, val=0, left=None, right=None):
    #         self.val = val
    #         self.left = left
    #         self.right = right
    class Solution:
        def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
            if not root:
                return []
            left = self.preorderTraversal(root.left)
            right = self.preorderTraversal(root.right)
            return [root.val] + left + right