teleren/devto huggingface dataset:
A Script Tells Me What To Test
Tags: javascript, opensource, typescript, testing
Published: 2022-12-02 08:25:56

When using Jest, I like to bump the global coverage threshold. Yesterday I was excited to bump the numbers in my [suggest-test](https://github.com/mattferrin/suggest-test) repository.

```
coverageThreshold: {
  global: {
    branches: 67,
    functions: 33,
    lines: 38,
    statements: 38,
  },
},
```

After testing 4 not large units, my branch coverage was much higher than everything else. The reason this made me happy is that it was the result of using my own `suggest-test` tool on itself. The `includeStatements` command line argument had honed in on conditionals for me.

```
suggest-test --includeTested=false --includeStatements=false
```

I think it's a mistake that so many focus on statements/lines and not more on conditionals/branches. Conditionals are where most of the business logic resides. And it's easy to write half baked tests to boost statement coverage without really testing much.

And while it's still only a release candidate, feel free to try out my [@clowd/suggest-test](https://www.npmjs.com/package/@clowd/suggest-test) NPM package.
Virtual Agent - Add Utterance to an Intend.
Tags: servicenow, utterance, virtualagent, ai
Published: 2022-12-02 08:11:58

Interested to further improve your Virtual Agent Service and see, what your customer are asking for in the Chat Conversation?

See the possibilities here:

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

More Details are available in this article:
https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/administer/virtual-agent/concept/nlu-tab.html
Layered Architecture Style
Tags: architecture, design, pattern
Published: 2022-12-02 08:10:58

---
title: Layered Architecture Style
published: true
description: 
tags: architecture, design, pattern
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-02 08:09 +0000
---

Layered architecture, is an architecture pattern that helps for having a more organized and structured codebase.

Each layer has its distinct job and all the layers communicate via well-defined interfaces.

This architecture helps us with maintainability and scalability and is often used on enterprise applications.

You should be strict about not letting these layers have direct dependencies between layers, otherwise, you will lose the benefits of this architectural style.

Usually, the communication or interaction between layers is top-down at higher levels of the application such as user interaction using lower parts of the application such as the Database.

The key idea of this architectural style is to have a clear separation of concerns.

Keep in touch on twitter [@slmdiar](https://twitter.com/slmdiar).
Kotlin Code Smell 3 - String Abusers
Tags: kotlin, cleancode, codesmells, programming
Published: 2022-12-04 11:23:14

---
title: Kotlin Code Smell 3 - String Abusers
published: true
date: 2022-12-02 08:00:42 UTC
tags: kotlin,cleancode,codesmells,programming
canonical_url: https://yonatankarp.com/kotlin-code-smell-3-string-abusers
---

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

> **_TL;DR:_** _Use real abstractions and real objects instead of string accidental manipulation._

## **Problems**

- Complexity

- Readability

- Maintainability

- Lack of Abstractions

## **Solutions**

- Work with objects instead of strings.

- Replace strings with data structures dealing with object relations.

- Find [**Bijection**](https://maximilianocontieri.com/the-one-and-only-software-design-principle) problems between real objects and the strings.

## **Examples**

- Serializers

- Parsers

## **Sample Code**

### **Wrong**

```
val schoolDescription = "College of Springfield"

// location = "Springfield"
val location = """[^]*\$""".toRegex()
    .find(schoolDescription)?.value

// school = "College"
val school = """^[\w]+""".toRegex()
    .find(schoolDescription)?.value

```

### Right

```
class School(
    private val name: String,
    private val location: Location
) {
    fun description() = "$name of ${location.name}"
}

class Location(
    val name: String
)

```

## **Conclusion**

Don't abuse strings. Favor real objects. Find absent protocol to distinguish them from strings.

## **Credits**

- [Code Smell 04 - String Abusers](https://maximilianocontieri.com/code-smell-04-string-abusers) by [Maxi Contieri](https://hashnode.com/@mcsee)
Shell into ECS Fargate container with VSCode AWSTool
Tags: ecs, fargate
Published: 2022-12-02 07:58:43

The AWS Toolkit for Visual Studio Code keeps getting better:


## Easily log into fargate container

![Log into fargate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wrokgn76au1xdvscu984.png)

This becomes possible with `aws ecs execute-command`, see [ecs.exec](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html). It has nothing to do with ssh, it's done via the Systems Manager!


## Execute Lambda Functions


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

As I like to save some example events locally, this lets me use these files. Again - faster than with the console.

## View larger CloudWatch logs streams

If you have a large log stream with the console, you must click *load more* **several** times.


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

The same thing is achieved by the toolkit:

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

Good work toolkit team!
Huawei MateBook D14 - AMD 7 4000 Series Run MacOS.
Tags: huawei, amd, vega
Published: 2022-12-02 07:39:58

Hello community.  I have a Huawei MateBook D14 Ultrabook with a CPU AMD 7 4000 series / model 4800h.  This UltraBook has an AMD Vega 10 GPU. Is it possible to run macOS on this UltraBook?
How to search accurately in google
Tags: beginners
Published: 2022-12-02 07:09:11

## KEYWORDS
~~How can i add drag-and-drop feature to my website~~
<u>implement drag-and-drop html javascript example</u>
**implement (target object) (stack) (what do you want to do)**
_ex) implement drag-and-drop html javascript example
ex) implement drag-and-drop html react demo
ex) implement drag-and-drop html Vue.js sample_

## EXACT MATCH
~~docker mysql existed with code 137~~
<u>docker "mysql existed with code 137"</u>
**"(the text really you want to search)"**

## EXCLUDE
~~how to use web sql database in javascript~~
<u>how to use web sql database in javascript - php</u>
**(The question) - (the results you don't want)**

## SITE:URL
~~detect click ouside element in react~~
<u>site:stackoverflow.com detect click outside element in react</u>
**site:(The site you want to get results) (question)**

## BEFORE:DATE, AFTER:DATE
~~site:stackoverflow.com detect click outside element in react~~
<u>site:stackoverflow.com detect click outside element in react after:2020</u>
<u>site:stackoverflow.com detect click outside element in react before:2020</u>
**(question) (after or before):(date)**

---

**REFERENCE**

{% embed https://www.youtube.com/watch?v=By_qxt0SZlI %}




[https://support.google.com/websearch/answer/134479?hl=en](https://support.google.com/websearch/answer/134479?hl=en)
Roadmap to big data?
Tags: beginners, programming, productivity
Published: 2022-12-02 07:03:09

Step by Step plan to getting started with Big Data (Free Resources)🚀

The best part is that all the below videos are Completely Ad-Free.

Step 1 - Learn SQL 

📌 Basic SQL Playlist (16 videos)
https://lnkd.in/gdnhRk8b


📌 Advanced SQL Playlist (2 videos)
https://lnkd.in/g8tyEKbU


📌 Leetcode SQL Playlist (5 videos)
https://lnkd.in/gKeSMPmW

Step 2 - Learn One Programming fundamentals

📌 Follow any playlist of your choice (Python, R, SQL)

Step 3 - Big Data Concepts 

📌 Big Data Fundamentals Playlist (12 videos)
https://lnkd.in/e2E5b3wK


📌 Big Data Mock Interviews Playlist (8 videos)
https://lnkd.in/g78x9KCa

I am sure this can give you a good start.
Hello world! Serverless JavaScript with codehooks.io
Tags: javascript, node, serverless, jamstack
Published: 2022-12-02 06:39:30

Hi JavaScript coders.

We´ve launced a new service for running your JavaScript (ES6) application as a serverless API backend with [codehooks.io](https://codehooks.io).
Zero config, built-in NoSQL storage and much more.

Check out the simple Hello world example below.

First install the CLI and login/signup.
```
$ npm install codehooks -g

$ codehooks login
```

Create a project with the `codehooks create` CLI command.

```bash
$ codehooks create mybackend

$ cd mybackend
```

In the mybackend folder, create a index.js file for your JavaScript.

```js
import app from 'codehooks-js'

// create an API GET endpoint /hello
app.get('/hello', async (req, res) => {
  console.log("Look mum I'm running in the cloud");
  res.json({"message": "Hello world!"});
});

export default app.init();
```

Install your NPM dependencies.

```bash
npm i codehooks-js
```

Deploy with the CLI.

```bash
$ codehooks deploy
```

Test the new API with curl (example API key is fake).

```bash
curl https://mybackend-x23a.api.codehooks.io/dev/hello -H 'x-apikey: 6e111ea6-6b3a-412d-8f6b-061c816c67c8'
```

Example output from curl.

```bash
{"message": "Hello world!"}
```

Happy coding and deploying :)
Recalling NPM Commands to Your Heart's Content
Tags: npm, packages, development, programming
Published: 2022-12-02 06:30:40

Who doesn't love a decent package for development purposes? These packages come of so many usual and unusual variations just to match with your desired requirements. And to keep you running them we got just what you need! Enjoy the show fellow devs:

# NPM Commands

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


## npm version checking

```
npm -v
```
<br>

## To find out usages of npm

```
npm help
```
<br> 

## To find out ways of installing individual npm files

```
npm install -h
```
<br>

## To create package.json file

```
npm init
```
<br>

## To create package.json file without typing out anything else

```
npm init --yes
```
or,

```
npm init -y
```
<br>

## To set package.json defaults

```
npm config set init-author-name "name"
```
or,

```
npm set init-license "name"
```
<br>

## To install a specific package

```
npm install "package_name"
```
or,

```
npm i "package_name"
```
<br> 

## To install a specific package just for development and not for production

```
npm install "package_name" --save-dev
```
or,

```
npm i "package_name" -D
```
<br>

## To uninstall a package

```
npm uninstall "name"
```
<br>

## To install a package globally

```
npm install "package_name" -g
```
<br>

## To uninstall a package globally

```
npm uninstall "package_name" -g
```
<br>

## To list down installed packages

```
npm list
```
<br>


## To install a specific version of package

```
npm install "package_name@version"
```

```
For Example - 3.4.1, here 3 is major version, 4 is minor version and 1 is patch version number
```

<br>

## To update a specific package

```
npm install "package_name@latest"
```
<br>

## To remove any packages not listed in package.json

```
npm prune
```
Opensearch using serverless
Tags: aws, serverless, localstack, node
Published: 2022-12-02 06:23:45

Hi, I'm mocking all my AWS services on local machine, but unable to create Opensearch service domain using serverless framework with cloudformation syntax. 
If someone has any leads on it please put it in the comment section.
I've raised a question on stackoverflow but did not get any response. 
here is the [link](https://stackoverflow.com/questions/74625907/unable-to-create-opensearch-resource-using-serverless-template)
react useState() Hook (web dev simplified)
Published: 2022-12-02 06:19:16

## App.js code:

``` react
import './App.css';
import { useState } from 'react'

function App() {


  // const [count, setcount] = useState(4);
  // const [count, setcount] = useState(() => {
  //   console.log('only one time render ');
  //   return 4
  // });


  function countInitial() {
    console.log("this will run every time")
    return 4
  }
  const [count, setcount] = useState(countInitial());

  function decrementCount() {
    console.log("decrement");

    // if we write setcount two times that it simply overwrite. it wont works. 
    // setcount(count - 1);
    // setcount(count - 1);
    
    setcount((prevCount) => {
      console.log('aksh1', prevCount);
      return prevCount - 1
    });

    // setcount((prevCount) => {
    //   console.log('aksh2', prevCount);
    //   return prevCount - 1
    // });
  }


  function incrementCount() {
    setcount(aksh => aksh + 1);
  }
  return (
    <>
      {console.log("re - render")}
      <button onClick={decrementCount}> - </button>
      {count}
      <button onClick={incrementCount}> + </button>
    </>
  );
}

export default App;

```

## another part of app.js code

``` javascript
import './App.css';
import { useState } from 'react'

function App() {


  const [state, setstate] = useState({ count: 4, theme: "blue" });

  function decrementCount() {
    // setstate({count: state.count - 1})

    setstate((prevState) => {
      return {...prevState, count: prevState.count - 1}
    })
  };

  return (
    <>
      <button onClick={decrementCount}> - </button>
      {state.count} - {state.theme}
      <button> + </button>
    </>
  );
}

export default App;

```
Thank You.
You can follow us on:
[Youtube ](https://www.youtube.com/c/ULTIMATEPROGRAMMING)
[Instagram](https://www.instagram.com/full_stack_web_developer1/)
Web Developer vs Web Designer
Tags: webdev, beginners
Published: 2022-12-02 06:13:37


Web Developer vs Web Designer When diving deep into web development, you might have many questions, such as, "Is a web developer the same as a web designer?"Even I had the same experience. If you want to know more about the difference, then check this out 
{% embed https://youtu.be/bDtxF7qSofg %}
1657. Leetcode Solution in cpp
Tags: cpp
Published: 2022-12-02 05:51:21

```cpp
class Solution {
 public:
  bool closeStrings(string word1, string word2) {
    if (word1.length() != word2.length())
      return false;

    unordered_map<char, int> count1;
    unordered_map<char, int> count2;
    string s1;           // unique chars in word1
    string s2;           // unique chars in word2
    vector<int> freqs1;  // freqs of unique chars in word1
    vector<int> freqs2;  // freqs of unique chars in word2

    for (const char c : word1)
      ++count1[c];

    for (const char c : word2)
      ++count2[c];

    for (const auto& [c, freq] : count1) {
      s1 += c;
      freqs1.push_back(freq);
    }

    for (const auto& [c, freq] : count2) {
      s2 += c;
      freqs2.push_back(freq);
    }

    sort(begin(s1), end(s1));
    sort(begin(s2), end(s2));

    if (s1 != s2)
      return false;

    sort(begin(freqs1), end(freqs1));
    sort(begin(freqs2), end(freqs2));

    return freqs1 == freqs2;
  }
};
```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/determine-if-two-strings-are-close/
Loading Dot component for React Native applications
Tags: reactnative, typescript, npm, mobile
Published: 2022-12-02 05:50:10

I have been working with React Native for several years now and I have always appreciated the contributions made by the React community. I thought this would be a neat opportunity try my hand at open source development. I created a npm package that displays loading dots specifically for React Native applications. The `<LoadingDot />` component allows for customization of the following attributes:

 - Animation style
 - Animation delay
 - Quantity
 - Color
 - Size
 - Spacing

Here is how to get started:

## Installation

```sh
npm i @apolloeagle/loading-dots
```

## Usage

```javascript
import React from "react";
import { View, StyleSheet } from "react-native";
import LoadingDots from "@apolloeagle/loading-dots";

const Page = () => {
  return (
    <View style={styles.container}>
      <LoadingDots
        animation="pulse"
        dots={4}
        color="white"
        size={15}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "center",
  },
});
```
## Resources

 - For more examples: [CodeSandbox.io](https://codesandbox.io/s/apolloeagle-loading-dots-xkez8v)
 - NPM: [@apolloeagle/loading-dots](https://www.npmjs.com/package/@apolloeagle/loading-dots)
 - GitHub: [@apolloeagle/loading-dots](https://github.com/ApolloEagle/loading-dots)
 - Animations inspired by: [@nzbin/three-dots](https://github.com/nzbin/three-dots)
Unseen Progress
Tags: gamedev, godot
Published: 2022-12-02 05:43:08

Two weeks since my last update on this project. While I have been very busy outside of this side-project, I have made some notable progress! BUT, it isn't cool and flashy to look at.

I've been working hard on a web based level designer that I will use to (hopefully) create many unique levels in the game. Using Godot's interface and gdscript to manually build each level would be very time consuming. My solution was to come up with a simple JSON document that I could generate from an external tool that describes how each level will work. Over the last couple of weeks, I've built a functioning version of that tool. It isn't pretty, but since I'm the only one who will ever need to use it, it doesn't need to be.

The Room Editor lets me set the size and name of each room and upload images for the the 5 visible walls. It then generates a single PNG file as the UV map that I use as the texture for Albedo and I can modify and provide the Normal and Emission maps as well. Rooms are not going to always be distinct. There may be several rooms per level that have the same appearance.

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

The building editor lets me create new buildings by just dragging and dropping the rooms that I created in the room editor into whatever position I like. I can also add 3d props (like stairs) and set the number of students that will start in the room.

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

From there I can have the designer generate a zip file that contains that JSON file that describes each level along with the textures that were generated in the room editor and import it into my game to be parsed:

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

Now that the level designer is out of the way, maybe I can spend some time making a more visually pleasing level to demo. I also need to figure out how I want to handle the student sprites. I'm still thinking that I'll need to add an editor to the level designer just to put together some students or at least their parts and then have them randomly generated. I also had a crazy idea to pull the spritesheet from an NFT. Then I could trade/sell the NFTs and their new owners can modify them however they want. The modified spritesheets will get pulled from whatever blockchain I use and get imported into the game with the modifications that the new owner has made. I think that sounds unique and cool.. but it would make it hard to keep this a family-friendly game if there is user generated content. More to come on that!
Alert!! Operators are Functions in Javascript ??
Published: 2022-12-02 05:37:46

An operator is actually a special function that are written in your code.

Generally, operators take two parameters and return one result.

Let's look at an example.

```
var a = 3 + 4;
console.log(a); //7

```
Quite easy to guess what you will see on screen
Seven i.e. 3+4 = 7

No rocket science in this.

But 
** How did the JavaScript engine do that? **

**How did it know that this was my intent to add three and four?**

Well, code, saw the plus sign and added these two numbers.

This plus sign is an operator.

It's the addition operator and **it's actually a function** under the hood.


It would be as if I declared a function and instead of giving it the name add and instead, simply gave it the name plus.
Gave it two number and then returned.

Like

```
function +(3,4){
   //
}
```

If this was a function name, I would then put parentheses and pass three and four to it, and that would have been a normal function call like `+(3,4)` instead of `3+4`.

But this as other programming languages follow the process so does javascript. This notation is known as 'Infix Notation'.

Infix means that the function name, the operator, sits between the two parameters.

So, instead of `+(3,4)`, calling the function this way.

Say, we remove the parentheses, and the comma so, it will become `+3 4`.This is called prefix notation.

And if I put  the plus sign at the end. This is called postfix notation.

There are other operators.
Like ` - minus`,` * multiplication `,` > `, ` < `.
console.log this value.

In `4>3` or `3<4`, this is a function, a special one, because the greater than function, it accepts two numbers and returns a Boolean.

That these parameters are being passed to those functions and

a value is being returned.

And inside those functions, there is pre-written code, essentially, for you that the JavaScript language, the engine provides to do, or run, or to invoke these functions.

So, we saw that operators are functions.

Keep Coding until I next Camp !!

Cheers
🚀AWS Lambda SnapStart
Tags: awscommunitybuilders, serverless, awsreinvent, awscommunity
Published: 2022-12-02 05:32:49

🚀 AWS Lambda SnapStart:
Get upto 90% Reduction in Lambda function cold start latency at no extra cost!

If you are using AWS Lambda funcitons this will drastically reduce lambda response time at little to no effort and cost. ⚡🎉

Things to know about Lambda SnapStart:

🔷 Caching – Cached snapshots are removed after 14 days of inactivity. Lambda will automatically refresh the cache if a snapshot depends on a runtime that has been updated or patched.

🔷 Pricing – There is no extra charge for the use of Lambda SnapStart.

🔷 Feature Compatibility – You cannot use Lambda SnapStart with larger ephemeral storage, Elastic File Systems, Provisioned Concurrency, or Graviton2. In general, AWS recommend using SnapStart for your general-purpose Lambda.


Read More - https://aws.amazon.com/blogs/aws/new-accelerate-your-lambda-functions-with-lambda-snapstart/
Laravel 9 Multiple Image Upload Example
Tags: laravel9, image, upload, jquery
Published: 2022-12-02 05:30:00

In this article, we will see the laravel 9 multiple image upload example. here, we will learn multiple image uploads in laravel 9. 

Uploading multiple images in laravel 9 is not a big task if you follow the below steps then you can very easily upload images with validation. 

Also, you can validate image mime type, image size, image dimension, etc on the laravel 9 controller by using laravel validation rules. you can see upload multiple images with a preview of image in laravel 9.

So, let's see multiple image uploads in laravel 9, laravel 9 multiple image uploads with a preview.

How To Upload Multiple Images In Laravel 9

```
Step 1: Install Laravel 9

Step 2: Add Model and Migration

Step 3: Create Controller

Step 4: Create Route

Step 5: Create Blade File
```