teleren/devto huggingface dataset:
Exposing GKE PODs to Apigee
Tags: googlecloud, kubernetes, apigee, cloud
Published: 2022-06-10 06:05:23

https://www.linkedin.com/posts/mahmoudrabie2004_didabryouabrknowabrthat-google-cloud-activity-6940905239856222209-sh-L?utm_source=linkedin_share&utm_medium=member_desktop_web

Google recently supported an organization that wanted to 𝙚𝙭𝙥𝙤𝙨𝙚 𝙞𝙩𝙨 𝙂𝙤𝙤𝙜𝙡𝙚 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙀𝙣𝙜𝙞𝙣𝙚 (𝙂𝙆𝙀) backend 𝙗𝙚𝙝𝙞𝙣𝙙 𝘼𝙥𝙞𝙜𝙚𝙚 𝙓. A 𝙦𝙪𝙞𝙩𝙚 𝙘𝙤𝙢𝙢𝙤𝙣 𝙖𝙧𝙘𝙝𝙞𝙩𝙚𝙘𝙩𝙪𝙧𝙚, which most of the users delivering 𝙢𝙤𝙙𝙚𝙧𝙣 𝙬𝙚𝙗 𝙖𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣𝙨 on Google Cloud tend to build upon.

You could connect 𝘼𝙥𝙞𝙜𝙚𝙚 𝙖𝙣𝙙 𝙂𝙤𝙤𝙜𝙡𝙚 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙀𝙣𝙜𝙞𝙣𝙚 (𝙂𝙆𝙀) backends so that you 𝙬𝙤𝙣’𝙩 𝙝𝙖𝙫𝙚 𝙩𝙤 𝙥𝙚𝙧𝙛𝙤𝙧𝙢 𝙇7 𝙧𝙤𝙪𝙩𝙞𝙣𝙜 in 𝙗𝙤𝙩𝙝 𝙘𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩𝙨. 

This will likely help you to:
(1) ⏱️ 𝙨𝙖𝙫𝙚 𝙩𝙞𝙢𝙚 (managing way fewer configurations) and 
(2) 🚀 reach 𝙗𝙚𝙩𝙩𝙚𝙧 𝙥𝙚𝙧𝙛𝙤𝙧𝙢𝙖𝙣𝙘𝙚𝙨.

When a request comes in, Apigee:
(1) reads the Target Endpoint value and 
(2) queries Cloud DNS to get the IP of the application pod. 
(3) reaches the pod directly, with no need for additional routing to be configured on the K8s cluster.

Thanks to Federico Preli and Luca Prete for releasing their demo as open-source
https://github.com/google/gke-cloud-dns-tls/

𝘾𝙤𝙣𝙣𝙚𝙘𝙩𝙞𝙣𝙜 𝘼𝙥𝙞𝙜𝙚𝙚 𝙩𝙤 𝙂𝙆𝙀 𝙪𝙨𝙞𝙣𝙜 𝙝𝙚𝙖𝙙𝙡𝙚𝙨𝙨 𝙨𝙚𝙧𝙫𝙞𝙘𝙚𝙨 𝙖𝙣𝙙 𝘾𝙡𝙤𝙪𝙙 𝘿𝙉𝙎
https://cloud.google.com/blog/products/application-modernization/connecting-apigee-to-gke-using-headless-services-and-cloud-dns

𝙎𝙩𝙖𝙮 𝙩𝙪𝙣𝙚𝙙 𝙗𝙮 𝙛𝙤𝙡𝙡𝙤𝙬𝙞𝙣𝙜
https://www.linkedin.com/feed/hashtag/didAbRyouAbRknowAbRthat/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69syegbzxdqb465wtmbc.jpg)
Maximum Depth of N-ary Tree
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 06:00:47

Given a n-ary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

_Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples)._

**Example 1:**

