teleren/devto huggingface dataset:
A Simple Way to Clean up Docker
Tags: beginners, docker
Published: 2020-06-16 17:41:09

---
title: A Simple Way to Clean up Docker
published: true
date: 2020-03-27 00:00:00 UTC
tags: beginners,docker
canonical_url: https://mannes.tech/clean-up-docker
---

Have you ever had a full hard drive because of Docker? I had. All those old Docker containers, images, and volumes take up so much space. I used commands like `docker stop $(docker ps -a -q)` and `docker rm $(docker ps -a -q)`  to remove all containers and images.

But newer Docker versions (Docker with API version 1.25+) have this handy cleanup command:
```bash
docker system prune --volumes
```
It cleans up all stopped containers, unused networks, dangling images, and the build cache. The `--volumes` flag also removes all unused volumes. You can skip the "are you sure" prompt by using the `-f` or `--force` flag

Beforehand, you will want to stop all containers using this command:
```bash
docker container stop $(docker container ls -aq)
```
And voilá! You have a clean local Docker installation.

Bonus tips:
- Find out how much space Docker takes on your system with: `docker system df`
- Use the `until` filter to only clean up stuff created more than, e.g., two days ago: `docker system prune --filter "until=48h"` (Docker API version 1.28+; use `docker version` to find out the versions of your client and daemon)
- Only clean up containers created more than two days ago: `docker container prune --filter "until=48h"`
My Tech Journey Wk 3 update
Published: 2020-06-15 23:58:34

14th June, 2020
Even though I'm writing this a little late, no I did not forget to update this blog.

It's becoming difficult to stick to this schedule but I will push through. Here's an update on last week:

1. My friend taught me some C programming. It's the first actual language I've learnt (other than Pascal). I enjoy the logic and problem solving of programming.

2. I learnt a little about Game Programming Mechanics on Futurelearn. It was interesting so I will try to complete it soon.

I will be focused on my studies so programming will be a necessary challenge.


Xoxo. Thanks for following along. Leave a comment on how I can manage my time or on what I should learn next.
What's the quickest, most rigorous path to becoming a game developer?
Tags: unity3d, game, c
Published: 2020-06-15 23:27:36

