teleren/devto huggingface dataset:
Migrating from ethers.js v5 to v6
Published: 2023-05-07 16:14:52

---
title: Migrating from ethers.js v5 to v6
published: true
description: Let's learn how to do a proper migration to the new ethers.js library version.
tags: 
# ethers
# ethereum
# ethers.js
# web3
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-07 14:28 +0000
---

## The Ether.js Library
Ethers.js is a complete and compact library focused on iteracting with EVM blockchains and the Ethereum ecosystem. It's most frequently used in Dapps, wallets and when someone wants to read or write something manually to the blockchains.
The version 6 ws released in March 23 and brought many improvements and changes over its previous version. Let's explore some differences between both versions and how to do a proper migration of your project in a safe and efficient way.

## BigInt killing BigNumber
The biggest impact change is that replacement of the class BigNumber in favor of the JS native BigInt. This removes many operations that were made using BigNumber functions by simply using the normal JS operators.

```javascript
// Big Number in version 5
value = BigNumber.from('1000')
// Sum on version 5
sum = value1.add(value2)
// Equality
isEqual = value1.eq(value2)

// BigInt in version 6
value = 1000n
// Sum, remember both values needs to be a BigInt
sum = value1 + value2
// Equality
isEqual = (value1 === value2)
```

BigInt is faster, simpler and compatible with any JS environment. The problem here is that BigInt just works with Integers. So for non-integers we use the FixedNumber class.

## ES6 Proxy Contracts
The `Contract` is a ES6 Proxy, that means that it can resolve names and methods in execution time. Its more convenient and flexible when interacting with smart contracts.

### Method Overloading
In v6 we can access overloaded methods directly by the Typescript interface.

```javascript
abi = [
  "function foo(address bar)",
  "function foo(uint160 bar)"
]
contract = new Contract(address, abi, provider)

// In v6 this will work easily
contract["foo(address)"](addr)
contract.foo(Typed.address(addr))
```

### Method Operations
Some methods inherit to contract operations are not available in the Contract direct scope anymore. Now you need the namesapce `in` to access them.

```javascript
contract.foo.in.estimateGas(args)
contract.foo.in.populateTransaction(args)
contract.foo.in.callStatics(args)
```

