teleren/devto huggingface dataset:
Firestore Modelling Data
Tags: firebase, firestore, data, modelling
Published: 2019-08-24 16:54:15

---
title: Firestore Modelling Data
published: true
description: Instagram clone
tags: firebase, firestore, data, modelling
---

Hi,

I want to create an instagram clone with firebase and found some limitations while working on the datastructure. 

As the documentation reccomends to keep the documents as small as possible and the collections big I have created this model.

```
+ Profile (collection)

  |--- uid (document)

      |--- userName (String)

      |--- firstName (String)

      |--- lastName (String)

      |--- profileImgUrl (String)

      |--- userName (String)

      |--- UserPosts (collection)

         |--- uid (document)

            |--- title (String)

            |--- createdAt (timeStamp)

            |--- description (String)

            |--- imgUrl (String)

```

I have decided to go with this model because by splitting `Profile` and `Post` into seperate root collections I am not able to query Posts by `userName` without a second query after I get the `uid` of the user.

My problem now is that I dont know how to write a query to get the posts of a user by `userName`
Corbind. First stable release.
Tags: kotlin, android, library
Published: 2019-08-24 16:33:50

Hi everyone! I don’t want to take a lot of time, so ...

Finally it happened. New Kotlin Coroutines [release][coroutines] and the first stable (more or less) release of Flow API.
I think it's time for me to release the first stable version of Corbind.

## What is Сorbind?
Kotlin Coroutine binding APIs for Android UI widgets from the platform and support libraries. Supports [Flow][flow], [ReceiveChannel][channel] and [Actor][actor].
You can learn more about how to use the library if you follow the link below.

Github link: https://github.com/LDRAlighieri/Corbind
Current version: 1.0.0

Thank you.


[coroutines]: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.3.0
[flow]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html
[channel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/index.html
[actor]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/actor.html
1Gbps Internet Speedtest by OpenSpeedtest.com
Tags: javascript, docker, html, linux
Published: 2019-08-24 16:15:52

Install Docker and run the following command!

1) docker run --restart=unless-stopped --name=openspeedtest -d -p 80:8080 openspeedtest/latest

Now Visit http://localhost/ or http://YOUR-IP/

This can run offline! So you can use it to test your Local Area Network or put it on a server to test your line speed to that server. Currently optimised to test speeds up to 1~2 Gbps. You can change the values and files inside this docker and can test even faster connection.
Emails getting cut off in Gmail
Tags: gmail, htmlemail, css
Published: 2019-08-24 15:41:49

---
title: Emails getting cut off in Gmail
published: true
description: Gmail will cut off and display [Message clipped] View entire message at the bottom of your email if the email is larger than 102kb. 
tags: #Gmail #HTML_Email #CSS
---

Have you ever noticed your email been cut off in Gmail, this is because of the Email file size is larger than 102kb. A quick fix i found for this was to get rid of unwanted spaces in your HTML by using this tool https://htmlcompressor.com/compressor this helps in stripping and optimising the file size to the barest minimum. 


**Please note:** the 102kb limit is based on the amount of content in the HTML code, not the size of specific images in your message. While resizing an image will not change the size of the content, deleting an image from the email body will reduce the size of the message.
Dev parents, how do you do it?
Tags: anonymous, career, discuss
Published: 2019-08-24 15:22:59

---
title: Dev parents, how do you do it?
description: How do parents who work in tech balance parenting and their careers?
published: true
tags: anonymous, career, discuss
---

_This is an anonymous post sent in by a member who does not want their name disclosed. Please be thoughtful with your responses, as these are usually tough posts to write. Email sloan@dev.to if you'd like to leave an anonymous comment._

I am at what feels like the prime of my career. I am crushing it at work and moving up to take on larger leadership positions at my company. My speaking career has really exploded and I am consistently getting asked to talk at conferences. With all of this going on I have been considering have kids. I never thought I wanted kids but now I am reconsidering. I am 32 years old and I definitely would like to be a younger mom so I see it as now or never. 

However, I am worried if I did it now my career would suffer and I wouldn't have the time to work and speak. I'm also worried as to how I will be perceived. If people will take me less seriously. I love my current life but I wonder if there is more, if I am missing out by not having kids somehow.

Parents, who work in tech, especially those who work and speak, how do you do it? Is it something you would recommend? What are the pros and cons? Please don't hold back, I want the honest truth so I can make the best-informed decision possible.

