teleren/devto huggingface dataset:
Heaters
Tags: leetcode, dsa, theabbie
Published: 2022-06-15 16:30:37

Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses.

Every house can be warmed, as long as the house is within the heater's warm radius range. 

Given the positions of `houses` and `heaters` on a horizontal line, return _the minimum radius standard of heaters so that those heaters could cover all houses._

**Notice** that all the `heaters` follow your radius standard, and the warm radius will the same.

**Example 1:**

**Input:** houses = \[1,2,3\], heaters = \[2\]
**Output:** 1
**Explanation:** The only heater was placed in the position 2, and if we use the radius 1 standard, then all the houses can be warmed.

**Example 2:**

**Input:** houses = \[1,2,3,4\], heaters = \[1,4\]
**Output:** 1
**Explanation:** The two heater was placed in the position 1 and 4. We need to use radius 1 standard, then all the houses can be warmed.

**Example 3:**

**Input:** houses = \[1,5\], heaters = \[2\]
**Output:** 3

**Constraints:**

*   `1 <= houses.length, heaters.length <= 3 * 104`
*   `1 <= houses[i], heaters[i] <= 109`

**SOLUTION:**

    import bisect
    
    class Solution:
        def findRadius(self, houses: List[int], heaters: List[int]) -> int:
            houses.sort()
            heaters.sort()
            n = len(heaters)
            maxclosest = 0
            for h in houses:
                i = bisect.bisect_left(heaters, h)
                mindist = float('inf')
                if 0 <= i < n:
                    mindist = min(mindist, abs(h - heaters[i]))
                if i < n - 1:
                    mindist = min(mindist, abs(h - heaters[i + 1]))
                if i > 0:
                    mindist = min(mindist, abs(h - heaters[i - 1]))
                maxclosest = max(maxclosest, mindist)
            return maxclosest
Python Exercise 11: Count the number and generate new dictionary
Tags: python, beginners, exercise
Published: 2022-06-15 16:27:03

## Question
- Write a program to iterate a given list and count the occurrence of each element and create a to show the count of each element.
- **Given**:

```python
sample_list = [11, 45, 8, 11, 23, 45, 23, 45, 89]
```

- **Expected Output**:

```
Printing count of each item   {11: 2, 45: 3, 8: 1, 23: 2, 89: 1}
```

## My solution
1. initiate an empty dictionary
2. initiate an counter
3. iterate over the sample_list
	- 3.1 for each number, count the occurrence of that number in sample
	- 3.2 use setdefault() method to add the number as key and occurrence as value to dictionary

```python
sample_list = [11, 45, 8, 11, 23, 45, 23, 45, 89]  
count_dictionary = dict()
occurrence = 0
for number in sample_list:  
    occurrence = sample_list.count(number)  
    count_dictionary.setdefault(number, occurrence)  
  
  
print(f"Printing count of each item {count_dictionary}")
```
## Other Solution
1. initiate an empty dictionary
2. iterate over the sample_list
	- 2.1 check if the number appear in the dictionary
		- 2.1.1 if the number does not appear in the dictionary, add the number as key and 1 as value to the dictionary
		- 2.1.2 if the appear in the dictionary, increase the value by 1.

