teleren/devto huggingface dataset:
Hello World in Spring Boot
Tags: java, springboot, backend
Published: 2021-08-22 13:52:59

![Alt Spring Boot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/853hl8twca6nzmzf0pi7.png)

## Spring Boot [Rest API] - Hello World

Hello World App developed using Spring Boot.

## Installation

Import Maven based project in any of your Favourite IDE.

```bash
./mvnw spring-boot:run
```
## Output
Open in Browser

```
http://localhost:5000/hello-world
```

```
http://localhost:5000/helloworld-bean
```
## Usage
### HelloWorldController.java
helloWorld() method returning a string "Hello World".
The @GetMapping annotation is used to handle the GET request with the URI provided. It is a different version of @RequestMapping specifically for the GET Request.

```java
@GetMapping("/hello-world")
	public String helloWorld() {
		return "Hello World";
	}
```
helloWorldBean() method returning a bean with string parameter "Hello World". The bean is nothing but the instance object which are managed by the spring container. These beans are kind of stored at a one place like bag of beans from where they are accessed whenever required. The object created by the container are called beans.

```java
@GetMapping("/helloworld-bean")
	public HelloWorldBean helloWorldBean() {
		return new HelloWorldBean("Hello World");
	}
```
helloWorld1() method printing Hello World, 'name' using @PathVariable annotation. The @PathVariable annotation is used to extract the parameter value from the URI provided in this case name is being extracted from the URI and then it is called by the HelloWorldBean.

```java
@GetMapping("/helloworld/{name}")
	public HelloWorldBean helloWorl1(@PathVariable String name) {
		return new HelloWorldBean(String.format("Hello World, %s", name));
	}
```


