teleren/devto huggingface dataset:
Flutter Tip (#3): Preventing Widgets overflow
Tags: dart, flutter
Published: 2020-04-08 22:53:40

Widgets overflow is something that every new Flutter developer faces in their first time with the framweork, and is something that professional devs faces sometimes.

**Whats is Widget overflow?**
Is when your widgets run out of room in the screen. I bet that you already saw some yellow lines like:

<dl> 
<img src="https://dev-to-uploads.s3.amazonaws.com/i/mmekxryi3yuptcxdr5jl.png" width="240" height="450">
</dl>

The code is as follow:

```dart
class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
  return Scaffold(
      appBar: AppBar(
        title: Text("Flutter Demo"),
      ),
      body: Row(
        children: List.generate(12, (i) {
          return Padding(
            padding: const EdgeInsets.all(8.0),
            child: Chip(
              label: Text("Item $i"),
            ),
          );
        }),
      ),
    );
  }
}
```

You can see that we used the `Row` widget to list a set of `Chips` but since the Row widget is not scrollable he keep adding items in the same line. We have many widgets to fix this, but today we will use the `Wrap` widget. Lets replace `Row` with the `Wrap` widget. So the code is now:

```dart
class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Flutter Demo"),
      ),
      body: Wrap( // We changed from Row to Wrap
        direction = Axis.horizontal, // we need to specify the direction
        children: List.generate(12, (i) {
          return Padding(
            padding: const EdgeInsets.all(8.0),
            child: Chip(
              label: Text("Item $i"),
            ),
          );
        }),
      ),
    );
  }
}
```

Now the error just disappear. It is because the `Wrap` widget add its children in one line until there is no space left then it move to the next line and keep adding the childrens left until everything is added on the screen.

<dl> 
<img src="https://dev-to-uploads.s3.amazonaws.com/i/6nmaf7tcl6nucztyn25e.png" width="240" height="450">
</dl>

`Wrap` widget have so many parameters that you can aply to customize its behaviour and is so powerful. I recommend you to read its docs [here](https://api.flutter.dev/flutter/widgets/Wrap-class.html).

Happy code and see you in the next post.
I Created A New Way To Make Your Site Faster
Tags: webperf, showdev, javascript, news
Published: 2020-04-09 00:16:50

##I love a fast website. But it's hard to achieve.

You can make your site faster when you preload the next page the user will navigate to and render it in the background. 

The current libraries that do this do not support older browsers.

##Every user deserves blazing fast load times.

This is why I made **prerender.js**, which loads pages before a user clicks on them. 

### How is this different from current solutions?

**prerender.js** is designed to work on a mobile phone from 2020 or a PC running Internet Explorer 8. It is designed to be universal. 


### Isn't prerender expensive for bandwidth? You can't just prerender every link!

Prerender is expensive for bandwidth, so I  made prerendering occur on touchstart or mouseover.

### Can I make links prerender that are loaded from button clicks?
Here's how to use **prerender.js** with button hovers:
```
function buttonRender() {
  var x = document.createElement("link");
  x.setAttribute("rel", "prerender");
  x.setAttribute("href", location.href); //location.href = "/example.html"
  document.head.appendChild(x);
}
document.getElementById("mybutton").onmouseover = function() {buttonRender()};
document.getElementById("mybutton").ontouchstart = function() {buttonRender()};
```
### Can I be part of this?
If you want to make the functionality for buttons nicer and neater, make a pull request to the [Github repo](https://github.com/genderev/prerender.js). **Please.** I'm asking nicely.
Too good to pass up 💸
Tags: offers
Published: 2020-04-09 00:06:49

# Free month of passwordless authentication with JustAuthenticateMe 🤸

If you need an authentication layer for your COVID19 Twilio hackathon project keep reading.

And if you don't. Keep it in mind.

**JustAuthenticateMe** have opened up their service to help fight Covid19.

**https://www.justauthenticate.me**

I spoke to **Grant Orndorff** a few minutes ago and he said, "Tell them that if they sign up for the free plan and then email grant@justauthenticate.me and mention your name and that they’re fighting COVID19, I’ll give them a month free of the Growing App plan (3000 successful logins).

Does that work?"

I think it does! Well done Grant 😍

This is extremely generous of them.

**Thanks JustAuthenticateMe**
Continuous Integration/Deployment for Data
Tags: dolt, ci, cd, sql
Published: 2020-04-09 00:01:56

Ever wanted to run continuous integration or continuous deployment on a database. With Dolt and DoltHub Webhooks now you can!

[Dolt](https://github.com/liquidata-inc/dolt) is a SQL database with Git-style versioning. In Git the unit of versioning is files. In Dolt, the unit of versioning is SQL tables. Dolt will eventually support 100% of the Git command line and 100% of MySQL SQL. Moreover, anything you can do on the Git command line, you will be able to do via SQL. Right now, we're at about 90% coverage of the Git command line and SQL.

[DoltHub](https://www.dolthub.com/) is a place to share Dolt repositories. In the Git context, you clone, push, and pull from DoltHub as if it was a remote. Like GitHub, DoltHub is a central place to collaborate on Dolt data projects. You can create or find public data to work on. You can give read and write permissions to your Dolt repositories to other users. You can have them create pull requests to improve your data. In the future we imagine DoltHub issues and releases. We also expect to invent some new data-specific features.

[Read more about our Webhooks launch and how to set up Jenkins to use them on our blog](https://www.dolthub.com/blog/2020-04-08-data-ci-with-dolthub-webhooks/).
Auto Source vimrc When Saved
Tags: vim
Published: 2020-07-22 14:19:22

---
title: Auto Source vimrc When Saved
published: true
date: 2020-04-09 00:00:00 UTC
tags: #vim
canonical_url: https://tech.serhatteker.com/post/2020-04/auto-source-vimrc-when-saved/
---

If you find yourself always executing `:so` after every `vimrc` change, put this in your `.vimrc`.

```vim
autocmd! bufwritepost .vimrc source %
```

This causes __Vim__ to automatically source and apply your changes to your `vimrc` when the buffer is saved.

### Improvements

#### One
It will be better option to use variable, since your `.vimrc` file may be different: For instance if you use __NeoVim__ your `rc` file is `init.vim`.

```vim
" Automatically source vimrc on save.
autocmd! bufwritepost $MYVIMRC source $MYVIMRC
```

#### Two
I want to see a _confirmation_ from __Vim__ after my file sourced to ensure everything is OK. In order to make this happen you can use below snippet:

```vim
autocmd! BufWritePost $MYVIMRC source $MYVIMRC | echom "Reloaded $NVIMRC"
```

All done!
React Testing Library fireEvent.change example
Tags: react, testing
Published: 2020-04-21 17:32:52

---
title: React Testing Library fireEvent.change example
published: true
date: 2020-04-09 00:00:00 UTC
tags: React,Testing
canonical_url: https://www.jskap.com/notes/react-testing-library-fireevent-change/
---

  

![](https://friendly-heyrovsky-86d9f9.netlify.app/opengraph?&author=kapilgorve&title=React%20Testing%20Library%20fireEvent.change%20example&tags=React,Testing)

  

Example -

```
import React from 'react';
import { cleanup, render, fireEvent } from '@testing-library/react';

import App from './App';

afterEach(cleanup);

it('Enter principal amount', async () => {
  const { getByTestId } = render(<App />);
  const principalInputElement = getByTestId('principalInput') as HTMLInputElement;
  fireEvent.change(principalInputElement, {target: {value: '20000'}});
  expect(getByTestId('emititle')).toHaveTextContent('1758');
});
```

  

This post was originally published at https://www.jskap.com/notes/react-testing-library-fireevent-change/

  

👋 Hi! I’m Kapil. I am always chatty about building things, sharing my learnings, freelancing. Come say hi to me at [https://twitter.com/kapilgorve](https://twitter.com/kapilgorve)
[react-native-tests] - run jasmine tests on simulator/emulator/device
Tags: react, reactnative, testing
Published: 2020-04-08 23:02:33

for anyone interested, [react-native-tests](https://www.npmjs.com/package/react-native-tests) runs jasmine tests on a simulator/emulator/device

strongly inspired by the test suite created for [expo/expo](https://github.com/expo/expo/tree/master/apps/test-suite)

let me know what you think. useful? improvements?

thanks

![Screenshot_1586380262.png](https://spectrum.imgix.net/threads/draft/173cfc9d-9863-4806-b0ba-a6e92740c0a6-Screenshot_1586380262.png?expires=1585785600000&ixlib=js-1.4.1&s=ff16826321fee32faf6c16b5d2ae5aba)
Quick Python: Dataclasses
Tags: python
Published: 2023-01-06 01:32:40

---
title: Quick Python: Dataclasses
published: true
date: 2020-04-08 22:59:48 UTC
tags: Python
canonical_url: https://brandonrozek.com/blog/pydataclass/
---

Python 3.7 and above have a feature called dataclasses. This allows us to reduce boilerplate code by removing the need to create a whole constructor and providing a sensible ` __repr__ ` function.

```
from dataclasses import dataclass

@dataclass
class Person:
    name: str
    age: int = 0

```

Usage:

```
p = Person("Bob", 30)
print(p)


Person(name='Bob', age=20)

```

To make an attribute have a default value, add it after the type declaration like I have with `age`.
Rome – New All-In-One JavaScript Toolchain
Tags: javascript, webdev
Published: 2020-04-08 22:58:21

Facebook just introduced a new experimental JavaScript toolchain tool called [Rome](https://romejs.dev/).

Rome is an experimental JavaScript toolchain. It was started by [Sebastian McKenzie](https://twitter.com/sebmck), author of Babel and Yarn and member of the React Native team at Facebook.

Rome includes compiler, linter, formatter, bundler, testing framework and more. It supports processing JSX, [Flow](https://codepulse.blog/my-first-time-using-flow-for-static-type-checking/) and TypeScript code. It is not production ready and is under active development. The current focus of the Rome team is linting and they welcome contributors (well, who doesn’t)!

It aims to be “a comprehensive tool for anything related to the processing of JavaScript source code”. It is not collection of existing tools and it actually doesn’t use any third-party dependencies.

The documentation of Rome is quite narrow by having installation, getting started and contributing sections, which is understandable given the stage of the project. Rome is not available via npm and it must be installed from Github. So it is self-hosted and it compiles itself with an old version.

I am very interested to see what direction Rome will go and if it will be the thing in the future. Right now it is still in the early stages and only time will tell what will come of it.

What do you think?

-----------
_Originally published at [codepulse.blog](https://codepulse.blog/rome-new-all-in-one-javascript-toolchain/?utm_source=devto) on April 9, 2020._
Coders know how fast would be to put all the knowledge of a university career for free on the web
Tags: programmers, knowledge, infomation, university
Published: 2020-04-08 22:52:55

It is easy, and if you are a web dev, you know it.

All the academical knowledge that a person could get in one year, would not take a minute for a computer to share it through internet (with a reasonable bandwidth).

However, the very prestigious universities, which have thousands of people trying to get into them, are more into "business" than into teaching.

Have you noticed how much inefficient capitalism make us?

Not capitalism. It is not an idea. It is more the lack of imagination of the people ruled by greed (because capitalism is, basically, to make a society greed-driven, sorry if you did not notice yet).

I am not selling propaganda. But if I was, I would sell propaganda about self-archism, about Direct Democracy by blockchain infrastructures in a society with one Free Online University of high, high quality.

But I am not into propaganda.

I am into efficiency, that thing that makes me think that I am not paying for my education, but for the lack of it of others.

Male bitches.
Quick Python: Copy Decorator
Tags: python
Published: 2023-01-06 01:32:55

---
title: Quick Python: Copy Decorator
published: true
date: 2020-04-08 22:49:54 UTC
tags: Python
canonical_url: https://brandonrozek.com/blog/copydecorator/
---

If you want to guarantee that your function doesn’t modify any of the references and don’t mind paying a price in memory consumption, here is a decorator you can easily add to your functions.

```
from copy import deepcopy
def copy_arguments(func):
    def wrapper(*args, **kwargs):
        new_args = deepcopy(args)
        new_kwargs = deepcopy(kwargs)
        return func(*new_args, **new_kwargs)
    return wrapper

```

Example usage:

```
@copy_arguments
def modify1(xs):
    for i, _ in enumerate(xs):
        xs[i] *= 2

```

Comparison:

```
def modify2(xs):
    for i, _ in enumerate(xs):
        xs[i] *= 2

a = [1, 2, 3, 4, 5]
b = [1, 2, 3, 4, 5]
modify1(a)
modify2(a)
print(a)
print(b)


[1, 2, 3, 4, 5]
[2, 4, 6, 8, 10]

```
Algorithms 
Published: 2020-04-08 22:23:20


An algorithm is a set of instructions designed to perform a specific task. 
In a world of computer science, it's just a fancy word for code.  An example of the basic code that returns the average from a list of integers is an *algorithm*.
```javascript
function getAverage(list) {
    int sum = 0, count = list.length;
    for (var i = 0; i < count; i++) {
        sum += list[i];
    }
    return sum/count;
}
```

For example, a non-internet based algorithms would be something like a recipe for bread. You start with the following set of instructions on how to put all ingredients together and get the final product.  
On the other side with algorithms is the same, a set of instructions that enable the computer program to put together different sources of information and generate results.

There are often many different algorithms ways to accomplish any given task. Each algorithm has advantages and disadvantages in different situations. Sorting is one place where a lot of research has been done because computers spend a lot of time sorting lists. Here are five different algorithms that are used in sorting:
**1. Bin sort**
**2. Merge sort**
**3. Bubble sort**
**4. Shell sort**
**5. Quicksort**




If you are familiar with any programming language you should base on that language, it will help you to be more comfortable to understand. 
For example, Python because it has a relatively shallow learning curve, allowing new programmers to focus more on the logical/problem-solving aspect of programming instead of syntax. Javascript another great choice but it becomes steeper as you get into some of the more advanced topics.

Programming languages are tools that developers use to solve problems. How are you even expected to solve a problem effectively if you don’t know how to use the tools to solve problems?

So why algorithms?
They give the programmer the power to implement efficient, reliable, and fast code in a shorter amount of time.

Practice, practice, and practice! This is the best way of learning. 

Check this link for beginner-friendly algorithms challenges.
[HackerRank Algorithms](https://www.hackerrank.com/domains/algorithms)
To CS or not to CS
Tags: question
Published: 2020-04-08 22:18:03

Hello Dev community, this is my first post here! I'm graduating this semester with a bachelor of fine arts with a major in graphic design (queue the blank stare) and I've been working as a front-end developer at my university for about 4 years. I've since discovered that I'm much happier pecking at code than pushing pixels and decided I'd pursue a career in UI/UX, web design, and/or front-end development.

I know how to code. I'm not an expert and don't claim to be, but I feel that I can hold my own and generally know what I'm doing. I have a deep understanding of accessibility, HTML, CSS, and am comfortable with JavaScript. I recently started playing around with Vue to build my website. (It was previously built with PHP) I'm comfortable with Git, the command line in general and the Node ecosystem.

I'll admit that I don't have knowledge of more full-featured languages like Python, C#, Ruby, etc. But I love learning. Its what I like so much about this industry, that I'm constantly learning new things. 

As I'm looking at jobs and networking, however, it never fails. As soon as a potential employer or connection finds out I don't have formal training in computer science they look at me like I wandered off on the wrong floor. They completely shut down and my experience and portfolio suddenly mean nothing.

So, as I'm approaching graduation I'm starting to question the value of my degree and what I should do next. I don't regret getting my BFA. It has been an extremely good experience and I like to think of myself as a decent designer because of it. But I do wonder if I should go back to college for a BS (bachelor of science) or BA (bachelor of arts) in computer science. I've also thought about a bootcamp or an online program that could grant a certificate just to have something to prove that I didn't just learn HTML last night.

If you were an employer, what would you advise? Do employers respect certificates from online programs? With as much money it costs to go to a bootcamp, would it be better to get a CS degree? If I did go for a CS degree, would a BA be looked down on?

Are there any certificates or programs you could link that are well respected in the industry?

I'd especially love to hear from any of you who got a job in tech without a CS degree at all. What were your experiences finding a job?

Thanks everyone!
Quick Python: Getters and Setters
Tags: python
Published: 2023-01-06 01:33:15

---
title: Quick Python: Getters and Setters
published: true
date: 2020-04-08 22:15:21 UTC
tags: Python
canonical_url: https://brandonrozek.com/blog/pygetset/
---

One of the hidden gems in Python classes are seamless getters and setters. I discovered this through the book [Effective Python by Brett Slatkin](https://effectivepython.com/). Though the example I’ll use is different and shorter than the one he uses in his book.

Let’s create a class representing a person. The only information we’re going to store is their age and we’ll make it optional to provide it.

```
class Person:
    def __init__ (self, age=None):
        self._age = None
    @property
    def age(self):
        if self._age is None:
            raise ValueError("age must be set before accessing it.")
        return self._age
   	@age.setter
    def age(self, age):
        if age < 0:
            raise ValueError("age must be at least zero.")
        self._age = age

```

The second function in the class decorated by `@property` will be the getter function for the attribute `_age`. The name of the function will be what we expect the user to access it as. The setter is then decorated with `age.setter` where `age` is the name of the attribute. As such the name chosen in the getter function name, setter function name, and decorator must all match.

Now let’s try using it

```
bobby = Person()
bobby.age


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/test.py", line 7, in age
    raise ValueError("age must first be set before accessing it")
ValueError: age must first be set before accessing it


bobby.age = 5
bobby.age


5

```
.NET How to throttle HttpClient Requests using SemaphoreSlim
Tags: csharp, dotnet, dotnetcore
Published: 2020-04-08 22:07:35

---
title: .NET How to throttle HttpClient Requests using SemaphoreSlim
published: true
description: This post will demonstrate how to deal with rate limited APIs in .NET using SemaphoreSlim
tags: csharp, dotnet, dotnetcore,
---

Last week I had to deal with an external API that didn't allow for more that 50 requests per second.

On my journey on how to deal with this limitation I stumbled upon [**SemaphoreSlim Class**](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netcore-3.1).

SemaphoreSlim limits the number of threads that can access a resource concurrently. It seemed a good fit and guess what... It was! :stuck_out_tongue:

I won't bother you with more details, let's see a simplified example on how we can limit our concurrent requests to just 3 per second with code:

```csharp
class Program
    {
        private static HttpClient httpClient = new HttpClient();

        static async Task Main(string[] args)
        {
            var tasks = new List<Task>();

            // here we set the max allowed concurrent requests, in our case it is 3
            var throttler = new SemaphoreSlim(3);

            // Let's say that we have 12 requests in total that we want to send
            for (var i = 0; i < 12; i++)
            {
                // let's wait here until we can pass from the Semaphore
                await throttler.WaitAsync();
               
                // add our task logig here
                tasks.Add(Task.Run(async () =>
                {
                    try
                    {
                        var result = await ExecuteRequest();

                        // let's wait here for 1 second to honor the API's rate limit                         
                        await Task.Delay(1000);
                    }
                    finally
                    {
                        // here we release the throttler immediately
                        throttler.Release();
                    }
                }));
            }

            // await for all the tasks to complete
            await Task.WhenAll(tasks.ToArray());
        }

        private static async Task<HttpResponseMessage> ExecuteRequest()
        {
            var result = await httpClient.GetAsync("https://www.bing.com");
            return result;
        }
    }
``` 

Please let me know in the comments below what is the equivalent of SemaphoreSlim class in other languages.

You can find the full code on my [GitHub](https://github.com/Rickinio/HttpClientThrottling)

Just run the project and use Fiddler or any other network tool to verify the throttled behaviour.

**ALWAYS TRUST BUT VERIFY** :grin:

This post was written with love ❤️
Angular Checkbox doesn't check
Tags: angular
Published: 2020-04-08 21:46:07

Try this binding first

```html
   <input 
      #checkbox
      (change)="onCheckBoxChanged(checkbox, setting)"
      [checked]="setting.values[0] != 'false'"       
      type="checkbox"
   />
```
Where the variable *setting* is a part of a parent **ngFor* loop. This is different than other [(ngModel)] bindings; in that, we are going directly to the input *checked* attribute. What's interesting is that we had to add the comparator to get it to work.

```html

[checked]="setting.values[0] != 'false'"  

``` 
Even though setting.values[0] only had string values of "true" and "false" binding directly to it like these two statements:

```html
 [checked]="setting.values[0]"
 [(ngModel)]="setting.values[0]

```
Did not work! Not sure why, but I do know it can chew up time finding these syntactic errors.

JWP2020