![](https://assets.leetcode.com/uploads/2018/10/12/narytreeexample.png)

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

**Example 2:**

![](https://assets.leetcode.com/uploads/2019/11/08/sample_4_964.png)

**Input:** root = \[1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14\]
**Output:** 5

**Constraints:**

*   The total number of nodes is in the range `[0, 104]`.
*   The depth of the n-ary tree is less than or equal to `1000`.

**SOLUTION:**

    """
    # Definition for a Node.
    class Node:
        def __init__(self, val=None, children=None):
            self.val = val
            self.children = children
    """
    
    class Solution:
        def maxDepth(self, root: 'Node') -> int:
            if root:
                mdepth = 1
                if root.children:
                    for c in root.children:
                        curr = 1 + self.maxDepth(c)
                        mdepth = max(mdepth, curr)
                return mdepth
            return 0
I wanna become an AI expert.
Tags: machinelearning, ai, tutorial, beginners
Published: 2022-06-10 05:53:55

Hi, Everyone. Hope you are doing well.
In these days, AI is most trending skill and it tends out more and more engineers turn into this technical field. I am so excited with AI technology and wanna to start my journey to become a AI Engineer.

I believe and hope there are many AI expert here and if someone suggest me anything to good start, it will be helpful for me.
Of course, If there is anyone who want to go with me in this journey, I am always open to you.

Hope to advice from AI Gurus.
Best Regards.
Formalizing Konnakol using Haskell @ GSoC '22
Tags: gsoc, tidalcycles, haskell
Published: 2022-06-10 05:30:55

Konnakol, in South Indian Carnatic music, is the art of performing percussion syllables vocally. It is the recitation of Solkattu – the vocal syllables related to the sounds of the Mridangam, a major percussion instrument in Carnatic Music. Recognized as an art form of principle study, Konnakol is also a medium used by Carnatic musicians to convey rhythmic ideas to each other.

However, notwithstanding its importance in Carnatic music, there have not been any successful attempts in creating a system which could formalise the conventional rules of Konnakol and check whether a given rhythmic pattern fits into a fixed set of rhythmic cycles or not. Such a pattern forms a partition of the total length of the rhythmic cycles.

This project aims to formalize Korvai (cadence) and Koraippu (starting with a longer pattern and progressively performing shorter patterns) and Mohra, three main aspects of Konnakol. The system developed will be able to formalize pre-existing compositions, as well as check whether a given composition follows the conventional rules of Konnakol. This system can then be used to generate new patterns, which could, further on, be compared to one another to find the most complex ones.

The project also aims to display valid compositions using the Jathi notation, as well as use a grid design to visualize the patterns generated, where syllables of different lengths and the gaps between syllables will be displayed using different colors. This will facilitate understanding of the patterns among the partition that this composition has formed. The system developed will be integrated with the 
"Tidal Cycles” software, so that users may include Konnakol in their compositions as well. The documentation and the visualization tools provided will help TidalCyclists with no prior knowledge to develop a basic understanding about Konnakol. 

To read more about the project and to follow progress, you can visit the Google Summer of Code Project Page {% embed https://summerofcode.withgoogle.com/programs/2022/projects/Q8cce5AG %}
Sort List
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 05:30:41

Given the `head` of a linked list, return _the list after sorting it in **ascending order**_.

**Example 1:**

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

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

**Example 2:**

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

**Input:** head = \[-1,5,3,4,0\]
**Output:** \[-1,0,3,4,5\]

**Example 3:**

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

**Constraints:**

*   The number of nodes in the list is in the range `[0, 5 * 104]`.
*   `-105 <= Node.val <= 105`

**Follow up:** Can you sort the linked list in `O(n logn)` time and `O(1)` memory (i.e. constant space)?

**SOLUTION:**

    # Definition for singly-linked list.
    # class ListNode:
    #     def __init__(self, val=0, next=None):
    #         self.val = val
    #         self.next = next
    class Solution:
        def mergeTwoLists(self, list1, list2):
            if not list1 or not list2:
                return list1 or list2
            if list1.val < list2.val:
                list1.next = self.mergeTwoLists(list1.next, list2)
                return list1
            else:
                list2.next = self.mergeTwoLists(list1, list2.next)
                return list2
        
        def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]:
            if not head or not head.next:
                return head
            prev = None
            slow = head
            fast = head
            while slow and fast and fast.next:
                prev = slow
                slow = slow.next
                fast = fast.next.next
            prev.next = None
            return self.mergeTwoLists(self.sortList(head), self.sortList(slow))
Redis is redefining itself
Tags: redis, database, enterprise, discuss
Published: 2022-06-10 05:16:45

Redis is an amazing in memory #database. But that's all it used to be, a really amazing distributed hash table to get or set key value pairs. But recently while consulting for a startup I came across Redis Enterprise and it totally blew my mind away.

I have never seen a big database company totally revamp their offerings. For example, MongoDb is still trying to find a way to monetize their DB by changing the license to Server Side Public License. ElasticSearch did something similar and that's why Amazon created OpenSearch(a fork of ElasticSearch).

**What all can Redis Enterprise do?
**

They introduced bloom filter and cuckoo filter as first class citizens. Bloom filter is probably one of the most underrated yet one of the most widely used algorithm I know of. Google Chrome uses Bloom filter to check if a URL exists in their malicious URLs Dataset.

Besides that, Redis also introduced a new JSON module that let's users save any JSON objects and then allows the users to run queries on any fields.

Redis Enterprise has a lot more modules such as TimeSeries, Streams, AI and more.

The entire ecosystem is really new but it totally has the capability to replace a whole suite of document databases, #caches and indexed search systems.

The only "con" would be the pricing. It's a bit expensive and also it's not #opensource but has Redis source available License(RSAL).

I am pretty sure some companies are already working on an open sourced alternative to Redis Enterprise and various modules.

It's just amazing to see how databases are evolving. I would have never imagined someone using Redis as their main database but it's happening.

What do you think? Would you trust #Redis with your Production load?
Max Points on a Line
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 05:00:45

Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_.

**Example 1:**

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

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

**Example 2:**

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

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

**Constraints:**

*   `1 <= points.length <= 300`
*   `points[i].length == 2`
*   `-104 <= xi, yi <= 104`
*   All the `points` are **unique**.

**SOLUTION:**

    class Solution:
        def maxPoints(self, points: List[List[int]]) -> int:
            n = len(points)
            maxPoints = float('-inf')
            for i in range(n):
                for j in range(i + 1, n):
                    a = points[i]
                    b = points[j]
                    xdiff = a[0] - b[0]
                    ydiff = a[1] - b[1]
                    xsm, xbig = b[0], a[0]
                    ysm, ybig = b[1], a[1]
                    if a[0] < b[0]:
                        xsm, xbig = a[0], b[0]
                    if a[1] < b[1]:
                        ysm, ybig = a[1], b[1]
                    currPoints = 2
                    for x, y in points:
                        if x >= xsm and x <= xbig and y >= ysm and y <= ybig:
                            if tuple(a) != (x, y) and tuple(b) != (x, y) and xdiff * (b[1] - y) == (b[0] - x) * ydiff:
                                currPoints += 1
                    maxPoints = max(maxPoints, currPoints)
            maxPoints = max(maxPoints, 1)
            return maxPoints
    
    # class Solution:
    #     def maxPoints(self, points):
    #         n = len(points)
    #         maxPoints = float('-inf')
    #         done = set()
    #         for i in range(n):
    #             for j in range(i + 1, n):
    #                 a = points[i]
    #                 b = points[j]
    #                 xdiff = a[0] - b[0]
    #                 ydiff = a[1] - b[1]
    #                 slope = ydiff / xdiff if xdiff != 0 else float('inf') if ydiff > 0 else float('-inf')
    #                 yint = a[1] - slope * a[0]
    #                 if (slope, yint) in done:
    #                     continue
    #                 done.add((slope, yint))
    #                 currPoints = 0
    #                 for x, y in points:
    #                     if xdiff * (b[1] - y) == (b[0] - x) * ydiff:
    #                         currPoints += 1
    #                 maxPoints = max(maxPoints, currPoints)
    #         maxPoints = max(maxPoints, 1)
    #         return maxPoints
A11Y 101: WAI-ARIA live
Tags: a11y, beginners, webdev
Published: 2022-06-10 04:39:56

While diving into this magical accessibility journey, we have come across the WAI-ARIA Live several times.

And every time, I've promised you to return to it as it deeps a deeper explanation.

So here we are, an introduction to ARIA live.

## The need for ARIA live

In modern-day websites and applications, we use fancy scripts and methods to reload parts of the website dynamically.
This can include updating post items on the fly, showing notifications, etc.

The possibilities are endless.

Now imagine you are a non-visual user.
How are you notified of these changes suddenly appearing on your screen?

And that's precisely where ARIA-live comes in handy. It will announce elements inside a live region.

## What are live regions?

We can denote these regions with dynamically changing content by using the `aria-live` attribute.

It's also good to note you should only opt to have one aria-live per page as it can confuse screen readers and make it unclear what's happening.

As for the value of this aria-live, we have a set of three possible values.

- `polite`: This is the default way of announcing elements. Whenever something changes, the reader will focus right after finishing what was active.
- `assertive`: This should only be used for critical or time-sensitive notifications as it abruptly changes focus from what it was focused on before to the live region.
- `off`: This is the default for any element and the equivalent of not setting aria-live.

## Roles are aria-live

There are also a couple of roles that act as aria-live when used.

- `role="log"`: Additionally you can use `aria-live="polite"` to enhance this feature.
- `role="status"`: Additionally you can use `aria-live="polite"` to enhance this feature.
- `role="alert"`: Be careful with manually adding aria-live as screen readers might read out your text twice.
- `role="marquee"`: For scrolling text
- `role="timer"`: For any countdown/clock

## Addons to live regions

There have been some additions to live regions that we can also leverage.

- `aria-atomic`: This is a boolean value to describe whether or not the whole live region changes. The default is false, and only "new" changes will be announced. Setting this to true will read out the entire live region again.
- `aria-relevant`: We can describe which types of changes we want to announce. For this, we can use `additions removals` as our options.

## Conclusion

Be minimalistic when it comes to introducing live regions. Make sure your non-visual readers only get updates they need, as this is pretty disruptive behavior.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Deploy AWS elastic beanstalk on custom VPC network
Tags: aws, beanstalk, vpc
Published: 2022-06-10 04:33:28

If you want to deploy a web application on AWS elastic beanstalk and you want that to be highly available and secure. Read this content. I hope it will be helpful to you. 

1. Keep web servers and database hosted in private subnet. 
2. Keep Load Balancer on public subnet. 

You need an Internet Gateway to connect to internet. You also need NAT Gateway since your web servers need internet access and web servers will not be accessible to internet.

Use VPC launch template to setup the infrastructure quickly. 

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

If your web servers need access to other AWS services(like S3, dynamoDB, SQS etc) in that case, you need to create VPC endpoints. This will allow your web servers securely access AWS resources with low latency. Example: If your web application need image upload and file reading from S3 you can enable VPC endpoints with S3 Gateway option in the VPC launch template.

Note:~ you can also create single single NAT Gateway in 1 AZ instead of NAT Gateway 1 per AZ to save money.


Once you setup above infrastructure successfully. You can go to elastic beanstalk and create a beanstalk environment using this network setup. In network configuration first choose the VPC and select public subnets for Load Balancer and private subnet for instances.
Tweeter - Solution for a challenge from Devchallenges.io.
Published: 2022-06-10 04:33:17

Tweeter is a Twitter clone with all twitter functionalities.
A solution for a challenge from devchallanges.io

GitHub repo : https://github.com/nisabmohd/Tweeter
Challenge link : https://devchallenges.io/challenges/rleoQc34THclWx1cFFKH

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

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjogqn45g404qi5cu7ct.png)
Validate Stack Sequences
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 04:30:40

Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._

**Example 1:**

**Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\]
**Output:** true
**Explanation:** We might do the following sequence:
push(1), push(2), push(3), push(4),
pop() -> 4,
push(5),
pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1