## Credits
[in28Minutes](https://www.udemy.com/user/in28minutes/)
How to Master Vim
Tags: vim, linux
Published: 2021-08-22 13:50:08

Vim is a text editor that I use every day. It's a program that most people know about, but not many mastered.Here are some tips and tricks to get you started.

Vim is part of the UNIX family of programs, which means that it's an old program with a lot of history and power. Vim is not just a text editor, it's a "programmer's editor". That means it has some pretty advanced features under the hood.

First thing you need to do is get Vim installed on your computer, where I will assume that you are using Linux. If not, you can download it at [vim.org](https://vim.org)

One thing to know about vim is that it's **keyboard oriented**.

Every function has a keyboard shotcut. For example:

* To quit without saving, press `ZQ`.
* To save press `ESC` `:w`
* To start typing press `i`
* To go back to option mode, press `ESC`

And so in order to master vim, you need to master the keyboard shortcuts. 

To start learning vim, this [tutorial](https://vim.is/) is a good staring point. It takes you from beginner to master level.

Alternatively, you can grab a cheat sheet and start editing text. But that can be a frustrating process, as you will need to learn the keyboard shortcuts while at the same time doing your work.

## Why vim?

As software developers, we often spend all day inside looking at computers and writing code. 

So many people like me start a terminal to type vim. The reason is that vim is a good tool. Users can edit files, run simple shell commands, compile programs

What makes the tool good? I created some list of features that are very important for me:

* **Fullscreen** is the best way to focus. How to close windows, how to maximize them, how to split them - you don't need to think about how to use vim. 

* **Keyboard control** because as a coder your hands are already on the keyboard. You can just do everything what you need with keyboard. It's similar to "Windows" keyboard shortcuts, but much more powerful.

* **Keyboard macros** easily record and replay keystrokes. This feature saves you a lot of time
How to turn your whatsapp into an  API ?
Tags: node, npm, openwa, api
Published: 2021-08-22 13:37:12

Very easy steps to create an API using your Whatsapp number!(Open-Wa) 

It is very easy to use and in few steps get it up and running !

First You need to have node,npm and npx installed on your system!

and then.......

**Enter the line below on your terminal as shown below** 
![terminal example ](https://i.imgur.com/SxyIztr.png)


**To know how this works and other related stuffs, use this**
![terminal example ](https://i.imgur.com/Qz7UNsX.png)

**Setting a custom port, in my case I am using 8080**
![terminal example ](https://i.imgur.com/Xb4YMS4.png)

To know more about this please see the 
[open wa docs](https://docs.openwa.dev/pages/Getting%20Started/quick-run.html)
I’m fine. How are you?
Tags: mentalhealth
Published: 2021-08-23 20:21:06

---
title: I’m fine. How are you?
published: true
date: 2021-08-22 13:20:00 UTC
tags: mentalhealth
canonical_url: https://jasonstcyr.com/2021/08/22/im-fine-how-are-you/
---

> "Hi there, how are you?"
> "Fine, how are you?"
> "Fine, thank you." 

I’ve seen this play out as some sort of passphrase to start a conversation. It seems people can’t get started without the secret social handshake. But nobody wants to hear the **real answer to that question**.

I'm a little tired of saying "I'm fine". But I also understand it's purpose. If I unload on you, we're now derailing the conversation to be about my thing. If you unload on me, same deal. If we both unload, nothing's getting done. For efficiency, we must bury the details.

But the 100% real news is that **most people are not fine**. Almost everybody is dealing with something, and right now "fine" just means "I have it under control and you don't have to worry about it/I don't want to talk to you about it."

> “I have it under control and you don't have to worry about it.”
> - People who are not fine

But at times we have to tear down the façade. We gotta say: "Sorry, I can't deal with this right now." Some days, even good friends with great news is something you can't handle right now. I heard somebody use the phrase of ["not having the spoons"](https://en.wikipedia.org/wiki/Spoon_theory).

I wish we had another way of indicating "I'm not fine, but I don't want to talk about it, and I don't want to hear about your thing because I can't handle it right now".

For now, I guess we'll just say: **"I'm fine. How are you?"**

_**NOTE:** This text originally appeared [as a thread on Twitter](https://twitter.com/StCyrThoughts/status/1422675183324864518)._
PWA || Mistakes While making pwa INSTALLABLE
Tags: javascript, webdev, webmanifest, pwa
Published: 2021-08-22 13:09:38

## The Mistakes that make your pwa not valid to install. Or service and manifest does not meet installability

Today,I'm writing the mistake that I created while making my pwas and grabbed some knowledge and now I am sharing that knowledge with you.

## M1 : Icons purpose .
In webmanifest we have to declare the purpose of our icon in `"icons":[{"purpose":"my purpose"}]`
We write purpose `maskable` but it is not valid for Installiblity. You have to declare purpose to any .
```json
{
...
"icons":[
{
...
"purpose":"any"
}
]
}
```
## M2 : Broken path.
It's more important that you have to write correct path every time.
If you write any broken path it will not meet Installiblity.
*Where it's important.*
1. While Adding caches(sw.js)
1. While writing paths of icon , scope and start_url.(manifest)

## M3 : Path have to smaller case
In my app
I was written 
https://formal-stack.netlify.app/APP/
And my folder was also `APP` but it's important that start_url and scope in manifest have to match with the scope of registration of service worker (with case sensitivity).
I replaced `APP` with `app` and my app became installable.
## source code
If you want to check pwa example.<br>
Check
https://notableapp.github.io

https://formal-stack.netlify.app

{% github NotableApp/Formal-stack-pdfs %}
{% github NotableApp/notableapp.github.io %}
How to Redirect a domain only using DNS records
Tags: microservices, showdev
Published: 2021-08-22 12:26:00

At some point in time to want to move your website to a new domain address but don't want people with existing URL links to your old domain to find your content is no longer found, so then you need to set up a redirect link.

I thought this was easy, but turns out it isn't. You need a separate server for that. Who would want to purchase additional bucks just to set up a server to redirect links?

So let's meet [forwarddomain.net](https://forwarddomain.net), a simple redirect service.

All you need to do to use this service is to add CNAME and some TXT records, like this:

```conf
www.old.com     IN    CNAME   r.forwarddomain.net
_.www.old.com   IN    TXT     forward-domain=https://old.com/*
```

This will redirect all links from `www.old.com` to `old.com`. You can also redirect other domains, just change the `forward-domain=` part.

In case you want to redirect a root or apex domain, you can't do that with CNAME, so you can use an A record that directly bind to the IP address of this service:

```conf
old.com     IN    A       167.172.5.31
_.old.com   IN    TXT     forward-domain=https://new.net/*
```

That's it! this will redirect all links from `old.com` to `new.net`. Note the `*` part? it means also forward URL paths and GET query data.

What about the email? It is used to signing HTTPS certificates from Let's Encrypt. This should be your valid public email. HTTPS redirection would not work without it.

This is all you need to be able to set up domain redirection of your old domain. No coding required, no registration required, completely free and anonymous. You can also see the [GitHub repo](https://github.com/willnode/forward-domain) since it's an open-source project anyway.

> EDIT 2021-09-21: This post is updated for [v2.0 changes](https://github.com/willnode/forward-domain/blob/main/CHANGES.md)
Free courses this month (limited time)
Tags: programming, redis, linux, haskell
Published: 2021-08-22 12:15:06


Some of my courses are 100% free this month. If you want to learn more about ethical hacking or programming don't hesitate, it's a limited time offer :smile:

**Ethical hacking**

* [Password cracking with Python](https://www.udemy.com/course/ethical-hacking-password-cracking-with-python/)

* [SQL Injection tutorial](https://www.udemy.com/course/sql-injection-tutorial/)

* [Introduction to Exploits](https://www.udemy.com/course/ethical-hacking-introduction-to-exploits/?couponCode=AUG2021FREE)

**Programming**

* [C programming exercises](https://www.udemy.com/course/c-programming-exercises-for-beginners/)

* [Haskell programming exercises](https://www.udemy.com/course/haskell-exercises-for-beginners/)

**DevOps**

* [Redis Database tutorial](https://www.udemy.com/course/redis-database-tutorial/)

* [Linux AWK tutorial](https://www.udemy.com/course/awk-tutorial/)

* [Linux tmux tutorial](https://www.udemy.com/course/linux-tmux/)
Training Machine Learning models in AzureML
Tags: azure, microsoft, machinelearning, cloud
Published: 2021-08-22 11:39:05

Welcome to the next part of my blog series on Azure Machine Learning. Now we are going to jump into one of the most important aspect of the MLOps - Training of Machine Learning Models.

Usually Machine Learning models require high compute power to train on the dataset. It is quite evident that not everyone has access to high processing and storage capabilities. So, keeping in mind of the cost of procuring the infrastructure for the same, its better option to leverage the cloud resources and pay for the usage. 

Now, coming to training of Machine Learning models in Azure, we are going to follow simple steps to do so. At the end of the article, you will have created a training environment, trained your ML model and stored the artefacts of the models for future use. 


## Steps

1. Setup the environment
2. Creating your ML Script
3. Create Training Environment dependency file
4. Training the model

## Setup the Environment for ML

Follow the previous article to create Workspace, Compute and Data.

## Creating your ML Script

Before creating the ML Script, lets first create the directories for source files

{% gist https://gist.github.com/Vivek0712/2562a0d2d344fe0d7fc6debd313e8409 %}

The ML Script does the following 
- Parsess the Argument passed to the script (Input Data and Hyperparameters)
- Starts the run for the experiment
- Does all the ML Training
- Logs the metrics of the run
- Stores the output model

 {% gist https://gist.github.com/Vivek0712/54de84fa7cfc1e7923f419b376228af8 %}

## Creating Training Environment Dependency File

An Environment is managed and versioned in an Azure Machine Learning Workspace. You can update an existing environment and retrieve a version to reuse. Environments are exclusive to the workspace they are created in and can't be used across different workspaces.

We will use YAML file to list the dependencies of the environment we are going to use

{% gist https://gist.github.com/Vivek0712/79b3569f702381d429129a48a62c127e %}

## Training the Machine learning Model

- Create the environment from the dependency file
- Creating Configuration for Python Script
- Submitting the Script to the Experiment
- Register the model along with the RSME Value

We are going to create 10 different runs for 10 different Alpha values for our Ridge Algorithm to be trained on the Diabetes Dataset. The model with less RMSE will be considered as best model.

A ScriptRunConfig packages together the configuration information needed to submit a run in Azure ML, including the script, compute target, environment, and any distributed job-specific configs.

A model is the result of a Azure Machine learning training Run or some other model training process outside of Azure.Register a model with the provided workspace, we use _register_ method.

{% gist https://gist.github.com/Vivek0712/26e4fd2ccc4aa547e7bc3db2293e515d %}

We have successfully created and trained our Machine Learning model. In next article, we will see how to deploy our model to production and perform real-time inference.
Devlog #2: Small update
Tags: devlog, cms
Published: 2021-08-22 11:37:06

This is a short post about the improvements i made working on building my own CMS.

1. Added everything to one project
===================================

So before the admin panel and the blog was divided into two separate projects but now I have integrated both of them into one project so that now everything is tidier than before.

Now the project structure looks as so

    .
    ├── cron jobs
    ├── debug
    │   └── debug.log
    ├── index.js
    ├── node_modules
    │   └── ...
    ├── package.json
    ├── package-lock.json
    ├── public
    │   ├── css
    │   │   └── ...
    │   ├── fonts
    │   │   └── ...
    │   ├── images
    │   │   └── ...
    │   └── js
    │       └── ...
    ├── README.md
    ├── routes
    │   ├── blog.js
    │   └── dashboard.js
    ├── src
    │   ├── blogHandler.js
    │   ├── getPosts.js
    │   └── validateUser.js
    └── views
        ├── admin
        │   ├── addons
        │   │   └── ...
        │   └── pages
        │       └── ...
        └── blog
            ├── addons
            │   └── ...
            └── pages
                └── ...

You can see now that there is a `index.js` file in the root folder and that is the server file and then in the `index.js` routes are defined for the blog and the admin panel where you can access the admin panel by going to abodsakka.xyz/login now instead of admin.abodsakka.xyz before.

2. started adding stats to the dashboard
=========================================

![Dashboard of admin panel](https://i.ibb.co/txKmyCQ/screely-1628721515478.png)

As you can see now the dashboard has the amounts of posts that are posted and I am working on adding more stats but trying to figure out what to add and to integrate google analytics with the application.

Another thing you can see is a preview of how the user's profile picture would look like.

3. stability
=============

In this update, I also worked a lot on improving stability were implemented a system to catch all errors and save them so that they are not only in the terminal and it displays the time that error was caught on so that debugging could be much easier.
An MVC Generator for Your Next Express JS Project
Tags: javascript, node
Published: 2021-08-22 11:35:43

I'm tired of writing boilerplate codes for an MVC design pattern in my Express project. So I decided to create a generator for it. 🚀🚀

The package for this tool, I named it VYNL, it is published in [npm](https://www.npmjs.com/package/vynl) and you can start using it in your project.
```
$ npm install vynl
```

Create an empty express project, then type in 
```
$ npx vynl init
```

What it does for you, is simple, it makes out your project directory like so:

```
.
|--auth
|    └──auth.js
|--config
|    └──config.json
|--docs
|    |--paths
|    |    |--index.js
|    |    └──users.js
|    └──schemas
|         |--index.js
|         └──users.js
|--migrations
|--models
|--routes
|--app.js
└──swagger.js
```
It also creates these things out of the box for you:
1. A Users MVC (with Sequelize Model)
2. Basic authentication using jsonwebtoken
3. Swagger Documentation for the API routes.

Next, Adjust your project database configuration in `config/config.json`

Since the generator will only write codes for you, You are still required to install the packages needed to run the project yourself.
```
$ npm install sequelize jsonwebtoken swagger-ui-express mysql2 
```
if you are using other database than mysql, check [here](https://sequelize.org/master/manual/getting-started.html)

Then to generate a new MVC simply use:
```
$ npx vynl generate:api -m <model_name> -f <model_fields>
```

model_fields syntax: <name_of_field>:<field_data_type> and comma separated for the next field. Ex. `name:string,birth_date:string,email:string,password:string`

It also allows you to only generate a part of the MVC (ex. only the Model).

- Generate Model
```
$ npx vynl generate:model -m <model_name> -f <model_fields>
```

- Generate Controller
```
$ npx vynl generate:controller -m <model_name>
```

- Generate Route
```
$ npx vynl generate:route -r <route_name>
```

- Generate Swagger Doc
```
$ npx vynl generate:swagger -m <model_name> -f <model_fields>
```

And that's it. I hope this tool can help you in your next Express project.

Cheers 🍷
Renaming Columns for Mutable Operations
Tags: datascience, analytics, python, pandas
Published: 2021-08-22 11:16:24

The simple syntax used to change a column name is like this:
>>>This is with the following info in mind: 
dataframe name is file and we want to modify the 9th column's name

```python
file_df.columns[8] = 'new_column_name'
```

However, index doesn't support mutable operations, and that's why we'll have to use a different syntax for this modification, which is as follows:

```python
file_df.rename(columns={'old-column-name':'new_column_name'}, inplace=True)
```

##There's another method that's a little longer, and it goes as follows:

```python
new_labels = list(file_df.columns)
new_labels[8] = 'new_column_name'
file_df.columns = new_labels
```

_Note: Using this method, we're reassigning the entire thing to a new list_
Retry, Timeout and Cancel with fetch()
Tags: web, fetch
Published: 2021-08-22 11:13:34

*(This was originally posted at my development blog on [chrisarmstrong.dev](https://www.chrisarmstrong.dev). Check it out for more AWS and DynamoDB related articles!)*

Although none of these are built-in, it's easy to add retries, timeouts and cancellations to your fetch() calls without needing to use a full-featured third-party library.

## Retries

By wrapping your fetch handler in a recursive function that returns a promise, you can easily get retry behaviour:

```javascript

const fetchWithRetries = async (
url, options, retryCount = 0) => {
  // split out the maxRetries option from the remaining options
  // (with a default of 3 retries)
  const { maxRetries = 3, ...remainingOptions } = options;
  try {
    return await fetch(url, remainingOptions);
  } catch (error) {
    // if the retryCount has not been exceeded, call again with retryCount + 1
    if (retryCount < maxRetries) {
      return fetchWithRetries(url, options, retryCount + 1)
    }
    // max retries exceeded, just throw error
    throw error;
  }
}
```

You could even customise it further with additional flags to control when to retry, or to throw a `MaxRetriesError` when the `maxRetries` count is hit.

## Timeout

This one is fairly easy - we use `setTimeout` to reject the promise when there is a timeout error.

```javascript

// Create a promise that rejects after `timeout` milliseconds
const throwOnTimeout = (timeout) => 
  new Promise((_, reject) => 
    setTimeout(() => 
     reject(new Error("Timeout")),
     timeout
    ),
  );

const fetchWithTimeout = (url, options = {}) => {
  const { timeout, ...remainingOptions } = options;
  // if the timeout option is specified, race the fetch call
  if (timeout) {
    return Promise.race(fetch(url, remainingOptions), throwOnTimeout(timeout));
  }
  return fetch(url, remainingOptions);
}
```

We use Promise.race to run both the `fetch()` call and the `setTimeout()` call at the same time - whichever resolves or rejects first will resolve or reject the `Promise` (respectively), with the other result being ignored.

## Cancel

[This one is documented on MDN](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), but for completeness here it is below.

```javascript
const fetchWithCancel = (url, options = {}) => {
  const controller = new AbortController();
  const call = fetch(url, { ...options, signal: controller.signal });
  const cancel = () => controller.abort();
  return [call, cancel ];
};
```

In the above, we return a tuple with the returned promise and a `cancel` function that allows the user to cancel the request if needed.

An example showing its usage is below:

```javascript
// We don't await this call, just capture the promise
const [promise, cancel] = fetchWithCancel('https://cataas.com/cat?json=true');

// await the promise to get the response
const response = await promise;

// ...
// cancel the request (e.g. if we have rendered something else)
cancel();

```
Appending Two DataFrames in Pandas
Tags: python, datascience, analytics
Published: 2021-08-22 11:04:15

Let's say we have two dataframes with the same attributes and they share a physical attribute that may vary. We can combine both dataframes and differentiate using this physical attribute to make handling csv files easier.

For example, if we have descriptions of colors of skin, hair, and eyes for two dataframes, one for males and one for females, we can add a column at the end that signifies whether the attributes in a certain row belong to a male or female, all in the same dataframe (population_df) instead of 2.

##Importing and reading the files
```python
Import pandas as pd
males_df = pd.read_csv('males.csv')
females_df = pd.read_csv('females.csv')
```

##Adding a last column with the attribute used for distinction
```python
gender_male = np.repeat('male', males_df.shape[0])
gender_female = np.repeat('female', females_df.shape[0])
```

##Appending the two dataframes
```python
population_df = males_df.append(females_df)
```

##Saving the combined dataset with a False index in order not to save the file with the unnamed column
```python
population_df.to_csv('Filename.csv'), index=False)
```

_Note: You can make sure that you've successfully appended your two dataframes by using .shape_

```python
population_df.shape
```

_If the number is the sum of the two dataframe counts, proceed with your work_