teleren/devto huggingface dataset:
Community Bonding Period at CircuitVerse — Google Summer of Code 2022
Tags: opensource, webdev, programming, career
Published: 2022-06-12 04:24:10

## What is the Community Bonding Period?
Every successful project has been planned before. Similarly, in this phase contributors connect with respective mentors and discuss the project deliverables, plan the project and finalize the scope of the Project.

### My experience
I was so happy after getting selected for GSoC, especially with CircuitVerse. After getting selected, our private channel was created and all the contributors, mentors, and OA were there. We had our first meeting on 26th May, and we were welcomed by our mentors, I meet my mentors Aboobacker, Pavan, Samiran, Ayan, Ruturaj, and contributors Pulkit, Devjit, and Aman. It was a pleasure meeting them all. We had a great meeting and our mentors told us about the flow of the GSoC at CircuitVerse.

After that, for each project separate private channels were created and I had my meeting with my project’s mentors. We set up the project board on GitHub for tracking the project's progress and discussing the project scope, and deliverables. I asked them to let me start the coding on 1st June, as I was aware of the codebase.

## My progress and learning (1st June — 10th June)
I start with the feature of integrating Gitlab Authentication for CircuitVerse. I used omniauth-gitlab gem for that. I made an application in gitlab for testing and configured the .env file. I configured and implemented all the required things correctly referencing other OAuth implementations but there was an unknown error. I had a meeting with my mentor and the problem was the omniauth gem version. I will be working on updating that in the upcoming week and hopefully will complete my first task of the Project.

I also started with implementing SSO(Single Sign-On) in CircuitVerse. I used devise_saml_authenticatable gem for it. I created WIP(Work in Progress) PR for that. I was facing an issue on the IDP side. I will be completing this PR after gitlab-implementation. I am researching it meanwhile…