```python
sample_list = [11, 45, 8, 11, 23, 45, 23, 45, 89]
print("Original list ", sample_list)

count_dict = dict()
for item in sample_list:
    if item in count_dict:
        count_dict[item] += 1
    else:
        count_dict[item] = 1

print("Printing count of each item  ", count_dict)


```
## Credit
exercise on  [Pynative](https://pynative.com/python-data-structure-exercise-for-beginners/)
Find All Lonely Numbers in the Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-15 16:00:46

You are given an integer array `nums`. A number `x` is **lonely** when it appears only **once**, and no **adjacent** numbers (i.e. `x + 1` and `x - 1)` appear in the array.

Return _**all** lonely numbers in_ `nums`. You may return the answer in **any order**.

**Example 1:**

**Input:** nums = \[10,6,5,8\]
**Output:** \[10,8\]
**Explanation:** 
- 10 is a lonely number since it appears exactly once and 9 and 11 does not appear in nums.
- 8 is a lonely number since it appears exactly once and 7 and 9 does not appear in nums.
- 5 is not a lonely number since 6 appears in nums and vice versa.
Hence, the lonely numbers in nums are \[10, 8\].
Note that \[8, 10\] may also be returned.

**Example 2:**

**Input:** nums = \[1,3,5,3\]
**Output:** \[1,5\]
**Explanation:** 
- 1 is a lonely number since it appears exactly once and 0 and 2 does not appear in nums.
- 5 is a lonely number since it appears exactly once and 4 and 6 does not appear in nums.
- 3 is not a lonely number since it appears twice.
Hence, the lonely numbers in nums are \[1, 5\].
Note that \[5, 1\] may also be returned.

**Constraints:**

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

**SOLUTION:**

    from collections import Counter
    
    class Solution:
        def findLonely(self, nums: List[int]) -> List[int]:
            numctr = Counter(nums)
            op = []
            for num in nums:
                if numctr[num] == 1 and num - 1 not in numctr and num + 1 not in numctr:
                    op.append(num)
            return op
AJAX Project help
Tags: javascript, ajax, webdev, programming
Published: 2022-06-15 15:51:36

AJAX stands for Asynchronous JavaScript and XML. It is a modern method for creating faster, better, and more innovative web applications with XML, CSS, HTML, and JavaScript. AJAX is one of the leading web development concepts used in the front-end for communications with the back-end. [AJAX Project help](https://www.theprogrammingassignmenthelp.com/ajax-assignment-help)
CSS 小技巧💡
Tags: css
Published: 2022-06-15 15:48:05

CSS的计算函数`clamp()`，它接收三个参数，第一个是最小值，第二个是具体的数值，第三个是最大值。
CSS会自动计算，限定数值在定义的最小值和最大值之间。
Not Documented, not Done!
Tags: career, writing, management, productivity
Published: 2022-06-15 15:45:02

---
title: "Not Documented, not Done!"
published: true
description: This is probably my most used comment in Jira & GitHub as a #CTO and engineering leader 🙄 I hate writing it. But at the same time I'm absolutely convinced that documenting tasks results is amongst the most valuable documentation you can write.
tags: Career, Writing, Management, Productivity
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

"Not Documented, not Done!" is probably my most used comment in Jira & GitHub as a CTO and engineering leader 🙄

I hate writing it. But at the same time I'm absolutely convinced that documenting tasks results is amongst the most valuable documentation you can write.

Not documenting task results will have many negative consequences. Without Documentation, People not directly involved with the task will not know

- if the task got finished, aborted, skipped?
- where to find the results of the tasks?
- how it relates to other tasks?
- etc.

All of which is going to be very important to know as the team grows and will be collaborating with many people on multiple tasks at the same time.

It's also going to be a treasure trove of "undocumented behavior" as Repositories can grow to thousands of issues over the years.

Any old bug report, can either be a source of knowledge on what was tried to fix the bug and decisions on why a bug was "not fixed". Or it can just be a "closed" ticket, leaving you puzzled about what happened and wondering if that's somehow related to your current task.

Therefore I recommend everyone to add short comment covering the following whenever they close an Issue

- What was the outcome?
- Are there any links to results, documents etc you can add?
- Are there follow up tasks or open points that are being tracked in separate issues?

Biggest challenge in being "documentation police" is making that team members are not feeling checked up on, or otherwise offended. I usually resolve these tensions in a 1:1, ensuring that this is about the documentation and not about reviewing the quality of work.
Paracetamol.test.js🧪| #4: Testea este código JavaScript
Tags: javascript, webdev, testing, spanish
Published: 2022-06-15 15:30:47

## **<center>Testea el siguiente código JavaScript</center>**
#### <center>**Dificultad:** <mark>Básico</mark></center>

```js
//arr.test.js
const numPorDos = (arr) => {
    return arr.map((item) => {
        return item * 2
    });
}

test('[1,2,3] => [2,4,6]', () => {
    const res = numPorDos([1,2,3]);
    expect(res).toEqual([2,4,6]);
});
```


A. `❌ FAIL tests, Expected: [2,4,6] , Received: [1,2,3]`
B. `✅ PASS tests, [1,2,3] => [2,4,6]`

Respuesta en el primer comentario.

---
Find All Duplicates in an Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-15 15:30:35

Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_.

You must write an algorithm that runs in `O(n)` time and uses only constant extra space.

**Example 1:**

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

**Example 2:**

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

**Example 3:**

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

**Constraints:**

*   `n == nums.length`
*   `1 <= n <= 105`
*   `1 <= nums[i] <= n`
*   Each element in `nums` appears **once** or **twice**.

**SOLUTION:**

    class Solution:
        def findDuplicates(self, nums: List[int]) -> List[int]:
            exists = set()
            op = []
            for num in nums:
                if num in exists:
                    op.append(num)
                else:
                    exists.add(num)
            return op
Splitting Warehouse Shipment lines in multiple headers in Business Central
Published: 2022-06-15 15:27:43

AL extensibility challenge : how to spread automatically Warehouse Shipment Lines on multiple Warehouse Shipment Header without being too much intrusive ? _(with the constraint that the count of lines per document should now exceed a fixed value)_

Just find the right event in the "Get Source Document" report and force the creation of a new header by setting WhseHeaderCreated to false when the condition is met :-)

```
    [EventSubscriber(ObjectType::Report, Report::"Get Source Documents", 'OnSalesLineOnAfterGetRecordOnBeforeCreateShptHeader', '', false, false)]
    local procedure OnSalesLineOnAfterGetRecordOnBeforeCreateShptHeader(SalesLine: Record "Sales Line"; var WarehouseRequest: Record "Warehouse Request"; var WarehouseShipmentHeader: Record "Warehouse Shipment Header"; var WhseHeaderCreated: Boolean; var OneHeaderCreated: Boolean; var IsHandled: Boolean);
    var
        WhseShipmentLine: Record "Warehouse Shipment Line";
    begin

        IF WarehouseShipmentHeader."No." = '' then
            exit;

        WhseShipmentLine.Reset();
        WhseShipmentLine.SetRange("No.", WarehouseShipmentHeader."No.");
        if WhseShipmentLine.Count = <MaxLinePerDocument> then
            WhseHeaderCreated := false; //create new Whse Shipment Header

    end;


```

I like simplicity :-)

Edit : the event is located here 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqhxt7n1az8q1ota63kp.png)
Day 18 - Revert Statement
Tags: 100daysofcode, solidity, web3, blockchain
Published: 2022-06-15 15:25:00

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

