teleren/devto huggingface dataset:
Build REST API with Go Fiber and PlanetScale - Part 2
Tags: go, planetscale, api
Published: 2022-10-19 11:24:39

## Models

Create a `User` model and create a file called `user.go` inside `models` directory, and define a struct with gorm.

```go
package models

import "gorm.io/gorm"

// User struct
type User struct {
    gorm.Model
    Name    string `json:"name"`
    Email   string `json:"email"`
    Website string `json:"website"`
}
```

## Connect to Database

Create a development database branch called `add-users-table`.

```
$ pscale branch create fiber-pscale add-users-table
```

Open a new terminal tab, we're going to connect to the database inside add-users-table branch and listen to `3309` PORT. See more [Connect using client certificates](https://docs.planetscale.com/tutorials/connect-any-application#connect-using-client-certificates).

```
$ pscale connect fiber-pscale add-users-table --port 3309
```

Create a file called `database.go` inside the models directory and add a function to connect to the database.

```go
package models

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func ConnectDatabase() {
	// refer https://github.com/go-sql-driver/mysql#dsn-data-source-name for details
	dsn := "root:@tcp(127.0.0.1:3309)/fiber-pscale?charset=utf8mb4&parseTime=True&loc=Local"
	database, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	}
	// Migrate the users table
	database.AutoMigrate(&User{})
	DB = database
}
```

open your `main.go`, and call the `ConnectDatabase` function to migrate the tables and connect to the database.

```go
import (
    // ...
    "github.com/maful/fiber-pscale/models"
)

func main() {
    // ...
    models.ConnectDatabase() // New
    
    //
    app.Use(logger.New())
}
```

then run the app `go run cmd/main.go`, Gorm will automatically migrate the table into `add-users-table` branch. How to know if the migration is success? You can check in the PlanetScale dashboard for the following branch, or use CLI to see the schema for `add-users-table` branch.

```
$ pscale branch schema fiber-pscale add-users-table
-- users --
CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` datetime(3) DEFAULT NULL,
  `updated_at` datetime(3) DEFAULT NULL,
  `deleted_at` datetime(3) DEFAULT NULL,
  `name` longtext,
  `email` longtext,
  `website` longtext,
  PRIMARY KEY (`id`),
  KEY `idx_users_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
```

The schema won't apply to the main branch until you create a deploy request. Lastly, stop the connection from `add-users-table` branch or Ctrl+C.
Difference between find() and filter() methods in Javascript ?
Tags: javascript, beginners, programming, react
Published: 2022-10-19 11:20:46

## **find() Method**

This method is used to find the single item in the array. find() method return a single item that fulfill the condition which passes into the callback function.

```
let array = ['apple','orange','WaterMelon','Melon']   

//apply find() method to the array

console.log(array.find((item) => item=='apple'))
returns --> apple
```




## **filter() Method**

This method is used to find the multiple items in the array. filter() method return all those items which fulfills the condition that passes into the callback function.This method return a new array without modifying the original array.