### Work done so far
- [Gitlab integration](https://github.com/CircuitVerse/CircuitVerse/pull/3154)
- [SSO integration](https://github.com/CircuitVerse/CircuitVerse/pull/3167)

## Conclusion
I feel the best experience of my engineering life as it is my first work experience. The whole vibe of the community is so supportive. I learned a lot. I don’t know after getting selected for GSoC I feel responsible and am working accordingly. I am researching more, reading more, and learning more. It is the vibe of GSoC. Overall, I had a great week.
1845. Leetcode solution in CPP
Tags: cpp
Published: 2022-06-12 04:00:47

```

class SeatManager {
 public:
  SeatManager(int n) {}

  int reserve() {
    if (minHeap.empty())
      return ++num;

    const int minNum = minHeap.top();
    minHeap.pop();
    return minNum;
  }

  void unreserve(int seatNumber) {
    minHeap.push(seatNumber);
  }

 private:
  priority_queue<int, vector<int>, greater<>> minHeap;
  int num = 0;
};
```
Evaluate Reverse Polish Notation
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 04:00:43

Evaluate the value of an arithmetic expression in [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).

Valid operators are `+`, `-`, `*`, and `/`. Each operand may be an integer or another expression.

**Note** that division between two integers should truncate toward zero.

It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.

**Example 1:**

**Input:** tokens = \["2","1","+","3","\*"\]
**Output:** 9
**Explanation:** ((2 + 1) \* 3) = 9

**Example 2:**

**Input:** tokens = \["4","13","5","/","+"\]
**Output:** 6
**Explanation:** (4 + (13 / 5)) = 6

**Example 3:**

**Input:** tokens = \["10","6","9","3","+","-11","\*","/","\*","17","+","5","+"\]
**Output:** 22
**Explanation:** ((10 \* (6 / ((9 + 3) \* -11))) + 17) + 5
= ((10 \* (6 / (12 \* -11))) + 17) + 5
= ((10 \* (6 / -132)) + 17) + 5
= ((10 \* 0) + 17) + 5
= (0 + 17) + 5
= 17 + 5
= 22

**Constraints:**

*   `1 <= tokens.length <= 104`
*   `tokens[i]` is either an operator: `"+"`, `"-"`, `"*"`, or `"/"`, or an integer in the range `[-200, 200]`.

**SOLUTION:**

    class Solution:
        def evalRPN(self, tokens: List[str]) -> int:
            stack = []
            for t in tokens:
                if t in { '+', '-', '*', '/' }:
                    op2 = stack.pop()
                    op1 = stack.pop()
                    if t == '+':
                        stack.append(op1 + op2)
                    elif t == '-':
                        stack.append(op1 - op2)
                    elif t == '*':
                        stack.append(op1 * op2)
                    elif t == '/':
                        stack.append(int(op1 / op2))
                else:
                    stack.append(int(t))
            return stack.pop()
860. Leetcode solution in Javascript
Tags: javascript
Published: 2022-06-12 03:58:37

```
var lemonadeChange = function(bills) {
    
    let five = 0 , ten = 0
    for(let i = 0 ; i < bills.length ; i++){
    
        if(bills[i] === 5){
    
            five++
        }else if(bills[i] === 10){
    
            if(five >= 1){
    
                five--	// Give change 5 element 
                ten++
            }else{
    
                return false
            }
        }else{
    
            if(five >= 1 && ten >= 1){
    	// Give priority to  5 + 10
                five--
                ten--
            }else if(five >= 3 && ten === 0){
    	// use  3 * 5
                five -= 3
            }else{
    
                return false
            }
        }
    }
    return true
};
```
2299. Strong Password Checker II
Tags: algorithms, leetcode, programming, computerscience
Published: 2022-06-12 03:53:34


A password is said to be strong if it satisfies all the following criteria:

It has at least 8 characters.
It contains at least one lowercase letter.
It contains at least one uppercase letter.
It contains at least one digit.
It contains at least one special character. The special characters are the characters in the following string: "!@#$%^&*()-+".
It does not contain 2 of the same character in adjacent positions (i.e., "aab" violates this condition, but "aba" does not).
Given a string password, return true if it is a strong password. Otherwise, return false


```
class Solution {
public:
    bool strongPasswordCheckerII(string &p) {
        if(p.size()<8) return false;
        bool low =false, upper = false,digit = false,special =false;
        for(auto it:p){
            if(it>='a' and it<='z')low = true;
        else if(it>='A' and it<='Z')upper = true;
        else if(isdigit(it)) digit = true;
            else special = true;
            
        }
        //check the 6th condition 
        for(int i=0;i+i<p.size();i++) if(p[i] == p[i+1]) return false;
        if(low and upper and special and digit) return true;
        return false;
        
    }
};
```
1695 leetcode solution in JavaScript
Tags: javascript
Published: 2022-06-12 03:50:00


#leetcode
```
var maximumUniqueSubarray = function(nums) {
    let nmap = new Int8Array(10001), total = 0, best = 0
    for (let left = 0, right = 0; right < nums.length; right++) {
        nmap[nums[right]]++, total += nums[right]
        while (nmap[nums[right]] > 1)
            nmap[nums[left]]--, total -= nums[left++]
        best = Math.max(best, total)
    }
    return best
};
```
#challenge
Here is the link for the problem:
https://leetcode.com/problems/maximum-erasure-value/
Construct Binary Tree from Inorder and Postorder Traversal
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 03:30:37

Given two integer arrays `inorder` and `postorder` where `inorder` is the inorder traversal of a binary tree and `postorder` is the postorder traversal of the same tree, construct and return _the binary tree_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/02/19/tree.jpg)

**Input:** inorder = \[9,3,15,20,7\], postorder = \[9,15,7,20,3\]
**Output:** \[3,9,20,null,null,15,7\]

**Example 2:**

**Input:** inorder = \[-1\], postorder = \[-1\]
**Output:** \[-1\]

**Constraints:**

*   `1 <= inorder.length <= 3000`
*   `postorder.length == inorder.length`
*   `-3000 <= inorder[i], postorder[i] <= 3000`
*   `inorder` and `postorder` consist of **unique** values.
*   Each value of `postorder` also appears in `inorder`.
*   `inorder` is **guaranteed** to be the inorder traversal of the tree.
*   `postorder` is **guaranteed** to be the postorder traversal of the tree.

**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 getRoot(self, p, q):
            return max((i for i in range(p, q)), key = lambda x: self.valIndex[self.inorder[x]])
        
        def buildTreeRec(self, p, q):
            if p < q:
                root = TreeNode()
                currRoot = self.getRoot(p, q)
                root.val = self.inorder[currRoot]
                if currRoot > p:
                    root.left = TreeNode()
                    root.left = self.buildTreeRec(p, currRoot)
                if currRoot < q - 1:
                    root.right = TreeNode()
                    root.right = self.buildTreeRec(currRoot + 1, q)
                return root
        
        def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]:
            n = len(postorder)
            self.inorder = inorder
            self.valIndex = {}
            for i, item in enumerate(postorder):
                self.valIndex[item] = i
            return self.buildTreeRec(0, n)