This is Day `18` of `30` in Solidity Series
Today I Learned About Revert Statement in Solidity.

## Revert Statement

This statement is similar to the require statement. It does not evaluate any condition and does not depends on any state or statement. It is used to generate exceptions, display errors, and revert the function call. This statement contains a string message which indicates the issue related to the information of the exception. Calling a revert statement implies an exception is thrown, the unused gas is returned and the state reverts to its original state.  Revert is used to handle the same exception types as require handles, but with little bit more complex logic.

Example:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract RevertStatement {
    function checkOverflow(uint256 _num1, uint256 _num2)
        public
        view
        returns (string memory, uint256)
    {
        uint256 sum = _num1 + _num2;
        if (sum < 0 || sum > 255) {
            revert(" Overflow Exist");
        } else {
            return ("No Overflow", sum);
        }
    }
}
```

Output:
when we pass 96 and 178 to the function checkOverflow, it will throw an exception with the message "Overflow Exist".
```solidity
call to RevertStatement.checkOverflow errored: VM error: revert.

revert
	The transaction has been reverted to the initial state.
Reason provided by the contract: " Overflow Exist".
Debug the transaction to get more information.
```
---
Hello World
Tags: watercooler, writing, devjournal
Published: 2022-06-15 13:44:56

**Hello World.** This is my first post on dev.to!

I’m a 32-year-old Full-Stack Developer from Portugal. A pleasure to meet you! You can read more about me on my website: {% embed https://www.nunogois.com %}

I used to *very rarely* post stories on [Medium](https://nunogois-dev.medium.com/) but decided to try dev.to from now on, for multiple reasons. Who knows, I might even write more often now!

Most of the things I wrote on my first Medium story still hold true when writing this, so in case you would like to check it out you can read it [here](https://nunogois-dev.medium.com/hello-world-cdc7c93785f5).

This will also be a great opportunity for me to embed these posts into my website in a cool way very soon, so stay tuned for that.
Paracetamol.js💊| #142: Explica este código JavaScript
Tags: javascript, webdev, spanish, programming
Published: 2022-06-15 15:01:15

## **<center>Explica el siguiente código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
const nums = [1,2,3];
console.log(nums["LENGTH".toLowerCase()])
```

