teleren/devto huggingface dataset:
Troubleshooting: replacement fee too low
Tags: troubleshooting, blockchain, ethereum, solidity
Published: 2022-12-24 11:28:37

## Symptom

Calling a contract method returns the following error message:

```
Error: replacement fee too low (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":109,\"error\":{\"code\":-32000,\"message\":\"replacement transaction underpriced\"}}","error":{"code":-32000},"requestBody":"{\"method\":\"eth_sendRawTransaction\",\"params\":[\"... \"],\"id\":109,\"jsonrpc\":\"2.0\"}", "requestMethod": "POST", "url":"..."} , method="sendTransaction", transaction="..." , code=REPLACEMENT_UNDERPRICED, version=providers/5.5.2)
    at Logger.makeError (... /node_modules/@ethersproject/logger/lib/index.js:199:1)
    at Logger.throwError (... /node_modules/@ethersproject/logger/lib/index.js:208:1)
    at checkError (... /node_modules/@ethersproject/providers/lib/json-rpc-provider.js:111:1)
    at InfuraProvider.<anonymous> (... ) /node_modules/@ethersproject/providers/lib/json-rpc-provider.js:659:1)
    at step (... /node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:1)
    at Object.throw (... /node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:1)
    at rejected (... ) /node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
```

## Cause

This error message has included a clear reason already: **replacement fee too low**. But, what does it mean? To a new comer of Ethereum, it is confusing.

In short, it implies you are sending two txes with the same nonce but the gas prices in these two txes are almost the same. At least, there are no big difference between two.

There are two possible reasons for this:

- The same account are submitting two txes within a short period of time, which results in the same nonce being used for these two txes. Of course, the gas prices in these two won't be changed too much.
- The price was set incorrectly when a tx was being cancelled or accelerated.