For context, I'm a JavaScript software developer and I've written my fair share of [MUD (multi-user dungeon) games and canvas-based games](https://justin.irabor/projects), but lately I've been trying to kick it up a notch and create more robust, visually appealing games (ideally) for the web. 

(Aside: I've been learning three.js, creative coding and AR.js. I'm neither here nor there with those either)

I hear that I need to learn Unity and C++, but I'm not particularly sure the best way to dive into this, and the more I think about it, the more I overthink it - the more I find myself procrastinating. 

In a nutshell, I need help: if you're a game developer, what things do I need to know? I could really use a syllabus-styled list. 

I'll appreciate all the help I can get! 

Thanks
React : Problem calculating points for a questionnaire
Tags: reactnative, javascript
Published: 2020-06-15 23:23:23


Hello,
I would like to develop a point system for my questionnaire but I have a little trouble putting that.
I have 2 types of Questions:
- Free fields (and if the user answers correctly, he earns 10 points or nothing)
- Multiple question (and if the user answers correctly, he earns 10 points if nothing).
And then collect all the points in order to add them up and then display the points and the name of the user at the end of the questionnaire.

Does anyone have an idea to unlock so that I can start my development?

Thank you
Coffee Companion App LS:007
Tags: swift, swiftui, ios
Published: 2020-06-15 22:32:40

---
title: "Coffee Companion App LS:007"
published: true
description: Coffee Companion - iOS app development.
tags: [Swift, SwiftUI, iOS]
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/30uyz1j8uwzh0jbqeq7n.png
canonical_url: https://www.ko-fi.com/post/Coffee-Companion-App-LS007-I2I11TNVJ
series: Coffee Companion App
---

Thanks for all that joined me on the live stream! Make sure to tune in next week same time (1pm CDT on Friday) and [same place](https://twitch.tv/appsbymw)!

{% youtube sTfO1GOWtYU %}

# What did I do in the stream?

- Added a notes function to brew method
- Made the timer turn orange when the bloom time has been hit

# What am I doing in the next one?

- Make the timer not stop when the app goes into the background
- Make the edit button align vertically with the back button

Also, I'm really close to a 1.0 release 🥳!

# Looking for more about the project?

- Make sure to watch the next stream on [my Twitch](https://twitch.tv/appsbymw)
- Want to know what tasks need to be done or what's being planned for the app? [Check out the Trello board](https://trello.com/b/KgqJHA8o/coffee-app)
- Want to see the code? Dig through the [GitHub repo](https://github.com/appsbymw/coffee-app) and star, watch, or sponsor it!
- Want to help fund the app and get your name listed at the end of the stream? Buy me a coffee or two on [Ko-Fi.com](https://ko-fi.com/appsbymw)

[![Donate Caffeine by buying me a coffee on Ko-Fi](https://dev-to-uploads.s3.amazonaws.com/i/8fey6iatjrl7cvrent11.png)](https://ko-fi.com/appsbymw)

---

Find me on the socials!

![Follow me on social media](https://dev-to-uploads.s3.amazonaws.com/i/hdy3a8kjjqn9i8frzs2j.png)
Road to Genius: smart #16
Tags: javascript, beginners, computerscience
Published: 2020-06-15 22:25:52

Each day I solve several coding challenges and puzzles from Codr's ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, and you will learn a ton of new and interesting things as you go.

![coding challenge](https://dev-to-uploads.s3.amazonaws.com/i/xwznjpsj88r8c48o40wj.png)

Let's jump right to it. We need to fix one bug 🐼, which should be an identifier (most likely a variable name). The code starts with a function `canJump`. If you analyze the code, it seems some strange algorithm that returns a boolean value. Fortunately we don't have to fully understand the code to complete the challenge.

Let's focus on the buggy line which is in the form of `max = Math.max(a, b)`. This is a very common line of code for keeping track of the largest/max value while iterating an array. In our simplified form, the code returns `a` if `a > b` otherwise it returns `b`. In our challenge code, `a` is given, and `b` is 🐼. The code is likely going to compare `a` with the current `max` value. So 🐼 must be `max`:

![coding challenge answer](https://dev-to-uploads.s3.amazonaws.com/i/he6cfud3vkobqmpdvofk.png)

---

If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at https://nevolin.be/codr/
Coffee Companion App LS:006
Tags: swift, swiftui, ios
Published: 2020-06-15 22:23:14

---
title: "Coffee Companion App LS:006"
published: true
description: Coffee Companion - iOS app development.
tags: [Swift, SwiftUI, iOS]
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/30uyz1j8uwzh0jbqeq7n.png
canonical_url: https://www.ko-fi.com/post/Coffee-Companion-App-LS-006-G2G81TNUI
series: Coffee Companion App
---

Thanks for all that joined me on the live stream! Make sure to tune in next week same time (1pm CDT on Monday) and [same place](https://twitch.tv/appsbymw)!

{% youtube sh77-oUGMkE %}

# What did I do in the stream?

- Add CloudKit to share on all devices
- Made time and button bigger
- Able to edit brew method from a list

# Looking for more about the project?

- Make sure to watch the next stream on [my Twitch](https://twitch.tv/appsbymw)
- Want to know what tasks need to be done or what's being planned for the app? [Check out the Trello board](https://trello.com/b/KgqJHA8o/coffee-app)
- Want to see the code? Dig through the [GitHub repo](https://github.com/appsbymw/coffee-app) and star, watch, or sponsor it!
- Want to help fund the app and get your name listed at the end of the stream? Buy me a coffee or two on [Ko-Fi.com](https://ko-fi.com/appsbymw)


[![Donate Caffeine by buying me a coffee on Ko-Fi](https://dev-to-uploads.s3.amazonaws.com/i/8fey6iatjrl7cvrent11.png)](https://ko-fi.com/appsbymw)

---

Find me on the socials!

![Follow me on social media](https://dev-to-uploads.s3.amazonaws.com/i/hdy3a8kjjqn9i8frzs2j.png)
Job Search Week 17
Tags: makers
Published: 2020-06-15 22:13:29

This week I started with a review and I finished off the backend of my message board app. I also updated my CV and projects guide to show off my message board app.

Day 1

So I started this week off with a review. It was good to get another one done plus I'm definitely a lot better with my process. My feedback was mostly steady so I'm feeling a lot more confident with my process.

Day 2

On Tuesday I tidied up my review repository cleaning up and finishing any features I was adding and adding the read me. I also updated my projects guide to link to this review as it is my most recent review.

Day 3

I updated my GitHub Cv on Wednesday because I was mainly working on external CV's so I thought it'd be a good idea to update it to reflect what I've been doing. It was also nice to see how I've come since completing Makers.

Day 4

I was working on the message board app on Thursday. I was adding the update function and changing the HTML to show that you were updating a message. I also did quite a bit of debugging to fix some broken tests so it was a relief to get that done.

Day 5

Friday I did the error handling for the update function in case the user tries to give invalid input like an empty string. So I'm getting closer to wrapping this project up.

Summary


I felt really good about my review since the last time I did one the feedback had far more improving than steady. So it's good to see that I'm getting better. I'm also very close to finishing my message board app which would mean I've completed a full-stack MERN project.
Deno REST API / MongoDB or PostgreSQL
Tags: deno, mongodb, node, postgres
Published: 2020-06-15 22:12:27

Hi folks! This is my first project working with Deno. It's only a 'getting started' kind of project with a simple Rest API and MongoDB/PostgreSQL connection.

## Installation
First we need to instal Deno following this [link](https://deno.land/manual/getting_started/installation). 
In order to use MongoDB or PostreSQL we include them with Docker implementation (Install [Docker](https://docs.docker.com/get-docker/) and [Docker compose](https://docs.docker.com/compose/install/)). Otherwise you can use your own database engine, and obviously you have to change your connection string.


## Features
With this simple project you will be able to test /users endpoints (GET, POST, PUT and DELETE). And you can decide which db use only adding the query string db=mongo or db=postgres.


## Running the project
If you will use docker-compose you have to run on the root of the project:
```javascript
docker-compose -f docker/docker-compose.yaml up
```
Await a few seconds until databases are ready and then run in another terminal window:
```javascript
deno run -A --allow-net --allow-write --allow-read --allow-plugin --unstable index.ts
```
After this the server has to start and you will be able to make requests.


## Repository
You can find the repository code [here](https://github.com/renacargnelutti/deno-rest-api)


### Note: I'm working on this project and I will be adding more details and explanations. Let me know if you have a doubt.
Control text excerpt length with JavaScript
Tags: javascript, html
Published: 2020-06-15 22:10:12

# Why not use CSS?
The CSS version works just fine and there are actually a couple ways you can pull it off. But, it feels like a bit of a "hack" to me. Using JavaScript feels more purposeful and makes a little more sense in my opinion.

# Let's get started

### Write a function
`function myFunction() {`

### The string
You'll need to assign a variable for your string. For this example, I'll write the string in:
`var str = "Killua Zoldyck is the best friend of Gon Freecss";`

If you're trying to pull all excerpts in your blog, you'll need to find the class name used and call that in:
`var str = document.getElementByClassName("my_excerpt");`

### The output
Next, you'll need to define a space to insert your excerpt in the HTML:
`var output = document.getElementById("excerpt_area");`

### The if statement
The first thing we want to do here is decide our character length. For this example, we'll set it to 10 characters.
So, let's start by checking if our string is greater than 10 characters using `.length`:
`if (str.length > 10) {`

Next, let's tell our function what to do if that criteria is met. We'll need to only show part of the string using `.substring()` which requires two arguments: a start and end point in the string. We'll tell it to start at character 0 and end at character 10:
`str = str.substring(0,10);`

Optional:
I like to show the user that we're clipping the text by adding three periods. We can simply add on to our if statement:
`str = str.substring(0,10) + "...";`

Lastly, we can close our if statement.

### Showing the excerpt
Using the output variable we defined, we can use `.innerHTML` to print our excerpt:
`output.innerHTML = str;`

We place this outside the if statement so that any excerpts below 10 characters will still be shown in the HTML.

The end result should show: "Killua Zol..."

### Full code snippet:
```javascript
function myFunction() {
    var str = "Killua Zoldyck is the best friend of Gon Freecss";
    var output = document.getElementById("excerpt_area");
    if (str.length > 10) {
        str = str.substring(0,10) + "...";
    }
    output.innerHTML = str;
}
```
Diferenças entre querySelector() e getElementById()
Tags: ptbr, javascript
Published: 2020-06-15 22:02:47

Recentemente comecei a estudar JavaScript por "n" motivos e uma coisa que eu pude perceber, é que uns professores ensinam a mexer na DOM usando o <code>getElementById()</code> e outros usam o <code>querySelector()</code>. De inicio achei normal já que fazem praticamente a mesma coisa, porém não são os mesmos. Sabendo disso, resolvi trazer esse post mostrando algumas informações encontradas.

##Qual a função de cada um
###querySelector()
Retorna o primeiro elemento dentro do documeto que foi especificado pelo seletor. O <code>querySelector()</code> aceita os atributos ids, classes e outros parametros de seleção.

Exemplo:

```
<h2 class="exemplo"></h2>
<script>
    document.querySelector(".exemplo").innerHTML = "Olá mundo!";
</script>
```

```Saída:
Olá mundo!
```

###getElementById()
O getElementById retorna o elemento com o id selecionado.

Exemplo:

```
<h2 class="exemplo"></h2>
<script>
    document.getElementById("exemplo").innerHTML = "Como está?";
</script>
```
```Saída:
Como está?
```

Como o metódo procura somente ids, não será necessário usar o "#" para especificar que é um id. Diferente do <code>querySelector()</code> que deve sim informar, já que faz uma busca em todo o documento por aquilo que foi especificado.

##Benchmarck

Mesmo sendo similares, o <code>querySelector()</code> pode procura em uma DOM, uma id ou classe, diferente do <code>getElementById()</code> que só procura pela id selecionada. Mas será que há uma diferença no quesito velocidade? Pelo visto sim, e é o que o site MeasureThat.net [pode mostrar nesse benchmark](https://www.measurethat.net/Benchmarks/Show/2488/0/getelementbyid-vs-queryselector):

![Resultados do benchmarck entre getElementById e querySelector](https://dev-to-uploads.s3.amazonaws.com/i/dl2hh3m0711hbzhtlhc0.png)
<figcaption><a target="_blank" href="https://www.measurethat.net/Benchmarks/Show/2488/0/getelementbyid-vs-queryselector">Fonte: MeasureThat.net</a></figcaption>

Segundo o [benchmark](https://www.measurethat.net/Benchmarks/ShowResult/112439), o método <code>getElementById()</code> tem 922,827.555 execuções por segundo, enquanto o <code>querySelector()</code> tem somente 467,885.649. Olhando pelo gráfico fica visivelmente perceptível qual é o que se sai melhor.

<hr>

| [➕ Telegram](https://t.me/allytiago) | [🌐 Blog](https://blog.allytiago.me/?utm_source=dev.to) |
|---------------------------------------|----------------------------------------------------------------------------|
Soft dev practice in ML?
Tags: machinelearning
Published: 2020-06-15 21:50:59

Machine learning projects should not be managed as software development projects. Although both use code, ML projects are prone to a higher rate of change throughout their lifetime. This happens because of their close connection to the environment. 

In crude terms, one might think about a software development project as building a finished product such as a plane or a car. On the other hand, the ML project is similar to operating a farm. You need to have all the necessary tools to manage a farm, but you also need to respond to the changes in the environment such as weather, nutrients in the soil, possibility of being invaded by parasites or your crop getting sick etc.

A farm needs much more attention since it's embedded into its surrounding environment much closer than the car into the road. In the same way, a farm is connected to its surrounding; ML models are connected to their data. If models are not managed or taken care of, then they would not yield good predictions. Similarly, a farm would not produce a good crop if its environment is neglected.

Instead of using software development processes, it's better to focus on the software development principles of version control, testing, code review and design principles. Then we should re-arrange them into workflows that would better fit with the nature of ML projects.
Frontend Horse #2 - Black Lives Matter
Published: 2020-06-15 21:49:59

*This is an issue from the newsletter Frontend Horse. It was originally sent June 4th, 2020. Visit [Frontend.Horse](https://www.frontend.horse) to subscribe and find more issues.*

---

Like many of you, I spent this week witnessing the violence against Black people that occurs every day in the United States and across the world. I’m sad, I’m angry, I’m ashamed, I’m disgusted. Racist policies and ideas corrupt our government, law enforcement, and financial institutions.

It’s not one bad apple. It’s the tree.

While massive changes need to happen, individuals will make the difference. You can protest, you can donate, you can vote, you can inform your friends and family.

 I stand with the Black community against these racist policies and police brutality. I stand in solidarity with George Floyd, Breonna Taylor, Ahmaud Arbery, and countless others.

This was a week for listening, not talking tech, so I’m including a different set of links. I urge you to support these organizations, support Black businesses, Black voices, and the Black community.

If you donate to these, or any other similar organizations, send me the receipt and I’ll match up to $400.

[Black Lives Matter](https://blacklivesmatter.com/)

[National Bail Fund Network](https://www.communityjusticeexchange.org/nbfn-directory)

[NAACP Legal Defense and Educational Fund](https://www.naacpldf.org/)

[Equal Justice Initiative](https://eji.org/)

If you’re in the US, reach out and [apply Pressure on Your Representative](https://www.house.gov/representatives/find-your-representative). Last, here’s a resource I personally found helpful for [White men](https://tatianamac.com/posts/white-guyde/) and [White women](https://tatianamac.com/posts/save-the-tears) who want to make meaningful change right now.

Please, take care.

Alex

---

If you liked this post, head to [Frontend.Horse](https://frontend.horse) to subscribe! You'll get the next issue before it's posted here on Dev.
When to use Keyup or Keypress in Javascript
Published: 2020-06-15 21:49:19

Eventhough the differences between keyup and keypress in javascript may seem insignificant, it can cause damaging consequences when not used appropriately.

Keyup and keypress are javascript functions that allow you to execute an action when a specified key is pressed. But what are the actual differences between keyup and keypress?

<h4>Difference</h4>
The keypress function executes code when a specified key is detected to be pressed. The keyup function activates when you release that key. So with keypress it detects as the key is being pressed down, while keyup is not detected when you press the key but when you release it. 
You may say, so what? There's no difference both instances will result in the key being pressed and the action being executed. 
This is only partially true and this fact can cause unwanted consueqneces in your app.

<h4>The Problem</h4>
To udnerstand why we'll demnstrate with a simple example. Say we want to append an element to our page when we press the enter key with a keypress function. Here's our code:

```javascript
$('input').on('keypress', function(e) {
    var enter = e.keyCode || e.which;
    if(enter == 13){
        $('body').append($(this).val());
    }
});

```

What will happen here is if the user unintentionally presses the key twice or holds on to the key for too long, the content that we wanted to append to our page will be appened twice or more. This is undesired.

So what can we do to fix that, so no matter how many times the user presses enter, the content is appended only once to our page? (if that is what we desire - sometimes we want to append as many times as user presses enter, but in most cases we don't).

<h4>Solution</h4>
The solution is using keyup.

Let's modify our code slightly to achieve this:
```javascript
$('input').on('keyup', function(e) {
    var enter = e.keyCode || e.which;
    if(enter == 13){
        $('body').append($(this).val());
    }
});

```

Now if the user presses enter and holds on to the key a little too long, the content will only be appended once. 
If we program  our form to dissappear after the user hits the enter key, then no matter how many times the user presses enter, the content will only be appended once, which is what we desire in most cases (i'll venture to say). 

So there you have it, the difference between keyup and keypress. Use keyup for single action execution and keypress for executing actions everytime the user hits the desired key.

Hope you enjoyed this one.

See you un the next one!
What are your thoughts on testing and TDD?
Tags: webdev, testing, discuss
Published: 2020-06-15 21:38:36


I discovered testing and TDD when I was in university. I was trying to find something that could improve my programming skills overall and not just my skills in a specific language or stack.

To cut a long story short, I had excellent results as my grades greatly improved across all programming subjects. It wasn't only due to TDD, but it played an important role.

Because of how well things went during university, I naturally used it and still use it in my professional life as a Front-end developer. And given that I'm able to keep my developer experience pretty stress free code-wise, I'd say that things have been going pretty well.

If I had to say why I find testing and testing as used in TDD so amazing is because of 2 things:
1. _It forces me to think before and while I write code._ This makes me find holes in the requirements and opportunities to improve the code's design.
2. _It gives me a development process that lets me stay focused on my task at hand, which makes me more productive and less stressed.

Although it can be frustrating at the beginning, my opinion on testing and TDD is pretty good, and I recommend people try it out.

What's your opinion on testing and TDD?