teleren/devto huggingface dataset:
Replace Words
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 02:30:41

In English, we have a concept called **root**, which can be followed by some other word to form another longer word - let's call this word **successor**. For example, when the **root** `"an"` is followed by the **successor** word `"other"`, we can form a new word `"another"`.

Given a `dictionary` consisting of many **roots** and a `sentence` consisting of words separated by spaces, replace all the **successors** in the sentence with the **root** forming it. If a **successor** can be replaced by more than one **root**, replace it with the **root** that has **the shortest length**.

Return _the `sentence`_ after the replacement.

**Example 1:**

**Input:** dictionary = \["cat","bat","rat"\], sentence = "the cattle was rattled by the battery"
**Output:** "the cat was rat by the bat"

**Example 2:**

**Input:** dictionary = \["a","b","c"\], sentence = "aadsfasf absbs bbab cadsfafs"
**Output:** "a a b c"

**Constraints:**

*   `1 <= dictionary.length <= 1000`
*   `1 <= dictionary[i].length <= 100`
*   `dictionary[i]` consists of only lower-case letters.
*   `1 <= sentence.length <= 106`
*   `sentence` consists of only lower-case letters and spaces.
*   The number of words in `sentence` is in the range `[1, 1000]`
*   The length of each word in `sentence` is in the range `[1, 1000]`
*   Every two consecutive words in `sentence` will be separated by exactly one space.
*   `sentence` does not have leading or trailing spaces.

**SOLUTION:**

    class Solution:
        def replaceWords(self, dictionary: List[str], sentence: str) -> str:
            dictionary = set(dictionary)
            lens = sorted([len(w) for w in dictionary])
            words = sentence.split()
            op = []
            for w in words:
                found = False
                for l in lens:
                    if w[:l] in dictionary:
                        op.append(w[:l])
                        found = True
                        break
                if not found:
                    op.append(w)
            return " ".join(op)
Figma to React
Tags: copycat, react, figma
Published: 2022-06-08 10:35:09