Best Static Website Hosting for free
Tags: beginners, tutorial, productivity, devops
Published: 2022-06-12 03:10:36

- Netlify :- https://www.netlify.com/
- **Vercel** :- https://vercel.com/
- Heroku :- https://heroku.com/
- **Replit** :- https://replit.com/
- Surge :- https://surge.sh/
- GitHub Pages :- https://pages.github.com/
- GitLab Pages :- https://about.gitlab.com/stages-devops-lifecycle/pages/
- Glitch :- https://glitch.com/
- Vultr :- https://www.vultr.com/
- Render :- https://render.com/
- Stormkit :- https://www.stormkit.io/
- Deta :- https://www.deta.sh/
- Fly.io :- https://fly.io/
H-Index II
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 03:00:44

Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper and `citations` is sorted in an **ascending order**, return compute the researcher's `h`**\-index**.

According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): A scientist has an index `h` if `h` of their `n` papers have at least `h` citations each, and the other `n − h` papers have no more than `h` citations each.

If there are several possible values for `h`, the maximum one is taken as the `h`**\-index**.

You must write an algorithm that runs in logarithmic time.

**Example 1:**

**Input:** citations = \[0,1,3,5,6\]
**Output:** 3
**Explanation:** \[0,1,3,5,6\] means the researcher has 5 papers in total and each of them had received 0, 1, 3, 5, 6 citations respectively.
Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.

**Example 2:**

**Input:** citations = \[1,2,100\]
**Output:** 2

**Constraints:**

*   `n == citations.length`
*   `1 <= n <= 105`
*   `0 <= citations[i] <= 1000`
*   `citations` is sorted in **ascending order**.

**SOLUTION:**

    import bisect
    
    class Solution:
        def hIndex(self, citations: List[int]) -> int:
            n = len(citations)
            for h in range(n, -1, -1):
                if h <= n - bisect.bisect_left(citations, h):
                    return h
Sort Colors
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 02:30:34

