teleren/devto huggingface dataset:
Web3 Solidity + JavaScript 32 hour course recap #13
Tags: beginners, blockchain, solidity, devjournal
Published: 2022-06-09 18:53:10

timestamps: 4:20:00 - 4:33:33

This is a recap of me making my way through the 32 hour course by Patrick Collins posted on [FreeCodeCamp](https://www.youtube.com/watch?v=gyMwXuJrbJQ).

I started off by reviewing mapping vs arrays, because we're going through this material rather quickly and needed the refreshers. Mappings are hashes (key/value pair), and arrays are arrays.

Then we reviewed interfaces, which define which functions are available in a contract, and can be imported and used as the ABI since we need the ABI _and_ the contract address to interact with 3rd part contracts.

Here is the [Global Variable Cheatsheet](https://docs.soliditylang.org/en/v0.8.14/cheatsheet.html?highlight=global%20variable#global-variables) from the Solidity documentation. It lists all of the variables that are available to us "for free" globally.

[Solidity by Example](https://solidity-by-example.org/) was mentioned as a good resource yesterday, but we specifically went to the library lesson.

It turns out that Solidity libraries are like contracts except they're defined as `library` instead of `contract` and the functions should be `internal` instead of `public`. They also cannot have any state variables, and they cannot handle Ethereum.

It was also a cool trick to import the library, and then define a type `as` that, so that we could then just chain it on uint256. In a library function, the thing that's changed on that is that result is the first parameter inside that goes to that library function.

`import "./PriceConverter.sol";`

`using PriceConverter for uint256;`

`msg.value.getConversionRate()`

the PriceConverter.sol has the `getConversionRate` defined as:

`function getConversionRate(uint256 ethAmount) internal view returns (uint256){`

As an aside: if you have a section collapsed in Remix, and you try to search for a term; it will not find it.

I did not learn for a full hour tonight, but I **did** learn about libraries, so I've got that going for me - which is nice.
Screen Capture tool for Linux and Windows
Tags: screenrecording, popos
Published: 2022-06-09 18:41:20

An essential tool for every developer is a good screen 🎬 recording app 🎬 .  Screen recording helps help record and annotate new feature mock-ups, bug reports, and videos for YouTube.  On a Windows PC, there are a myriad of choices available.  

## Windows
My first choice on the Windows side of things is [Snagit](https://www.techsmith.com/screen-capture.html).  You will have to pay for a subscription, but it's video screen annotation tools and ease of use make it worth every penny.

## Linux
But what do we do on the Linux side of things?  Here, we are a bit limited.  

[SimpleScreenRecorder](https://www.maartenbaert.be/simplescreenrecorder/) ⭐⭐⭐
In the past, I have used SimpleScreenRecorder.  It has never hung up my system or crashed on me, so I'll give it 5 stars for stability.  Unfortunately, it is missing an editor and annotation tool.  If you are mocking up screenshots and videos, this is a required feature.  

[VokoScreenNG](https://linuxecke.volkoh.de/vokoscreen/vokoscreen-download.html).⭐⭐⭐⭐
These days I am testing out VokoScreenNg.  I have it loaded on my PopOs 22.04 Linux system, and it seems to have the annotation features I was looking for.  You can install it using the debian package manager, but I recommend you download it direct from their website so you get the [latest version](https://linuxecke.volkoh.de/vokoscreen/vokoscreen-download.html).  

An annoying caveat I've found when using VokoScreen, is it seems that all mouse clicks to the buttons in an apps' title bar are not registered.  This means I can not close any windows.  In order to fix this, I need to kill the VokoScreenNg process.  I've filed a issue on their [here](https://github.com/vkohaupt/vokoscreenNG/issues/221).
DevNews: Talking About The Recent Wave of Tech Layoffs 🎙
Tags: podcast, news, career, gamedev
Published: 2022-06-09 18:37:42

This week we’re talking about the recent wave of tech layoffs, and React Eurasia’s controversial decision to locate this year's conference in Dubai — and more.

Enjoy a great episode!

## Listen on Apple Podcasts

{% embed https://podcasts.apple.com/us/podcast/s8-e9-diablo-immortal-and-video-game-accessibility/id1525581923?i=1000565754490 %}

{% embed https://open.spotify.com/episode/7MMcbdRV2CGNq9ZTpFvHPE?si=KfDk5g6UTIG5PVVsvBTg0Q %}

## [Or listen right here on DEV 🎉](https://dev.to/devnews/s8e9-diablo-immortal-and-video-game-accessibility-the-challenges-of-creating-an-ar-system-the-recent-wave-of-tech-layoffs-and-more)

Happy coding.
Pfetch: Una alternativa a Neofetch
Tags: pfetch, neofetch, linux, terminal
Published: 2022-06-09 18:36:21

Existen diferentes herramientas en Linux que nos permiten visualizar toda la información de nuestro sistema, las herramientas más famosas son neofetch y screenfetch. 

Estas herramientas nos permiten visualizar en nuestra terminal de una forma muy rápida y atractiva toda la información de nuestro sistema (hardware, sistema operativo, configuración, etc).

Hoy vamos a hablar de **pfetch**, la cual es una herramienta parecida a las anteriores con la diferencia es que nos da solamente la información importante y tiene un estilo **minimalista**.

## Instalación

Es un archivo binario, por lo cual no es necesario compilarlo.

Clonaremos el repositorio (recuerda tener *git* instalado), entonces usaremos el comando *git clone*:

```
git clone https://github.com/dylanaraps/pfetch
```
Instalaremos el archivo como *root* útilizando el comando *install*:
```
sudo install pfetch/pfetch /usr/local/bin/
```
Para terminar la instalación:
```
ls -l /usr/local/bin/pfetch
```

## Uso

Basta con escribir *pfetch* para correr nuestro programa y poder visualizar la información de nuestro sistema:
```
pfetch
```

Para mayor información y configuración extra puedes revisar el [repositorio oficial](https://github.com/dylanaraps/pfetch).

Saludos.
Longer Contiguous Segments of Ones than Zeros
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 18:30:40

Given a binary string `s`, return `true` _if the **longest** contiguous segment of_ `1`'_s is **strictly longer** than the **longest** contiguous segment of_ `0`'_s in_ `s`, or return `false` _otherwise_.

*   For example, in `s = "110100010"` the longest continuous segment of `1`s has length `2`, and the longest continuous segment of `0`s has length `3`.

Note that if there are no `0`'s, then the longest continuous segment of `0`'s is considered to have a length `0`. The same applies if there is no `1`'s.

**Example 1:**

**Input:** s = "1101"
**Output:** true
**Explanation:**
The longest contiguous segment of 1s has length 2: "1101"
The longest contiguous segment of 0s has length 1: "1101"
The segment of 1s is longer, so return true.

**Example 2:**

**Input:** s = "111000"
**Output:** false
**Explanation:**
The longest contiguous segment of 1s has length 3: "111000"
The longest contiguous segment of 0s has length 3: "111000"
The segment of 1s is not longer, so return false.

**Example 3:**

**Input:** s = "110100010"
**Output:** false
**Explanation:**
The longest contiguous segment of 1s has length 2: "110100010"
The longest contiguous segment of 0s has length 3: "110100010"
The segment of 1s is not longer, so return false.

**Constraints:**

*   `1 <= s.length <= 100`
*   `s[i]` is either `'0'` or `'1'`.

**SOLUTION:**

    class Solution:
        def checkZeroOnes(self, s: str) -> bool:
            s += "x"
            longest = [0, 0]
            curr = [0, 0]
            for c in s:
                if c == "x":
                    longest[0] = max(longest[0], curr[0])
                    longest[1] = max(longest[1], curr[1])
                elif c == "1":
                    longest[0] = max(longest[0], curr[0])
                    curr[0] = 0
                    curr[1] += 1
                elif c == "0":
                    longest[1] = max(longest[1], curr[1])
                    curr[1] = 0
                    curr[0] += 1
            return longest[1] > longest[0]
This is a test
Tags: perceptron
Published: 2022-06-09 18:04:20

This is the first time I blog in this platform. I like the simple design and ease of use. 

```python
print("Hello DEV community") 
```

Testing the GIF loader.

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

Testing the image loader.

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

Testing for drawings.


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

Hope you like this inline `blog`.
Next Greater Element III
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 18:00:48

Given a positive integer `n`, find _the smallest integer which has exactly the same digits existing in the integer_ `n` _and is greater in value than_ `n`. If no such positive integer exists, return `-1`.

**Note** that the returned integer should fit in **32-bit integer**, if there is a valid answer but it does not fit in **32-bit integer**, return `-1`.

**Example 1:**

**Input:** n = 12
**Output:** 21

**Example 2:**

**Input:** n = 21
**Output:** -1

**Constraints:**

*   `1 <= n <= 231 - 1`

**SOLUTION:**

    class Solution:
        def nextGreaterElement(self, n: int) -> int:
            digits = [int(c) for c in str(n)]
            k = len(digits)
            i = k - 1
            while i > 0:
                if digits[i - 1] < digits[i]:
                    break
                i -= 1
            if i == 0:
                return -1
            closest = i
            for j in range(i, k):
                if digits[j] > digits[i - 1] and digits[j] - digits[i - 1] <= digits[closest] - digits[i - 1]:
                    closest = j
            digits[i - 1], digits[closest] = digits[closest], digits[i - 1]
            op = 0
            for d in range(i):
                op = 10 * op + digits[d]
            for d in range(k - 1, i - 1, -1):
                op = 10 * op + digits[d]
            return op if op <= ((1 << 31) - 1) else -1
Maximum Binary Tree
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 17:30:37

You are given an integer array `nums` with no duplicates. A **maximum binary tree** can be built recursively from `nums` using the following algorithm:

1.  Create a root node whose value is the maximum value in `nums`.
2.  Recursively build the left subtree on the **subarray prefix** to the **left** of the maximum value.
3.  Recursively build the right subtree on the **subarray suffix** to the **right** of the maximum value.

Return _the **maximum binary tree** built from_ `nums`.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/12/24/tree1.jpg)

**Input:** nums = \[3,2,1,6,0,5\]
**Output:** \[6,3,5,null,2,0,null,null,1\]
**Explanation:** The recursive calls are as follow:
- The largest value in \[3,2,1,6,0,5\] is 6. Left prefix is \[3,2,1\] and right suffix is \[0,5\].
    - The largest value in \[3,2,1\] is 3. Left prefix is \[\] and right suffix is \[2,1\].
        - Empty array, so no child.
        - The largest value in \[2,1\] is 2. Left prefix is \[\] and right suffix is \[1\].
            - Empty array, so no child.
            - Only one element, so child is a node with value 1.
    - The largest value in \[0,5\] is 5. Left prefix is \[0\] and right suffix is \[\].
        - Only one element, so child is a node with value 0.
        - Empty array, so no child.

**Example 2:**

![](https://assets.leetcode.com/uploads/2020/12/24/tree2.jpg)

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

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `0 <= nums[i] <= 1000`
*   All integers in `nums` are **unique**.

**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 makeTree(self, nums, a, b):
            if a >= b:
                return None
            root = TreeNode()
            peak = max(range(a, b), key = lambda i: nums[i])
            root.val = nums[peak]
            root.left = self.makeTree(nums, a, peak)
            root.right = self.makeTree(nums, peak + 1, b)
            return root
        
        def constructMaximumBinaryTree(self, nums: List[int]) -> Optional[TreeNode]:
            return self.makeTree(nums, 0, len(nums))
Day 4 : What is memoization in javascript ?
Tags: javascript, tutorial, 100daysofproductivity, webdev
Published: 2022-06-09 17:58:25

- Memoization is a cache technique that makes application performance faster by storing the results of expensive function calls.

- In simple terms it's storing in memory, let's understand it this way,

`Example`
```
function someIntensiveDBTask(dependsOnThis){

// Lot's of calculations here, will return same output for same input

}
```
So in that kind of scenario we can implement Memoization, Let's understand it.

```
const memo = []
function someIntensiveDBTask(dependsOnThis){

if(memo[dependsOnThis]) return memo[dependsOnThis];

// else part
// Do some calculations...
// ..
// ..
// ..

// we are caching result before returning here and storing it in memo so next time we can use it directly.

memo[dependsOnThis] = result; 
 
return result

}
```

Memoization is a way to lower a function’s time cost in exchange for space cost.

Resources :
[Res 1](https://betterprogramming.pub/save-up-computation-time-in-javascript-using-memoized-wrapper-functions-ae85f28d8087)
[Res 2](https://www.freecodecamp.org/news/understanding-memoize-in-javascript-51d07d19430e/)
Linked List in C.
Published: 2022-06-09 17:53:52

## Linked List

This article covers single linked list.

A Linked List is basically nodes connected or linked to each other. We will discuss how they are linked together.

A node is basically a block which contains a data and a pointer which points to the data of the next node’s data or points to null if that block is the last node in the list.

![Node. 
taken from https://www.alphacodingskills.com/ds/notes/linked-list.php  ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7t50ph5j3y6jpeehqn2v.png)

```c
struct node
{
    int data;
    struct node *next;
};
// We created a structure named node. It has data and a pointer named next.
```

How to initialise the linkedlist?

In the main function, We first create a node called head which is the first node and it is used as reference node to transverse through the list.

```c
int main()
{
    struct node *head;
		// creating head node
    head = (struct node *)malloc(sizeof(struct node));
		// allocating memory
    head->data = 45;
		// head node's data 
    head->next = NULL;
		// head node's next pointer points to null as we have only one element.

    return 0;
}
```

 

We now have a list with one element 45.

We can simply add more values for the time being to see how it works.

```c
int main()
{
    struct node *head;
    head = (struct node *)malloc(sizeof(struct node));
    head->data = 5;
    head->next = NULL;

    struct node *current = (struct node *)malloc(sizeof(struct node));
    current->data = 98;
    current->next = NULL;
		// we create a second node current and the next pointer points to null as only two elements are present.
    head->next = current;
		// we assign the head node's next pointer to current. That means it stores the address of 98.   

    current = malloc(sizeof(struct node));
    current->data = 34;
    current->next = NULL;
		// we assign this node's next pointer to null.
    head->next->next = current;
		// head->next->next should point to the address of 34. 

    return 0;
}
```

This code should give me a list 

5 98 34

The first node contains integer data 5 and address of 98, Second node contains data 98 and address of 34. The third node contains 34 and next pointer points to null.

In the next article, Further operations on linked list will be covered.
merge, commit, push, pull sync
Tags: webdev, beginners, devjournal, codenewbie
Published: 2022-06-09 17:52:07

well here's another issue.

understanding all of the actions in the title is obviously a must know. - and also, falling into the holes that it is when trying to do any of them and breaking something is also a MUST KNOW.

especially working on big projects or multiple ones. it's never a good idea to not know how it works and where's what.

so ALWAYS make sure you ask your senior or supervisor to walk you through it at least once. - and I say it again: it's always a bad idea to NOT ASK!
New Things Added - Laravel 9.16 Released
Tags: laravel, webdev, php, programming
Published: 2022-06-09 17:43:07

Let's get started quickly I found new things in Laravel 9.16 Released I wanted to share with you.

- Eloquent withWhereHas()
https://github.com/laravel/framework/pull/42597

method that simplifies cases where you have to repeat code used to both filter with whereHas and select the same record via with()
```php
CollectionModel::whereHas('products', function ($query) {
    $query->where('enabled', true)->where('sale', true);
})->with(['products' => function ($query) {
    $query->where('enabled', true)->where('sale', true);
});
```
Using the withWhereHas method, you can simplify your code around this use case
```php
CollectionModel::withWhereHas('products', fn ($query) => $query->where('enabled', true)->where('sale', true));
```


I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.
Source :- https://laravel-news.com/laravel-9-16-0
Source :- https://www.youtube.com/watch?v=ZEDUihpRQMM
Using a react widget/micro-frontend in Angular app
Tags: react, angular, javascript, webdev
Published: 2022-06-09 17:26:34

Hi there,

Thank you for taking time and answering these questions. We are developing a platform that serves widgets/micro-frontends (Example: chatbot) to multiple applications which are heavy on front end. These applications that will integrate our widget(chatbot) can be built using any javascript framework like Angular.

1. My question is if a consuming application is built in Angular, then Adding a React based widget to Angular based app considered not a "good practice"?

2. Is there any known benchmarking for performance hit when we load a React based widget in Angular. Example: An Angular framework now has integrated a chatbot developed in React

3. what are the general best practices around loading any of such widget library file size?
Hacks do Github - Gists
Tags: braziliandevs, github, beginners, programming
Published: 2022-06-09 17:24:11

![Gists](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlu2mzyhuc0z7a4twtac.png)
 
O Github é cheio de funcionalidades e o mais utilizado isso vocês já sabem e vamos continuar a série de "hacks" da plataforma que vão otimizar e melhorar sua experiência.

⚠️ Importante: Os prints que serão exibidos para exemplificar podem estar diferentes da interface do seu GitHub, por que sou muito adepto a extensões que melhoram a usabilidade e que ajudam no meu dia a dia. Partindo desse ponto peço que dê uma olhada [nesse artigo](https://dev.to/jhonywalkeer/extensoes-para-navegador-turbinando-sua-experiencia-no-github-538) antes

Para pequenos trechos de código, não existe ferramenta melhor que os **Github** gists! Se você não sabia, é possível adicionar arquivos e criar pequenos trechos de código, que seria muito pouco pra um repositório completo usando os gists.

![Gist](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rllboevlc7cnr7lo13pd.png)

Você pode criar quantos arquivos achar necessário, clicando no botão **Add file**. O nome mostrado no gist é o nome do primeiro arquivo. Eles são organizados em ordem alfabética.

## Embed

Se você quiser fazer embed de um gist na sua aplicação, você só precisa adicionar a extensão `.pibb` na URL, e você terá a versão HTML, somente com os os arquivos do gist. Ou então, copiar o script de Embed na que aparece na sidebar, na lateral direita.

## Versionamento do gist

Você pode tratar seus gists também como repositórios, pois eles podem ser clonados como qualquer outro projeto:

```
https://gist.github.com/jhonywalkeer/09223d1f8e7f21e8bccfd9286e5df26c
```
A única questão é que os gists não suportam diretórios. Se precisar criar uma esturuta de diretórios, a melhor coisa é criar um repositório no Github mesmo.

Fontes onde pesquisei esse conteúdo:

- https://docs.github.com/pt/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists
Learn Django
Tags: django, python, tutorial, programming
Published: 2022-06-09 17:08:51

Hey DEV bloggers, coders and coffee drinkers: Hope you're having an amazing day!

This is my Django crash course that I've created a year ago, and I have just added a few things for 2022; watching this course will give you a great understanding on different aspects on the Django Web framework.

Appreciate all the support from DEV community .. Thank You so much!

{%youtube sD1mvTxHces %}

I have created a lot of projects in Django without actually creating a crash course, which felt odd in my channel, that's why I made this for you so you can learn and spread knowledge.
Front-End development vs. UI Design. or are both equally important
Tags: frontend, webdev, uidesign, career
Published: 2022-06-09 17:05:26

One hurdle I have recently come across in my web development career is really defining exactly what I do. What I mean by this is that I have 2 very similar interests, which are designing interfaces from scratch and then developing those designs into feasible front-end websites. As I have been looking for internships and junior roles lately, being a UI designer seems very attractive at this point as my design skills currently surpass my development skills. My question is, would it be better to abandon one at this point and solely focus on the other or should I do both?
All Possible Full Binary Trees
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 17:00:45

Given an integer `n`, return _a list of all possible **full binary trees** with_ `n` _nodes_. Each node of each tree in the answer must have `Node.val == 0`.

Each element of the answer is the root node of one possible tree. You may return the final list of trees in **any order**.

A **full binary tree** is a binary tree where each node has exactly `0` or `2` children.

**Example 1:**

![](https://s3-lc-upload.s3.amazonaws.com/uploads/2018/08/22/fivetrees.png)

**Input:** n = 7
**Output:** \[\[0,0,0,null,null,0,0,null,null,0,0\],\[0,0,0,null,null,0,0,0,0\],\[0,0,0,0,0,0,0\],\[0,0,0,0,0,null,null,null,null,0,0\],\[0,0,0,0,0,null,null,0,0\]\]

**Example 2:**

**Input:** n = 3
**Output:** \[\[0,0,0\]\]

**Constraints:**

*   `1 <= n <= 20`

**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 getTrees(self, n: int) -> List[Optional[TreeNode]]:
            trees = []
            if n == 1:
                return [TreeNode()]
            if n in self.cache:
                return self.cache[n]
            for i in range(1, n, 2):
                lefts = self.getTrees(i)
                rights = self.getTrees(n - i - 1)
                for left in lefts:
                    for right in rights:
                        root = TreeNode()
                        root.left = left
                        root.right = right
                        trees.append(root)
            self.cache[n] = trees
            return trees
        
        def allPossibleFBT(self, n: int) -> List[Optional[TreeNode]]:
            self.cache = {}
            return self.getTrees(n)