teleren/devto huggingface dataset:
Who will win the 2022 Colombian Election?, according to statistics.
Tags: datascience
Published: 2022-06-12 18:45:05

In about a week, A new President will be elected to lead the Republic of Colombia, since this has become a popular topic in the media, many news outlets have run opinion polls on presidential candidates; what does this data tell us about a possible winner?.

### Does polling data provide useful insights?

The short answer is, yes. Thanks to public polling data, we can build a statistical model that gives us the probability of a candidate winning the second round of the election. However, there are some caveats:

### Polling Variability

When we build our prediction model, we need to take into account possible variability in the collected data; this can happen for many reasons:

-   People lie in polls.
-   People's opinions change over time.
-   Voting and polled population may differ.
-   Pollster Bias.

Despite these problems, we can still construct an effective model to predict a winner.

### How was this model built, despite polling data issues?

All of these flaws found in polling data are interpreted as *variability* in our model, which works perfectly because we want to predict who will win, not precisely the number or percentage of votes, previous election data is also available to use as reference in order to tell what is the expected behavior of poll data vs election results and how bigger is the percentage of votes obtained by the election winner.

### Check out our current forecast here: <https://artofcode.tech/2022-colombian-election-forecast/>
&nbsp;

### How to interpret this model?

Currently, it's a tossup. One candidate has a higher probability of winning, but a victory is not certain, in statistics we are often certain about an event if we see a 95% probability of it happening, this is not the case here; similar scenarios have been seen in other elections like the USA 2016 Election, a model very similar to this one predicted a win for Hillary Clinton with a 71% probability, however, she lost the election; it is true that she had a higher percentage of winning but unless we see a probability of over 90% of winning, it's hard to be certain about a clear victory.

### Conclusion

Statistics and Data Science are very useful to predict results given polling data, however, it seems that many popular news outlets have problems when interpreting these numbers since it is becoming a popular sentiment among the general public that polls do not provide useful information or are rigged, hopefully here you can a find a more realistic assessment of the meaning of opinion polling results and we invite you to check our current forecast, we update it as often as we can.

### References:

Forecast: <https://artofcode.tech/2022-colombian-election-forecast/>
Github: <https://github.com/christianpaez/colombian-election-analysis-2022>
Subtree of Another Tree
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 18:30:38

Given the roots of two binary trees `root` and `subRoot`, return `true` if there is a subtree of `root` with the same structure and node values of `subRoot` and `false` otherwise.

A subtree of a binary tree `tree` is a tree that consists of a node in `tree` and all of this node's descendants. The tree `tree` could also be considered as a subtree of itself.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/04/28/subtree1-tree.jpg)

**Input:** root = \[3,4,5,1,2\], subRoot = \[4,1,2\]
**Output:** true

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/04/28/subtree2-tree.jpg)

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

**Constraints:**

*   The number of nodes in the `root` tree is in the range `[1, 2000]`.
*   The number of nodes in the `subRoot` tree is in the range `[1, 1000]`.
*   `-104 <= root.val <= 104`
*   `-104 <= subRoot.val <= 104`

**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 isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
            if not p or not q:
                if p or q:
                    return False
                return True
            if p.val == q.val and self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right):
                return True
        
        def isSubtree(self, root: Optional[TreeNode], subRoot: Optional[TreeNode]) -> bool:
            if self.isSameTree(root, subRoot):
                return True
            if not root or not subRoot:
                return False
            return self.isSubtree(root.left, subRoot) or self.isSubtree(root.right, subRoot)
Hi Indonesia Developers 👋
Published: 2022-06-12 18:23:15

## Hi Indonesia Developers 👋
# Web3Indonesia
## Welcome To New Decentralized World! Our Mission Is Simple, Let's Make Blockchain And Cryptocurrency Easy To World!

## 🙋‍♀️ Blockchain Resources Indonesia – Decentralized ID

## 🌈 Build From Any Idea, I Will Share All About Knowledge Base. So That Anyone Can Come To Learn And Earn With Us.