Given an array `nums` with `n` objects colored red, white, or blue, sort them **[in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

We will use the integers `0`, `1`, and `2` to represent the color red, white, and blue, respectively.

You must solve this problem without using the library's sort function.

**Example 1:**

**Input:** nums = \[2,0,2,1,1,0\]
**Output:** \[0,0,1,1,2,2\]

**Example 2:**

**Input:** nums = \[2,0,1\]
**Output:** \[0,1,2\]

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 300`
*   `nums[i]` is either `0`, `1`, or `2`.

**Follow up:** Could you come up with a one-pass algorithm using only constant extra space?

**SOLUTION:**

    class Solution:
        def partition(self, nums, x, beg, end):
            i = beg
            for j in range(beg, end):
                if nums[j] <= x:
                    nums[i], nums[j] = nums[j], nums[i]
                    i += 1
            return i
        
        def sortColors(self, nums: List[int]) -> None:
            n = len(nums)
            i = self.partition(nums, 1, 0, n)
            self.partition(nums, 0, 0, i)
            return nums
Immediately Invoked Function Expression
Tags: javascript, beginners
Published: 2022-06-12 02:03:38

I was struggling to understand IIFE's so I wrote about it. Hopefully this article helps you understand IIFE's in a Jiffy.

Immediately Invoked Functions are **Functions that execute as soon as it is defined**.

Here is an Example:

```
(function(){
    console.log('This is an Immediately Invoked Function');
})();
```
It has two enclosing parenthesis , the First parenthesis makes the function an expression and the last parenthesis tells the JavaScript compiler to invoke or call the function Immediately.

The Expression evaluates itself to execute the function.

Is that it? 

### what are the uses of IIFE?


### 1. Avoid Calling Variables in the global scope and create closures
With IIFE being executed immediately it means variable names will not conflict.This is better in situations where we don't need to use the function again.

However, with the introduction of let and const variable keywords we can differentiate between global and block scope variables.

Hope this explained the concept in an easy , beginner-friendly manner.Cheers
Check If N and Its Double Exist
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 02:00:46

Given an array `arr` of integers, check if there exists two integers `N` and `M` such that `N` is the double of `M` ( i.e. `N = 2 * M`).

More formally check if there exists two indices `i` and `j` such that :

*   `i != j`
*   `0 <= i, j < arr.length`
*   `arr[i] == 2 * arr[j]`

**Example 1:**

**Input:** arr = \[10,2,5,3\]
**Output:** true
**Explanation:** N `= 10` is the double of M `= 5`,that is, `10 = 2 * 5`.

**Example 2:**

**Input:** arr = \[7,1,14,11\]
**Output:** true
**Explanation:** N `= 14` is the double of M `= 7`,that is, `14 = 2 * 7`.

**Example 3:**

**Input:** arr = \[3,1,7,11\]
**Output:** false
**Explanation:** In this case does not exist N and M, such that N = 2 \* M.

**Constraints:**

*   `2 <= arr.length <= 500`
*   `-10^3 <= arr[i] <= 10^3`

**SOLUTION:**

    class Solution:
        def checkIfExist(self, arr: List[int]) -> bool:
            arr.sort(reverse = True, key = lambda x: abs(x))
            exists = set()
            for num in arr:
                if num * 2 in exists:
                    return True
                exists.add(num)
            return False
A Cool Way To Learn JavaScript
Tags: javascript, beginners, webdev, codenewbie
Published: 2022-06-12 01:56:23

Hello World !
I'm [S Soumyakanta](https://twitter.com/s_soumyakanta).
It's quite difficult to learn coding for a newbie, by watching video tutorials from Youtube. As a beginner I wasted several weeks by watching Javascript video tutorials. Because you can't learn coding by only watching videos. When it comes to practice my device regularly hangs due to low memory. I can't use both Chrome and V S Code for a long time.  

It's important to learn things in a structured way. After all I found [Free Code Camp ](https://freecodecamp.org) on web and Youtube. As a beginner I was making the same mistake again and again. But from the Free Code Camp's Youtube channel I found [Per Harald Borgen's](https://twitter.com/perborgen) free beginner level full Javascript course. It was a interactive course on [Scrimba.com](https://scrimba.com/).


It was important for me to practice online to boost my journey. I know you may ask their are many online code learning platform's then why Scrimba !!! then here are some answers why as newbie should learn JS from Scimba's [Learn JavaScript for free](https://scrimba.com/learn/learnjavascript) !

**1. If you haven't a high end device:-** For this course you only need a PC(1 GB Ram),Internet and a browser(Chrome suggested). Your journey will not stop due to lack of resources. You don't need to run several application to start.

**2.If you're a beginner:-**I struggled hard to learn code by self ,in the way to my web development journey. I love to learn things by doing practical application in real world. This course will teach you Javascript by creating three projects like Passenger counter app, Blackjack game and a chrome extension.

**3.Fun and Zero distraction:-** While learning from Youtube as a newbie I was so distracted by other recommended videos. In this course it was simple for me to stay focused. This course is amazingly delivered by Mr. Per . You will learn several things by doing challenges in this course.




**My Suggestion to beginners:-**After searching several platform's  I would suggest to learn Javascript from Scrimba. Don't waste so much time on watching random videos one after one to learn. It's a 7 hour long video and I assure you that you're  going to enjoy it.


**For Mr. Per:-** Hello sir ! thanks for your teaching. Your course impacted my life. It's my humble gratitude to you. Thanks a lot.


I hope this review will help you to start journey in a productive way.




If you are reading this I will happy that we will stay connected. Here is my social media links below  !

[Me on Twitter](https://twitter.com/s_soumyakanta)
[Me on Linkedin](https://linkedin.com/in/s-soumyakanta)
Install and use multiple Bundler versions
Tags: ruby, bundler, webdev, todayilearned
Published: 2022-06-12 01:33:52

As of Bundler v2.3 (when using RubyGems v3.3+), Bundler will automatically use the `BUNDLED WITH` version specified in `Gemfile.lock` when running the `bundle install` command. If the specified version of Bundler is not available, [it will be downloaded and installed](https://bundler.io/blog/2022/01/23/bundler-v2-3.html).

<!-- more -->

```bash
$ bundler -v
Bundler version 2.3.15

$ tail -2 ./example/Gemfile.lock
BUNDLED WITH
   2.1.4

$ (cd ./example && bundler -v)
Bundler version 2.1.4
```

If you can't upgrade to v2.3, there is a workaround. You will have to install the correct version of Bundler manually, but then you can use the `_version_` syntax.

```bash
$ bundler _2.1.4_ -v
Bundler version 2.1.4
```
Concatenation of Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 01:30:38

Given an integer array `nums` of length `n`, you want to create an array `ans` of length `2n` where `ans[i] == nums[i]` and `ans[i + n] == nums[i]` for `0 <= i < n` (**0-indexed**).

Specifically, `ans` is the **concatenation** of two `nums` arrays.

Return _the array_ `ans`.

**Example 1:**

**Input:** nums = \[1,2,1\]
**Output:** \[1,2,1,1,2,1\]
**Explanation:** The array ans is formed as follows:
- ans = \[nums\[0\],nums\[1\],nums\[2\],nums\[0\],nums\[1\],nums\[2\]\]
- ans = \[1,2,1,1,2,1\]

**Example 2:**

**Input:** nums = \[1,3,2,1\]
**Output:** \[1,3,2,1,1,3,2,1\]
**Explanation:** The array ans is formed as follows:
- ans = \[nums\[0\],nums\[1\],nums\[2\],nums\[3\],nums\[0\],nums\[1\],nums\[2\],nums\[3\]\]
- ans = \[1,3,2,1,1,3,2,1\]

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 1000`
*   `1 <= nums[i] <= 1000`

**SOLUTION:**

    class Solution:
        def getConcatenation(self, nums: List[int]) -> List[int]:
            n = len(nums)
            return [nums[i % n] for i in range(2 * n)]
postmaps.js: maxDataZoom
Tags: protomaps, unvt
Published: 2022-06-12 01:14:49

postmaps.js でオーバーズームを正しく効かせるために、ベクトルタイル側の maxzoom を知らせるためには、maxDataZoom を設定すれば良いことがわかりました。

[デモサイト](https://x.optgeo.org/proton/#18/36.08469/140.19806)

## 情報源
ソースコードを GitHub で検索して見つけました。検索文字列は 14 です。protomaps のサービスが maxzoom を 14 にしていると知っていたからです。

```typescript
    let maxDataZoom = o.maxDataZoom || 14;
```
https://github.com/protomaps/protomaps.js/blob/c30bec880a7228ae53de9f5c88f9c789579f7f71/src/view.ts#L228

## 動的なスタイル設定
protomaps.js では、width や color に (z, f) を引数とする関数を渡せるので、それを使って色々ためしています。

### 道路の太さをランダムで設定

```javascript
{
  dataLayer: 'road',
  symbolizer: new protomaps.LineSymbolizer({
    color: 'gray',
    width: (z, f) => {
      return Math.random() * 4
    }
  })
},
```
https://github.com/optgeo/proton/blob/main/docs/index.html#L50-L58

### ポリゴンの塗色をランダムで設定

```javascript
{
  dataLayer: 'building',
  symbolizer: new protomaps.PolygonSymbolizer({
    fill: (z, f) => {
      return ['yellow', 'blue'][Math.floor(Math.random() * 2)]
    }
  })
}
```
https://github.com/optgeo/proton/blob/main/docs/index.html#L59-L66

## 謝辞・出典
protomaps.js をオープンソースで開発している皆様に敬意と共感を持っています。

地理院地図 Vector タイルのドキュメントは https://github.com/gsi-cyberjapan/gsimaps-vector-experiment にあります。
Maximum Frequency Stack
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 01:00:43

Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.

Implement the `FreqStack` class:

*   `FreqStack()` constructs an empty frequency stack.
*   `void push(int val)` pushes an integer `val` onto the top of the stack.
*   `int pop()` removes and returns the most frequent element in the stack.
    *   If there is a tie for the most frequent element, the element closest to the stack's top is removed and returned.

**Example 1:**

**Input**
\["FreqStack", "push", "push", "push", "push", "push", "push", "pop", "pop", "pop", "pop"\]
\[\[\], \[5\], \[7\], \[5\], \[7\], \[4\], \[5\], \[\], \[\], \[\], \[\]\]
**Output**
\[null, null, null, null, null, null, null, 5, 7, 5, 4\]

**Explanation**
FreqStack freqStack = new FreqStack();
freqStack.push(5); // The stack is \[5\]
freqStack.push(7); // The stack is \[5,7\]
freqStack.push(5); // The stack is \[5,7,5\]
freqStack.push(7); // The stack is \[5,7,5,7\]
freqStack.push(4); // The stack is \[5,7,5,7,4\]
freqStack.push(5); // The stack is \[5,7,5,7,4,5\]
freqStack.pop();   // return 5, as 5 is the most frequent. The stack becomes \[5,7,5,7,4\].
freqStack.pop();   // return 7, as 5 and 7 is the most frequent, but 7 is closest to the top. The stack becomes \[5,7,5,4\].
freqStack.pop();   // return 5, as 5 is the most frequent. The stack becomes \[5,7,4\].
freqStack.pop();   // return 4, as 4, 5 and 7 is the most frequent, but 4 is closest to the top. The stack becomes \[5,7\].

**Constraints:**

*   `0 <= val <= 109`
*   At most `2 * 104` calls will be made to `push` and `pop`.
*   It is guaranteed that there will be at least one element in the stack before calling `pop`.

**SOLUTION:**

    from collections import Counter
    
    class FreqStack:
    
        def __init__(self):
            self.freq = Counter()
            self.maxfreq = 0
            self.freqgrp = {}
    
        def push(self, val: int) -> None:
            newfreq = self.freq[val] + 1
            self.freq[val] = newfreq
            self.maxfreq = max(self.maxfreq, newfreq)
            self.freqgrp[newfreq] = self.freqgrp.get(newfreq, []) + [val]
    
        def pop(self) -> int:
            val = self.freqgrp[self.maxfreq].pop()
            if len(self.freqgrp[self.maxfreq]) == 0:
                self.maxfreq -= 1
            self.freq[val] -= 1
            return val
    
    
    # Your FreqStack object will be instantiated and called as such:
    # obj = FreqStack()
    # obj.push(val)
    # param_2 = obj.pop()