teleren/devto huggingface dataset:
Minimum Difference Between Highest and Lowest of K Scores
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 16:30:35

You are given a **0-indexed** integer array `nums`, where `nums[i]` represents the score of the `ith` student. You are also given an integer `k`.

Pick the scores of any `k` students from the array so that the **difference** between the **highest** and the **lowest** of the `k` scores is **minimized**.

Return _the **minimum** possible difference_.

**Example 1:**

**Input:** nums = \[90\], k = 1
**Output:** 0
**Explanation:** There is one way to pick score(s) of one student:
- \[**90**\]. The difference between the highest and lowest score is 90 - 90 = 0.
The minimum possible difference is 0.

**Example 2:**

**Input:** nums = \[9,4,1,7\], k = 2
**Output:** 2
**Explanation:** There are six ways to pick score(s) of two students:
- \[**9**,**4**,1,7\]. The difference between the highest and lowest score is 9 - 4 = 5.
- \[**9**,4,**1**,7\]. The difference between the highest and lowest score is 9 - 1 = 8.
- \[**9**,4,1,**7**\]. The difference between the highest and lowest score is 9 - 7 = 2.
- \[9,**4**,**1**,7\]. The difference between the highest and lowest score is 4 - 1 = 3.
- \[9,**4**,1,**7**\]. The difference between the highest and lowest score is 7 - 4 = 3.
- \[9,4,**1**,**7**\]. The difference between the highest and lowest score is 7 - 1 = 6.
The minimum possible difference is 2.

**Constraints:**

*   `1 <= k <= nums.length <= 1000`
*   `0 <= nums[i] <= 105`

**SOLUTION:**

    class Solution:
        def minimumDifference(self, nums: List[int], k: int) -> int:
            nums.sort()
            n = len(nums)
            minDiff = float('inf')
            for i in range(n - k + 1):
                minDiff = min(minDiff, nums[i + k - 1] - nums[i])
            return minDiff
Safe, fast and lightweight
Tags: opensource, microservices, community, luos
Published: 2022-06-14 16:19:28

Let’s make a correlation between flight and microcontrollers.

⏩ https://www.luos.io/blog/safe-fast-and-lightweight

A funny and intuitive way to explain how Luos organizes coding across multiple microcontrollers, as if everything were on one CPU.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qklg69hm7whnjv3sgon8.png)
Do You Create UML Diagrams For New Projects?
Tags: discuss, webdev, database, programming
Published: 2022-06-14 16:13:57

Hey awesome developers! 👋

I'm currently working on backend for a complex project that will require many tables and relationships. I was advised to create UML Diagram and UML use case before I start building anything in the project.

I usually start building, improvise and hope it works 😄

So I'm wondering, do you guys usually create UML diagrams before building new projects? Or are you like me?
100+
Tags: django, djangocms, python, opensource
Published: 2022-06-14 16:12:04

Hi,

I just realized that the module I created a few years ago just broke the 100 likes mark on github, and I wanted to share how happy I am!

It was my first project when I started working with Kapt.