A. `SyntaxError`
B. `3`
C. `2`
D. `true`

Respuesta en el primer comentario.

---
Design Parking System
Tags: leetcode, dsa, theabbie
Published: 2022-06-15 15:00:47

Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.

Implement the `ParkingSystem` class:

*   `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slots for each parking space are given as part of the constructor.
*   `bool addCar(int carType)` Checks whether there is a parking space of `carType` for the car that wants to get into the parking lot. `carType` can be of three kinds: big, medium, or small, which are represented by `1`, `2`, and `3` respectively. **A car can only park in a parking space of its** `carType`. If there is no space available, return `false`, else park the car in that size space and return `true`.

**Example 1:**

**Input**
\["ParkingSystem", "addCar", "addCar", "addCar", "addCar"\]
\[\[1, 1, 0\], \[1\], \[2\], \[3\], \[1\]\]
**Output**
\[null, true, true, false, false\]

**Explanation**
ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
parkingSystem.addCar(1); // return true because there is 1 available slot for a big car
parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car
parkingSystem.addCar(3); // return false because there is no available slot for a small car
parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied.

**Constraints:**

*   `0 <= big, medium, small <= 1000`
*   `carType` is `1`, `2`, or `3`
*   At most `1000` calls will be made to `addCar`

**SOLUTION:**

    class ParkingSystem:
    
        def __init__(self, big: int, medium: int, small: int):
            self.cap = [big, medium, small]
            self.ctr = [0, 0, 0]
    
        def addCar(self, carType: int) -> bool:
            if self.ctr[carType - 1] + 1 <= self.cap[carType - 1]:
                self.ctr[carType - 1] += 1
                return True
            return False
    
    
    # Your ParkingSystem object will be instantiated and called as such:
    # obj = ParkingSystem(big, medium, small)
    # param_1 = obj.addCar(carType)
How to Explain a Technical Concept to a Layman
Tags: communication, developer, tutorial, people
Published: 2022-06-15 14:47:22

How do you explain a concept to someone not in your field? Or to the new guy? Here's my take.

Firstly, be warm and polite. 

Your facial expression should be welcoming and not the opposite. Your facial expression shouldn't infer that the question was stupid. Thank the person for asking if necessary. It takes courage to ask a question. 

Politely decline if you can't answer the question.


Secondly, explain the concepts in a relatable way.

Use everyday objects and scenarios to guide your explanations.
It makes it more interesting. 

If you can, avoid technical **jargon** (common words used in a particular field or industry). Which of these two statements is easier for a layman? "We tell computers what to do using a programming language" or "A programming language is any set of rules that convert strings, or graphical program elements in the case of visual programming languages, to various kinds of machine code output." 

After explaining in simple terms, you may introduce the technical word. For example, "The technical term for so and so is....".


Finally, you may refer the person to a material that explains the topic better.

Thank you for reading.
Ubuntu SILENT! But not so silent O.o
Tags: ubuntu, beginners, fix
Published: 2022-06-15 14:43:00

My laptop decided to not to have any sound. My fresh Ubuntu 20.04 installation still does not account for my Bluetooth headphones (any tips to connect Jabra devices to Linux? Seems like the saga has millions of followers).

On an attempt to add their MAC address to the sound configuration of the laptop (my personal way to scream "YOU WILL CONNECT BECAUSE I AM THE HUMAN AND I TELL YOU WHAT TO DO!" to my PC), I messed up the entire sound configuration and lost not only sound but video and audio devices. A total messy mess!

![nervous laughing at computer](https://media.giphy.com/media/9FvN85CcQU9fW/giphy.gif)

So here is the tutorial about how to undo your booboo if by any chance you edit more files than you bash knowledge can chew.

1. Keep an eye on your error logs, one of them told me there was an invalid command on my config file. Read, `cd` into the MOFO, and fix it! Error messages are there for something.

What brings me to...
2. DO NOT indiscriminately EDIT files from `/etc/...`. Keep in mind that if things go South, it might be required to reset your entire machine. If you happen to change a lot, try and keep notes on an editor describing your steps. Worst case scenario, they can become a blog post in the future, or not. The goal here is to learn to document your booboos.
3. If you happen to be in Ubuntu 20.04 and someone is telling you to edit `/etc/asound.config` run away from there because this file does not exist on your version. On 20.04 the equivalent is called `/usr/share/alsa/pulse-alsa.config`. I've 'edited' _asound.config_ and broke it. Don't be like me!
4. If you also edited `~/.asoundrc` and is currently staring at a `Dummy Sound`, which is ironically silent on your _Settings_ window, come with me and let's fix this.

## Fix

Delete the files that you know you've edited and are now troublesome. In my case, I had to delete `~/.asoundrc` and `/etc/asound.config`. Both initially did not exist, but I thought I would create and edit them, just to make more difficult to debug later on. #sillyme


Once they have been deleted, go to your terminal and type:
```
systemctl --user mask pulseaudio.socket #restart pulse auto-starting
systemctl --user stop pulseaudio
pulseaudio -vvv
```

This will prompt the system to rebuild the config files. It should work! :)

In case your audio is still not alive after this, you could try the instructions in [here](https://aaroalhainen.medium.com/how-i-fixed-my-ubuntu-20-04-no-audio-dummy-output-issue-eaa525838e0d), it gives some great suggestions.

That's all then, folks!

Good luck and stay safe! Most importantly, don't forget to KEEP AWAY FROM `/etc/` files if you don't know your way.

I think I've learned my lesson for now :)
The next generation of AI for code is here!
Tags: webdev, programming, productivity, ai
Published: 2022-06-15 13:45:34

Dror Weiss | June 15, 2022

Today, I’m excited to make a few important announcements:

**1,000,000+ developers use Tabnine!**
I’m happy to share that Tabnine is successfully automating 30% (and often >40%) of the code created by over 1,000,000 developers. I would like to thank our fantastic user community. One million developers is massive, but as we’re confident that all developers will use AI in the near future, you are the early adopters of AI technology for creating higher quality software faster. Your trust and feedback drive us to push the limits of what’s possible, taking Tabnine to a new and exciting technology foundation.

**Tabnine’s new code-native AI models enable whole-line, full-function code completions, and natural language-to-code completions.**

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

Over the past year, we have completely revamped our AI models as well as our approach to integrating new models into the platform. As opposed to a monolithic approach that mandates a single AI model, Tabnine now supports any compatible AI model for providing guidance to developers. 

In fact, Tabnine now uses a family of a dozen of code-native models. The new code-native models are trained from the ground-up on code (vs. models pre-trained on text and retro-fitted to learn code). Each of these models is optimized from its basic “vocabulary” to fit a specific language and domain, thus using the entire learning capacity of the model for the relevant code patterns. Our code-native models improve Tabnine by providing better precision and a 5x increase in the length of suggestions. 

Tabnine’s AI models run on a powerful GPU cluster to predict the code for you. We can’t wait for you to try it!

With the new AI models, Tabnine can contextually complete whole lines of code and even full functions, as well as generate code based on natural language description in comments. This functionality is now available for Python, JavaScript, TypeScript, Java, and 7 other languages as a part of Tabnine Pro using the Visual Studio Code and JetBrains IDEs.

The new models are now used for predicting full lines and snippets of code, and we’ll be gradually rolling them out also for better precision and length than the current mid-line code completion available in Tabnine Starter.

**Launching Tabnine Pro**
We’ve included the new line completion and snippet completion functionality in our new Pro plan, which is now our recommended plan for professional developers. The new Pro plan also allows customers of 3+ team members to train the AI model on the code in their GitHub, GitLab, or BitBucket repositories.