**Example 2:**

**Input:** pushed = \[1,2,3,4,5\], popped = \[4,3,5,1,2\]
**Output:** false
**Explanation:** 1 cannot be popped before 2.

**Constraints:**

*   `1 <= pushed.length <= 1000`
*   `0 <= pushed[i] <= 1000`
*   All the elements of `pushed` are **unique**.
*   `popped.length == pushed.length`
*   `popped` is a permutation of `pushed`.

**SOLUTION:**

    class Solution:
        def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
            n = len(popped)
            i = 0
            j = 0
            stack = []
            while j < n:
                while len(stack) == 0 or stack[-1] != popped[j]:
                    if i >= n:
                        return False
                    stack.append(pushed[i])
                    i += 1
                stack.pop()
                j += 1
            return True
masonite关于jwt的处理
Tags: masonite, python, jwt
Published: 2022-06-10 04:24:43

## config配置

![config配置](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2rhgaf30psu7nc3xvoa.png)

注册provider

```python
from masonite.api.providers import ApiProvider

PROVIDERS = [
...
ApiProvider
] 
```


##  生成文件

```bash
python craft api:install 
```

此时会再config目录下生成一个`api.py`文件。


```python
"""API Config"""
from masonite.environment import env

from app.models.User import User

DRIVERS = {
    "jwt": {
        "algorithm": "HS512",
        "secret": env("JWT_SECRET"),
        "model": User,
        "expires": 过期时间,
        "authenticates": 认证者,
        "version": 版本,
    }
}
```