Today, [Django Check SEO](https://github.com/kapt-labs/django-check-seo) is the most known open source module made by Kapt (but it's not the only one, you can [find a list](https://pypi.org/user/kapt/) of our open source python modules on PyPi`[0]`). It's one of our last Python module hosted on Github, since we're using Gitlab since a few years and it's working well.

This module (and the [post](https://dev.to/corentinbettiol/django-check-seo-3ljk)s I made to share it with the community of web developers) was a big step for me, and I [watched the numbers](https://star-history.com/#kapt-labs/django-check-seo) go up and up as the months passed. 

Today I think that this project reached a new high, since it received its first PR from another developer! It's really cool to see that all of our hard work is helping others, and that sometimes other people will work with our project, not only for them, but for all the other devs too.

The number of likes looks like it's really low, but you can see that Django Check SEO is 11th on the topic [django-cms](https://github.com/topics/django-cms) on Github :P

So thank you all, keep creating nice modules we can use, we're still creating nice modules too, sharing is really something cool to do on Internet!

*`[0]` One example is this lovely little module named "[djangocms-filer-display-pages-where-files-are-used-before-removing-them](https://gitlab.com/kapt/open-source/djangocms-filer-display-pages-where-files-are-used-before-removing-them)".*
Dev self-service with Terraform controller
Tags: terraform, kubernetes, security
Published: 2022-06-14 15:49:15

👩‍💻 Our #OpenSource Terraform Controller manages the life cycles of a #Terraform resource, allowing #developers to self-serve dependencies but with a number of of controls and safeguards that the platform team can utilize to: 

- Enforce a security policy across the estate via Checkov.

- Enforce the source of the terraform modules, for example locking down to only fetch terraform modules from your company's repositories.

- Automatically inject environment-specific variables into the Configuration CRD, such as costs, project IDs, environment-specific labels or tags.
 

See how it works here: https://bit.ly/3NA4RV3
What is functional programming
Tags: react, typescript, javascript, frontend
Published: 2022-06-14 15:47:46

This is my second blog post and it has been published in [my personal blog too](https://learnfrontend.io/blog/what-is-functional-programming) 

Functional programming means using functions as building blocks to construct a process. Unlike OOP, functional programming is not an imperative paradigm but a declarative one, meaning it describes what the code has to accomplish, but not how.

Languages such as Haskell have been completely written with functional programming in mind. Javascript also makes it possible to follow functional programming principles, however, it also supports OOP.

Below are some of the key concepts from functional programming

## Pure functions

Pure functions are simple, reusable blocks of code written as functions, that don’t have any side effects, meaning the output of a function is defined by its input.


They should not modify anything outside of the function and should be stateless, meaning whenever the function runs, it should behave like it was its first time running. This also has more benefits like reducing the number of bugs that exist when there is a shared state between functions.


Example of an impure function that modifies a variable outside of itself.


![Impure function example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tmh7q6ew6iig4xg70fpv.png)

## Immutability

The main idea behind immutability is that when the data is created, it will never be mutated again. In functional programming, this is a key concept. It helps get rid of the rather complex bugs caused by mutating data over time. Libraries such as React and Redux, only provide a state which is not modifiable directly, instead, they make it possible to always create a new state instead.

ES6 array functions are an example of functions that don’t modify the data directly but instead always return a new one. One of them is the map function which can be seen in the example below.


![es6 map function example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bum3pjw9fivolnbblp1f.png)

## Conclusion

Functional programming can be very useful whether you are building frontend web applications or any other type of app. So if you haven’t already, I hope you give it a try and check for yourself if it's easier writing functional code.
Day 17 - Assert Statement
Tags: 100daysofcode, solidity, web3, blockchain
Published: 2022-06-14 15:38:00

{% embed https://github.com/Envoy-VC/30-Days-of-Solidity noreadme %}

This is Day `17` of `30` in Solidity Series
Today I Learned About Assert Statement in Solidity.

## Assert Statement 

Its syntax is similar to the require statement. It returns a boolean value after the evaluation of the condition. Based on the return value either the program will continue its execution or it will throw an exception. Instead of returning the unused gas, the assert statement consumes the entire gas supply and the state is then reversed to the original state. Assert is used to check the current state and function conditions before the execution of the contract. Below are some cases with assert type exceptions :

- When an assert is called with a condition that results in false.
- When a zero-initialized variable of a function is called.
- When a large or a negative value is converted to an enum.
- When a value is divided or modulo by zero.
- When accessing an array in an index which is too big or negative.

**Syntax:**
```solidity
assert(condition);
```

Example:
```solidity
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

contract ErrorsAndChecks {
    bool result;

    function assertStatement(uint256 _num1, uint256 _num2) public {
        uint256 sum = _num1 + _num2;
        assert(sum <= 255);
        result = true;
    }

    function checkAssert() public view returns (string memory) {
        if (result == true) {
            return "No Overflow";
        } else {
            return "Overflow exist";
        }
    }
}
```

Output:
when we pass input as 78 and 84 and then run the checkAssert function we get the output as 
```solidity
0 : string: No Overflow
```
as sum = 78 + 84 = 162 is less than or equal to 255.

when we pass input as 198 and 84 and then run the checkAssert function we get the output as 
```solidity
0 : string: No Overflow
```
as sum = 198 +  84 = 282 is greater than 255.

---
Xcode Man Page
Tags: xcode, manpage, swift, programming
Published: 2022-06-14 15:37:22

**What if Xcode had a man page? Well now it does.** 

Instead of searching all over the web for keyboard shortcuts, features, and other common questions you have about Xcode, wouldn't it be great if you could just open a Terminal window and search or browse the Xcode man page?

Impress your friends and coworkers when you go to this man page instead of wasting time searching all over the internet for answers to your Xcode questions. You'll want to keep it open in a tab at all times. 

Installation:

1) Create the directory:
```
sudo mkdir /usr/local/man/man1
```

2) Download the Xcode manpage:
[Download Here](https://github.com/jason-elwood/xcode-man-page/blob/master/xcode.1.gz)

3) Copy the manpage to your direcory:
```
sudo cp xcode.1.gz /usr/local/man/man1
```

4) Add new path to the /etc/man.conf file:
```
sudo vim /etc/man.conf
# Add the following line where you see the other MANPATH entries:
MANPATH /usr/local/man
```

Now you can use the xcode manpage like so:
```
man xcode
```
That's all there is to it.

Please let me know what you think. It is a work in progress and I welcome bug reports, suggestions, etc.

Thanks and enjoy!
Find the Difference of Two Arrays
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 15:30:38

Given two **0-indexed** integer arrays `nums1` and `nums2`, return _a list_ `answer` _of size_ `2` _where:_

*   `answer[0]` _is a list of all **distinct** integers in_ `nums1` _which are **not** present in_ `nums2`_._
*   `answer[1]` _is a list of all **distinct** integers in_ `nums2` _which are **not** present in_ `nums1`.

**Note** that the integers in the lists may be returned in **any** order.

**Example 1:**

**Input:** nums1 = \[1,2,3\], nums2 = \[2,4,6\]
**Output:** \[\[1,3\],\[4,6\]\]
**Explanation:**
For nums1, nums1\[1\] = 2 is present at index 0 of nums2, whereas nums1\[0\] = 1 and nums1\[2\] = 3 are not present in nums2. Therefore, answer\[0\] = \[1,3\].
For nums2, nums2\[0\] = 2 is present at index 1 of nums1, whereas nums2\[1\] = 4 and nums2\[2\] = 6 are not present in nums2. Therefore, answer\[1\] = \[4,6\].

**Example 2:**

**Input:** nums1 = \[1,2,3,3\], nums2 = \[1,1,2,2\]
**Output:** \[\[3\],\[\]\]
**Explanation:**
For nums1, nums1\[2\] and nums1\[3\] are not present in nums2. Since nums1\[2\] == nums1\[3\], their value is only included once and answer\[0\] = \[3\].
Every integer in nums2 is present in nums1. Therefore, answer\[1\] = \[\].

**Constraints:**

*   `1 <= nums1.length, nums2.length <= 1000`
*   `-1000 <= nums1[i], nums2[i] <= 1000`

**SOLUTION:**

    class Solution:
        def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:
            nums1 = set(nums1)
            nums2 = set(nums2)
            return [list(nums1 - nums2), list(nums2 - nums1)]
Person registration
Published: 2022-06-14 15:23:27

On Brazil we have some documents, who can appear on development test process and I have create a set of utilities to generate some random sequences of these documents.

[Demo](http://person-registration.kaeyosthaeron.com/)

[App](https://github.com/ktfth/person-registration-app)
[REST API](https://github.com/ktfth/person_registration_api)
[Module](https://github.com/ktfth/person_registration)

With these resources you can understand the usage of tools, it is totally simple and have a weight to use in practice mode. Enjoy!
v1.1.0 of req released
Tags: showdev, go, programming
Published: 2022-06-14 15:01:29

[v1.1.0][0] of req was just released. For those wondering, req is an HTTP scripting language designed with making HTTP scripting easier. I've written about this before, which you can read about [here][1].

This latest release supports working with cookies, so should open up the language for some useful scraping of webpages. Feedback always appreciated either via the GitHub page or email.

[0]: https://github.com/andrewpillar/req/releases/tag/v1.1.0
[1]: https://andrewpillar.com/programming/2022/02/26/req-an-http-scripting-language/
Most Frequent Subtree Sum
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 15:00:45

Given the `root` of a binary tree, return the most frequent **subtree sum**. If there is a tie, return all the values with the highest frequency in any order.

The **subtree sum** of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself).

**Example 1:**

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

**Input:** root = \[5,2,-3\]
**Output:** \[2,-3,4\]

**Example 2:**

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

**Input:** root = \[5,2,-5\]
**Output:** \[2\]

**Constraints:**

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

**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 sumOfTree(self, root):
            if root:
                curr = root.val + self.sumOfTree(root.left) + self.sumOfTree(root.right)
                self.sums[curr] = self.sums.get(curr, 0) + 1
                return curr
            return 0
        
        def findFrequentTreeSum(self, root: Optional[TreeNode]) -> List[int]:
            self.sums = {}
            self.sumOfTree(root)
            mfreq = max(self.sums.values())
            return [k for k, v in self.sums.items() if v == mfreq]
How To Recover Deleted Snapchat Memories Android?
Tags: recover, snapchat, photos, memorie
Published: 2022-06-14 14:42:04

Lost essential Snapchat pictures/video clips on your Android phone? If yes, then do not worry anymore, here I will share some useful and effective ways that will surely help you out to [recover deleted Snapchat pictures on Android](https://recover-androiddata.com/recover-deleted-snapchat-pictures-android/).
So, without any delay, follow the below-provided methods to recover Snapchat photos and memories on Android with ease.

##How To Recover Deleted Snapchat Memories Android? (From Cache Files)

The best part about the smartphones is - it used to keep the cache files of applications in the SD card that helps a lot. Though, cache data are unseen on the folders, thus you can recover deleted Snapchat pictures using the Android cache data.

Follow the below steps to get back images from Cache files:

**Step 1:** At first, open the file manager app on your device
**Step 2:** Then, navigate towards the folder named as "Android," & simply go ahead in the file folder.
**Step 3:** Here, you’ll see the list of all the apps which exists on your Android device.
**Step 4:** Now, open "**com.snapchat.android**" folder and open your cache folder.
**Step 5:** At last, you’ll be able to find all the deleted photos of the snapchat in your "**received_image_snaps**" folder.

## How To Get Snapchat Memories Back From Cloud?

In case the disappeared photos aren’t available in the cache folder then you should try to search them in your storage cloud backup. Almost all the Android devices come with an auto-sync feature in it.

If you’ve enabled this auto-sync option, your mobile phone will automatically create the backup of all your important pictures on your device’s cloud. And thus you’ll be able to access those pictures even if they are deleted from your Snapchat app. Google Drive app is an excellent Cloud backup feature for an Android devices.

Try the below easy steps to know how to get Snapchat memories back from Google Drive:

**Step 1:** Begin with signing in to your personal Google account by using the valid credentials.
**Step 2:** Make a click on a recent backup folder and open the photos from a drive.
**Step 3:** Doing this will display all the photos which were present while a last backup & the pictures you’ve uploaded on Snapchat.
**Step 4:** Now, choose the photos which you need to restore
**Step 5:** Hit on the **Restore **opt. to recover your missing Snapchat pictures on Android.

## Conclusion

I am sure, after trying these solutions, you will be able to restore Snapchat photos Android. 
Hopefully, you liked this post.
License Key Formatting
Tags: leetcode, dsa, theabbie
Published: 2022-06-14 14:30:43

You are given a license key represented as a string `s` that consists of only alphanumeric characters and dashes. The string is separated into `n + 1` groups by `n` dashes. You are also given an integer `k`.

We want to reformat the string `s` such that each group contains exactly `k` characters, except for the first group, which could be shorter than `k` but still must contain at least one character. Furthermore, there must be a dash inserted between two groups, and you should convert all lowercase letters to uppercase.

Return _the reformatted license key_.

**Example 1:**

**Input:** s = "5F3Z-2e-9-w", k = 4
**Output:** "5F3Z-2E9W"
**Explanation:** The string s has been split into two parts, each part has 4 characters.
Note that the two extra dashes are not needed and can be removed.

**Example 2:**

**Input:** s = "2-5g-3-J", k = 2
**Output:** "2-5G-3J"
**Explanation:** The string s has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s` consists of English letters, digits, and dashes `'-'`.
*   `1 <= k <= 104`

**SOLUTION:**

    class Solution:
        def licenseKeyFormatting(self, s: str, k: int) -> str:
            op = []
            n = len(s)
            i = 0
            for c in range(n - 1, -1, -1):
                if s[c] != "-":
                    i += 1
                    op.append(s[c].upper())
                    if i % k == 0:
                        op.append("-")
            if len(op) > 0 and op[-1] == "-":
                op.pop()
            op.reverse()
            return "".join(op)
Promise vs async/await - Stupid Version
Tags: javascript, promise
Published: 2022-06-14 14:29:57

---
title: Promise vs async/await - Stupid Version
published: true
description: 
tags: javascript,promise
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

What is the difference between promises and async/await? (Stupid answer only)

`Promises`: Failed Haskell Monad hearts and minds imperialism over V8 engine non-blocking code against imagined calamities from callback pyramids.

`async/await`: Progressives capitulating to imperative programmers perceived suffrage making Promises perform I/O pas de deux bolstered by Pythonistas.
How I'm covering changes with tests
Published: 2022-06-14 14:24:32

Hi there 👋🏼

This is my short note where I wanna talk How I'm covering changes with tests (or how I write tests for my code) and find out how are you doing this.

Questions which I ask myself after all changes:

# What's kind of a change?

Answer options: `feature/fix/improvement`

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

So, next if is the feature then

## Features

For feature you always should write new tests.

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

If the change is logic then write unit-tests and if the change is visual only then write snapshot tests.

## Improvements and bugs

If after running tests you have broken tests fix its and if all tests pass it means that a broken thing could have a test – write a test to never break again.


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

## Create a test

At last, let's talk about creating. Creating have three nodes: unit, snapshots and combined tests.

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

# Full scheme

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

Thank you!
PRACTICE - The memory bridge
Tags: productivity, programming, codenewbie, developer
Published: 2022-06-14 14:22:45

A lot of times, while learning, information consumption isn't enough. The way the brain is wired, whatever you learn stays in the short term memory.
 
So when you watch a tutorial/read a book, it's seems you totally get what is being explained but give yourself 1 min max... Poof.... Everything is gone.
This is because you have to convert the information from the short term memory to the long term memory and the gap between the two memories is PRACTICE.

Practicing what you just learnt would strengthens the information you took in. The more you practice, the more it sticks.
This is a hack a lot of senior dev use and that's why they pick up project based learning when they want to learn a new technology.
Deploy with bitbucket pipeline
Tags: bitbucket, php, discuss, help
Published: 2022-06-14 14:13:02

Anyone using bitbucket pipeline?, I have a question.
When bitbucket deploys, will it pack all my code into 1 file (zip for example) saved on bitbucket?, or I must build my own server storage, when bitbucket deploys, I have to write a script to pack and push to my own server?
Thank you in advanced
What's gotten better in programming languages
Tags: discuss
Published: 2022-06-14 14:08:36

---
title: What's gotten better in programming languages
published: true
description: 
tags: discuss
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

I have a question, especially for those who’ve been programming for some time or have experience with older languages:

**What improvements have you seen in programming languages that aren’t related to syntax or semantics of the language?** 

I’m thinking about things like the introduction of package managers for pulling in third party dependencies, and the existence of code formatters or linters.

I guess integrated testing into the tooling / language in rust and golang would count as well. 

( Another way to frame this would be what do you miss when you are programming in c or c++ or some older language that isn’t  the language, but more about the tooling and ecosystem.)