There are more minor improvements that are worth of studying in [ethers.js Docs](https://docs.ethers.org/v6/)
0–7 NestJS Hunter: Slaying Complexity in Node.js with TypeScript.
Tags: webdev, javascript, tutorial, programming
Published: 2023-05-07 16:05:04

## Pipes are an essential feature of NestJS, used for handling data transformation and validation in a clean and maintainable way. Pipes are classes that implement the PipeTransform interface, which requires a single method: transform(). This method takes an input value and returns a transformed value or throws an exception if the value is invalid.

![](https://cdn-images-1.medium.com/max/2000/1*oIEU9gn7RTLkMgUILN4bLQ.jpeg)

There are two primary use cases for pipes in NestJS:

* Validation: Pipes can validate incoming data, ensuring it meets specific requirements before it’s passed to a controller method. If the data is invalid, the pipe can throw an exception, which NestJS will convert into an appropriate HTTP error response.

For example, you can use the built-in ValidationPipe to automatically validate incoming data against a class-validator schema:
```typescript
    import { Controller, Post, Body, UsePipes } from '@nestjs/common';
    import { ValidationPipe } from '@nestjs/common';
    import { CreateCatDto } from './dto/create-cat.dto';
    
    @Controller('cats')
    export class CatsController {
      @Post()
      @UsePipes(ValidationPipe)
      create(@Body() createCatDto: CreateCatDto) {
        // Implementation of the create method
      }
    }
```
* Data Transformation: Pipes can transform incoming data, allowing you to modify or normalize it before it reaches a controller method. This is useful for cases like converting strings to numbers or formatting date strings.

For instance, you can create a custom pipe to parse a string into a number:
```typescript
    import { PipeTransform, Injectable, BadRequestException } from '@nestjs/common';
    
    @Injectable()
    export class ParseIntPipe implements PipeTransform {
      transform(value: string) {
        const val = parseInt(value, 10);
        if (isNaN(val)) {
          throw new BadRequestException('Validation failed');
        }
        return val;
      }
    }
```
To use this custom pipe, apply it to a controller method with the @UsePipes() decorator:
```typescript
    import { Controller, Get, Param, UsePipes } from '@nestjs/common';
    import { ParseIntPipe } from './parse-int.pipe';
    
    @Controller('cats')
    export class CatsController {
      @Get(':id')
      findOne(@Param('id', ParseIntPipe) id: number) {
        // Implementation of the findOne method
      }
    }
```
Pipes help maintain a clean and organized codebase by handling validation and transformation concerns separately from the core business logic.

Next, let’s explore the concept of interceptors in NestJS. How do interceptors work, and what are some common use cases for them in a NestJS application?

to be continued
0–6 NestJS Hunter: Slaying Complexity in Node.js with TypeScript.
Tags: webdev, javascript, beginners, programming
Published: 2023-05-07 16:02:35

## Dependency Injection (DI) is a design pattern used in NestJS to manage dependencies between classes, promoting decoupling and making it easier to test and maintain the code. In NestJS, the DI system is built around the concept of providers and tokens.

![](https://cdn-images-1.medium.com/max/2000/1*oIEU9gn7RTLkMgUILN4bLQ.jpeg)

* Providers: A provider is a class, value, or factory function responsible for creating an object that can be injected into other classes. Providers are typically registered in the providers array of a module. Here's an example of a provider class:
```typescript
    import { Injectable } from '@nestjs/common';
    
    @Injectable()
    export class CatsService {
      // Implementation of the service
    }
```

* Tokens: Tokens are unique identifiers used by NestJS to locate providers. By default, a class’s token is the class itself. When a class needs a dependency, it requests it from the DI system using a token.

* Injecting Dependencies: To inject a dependency, you can use the @Inject() decorator in the constructor of a class. The DI system will then resolve the dependency and provide an instance of the requested class. Here's an example:
```typescript
    import { Injectable, Inject } from '@nestjs/common';
    import { CatsService } from './cats.service';
    
    @Injectable()
    export class AppService {
      constructor(private readonly catsService: CatsService) {}
    }
```

In this example, the AppService class requests an instance of CatsService in its constructor. The DI system locates the CatsService provider, creates an instance, and injects it into the AppService class.

Dependency Injection in NestJS provides the following benefits:

* Decoupling: DI promotes loose coupling between classes by allowing them to depend on abstractions rather than concrete implementations. This makes it easier to modify or replace parts of the application without affecting other components.

* Testing: DI makes it simpler to test classes by allowing you to replace dependencies with mock implementations during testing.

* Reusability: By managing dependencies centrally, DI encourages the reuse of providers across multiple parts of the application.

Now that you understand Dependency Injection in NestJS, let’s discuss the role of pipes and their use cases. How can pipes help with validation and data transformation in a NestJS application?

to be continued
Using Event Bus in Vue.js 3
Tags: javascript, vue, vite, frontend
Published: 2023-05-07 16:02:31


## Introduction

In vue js we have essentially three ways of making unrelated components communicate with each other:

* Vuex
* Pinia
* Event Bus

On the [official documentation](https://v3.vuejs.org/guide/migration/events-api.html#event-bus) we can read:

*In most circumstances, using a global event bus for communicating between components is discouraged. While it is often the simplest solution in the short term, it almost invariably proves to be a maintenance headache in the long term.*

So generally in the long run it is better to use vuex.

Also in the [official documentation](https://v3.vuejs.org/guide/migration/events-api.html#_2-x-syntax) you can see how the Event Bus implementation has changed from Vue 2 to Vue 3

## Scaffolding the project

In this tutorial we will use Vite build tool to scaffold the project

    # npm 6.x
    npm init vite@latest vue-event-bus-1 --template vue
    
    # npm 7+, extra double-dash is needed:
    npm init vite@latest vue-event-bus-1 -- --template vue

then we need to install an external library implementing the event emitter interface, in this case [mitt](https://github.com/developit/mitt)

    npm install --save mitt

## The Project

The project consists of two simple components, **FirstComponent.vue** and **SecondComponent.vue**, when we click on the emit event button in **SecondComponent.vue** String to change in **FirstComponent.vue **becomes String changed thanks to the Event Bus

![](https://cdn-images-1.medium.com/max/2394/1*wf1KnHWyNklvzpbmSa3Jiw.png)

## The Code

In **main.js **we create an instance of mitt which is used globally

    import { ***createApp ***} from 'vue'
    import mitt from 'mitt'
    import App from './App.vue'
    
    
    const emitter = mitt()
    const app = ***createApp***(App)
    
    app.config.globalProperties.emitter = emitter
    app.mount('#app')

Now we can access emitter globally, so in **FirstComponent.vue** we subscribe to the event emitted by **SecondComponent.vue.**

Let’s take a look to **FirstComponent.vue**

    <script>
    export default {
      data: function () {
        return {
          testEvent: 'String to change'
        }
      },
      created (){
        this.emitter.on('my-event', (evt) => {
          this.testEvent = evt.eventContent;
        })
      }
    }
    </script>

Now in **SecondComponent.vue **let’s emit the event

    <template>
        <div style="border: 1px solid black;">
            <h1>Second Component</h1>
            <button v-on:click="emitMyEvent">Emit Event</button>
        </div>
    </template>
    
    <script>
        export default {
            methods: {
              emitMyEvent() {
                  this.emitter.emit('my-event', {'eventContent': 'String changed'})
              }
            }
        }
    </script>

## Github

You can find the code of this tutorial on github: [CertosinoLab/mediumarticles at vue-event-bus-1 (github.com)](https://github.com/CertosinoLab/mediumarticles/tree/vue-event-bus-1)

Thank you for reading!
TIL: how to disable cron for GitHub forks
Tags: todayilearned, githubactions, cron, github
Published: 2023-05-07 15:59:57

GitHub Actions has a useful feature to trigger workflows on a cron schedule. For example:

```yml
name: Test

on: 
  push:
  pull_request:
  schedule:
    - cron: "0 6 * * *" # daily at 6am

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
... 
```

But if a contributor has enabled GitHub Actions on their fork (which I recommend: test your contributions before opening a PR), it also runs the cron on their fork. This not only uses up extra CI resources on the fork:

![A list of daily GitHub Actions runs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tc2y55vsrfl3ulss4629.png)

It also sends a regular email to the contributor when the workflow fails:

![A daily email from GitHub: "hugovk/packaging.python.org Run failed: Test - main"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqdmv5m766yif5qgjols.png)

Instead, we only need to run the cron for the upstream. For example, for a `https://github.com/octocat/hello-world` repo, add:

```diff
 jobs:
   test:
+    if: ${{ github.repository_owner == 'octocat' || github.event_name != 'schedule' }}
     runs-on: ubuntu-latest
```

This only runs the `schedule` trigger for the `octocat` upstream, and all other triggers run for both upstream and forks.

## Also

For simpler workflows that only trigger on a cron, such as stalebot or CodeQL runs, we can add a simpler condition.

For example:

```yml
name: Close stale issues

on:
  schedule:
  - cron: "10 0 * * *" # daily at 12:10am

jobs:
  stale:
    runs-on: ubuntu-latest

    steps:
    - name: "Check issues"
      uses: actions/stale@v8
...
```

We can completely disable it for forks:

```diff
 jobs:
   stale:
+    if: github.repository_owner == 'octocat'
     runs-on: ubuntu-latest
```

## PS

Use single quotes in these lines, double quotes are invalid here (`Unexpected symbol`).

## Thanks

To [Alex Waygood](https://fosstodon.org/@AlexWaygood) for the tip.

To the British Library and Flickr Commons for the illustration of a [chronograph](https://www.flickr.com/photos/britishlibrary/11097061804/).
0–5 NestJS Hunter: Slaying Complexity in Node.js with TypeScript.
Tags: webdev, javascript, beginners, programming
Published: 2023-05-07 15:56:12


## Modules and decorators are fundamental concepts in NestJS that contribute to its modular architecture, helping you create well-structured and maintainable applications.

![](https://cdn-images-1.medium.com/max/2000/1*oIEU9gn7RTLkMgUILN4bLQ.jpeg)

* Modules: In NestJS, a module is a class annotated with the @Module() decorator, responsible for organizing application components such as controllers, providers, and other modules. By grouping related components together, modules make it easier to manage large applications and promote code reusability.

A typical NestJS module looks like this:
```typescript
    import { Module } from '@nestjs/common';
    import { CatsController } from './cats.controller';
    import { CatsService } from './cats.service';
    
    @Module({
      controllers: [CatsController],
      providers: [CatsService],
    })
    export class CatsModule {}
```

* Decorators: Decorators are a TypeScript feature that allows you to add metadata to classes, properties, and methods. In NestJS, decorators are used extensively to enhance classes and provide additional information to the framework. Some common decorators in NestJS include @Controller(), @Get(), @Post(), and @Inject().

For instance, a basic NestJS controller using decorators could look like this:
```typescript
    import { Controller, Get } from '@nestjs/common';
    
    @Controller('cats')
    export class CatsController {
      @Get()
      findAll() {
        return 'This action returns all cats.';
      }
    }
```

The @Controller('cats') decorator marks the CatsController class as a controller and associates it with the 'cats' route. The @Get() decorator is applied to the findAll method, indicating that it should handle HTTP GET requests.

By leveraging modules and decorators, NestJS enforces a clean, modular structure for your application, making it easier to manage, extend, and maintain.

Now, let’s explore a crucial aspect of NestJS: dependency injection. Can you explain how dependency injection works in NestJS and how it helps with decoupling and testing?

to be continued
0–4 NestJS Hunter: Slaying Complexity in Node.js with TypeScript.
Tags: webdev, javascript, beginners, programming
Published: 2023-05-07 15:54:46



## Interfaces in TypeScript are a powerful way to define contracts for the shape of objects, allowing you to enforce specific structures for objects and create reusable type definitions. They can also be used for type checking and autocompletion support in code editors.

![](https://cdn-images-1.medium.com/max/2000/1*oIEU9gn7RTLkMgUILN4bLQ.jpeg)

Here’s an example of an interface in TypeScript:
```typescript
    interface Person {
      firstName: string;
      lastName: string;
      age: number;
      greet(): string;
    }
```

This interface defines a Person object with firstName, lastName, and age properties, as well as a greet method. You can use the interface as a type for an object like this:

```typescript
    const john: Person = {
      firstName: "John",
      lastName: "Doe",
      age: 30,
      greet() {
        return `Hello, my name is ${this.firstName} ${this.lastName}.`;
      },
    };
```

If you try to create an object that doesn’t match the Person interface, TypeScript will throw a type error during compilation.

Now let’s shift our focus to NestJS. Can you explain the importance of modules and decorators in NestJS and how they contribute to the framework’s modular architecture?

to be continued
54 berufliches Vorwärtskommen: Werbung für klare Rollenverteilung in Software-Entwicklungsprojekten.
Tags: deutsch, career, discuss, management
Published: 2023-05-07 15:54:00

Moin Moin,

ich suche ab sofort Software-Entwickler, IT-Abteilungen und insbesondere dich zu gewinnen fürs klare Verteilen von Rollen in Software-Entwicklungsprojekten.

Ich denke, dass in den [letzten beiden Beiträgen→](https://dev.to/amustafa16421/53-berufliches-vorwartskommen-wie-sieht-eine-klare-rollenverteilung-in-software-entwicklungsprojekten-aus-3pii), einige Vorteile dieses Ansatzes aufgezeigt werden konnten. Zusammenfassend erwähnen möchte ich als Vorteile:
- reduzierter Stress / erhöhte Annehmlichkeit
- hohe Aufmerksamkeit durch SingleTasking
- zielführend / produktivitätssteigernd
- einfache Organisation

1) Würdest du diesen Ansatz gerne ausprobieren bzw. umsetzen? ( 5-Sterne-Skala ), 
Ausführungen willkommen.

Lasst uns mittels Kommentaren austauschen.

Beste Grüße,
Mustafa

Austausch mittels E-Mail: mustafa.kevin.dwenger@posteo.de
Betreff: Austausch
Using Coreutils in Rust
Tags: rust
Published: 2023-05-10 17:30:00

---
title: Using Coreutils in Rust
published: True
date: 2023-05-07 15:47:18 UTC
tags: rust
canonical_url: https://dlcoder.medium.com/using-coreutils-in-rust-ff5d01eae0a6
---

[![](https://cdn-images-1.medium.com/max/600/0*KaX3N1n_bXxzz-V8.png)](https://dlcoder.medium.com/using-coreutils-in-rust-ff5d01eae0a6?source=rss-93bca1b4c1e9------2)

[Continue reading on Medium »](https://dlcoder.medium.com/using-coreutils-in-rust-ff5d01eae0a6?source=rss-93bca1b4c1e9------2)
In-Game Wiki in Unity in 15 min
Tags: unity3d, gamedev
Published: 2023-05-07 15:47:10

This solution is ideal if you need a simple way to create a wiki in your game.

Solution is based on TextMesh Pro component.

The game itself is in active development, you can subscribe for updates about [what does it mean to be manager](https://mitrapunk.com) 

```
public class WikiUI : MonoBehaviour, IPointerClickHandler
{
    public TextMeshProUGUI text;

    public void OnenWikiAbout(string page)
    {
        text.text = "<line-height=125%>";

        if (page == "negotiations")
        {
            text.text += "Negotiations<br>Negotiations start when there are several opinions on the next steps. During negotiations, you and your colleagues communicate about which course to take.";
        }
        else if (page == "homepage")
        {
            text.text += "Wiki Index:<br><link=negotiations><u>Read about negotiations</u></link>";
        }
        else
        {
            text.text = "404<br>";
        }
                
        text.text += "<br><link=homepage><u>Go Home</u></link>";
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        // camera is null only if you use Screen Space Overlay, otherwise add camera reference
        int linkIndex = TMP_TextUtilities.FindIntersectingLink(text, eventData.position, null);

        if (linkIndex != -1)
        {
            TMP_LinkInfo linkInfo = text.textInfo.linkInfo[linkIndex];
            OnenWikiAbout(linkInfo.GetLinkID());
        }
    }
}
```
Verdaccio Private NPM Registry Setup
Tags: npm
Published: 2023-05-07 15:44:57

This guide will help you set up a private NPM registry using Verdaccio with Docker Compose. It also includes mounting storage and plugins directories and a custom configuration file.

## Step 1: Create Docker Compose file

Create a `docker-compose.yml` file with the following content:

```yaml
version: "3.9"

services:
  verdaccio:
    image: "verdaccio/verdaccio:5.24"
    container_name: "verdaccio"
    ports:
      - '4873:4873'
    volumes:
      - './verdaccio-storage:/verdaccio/storage'
      - './verdaccio-plugins:/verdaccio/plugins'
      - './verdaccio-config.yaml:/verdaccio/conf/config.yaml'

```

This configuration sets up a Verdaccio service using the official Verdaccio image (version 5.24). It exposes port 4873 and mounts three directories:

-   `verdaccio-storage` for storing NPM packages.
-   `verdaccio-plugins` for storing Verdaccio plugins.
-   `verdaccio-config.yaml` for providing a custom configuration.

## Step 2: Create a configuration file

Begin by initiating the container, then transfer the configuration file from within the container to the host machine. Proceed to modify the file as required.

```bash
# In the docker-compose file, comment out the configuration file mount, and then proceed to launch the container.
docker-compose up -d
docker cp verdaccio:/verdaccio/conf/config.yaml ./verdaccio-config.yaml

# Inspect the user ID and group ID utilized by the container.
# The output will resemble the following:
# uid=10001(abc) gid=10001(abc) groups=10001(abc)
docker run --rm -it verdaccio/verdaccio:5.24 id
sudo chown -R 10001:10001 ./verdaccio-storage
sudo chmod -R 770 ./verdaccio-storage

```

Prior to initiating, kindly adjust the contents of the configuration file to suit your specific requirements, for instance, by updating `max_body_size` to 100mb. Lastly, delete the comments from the mount configuration file in the docker-compose file, and proceed to restart the startup service by `docker-compose up -d`.

## Step 3: Set up Nginx reverse proxy (Optional)

Create an Nginx configuration file with the following content:

```nginx
http {
    # ...Other configuration...
    
    server {
        listen 80;
        server_name [YOUR_DOMAIN];
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl http2;
        server_name [YOUR_DOMAIN];

        ssl_certificate /path/to/ssl_certificate.crt;
        ssl_certificate_key /path/to/ssl_certificate_key.key;
        # ... Other SSL configuration ...

        location / {
            proxy_pass http://localhost:4873/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_buffering off;
            proxy_http_version 1.1;
        }
    }
}

```