teleren/devto huggingface dataset:
[Solved] The connection to the server 127.0.0.1:16443 was refused - did you specify the right host or port? (Ubuntu)
Tags: bug
Published: 2022-07-26 19:57:00

You might see this kind of issue:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9l5ebfs1yb7iz5vdrnn.png)

So, for Microk8s, you need to check if that is running or not
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0w5srjd2a7gm9zjwjkfc.png)

You can inspect microk8s:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79yg232x3iosahpcf6b8.png)

To solve these issues:

Simply uninstall microk8s:

```
snap disable microk8s
```

or,

```
microk8s.disable dashboard dns
sudo snap remove microk8s
```

Then [install](https://ubuntu.com/tutorials/install-a-local-kubernetes-with-microk8s#1-overview) microk8s again on your ubuntu

```
sudo snap install microk8s --classic

microk8s status --wait-ready

microk8s enable dashboard dns registry istio

microk8s kubectl get all --all-namespaces

microk8s dashboard-proxy

```



Start and stop Kubernetes to save battery
Start
`microk8s start`

Stop

`microk8s stop`


Now you can create pods
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbqc3ftd0g9lyq5mp6xg.png)
<img src="https://media0.giphy.com/media/Nfs5y1kzJKfu/giphy.gif?cid=ecf05e472d3w835ptrri5m1p6ifnwl9mi7ope9pifvhpcxf6&rid=giphy.gif&ct=g">
Configure your Apache server to allow Service Workers
Tags: apache, javascript
Published: 2022-07-26 19:57:00