To build UI faster, CopyCat offers [**Figma to React**](https://www.copycat.dev/figma-to-react) conversion. Copycat's algorithms work efficiently so that your existing design will fit onto multiple layouts, and the result of your code works well. Our Artificial Intelligence deeply recognizes your components and auto-group the reusable code. As a result, your resultant code will be responsive and suitable for various screen sizes. Furthermore, our AI can read extremely complex code and reuse your actual elements to convert Figma to React. 


![Uploading image](https://uploads-ssl.webflow.com/602a49b4c90708f6641a192e/612cd1e699e5c23815eadd94_homepage-convert-graphic-p-800.png)
Widest Vertical Area Between Two Points Containing No Points
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 10:30:42

Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._

A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the maximum width.

Note that points **on the edge** of a vertical area **are not** considered included in the area.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/09/19/points3.png)​

**Input:** points = \[\[8,7\],\[9,9\],\[7,4\],\[9,7\]\]
**Output:** 1
**Explanation:** Both the red and the blue area are optimal.

**Example 2:**

**Input:** points = \[\[3,1\],\[9,0\],\[1,0\],\[1,4\],\[5,3\],\[8,8\]\]
**Output:** 3

**Constraints:**

*   `n == points.length`
*   `2 <= n <= 105`
*   `points[i].length == 2`
*   `0 <= xi, yi <= 109`

**SOLUTION:**

    class Solution:
        def maxWidthOfVerticalArea(self, points: List[List[int]]) -> int:
            n = len(points)
            points = sorted(points)
            return max([points[i + 1][0] - points[i][0] for i in range(n - 1)])
Improving security & cryptography in popular cryptocurrency wallets
Tags: cryptography, security, blockchain, cryptocurrency
Published: 2022-06-08 10:10:37

>Lots of people apply the idea that “blockchain is secure” by default to every project that has “blockchain” in its description. But in tech, you know it’s not so simple. 

From a security perspective, we often see weak points requiring **special attention in cryptocurrency ecosystems and their wallets** (read our blog post [Crypto wallets security as seen by security engineers] (https://www.cossacklabs.com/blog/crypto-wallets-security/) to 🐬 deep dive into the topic). When working with large blockchain foundations, we ensure that their ecosystem (wallets, backends, APIs, protocols) are secure. 
***
▶️ Have a look at a real-life example.

Say, there’s a blockchain foundation with a **non-custodial cryptocurrency wallet** available for millions of users as mobile applications and a web extension. 

The users, regulators, investors, etc. expect that the cryptocurrency wallet gives **the same level of security guarantees as modern financial or banking apps.**

> 💡 Since this is a non-custodial cryptocurrency wallet, special attention should be paid to protecting data on the client side and its communication with a blockchain.

This comes with the requests for: 
✔️ advanced level of protection, 
✔️ encryption for data at rest (non-custodial wallets store private keys and mnemonics), 
✔️ platform-specific security controls for all the supported platforms,
✔️ building app security into UX.

▶️ Now this looks like a job for us.
 
So, we roll up our sleeves and, using the superpower :) of our mobile apps security, [security](https://www.cossacklabs.com/solutions/security-engineering-architecture/) and [cryptography engineering](https://www.cossacklabs.com/solutions/cryptography-engineering/) services, and a cryptographic library [Themis](https://cossacklabs.com/themis), we:

🎯 assess risks and do threat modelling for the apps and backend ecosystem.
🎯 conduct a deep cryptography audit of the wallet: web extension (Chrome, Firefox, Chromium) and mobile apps (iOS, Android).
🎯 provide cryptographic enhancements and dozens of [application security](https://dev.to/cossacklabs/what-do-appsec-and-fire-extinguishers-have-in-common-5efe) improvements aligned with the “defense in depth” approach.
🎯 analyze the development process and advise [SSDLC](https://www.cossacklabs.com/solutions/product-security-ssdlc/) improvements (from further automation in CI/CD pipeline to formalizing a security roadmap).

Read the detail behind every stage in our case study [Filling cryptography and security gaps in cryptocurrency wallets](https://www.cossacklabs.com/case-studies/cryptocurrency-wallets/)🐬 to learn how these efforts resulted in web extension and mobile apps synced in their security guarantees and providing **defence in depth protection for the users’ data.** 🔐
***

{% embed https://github.com/cossacklabs/themis %}
Sum of Square Numbers
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 10:00:48

Given a non-negative integer `c`, decide whether there're two integers `a` and `b` such that `a2 + b2 = c`.

**Example 1:**

**Input:** c = 5
**Output:** true
**Explanation:** 1 \* 1 + 2 \* 2 = 5

**Example 2:**

**Input:** c = 3
**Output:** false

**Constraints:**

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

**SOLUTION:**

    import math
    
    class Solution:
        def isPerfectSquare(self, num: int) -> bool:
            beg = 0
            end = num
            while beg <= end:
                mid = (beg + end) // 2
                if mid * mid == num:
                    return True
                elif beg == end:
                    break
                elif mid * mid > num:
                    end = mid
                else:
                    beg = mid + 1
            return False
        
        def judgeSquareSum(self, c: int) -> bool:
            k = 1 + int(math.sqrt(c))
            for i in range(0, k):
                if self.isPerfectSquare(c - i * i):
                    return True
            return False
How to take neighbor key in array
Tags: php, webdev
Published: 2022-06-08 09:57:38

Hello, i need help.
I have next array
`[177] => Array
        (
            [0] => Josh
            [1] => 7
        )

    [178] => Array
        (
            [0] => Bob
            [1] => 17
        )
`
i want to enter a person's name and get a number, but how to do it (data from google sheets)
The Zen of Python by Tim Peters
Tags: python, beginners, poem, webdev
Published: 2022-06-08 09:42:04

Zen of Python is a collection of 19 "guiding principles" for writing computer programs.

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren't special enough to break the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one-- and preferably only one --obvious way to do it.

Although that way may not be obvious at first unless you're Dutch.

Now is better than never.

Although never is often better than right now.

If the implementation is hard to explain, it's a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea -- let's do more of those!
Find the Duplicate Number
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 09:30:40

Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive.

There is only **one repeated number** in `nums`, return _this repeated number_.

You must solve the problem **without** modifying the array `nums` and uses only constant extra space.

**Example 1:**

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

**Example 2:**

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

**Constraints:**

*   `1 <= n <= 105`
*   `nums.length == n + 1`
*   `1 <= nums[i] <= n`
*   All the integers in `nums` appear only **once** except for **precisely one integer** which appears **two or more** times.

**Follow up:**

*   How can we prove that at least one duplicate number must exist in `nums`?
*   Can you solve the problem in linear runtime complexity?

**SOLUTION:**

    class Solution:
        def findDuplicate(self, nums: List[int]) -> int:
            nums.sort()
            curr = nums[0]
            for num in nums[1:]:
                if num == curr:
                    return num
                curr = num
Giới thiệu về Seenee
Published: 2022-06-08 06:28:16

Seenee là kênh chuyên đánh giá về các dự án bất động sản đưa ra góc nhìn chân thực, đa chiều cho người xem. Đáp ứng đầy đủ tiêu chí khách quan về dự án, để người xem tự đưa ra quyết định đúng đắn và sáng suốt nhất. Seenee đã và sẽ đồng hành cùng các bạn trong suốt chặng đường đi tìm lựa chọn phù hợp nhất cho gia đình bạn. 
Thông tin liên hệ:
Địa chỉ: A5.09 Precia, 21 Nguyễn Thị Định, An Phú, Thủ Đức, Hồ Chí Minh, 700000. 
SĐT: +84901057888
Email: info@seenee.vn
Website: [](https://seenee.vn/)
Google map: [https://goo.gl/maps/UHLtJtpAuof4WYwb8](https://goo.gl/maps/UHLtJtpAuof4WYwb8)
Tìm hiểu thêm về Seenee tại: 
https://www.facebook.com/seenee.vn
https://www.youtube.com/channel/UCriBZIK_Y14_GzaVc_vbCSg
https://www.tiktok.com/@seenee.vn
https://www.instagram.com/seenee.vn/
https://roundme.com/@seeneevn/about
https://www.slideserve.com/seeneevn
https://linkhay.com/u/seeneevn
https://vietid.net/
https://the-dots.com/users/seenee-vn-1254746
https://mastodon.social/@seeneevn
https://osf.io/fe9r7/
https://www.mobygames.com/user/sheet/userSheetId,888576/
https://gab.com/seeneevn
https://www.ultimate-guitar.com/u/seeneevn
https://www.tetongravity.com/community/profile/seeneevn
https://telegra.ph/Gi%E1%BB%9Bi-thi%E1%BB%87u-v%E1%BB%81-Seenee-06-07
https://www.liveinternet.ru/users/seeneevn/profile/
Goal Parser Interpretation
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 09:00:47

You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G"`, `"()"` and/or `"(al)"` in some order. The Goal Parser will interpret `"G"` as the string `"G"`, `"()"` as the string `"o"`, and `"(al)"` as the string `"al"`. The interpreted strings are then concatenated in the original order.

Given the string `command`, return _the **Goal Parser**'s interpretation of_ `command`.

**Example 1:**

**Input:** command = "G()(al)"
**Output:** "Goal"
**Explanation:** The Goal Parser interprets the command as follows:
G -> G
() -> o
(al) -> al
The final concatenated result is "Goal".

**Example 2:**

**Input:** command = "G()()()()(al)"
**Output:** "Gooooal"

**Example 3:**

**Input:** command = "(al)G(al)()()G"
**Output:** "alGalooG"

**Constraints:**

*   `1 <= command.length <= 100`
*   `command` consists of `"G"`, `"()"`, and/or `"(al)"` in some order.

**SOLUTION:**

    class Solution:
        def interpret(self, command: str) -> str:
            n = len(command)
            i = 0
            op = ""
            while i < n:
                if command[i] == "G":
                    op += "G"
                    i += 1
                elif i < n - 1 and command[i:i+2] == "()":
                    op += "o"
                    i += 2
                elif i < n - 3 and command[i:i+4] == "(al)":
                    op += "al"
                    i += 4
            return op
The Lenra team
Tags: webdev, javascript, startup, management
Published: 2022-06-08 08:48:35

Because Lenra's people are worth showing :)

Learn more about Thomas our CEO :
{% embed https://www.youtube.com/shorts/ukHZfjO391U %}

Jonas, one of our fullstack developer : 
{% embed https://www.youtube.com/shorts/1-OdmEHCYmQ %}

Flavien, our SecDevOps : {% embed https://www.youtube.com/shorts/rc2oHcJDpaA %}

Stay tuned for the other ones ;)
Smallest Subtree with all the Deepest Nodes
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 08:30:37

Given the `root` of a binary tree, the depth of each node is **the shortest distance to the root**.

Return _the smallest subtree_ such that it contains **all the deepest nodes** in the original tree.

A node is called **the deepest** if it has the largest depth possible among any node in the entire tree.

The **subtree** of a node is a tree consisting of that node, plus the set of all descendants of that node.

**Example 1:**

![](https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/01/sketch1.png)

**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\]
**Output:** \[2,7,4\]
**Explanation:** We return the node with value 2, colored in yellow in the diagram.
The nodes coloured in blue are the deepest nodes of the tree.
Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is the smallest subtree among them, so we return it.

**Example 2:**

**Input:** root = \[1\]
**Output:** \[1\]
**Explanation:** The root is the deepest node in the tree.

**Example 3:**

**Input:** root = \[0,1,3,null,2\]
**Output:** \[2\]
**Explanation:** The deepest node in the tree is 2, the valid subtrees are the subtrees of nodes 2, 1 and 0 but the subtree of node 2 is the smallest.

**Constraints:**

*   The number of nodes in the tree will be in the range `[1, 500]`.
*   `0 <= Node.val <= 500`
*   The values of the nodes in the tree are **unique**.

**Note:** This question is the same as 1123: [https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/)

**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 maxDepth(self, root):
            if root:
                a = 1 + self.maxDepth(root.left)
                b = 1 + self.maxDepth(root.right)
                return max(a, b)
            return -1
        
        def subtreeWithAllDeepest(self, root: TreeNode) -> TreeNode:
            if root:
                left = self.maxDepth(root.left)
                right = self.maxDepth(root.right)
                if left > right:
                    return self.subtreeWithAllDeepest(root.left)
                elif right > left:
                    return self.subtreeWithAllDeepest(root.right)
                else:
                    return root
Laravel: Why I Love Cache:remember(‘me’, fn () => ‘I Love Laravel’);
Published: 2022-06-08 08:14:38

Today I want to share you guys about the feature that I feel impress the most when I develop the Laravel app.

After few years, I think Redis is the important part I must use for every Laravel projects that I start.

Why? The Redis is very useful like: Caching, Queue… I can not name which parts or services use it. Help me comments If you know.

Talk about the use case, It easy for you guys can imagination

Today, I have an issue to improve the Laravel Sanctum that I use to authenticate the API. But the table `personal_access_tokens` read and write too much. So, I think it worthless in the app. You can read detail here[https://dylanbaine.com/read/scaling-laravel-sanctum]. I only show you why I love Cache:remember

Instead of make the query for every request, We can use the Cache to reduce stress on the server. I think you can not see it for the small app. But for the large app and especially when you use the AWS Lambda which cost how much you use it. It save your money :)

Example:
```
// Before

return static::where('token', hash('sha256', $token))->first();

// After

return Cache::remember("PersonalAccessToken::$token", 600, function () use ($token) {
    return parent::findToken($token) ?? '_null_';
});
```

An other use case, When you make the dashboard and counting the numbers.
But every time you access the page, It will make a query. So, for example you make a count query with the table have 30 mils records. I think it will cost few seconds and I think you do not need it in the real-time.

```
// Before
$usersCount = User::count();

// After
$usersCount = Cache::remember('usersCount', $seconds, function () {
    return User::count();
});
```

Anyway, You must read this page in the Laravel document: [https://laravel.com/docs/9.x/cache#retrieve-store]
SkemaBuild: Make gRPC Development Faster and Easier
Tags: grpc, protocol, protobuf, go
Published: 2022-06-08 08:09:27

https://github.com/skema-dev/skemabuild

I just finished the preview version for a toolkit to generate grpc service code (with grpc-gateway) from protobuf file AUTOMATICALLY.

Well, in some sense, it's close to what Buf wants to do, but in a simpler way (in my opinion). You don't need the buf.yaml file, and you can use whatever git repo (github/gitlab/bitbucket/your own git server) to host your proto files (this is very important for proto management, and it's actually why I started making this tool).

Further than just a protobuf stubs automation and management tool, it provides service code generating based on another framework https://github.com/skema-dev/skema-go. So the tool is fundamentally a scaffolding toolkit for stubs and codes. All you need to do is 4 steps in your terminal. For example:
`
skbuild api init --package=org.test --service=Hello

skbuild api create -i ./Hello.proto -o ./temp --go_option "<your go_package address>"

skbuild api publish -s ./temp -u stub --version v1.0.0

skbuild service create -p <online url to your uploaded proto file>

`
Feel free to try out if interested. I'll be very appreciated if you leave any thought in the github discussion board.
GPT: Can Understand Other Language?
Published: 2022-06-08 08:03:47


Generative Pre-trained Transformer 3 (GPT-3) is an autoregressive language model that employs deep learning to create human-like prose.
It is the third-generation language prediction model in OpenAI's GPT-n series (and the successor to GPT-2).

The final version of GPT-3 has a capacity of 175 billion machine learning parameters.
GPT-3, which was launched in May 2020 and was under beta testing as of July 2020, is part of a trend in natural language processing (NLP) systems of pre-trained language representations.

So this week-end I played with GPT and I was wondering if GPT can understand something else than English.
I tried with french, I asked "What is my name?" in french "**Comment je m'appelle?**".

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



I was very surprised by the result of GPT.

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

I still don't understand how GPT get this response. 
This is the English version 😂😂.

```
what my name is christian. I currently live in Paris and I am looking to meet people. I am a strong and sincere woman. I am looking for a man with whom I could share my life. I love to laugh and enjoy life. Contact me if you are interested.
Dating in your area, dating
Read more How to make l*ve to a man well: l*ve with a man without you realizing it. How to joke with a man. I am an efficient and very talkative man.
Read more How to make l*ve to a man This question does not kill the mood but at least things are clear. 2. Kiss him. If you feel ready to make love to her, nothing better than a
Read more How to make love to a man: the video - Dr I met him a few days ago, we have seen each other for once and we like each other. We kissed and he already had tender testes.
Read more How to make love to a man without him How to make love to a man, When you want to make love to a man, you must never forget about oral s**.
Read More How to Make L*ve to a Man - wikiHow How to Make Love to a Man But how do you get a man to make love like a love god? Can a man be a god of love?
Read more How to make l*ve to a man without hurting him How to make love to a man without hurting him? The answer is clear, you have to stroke it! It's quite simple.
Read more How to make l*ve to a man without him How to make love to a man. The key to making l*ve to a man making l*ve to a man without hurting him? The answer is clear, you have to stroke it! It's quite simple.
Read more Making l*ve to a white man - Afro Say How to make l*ve to a man properly without hurting him
4:31 p.m.
```
GPT does not really understand french.. But thank to GPT to teach how to make l*ve that was very helpful 😅.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b33bxdmqye1eg2tvoye9.jpg)
Perfect Squares
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 08:00:42

Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`.

A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not.

**Example 1:**

**Input:** n = 12
**Output:** 3
**Explanation:** 12 = 4 + 4 + 4.

**Example 2:**

**Input:** n = 13
**Output:** 2
**Explanation:** 13 = 4 + 9.

**Constraints:**

*   `1 <= n <= 104`

**SOLUTION:**

    import math
    
    class Solution:
        def numSquaresRec(self, n: int) -> int:
            if n <= 1:
                return n
            if n in self.memo:
                return self.memo[n]
            root = int(math.sqrt(n))
            minSquares = float('inf')
            for k in range(1, root + 1):
                minSquares = min(minSquares, 1 + self.numSquaresRec(n - k * k))
            self.memo[n] = minSquares
            return minSquares
    
        def numSquares(self, n: int) -> int:
            self.memo = {}
            return self.numSquaresRec(n)