teleren/devto huggingface dataset:
How to wait for requests on Cypress tests
Tags: webdev, testing
Published: 2020-08-31 23:29:03

With `cy.route()` you can create an alias for a particular request, and then later wait with `cy.wait()` for that request to be made and return a response, like this:

```javascript
describe('Some page', () => {
  beforeEach(() => {
    // Needs to be called before cy.route
    cy.server();

    // Alias request
    cy.route('POST', '**/items/show_all').as('showAll');
    cy.visit('/page');
  });

  it('should test something', () => {
    cy.get('[data-testid=GetItemsButton]').click();

    // Waits for request to finish and fails if it's not made
    cy.wait('@showAll');
    cy.get('[data-testid=ItemsList]')
      .should('be.visible')
      .and('contain', 'Item 1')
      .and('contain', 'Item 2');
  });
});
```

### If you need to make assertions on the response
You can with a callback!
```javascript
cy.wait('@showAll').then((response) => {
  expect(response.body.length).to.be(5);
});
```
#### Documentation
You can get more details on the function calls here:
- [cy.route](https://docs.cypress.io/api/commands/route.html)
- [cy.wait](https://docs.cypress.io/api/commands/wait.html)

Happy testing!
C++ datatypes
Published: 2020-08-31 23:22:31

Today I set up my development environment with Unreal engine 4.
I also learned about the data types present in c++ and the space in memory they occupy. 

[Github](https://github.com/3Mustard/cpp-data-type-size-example)

## Data types
In c++ a variable is declared with the data type that will be assigned to it.
-Integer(keyword: int, example: 1,2,3);
-Float(keyword: float, example: 3.14, 4.5);
-Double(keyword: double, example: 3.3333);
-Characters(keyword: char, example: a-z,A-Z,0-9,symbols);
-Boolean(keyword: bool, example: 0/1, true/false);

*The difference between a float and a double is precision, the amount of decimal values.*

#### example of declaring a variable in c++
```
int a = 4;
or if the variable will not be reassigned
const int b = 6;
```

## Modifiers
modifiers operate on the range of memory the data type will occupy. The modifiers are as follows.
-short 
-long
-unsigned (only positive values accepted)
-signed (both positive and negative values accepted)


## sizeof()
Passing a value into the sizeof operator will return it's size in bytes.

```
cout << "Size of char : " << sizeof(char) << " byte" << endl;
output: Size of char : 1 byte
```

In the github I linked I used the sizeof operator on all the datatypes and produced the following output

```
Size of char : 1 byte
Size of int : 4 bytes
Size of signed int : 4 bytes
Size of unsigned int : 4 bytes
Size of short int : 2 bytes
Size of signed short int : 2 bytes
Size of unsigned short int : 2 bytes
Size of signed long int : 4 bytes
Size of unsigned long int : 4 bytes
Size of float : 4 bytes
Size of double : 8 bytes
Size of long double : 8 bytes
Size of boolean : 1bytes
Size of wchar_t or wide char : 2 bytes
```
I completed #100DaysOfCode...
Tags: 100daysofcode, 24pullrequests, hacktoberfest
Published: 2020-08-31 19:16:44

Earlier this year, I started #100DaysOfCode through Team Treehouse and Github.  

I focused on the Web Design course, as I was already involved in it.  It took a ton of effort, especially when I felt like I'd lost all of my motivation.  

It turned out, though, that I knew myself better than I ever thought.  

In a tweet from not two days before, I noted that my problem was likely that I need to type along with the tutorial or it doesn't sink in.  

This was during three weeks of mindnumbing torpor, but I finally finished on the seventh of this month and got my badge.  I was ecstatic after all that bother about 'why can't I do this?'

I knew I could, I just kept forgetting myself.  My next goal for this year is, of course, Hacktoberfest, which I've participated in for three years this October, and 24PullRequests, which I've been participating in since 2013, and preparing for by creating pull requests in my own projects to get out of the lamentable habit of publishing directly to master all the time.

My main concern is that since I didn't know I was learning HTML/CSS when I started using Livejournal in my senior year of high school, I never knew to read the documentation about my particular interests, much less about things I wouldn't learn for roughly eight years.  

When I joined Foursquare, I had no idea that apparently, I joined with hackers, the stripes of which I still don't know.  I guess I'm a grey hat, though this is mainly because I feel learning the techniques I'm trying to monitor wouldn't mean I would hand them out to horrible businesses like Facebook and HB Gary.

{% github Angelfirenze01/Web-Design no-readme %}
Chingu Weekly 110
Tags: applicationdevelopme, learning, community, development
Published: 2020-09-02 14:33:31

---
title: Chingu Weekly 110
published: true
date: 2020-08-31 22:56:39 UTC
tags: applicationdevelopme,learning,community,development
canonical_url: https://medium.com/chingu/chingu-weekly-110-db2e0f151281
---

Getting Ready for Voyage 23 on August 31

### Shout-outs & Showcases

![](https://cdn-images-1.medium.com/max/1024/1*_PYYdz4Mi-orrjtAmZfvOw.jpeg)<figcaption>Photo by <a href="https://unsplash.com/@guillaumedegermain?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Guillaume de Germain</a> on <a href="https://unsplash.com/s/photos/ears?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

🎉 Congratulations VirgilT who was promoted to the position of Database Administrator at his job!

🎉 Welcome Voyage 23 Chingus to Sprint #1 of your journey!

### Overheard in Chingu

![](https://cdn-images-1.medium.com/max/1024/1*RHWc6R1skLkFEjNSOaVgAw.jpeg)<figcaption>Photo by <a href="https://unsplash.com/@chesnutt?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Eran Menashri</a> on <a href="https://unsplash.com/s/photos/ears?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

> I’ve just found the CSS Font Loading API!

> I need user advice, Where should the buttons be, or some relational text go, so that they know there’s a demonstration by pushing the buttons and/or selection?

> I really need to find some open source project

> Does anyone use Sketch? I am converting the design into code but I do not know what size matrix that it uses mean.

> Hmmm. But this is what happens when I do that

> ah cool thanks

> Ooo I’ve been to one of Rad Devon’s workshops

> Luxon has been built by MomentJS team to address some old issues that moment is still carrying around

> Anyone have any advice about getting some interviews for your first dev job? I don’t really know if I’m doing something wrong or what.

> Lol when I skip through a youtube video it sounds like someone speaking Swedish or Danish lol

> Did you ever hear back from the interview?

> I changed a field in a db today and it didn’t break!!!

> I need a date picker to help me with dates. I know I know, I’ll find the door myself.

### Chingu of the Week

Thank you Abandoned\_VarunR & ๏๏๏ ᗦ who worked to help other Chingu’s with questions in the #ask-cohort-n-code-questionschannel in our Discord community.

### Resources of the Week

[Chingu Resources List](https://github.com/chingu-voyages/ChinguResourceList) is a collection of useful resources anyone may contribute to!

[chingu-voyages/ChinguResourceList](https://github.com/chingu-voyages/ChinguResourceList)

And this one has been very, very popular in Chingu!

[anuraghazra/github-readme-stats](https://github.com/anuraghazra/github-readme-stats)

### Quotes to Go

![](https://cdn-images-1.medium.com/max/1000/0*YW6PS-YcNexsnOUA.png)

> _You can learn more about Chingu & how to join us at_ [_https://chingu.io_](https://chingu.io/)

* * *
The Great RGB Color Game
Tags: react, javascript
Published: 2020-08-31 22:32:23

In a previous post earlier today, I mentioned working on The Great RGB Color Game originally by Colt Steele. I rebuilt that application in React.js, [and you can see a live demo here.](https://rgbcolorgame.vercel.app/)

This project was very fun to do, and it did a great job reminding me about using functions in stateless components. The `()` at the end of a function being called is so important since it executes a function. Without it, functions literally will return the entire function code itself. I also found that passing state down as props became ideal when state turned out to be so dynamic. 

The app itself needed the ability to assign colors at random, but even `this.setState({ })` could not seem to handle the random assignments. I ended up moving my random/assigning logic to the top level of my application so that I could pass down solid data. 

If there is anything I would want my readers to know about a project like this, it should be that vanilla JS is much harder to use in a library if you're not quite sure what's initially happening. However, vanilla JS is still a powerful tool despite the default power of libraries. Never underestimate the power of your roots!
Load Balancer Tutorial 2020 - System Design Basics
Tags: webdev, career, javascript, tutorial
Published: 2020-08-31 21:54:19

Load balancers aren't sexy but they ARE pretty much the backbone required for building modern distributed systems. There's surprisingly little content covering this topic, so I thought I'd make a tutorial to help beginners dip their toes into the basics of system design

{% youtube OeJpHnnXzxM%}

##Future system design topics
I'll be making more videos and articles covering the following topics
* horizontal vs vertical scaling
{%link https://dev.to/renaissancetroll/vertical-vs-horizontal-scaling-system-design-basics-9i1 %}
* Caching
{% link https://dev.to/renaissancetroll/caching-tutorial-2020-system-design-basics-2f33 %}
* Database Design
{% link https://dev.to/renaissancetroll/database-scaling-tutorial-system-design-basics-24p7 %}
* CAP theorem
* Distributed System Basics
* Consistent Hashing
* Communication Protocols
* Security Basics

##Why bother with this stuff
Even if you are a beginner frontend developer who doesn't necessarily need to worry about this stuff directly, I think it's important to have at least some exposure to how everything works together in an application. System design also becomes a much larger factor as you progress in your career and you gradually move from simply implementing features to helping to plan out the architecture of a complex app. 

System design is often what separates a junior from a senior engineer, moving from knowing HOW to build something to knowing WHY to build something.
What is WebRTC leak?
Published: 2020-08-31 21:50:04

WebRTC works by sending audio/video feeds between two entities. For this, it established communication channels from the browser to the website you open. This means your browser will share some of your information with the website, which will include your IP address. And these channels can bypass the encrypted tunnel you have setup. So basically, a WebRTC leak can reveal your real IP address even if you are using a VPN.

More on how to disable WebRTC in Chrome, Firefox, Safari, Opera and Edge: https://kingpinbrowser.com/blog/how-disable-webrtc/
PSA: delegate is a Thing
Tags: programming, c, opinion
Published: 2020-11-26 14:37:44

---
title: PSA: delegate is a Thing
published: true
date: 2020-08-31 21:35:46 UTC
tags: programming,c,opinion
canonical_url: https://blog.jonstodle.com/psa-delegate-is-a-thing/
---

This is just a short reminder to all C# developers defining and implementing interfaces with a single method:

> ### What you are looking for is `delegate`

A `delegate` is a way to define the signature of a method. It can then be implemented by a `Func`, an `Action` or class method, whichever fits the best.

They even work nicely with dependency injection: a `delegate` is just a definition, not an implementation. If you want to preserve testability, that's taken care of: in tests you can just pass in a dummy implementation by way of a `Func` or `Action`; no mocking framework needed.

Here's an example

```
// Definition
public delegate void SendEmail(string recipient, string sender, string subject, string message);

// Registering with a DI system
services.AddTransient(_ => (recipient, sender, subject, message) => { /* Implementation */ });
// or
services.AddTransient(_ => StaticClassWithImplementation.StaticMethodImplementingDelegate);

// In testing
var systemUnderTest = new ClassThatNeedsToSendEmails((_, __, ___, ____) => { log.Info("Sent email"); });
```

Don't overcomplicate with interfaces and classes, what could simply be a delegate.
Another two C# idioms - Part 3
Tags: tutorial, csharp, beginners, dotnet
Published: 2020-08-31 21:31:44

This part of the C# idioms series is only about dictionaries.

## Instead of checking if a dictionary contains an item before adding it, use `TryAdd`

`TryAdd` will return if an item was added or not to the dictionary. Unlike `Add`, if the given key is already in the dictionary, `TryAdd` won't throw any exception. It will simply do nothing. The item is already there.

Before,

```csharp
var myDictionary = new Dictionary<string, string>();
myDictionary.Add("foo", "bar");

// System.ArgumentException: An item with the same key has already been added. Key: foo
myDictionary.Add("foo", "baz");
```

After,

```csharp
var myDictionary = new Dictionary<string, string>();

if (!myDictionary.ContainsKey("foo"))
  myDictionary.Add("foo", "bar");
```

Even better,

```csharp
var myDictionary = new Dictionary<string, string>();
myDictionary.TryAdd("foo", "bar"); // true

myDictionary.Add("foo", "baz");
myDictionary.TryAdd("foo", "bar"); // false
```

## Avoid `KeyNotFoundException` with `TryGetValue` or `GetValueOrDefault`

At least now, the `KeyNotFoundException` message contains the name of the not-found key. _The old days chasing the not-found key are over._

On one hand, `TryGetValue` uses an output parameter with the found value. It outputs a default value when the dictionary doesn't contain the item. `TryGetValue` dates back to the days without tuples.

On another hand, `GetValueOrDefault` returns a default value or one you provide if the key wasn't found.

Before,

```csharp
var dict = new Dictionary<string, string>();

// System.Collections.Generic.KeyNotFoundException: The given key 'foo' was not present in the dictionary.
dict["foo"];
```

After,

```csharp
var dict = new Dictionary<string, string>();

dict.TryGetValue("foo", out var foo); // false, foo -> null

dict.Add("foo", "bar");
dict.TryGetValue("foo", out foo); // true, foo -> "bar"
```

Even better,

```csharp
var dict = new Dictionary<string, string>();

dict.GetValueOrDefault("foo"); // null
dict.GetValueOrDefault("foo", "withoutFoo"); // "withoutFoo"

dict.Add("foo", "bar");
dict.GetValueOrDefault("foo", "withoutFoo"); // "bar"
```

_Happy coding!_
Hello.. !
Published: 2020-08-31 21:27:49

This is my first post on dev.to - I wanted to say hello to everyone and looking forward to reading posts here from other developers.

I'm primarily a project manager/community/developer relations kind of person. So you might see some technical things - but likely see more posts on the initiatives I'm working on with the GNOME Project and things I do at work in regards to open hardware, open system firmware and other sundry things.

Talk to you soon!
HTML Must Knows the datalist element 
Tags: html
Published: 2020-08-31 21:23:33

The HTML `<datalist>` element is a very powerful input element. It functions as an input field with dropdown options, but here is the catch: it comes with autocomplete. Users will see a drop-down list of predefined options as they write in the input field!

The `<datalist>` element contains various `<option>` elements that represent the options that are available to the user.

It kind of feels like a `<select>` dropdown, but on steroids. Since the user is able to type and get autocomplete options in return.

## How to use `<datalist>`
```html
<label for="animals">What is your favorite animal?:</label>
<input list="animals" name="animal" id="animal">

<datalist id="animals">
  <option value="Dog">
  <option value="Cat">
  <option value="Horse">
  <option value="Donkey">
  <option value="Bunny">
</datalist>
```
Note the id of the `<datalist>` and the value of the list attribute on the `<input>` field


The HTML will translate into:

{% codepen https://codepen.io/karsviersel/pen/ZEWJXgW %}

If you click on the input field you already see the generated list of options that I've provided. Now start typing in the input field! As you will notice, once you start typing the list will shrink. It will only show the available options based on what you have typed.

So out of the box, HTML gives us an input field that brings autocomplete to the table.

The beauty of this is that it even works in all browsers! Both desktop and mobile.

## Conclusion
When I learned about the `<datalist>` element I was very happy! In almost every project I had to spend hours creating custom dropdown lists with autocomplete. Never knowing that there was a HTML tag for it!

I wonder what you think of the `<datalist>` element? Let me know!
Day 207: Black Panther
Tags: hiphop, code, coding, lifelongdev
Published: 2020-08-31 21:21:29

_liner notes_:
- Saturday : Got the horrible news that Chadwick Boseman had passed away. Damn. The impact that he and 'Black Panther' had on myself and so many people was immense. To find out that he had been really sick for a long time, but still released a bunch of movies is amazing. Rest In Power. Also found out that Cliff Robinson of the Portland Trail Blazers passed away. We spoke about those things and more on the show. The recording of this week's show is at https://kNOwBETTERHIPHOP.com After the radio show, I checked out a dope HIPHOP event that was streamed online.

![Radio show episode image of Chadwick Boseman with the words August 29th 2020 and F*** 2020](https://dev-to-uploads.s3.amazonaws.com/i/2ygjwlvo81wzyeiezofw.jpg)

- Sunday : Helped look over a friend's resume and gave some feedback. Watch the Movement for a People's Party convention live stream. Had some really good speakers. Did a little research on the side project.

- Professional : Today I found out how to fix an error on a pull request I did last week. It passed all the tests this time. Nice. Worked on a new Web Component. Also wrote out a script for a promo video I'll be putting together this week.

- Personal : Got most of the things I need to put solar panels on top of my van's roof. Waiting on the rack that will hold the solar panels to the top of the van. The website said I would have gotten it on Friday. Nope. Got an email that says it was shipped. If I knew I wouldn't be getting it the next day, I would have just had it shipped to my parents' place like all the other stuff. Never ordering from them again! haha.

![Green cliffs surrounding a cove that opens into the ocean in County Clare, Ireland](https://dev-to-uploads.s3.amazonaws.com/i/eozav6mzss7a7pd1w5xn.png)

About to leave my parents' place and back to my parking spot. I'll probably stop off and get some food on the way. Going to work on my side project some more. There's some things I want to try. About to head out, was waiting for traffic to hopefully not be too bad.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube QpOkxBeng2I %}
To:CEO; Subject:TESTING
Tags: testing
Published: 2020-08-31 21:21:14

---
title: To:CEO; Subject:TESTING
published: true
description: As developer sometimes we need to test things connected to external services if we didn't take enough caution we can end up with a test mail on the CEO inbox. I don't want this, you don't want this, lets mock up our external servers 
tags: testing
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ncxxh1ccrm9lisyhwzjy.png
---

Last week I received a mail from a user:

>Subject:  **"RE: Testing WTF"** 
>Body:    _"please stop sending these test emails"_

At first, we tried to replace all the email addresses on the database and config files, but the feature that sends the emails uses a lot of business logic. So we wanted to test the feature with a more realistic and end-to-end approach.

After looking for a while I found this lovely piece of software. [MockMock](https://github.com/tweakers/MockMock) is a very simple but powerful SMTP mock server built in java.

How it works:
Simply download the MockMock.jar and run `java -jar MockMock.jar` this starts the SMTP server on the port 25 and an HTTP server on port 8282.

Now you can configure your SMTP server as `localhost` on port `25`, when the application sends an email just browse on `http://localhost:8282/` and you'll see something like this:

![mockmock email list](https://dev-to-uploads.s3.amazonaws.com/i/dvp9arsdkcjuuhgptfv9.png)

And we can see de detailed info of each mail:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3o2ye9m2arp3tqhh8agz.png)

You can also change the ports with `-p` argument for SMPT and `-h` for HTML like  `java -jar MockMock.jar -p 25250 -h 8080` 

I love this type of test because we can extend our test cases and look for the result in a fancy and safe way.
Rapid Development + Scaling Web
Tags: help, discuss, linux, webdev
Published: 2020-08-31 21:19:56

What does everyone use these days for rapid development for the web?

I tend to have strong feelings against wordpress and similar CMS, but end up needing a CMS like features to allow people to post, login, moderate etc.

I'm not stuck with any technology but I know i'm not great on the frontend side, so I'd love to find something that's fast to get something out while not being a nightmare to scale up if we need to down the line (Like Wordpress for example )

--
csgeek
Fear and Loathing with a CLI
Published: 2020-08-31 21:18:59

The biggest lesson I learned with how to build a CLI from scratch is how to mind my own hubris. 

Up until the start of project mode I had the labs down. I chased the green passing methods relentlessly, I thought the project was going to be a breeze, I thought I had this, I thought wrong. When I actually started to code I realized that the undertaking was a lot bigger than I thought it was going to be and I maybe didn't know things as well as I thought I did. I started to panic.

The New York Times Book section has always been a favorite section of mine, I have found a few of my favorite books reading their reviews and opinion pieces. So when it came down to coming up with an idea for a project, I thought about doing a New York Times API. So I decided to make a CLI that used and API that pulled book summaries from the New York Times and provided summaries for those books. 

My biggest struggle with writing the API class was getting lost in the details. I'd get so focused on some small side thing that I would loose sight of the bigger picture. In the future, when writing a program from scratch, I definitely want to come up with a plan of action before I actually start to code. 

When all is said and done though, as hard as it was, I'm really proud of myself for finishing the project. It really brought home topics I wasn't very strong in to begin with and I learned a lot of in depth coding. It was a very cool process to be able to use what I've learned so far to make something like a CLI, and to also use those skills to learn things I needed to know to finish the project. As much sleep as I lost stressed about this project, I would absolutely do it again.