```
let array = [1,2,3,4,5,6,7,8,9]   
//apply filter() method to the array
console.log(array.filter((item) => item >=4))`
returns --> new Array [4,5,6,7,8,9]
```
Why Won’t Gmail Load? –Causes
Tags: gmail, load, email, issue
Published: 2022-10-19 11:01:52

Extensions or add-ons which we install on our system might result in Gmail won't load. As we all know, Gmail is popular and has millions of users. It is the most trusted and proficient way of communication. But, it can trouble you if it won't load on time when you need it. For example: while sending important business mail.

Many reasons cause [Gmail Won't Load](https://www.emailsupport.us/blog/gmail-wont-load/); explore them below:
 

- Your current browser is not compatible with Gmail.
- Browser extensions restrict Gmail from loading correctly.
- Junk files or caches might interrupt Gmail.
- An issue with internet connectivity.
- Your Gmail account is hacked.
 

## What To Do If Gmail Won’t Load? Ways To Fix Issues
Wondering what to do if Gmail Won't Load when you need to send important mail? There are lots of ways to deal with the issue; let's have a quick look at them one by one.
 

### Reboot Your System
If your Gmail is not loading perfectly, it's a better option to reboot the system. This can help you rectify the problem. Shut down your system and wait for a while, now turn on the system and try to open your Gmail aging. If you can open it, that's great; else, try another method.
 

### Clear Browser Cache & Cookies
Cache data always supports you in finding the sites easily. But many times, due to corruption or other issues, they can cause problems, which ultimately result in Gmail not working. Hence clear the cache and cookies by following the below steps:
 


1. Tab on three dots ➥ settings
2. Click on security & privacy located ➥ Clear browsing data
3. Uncheck the things you want to keep ➥ click on clear data
 

### Don't Forget to Check Browser’s Compatibility
Check whether your browser is compatible with the Gmail server. Known browsers like Firefox, Chrome, Safari, and more work perfectly with Gmail, but few may not. Hence, first of all, check the compatibility before signing up for your email account over there.
 

### Internet Connectivity
Are you using a wifi connection? If yes, check the connection twice to make sure it's working perfectly. A weak internet connection does not provide a strategy to load many websites, and your Gmail account can be the one. Thus checks for the connection or turn off and on the connection for better supply or switch to another.
 

### Open Gmail in Other Browsers
If you encounter a Gmail Won’t Load issue on one browser, switch to another. In case your Gmail works effectively on other browsers, then there is a problem with the browser. You can uninstall and again install the browser to solve the issue.
 

## Conclusion
The above listed are a few of the ways to deal with the Gmail Won’t Load problem. But if you still encounter the issue, then contact the experts to help you with the same.
sealos Cloud operating system based on kubernetes. Own your own cloud with one click！
Published: 2022-10-19 10:43:06

sealos is a cloud operating system distribution based on Kubernetes.

sealos let you install kubernets HA in few minutes.

sealos let you use cloud like PC:

This is sealos desktop:

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



pgsql on sealos:


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

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


redis on sealos:

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


more info:

https://github.com/labring/sealos
We've passed a 10 PR milestone to our repo during HacktoberFest
Tags: javascript, webdev, hacktoberfest, react
Published: 2022-10-19 10:28:22

We’ve developed an open-source language for building full-stack Node + React web apps with less code. It's called [Wasp](https://wasp-lang.dev/), and its primary purpose is to make a life of a developer easier. 

You describe the application’s functionality (API endpoints, authorization, deployment, etc.) in a single file. The compiler does the rest itself. The result is a full-fledged web app built with Node + React, created in a few minutes.

We've opted in for HacktoberFest, and it has already brought us tremendous results! Ten merged PRs from the external contributors, six are in progress, and more to come! It's a huge step forward for the project! Not only in terms of the amount of work done. But also the user engagement and general feedback. Definitely a huge win for us!


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



If you're still thinking about whether you need to join HacktoberFest or not -- you definitely should while there's still time! 

P.S: And if you'd like to join us as a contributor -- [click here](https://github.com/wasp-lang/wasp/issues/735)! 

P.P.S: Only 63 stars left until 2,000 on Github! [Please star Wasp](https://github.com/wasp-lang/wasp) if you haven't yet 😄 🐝
Acho que entendi meus porquês
Tags: teamwork, career, devjournal, motivation
Published: 2022-10-19 10:26:14

## E porque isso me faz sentir viva trabalhando

São 05:19 da manhã e já faz pelo menos 1h que leio freneticamente um dos livros indicados pelo meu mentor. Nem mesmo o remédio prescrito pra eu dormir a noite inteira consegue segurar a animação que ando sentindo nas últimas semanas em que ando me conhecendo e entendendo o porquê algumas pequenas coisas me animam tanto no trabalho.

Você já se perguntou "por que eu tô aqui?" ou "porque entre tanta gente boa que concorreu comigo pela vaga, eu fui escolhida?"? Demorou um pouco para eu entender, mesmo que sempre estivesse na minha frente.

Não me entendam mal. Eu sou muito boa tecnicamente. Eu amo tecnologia e amo aprender, e acredito que geralmente aprendo com uma facilidade maior que a média das pessoas (nitidamente não foi por minha modéstia).

Mas tem algo que sempre esteve comigo: **minha vontade de mudar as coisas**. Das políticas escolares como participação em grêmio estudantil, disputas nos DCEs na Universidade, formação de grupos de mulheres pra discutir nossa participação na tecnologia, eu sempre venho assim: como um ventinho de mudança.

E acredito que minha própria cara expresse "essa mulher de 1 metro e meio pode me ajudar", porque no dia das crianças, enquanto minha filha pequena brincava na famosa cama elástica, as crianças chegavam em mim e diziam "tia, as crianças grandes não deixam eu pular". E lá ia eu resolver o problema do pula-pula. Ecoa até agora na minha cabeça as palavras do meu marido: "tu não consegue ir em um parquinho sem achar uma razão para lutar por alguém?"!

E onde entra tudo isso no meu trabalho? É que encontrei aquilo que sou muito boa e que vai muito além das minhas automações de testes usando Go. **Eu fico feliz ajudando os times a serem mais felizes.** E as pessoas sentem em mim essa confiança que podemos fazer a cultura do time melhorar.

Nas últimas semanas nós começamos a implementar novas ideias no time, tanto pra abraçar mais a assincronia do trabalho remoto como para nos aproximarmos como time (mesmo em timezones bem diferentes). E a energia de ajudar algo a melhorar, ou piorar e planejar em grupo novamente como melhorar, é o meu porquê de estar aqui.

Acho que faz sentido que o feedback que mais recebi de outros times na vida é que eu deixo as pessoas mais felizes. E você, sabe seu porquê?
How to deploy Ethereum Smart Contract via remix IDE to the live network.
Tags: webdev, solidity, blockchain, ether
Published: 2022-10-19 10:09:19

If you want to deploy your smart contract into the live Ethereum network without the pain of sync the whole blockchain with ‘geth’ (around 40GB before I stop the process) which run for a week without full sync. You can deploy your contract via the Ethereum online IDE remix http://remix.ethereum.org/ .

The steps are very easy:

You need to flatten your contracts into single contract sol file, the best tool to use for this “truffle-flattener” https://www.npmjs.com/package/truffle-flattener
Copy and paste the code into the remix online IDE editor like on the screenshot:

Auto compile will compile your code and show you if there are warnings or errors.

3. After compile finishing you must go to the run tab:


4. Make sure you have a MetaMask installed (if not use MetaMask install it from here https://metamask.io/) and run on live network.

5. Make sure you have funds in your current MetaMask account they are needed for pay the gas price for uploading the contract to the live network.

6. From the select in the run tab select the contract you want to deploy


In my example, I want to deploy the contract “Crowdsale” this contract have a constructor params in my case `rate`, `wallet` and token address you want in your Crowdsale campaign to be sold.

7. Enter the values and click the green button upload, a MetaMask will open a small window in order to confirm your transactions. After you click to confirm you will see in the IDE console logs of your actions and your contract begin deployed.

8. You will wait a while until you can get your contact address. And that is your contract is deployed to the live Ethereum network.

* As you can see we use a Token Contract address in our constructor deployment. This is because we use Open-Zeppelin framework they contract Crowdsale accept Token contract address which will be distributed to investors.

In this case, you must first deploy your token contract ‘TokenContractName” by selecting it from the drop-down menu as we select our Crowdsale contract. After you successfully deploy your token contract you will receive the address in the Ethereum network where your token contract is live.

You then get this address and provide it to our Crowdsale contract as a constructor param.

It is as simple as that, if you have questions ask them in the comments.

Martin Tonev: CEO at https://entro.solutions/
How to deploy Vert.x applications with Docker
Tags: java, devops, docker, cloud
Published: 2022-10-19 10:09:19

---
title: How to deploy Vert.x applications with Docker
published: true
description: 
tags: java, devops, docker, cloud
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

{% embed https://youtu.be/e80eGbsWR4I %}

The most common approach is to deploy Vertx applications as fat jars - this means that we rely on build tools to generate a "fat jar" project (the application that includes built code, configurations alongside with bundled external dependencies). This app is ready to be executed on local systems as any normal jar project or could be deployed to popular platform as a service cloud providers that support deployments of fat jar apps (examples include Heroku, Clever Cloud, Microsoft Azure, Amazon among others). In addition, when we talk about microservices, it is a common practice to deploy them inside containers in order to improve their portability.
Upload a fil with JS Fetch API
Tags: javascript, node, webdev, programming
Published: 2022-10-19 10:07:21

// Select your input type file and store it in a variable
const input = document.getElementById('fileinput');

// This will upload the file after having read it
const upload = (file) => {
  fetch('http://www.example.net', { // Your POST endpoint
    method: 'POST',
    headers: {
      // Content-Type may need to be completely **omitted**
      // or you may need something
      "Content-Type": "You will perhaps need to define a content-type here"
    },
    body: file // This is your file object
  }).then(
    response => response.json() // if the response is a JSON object
  ).then(
    success => console.log(success) // Handle the success response object
  ).catch(
    error => console.log(error) // Handle the error response object
  );
};

// Event handler executed when a file is selected
const onSelectFile = () => upload(input.files[0]);

// Add a listener on your input
// It will be triggered when a file will be selected
input.addEventListener('change', onSelectFile, false);
Matchspace Music - Making music accessible to everybody
Tags: music, musicians
Published: 2022-10-19 10:07:18

Matchspace Music is the leading software platform for flexible music lessons and more. Whether children, adults, or the elderly, everyone will find here a suitable teacher.

Discover our app for music lessons and keep your appointments, payments, and homework under control. Learn one of over 45 different musical instruments with qualified music teachers at your home, in the teacher's studio, or live online.

[https://matchspace-music.ch](https://matchspace-music.ch)
We are doing a Code Coverage Webinar: what would you like to know?
Tags: programming, discuss, performance, testing
Published: 2022-10-19 10:05:04

We’re really excited for next week’s Live Talk on how to **Take your Code Coverage to the Next Level**. It's only a week away, and you can register [here](https://us02web.zoom.us/webinar/register/4016660923298/WN_0nByexsdRtOPl_IL171a6w).

If you're a developer, you probably know what code coverage is, and that a well-tested codebase is usually (but not always) a well-structured codebase. But are you leveraging your code coverage reports to achieve the best code quality possible?

Your team can easily overlook code coverage, especially if they are unaware of its benefits and how it impacts their work.

This webinar is made by developers, for the developer community, so your input is really important to us. 

## **What would you like us to cover?**
**(pun intended)**

👉 Share your questions in the comments
👉 Join us on October 25th to discuss code coverage with the engineering and product teams that built our [Codacy Quality](https://www.codacy.com/product) product 🤖 and see some real examples of how to improve your line coverage
Journey to Microsoft..
Tags: summerinternship, software, softwareengineer, dsa
Published: 2022-10-19 10:02:57

I recently completed my summer internship as a Software Engineer intern at Microsoft for the summer of 2022.I must say it has been a journey of self discovery and confidence-building.

I remember back in January 2022 when I decided to apply.
After viewing the Ad, I immediately proceeded to the Microsoft careers portal to submit my application. 

**January 2022**
I had submitted my application within 24 hours of viewing the job on LinkedIn and so the wait begun.  

**February 19th 2022**
About 8 weeks later, I received a rejection email. I was not that disappointed(I mean come on, this is Microsoft) .

**February 21st 2022**
Received an email telling me to disregard the rejection.

**March 7th 2022**
Was invited to take an online coding test and participate in a first round interview phone screen. All this was to happen in the next 4 weeks.

**March 24th 2022**
Did the codility online coding test.

**March 25th 2022**
Did the first round phone screen interview. 

**April 22nd 2022**
Was invited to the final round of interviews.

**May 11th 2022**
Did all four final round interviews.

**May 18th 2022**
Received a Congratulatory email offering me a position as a SWE intern.

**July 4th 2022**
First day as a SWE intern at Microsoft.

That sums up my journey to Microsoft.
My overall experience has been amazing and I can't wait to share more of my experiences and knowledge as a Software Engineer.
7 Tips for programmers by memes
Published: 2022-10-19 09:51:05

What would you recommend to young developers for a better, more productive future career?

## 1 - Reduce notifications and other interruptions

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


## 2 - Focus on the essence and basics, not necessarily the new trends

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


## 3 - Advice with others 
Ask the most experienced developer to review your PRs
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55wnji0sb5ouy1nb5w2i.jpg)


## 4 - Be careful while deploying
Some of the skills required for developer are indeed soft skills, like thoroughness and accuracy.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tjdlbizpbnlim5me5o5d.jpg)


## 5 - Learn git and other basic tools
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vqz3ys8oxv9thrtyopg.jpg)


## 6 - Keep in mind the unexpected, don't be so optimistic on your plans
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lx2gotzsv3qthaow7rrx.jpg)


## 7 - Know what you don't know
There is always something to learn.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiguwl5cm2501kfgzayl.jpg)
Git 2.38 has changed!
Tags: programming, productivity, git, tutorial
Published: 2022-10-19 09:50:14

Hey there everyone 👋!

All developers have used **[git](https://git-scm.com/)**, right? Well, the recent update dated on _13-10-22_ [`DD-MM-YYYY`] has somewhat changed git forever.

## 🪸 Backstory of Git

🐲 Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. It was initially released on 7 April, 2005. Git was developed the same person who built the the great **linux kernal**.

## 🦄 Introduction of Scalar

**[Scalar](https://github.com/microsoft/scalar)** has been a side project of microsoft for years now. It is open-source since the very beginning.
😎 Scalar is a tool that helps Git scale to some of the largest Git repositories. It achieves this by enabling some advanced Git features like the following -

- _**Partial clone**_: reduces time to get a working repository by not downloading all Git objects right away.

- _**Background prefetch**_: downloads Git object data from all remotes every hour, reducing the amount of time for foreground `git fetch` calls.

- _**Sparse-checkout**_: limits the size of your working directory.

- _**File system monitor**_: tracks the recently modified files and eliminates the need for Git to scan the entire worktree.

- _**Commit-graph**_: accelerates commit walks and reachability calculations, speeding up commands like `git log`.

- _**Multi-pack-index**_: enables fast object lookups across many pack-files.

- _**Incremental repack**_: Repacks the packed Git data into fewer pack-file without disrupting concurrent commands by using the multi-pack-index.

## 😮 Git adapts scalar

In the recent update of git (2.38.1), a new executable has been included with the git package - `scalar`.

It's is going to be intense as we uncover all the commands and their uses in the _**scalar**_ executable.

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

As you can see in the picture given above, scalar becomes a command in the shell just like git did.

## 🧡 Using Scalar

_🐉 Just for a stater, let's clone a repository using scalar._

![Scalar clone preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45j64bxtflg5m5cbl5ej.png)

You can get to know more about the entire scalar executable and it's history **_[here](https://github.blog/2022-10-13-the-story-of-scalar/)_**.

## 🙍 Connect with me
- **Mail** - `akashpattnaik.github@gamil.com`
- **Github** - `BLUE-DEVIL1134`
- **Twitter** - `akash_am1`
Note of growth
Tags: codenewbie, career
Published: 2022-10-19 09:40:55

Growth is such a fickle thing. 

I'm currently going through all of my projects trying to figure out the purpose of these projects so I can improve and update my Github account. I've never been so embarrassed in my life. I'm literally cringing so hard at the work I published is my youth (3 months ago btw).

At the same time I'm not feeling disappointed at the work that I dished out, I'm more happy at the fact that I can look at my past work and see how much I could improve on set work. 

But still this shit is cringe.

PS. Appreciate growth