Thank you in advance for taking the time to read this and respond! ❤️️
Count of a List in D
Tags: dlang, tutorial
Published: 2019-08-24 15:07:26

In this case I wanted to get the number of elements in my list. It isn't hard with D arrays, however my search came to tasks of counting the number of elements which met a condition so I think I should cover that as well. 

```dlang
auto arr = [1, 2, 3];
assert(arr.length == 3;
```

To count based on criteria there are a number of options in D. 

```dlang
import std.algorithm;
auto arr = [1, 2, 3, 2];
assert(arr.count(2) == 2);
```

```dlang
import std.algorithm;
auto arr = [1, 2, 3, 2];
assert(arr
       .filter!(x => x == 2)
       .count() == 2);
```

Fun fact, the `filter` uses a lambda which provides more power but this technique works with `count` too.

I want to note that we're entering a more general form of navigating data. User types which expose a range. Again this is beyond the scope of this article. As you start using range based algorithms, import std.array and call `.array` to eagerly evaluate and get an array which meets all range type requirements. 

https://tour.dlang.org/tour/en/basics/ranges
Does writing a "Dev Blog" help improving your skills?
Tags: beginners, discuss, programming, career
Published: 2019-08-24 14:36:33

Hi I am Stefan and I have been a developer since two years now.
This is my first post here on dev.to but I am really curious what you think about this topic :) 

Every now and then I am asking myself if writing a developer blog (or maybe even a live coding stream) would improve my skills in coding. 

The main reason behind my thinking is, that the explanation of something complicated in a simple way, for example to other developers in my team, can change my point of view to some algorithms or written code.

Most of the time it happens, that i refactor my code right afterwards I had a talk with another team member because it fells like I was hit by an enlightenment.

What do you think about this? 

Can even talking about a topic I don't know that well help me, to improve my skills in a new language or framework? (for example learning node.js and just write some blog entries about what I have learned today and how I could manage to reach a certain goal?)

Every discussion and tip about this is really appreciated :)
ES6 for loops: Best Practices
Tags: javascript, beginners, todayilearned, codenewbie
Published: 2019-08-24 14:35:33

For loops are common control flow statements used to iterate over range, sequential data types etc. The ES6 revision of JavaScript provides several new features making the language more powerful, crisp and elegant. Here's what I came across as the best practices for the _for_ loop:

## Vanilla <code>for</code> loop
```javascript
// Old and Bad way

for(var i = 0; i < 10; i++) {
  // Do Stuff
}
// End of loop

console.log(i)
// 10
// iterator still accessible after the end of the loop
```
Using _var_ to initialize the iterator in the traditional _for_ loop causes it to be accessible even after the loop is over. A better alternative is to use the newer _let_ keyword to initialize the iterator.
```javascript
// Better way

for(let i = 0; i < 10; i++) {
  // Do Stuff
}
// End of loop

console.log(i)
// undefined
// iterator not accessible
```
The _let_ keyword limits the scope of the iterator to the for loop block only.

## Newer flavors of <code>for</code> loop
The ES6 revision also provides two new for loops the _for..of_ and _for..in_ loop.

**_for..of_:**
```javascript
let primes = [2, 3, 5, 7];

for(const value of primes) {
  console.log(value);
}
// 2
// 3
// 5
// 7
// Iterates over the values of the array
```

**_for..in_:**
```javascript
let primes = [2, 3, 5, 7];

for(const key in primes) {
  console.log(key);
}
// '0'
// '1'
// '2'
// '3'
// Iterates over the keys of the array
```
Notice that the _for..in_ loop here returns the keys in the form of strings and not numbers as one would expect. Another weird thing about the _for..in_ loops is that they can iterate thru an object while the _for..of_ loop cannot:

```javascript
let sandwich = {
  grilled: true,
  butter: "lots",
  bread: "whole wheat",
  calories: 250
}

for(const value of sandwich) {
  console.log(value)
}
// Error: Objects are not iterable

for(const key in sandwich) {
  console.log(key)
}
// "grilled"
// "butter"
// "bread"
// "calories"
```