## 👩‍💻 Useful resources - here community find our [docs](https://web30.my.id/docs)

## 👩‍💻 Blockchain Tech

### Technology Is A New Thing That Cannot Be Separated From Humans Today, We Really Need It But We Have To Learn A Lot More, Like A Web Development, Blockchain Tecnology And Cryptocurrency. New For Open Money And Dapps or Web3 For Open Web.


## Social Media
[support@web30.my.id](mailto:support@web30.my.id)

[Website](https://web30.my.id/)

[Blog](https://dapps.my.id)

[Medium](https://medium.com/@web3id)

[Github](https://github.com/Web3ID)

[Facebook](https://web.facebook.com/web3id)

[Group Facebook](https://web.facebook.com/groups/web3id/)

[Twitter](https://twitter.com/Web30_ID)

[Instagram](https://www.instagram.com/web3id/)

[Channel Telegram](https://t.me/web3_idn)

[Group Telegram](https://t.me/web3_idn_group)

[Quora](https://web3id.quora.com/)


![Web3ID Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkrqbpy857fpep58fjdu.png)
What is JavaScript ? Why use JavaScript? 🔥🚀
Tags: webdev, javascript, beginners, discuss
Published: 2022-06-12 18:06:28

## What Is JavaScript? ✨
**JavaScript** is a high-level programming language. it's originally designed to add interactivity to web pages.

> (_high-level_ language means it's closer to human languages and further from machine language).

**JavaScript** also defined as _interpreted_, _object-oriented_, prototype-based, _just-in-time_ compiled, _multi-paradigm_ with _dynamic typing_ programming language. it's one of the core & leading technologies used in the web _[(world wide web)](https://en.wikipedia.org/wiki/World_Wide_Web)_ alongside with HTML and CSS.

## A bit of history 🗺️
1995 in the offices of Netscape where the first version of JavaScript was born. At that moment though, Netscape's was one of the most popular web browsers.It's to support it that JavaScript was created, as a companion language to Java.
Back then, the web was fully-static, powered by simple HTML & CSS. **JS** brought dynamism.
Even after the death of Navigator, it was eventually adopted by all succeeding web browsers, from Explorer to Firefox and Chrome.

JavaScript was born in a hurry though, and various quirks would harm the language adoption in its early years. Still, some of its powerful features were part of it since its inception. These would define JS and allow it to grow.

The next big step following the public release came with ECMA standardization, which became the “convention” behind JavaScript. It brought the language to a broader audience and allowed other potential implementors.

## Why do we Need JavaScript? 🚀
**JavaScript is a crucial programming language for any web developer**. 
Without JavaScript, we wouldn’t have the dynamic and interactive web pages that have become the standard user experience we all know.
Initially JavaScript comes as client-side language, which is executed in browsers.but modern JavaScript support up both front-end and back-end in web application development.

In front-end, JavaScript client-side execution of the logic brings faster user experiences. With the code running directly in the browser, the need for server calls is abstracted, hence a cut in loading times. Even with the presence of a server, the fact that **JS** is asynchronous means that it’s able to communicate with the server in the background without interrupting the user interaction taking place in the front-end.

When it's used for back-end, the Node.js framework allows a server to handle front-end data updates and build scalable network applications to process simultaneous user requests.

![JavaScript Everywhere](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7g1wx72jd11ekmvvwpx.jpg)

Besides front-end & back-end in web, we need **JavaScript** in mobile app, desktop app development.🔥🔥🔥
Longest Uncommon Subsequence I
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 18:00:42

Given two strings `a` and `b`, return _the length of the **longest uncommon subsequence** between_ `a` _and_ `b`. If the longest uncommon subsequence does not exist, return `-1`.

An **uncommon subsequence** between two strings is a string that is a **subsequence of one but not the other**.

A **subsequence** of a string `s` is a string that can be obtained after deleting any number of characters from `s`.

*   For example, `"abc"` is a subsequence of `"aebdc"` because you can delete the underlined characters in `"aebdc"` to get `"abc"`. Other subsequences of `"aebdc"` include `"aebdc"`, `"aeb"`, and `""` (empty string).

**Example 1:**

**Input:** a = "aba", b = "cdc"
**Output:** 3
**Explanation:** One longest uncommon subsequence is "aba" because "aba" is a subsequence of "aba" but not "cdc".
Note that "cdc" is also a longest uncommon subsequence.

**Example 2:**

**Input:** a = "aaa", b = "bbb"
**Output:** 3
**Explanation:** The longest uncommon subsequences are "aaa" and "bbb".

**Example 3:**

**Input:** a = "aaa", b = "aaa"
**Output:** -1
**Explanation:** Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a.

**Constraints:**

*   `1 <= a.length, b.length <= 100`
*   `a` and `b` consist of lower-case English letters.

**SOLUTION:**

    class Solution:
        def findLUSlength(self, a: str, b: str) -> int:
            if a == b:
                return -1
            return max(len(a), len(b))
AWS S3 Security
Published: 2022-06-14 16:50:44

---
title: AWS S3 Security
published: true
date: 2022-06-12 17:55:52 UTC
tags: 
canonical_url: https://venkatesh111.hashnode.dev/aws-s3-security
---

All Buckets and objects are private by default. Only the resource owner, an AWS account that created it, can access the resource.

Access to S3 bucket and/or objects can be controlled via

1. IAM Policies
2. Bucket Polices
3. Access Control Lists

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655055714490/9ykVabn6S.png)

**IAM Policies, Bucket Polices, & ACL**![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655055754227/1hPu8pZYw.png)

**IAM Policies Vs. Bucket Polices**  
IAM Policies are **attached to IAM Entities** such as User, Groups and Roles and they define **What** is allowed or denied ?

Bucket Polices are **attached to S3 Buckets** and define **Who** is allowed or denied

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655055829919/OU8Wm7etD.png)

AWS S3 **Block Public Access** Block Public Access is applicable to only Public/Anonymous access Block public access settings **can override ACLs and bucket policies** public access You can apply block public access settings to **individual buckets** or to **all buckets** in your account

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655055905130/nir31Hj8S.png)

**When to use What ?**

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655055925424/l1IN9x7Qm.png)

AWS References:  
https://aws.amazon.com/s3/security/  
https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html  
https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-iam-policies.html  
https://docs.aws.amazon.com/AmazonS3/latest/userguide/acls.html  
https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html

For More such simple notes on AWS, Follow me on  
LinkedIn: https://www.linkedin.com/in/venkatesh111/  
Twitter: https://twitter.com/venkatesh111  
GitHub: https://venkateshk111.github.io/
Flip Equivalent Binary Trees
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 17:30:40

For a binary tree **T**, we can define a **flip operation** as follows: choose any node, and swap the left and right child subtrees.

A binary tree **X** is _flip equivalent_ to a binary tree **Y** if and only if we can make **X** equal to **Y** after some number of flip operations.

Given the roots of two binary trees `root1` and `root2`, return `true` if the two trees are flip equivalent or `false` otherwise.

**Example 1:**

![Flipped Trees Diagram](https://assets.leetcode.com/uploads/2018/11/29/tree_ex.png)

**Input:** root1 = \[1,2,3,4,5,6,null,null,null,7,8\], root2 = \[1,3,2,null,6,4,5,null,null,null,null,8,7\]
**Output:** true
**Explanation:** We flipped at nodes with values 1, 3, and 5.

**Example 2:**

**Input:** root1 = \[\], root2 = \[\]
**Output:** true

**Example 3:**

**Input:** root1 = \[\], root2 = \[1\]
**Output:** false

**Constraints:**

*   The number of nodes in each tree is in the range `[0, 100]`.
*   Each tree will have **unique node values** in the range `[0, 99]`.

**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 flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool:
            if not root1 and not root2:
                return True
            if root1 and root2:
                if root1.val != root2.val:
                    return False
                if self.flipEquiv(root1.left, root2.left) and self.flipEquiv(root1.right, root2.right):
                    return True
                if self.flipEquiv(root1.left, root2.right) and self.flipEquiv(root1.right, root2.left):
                    return True
            return False
Next Permutation
Tags: leetcode, dsa, theabbie
Published: 2022-06-12 17:00:42

A **permutation** of an array of integers is an arrangement of its members into a sequence or linear order.

*   For example, for `arr = [1,2,3]`, the following are considered permutations of `arr`: `[1,2,3]`, `[1,3,2]`, `[3,1,2]`, `[2,3,1]`.

The **next permutation** of an array of integers is the next lexicographically greater permutation of its integer. More formally, if all the permutations of the array are sorted in one container according to their lexicographical order, then the **next permutation** of that array is the permutation that follows it in the sorted container. If such arrangement is not possible, the array must be rearranged as the lowest possible order (i.e., sorted in ascending order).

*   For example, the next permutation of `arr = [1,2,3]` is `[1,3,2]`.
*   Similarly, the next permutation of `arr = [2,3,1]` is `[3,1,2]`.
*   While the next permutation of `arr = [3,2,1]` is `[1,2,3]` because `[3,2,1]` does not have a lexicographical larger rearrangement.

Given an array of integers `nums`, _find the next permutation of_ `nums`.

The replacement must be **[in place](http://en.wikipedia.org/wiki/In-place_algorithm)** and use only constant extra memory.

**Example 1:**

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

**Example 2:**

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

**Example 3:**

**Input:** nums = \[1,1,5\]
**Output:** \[1,5,1\]

**Constraints:**

*   `1 <= nums.length <= 100`
*   `0 <= nums[i] <= 100`

**SOLUTION:**

    class Solution:
        def nextPermutation(self, nums: List[int]) -> None:
            n = len(nums)
            i = n - 1
            while i > 0:
                if nums[i - 1] < nums[i]:
                    break
                i -= 1
            if i == 0:
                nums.reverse()
                return
            mdiff = float('inf')
            closest = None
            for j in range(i, n):
                if nums[j] > nums[i - 1] and nums[j] - nums[i - 1] <= mdiff:
                    mdiff = nums[j] - nums[i - 1]
                    closest = j
            if closest:
                nums[i - 1], nums[closest] = nums[closest], nums[i - 1]
            for j in range(i, (i + n) // 2):
                nums[j], nums[n - j + i - 1] = nums[n - j + i - 1], nums[j]
React Frontend Code Review- Checklist (Master Code Review)
Tags: webdev, react, productivity, typescript
Published: 2022-06-12 17:23:39

Many authors write tons of paragraphs and explain the main content in between them, let me not create nuisance here and get directly to the point so that without wasting a second, you geeks out here can utilise this checklist and become a master in code review.

- Keep the components small, If the size exceeds 200-300 lines then create child components.
- JSX markup should be no more than 50 lines.
- Every function should have comments over it describing what it do.
- Code has no linter errors.
- If there are any React warnings reported in console, please solve that for example, Provide a key prop with a unique value for each element in array.
- Do not repeat your code (DRY).
- Code is in sync with existing code patterns.
- No unused props are being passed.
- Naming conventions followed for variables, file names, translations.
- Styles in components over a common styling file is preferred.
- No hardcoded values, use constants values.
- Group similar values under an enumeration (enum).
- Proper interfaces should be there with proper names.
- Extend interfaces and types wherever required.
- Create service in frontend for API calls.
- No console.logs.
- Use Promises or Asyns/Await. Handle API rejections.
- Use destructuring assignment for arrays and objects.
- Removed unused packages from NPM.
- Create custom hooks.
- Use useCallback with useEffect for function calls with proper dependencies.
- No infinite API callings inside loops.
- Create helper function (common function) if function is repeated somewhere else too.
- Consider generic functions and classes.
- Exception handling and clean-up (dispose) resources.
- Don’t use dangerouslySetInnerHtml
- If new library is used for a feature, check for library size (if lightweight library present then check it out)
- If there are any timers (setInterval) register in mounting phase, please unregister those in clean-up effects
- alt for images, an HTML attribute for alternative text which is used for non-visual browsers.
- Git Commits messages are small and understandable.

You can add more pointers in the discussion!
Python | A simple Stack Class
Tags: programming, beginners, tutorial
Published: 2022-06-12 16:42:54

Today I want to talk about a famous, basic but pretty wonderful data structure we all read in our universities or colleges.

## Stack
A stack is a linear data structure that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack is removed first.

You can think of the stack data structure as the pile of plates on top of another.
![stack-of-plates](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nqurmbrqcyhw1o9xra8.png)
 

Here, you can:
- Put a new plate on top
- Remove the top plate
- And, if you want the plate at the bottom, you must first remove all the plates on top. This is exactly how the stack data structure works.

## Applications
- To **reverse a word** - Put all the letters in a stack and pop them out. Because of the _LIFO_ order of stack, you will get the letters in reverse order.
- In **compilers** - Compilers use the stack to calculate the value of expressions like `2 + 4 / 5 * (7 - 9)`.
- **In browsers** - The back button in a browser saves all the URLs you have visited previously in a stack.

## Key functions of a Stack
- Push: Add new element
- Pop: Remove an element from last
- Peek: Get the last element without removing it

## Cherry on Top
In the following implementation instead of using built-in functions to check empty or length of stack we will use an extra variable `count` to keep track of these things.

## Code
```python
from typing import Type

class Stack:

	elements = []

	count = -1

	def push(self, data):
		self.elements.append(data)
		self.count += 1

	def pop(self) -> int:
		if self.isEmpty() is True:
			raise Exception('Nothing to pop!')
		
		self.count -= 1
		self.elements.pop()

	def peek(self):
		if self.isEmpty() is True:
			raise Exception('Cannot peek an empty stack')

		return self.elements[self.count]

	def isEmpty(self):
		return self.count < 0
```
Types of api testing
Tags: blst, startup, api, saas
Published: 2022-06-12 16:37:09

**Hi everyone,**

API testing is an essential part of any software development process. By focusing on the API, testers can uncover problems that would otherwise be missed. API testing should be given the attention it deserves and performed at both the unit and integration levels.

Testing the application programming interface (API) to determine if it meets expectations for functionality, reliability, performance, and security is a type of API testing.

It is possible to test APIs either at the unit level, which tests individual API components or at the integration level, which tests the API along with other software system elements. API testing is often performed in conjunction with different types of testing, such as functional or load testing.

API testing is **essential to ensure any software system's quality**, and it should be given the attention it deserves. API testing reveals problems that other types of testing may not detect.

Unit testing in API
Unit testing is the lowest level of API testing, focusing on individual components of the API. The API developers typically write unit tests.

**Integration testing in API**
Integration testing is the next step up from unit testing, and it tests the API in conjunction with other parts of the system. Most integration tests are written by testers familiar with both the API and the integrated system.

Functional tests examine the overall functionality of a system. An API functional test would ensure that its methods perform as expected.

To determine how the system performs under load, load testing is performed. A load test for an API would ensure it can handle the expected load.

**Security testing focuses on the security of a system.** The API is tested in API security to ensure it is secure from attacks.

API testing should be part of any software development process. By focusing on the API, testers can uncover problems that might otherwise go unnoticed. It is important to give API testing the attention it deserves and perform it at the unit and integration levels.

In conclusion,
API unit testing focuses on individual components of the API. The next step is integration testing, which focuses on testing the API with other system parts. Functional testing focuses on the system's overall functionality. Load testing focuses on the security of a system.

if you're interested in exploring API security testing tools, I invite you to check out our API security GitHub ⭐
https://github.com/blst-security/cherrybomb

**Thanks for being here with me :)**