teleren/devto huggingface dataset:
Frequently used 2 healthcheck recipes for docker-compose dependency resolution
Tags: docker, dockercompose
Published: 2022-04-25 01:56:00

These days, many developers are using `docker-compose` to build system on our local machines. If each container does not depend on each other, the system is simple. However, we usually have dependent and dependency containers within our docker-compose networks. I'm sharing the most basic cases of dependent-dependency pattern and how to boot containers in a order that we expect.

# Basics: Docker healthcheck
Docker has [healthcheck](https://docs.docker.com/engine/reference/builder/#healthcheck) functionality. The rules can be written in our Dockerfile or docker-compose. In docker-compose, it is written like following. The `server` container relies on `db` container. `db` should have `healthcheck` section and the condition. `server` should have `db` in the `depends_on` and the condition underneath to make sure that it boots after the `db` container gets health status.

```yaml
services:
  server:
    image: your_server_image
    depends_on:
      db: 
        condition: service_healthy
  db:
    image: your_db_image
    healthcheck:
      test: ... # Command to check health.
      interval: 5s # Interval between health checks.
      timeout: 5s # Timeout for each health checking.
      retries: 20 # Hou many times retries.
      start_period: 10s # Estimated time to boot.
```

# Case 1: Server depends on MySQL
Maintain server and MySQL containers in the same docker-compose runtimes is a very common pattern. The server must be booted after the MySQL container gets ready if you want to do something like table migrations when the server container booted. Pinging with `mysqladmin` to MySQL server in the db container, we can check if MySQL is ready. The MySQL server runs on localhost in the contianer, the host `-h` parameter must be `localhost`. The password is the one you set in the `environment` section with the `MYSQL_ROOT_PASSWORD` parameter.

```yaml
  db:
    image: mysql:8.0.26
    ports:
      - 3316:3306
    environment:
      MYSQL_DATABASE: yourdb
      MYSQL_ROOT_PASSWORD: pass
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-ppass"]
      interval: 5s
      timeout: 5s
      retries: 20
```

# Case 2: Server depends on another server
If we have more than 1 server, the servers may depends on others. e.g. In an image detection service system, one main server for user access and another server for image detection by machine learning. For the case, self-pinging should be the simplest solution. For the server runs on `localhost` and `8080` port in the container, `curl` command to ping should be like the below.

```yaml
  image_detection:
    image: your_image
    ports:
      - 8082:8080
    healthcheck:
      test: "curl -f localhost:8080"
      interval: 5s
      timeout: 5s
      retries: 20
```
Vinyl17
Published: 2022-04-25 01:54:41

I was inspired to create an application that would allow a user to keep track of their vinyl record collection. The user is able to add a new vinyl to their collection by providing an artist name, album name, year, and genre. The user can browse the collection by genre. A user can also delete a vinyl record from their collection. The application also has a list of resources about vinyl records.

Here are a few notes that I took while bringing this project to life. 


1. Back-End

I created a new rails application with an API using the following command:

```
rails new PROJECT_backend --api
```

I created a github repository for only the backend and added models, seed data, ran migrations, created the controllers, uncommented CORS, and lastly added the fast jsonapi gem. 

2. Front-End

I double checked my routes and moved on to the frontend of the application by creating a new React application using the following command: 

```
npx create-react-app PROJECT
```
I used the following commands to install react-redux. 

```
npm install react-redux
npm intall redux
npm install redux-thunk
```

Installed React Router v5
```npm install react-router-dom@5```


```npm start``` 
starts the development server
[Solved] MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe"
Published: 2022-04-25 01:52:20

### Problem:
Running into the following error when trying to run `npm install` in a React application:
```
npm ERR! MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". 
To fix this, 
1) install the .NET Framework 2.0 SDK, 
2) install Microsoft Visual Studio 2005 or 3) 
add the location of the component to the system path if it is installed elsewhere.  
[..\node_modules\node-sass\build\binding.sln]

```

### Solution: 

This error has failed to be resolved after trying the well known solution of running the following commands on an Administrator Windows PowerShell instance:
```
npm install -g node-gyp
npm install --global --production windows-build-tools 
```

![Windows PowerShell frozen after running the above commands](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uk2quundkdj7dc730gpf.png)

_Figure 1: PowerShell freezes after running the above commands_

Due to PowerShell freezing after running the above commands, I abandoned trying to run `npm install` on a Windows OS altogether. 

Instead, I transferred over the application to a Ubuntu VM instance and was able to run `npm install` with no issues. 
So try creating a Linux VM and porting over your codebase onto it. Then run `npm install` and see if it works. 

While this method does not directly solve the error on Windows, I believe it is the quickest and most pragmatic workaround if you don't mind working in a Linux environment. 


### Conclusion

Thanks for reading this blog post!

If you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.

If you found this article helpful please share it and make sure to follow me on [Twitter ](https://twitter.com/Shehan_Atuk)and [GitHub](https://github.com/ShehanAT), connect with me on [LinkedIn](https://www.linkedin.com/in/shehan-atukorala-8631491a5/) and subscribe to my [YouTube channel](https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ).
Install Docker Community in WSL 2 (Ubuntu 22.04)
Tags: docker, wsl
Published: 2022-04-25 01:24:15

After installing Ubuntu 22.04 stable in WSL, I proceeded to install Docker Engine using the [official Docker instructions](https://docs.docker.com/engine/install/ubuntu/). Since this is WSL, running `sudo systemctl start docker` does not work. To start the docker service, you'll need to use `sudo /etc/init.d/docker start`.

You will notice that the docker service is not running if you check using `sudo /etc/init.d/docker status`. The reason is because of this [error in starting docker](https://patrickwu.space/2021/03/09/wsl-solution-to-native-docker-daemon-not-starting/).

To fix this, you will need to update your default iptables to the legacy option. After doing this, you should be able to start the docker service and run the normal docker commands.

```
$ sudo update-alternatives --config iptables

There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode
  1            /usr/sbin/iptables-legacy   10        manual mode
  2            /usr/sbin/iptables-nft      20        manual mode
```
3 / 100DaysOfFlutter: Dart Sound Null Safety, Null Assign, Null Check, Everything null.
Tags: flutter, dart, tutorials, learn
Published: 2022-04-25 01:12:23

---
title: 3 / 100DaysOfFlutter: Dart Sound Null Safety, Null Assign, Null Check, Everything null.
published: true
description: 
tags: #flutter #dart #tutorials #learn
//cover_image: ![Day 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qo1bfdcqiccm1j39vwtm.jpg)
---

<!-- title: 3 /100DaysOfFlutter :Dart Null Safety, Null able, Null Check Everything null.  -->

# Learning null Safety in Dart:
understanding why we need null Safety; **Null** means nothing is there. so handle the programme at any point in time if there is a value which is null what should be performed?

# Sound NullSafety:
By sound you might is understand that here you may know when the value will be null; so for that flow, we use **SOUND Null Safety**

```Dart
 int i = 0;
 i= null; ❌
  // here i is 0; but what if somepoint it becomes null;
  // then it will throw an error
  // so we need to add a check for null
  <!-- down arrow unicode -->
  
  int❓ j = 1;
    //^ this is a nullable variable; so in future it can be null; and wount' throw error.   
    // make any value nullable by adding ❓after the variable type.  
  j = null; ✅
```
```Dart
List<String> names = ['Ram', 'Shyam', 'Hari'];
names[0] = null; ❌


List<String?> names2 = ['Ram', 'Shyam', null];
names2[0] = null; ✅

List<String>? names3 = ['Ram', 'Shyam', 'Hari'];
names3 = null ✅
// for making a list nullable we need to add ? after the list type here it is String.

List<String?>? names4 = [null, null, "Ram"]; ✅
// Here List as well as list Type is also nullable.
```


# Null Assign:

**Null Assign** means if the **value** is null **Assign** this *value*

    
```Dart
int? age = 12;
age = null;

int RealAge = age ?? 18;
// adding this ❓❓ after the variables (age) makes us sure that if any case the value of age is null the RealAge will be 18; 
```

# Null Check
Null check is a process of checking if the value is null or not, and perform tasks accordingly.

```Dart


List<String>? names5 = null;
print(names5?.length);

// it is shortcut for
if(names5 != null) {
  print(names5.length);
} else {
  print("null");
}

print(Person?.skills?.length);✅
.❓.❓.❓
// it will only print the length of skills if the person is not null and if the skills are not null.
```

I will explain Objects; Classes in the next blog.

Share with me if anything is missing or you don't understand; don't shy 🥺

ping me on **Twitter** 🕊️ [`@Abhayprajapati_`](https://twitter.com/Abhayprajapati_)

Check the code for today here.
[`Repo`](https://github.com/theabhayprajapati/100DaysOfFlutter/blob/main/day3/null.dart)




**🤝🏾Connect me on:**
**Twitter**: 🕊️[`@Abhayprajapati_`](https://twitter.com/Abhayprajapati_)
**Github**: 🐧[`@theabhayprajapati`](https://github.com/theabhayprajapati)
Coding Journey Report 1 (18-24/4/2022)
Published: 2022-04-25 01:01:54

Wow what an amazing week, I had the pleasure of having [Matteo Leonesi](https://dev.to/matteol) reach out and wanting to help - I am very humble to have anyone help me reach my goals of creating monoGames, I can only hope I can help you out too, Thank You ❤️ your a Champion 🏆. 

I had the pleasure in having a conference call with [Cockraoch Labs](https://www.cockroachlabs.com/) with Emily and Rachel. They were simply amazing to talk with and what they could offer my projects and I also received $100 gift voucher which I let them donate the gift to cancer as I know what victims of cancers go through. So you can see why I will be using Cochroach Labs in my project.

I reached out to [Ready Player Me ](https://readyplayer.me/avatar) to see if I could connect their awesome easy to use character creator for monoGames, and I got a wonderful email saying I have been accepted - Thank you and I am over the moon.

A member of my [Torum](https://www.torum.com/) followers reach out to me to see if I could use Koinos Blockchain, so I sent them an email and I got a positive response. So I will be adding Koinos Blockchain to monoGames with Eth, Sol, Hive, Signum, Wax, BSC, etc. I know if your going to build your project you need to listen to your followers and Thank You Journeyman.

This has truly been a Great Week but you can imagine every week I go through a lot of information, save them in files, go through the files thoroughly and weed out what I dont think I need while working on the monoGames project at my Github repository for [monoGames](https://github.com/369gtech/monoGames). I still have a very long way to go but every day I get closer especially with this Devto community as it has so many resources.

On a final note, last week I said I would post some basic HTML and CSS that I had learnt from HeadFirst HTML and CSS that I wanted to share to help others to understand workflows who are starting off but I see its a big undertaking especially with all the work I do trying to build my project so until I become an expert at HTML and CSS I will leave this to the experts but what I will say is that the HeadFirst HTML and CSS Book with these two links [w3school](https://www.w3schools.com/default.asp) and [MDM](https://developer.mozilla.org/en-US/) are really good sources to learn especially now that I am learning javascript.

Thanks for reading the post and if you have any questions or would like to know more about my projects then please feel free to PM.
How to send and receive data in Socket IO?
Tags: programming, socketio, javascript, webdev
Published: 2022-04-25 00:55:30

Socket.io is a library to abstract the WebSocket connections. According to the official website of socket io, Socket.IO is a library that enables low-latency, bidirectional and event-based communication between a client and a server.

What does it mean by event-based? We can send and receive data in Socket by using the following code block. We can send an event from the server and receive it in the client and vice-versa. 

**To Receive Data**
socket.on("message", (hello) => {
  console.log(hello); // world
});

**To send Data**
 socket.emit("message", "hello");

In general, the code for sending and receiving data is 
Receiving Data: socket.on(eventName, listenerFn)
Sending Data : socket.emit(eventName, Data) 

We have to use same eventName for sending and catching data. There are some pre-defined events in Socket Io but we can also make our own custom events provided that the same event name is to be used in both client and server.
asp.net journey
Published: 2022-04-24 18:19:19

---
title: asp.net journey
published: True
description: rough as it is
tags: 
//cover_image: https://direct_url_to_image.jpg
---

This is dev log for todya, I've taken a step back and taken some time to reflect on what I need to learn, I'm rushing things again, so I'm taking it easy.
After learning Dependency injection and DDD, (well... still learning DDD) I'm working through c# and asp.net again. I've picked up this book [ASP.NET core 6 and angular](https://www.oreilly.com/library/view/aspnet-core-6/9781803239705/) it is pretty good and intermediate, just enough to get someone who knows programming to step into this world.
For the last 2 months I was stuck on the concept of DI and DDD. It was all strange, but I pushed on, now I've collected a grasps of it and a bit more on the builder pattern.
I can see the use of singleton pattern and scoped classes. Its interesting that these patterns were nto apparent to me at first.

once I go through this book to some extent I should be ok to get started on my project.

Two years ago when i tried ASp.net I was all over the place, I remember I was completely lost as to what was going on. Now with a focus to get into enterprise, I feel a bit comfortable and focused on my career path.
Moving away from my current role into this industry is a dream. I love programming since the age of 12, albeit I was doing it in php and didn't know any better because that was the only thing available for free and I was able to work with it.

So in the last two days I've picked up:

- Secret Manger [link](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=linux#enable-secret-storage) and the use of it to store credentials

- re-read up on OAuth2 [link](https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/external-authentication-services)

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


I'm currently going through Angular and asp.net now so it should get better in the next few weeks.
Speaking is more joyful than writing
Published: 2022-04-26 05:09:21

---
title: Speaking is more joyful than writing
published: true
date: 2022-04-25 00:00:00 UTC
tags: 
canonical_url: https://ulisesavila.com/general/the-power-of-speaking
---

I remember my high school days when I used to write some reports using Dragon Neutral Speaking software I do not understand why I didn't continue doing that.

Because now I'm having the same creative blockage that many people have. This problem is famous, you know it, and you may have suffered from it.

You have a topic to write about and even though you have the overall structure of your posting you don't have ideas coming to you, and this problem is exacerbated because you enter into a loop that doesn't let you work. No idea comes to you, staring at the white space of your monitor stresses you back, then you force yourself to write something but again nothing comes to mind, and when you finally have something to write then suddenly the flow of the ideas stops, and then you get into the loop again.

This situation blinds us to the real problem and it is that we are not used to expressing ourselves. Making your ideas come to you is also a skill that has to be developed, and forcing us to write is hindering us from improving such skill

This is why I think that speech-to-text technologies come into play as I said in my introduction paragraph, I used to use one to write some reports and now I don't use it anymore I don't even know what is the reason behind this. But today I get the realization that now I have the same opportunity but now inside a smartphone. This pushes me to again start writing some ideas, but now those ideas are not going to come from my fingers if not from my mouth.

This posting here is done fully by speech-to-text technologies I also need to train my idea eloquence fluency, not just my fluency in using a foreign language. This also helps to develop speech skills and my elaboration of texts too.

So this is more a text to tell you that if you aren't writing the old-fashioned way. Do not distress yourself over word count typing because that will be a hassle to your thought process and if you start to dictate your ideas, also do not get distressed on the maximum words per minute that speaking will supposedly give you unless you already have the text word by word in your mind, you won't benefit of the primary speed that speech gives you.
How to get the full public URL of ASP.NET Core
Tags: dotnet, aspnet, csharp
Published: 2022-04-26 04:29:36

---
title: How to get the full public URL of ASP.NET Core
published: true
date: 2022-04-25 00:00:00 UTC
tags: dotnet, aspnet, csharp
canonical_url: https://swimburger.net/blog/dotnet/how-to-get-the-full-public-url-of-aspdotnet-core
---

URLs are what makes the web the web. In ASP.NET Core Controllers, Razor Pages, and Razor views, there's a `Request` property which gives you access to the `HttpRequest` instance. The `HttpRequest` object gives you access to scheme, host (which is the domain and port), path, query string, body content, and headers of the incoming HTTP request.

If you need to know what the full URL is of your web application, you can put the URL together by grabbing the `Scheme`, `Host`, `PathBase`, `Path`, and `QueryString` and combining it like this:

```csharp
$"{Request.Scheme}://{Request.Host}{Request.PathBase}{Request.Path}{Request.QueryString}"
```

Maybe you're only interested in the URL without the path and query string, in which case you can omit the `PathBase`, `Path`, and `QueryString` parameter from the string interpolation:

```csharp
$"{Request.Scheme}://{Request.Host}"
```

If you want to generate URLs for your application, I suggest you use the `UrlHelper` as explained in this blog post about generating absolute URLs.

If you're using Minimal APIs, there's no `Request` property accessible to you, but you can accept an instance of `HttpRequest` as a parameter to your endpoint callback like this:

```csharp
app.MapGet("/hello-world", (HttpRequest request) =>
    {
        return $"{request.Scheme}://{request.Host}{request.PathBase}{request.Path}{request.QueryString}";
    }
);
```

**What if there's no HTTP request?**

If there is no HTTP request that you're handling in your code, like when you're doing some background processing using a `BackgroundWorker`, you'll need to get the scheme and host some other way. You could store your desired scheme and host into your configuration, or combine them together in a single property and store it into your configuration. Once configured, extract it from configuration and use it to build your absolute URL.

Be mindful of the fact that web application can be requested from multiple URLs depending on the network and infrastructure configuration. So even though you could simply store the full public URL in configuration, that may not be the only URL that users use.
Phase 3 project
Published: 2022-04-24 23:54:35

Last night as I gobbled down my padres home made burgers I pondered any updates I wanted to make to our website. As I worked through a long punchlist of last minute changes we wanted to make, I watched as my ability to work with css and html grew with me. 

I had less than 24 hours left to add any finishing touches and had to start somewhere. I imagined and played around with the code for a bit, until I was comfortable with the design and overall look. Just to show you guys, this is the home page!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d75v73narbm5ebp0hiyi.png)
JavaScript arrow functions
Tags: javascript, beginners, webdev, programming
Published: 2022-04-24 23:53:44

**What is an arrow function in JavaScript?**
Arrow functions are an alternative way of writing functions in JavaScript. There are a few limitations compared to the traditional function that will be discussed in this article.

```js
// Traditional function declaration
function myFunc(myParam) {
  return myParam + 1;
}

// Arrow function declaration
const myFunc = (myParam) => {
  return myParam + 1;
}
```
Arrow functions can often be shortened substantially.

```js
// If there is one parameter, then you do not need to include
// the parenthesis. 
const myFunc = myParam => { return myParam + 1; }

// If the functions contents can fit on one line, then you can
// remove the 'return' keyword and '{}'. 
// In this case, the 'return' is implied.
const myFunc = myParam => myParam + 1;

```
It is common to use arrow functions with the built in array methods.

```js
const arr = [1, 2, 3, 4, 5];

const arrMap = arr.map(v => v + 1);

const arrFiltered = arr.filter(v => v > 3);

arr.forEach(v => console.log(v));
```

**The limitations of Arrow functions.**

Arrow functions do not have their own binding of `this`. As a result, you generally will not want to use them as `methods` in your objects. A few more things to know:
- They don't have their own binding to `arguments`, or `super`
- They cannot be used as `constructors` within classes.
- They likely will not behave as expected with the keywords `call`, `apply` and `bind`.

Since the arrow function does not have its own binding of `this`, it cannot reference other attributes or methods in objects. `this` in an arrow function will always reference the global scope.
```js
const obj = {
  value: 1,
  myFunc1: function () {
    console.log(this.value, this);
  },
  myFunc2: () => {
    console.log(this.value, this);
  },
};

obj.myFunc1(); // 1, obj{...}
obj.myFunc2(); // undefined, Window{...} or the Global object
```

For more info, reference the MDN documentation: [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)

Leave a comment if you have any questions or feedback.