## <code>const</code> vs <code>let</let>
If you were reading until now really carefully, you would have noticed that I have use _let_ in the vanilla _for_ loop and _const_ in the ES6 flavors of _for_ loops. The vanilla _for_ just increases the initial iterator value and there is a single scope for the whole loop. Thus using _const_ won't work as increasing the iterator value in the next iteration will result in an error. In the newer loops however, every iteration creates a new scope. Thus we can use _const_ as well as _let_ in these loops. _const_ is more preferred in such cases as we don't want to change the value of the iterable.

> And that's it folks! Thankyou for reading and have a great day 😄
Windows 95 Web UI Kit
Tags: webdev, css, javascript, retro
Published: 2019-08-24 14:31:48

Demo: https://themesberg.com/preview/windows-95-ui-kit
Download: https://themesberg.com/product/windows-95-ui-kit
Github Repo: https://github.com/themesberg/windows-95-ui-kit

Relive the awesome 90's design trends by using our Windows 95 UI Kit. It features over 50 unique Bootstrap 4 Components including the infamous Windows 95 icons.

We've carefully recreated the windows cards and all components have their versions in the three basic colors: grey, teal and blue.

List of components:

- Default Buttons
- Bordered Buttons
- Buttons Color Variations
- Form Controls
- Windows 95 Checkboxes
- Windows 95 Radio Buttons
- Original Windows Cards with variable colors
- Windows 95 bar as a Bootstrap 4 Navbar
- Nav Tabs
- Basic Typography

We also offer a full documentation with available code snippets. We used NPM to manage our dependencies and jQuery for a little bit of magic.

The project is very easy to set up, all you need to do is download the zip and open the index.html page from your folder.

If you like this UI Kit make sure to check out our other free and premium products on Themesberg.com!

Demo: https://themesberg.com/preview/windows-95-ui-kit
Download: https://themesberg.com/product/windows-95-ui-kit
Github Repo: https://github.com/themesberg/windows-95-ui-kit
nth-child CSSGrid Checkerboard Pattern
Tags: codepen
Published: 2019-08-24 12:41:57

