teleren/devto huggingface dataset:
Asynchronous CRUD Operations in Node js
Tags: javascript, node
Published: 2022-06-26 20:08:47

**What is Asynchronous ?**

Asynchrony, in programming world, refers to the occurrence of events independent of the main program flow and ways to deal with this kind of events.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vm20agvm7if8trecas9y.png)

##CRUD ?

The term "CRUD" refers to the four operations that are thought to be required to develop a data storing application: create, read, update, and delete. It originates from the area of computer programming. Any data storage device, such as a solid-state drive or a hard disc, that keeps power after the device is turned off is referred to as persistent storage. In contrast, volatile memory, which includes random access memory and internal caching, stores information that will be lost when a device loses power. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssphniguopj2kpb9pgti.png)

## 1 Create a file and data into it 

```javascript
const fs = require ("fs");

fs.writeFile("Newfile.txt","sample data" ,(err) =>{
console.log("created");});

```

## 2 To append changes 

```javascript
fs.appendFiles("Newfile.txt","sample data changed" ,(err) =>{
console.log("appended");});

```

## 3 To read file

```javascript
fs.readFile("Newfile.txt",'utf-8',(err,data) =>{
console.log(data);});

```

## 4 To delete a file

```javascript
fs.unlink("Newfile.txt",(err) =>{
console.log("delted");});

```

Check out my Github for source code :-https://github.com/crackingdemon/NodejsFilesystemCrud
Making a Website Application (Belafonte Food Hub) using a public API
Published: 2022-06-26 19:49:51

When learning Javascript, using a FETCH API to come-up with a website is one of the milestones that you could achieve as a weekend task.You get to experience different types of API and a variety to choose from.
 Below are a few sites that have API feel free to go through as you follow along:

1. https://github.com/public-apis/public-apis

Things you need before starting:

1. A Design of the website: Figma will give you an idea: https://www.figma.com/login
2. A public API

Using a fetch API _("https://www.themealdb.com/api/json/v1/1/search.php?s=")_ to get a list of meals I came up with Belafonte Food Hub website that offers users a variety of meals and using a button one can watch how to prepare the meals, like or dislike based on their preference and Submit a review at the button of the page.
Getting:
1.List of meals/dish.
2.Name of the meal.
3.Category: such as Soup or side dish.
4.Origin of the meal.
5.Youtube link to learn how to prepare the meal with the aid of a video.