Trying out Service Workers in your web project, you might have encountered this error message at some point:
> The path of the provided scope ('/') is not under the max scope allowed ('/assets/js/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.

This happens when you try to place your Service Worker (let's call it `sw.js`) in some folder other than the root folder of your project. While it's basically okay to put that file at root, it might clash with the pattern you had in mind for your project and you'd rather have `sw.js` in a folder like `/assets/js/`. 

Well, the error message already has all the hints you need to achieve this.

In order to modify the HTTP header, you'll first have to load the headers module in your `httpd.conf` file by adding/uncommenting this line:
`LoadModule headers_module modules/mod_headers.so`

Then, assuming you're serving via HTTPS, go into your `httpd-ssl.conf` file and add the following lines:
```
<IfModule mod_headers.c>
<Files "sw.js">
Header set Service Worker-Allowed "/"
</Files>
</IfModule>
```

And that's it.
You should now be able to place your Service Worker at basically any place you like inside your project.
FastifyError- Request body is too large
Tags: node, webdev, javascript, programming
Published: 2022-07-26 19:46:17

Article is originally published to my blog here- [FastifyError- Request body is too large](https://stackblogger.com/fastify-request-large-body-error/)

Fastify is a Node.Js Server Side Framework written on top of JavaScript scripting language. It has by default 1MB of Request Payload size limit. Passing a large payload or even more than 1MB of payload gives **Request Body is too large error**. Let’s resolve the FastifyError- Request body is too large error.

Below screenshot shows the default maximum payload size limit Fastify is allowed to accept.


![Source: Fastify default Body Limit](https://cdn.stackblogger.com/wp-content/uploads/2022/07/fastify-request-body-limit-min-1024x223.png)

## How the error looks
Following screen shows the Fastify Request body too large error.

![FST_ERR_CTP_BODY_TOO_LARGE- Request body is too large](https://cdn.stackblogger.com/wp-content/uploads/2022/07/fastify-request-body-too-large-error-min-1024x160.png)

## Resolve FastifyError- Request body is too large
To resolve the Request body too large error, we need to increase the default size in Fastify Server instance.

Provide the `bodyLimit` parameter in the Fastify create server options object.

```typescript
import Fastify from 'fastify'
const fastify = Fastify({
  logger: true,
 
  bodyLimit: 30 * 1024 * 1024 // Default Limit set to 30MB
})
 
 
// Declare a route
fastify.get('/', function (request, reply) {
  reply.send({ hello: 'world' })
})
 
// Run the server!
fastify.listen({ port: 3000 }, function (err, address) {
  if (err) {
    fastify.log.error(err)
    process.exit(1)
  }
  // Server is now listening on ${address}
})
```

Provide the size in bytes (convert to MB by multiplying 1024 twice) to `bodyLimit` parameter. Following line sets the default size limit to 30MB.

```typescript
bodyLimit: 30 * 1024 * 1024
```

Save the changes and run application. Now you can send up-to 30MB of request body without any failure.

## Conclusion

Fastify is Node.Js Framework to write Server-Side apps built on top of JavaScript platform. It is recommended to use with Node.Js TypeScript project.

The article resolves a very common fastify error ie. request body is too large error. Hope it helps you resolve your issue. If you still face the problem, make sure to comment below and we will try to look into the issue.

Checkout other JavaScript articles [here](https://stackblogger.com/category/javascript/).
How to become KEYBOARD ONLY user (macOS)⚡️
Published: 2022-07-26 19:35:00

I got tired of lifting my palms from the keyboard while browsing the web. 

Especially now, after mastering the 10-finger typing technique on the US layout. 

Grabbing mouse for a one-click action is the lowest ROI activity any 99+ word per minute typer can experience.

## [Vimium Chrome extension](https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en)

Click `f` to map all the links to keyboard shortcuts on Chrome tab.

## [Spectacle](https://www.spectacleapp.com/)

Resize/position Application windows in macOS.

## [Vim Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=vscodevim.vim)

_prerequisite: Get a hold of the extension by going through [Learn Vim](https://marketplace.visualstudio.com/items?itemName=vintharas.learn-vim)_

Ditch the arrow key navigation in VSC.

## [Alfred](https://www.alfredapp.com/)

Supercharged Finder, navigate to bookmarks and browsing history from the macOS.

**Summary**

Ditching mouse navigation is an uncomfortable journey.

It took me 2-3 months to feel the benefits of switching to keyboard only navigation.
 
Get going, let me know how it goes! ⌨️
Python script to run multiple servers simultaneously on a local machine on Mac.
Tags: python, automatio, microservices
Published: 2022-07-26 19:33:00

There are a number of times we have a bunch of servers we need to run to fully run an application, yes i am talking about the microservice arch. It's annoying to go to each repo and get the server running. Below is the script for making it automated.

```python

#!/usr/bin/python3

"""
Script that starts the servers from the "services" array.
services = [
  {
    "name": "service_name",
    "path": "path_to_service",
    "command": "command_to_run",
  },
  ...
]
for a single server, please pass the name of the service to start...
author: msamgan
created at: 2022-05-01
updated at: 2022-07-22
version: 1.1.0
signature: ./server | ./server <service_name>
"""

import os
import sys

services = [
    
]

# uncomment if on mac os..
# os.system("say 'booting shopini servers'")
os.system("sleep 1")

n = len(sys.argv)

serverCommand = ""
for service in services:
    if n > 1:
        if service["name"] != sys.argv[1]:
            continue

    # say = "say 'booting " + service["name"] + " server'"
    # os.system(say)
    os.system(
        "ttab.sh -w -t '"
        + service["name"]
        + "' -d "
        + service["path"]
        + " "
        + service["command"]
    )

# os.system(
#     "say 'all shopini servers are running at there full potentials, have a nice day!'"
# )
# kill command: kill -9 $(lsof -ti:5100)

```

The [ttab.sh library you will need](https://github.com/mklement0/ttab)
Functional Class
Published: 2022-07-04 02:53:27

I see a lot of question asked about javascript. As I  One of the things I have been studying is function vs classes. 

One of the things I learned is that anything that can be written as a function can be written as a class. 

Below I have typed out an example.
We have a book function that gives us some attributes of a book object.  

## Function 
```
function Book(title, author, ISBN, numCopies) {
  this.title = title;
  this.author = author;
  this.ISBN = ISBN;
  this.numCopies = numCopies;
}

Book.prototype.getAvailabitly = function() {
  if (this.numCopies == 0) {
    return "Out Of Stock";
  } else if (this.numCopies < 10) {
    return "Low Stock";
  }
  return "In Stock";
}

Book.prototype.sell = function(numCopiesSold = 1) {
  this.numCopies -= numCopiesSold;
}

Book.prototype.restock = function(numCopiesStocked = 5) {
  this.numCopies += numCopiesStocked;
}

const Divergent = new Book("Divergent", "Veronica Roth", 9780007550142, 5);
console.log(Divergent.getAvailabitly());
HungerGames.restock(12);
console.log(Divergent.getAvailabitly());
HungerGames.sell(17);
console.log(Divergent.getAvailabitly());
```

##Class 
```
class Book {
  constructor(title, author, ISBN, numCopies) {
    this.title = title;
    this.author = author;
    this.ISBN = ISBN;
    this.numCopies = numCopies;
  }

  get availability() {
    return this.getAvailability();
  }
  
  getAvailability() {
    if (this.numCopies === 0) {
      return "Out of stock";
    } else if (this.numCopies < 10) {
      return "Low stock";
    }
    return "In stock";
  }

  sell(numCopiesSold = 1) {
    this.numCopies -= numCopiesSold;
  }

  restock(numCopiesStocked = 5) {
    this.numCopies += numCopiesStocked;
  }
}

const Divergent = new Book("Divergent", "Veronica Roth", 9780007550142, 5);
console.log(Divergent.getAvailabitly());
HungerGames.restock(12);
console.log(Divergent.getAvailabitly());
HungerGames.sell(17);
console.log(Divergent.getAvailabitly());
```
Both will give you the same results. 
But one of the things that I like about using a class method is that we can encapsulate our code so we know what function belong to the class. It helps us better organize our code and follow the flow. 

As I am learning classes are becoming more of the standard when you have to choose between the two. 

Hopefully as I learn I can continue to help make this path easier for others. 

I hope this helps and as always
Happy Coding 👨🏿‍💻👨🏻‍💻🧑🏾‍💻👩‍💻
how to solve this npm error and this bug in cache file
Tags: react, npm
Published: 2022-07-26 19:25:46

 A complete log of this run can be found in:
npm ERR!     C:\Users\sajol\AppData\Local\npm-cache\_logs\2022-07-26T19_22_03_575Z-debug-0.log

how to solve this npm error in react
function to round up a float number to next point five like 3.3 to 3.5, 3.8 to 4
Tags: php, functional
Published: 2022-07-26 19:17:11

If you are from the shipping industry you face this problem a lot of time where you charge per 0.5 kg. In this kind of case, you need to make the weight from float to round up.

here is a php function to achieve that.


{% embed https://gist.github.com/msamgan/c89ddb034761602bfc7a1f402151cc6b %}
10 Rust technology essentials
Tags: rust, programming
Published: 2022-07-26 19:09:05

This article will cover a bunch of examples what really makes Rust so interesting for developers. It’s not just about system programming anymore. Rust moved on to boost different areas where classical system programming languages haven’t really taken hold. The formula for success is a sophisticated combination of new and carefully selected concepts from other languages that form Rust and [developers already love Rust](https://insights.stackoverflow.com/survey/2021#most-loved-dreaded-and-wanted-language-love-dread).

Of course the language itself is no reason to blindly adopt it. There are so many different aspects starting with a module eco-system and ending with the question about hiring new developers, but that’s another thing that is always hard for new technologies. Even if you can’t or don’t plan to use Rust it might be a huge asset for your daily work to have some Rust understandings that makes you a better developer.

## Essentials

When we compare Rust to other system programming languages it’s clear, why memory-safety is such an important thing, while VM-based technologies don’t have to deal a lot with those problems. The other way round for asynchronous programming there is less often a need for native local programs, but as an IO-intensive application running in the cloud it’s a huge benefit to use less resources more efficiently.

[Read about 10 Rust essentials](https://blog.consol.de/software-engineering/web-application-development/rust-technology-essentials/) at my company's blog.
Paste Hosting CSS code with StaticSave.com for free
Published: 2022-07-26 18:39:18

## 1. Introduction

Paste hosting is a service that allows you to store code snippets, files, and other text-based content online. It is often used by developers and programmers to share code snippets with others, or to store code snippets for later use.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7fl31w65m604e8skhc4.png)
 
## 2. What is Paste Hosting?

Paste hosting is a service that allows you to store code snippets, files, and other text-based content online. It is often used by developers and programmers to share code snippets with others, or to store code snippets for later use.

Paste hosting services typically provide a web-based interface that allows you to create and manage your code snippets. Some paste hosting services also offer features such as syntax highlighting, version control, and collaboration tools.

Read: [Importance of CSS in Web Development](https://staticsave.com/blog/importance-of-css-in-web-development)

## 3. How to use StaticSave.com to host your CSS code for free

[StaticSave.com](https://staticsave.com/) is a free paste hosting service that allows you to store code snippets, files, and other text-based content online. StaticSave.com offers a web-based interface that allows you to create and manage your code snippets.

To use StaticSave.com to host your CSS code for free, simply create a new paste, enter your CSS code into the paste editor, and then click the "Save" button. Your CSS code will then be stored on StaticSave.com's servers and will be accessible to anyone with the URL.

## 4. The benefits of using StaticSave.com to host your CSS code

There are several benefits to using StaticSave.com to host your CSS code. 

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

First, StaticSave.com is a free service, so you don't have to pay anything to start using it. 

Second, StaticSave.com offers a web-based interface that is easy to use. 

Third, your CSS code easier to read and update. 

Finally, it provides unlimited views for viewing the hosted content.

## 5. Conclusion

Paste hosting is a great way to share code snippets with others, or to store code snippets for later use. StaticSave.com is a free paste hosting service that offers a web-based interface with simple interface and easy to update your code.

Also Read: [Paste Hosting Code Snippets](https://staticsave.com/blog/paste-hosting-code-snippets)
Meet react-cloud-letter, a React component to wrap your text in cloud-like shapes ☁️
Tags: react, component, showdev, opensource
Published: 2022-07-26 18:33:00

I made [react-cloud-letter](https://github.com/foretoo/react-cloud-letter) — a customizable, easy-to-use React component. It turns your content into auto-merged clouds that are super stylish and attractive to read.

[npm link](https://www.npmjs.com/package/react-cloud-letter), unpacked size — 37 kB only

You can wrap the whole text, certain parts of it, just spaces (see examples below!), or customize your variant on [Demo page](https://foretoo.github.io/react-cloud-letter).

1. Partial mode
![example of react-cloud-letter applying](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ti50m3imco7t8unickc.png)
2. Word mode

![example of react-cloud-letter applying](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abkw0jnhrio91oy6g7cu.png)
3. Space mode

![example of react-cloud-letter applying](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcv5zv73zwjdqaxxvgq3.png)

Let me know what you think. Any feedback would be appreciated! ✌️
Leetcode 523. Continuous Subarray Sum
Published: 2022-07-26 17:56:37

Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise.

An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.

 

Example 1:

Input: nums = [23,2,4,6,7], k = 6
Output: true
Explanation: [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.
Example 2:

Input: nums = [23,2,6,4,7], k = 6
Output: true
Explanation: [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42.
42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.
Example 3:

Input: nums = [23,2,6,4,7], k = 13
Output: false
 

Constraints:

1 <= nums.length <= 105
0 <= nums[i] <= 109
0 <= sum(nums[i]) <= 231 - 1
1 <= k <= 231 - 1



**Solution:** Here is the link of our blog to the solution of this problem:
[continuous subarray sum - FoolishHungry Blog](https://foolishhungry.com/continuous-subarray-sum/)
Experience Of Virtual Internship
Published: 2022-07-26 17:51:01

Hello Folks!

I am really happy to write about my internship experience at **LetsGrowMore(LGM)** Community under the virtual internship program in July 2022.

It is very good platform for exploring your existing knowledge and expand your knowledge.

I would like to thanks to **Aman Kesarvani Sir** and **LetsGrowMore(LGM) Community** for giving me this opportunity to explore my talents and skills.

Please visit below given website:
http://letsgrowmore.in/
http://letsgrowmore.in/vip
How to Automate REST API Security Testing
Tags: api, security, testing
Published: 2022-07-26 17:48:07


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

Developers and early-stage startups build REST APIs to enable mobile, web, and API applications. Most APIs are public-facing and seldom go through a proper security testing cycle. 

According to Gartner, APIs have now become the most attack vector. Ahead of networks, fishing attacks, etc. Bots can scan and detect public-facing APIs, and once they discover vulnerabilities, they continuously exploit them.

Most applications fall into compliance categories like SOC 2 for technology, PCI DSS for payments, HIPAA for medical privacy, and GDPR/CCPA for consumer privacy.

If your API is in any of these compliance areas, you're required by these standards to continuously security/penetration test your APIs, report breaches, and pay punitive damages. You can no longer hide and ignore security issues. You must report within a specific time frame, and failing to comply can cost you dearly.

These standards have the same primary purpose: to protect user data and privacy and ensure your application/organizations treat security with utmost importance.

Historically, these below impedances caused developers to skip or delay security testing.
Manual Testing - DAST scanners automate basic stuff, but deeper testing requires skillful penetration testers
Expensive - Penetration testing incurs high costs
Low Quality - Most penetration test reports contain a lot of issues that developers rate as low priority and with no clear remediation instructions.

I'm going to suggest free and automated solutions for you to get started:

[EthicalCheck](https://www.ethicalcheck.dev/) (Recommended)
It is a free and instant API penetration testing online tool. The tests are non-intrusive and require no sign-up. The downside is the tests are limited. Point to your public-facing API and get an instant report in under 1 minute. Additionally, the generated PDF report is SOC 2 and other compliance compatible.

[Stackhawk](stackhawk.com)
Offers free and paid versions. It is built on top of ZAP. Sign-up and basic security understanding is required.

[APIsec](apisec.ai)
Offers free and paid versions. A low code platform. Sign-up is required. Coverage API-centric issues like logic flaws, access control, OWASP, etc.
Vitest is fast, jest is faster *
Tags: vue, vitest, javascript, testing
Published: 2022-07-26 17:31:32

* for the more real world cases

https://vitest.dev/ is claiming to be blazing fast, and that maybe the case for some very unity tests with no dependencies.

But if you're writing real world more feature/integration "unit" tests you're better of sticking with what you have already.

I won't go into much detail, but be aware of the issues before deciding to migrate to vitest

Github issues discussing the problems:

- [Vitest runs tests 3x slower than Jest with threads: true](https://github.com/vitest-dev/vitest/issues/579)
- [Coverage is very slow on large projects](https://github.com/vitest-dev/vitest/issues/1075)

I've migrated a large codebase not aware of these issues and now have to wait 10/15 minutes on ci pipeline instead of the 3/4 minutes i used to with jest.

Just be aware of these things before going down the same road i've done.
Installing Unreal Engine Plugins from GitHub or Source Code
Tags: ue5, gamedev, github, webrtc
Published: 2022-07-26 17:14:00

Whether you are just getting started with the Unreal Engine or have been using it for years, Plugins are a great way to enhance your creation and reduce the development time across a project. Although many useful plugins come preinstalled on your system, your project may require more bespoke and advanced tools that aren’t included by default and need to be installed from a 3rd party host like GitHub.


## How to install 3rd Party Plugins from GitHub or Source Code

1. To get started make sure you have the [Unreal Engine installed](https://docs.unrealengine.com/5.0/en-US/installing-unreal-engine/) along with Visual Studio. Make sure that you also have [Visual Studio set up for game development with C++](https://docs.unrealengine.com/4.26/en-US/ProductionPipelines/DevelopmentSetup/VisualStudioSetup/).
2. Create a project within the Unreal Engine editor, then save and close the program.
3. Locate the directory of your newly created project. For example _C:\Users\User\Unreal Engine\MyProject_
4. Create a “Plugins” folder and place the source code into the new directory.  For example _C:\Users\User\Unreal Engine\MyProject\Plugins_
5. Navigate back to the top level of your project and right-click on the _.uproject_ file. Select Generate Visual Studio Project.
6. Reopen the project with the Unreal Engine editor and Navigate to _Edit>Plugins_ and enable (if already enabled don’t worry) your new plugin. 


From there the engine should restart and you should have your newly installed plugin ready to use. If you are interested in an example of a plugin your might want to install from a 3rd party, [check out the Dolby.io Millicast WebRTC plugin for creating WebRTC pixel streams.](https://dolby.io/blog/using-webrtc-plugins-to-build-a-scalable-unreal-engine-5-streaming-experience/)