{% codepen https://codepen.io/rebelclause/pen/mdbWbXz %}

Even after cobbling this example, following a cursory search for something that might explain to me the subtleties of nth-child and nth-of-type, these two pseudo-selectors remain in my mind still as somewhat of a mystery.

In testing out various approaches, my imagining of their use soared into Machine Learning territory, as patterns flashed across my screen like so many blinking lights in an early Bond movie computer mainframe housing, calculating ballistic missle trajectories to the forbidden hard target.

It's doubtful the grid presented here will destroy the world any time soon... I really hope not. It may be the games which we decide to play on a board such as this that will really determine what any given set of patterns will ultimately mean for the fate of Mankind.

Since, for me, it's trouble enough figuring out nth-child and nth-of-type, I'm leaving the ways of intrigue behind as too much bother on top of the search for a solid use case for this hard-won bit of 'legendary' programming. 

It's OK if you laugh. That's part of every good game no matter how inconsequential it may seem.

If you have some idea to make use out of it, so much the better. I'd like to hear what you might do or want to see done.
Need contribution, Node-GTK project
Tags: contributorswanted, githunt, cpp
Published: 2019-08-24 14:14:07

## What is Node-GTK?
[Node-GTK](https://github.com/romgrk/node-gtk) is a work in progress to bring [GTK+](https://www.gtk.org/) can usable directly from `NodeJS` so that the environment would be more updated and supported than the one available via [GJS](https://gitlab.gnome.org/GNOME/gjs). It uses the `GObject Introspection` library (as `PyGObject`, for example), so any `GObject-Introspectable` library is supported.

## Why Node-GTK is useful?
This is very useful for those of you who want to build desktop applications that can run on `Linux`, `Mac`, `Windows` using javascript. With the help of `NodeJS (C / C ++ Addon)` and `GTK +`, we can easily build cross-platform desktop applications. maybe you have already tried `Electron`, but we know that it runs on` browser runtime`. Of course, it requires `large memory` and size. Even for a simple application like a calculator, you need a minimum of 40MB to install it. Therefore, with this `Node-GTK` project, we hope we can overcome that problem.

## What types of contributions are needed?
- API documentation
- Testing code performance
- Bind C ++ libraries to NodeJS (Node C / C ++ Addon)
- Creating an effective and efficient API (JS and C ++)
- Code Review
- Test and report problems and feedback

## List of possible programming languages?
- Javascript (NodeJS)
- Shell Script Language (Bash. Etc)
- C++

I hope this would be helpful for them that want to make their first contribution to the open-source project.


Thank you... 


Repo => **[Node-GTK](https://github.com/romgrk/node-gtk)**
The Art of Making It Happen
Tags: productivity, career, feeling, management
Published: 2019-08-24 12:09:57

Getting Things Done, or simply GTD, is a task management system created by David Allen who also wrote a book with the same name. After reading the book I'll write this as much as possible, brief summary.

The method aims to leave those who have adopted it with the mind as water, a state of mind where you are no longer concerned with remembering what to do because you can trust that everything you need to do is already written down so you can focus so well and exclusively on what you need to do at the moment. With this method you will capture all your disorder in an external system and it is this system that will help you organize what you need to do and have everything under control.

The GTD is based on five steps to make things happen:

1. Capture everything;
2. Process;
3. Plan;
4. Review;
5. Begin to work.

**Capture everything:** Literally take all the tasks out of your head and move on to an external system that is more reliable.
**Process:** At this point you must process everything you've captured in clear action steps that require action. Decide if the items are a project, next action or reference.
**Plan:** It is important to have your lists organized so put everything in the right place. Add dates to your calendar, delegate projects to others, archive reference material, and sort your tasks.
**Review:** This is the time to review the entire system to update the information and gain perspective.
**Get to work:**  It's running knowing what you're doing at that moment, the most important thing you should be doing.

The method still relies on the rule of two minutes, which basically is to perform at the current time, now, everything that takes less than two minutes.

The key to any productivity system is to keep it as simple as possible and use it as often as possible.

Do you have a question or do you want a hint? Use the comments! 

Thank you for reading!

Best regards,
Daniel Maurer
VirtualBox: Taking Screenshots of Guest Windows
Tags: virtualbox, screenshots, hostkey, howto
Published: 2019-08-24 10:34:39

---
title: VirtualBox: Taking Screenshots of Guest Windows
published: true
description: It's a pity around the guest system screen of VirtualBox that "Alt + PrintScreen" doesn't work when running the guest system and activating its screen window. But there is a way: "Host Key + E".
tags: virtualbox, screenshots, hostkey, howto
---

It's a pity around the guest system screen of [VirtualBox](https://www.virtualbox.org) that "Alt + PrintScreen" doesn't work when running the guest system and activating its screen window.
But there is a way: "__Host Key + E__".

Click the combination at this time:

![desktop](https://thepracticaldev.s3.amazonaws.com/i/l8pav9htjs8kdkdvaeje.png)

It calls the saveas dialog:

![saveas popup](https://thepracticaldev.s3.amazonaws.com/i/3gdkc6dqcmdt0dehmuyk.png)

The result is (as an image file):

![screenshot](https://thepracticaldev.s3.amazonaws.com/i/n2upgdv2ys5sogj0woap.png)

---

Besides, you can edit Host key binding:

{% link nabbisen/virtualbox-configuring-host-key-3akl %}
NodeJS: How To Use The URL Module
Tags: javascript, node, eli5
Published: 2019-08-24 10:32:14

---
title: NodeJS: How To Use The URL Module
published: true
description: How To Use The URL Module
tags: javascript, node, eli5
series: Intro to NodeJS
---

## Intro

So we [installed NodeJS](https://dev.to/miku86/what-is-nodejs-how-to-install-it-1900) on our machine.

We also know [how to use commandline arguments](https://dev.to/miku86/nodejs-how-to-run-scripts-from-the-terminal-use-arguments-2olm).

Now we want to learn how to process an `url` from the commandline by using the [URL module](https://nodejs.org/api/url.html).

## Write a simple script

- Open your terminal
- Create a file named `index.js`:

```sh
touch index.js
```

- Add this JavaScript code into it:

```js
const url = require('url');

const myUrl = process.argv[2];

if (myUrl) {
  const { href, host, pathname, protocol } = new URL(myUrl);

  console.log(`The HREF is: ${href}`);
  console.log(`The Protocol is: ${protocol}`);
  console.log(`The Host is: ${host}`);
  console.log(`The Pathname is: ${pathname}`);
}

```

Note: I use the most used url properties to decrease the complexity of this simple example. To see all the available properties, read [the docs of the URL module](https://nodejs.org/api/url.html#url_url_strings_and_url_objects).

---


## Every line explained

```js
// import the url module
const url = require('url');

// read the third argument (= the url ) & save it into a variable
const myUrl = process.argv[2];

// only run this block if the user inputs a third argument
if (myUrl) {
// destructure these specific properties from the URL
  const { href, host, pathname, protocol } = new URL(myUrl);

// log the destructured properties
  console.log(`The Href is: ${href}`);
  console.log(`The Protocol is: ${protocol}`);
  console.log(`The Host is: ${host}`);
  console.log(`The Pathname is: ${pathname}`);
}
```

Sometimes you can see the usage of [url.parse()](https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost) from the [Legacy URL API](https://nodejs.org/api/url.html#url_legacy_url_api). The Legacy URL API is deprecated, [don't use `url.parse()`](https://nodejs.org/api/url.html#url_legacy_url_api), use `new URL()`.

---

## Run it from the terminal

- Run it: 

```sh
node index.js https://miku86.com/articles
```

- Result: 

```sh
The Href is: https://miku86.com/articles
The Protocol is: https:
The Host is: miku86.com
The Pathname is: /articles
```

---

## Further Reading

- [URL module](https://nodejs.org/api/url.html)
- [URL properties overview](https://nodejs.org/api/url.html#url_url_strings_and_url_objects)
- [URL properties explained](https://nodejs.org/api/url.html#url_class_url)


---

## Questions

- Do you use the native `URL module` or some libraries like [query-string](https://www.npmjs.com/package/query-string)? Why do you use it?
Hybrid Load Balancing traffic between EC2 and Lambda functions - useful API migration pattern
Tags: aws, cloud, serverless, api
Published: 2019-08-24 09:51:47

---
title: Hybrid Load Balancing traffic between EC2 and Lambda functions - useful API migration pattern
published: true
tags: AWS, Cloud, Serverless, API
---

With [this](https://github.com/serverless/serverless/pull/6073) particular PR included in version `1.45`, the Serverless Framework team has finally enabled a possibility of using Application Load Balancers as event source instead of using API Gateway.

We've heard few of stories where [replacing costful API Gateway with ALB has saved thousands of dollars](https://serverless-training.com/articles/save-money-by-replacing-api-gateway-with-application-load-balancer/) and it's really awesome but here I'd like to talk about another aspect which might be really helpful in migrations:

# Hybrid Load Balancing

Imagine following scenario: your company wants to migrate from ECS/EC2 to Lambda by stripping monolith web server route by route. It appears that such thing can be achieved easily with multiple target groups associated with Load Balancer. Instead of just one, you can specify many of them and basing on request paths (or whatever you like) route requests to EC2/ECS or to Lambda.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/sx6aanbuysdwuyip73vg.png)

# How to do that?

1. If you don't have existing infra, provision [VPC](https://github.com/RafalWilinski/hybrid-load-balancing/blob/master/infra/vpc.yml), [EC2](https://github.com/RafalWilinski/hybrid-load-balancing/blob/master/infra/ec2.yml) and [ALB](https://github.com/RafalWilinski/hybrid-load-balancing/blob/master/infra/alb.yml), prefereably in separate files to keep it simple and clean. Otherwise, use existing ALB ARN.

2. Reference supplement CloudFormation files in main `serverless.yml` file:

```
resources:
  - ${file(./infra/alb.yml)}
  - ${file(./infra/ec2.yml)}
  - ${file(./infra/vpc.yml)}
```

3. Replace traditional `http` event with `alb` where you specify which Load Balancer, Condition and Priority. In this case all requests to path `/lambda` will be routed to Serverless solution. Rest of them will be routed to the EC2 based on rule specified [here](https://github.com/RafalWilinski/hybrid-load-balancing/blob/master/infra/alb.yml#L23-L34)

```
functions:
  hello:
    handler: handler.handle
    events:
      - alb:
          listenerArn:
            Ref: albListener
          priority: 1
          conditions:
            path: /lambda
```

One thing worth noting here is that Lambda priority should be bigger than server's, so it should look something like this:

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ziejuyps1ta12f84at5o.png)


If you want to check fully working example, the source code can be found [here](https://github.com/RafalWilinski/hybrid-load-balancing)

Just run it with:

```
serverless deploy
```

This article was originally published at [servicefull.cloud](https://servicefull.cloud/blog/hybrid-elb/)