SCREENSHOTS
- ![Screenshot from 2022-06-26 21-33-24](https://user-images.githubusercontent.com/24671358/175829051-5c3bd3ed-01ab-4597-8d54-10bd83a9df6e.png)
- ![Screenshot from 2022-06-26 21-33-34](https://user-images.githubusercontent.com/24671358/175829052-fb18cd3e-bdac-489b-867b-187a79a29d70.png)
- ![Screenshot from 2022-06-26 21-33-51](https://user-images.githubusercontent.com/24671358/175829055-4038b828-29bf-4d39-bf07-8cd0ee8b2e51.png)

Repo link: https://github.com/Martinpouh/Belafonte-Food-Hub
Laravel - Class "Fideloper\Proxy\TrustProxies" not found - Fixed
Tags: webdev, laravel, php, tutorial
Published: 2022-06-26 18:51:49

Today what you are going to learn:
In this lesson you will learn Class "Fideloper\Proxy\TrustProxies" not found laravel. i explained simply about laravel Class "Fideloper\Proxy\TrustProxies" not found issue. it's simple lesson of fideloper/proxy laravel 8 issue. This article will give you simple lesson of laravel 8 fideloper/proxy issue.

Few days ago, i migrate my laravel 7 app into laravel 8 version then i simply composer install and checking on my domain, i got Class "Fideloper\Proxy\TrustProxies" not found error in browser as like bellow:

Then i research and find out solution from google, we need to install "fideloper/proxy" composer package. let's run bellow command:
Solution:

composer require fideloper/proxy

thank you very much for following up with me.

## [for more](https://freecoder.co/post/laravel-class-fideloperproxytrustproxies-not-found-fixed-2475)
Best Practice: Makefile
Tags: php, makefile, bestpractice
Published: 2022-06-26 18:44:14

---
title: Best Practice: Makefile
published: true
description: Best Practice to use Makefile efficiently
tags: php, Makefile, makefile, bestPractice
---
![Output by using "make"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u56yq51s7fgojiqz2u5z.PNG)
[Download My Makefile on GitHub Gist](https://gist.github.com/vikbert/54e27c7a304fe96def50ef76b96b04a6)

I use `Makefile` for most of every my project, both at work and in side-projects.
It let you just create very easily `task group` in a `Makefile`, which you can execute them via `make` command. 

My best practices are the following:

## Minimal config
I remove all unnecessary definition which might make noise in the `Makefile`. Now it has just 6 lines to configure and define the templating of my favorite `Makefile`.

```bash
SHELL := /bin/bash

help:
	@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$|(^#--)' $(MAKEFILE_LIST) \
	| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m %-43s\033[0m %s\n", $$1, $$2}' \
	| sed -e 's/\[32m #-- /[33m/'
```
> `Help:` this code block defines the templating for the task group and its tasks and I used it in every my makefile.

## Group your task
With Prefix `#-- `, you are able to define the title of task group. We can organise the relevant tasks in the same task group.
```bash
#-- Docker  
```
> this will define a task group with title name `Docker`

## Add task always the a task description
by using prefix `## description of this task`, we can add the description to each task. 
The following code defines a task group `Docker` with a single task `clean`, which triggers four commands to clean up the docker resources.
``` bash  
clean: ## clean up all docker resources
  docker-compose stop
  docker container prune -f
  docker volume prune -f
  docker network prune -f
``` 
> each command should begin with a `Tab`, for example, there is always a `Tab` before the command `docker-compose stop`.

## Simple start
By using `make`, you can show the list of all defined task groups in `Makefile`
By using `make clean`, you can execute the task `clean` under the task group `docker`

See the final result in the terminal:
![Output by using "make"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u56yq51s7fgojiqz2u5z.PNG)

 
[Download My Makefile on GitHub Gist](https://gist.github.com/vikbert/54e27c7a304fe96def50ef76b96b04a6)
Another small Javascript Tidbit for enforcing a number
Tags: javascript
Published: 2022-06-26 18:23:18

As I'm getting grasps with Typescript, I watched a really great [Youtube tutorial video by Academind (Maximilian) ](https://www.youtube.com/c/Academind) that ran through tons of details on Typescript. In the video, he shows the difference between Typescript and the transpiled Javascript generated which shows a pretty great syntax tool.

> ```
  > ...
  > const something = "5";
    > return +something
    > ...
> ```

The `+` character right before a variable is a way to enforce a number type! In Javascript, literal strings have become completely second-nature to most developers, and one use of it is to enforce a string by using interpolation. This `+` method is a really nice concise way of filtering a variable for numbers. 

The `+` character before numbers assigns a positive values (and `-` for negative), so for a dynamic language like Javascript, it's assuming and enforcing the variable as a number under the hood. 

This is the first time that I've seen an instance of this syntax used. Good stuff
Which headless CMS would you recommend for a blog site?
Tags: discuss, help, beginners, webdev
Published: 2022-06-26 18:03:46

I'm thinking about building a blog page using headless CMS, that said, I'm new to headless CMS world and currently is in a researching phase.

1. What aspects should be considered before making a choice (e.g., must-have features, must-avoid due to issues, etc.)?
2. Which solution would you recommend? Why?
  - Strapi
  - Contentful
  - Directus
  - Sanity
  - GraphCMS
  - Prismic
  - Drupal
  - WordPress
  - GhostCMS
  - Or something else

Some requirements on top of my head are (not strictly required though):
 - Has Next.js / TypeScript integration (dynamic website)
 - Has cloud hosted options
 - Has SSO (e.g., front-end users, back-end users, etc.)
 - Has markdown editor
 - Has article scheduling
 - Has localization
 - Has content backup to GitHub or third-party storage solution
 - Has SEO integration (tags, analytics, schema, etc.)
 - Has a wide variety of configurations, such as plugins (mailing list, webhook, payment, etc.)
Which YouTube channels do you follow and would recommend as a programmer/developer?
Tags: discuss, webdev, programming, productivity
Published: 2022-06-26 17:50:09

The question is simple, which YouTube channels do you follow and would recommend as a developer/programmer, this could be a channel you watch tutorials from, a channel who makes meme on programming content or a channel where you talk with the developer about stuff on live streams, it can be anything.

Here's my list of YouTube channels I follow and would recommend 👇
- [Fireship](https://www.youtube.com/c/Fireship)
- [FreeCodeCamp](https://www.youtube.com/c/Freecodecamp)
- [Programmers are also human](https://www.youtube.com/channel/UCi8C7TNs2ohrc6hnRQ5Sn2w)
- [Frying Pan](https://www.youtube.com/c/FryingPan)
- [Theo - Ping Labs](https://www.youtube.com/c/TheoBrowne1017)
- [Lama Dev](https://www.youtube.com/c/LamaDev)
- [devaslife](https://www.youtube.com/c/devaslife)

Write about your lists in the comments below, looking forward to reading them!
Laravel Sync Remote Database Package
Tags: laravel, database, sync, package
Published: 2022-06-26 20:02:39

---
title: Laravel Sync Remote Database Package
published: true
date: 2022-06-26 17:50:00 UTC
tags: laravel, database, sync, package
canonical_url: https://dcblog.dev/laravel-sync-remote-database-package
---

 ![Laravel Sync Remote Database Package](https://dcblog.dev/images/posts/laravel-sync-remote-database-package.png) 

I often want to sync a production database into a local database and manually exporting and importing, so I wrote a package to automate it!

A word of warning you should only sync a remote database into a local database if you have permission to do so within your organisation's policies. I'm syncing during early phases of development where the data is largely test data and not actual customer data.

I wrote a package called [Laravel DB Sync](https://github.com/dcblogdev/laravel-db-sync)

Install the package:

```
composer require dcblogdev/laravel-db-sync
```

Publish the config file

```
php artisan vendor:publish --provider="Dcblogdev\DbSync\DbSyncServiceProvider" --tag="config"
```

Set the remote database credentials in your .env file

When using SSH Add:

```
REMOTE_USE_SSH=true
REMOTE_SSH_PORT=22
REMOTE_SSH_USERNAME=
REMOTE_DATABASE_HOST=

REMOTE_DATABASE_USERNAME=
REMOTE_DATABASE_NAME=
REMOTE_DATABASE_PASSWORD=
REMOTE_DATABASE_IGNORE_TABLES=''

REMOTE_REMOVE_FILE_AFTER_IMPORT=true
REMOTE_IMPORT_FILE=true
```

For only MySQL remote connections:

```
REMOTE_DATABASE_HOST=
REMOTE_DATABASE_USERNAME=
REMOTE_DATABASE_NAME=
REMOTE_DATABASE_PASSWORD=
REMOTE_DATABASE_IGNORE_TABLES=''

REMOTE_REMOVE_FILE_AFTER_IMPORT=true
REMOTE_IMPORT_FILE=true
```

if you want to exclude certain tables you can add them to REMOTE\_DATABASE\_IGNORE\_TABLES for example to ignore users and jobs being exported

```
REMOTE_DATABASE_IGNORE_TABLES='users,jobs'
```

now when you want to export the remote database into the local database run:

```
php artisan db:production-sync
```

[https://github.com/dcblogdev/laravel-db-sync](https://github.com/dcblogdev/laravel-db-sync)
O(1): Constantly Efficient
Tags: algorithms, beginners
Published: 2022-06-26 17:41:28

In the last post, we broke down O(n) aka linear time, because (in my opinion) it is the most straightforward common complexity to understand. As n (number/size of input) grows O (number of operations) grows at a similar rate. 

The truth is, there's an even simpler common complexity. Not only that, it's also by far the most efficient.

Of course, i'm talking about O(1) or Constant Time.

#### Back to the Catering Company

If you'll remember from last time, we had a catering company who was hired to do an event. We decided to make an individual plate for everyone, and we therefore calculated our catering algorithm to be O(n).

But, what if we didn't have to make an individual plate for everyone? 

What if instead just made one big pot of soup!

Then we wouldn't have to do anything all day! We could just make one giant pot of soup and make sure it's big enough for all the guests.

Just like before, let's pseudocode this up:
```
# n = number of guests

def cater_party (n)
   # make 1 big pot of soup
end

```

So how does our number of operations grown in relation to our input size?

If there's 1 guest, we make 1 pot of soup.
If there're 100 guests, we make 1 pot of soup.
If there're 1,000,000,000 guests, we make 1 pot of soup.

Looking at our algorithm, and thinking about it logically, no matter how many people attend our event, we're still only going to make 1 pot of soup.

The number of operations, in our case, is constant. Our algo simply doesn't increase in complexity based on the input.

![constant complexity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enl4q2icb4uohlw8si65.png)

 
Remember, we can simplify constant values to 1 for the sake of simplifying our big-o notation (since the effects of constant values on complexity decrease to negligible at higher n values). No matter how many operations it actually takes, if it doesn't grow along with our input size, we might as well just consider it one big operation. 

And so we get O(1).

### The most efficient complexity

O(1) algorithms, because they are constant time, they are easily the most efficient complexity. A truly constant time algo, will process an infinite amount of data, in the same time it would take to do just 1.

A code example, that you've probably used, would be accessing an array element by index. In this case, since you know the index, it doesn't matter how large the array is because the program knows exactly where the element is.

There are other plenty of other algorithms with a complexity of O(1), and many other complex algorithms use them. In fact, you could probably think of most basic operations as algorithms with O(1) complexity.

### Next time

Now that we've gone through O(n) and O(1) were going to start getting more complex
Introducing Ambie V3
Tags: productivity, csharp, dotnet, showdev
Published: 2022-06-26 17:28:17

I created an app that plays background sounds to help people focus, study, or relax. This latest V3 release introduces a brand new Focus Timer inspired by Pomodoro. It's an interval timer that works with white noise to help you concentrate on your work. The new update uses Windows 11 styling, particularly using the new Mica material available on Windows 11. Give it a try and let me know what you think!

The app is free and open source. Download here: https://apps.microsoft.com/store/detail/ambie-white-noise/9P07XNM5CHP0


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


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


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


![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxcon9y305mz57cc3ini.png)
Learn Redux toolkit guide step by step with project
Tags: redux, javascript, beginners, react
Published: 2022-06-26 17:24:01

Medium Blog : [](https://itznur07.medium.com/learn-redux-toolkit-beginner-to-advance-step-by-step-9fe82a0e7539)

https://itznur07.medium.com/learn-redux-toolkit-beginner-to-advance-step-by-step-9fe82a0e7539
CSS Icon: Microsoft
Tags: css, webdev, beginners, tutorial
Published: 2022-06-26 17:20:19

In this article, I will create a Microsoft icon by using CSS only. Let's look at how we do that.

## Problem

![logo](https://imgur.com/eFnRBmo.png)


## Solution 

First, we need to create the structure for this logo then we will style that structure. 

### HTML

```html
<div class="wrapper">
  <div class="red"></div>
  <div class="green"></div>
  <div class="blue"></div>
  <div class="yellow"></div>
</div>
```

The above HTML code has a `wrapper` container and it has four children `red`, `green`, `blue`, and `yellow`.

### CSS

Now let's style them one by one. First, let's style the `wrapper` container.  I've created a two-column `grid` and managed spacing by using [`gap`](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) property.

```css
.wrapper {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
```

Now we style all the children by [Universal Selector (*)](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors) and give them `50px` height and width.

```css
.wrapper > * {
  width: 50px;
  height: 50px;
}
```

It's time to apply the colors to the individual children.

```css
.red {
  background: #f44336;
}
.green {
  background: #4caf50;
}
.blue {
  background: #2196f3;
}
.yellow {
  background: #ffc107;
}
```

## Codepen
Now the result is as follows: 

{% codepen https://codepen.io/j471n/pen/abYoBeR %}

## Wrapping up
This is going to be a series of CSS Icons so make sure you follow for more such articles. If you like this then don't forget to ❤️ it. And I'll see you in the next one.
working with API for the first time
Published: 2022-06-26 16:59:16

last week was project week. I was task with the responsibility of developing a project that uses a public API to perform CRUD operations. This means that the project should create,read, update and delete data from the chosen API. I have to mention that i just started learning JavaScript three weeks ago. However since i had done several crud operations with provided db.json , i was confident that i would have an ample time doing the project. Since i could not find a public API that served the needs of my project idea, i decided to create my own.
 The process was smooth and it worked properly until i had to host the API on github. This is when i started getting all  kinds of errors. I have too say that it took me a while to realize that my hosting was the problem. Simply because, i could easily fetch data from the API apart from creating and deleting. This means that while debugging, i had ruled in that the hosting is working perfectly. luckily, my dev buddy came to my rescue and informed me that github hosting has some restrictions when it comes to working with APIs. At the moment, am i looking at a site that he recommended for the hosting.
Angular - Use ChangeDetectionStrategy.OnPush
Tags: angular, javascript, webdev, typescript
Published: 2022-06-26 16:45:45

Angular gives us an option to choose the `ChangeDetectionStrategy` of a component. By default, the value is `Default`. It's recommended to change that to `OnPush` strategy to maximize the performance.

By default, Angular run its change detection cycle on all the components whenever there occurs some changes, like a simple click event or when we receive data from ajax calls. Running change detection cycle on every such events are costly and may affect the performance.
<br />

We can minimize these checks by setting our component's `changeDetection` to `ChangeDetectionStrategy.OnPush`. This will tell Angular to run change detection cycle only when:

1. The `Input` reference changes.
2. Some event occurs in the component or any of the children.

<br />
```
@Component({
  selector: 'app-selector',
  ...
  changeDetection: ChangeDetectionStrategy.OnPush
});
```
Note: Make use of `detectChanges()` or `markForCheck()` functions of `ChangeDetectorRef` to explicitely run the change detection cycle if required.
<br />
**Resources:** [A Comprehensive Guide to Angular onPush Change Detection Strategy](https://netbasal.com/a-comprehensive-guide-to-angular-onpush-change-detection-strategy-5bac493074a4).
<br />
Thanks to @fyodorio .
How Do Robo Advisors Work - The ROP Model explained
Tags: roboadvisor
Published: 2022-06-26 16:42:00

**The model (ROP model) developed as part of my master's thesis provides an overview of the structure of Robo Avisors. The three main components of the model are explained in this article.**

   

### ROP Model

The term ROP model describes a Robo Advisor model consisting of three components:

* Risk profile of investors
* Optimization of portfolios
* Portfolio management

It is important to note that the determination of risk profiles and the optimization of portfolios are detached from each other.


![Robo Advisor Model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cy1wrw3tyz056t9q8oz0.png)

### Risk Profile of Investors

The creation of a thorough risk profile is mandatory from a regulatory point of view. The regulatory framework is based on laws and guidelines to which traditional asset managers are also subject. Robo advisors request relevant information for the creation of risk profiles with the help of online questionnaires. Investors must thus provide information about their personal situation, financial knowledge and financial experience. In addition, they must determine the objective of their investment. When an asset management contract is concluded between a robo advisor and an investor, the investment strategy is already contractually stipulated and targets are set on the basis of key figures, such as benchmarks.

### Optimization of Portfolios

Detached from the determination of risk profiles, robo advisors select investment products from a defined investment universe. Portfolio optimization is used to create "efficient" portfolios based on investment products. Regulatory requirements stipulate that processes must be clearly defined and optimization algorithms must be continuously monitored.

### Portfolio Management

By combining risk profiles and efficient portfolios, optimal target portfolios can finally be simulated for investors. Based on target portfolios, investors are invested in their own actual portfolios. If deviations between actual and target portfolios become too large, a "rebalancing" of investor portfolios takes place. 

Find the original article here: <a href="http://blogbeat.app/blog/maxonce/article/how-do-robo-advisors-work-the-rop-model-explained">http://blogbeat.app/blog/maxonce/article/how-do-robo-advisors-work-the-rop-model-explained