teleren/devto huggingface dataset:
Minimize Maximum Pair Sum in Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 15:30:35

The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs.

*   For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`.

Given an array `nums` of **even** length `n`, pair up the elements of `nums` into `n / 2` pairs such that:

*   Each element of `nums` is in **exactly one** pair, and
*   The **maximum pair sum** is **minimized**.

Return _the minimized **maximum pair sum** after optimally pairing up the elements_.

**Example 1:**

**Input:** nums = \[3,5,2,3\]
**Output:** 7
**Explanation:** The elements can be paired up into pairs (3,3) and (5,2).
The maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.

**Example 2:**

**Input:** nums = \[3,5,4,2,4,6\]
**Output:** 8
**Explanation:** The elements can be paired up into pairs (3,5), (4,4), and (6,2).
The maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.

**Constraints:**

*   `n == nums.length`
*   `2 <= n <= 105`
*   `n` is **even**.
*   `1 <= nums[i] <= 105`

**SOLUTION:**

    import heapq
    
    class Solution:
        def minPairSum(self, nums: List[int]) -> int:
            minheap = []
            maxheap = []
            for num in nums:
                heapq.heappush(minheap, num)
                heapq.heappush(maxheap, -num)
            n = len(nums)
            smallest = heapq.nlargest(n // 2, minheap)
            biggest = heapq.nlargest(n // 2, maxheap)
            return max(smallest[i] - biggest[i] for i in range(n // 2))
Installing git-filter-repo on windows
Tags: git
Published: 2022-06-30 22:29:49

---
title: Installing git-filter-repo on windows
published: true
date: 2022-06-09 15:27:01 UTC
tags: git
canonical_url: https://jessehouwing.net/installing-git-filter-repo-on-windows/
---

 ![Installing git-filter-repo on windows](https://jessehouwing.net/content/images/2022/06/OIP--1-.jpg)

I've been trying to get `git-filter-repo` to work on Windows and WSL today and it's been quite a struggle. The docs are pretty limited and call out I may have to update some values in the script itself to make things work. But doesn't spell out what to fix and how to make it work.

I ended up doing the following:

# 1. Install Python on Windows

Install [Python for Windows 3.10](https://www.python.org/downloads/windows/). And enable long-path-support. I did not use the store version, though it should do the trick as well.

# 2. Add Python to the path

Add the path to Python and its Scrips folder to the environment.

![Installing git-filter-repo on windows](https://jessehouwing.net/content/images/2022/06/image-1.png)

# 3. Install `git-filter-repo` using pip3

```
c:\> pip3 install git-filter-repo
```

And be done with it!

It's probably not the Python way of doing things, but I can now use the tool I need. If you know a better way of solving this problem, let me know.
How to create a navbar with HTML and CSS.
Published: 2022-06-09 15:20:58

`HTML Codes`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Tech Joint is the most popular programming Teams Group for project development">
    <link href='https://unpkg.com/boxicons@2.1.2/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="/css/index.css">
    <link rel="icon" href="/img/phone_bg-removebg-preview.png">
    <title>Responsive webpage </title>
</head>
<body>
    <section id="main">
        <header>
            <p class="logo"><i class='bx bx-meteor'></i>Tech Joint </p>
             <nav>
                 <ul class="nav_links">
                     <li class="active"><a href="#main">Home</a></li>
                     <li><a href="#">Projects</a></li>
                     <li><a href="#">About</a></li>
                     <li><a href="#class">Party</a></li>
                 </ul>
             </nav>
             <a href="#" class="cta"><button>Contact</button></a>
         </header>

</body>
</html>
```
`CSS Code`
```
*{
    padding: 0;
    margin: 0;
    font-family: sans-serif;
    box-sizing: border-box;
    
}
#main {
    height:100vh;
  
    --webkit-transition: background 6s;
    background-image: url(/img/background-image.png);
    transition-delay: 2s;
    transition-duration: 3s;
 background-size: cover;
}
body {
    background: black;
}


li, a, button {
    font-weight: 500;
    font-size: 16px;
    color: #edf0f1;
    text-decoration: none;

}

header {
    display: flex;
    justify-content:flex-end;
    align-items: center;
    padding: 30px 10%;
    background:rgba(255, 250, 250, 0.164);
    position: sticky;
}
.logo {
    cursor: pointer;
    margin-right: auto;
    font-weight: bolder;
  
    font-size: 3vh;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(to right, #f32170,
            #ff6b08, #cf23cf, #eedd44);
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
}

.nav_links{
    list-style: none;
}
.nav_links li {
    display: inline-block;
    padding: 0px 20px;

}
.nav_links li a {
    transition:  all 0.3s ease 0s;
    font-weight: bold;
}

.nav_links li a:hover{
  color:white;
  background:#015958;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition:  all 0.3s ease 0s;
  font-weight: bold;
  padding: 9px 25px;
}
.nav_links li .active{
    color:black;
}
button {
    margin-left: 20px;
    padding: 9px 25px;
    background-color: rgba(0,136, 169, 1);
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition:  all 0.3s ease 0s;
    font-weight: bold;
}

button:hover {
    background-color: rgba(0, 136,169, 0.8);
}

```
From building to selling - EP.15
Tags: webdev, javascript, html, css
Published: 2022-06-09 15:12:54