就最后三项需要我们填写响应的信息


## model的修改

为了支持jwt的认证，将User修改一下

```python
__auth__ = "username"
```



## 测试

![测试认证获取jwt颁发的token](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wwuj0m5kujvwmy3123c.png)
Execute cypress test cases in Jenkin Pipeline by Integrating mochawesome report
Tags: javascript, cypressio, qaautomation, programming
Published: 2022-06-10 04:19:19

https://www.linkedin.com/posts/kailashpathak_execute-cypress-test-case-in-jenkin-with-activity-6940878639550857216-SBrA?utm_source=linkedin_share&utm_medium=member_desktop_web
Get max memory size of V8
Tags: tip, node
Published: 2022-06-10 04:02:19

The default max memory size of V8 is 2GB:

```
$ node

> v8.getHeapStatistics()
{
  ....
  heap_size_limit: 2197815296,
  ...
}
```

2197815296 is 2GB in bytes. When set `NODE_OPTIONS=--max_old_space_size=8192`, `heap_size_limit` will be 8G or 8640266240 bytes.

```
$ NODE_OPTIONS=--max_old_space_size=8192 node

> v8.getHeapStatistics()
{
  ....
  heap_size_limit: 8640266240,
  ...
}
```

## References

- [How do I determine the correct "max-old-space-size" for node.js?](https://stackoverflow.com/questions/48387040/how-do-i-determine-the-correct-max-old-space-size-for-node-js#answer-63495296)
- [V8 option: --max-old-space-size=SIZE](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes)
Running Lambda powered by Arm Graviton2 processor
Published: 2022-06-10 03:52:19

Running Lambda powered by Arm/Graviton2 vs x86_64
AWS Lambda Functions Powered by AWS Graviton2 Processor – Run Your Functions on Arm and Get Up to 34% Better Price Performance

Test case flow
The following test case will be using a lambda to call a dynamoDb table

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

The following test cases with different runtime environments
For the warm state, it will be sending multiple requests for each lambda one by one (lambda concurrency is 1, all request go to the same lambda instance). And on the slides, you can see the duration of the last request.

NodeJS: ARM is a bit fast

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

DotNet: ARM is fast

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

Python: ARM is faster

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3znca8kg4g36606z5eif.PNG)

TeamConnect test case
It is under the TeamConnect account utilizing Lambda, DynamoDB, and EventBridge resources.
Also, it is versioning to be able to use multiple architecture in this case x86 and arm64

Arm64

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

Vs

x86

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

Cost

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv3f44ionjok8x7ifz2r.png)
Takeaway
Arm-based systems and instances are available in public clouds such as AWS.
The computational performance of AWS’s Arm EC2 instances is similar to that of the x86_64 instances.
Considering that Arm instances are significantly cheaper, the cost effectiveness of Arm instances are better than x86_64 instances.
Arm instances perform better with “close to metal” applications. We hypothesize that the operating systems have received more engineering efforts to optimize for Arm than high level application frameworks.