You can find more details in [this ethers github issue](https://github.com/ethers-io/ethers.js/issues/444).

## Solution

One simple solution is to slow down the speed of sending tx and submit a tx after the previous tx is confirmed. 

```ts
const tx = await contract.writeMethod(...) ;
await tx.wait();
```

Another is to set a reasonable gas price when you plan to cancel or speed up a tx.
Customizing chrome dev tools as we customize our code editor
Tags: webdev, vscode, programming, javascript
Published: 2022-12-24 11:25:30


The Chrome Developer Tools, or DevTools for short, are powerful tools for web developers that allow you to inspect, debug, and modify the front end of your website or web application. While the DevTools are essential tools for any developer, they can also be customized to fit your personal style and preferences.
One way to customize the DevTools is by using Chrome theme extensions. These extensions allow you to change the look and feel of the DevTools by applying custom themes and styles. In this article, we'll show you how to make your DevTools look cool by using Chrome theme extensions.
Step 1: Install a Chrome theme extension
The first step to customizing your DevTools with a theme is to install a Chrome theme extension. There are many theme extensions available on the Chrome Web Store, so you'll have plenty of options to choose from. But I will prefer 
“Material DevTools Theme Collection” because in this extension you will get plenty of themes in one place.
To install a theme extension, follow these steps:
Open the Chrome Web Store and search for "Material DevTools Theme Collection".
Click the "Add to Chrome" button to install the theme extension.
A pop-up window will appear, asking you to confirm the installation. Click "Add extension" to continue.
Step 2: Enable the theme in the DevTools
Once you've installed a theme extension, you'll need to enable it in the DevTools to apply the theme. Here's how to do it:
Open the DevTools by right-clicking on any page and selecting "Inspect" or by pressing F12 on your keyboard.
Click the "Settings" icon in the top-right corner of the DevTools window.
In the left-hand menu, click “preferences” and then click on "Themes", a dropdown will appear to you promptly.
In the "Theme" dropdown, select "Dark" because it is mandatory no matter which theme you use.
Step 3: Once you have finished all the steps now you just need to select your favorite theme. For that -
Click on the extension's icon in the Chrome toolbar and select the “Material DevTools Theme Collection” extension, and a nice pop-up will appear to you.
From the pop-up click on the “Selected theme” option and choose your favorite theme.
Lastly, reopen your browser to affect those changes to your browser.
Step 4: Enjoy your new, cool-looking DevTools!
That's it! Once you've installed and enabled a theme extension, and customized the theme to your liking, you can enjoy your new, cool-looking DevTools.
Conclusion
Customizing the DevTools with a theme extension is a quick and easy way to make them more visually appealing and personalize your workflow. Whether you prefer a dark theme, a light theme, or something in between, there's a theme extension for you. So give it a try and see how it can enhance your developer experience!
React Date Range Picker
Tags: react, daterange, beginners, javascript
Published: 2022-12-24 11:13:03

Adding date range picker is an essential part of web applications when it comes to making a date selection or developing any kind of calendar component.
Today, we will try to explore the react 'react-date-range' package which is a handy react date library that allows us to choose date and date ranges.

Let's begin by installing the above mentioned package in our react app:

```js
npm install --save react-date-range
```

Please note that the above package will expect the date-fns dependency in order to calculate days so we need to install the following also:
```
npm install --save react date-fns
```

After the necessary installations, create a separate component where you can add the date range code.

Following are the imports that will be required in our react-component:
```js
import React, { useState } from "react";
import { addDays } from "date-fns";
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import { DateRangePicker } from 'react-date-range';
```

Now, we will use react useState hook to define the start_date, end_date and the key (selection of the dates)

```js
  const [state, setState] = useState([
    {
      startDate: new Date(),
      endDate: addDays(new Date(), 7),
      key: "selection",
    },
  ]);
```
Please note that we will use the addDays dependency to specify the start_date and end_date.
Now we can call DateRangePicker Component in the following manner:
```js
<DateRangePicker
        onChange={(item) => setState([item.selection])}
        showSelectionPreview={true}
        moveRangeOnFirstSelection={false}
        months={2}
        ranges={state}
        direction="horizontal"
      />
```

This will show a nice daterange selection on our web page which is useful in multiple scenarios.
Complete code for this component is shown below:
```js
import React, { useState } from "react";
import { addDays } from "date-fns";
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import { DateRangePicker } from 'react-date-range';

const DateRange = () => {
  const [state, setState] = useState([
    {
      startDate: new Date(),
      endDate: addDays(new Date(), 7),
      key: "selection",
    },
  ]);

  return (
    <div>
      <h1>Safe Travels Co</h1>
      <h2>Book Your Flight below</h2>
      <DateRangePicker
        onChange={(item) => setState([item.selection])}
        showSelectionPreview={true}
        moveRangeOnFirstSelection={false}
        months={2}
        ranges={state}
        direction="horizontal"
      />
      ;
    </div>
  );
};

export default DateRange;

```


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

Hope you guys enjoy reading the above article.
Happy coding...
Cara Format Flashdisk Lewat Terminal Linux
Tags: linux
Published: 2022-12-24 11:03:53

1. Ketikan command `df -h`
2. Cek dimana lokasi flashdisk tersebut, misalnya /dev/sdb1
3. Kemudian, umount flashdisk tersebut dengan comman `sudo umount /dev/sdb1`
4. Lalu lakukan format, `sudo mkfs.vfat /dev/sdb1`

Untuk tipe formatnya bisa diganti dengan lainya selain FAT.
Bypassing Realme App Lock
Published: 2022-12-24 10:57:49

If you have set app lock on your Realme, Oppo or Oneplus device and forgot the privacy password (app lock password) then this is for you.

First try to reset the password using the methods mentioned in [realme website](https://www.realme.com/in/support/kw/doc/2060708). If any of them works then great, else read the below.

You need a laptop to do this. First connect your device to laptop through adb by following [this](https://www.androidpolice.com/install-and-use-adb-on-windows-mac-linux-android-chromebooks-browser/). 

Also Disable Permission Monitoring from developer settings in Phone.

Then you can run this commands to bypass.

```
adb shell pm disable-user -k com.oplus.safecenter
adb shell pm clear com.oplus.safecenter
```

Now try to open the app that you locked. If that didn't open, try using a different launcher. It will open
Which is the Best programming language
Tags: javascript, python, programming
Published: 2022-12-24 10:55:46


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ybnmwjx7hi0tgv92tqd.jpeg)It is difficult to determine a "best" programming language, as the choice of language often depends on the specific needs and goals of the project or task at hand. Here are a few factors to consider when choosing a programming language:

**The type of project:** Different programming languages are better suited to different types of projects. For example, Python is a popular choice for data science and machine learning projects, while C++ is often used for low-level system programming and video game development.

**The target platform:** The programming language you choose may depend on the platform you are targeting, such as a specific operating system or a web browser.

**The desired features:** Different programming languages offer different features and capabilities. For example, some languages are designed to be easy to learn and use, while others are more powerful and efficient.

**The availability of resources and support:** The community of developers and the availability of resources and documentation can be important factors when choosing a programming language.

Overall, it is important to consider the specific needs and goals of your project when choosing a programming language. There is no "one size fits all" solution, and the best language for you may depend on your unique needs and goals.
Challenges Beginners face when learning to Code
Published: 2022-12-24 10:52:05


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a76v1d1vofz12xu7e89k.jpeg)There are a number of challenges that beginners may face when learning to code, including:

**Syntax:** One of the most basic, but also most challenging aspects of coding is learning the syntax of the programming language. Syntax refers to the specific rules and conventions that govern the structure of a program, and even small errors in syntax can cause a program to fail.

**Debugging: **Another common challenge for beginners is debugging their code. This involves finding and fixing errors or "bugs" in a program. Debugging can be time-consuming and frustrating, and it requires a methodical and systematic approach to problem-solving.

**Understanding concepts: **Coding involves learning and understanding a wide range of concepts and technical terms, such as variables, functions, loops, and data structures. This can be overwhelming for beginners and may require a lot of study and practice to fully grasp.

**Time management:** Coding can be a time-consuming activity, and it's important for beginners to learn how to manage their time effectively. This includes setting goals, breaking tasks down into smaller, more manageable chunks, and finding a balance between learning and practicing.

**Motivation:** Learning to code can be challenging, and it's important for beginners to stay motivated and focused on their goals. This may require setting aside dedicated time for learning, seeking out resources and support, and staying positive and resilient when facing challenges.

Overall, learning to code is a challenging but rewarding 
process that requires persistence, determination, and a willingness to learn and grow. With the right mindset and resources, anyone can learn to code and achieve their goals.
How to Install PostgreSQL database on Ubuntu: A step-by-step guide
Tags: postgres, database, ubuntu, devops
Published: 2022-12-24 10:38:23

In this blog I will demonstrate how to install PostgreSQL database on Ubuntu.

`Step #1:` List the Postgres related packages that already installed

```
dpkg -l | grep postgres
```

For example:

```
 dpkg -l | grep postgres
ii  postgresql-12                              12.12-0ubuntu0.20.04.1              amd64        object-relational SQL database, version 12 server
ii  postgresql-client-12                       12.12-0ubuntu0.20.04.1              amd64        front-end programs for PostgreSQL 12
ii  postgresql-client-common                   214ubuntu0.1                        all          manager for multiple PostgreSQL client versions
ii  postgresql-common                          214ubuntu0.1                        all          PostgreSQL database-cluster manager
```

`Step #2:` In case some packages are not needed run the "sudo apt-get --purge remove ..." command to purge them:

For example:

```
sudo apt-get --purge remove postgresql-12 postgresql-client-12
```

`Step #3:` Create the file repository configuration:

```
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
```

`Step #4:` Import the repository signing key:

```
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
```

`Step #5:` Update the package lists:

```
sudo apt update
```

`Step #6:` Install the latest version of PostgreSQL:

```
sudo apt install postgresql postgresql-client -y
```

`Step #7:` If you want a specific version, use 'postgresql-13' or similar instead of 'postgresql':

```
sudo apt install postgresql-13 postgresql-client-13 -y
```

`Step #8:` Check status

```
sudo systemctl status postgresql
```

`Step #9:` Check PostgreSQL client version

```
psql --version
```

For example:

```
dmi@dmi-VirtualBox:~$ psql --version
psql (PostgreSQL) 13.9 (Ubuntu 13.9-1.pgdg20.04+1)
dmi@dmi-VirtualBox:~$
```

`Step #10:` Check PostgreSQL Server version

```
sudo -u postgres psql
postgres=# select version();
```

For example:

```
postgres=# select version();

                                                              version                                                          
-----------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 13.9 (Ubuntu 13.9-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit
(1 row)
```
How to get an Internship if you are not from a good college
Tags: webdev, beginners, career, codenewbie
Published: 2022-12-24 10:31:00

If you are in your final year or you are learning some new technologies like Web development ,Data Science , Machine Learning etc you will be looking for Internship. But getting internship is not so much easy .In this article I will share my story of despite not being from a good college how I got my first Internship.Like you, I also used to apply in many Internships but was not getting responses from companies . What I learn from my experience is many things matter to get an Internship in India. So first you should select a platform to apply for the Internship like Linkedin, Internshala. Personally, I like Internshala . First, you have to be good in any one field. You don’t have to be good in many fields but you should master a specialized field and try to apply to these companies which are looking for that person. Other things that matter are you should have a good resume where your project, GitHub profile link should mention. Also, try to write a brief summary about yourself and what you are expecting from the company . After applying don’t sit back and relax but try to message them on different platforms that you have applied for their companies. And if you get a response from the company and they gave some tasks try to do that accurately and be prepared for the interview, Try to learn about their company also. I wish you all the best. Follow me for more articles like this.
Polymorphism Deep Dive: Single vs Double Dispatch
Published: 2022-12-24 10:23:21

Runtime polymorphism or dynamic method dispatch is a feature of object-oriented programming languages that allows a subclass or derived class to provide a different implementation for a method that is already defined in its superclass or base class. This is achieved by creating a method with the same name and signature in the derived class as in the base class, and then replacing or “overriding” the implementation of the method in the derived class.

At runtime, when an object of the derived class is created and a method is called on it, the object will execute the overridden version of the method rather than the one inherited from the base class. This allows the derived class to customize the behavior of the method to suit its own needs, while still maintaining the same interface as the base class.

For example, consider a base class called “Shape” that has a method called “area” that calculates the area of the shape. A derived class called “Rectangle” might override the “area” method to provide its own implementation that calculates the area of a rectangle using the length and width of the rectangle. When an object of the “Rectangle” class is created and the “area” method is called on it, the object will execute the overridden version of the method, which calculates the area of a rectangle.

In this way, runtime polymorphism allows an object to behave differently based on its type, even if the object is referred to through a base class reference. This can be useful for creating more flexible and reusable code, as it allows different types of objects to be used interchangeably without the need to write separate code for each type.

Read the full article here ...
[Polymorphism - Md Asiful Haque](https://asifulhaque.com/polymorphism-deep-dive-single-double-and-multiple-dispatch/)
Reescrever texto e machine learning. Ferramentas para copywriters.
Tags: reescrever, reescrevertexto, rewrite, rewritetext
Published: 2022-12-24 10:16:31

Reescrever texto e machine learning. Ferramentas para copywriters.

Há algum tempo atrás, eu estava fazendo uma pesquisa sobre técnicas de [reescrita de texto](https://redatudo.online/reescrever-texto/) e, embora existam muitos recursos úteis por aí, eu não consegui encontrar nada que realmente se aprofundasse no assunto. Então, resolvi escrever este artigo para compartilhar algumas das minhas descobertas.

Existem muitas ferramentas disponíveis para ajudar os copywriters a melhorar seu texto, mas eu gostaria de focar especificamente em uma: [REDATUDO](https://redatudo.online).

[REDATUDO](https://redatudo.online) é uma ferramenta que analisa o texto e o “reescreve”, usando uma série de algoritmos. Ele pode ajudar a identificar erros de gramática, sugerir substituições de palavras e até mesmo reescrever frases inteiras para melhorar o fluxo do texto.

E pra isso, [REDATUDO](https://redatudo.online) utiliza machine learning, um campo da inteligência artificial que se concentra na criação de sistemas que podem aprender e se adaptar à medida que novos dados são introduzidos. Isso significa que, com o tempo, um sistema de machine learning pode se tornar cada vez melhor em [reescrever textos](https://redatudo.online/reescrever-texto/), à medida que ele aprende com novos exemplos.

Uma das principais vantagens do machine learning é que ele pode analisar um texto com muito mais detalhes do que um humano jamais poderia. Isso significa que, com o tempo, um sistema de machine learning pode se tornar cada vez melhor em [reescrever textos](https://redatudo.online/reescrever-texto/), à medida que ele aprende com novos exemplos.

No entanto, é importante notar que o machine learning ainda está em sua infância e, como tal, ainda há muito a ser feito para melhorar a precisão desses sistemas. Enquanto isso acontece, os copywriters ainda precisam fazer a sua parte, prestando atenção aos detalhes do texto e fazendo as edições necessárias.

No final, é importante lembrar que a reescrita de texto é uma ferramenta poderosa, mas não é a única. Existem muitas outras técnicas que podem ser usadas para melhorar o texto, como a edição, a revisão e a leitura contínua. Todas essas técnicas têm seu lugar e devem ser usadas de acordo com as necessidades de cada texto.
How to clone your own voice?
Published: 2022-12-24 10:07:56


Would you like to clone your own voice ? 
You can learn to do that using Python and wondaful Python library named “TorToiSe”.

So, in this tutorial we will record your voice , and than we can use any text to create a new sample of your voice

The link for the video tutorial is here : [https://youtu.be/zrZ4efCkaxI]
I also shared the Python instructions to my Github repo in the video description.

Moreover I recommend this book for deep learning based on Tensorflow and Keras : [https://amzn.to/3STWZ2N]


Enjoy
Eran

#Python #Cnn #TensorFlow #deeplearning
Typescript WTF Moments 11: Function Unions: any Param Is Not any
Tags: webdev, javascript, typescript, programming
Published: 2022-12-24 09:20:19

---
series: Typescript WTF Moments 
---

observe the code below
```ts
type A = ((v: true) => void) | ((v: false) => void)

const abc: A = (v) => { }
//              ^?
abc(1)
//^?
```
[playground](https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UAUSBuAuKwBOBXCAlAgHxSoD2AlgCZEA+yamAZgIYA2AzoSWVbQCgBAY3IA7TsCisARsMxxEaIvFIBvKAF8BAeh1QDho0YB6AfgGzhSAIwFdO80A)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2rk2kwtzcyeh0x6jwm8.png)

notice that the type of the parameter when you declare it, is different from the type of the parameter when you call it

We know that when we union 2 function types
```ts
type A<B,C,D,E> = ((v:B)=>C) | ((v:D)=>E)
```
is equivalent to
```ts
type A<B,C,D,E> = (v:B & D)=> (C|E)
```

so the type of the first code should be
```ts
type A = (v: true & false) => void
```
since `true & false` is `never`, the type when we call it is the correct type

so what is happening to the declaration type?

turn out this is because TS fails to infer the type at this point, which is why it returns the `any` type(TS seem to use `any` type for problematic situations)

so it is still safe? 

It is, because we will know the real type when we try to call it, but it could be misleading and this is the thing you need to keep in mind when using TS
Audio and Video Tag HTML
Tags: webdev
Published: 2022-12-24 08:58:39

Whenever we visit any web site some time we see a video or audio like music and all is play there. and that video is not available on You-tube. so uses of audio and video tag when we want to add some video content or audio we use Audio video tag.
syntax of Audio and Video tag is ;
`<audio src="____">audio</audio>
<video src="___">video</video>`
this will show video or audio on our page.
To control video we can also add attributes like 
-control
-height 
-width 
-loop
-Autoplay 
Why we should use attributes ?
because to make out page more responsive 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plbgfjy75lsyqazn7sja.png)