Welcome to day fifteen of the Crossroad build journey! Kind of a bonus day! 😬 

This series follows my journey of indie hacking a product from building to selling. If you missed day fourteen, you could [check it out here](https://www.twankrui.com/blog/from-building-to-selling-14). 

## We’ve launched! Sort of! 😅

Have you really launched without submitting your product on Product Hunt? Well, I had so many things left on my to-do list that I decided to treat today as a soft launch for the people who followed this journey and do the big interwebs reveal tomorrow.

I still had to shoot the video for the website and prepare the entire launch (copy, images, etc.) for the Product Hunt launch. However, I woke up sneezing and coughing my brains out, so it took until noon until I was able to shoot the video.

I briefly thought about launching a little later in the day and updating the site throughout the day, but if you want to do something, don’t half-ass it. Besides, no one will send me hate mail for launching a day later.

And while I was a little annoyed with myself this morning, I am glad I took another day to put everything in order!

## Shot a video! 🎥

Lights? Camera? Action! For the landing page, it was the idea from the start to show visitors how easy and fast it is to use the template.

For some reason, I thought it was a great idea to do it in a single take, and after 30 or so takes, I finally had a spontaneous and complete video! Not that there is anything wrong with editing a video, but I know that would have cost me yet another day.

After uploading it to YouTube and adding it to the website, I must say that I am thrilled with how it turned out. I believe having any video going over your product is better than not having any video. It’s just the way people consume content in this day and age.

Let me come back from that just a little. You have to ensure that the video and audio quality are decent/professional.

## Scheduled the Product Hunt launch! 👋

With the video in place, all left was to create the pictures and write the copy for the PH launch. Having done it quite recently for [useaffiliates.com](http://useaffiliates.com/), I already had a good idea about what I needed to do.

And after uploading all the content and media, I scheduled [crossroadsui.com](http://crossroadsui.com/) to be launched on Product Hunt tomorrow! Please, if you have some time tomorrow, head over to [producthunt.com](http://producthunt.com/) and give Crossroads an upvote, and if you want to be a real MVP, leave a comment. ♥

Thanks again for reading this build log. Have a great day, and I hope to see you on Product Hunt tomorrow!

With love,

Twankrui
Find Bottom Left Tree Value
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 15:00:47

Given the `root` of a binary tree, return the leftmost value in the last row of the tree.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/12/14/tree1.jpg)

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

**Example 2:**

![](https://assets.leetcode.com/uploads/2020/12/14/tree2.jpg)

**Input:** root = \[1,2,3,4,null,5,6,null,null,7\]
**Output:** 7

**Constraints:**

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

**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 findBottomLeftValue(self, root: Optional[TreeNode]) -> int:
            nodes = [(root, 0, 0)]
            leftmost = (0, 0, root.val)
            while len(nodes) > 0:
                curr, w, l = nodes.pop()
                if curr:
                    if l > leftmost[1] or (l == leftmost[1] and w < leftmost[0]):
                        leftmost = (w, l, curr.val)
                    nodes.append((curr.left, w - 1, l + 1))
                    nodes.append((curr.right, w + 1, l + 1))
            return leftmost[2]
Degree program or bootcamp?
Tags: anonymous, discuss
Published: 2022-06-09 14:34:17

_This is an anonymous post sent in by a member who does not want their name disclosed. Please be thoughtful with your responses, as these are usually tough posts to write. Email sloan@dev.to if you'd like to leave an anonymous comment or if you want to ask your own anonymous question._ 

***

Hey, all. I was just wondering if I should pursue a degree program or skip that and go straight to a bootcamp. I'd really like to get things started soon, but I don't know the pros/cons of either choice. Would love some guidance on which is more beneficial in the long run. Thank you.
Check if the Sentence Is Pangram
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 14:30:40

A **pangram** is a sentence where every letter of the English alphabet appears at least once.

Given a string `sentence` containing only lowercase English letters, return `true` _if_ `sentence` _is a **pangram**, or_ `false` _otherwise._

**Example 1:**

**Input:** sentence = "thequickbrownfoxjumpsoverthelazydog"
**Output:** true
**Explanation:** sentence contains at least one of every letter of the English alphabet.

**Example 2:**

**Input:** sentence = "leetcode"
**Output:** false

**Constraints:**

*   `1 <= sentence.length <= 1000`
*   `sentence` consists of lowercase English letters.

**SOLUTION:**

    class Solution:
        def checkIfPangram(self, sentence: str) -> bool:
            return len(set(sentence)) == 26
I want to know a lot.
Tags: devops, java, database, linux
Published: 2022-06-09 14:27:32

Hi, i'm sumon. I'm certified on RHCE, RHCSA, CCNA, MCSA, MTCNA. Actually, i want to know everythings about earth, that's mean what i see and hear i want to know that. I have knowledge on DevOps, Virtualization, Full stack, IoT, Python, PHP, Java, SQL, Oracle Database, Firebase and anothers somethings. People call me a robot 😁.
ChefConf22 is scheduled for Sept 11-14
Tags: security, cloud, devops, discuss
Published: 2022-06-09 14:19:46


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tjugbuke197lm66unsp.png)ChefConf enters it's 11 year this time in Boston, MA or from the privacy of your own home --this hybrid event will showcase the best and brightest humans from the devops industry. We set up this user conference to highlight best practices, demos, new features, talk with industry leaders, and round table discussions for your use case. 
We currently have an open call for speakers [https://sessionize.com/chefconf-2022-with-progress360/]
I would love to read your proposal or talk suggestion around cloud security, compliance, devops, devsecops, CSPM. 
This is a user event with the goal to provide you recipes, cookbooks, and tools to make your lives easier or at least more secure.
Hexagon v2 released 🎉
Tags: kotlin, opensource, news, microservices
Published: 2022-06-09 14:05:03

Check the latest changes on the [project website](https://hexagonkt.com) or its [GitHub repository](https://github.com/hexagonkt/hexagon).

This is an important milestone in the project. It switches from using DSL transformation to adapters constructions,
to define a common handlers pipeline used by all adapters. 

To wrap up the project history:

1. Fork of Spark to support Java 8.
2. Port to Kotlin (first Hexagon version). Still heavily based on Spark.
3. V2, complete rewrite to be based on middlewares, as opposed to before/after filters like Spark.

This design change makes easier to add new adapters as proved
with Netty's brand new adapter.

These changes come with a performance boost, however there is still room for improvement here (stay tuned for more performance gains here).

Also, the new design improves reusability by letting users define their own Callbacks, Handlers and Predicates.

The documentation and examples are not yet fully ported, but works on this regard are ongoing.

Please take a look at the changes, share your feedback... and spread the word!

Thanks for your support 🙂
Unique Morse Code Words
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 14:00:43

International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:

*   `'a'` maps to `".-"`,
*   `'b'` maps to `"-..."`,
*   `'c'` maps to `"-.-."`, and so on.

For convenience, the full table for the `26` letters of the English alphabet is given below:

\[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."\]

Given an array of strings `words` where each word can be written as a concatenation of the Morse code of each letter.

*   For example, `"cab"` can be written as `"-.-..--..."`, which is the concatenation of `"-.-."`, `".-"`, and `"-..."`. We will call such a concatenation the **transformation** of a word.

Return _the number of different **transformations** among all words we have_.

**Example 1:**

**Input:** words = \["gin","zen","gig","msg"\]
**Output:** 2
**Explanation:** The transformation of each word is:
"gin" -> "--...-."
"zen" -> "--...-."
"gig" -> "--...--."
"msg" -> "--...--."
There are 2 different transformations: "--...-." and "--...--.".

**Example 2:**

**Input:** words = \["a"\]
**Output:** 1

**Constraints:**

*   `1 <= words.length <= 100`
*   `1 <= words[i].length <= 12`
*   `words[i]` consists of lowercase English letters.

**SOLUTION:**

    class Solution:
        def toMorse(self, s):
            morseMap = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
            return "".join([morseMap[ord(c)-ord('a')] for c in s])
        
        def uniqueMorseRepresentations(self, words: List[str]) -> int:
            return len(set([self.toMorse(w) for w in words]))
Como usar o cherry-pick no GIT
Tags: git, cherrypick
Published: 2022-06-09 13:59:03

Olá pessoal, tudo bem?

Recentemente tive a necessidade de publicar no ambiente de produção algumas alterações, já aprovadas, que estavam em uma branch, porém outras alterações de outros desenvolvedores ainda estavam aguardando aprovação. Para ajudar a visualizar o cenário, temos as branches:

- master
- homolog
- branch_joao
- branch_outro_dev


![Cenário atual das branches](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19vuhmej9c0nf0jzfks5.png)

Como podem perceber, a aprovação ocorre em cima da branch `homolog`. 

Enfim, outro desenvolvedor e eu criamos `Pull Requests` para `homolog `. 

Até então, somente a minha alteração foi aprovada e por conta do `Pull Request` do colega, eu não poderia criar a `Pull Request` de `homolog` para `master`, pois a alteração dele iria para produção.

Pois bem, o `git` tem o comando [cherry-pick](https://git-scm.com/docs/git-cherry-pick), que aplica alterações de acordo com `commits ` já existentes. Ou seja, cherry picking é o ato de escolher um commit de uma branch e aplicá-la em outra.

Os comandos abaixo foram realizados no Git Bash.

Obtem-se o `commit id` desejado de `branch_joao`

```
git log
```

```
commit 0b90d263bd15107c09955d735e8a671f537b4e4e
Author: João Oliveira 
Date:   Wed Jun 8 12:11:46 2022 -0300

Substituição de EmailHelper por MailKitHelper
```


Obtem-se o código mais recente de todas as branches
```
git fetch --all     
```



Cria-se uma nova branch baseada na `master`.
```
git checkout -b branch_joao_nova master      
```

Aplica-se a alteração desejada na branch. No meu caso, seria o id abaixo.
```
git cherry-pick 0b90d263bd15107c09955d735e8a671f537b4e4e
```

Executa-se o `push `com as alterações para a branch remota.
```
git push -u origin branch_joao_nova
```

Para exemplificar, as branches ficaram assim. Suprimi homolog e branch_outro_dev para facilitar a leitura.

![Nova branch e cherry pick](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8cnkopsoq2gawl4c4ys.png)


Depois disso, cria-se um `Pull Request` para a master e a situação foi contornada.

Claro, neste exemplo não foi abordado nenhum conflito entre `commits` ou outro tipo de situação que envolveria uma maior intervenção.

Espero ter ajudado.

Referências:
[https://git-scm.com/docs/git-cherry-pick](https://git-scm.com/docs/git-cherry-pick)
[https://www.atlassian.com/git/tutorials/cherry-pick](https://www.atlassian.com/git/tutorials/cherry-pick)
react/redux app data caching
Tags: discuss, dev, webdev
Published: 2022-06-09 13:51:13

---
title: react/redux app data caching
published: true
description: react/redux data caching
tags: discuss, dev, webdev
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

How do you implement data caching in react/redux app?
SQLite vs PostgreSQL
Tags: postgres, sql, database
Published: 2022-06-09 13:47:05

😲Suddenly, we’ve discovered that SQLite works much faster in some situations than PostgreSQL. 

We tried to compare the speed of SQLite and PostgreSQL during the simplest operations of inserting, updating and extracting data from a spreadsheet.

You should know that SQLite is a single file, while PostgreSQL is a whole server with many additional functions.
As we can see, the speed of SQLite due to its simplicity significantly exceeds PostgreSQL. For example:

- The insertion speed is 10 times higher.
- The sampling rate turned out to be 30 times higher.
- The update rate is almost identical to PostgreSQL.

That’s why we can conclude that SQLite will be an excellent choice if you need a database to store a small amount of data and do not need to do complex manipulations.

You can find the results of our tests here https://github.com/dev-family/sqlite-bench
How many time to stay in an IT company as m middle developer?
Published: 2022-06-09 13:35:53

How many time to stay in an IT company as developer? Currently I'm working in a product company(20 devs employess) with main 1.5 year and I have the possibility to move to an outsourcing company(more that 5000 devs employess) with increasing salary 1/2.5 from current company, while current company offers 2x salary but working as team lead. It's my first company as developer, I'm really confused. Current company learned me a lot of new things, but there are problems with architecture, managers, which put sticks in the wheels, mostly there are seniors, but I can't learn from them as they are old in their stack, but is offering freedom in case of decisions, tech used, I can add new techs in company.
I want to grow professional and I don't know that to choice and in other hand outsourcing company I think that will limit me as creational personal, but offer opportunity to learn different things from other peoples.
Sqrt(x)
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 13:30:41

Given a non-negative integer `x`, compute and return _the square root of_ `x`.

Since the return type is an integer, the decimal digits are **truncated**, and only **the integer part** of the result is returned.

**Note:** You are not allowed to use any built-in exponent function or operator, such as `pow(x, 0.5)` or `x ** 0.5`.

**Example 1:**

**Input:** x = 4
**Output:** 2

**Example 2:**

**Input:** x = 8
**Output:** 2
**Explanation:** The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.

**Constraints:**

*   `0 <= x <= 231 - 1`

**SOLUTION:**

    class Solution:
        def mySqrt(self, x: int) -> int:
            beg = 0
            end = x
            while beg <= end:
                mid = (beg + end) // 2
                if mid * mid <= x and (mid + 1) * (mid + 1) > x:
                    return mid
                elif mid * mid > x:
                    end = mid
                else:
                    beg = mid + 1
Resolution for npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Published: 2022-06-09 13:19:57


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibgkbgdj7nitz1gbfrym.png)
#OpenCV – Background Subtraction in a camera feed 🎦 using MOG2
Tags: englishpost, codesample, mog2
Published: 2022-06-09 15:25:03

---
title: #OpenCV – Background Subtraction in a camera feed 🎦 using MOG2
published: true
date: 2022-06-09 13:18:40 UTC
tags: EnglishPost,CodeSample,EnglishPost,MOG2
canonical_url: 
---

Hi !

Yesterday I wrote a post about how to remove the background from my camera feed. To remove the background, I used a python library “cvzone”.

While talking with some friends, someone asked about using some of the out-of-the-box features included in OpenCV, like MOG2 or KNN. So I read a little about them and I get this sample up and running.

![OpenCV Remove Background from Camera using MOG2](https://brunocapuano.files.wordpress.com/2022/06/opencv-remove-background-from-camera-using-mog2.gif?w=350)

As you can see the output is completely different than before, and not even close to what I’m looking for. And it makes sense, the official OpenCV documentation explains how this method works here: [[How to Use Background Subtraction Methods](https://docs.opencv.org/4.x/d1/dc5/tutorial_background_subtraction.html)].

_Background subtraction (BS) is a common and widely used technique for generating a foreground mask (namely, a binary image containing the pixels belonging to moving objects in the scene) by using static cameras._

_As the name suggests, BS calculates the foreground mask performing a subtraction between the current frame and a background model, containing the static part of the scene or, more in general, everything that can be considered as background given the characteristics of the observed scene._

![Background_Subtraction_Tutorial_Scheme.png](https://docs.opencv.org/4.x/Background_Subtraction_Tutorial_Scheme.png)

_Background modeling consists of two main steps:_

1. _Background Initialization;_
2. _Background Update._

_In the first step, an initial model of the background is computed, while in the second step that model is updated in order to adapt to possible changes in the scene._

And the sample code:

{% gist https://gist.github.com/elbruno/5bec8b2cdfb3841f674bb42d70a12608 %}

Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *