teleren/devto huggingface dataset:
How to place a file generated from strapi backend js code
Tags: strapi, file, upload
Published: 2022-04-13 10:59:02

`const mime = require('mime-types'); //used to detect file's mime type
const fs = require('fs');
const rootDir = process.cwd();
const fileName = 'test.csv';
const filePath = `${rootDir}/public/uploads/${fileName}`
const stats = fs.statSync(filePath);

//uploading it directly to upload services.
await strapi.plugins.upload.services.upload.upload({
    data:{}, //mandatory declare the data(can be empty), otherwise it will give you an undefined error.
    files: {
		path: filePath, 
		name: fileName,
		type: mime.lookup(filePath), // mime type of the file
		size: stats.size,
	},
});`
[
https://forum.strapi.io/t/strapi-upload-plugin-how-to-place-a-file-generated-from-strapi-backend-js-code/3323](https://forum.strapi.io/t/strapi-upload-plugin-how-to-place-a-file-generated-from-strapi-backend-js-code/3323)
Something about HTML, CSS, JavaScript...
Tags: javascript, html, css, flatironschool
Published: 2022-04-13 10:58:44

In touching the second week of my journey at Flatiron School, I begin to believe that JavaScript has so much to give out to the world. My main goal here is to write each day about something that I learn along my journey to becoming a full-stack developer! My post will be focused on sharing and discussing my understanding of topics, concepts, or skills that I acquire. First of all, the Web has three important components and it can be made using those three HTML, CSS, and JavaScript all together. HTML is defining the content structure of the Web and CSS is to be dealt with the layouts of the Web lastly, JavaScript is to function the behavior of the Web. To put it simply in words, HTML is a bone and CSS is a skin, JavaScript is a muscle.
Meetings best practices
Tags: leadership, projectmanagement, meetings, productivityhacks
Published: 2022-04-13 10:56:19

Source: [This repo has guides for almost everything](https://github.com/thoughtbot/guides/tree/main/working-together#meeting-guidelines).

What do you think about this meeting guideline?

- Be kind: Treat each other with respect.

- Remote matters: Listen for and solicit input from remote members so their voice is heard.

- Ensure the space is set up so everyone can see each others' faces.

- Enunciate and speak loud enough so that remote members can hear you clearly.

- Introduce everyone: Don't assume everyone has met before. Introductions help break the ice and give an opportunity for voices to be heard.

- Pay Attention: Be present with others during a meeting, but also engage and communicate in the way you feel most comfortable.

- Be respectful of others' schedules: Try to start and end meetings on time.

- Step up, step back: After you speak, let others speak. If you are speaking often, make sure others have had a chance to say something.

- Apply the Shine Theory: Notice if someone is being cut off or ignored. Help shine the light back on that contributor by repeating their idea, giving clear support and credit to its source.

- Give credit: Acknowledge input from others and highlight contributors. Show encouragement and, if you agree with something, call it out. Ensure that even the quiet voices are heard and supported.

- Why am I talking?: Make sure that the thing you're about to say has not already been said. If it has and has been ignored, clarify that you are amplifying an under-recognized idea.

- One mic: Let one person speak at a time, and let them complete their full thought before responding. Don't interrupt.

- Clarify what you hear: Use phrases like "What I heard you say was..." or "My feedback for that is..."

- Speak as I: Try to speak from the I perspective. Don't speak for others.

- Disagree: You don't have to agree with everybody, but be aware of how you frame your feedback. Criticise the idea, not the person.

- Everyone can participate: Assuming someone doesn't want to participate can be exclusionary. Give people the opportunity to decline an invitation.

- Speak up: Follow up if team members treat others disrespectfully. If you don't feel comfortable addressing someone directly, speak with your manager or Chief People Officer.
Why choose reactJS for web development
Tags: react, webdev, technology
Published: 2022-04-13 10:45:20

React JS is described as an ultra-lightweight and efficient open source JavaScript library for building simple, fast and scalable frontends for web development applications.
In today's world, ReactJS is used by over 220,000 live websites. However, some industry heavyweights like Apple and Netflix have already included ReactJS navigation into their cutting-edge software creations.
Benefits

- Performance
- Usability
- Flexibility
- Speed
Why choose ReactJS for Web Development

- Easy to understand
- Customized Content
- Build rich user interface


Learn more about Reactjs For Web development [here](https://influencedigest.com/other/why-choose-reactjs-for-web-development/)
React JS vs Node JS : An Effective Comparison between two crucial Frameworks
Tags: react, node, reactvsnode, reactjsornodejs
Published: 2022-04-13 10:43:27

Both React JS and Node JS play a vital role in the Business world but in different ways. ReactJS is highly popular for its rich UI frameworks whereas NodeJS is highly preferred for its NPM support.
ReactJS and NodeJS together are a great combination for high quality solutions. 
ReactJS and NodeJS are completely distinct as one enhances the frontend while the other one enrich the backend. But one thing that both of them have in common is their ability of bringing ease and quickness in the development process. To know more- https://www.techtricksworld.com/node-js-vs-react-js/
Learn how to generate and verify signatures using ethers
Tags: javascript, react, ethereum, blockchain
Published: 2022-04-13 10:29:25

[ethers](https://www.npmjs.com/package/ethers) module provides complete Ethereum wallet implementation and utilities in JavaScript (and TypeScript).

### importing ether

```import { ethers } from "ethers"```

### Verify wallet installation

```
const isWalletInstalled = () => {
  if (!window.ethereum) {
    throw new Error("No crypto wallet found. Please install it.");
  } else {
    return true;
  }
};
```

### Request accounts
```
const requestAccount = async () => {
  if (!window.ethereum) {
    throw new Error("No crypto wallet found. Please install it.");
  }
  const accounts = await window.ethereum.send("eth_requestAccounts");
  if (accounts.result.length) {
    const account = accounts.result[0];
  }
};
```

### Using wallet to Sign a message
```
const signMessage = async (message) => {
  try {
    if (isWalletInstalled()) {
      const provider = new ethers.providers.Web3Provider(window.ethereum);
      const signer = provider.getSigner();
      const signature = await signer.signMessage(message);
      const address = await signer.getAddress();
      return {
        signature,
        address,
      };
    }
  } catch (err) {
    console.log(err);
  }
};

```

### Verify message
```
const verifyMessage = async ({ message, address, signature }) => {
  try {
    const signerAddr = await ethers.utils.verifyMessage(message, signature);
    if (signerAddr !== address) {
      return false;
    }
    return true;
  } catch (err) {
    console.log(err);
    return false;
  }
```

Credits: Artur Chmaro
[Video reference](https://www.youtube.com/watch?v=vhUjCLYlnMM)
Generate QR code using laravel 9.
Published: 2022-04-13 10:11:00

Hello Readers,

In this blog post we will see how to create QRCode in laravel 9 using `simplesoftwareio/simple-qrcode` package.

Firstly we will setup our laravel 9 project by following below steps

* Step 1 – Install Laravel 9 Application
* Step 2 – Database Configuration
* Step 3 – Installing simplesoftwareio/simple-qrcode package
* Step 4 – Configure simplesoftwareio/simple-qrcode
* Step 5 – Create QRCode Controller
* Step 6 – Add QR Code Routes
* Step 7 – Run This App on Browser

**Step 1** - create and install laravel 9 using command
```
composer create-project --prefer-dist laravel/laravel LaravelPDFGenerate
```
**Step 2** - Configure database 
```
  DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=qr_code_laravel
  DB_USERNAME=root
  DB_PASSWORD=password
```
**Step 3** - Install QRCode package using composer  
```
  composer require simplesoftwareio/simple-qrcode
```
**Step 4** - Configure `simplesoftwareio/simple-qrcode` package in config/app.php file

Open **config/app.php** file and add below line in **providers**.

`SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class`

and add below line in **aliases**.

`QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class`	

**Step 5** - To create QRCode controller run command

`php artisan make:controller QRCode/QRCodeController`

**Step 6** - Create routes, open `web.php` file and add routes

```
  Route::get('qr-code', [QRCodeController::class, 'index']);
  Route::get('qr-code-colored', [QRCodeController::class, 
  'colorQrCodeIndex']);
```

Now we have successfully setup our project, the next step is to write a code to generate QRCode.   Open Controller and we add below code

```
    public function index()
    {
       return QrCode::size(200)->generate('My first QR 
 Code');
    }
    public function colorQrCodeIndex()
    {
      return QrCode::size(100)
               ->backgroundColor(255,255,10)
               ->generate('Example of Colored QR code');
    }
```

- **size()** - is used to define the size of the QR Code
- **generate()** method - hold the message, address, price, phone etc for which we are generating QR code.
- **background()** - used to give background colour to our QR.   

**Step 7** - Run the development server by running `php artisan serve` command and visit the browser to see your QR code.  

`http://127.0.0.1:8000/qr-code-colored` - for coloured QR
`http://127.0.0.1:8000/qr-code` - for simple QR


Happy Reading…
:unicorn: :heart:
How MetaMask Creates Accounts
Tags: web3, ethereum, metamask, blockchain
Published: 2022-04-13 10:03:56

## How MetaMask Creates Accounts

1. when you install MetaMask, you were shown a list of 12 words known as the Secret Recovery Phrase.
   - Note: The order of the words in the secret recovery  phrase is important.
   - MetaMask uses a specification known as the BIP39 to generate these 12 words. 
   - BIP39(Bitcoin Improvement Proposals) recommends use of a mnemonic phrase to recover accounts in the event your accounts are compromised or lost.MetaMask calls this mnemonic phrase as the Secret Recovery Phrase.
   - 12 words are chosen from a list of 2048 words.The complete list of 2048 words can be found from [here](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt)

2. Each word in the secret recovery phrase has a number associated with it. These numbers are used to form a seed integer, which is then used to create a set of public/private keys


![seed integer generation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b571rrf6opsi78huknqk.png)

###Generating the public/private key pair and the Ethereum address using seed interger
1. a private key is generated using the seed integer using the [SHA256](https://emn178.github.io/online-tools/sha256.html) hash function
2. public key is generated from private key using ECDSA(Elliptic Curve Signature) algorithm
3. from the public key derived, compute a keccak256 hash
4. from the keccak256 hash, take the last 20 bytes (which is 40 hexadecimals), prefix it with “0x” and this is your Ethereum address.

- [Eth graphical address](https://www.royalfork.org/2017/12/10/eth-graphical-address/?ref=hackernoon.com)

### Creating the Default Account
1. With the public/private key pair created from the seed integer, MetaMask will now be able to create your first account.As explained, your first account is generated from the keccak256 hash.

2. Internally, MetaMask encrypts your private key using the password that you supplied during the installation stage, and stores it in your browser’s data store. It does not store them on the cloud.


![where do Metamask stores key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s53bt1wia6bawyau2h3.png)

### Creating Additional Accounts
1. MetaMask makes use of the private key of the first account and hashes it to get the next private key.Using the newly created private key, the same procedure applies (as described earlier) to get the public key and subsequently the account address. And the next account is always the hash of the previous private key.

![Multiple accounts from private key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srmy20zltc33rug4c85o.png)
Note: 
- This is the reason why your accounts can be recovered as long as you have your secret recovery phrase. 
- And this brings us to this very important point you have to know — protect your secret recovery phrase under lock and key! - Once you compromised your secret recovery phrase, your accounts can be accessed by anyone who has them. Needless to say, your cryptocurrencies will be gone in a heartbeat!

Credits: [Wei-Meng Lee](https://weimenglee.medium.com/)
Developer Here ?
Tags: javascript, php, webdev, design
Published: 2022-04-13 09:57:57

Hi to Everyone. 
I need to know if someone here can create a tool for me with PHP, HTML, CSS, and JavaScript. I shall be very thankful. Also, I have to embed the tool in the website which is already live. Thanks in Advance. This is the website.
[Coolest and Eye-Catching Longboards for Men and Women](https://boardsontop.com).
High Level Science Of Cryptocurrency
Tags: web3, blockchain, crypto, bitcoin
Published: 2022-04-13 09:49:13

First, I want to thank Patrick McCorry for making all of this knowledge available to myself and others.

Second, I'd like to assert that I'm writing from a Bitcoin and Ethereum paradigm.

## Overview

We'll be looking at cryptocurrencies from the perspective of three different computer science topics. The three topics will be (1) Data Structures and A Cryptographic Audit Trail, (2) Distributed Systems and Global Consensus, and (3) Applications.

## (1) Data Structures and A Cryptographic Audit Trail

**Q:** What if there was a data structure to let someone re-compute an entire database from scratch and then compare it with others to verify its validity?
**A:** The data structure that makes this possible is the blockchain. The blockchain is a cryptographic audit trail that will allow anyone to re-compute the same database by verifying a sequence of transactions.

**Q:** How can one be sure they've re-computed the correct database (blockchain) on their local system?
**A:** The re-computation of "the" blockchain passed to us from a peer on "the" network alone doesn't guarantee that we've actually re-computed the "right" one- the one "everyone else" is using. That's where the idea of a distributed system and global consensus comes into play.

## (2) Distributed Systems and Global Consensus

**Q:** What is a consensus protocol?
**A:** A set of computers that want to reach an agreement about a data item. You can imagine a set of questions (data) being propagated (bounced around) throughout a set of computers and then filtered through the protocol (rules) until there's a final decision made (true/false) on each question (data item).

**Q:** What is safety compared to liveness, and why are these terms relevant when it comes to a blockchain's consensus protocol?
**A:** In a centralized network, the focus is on safety; where as in a decentralized network, it's usually on liveness. Safety is based on "nothing bad should ever happen"; where as liveness is based on "something good happening eventually". No consensus protocol can guarantee both simultaneously. Networks based on safety are usually closed off from the public- requiring 2/3 nodes to be online; where as networks based on liveness are usually open to the public- requiring at least 1 node to be online.

## (3) Applications

Ultimately what we get from a blockchain is a public consistent view for all parties; which have lead to applications that enable peer-to-peer electronic cash, smart-contracts, and the array of possibilities that come with smart-contracts such as auctions without auctioneers, voting without tallying authorities, gambling without casinos, and etc..

## Conclusion

At a very high level, when it comes to cryptocurrency, we've covered (1) Data Structures and A Cryptographic Audit Trail, (2) Distributed Systems and Global Consensus, and (3) Applications.

_If you have any questions or suggestions, then please leave them in the comment section below._
Do I overestimate my abilities?
Tags: discuss, webdev, node, help
Published: 2022-04-13 09:47:46

Hello, everyone. Today I decided to challenge myself and build an entire e-commerce web app with the MERN stack (which is the one I'm the most comfortable with).The web app will be a full-fledged e-Commerce platform with features such as multiple user roles (client, store manager, and admin), each with their own dashboard interface, and a fully responsive front-end (I hope lol).

I will use as few libraries as possible and bare vanilla CSS (yes, you read it right). The reason? I'm attempting to overcome the impostor syndrome and improve my skills while building a project that might be relevant to put in a portfolio and maybe get a job as a university drop-out (cause yeah, I couldn't find a job with the projects I did until now).

Has anyone completed a similar project while working alone? Does it seem doable considering i will not be watching any tutorial ?

Please let me know what you think in the comments and maybe share your experience or a few tips with me.
Complete guide to deploying SSR Vite apps on AWS with automation
Tags: aws, vue, ssr, automation
Published: 2022-04-13 09:09:46

Want to learn how to deploy the Server-side rendering(SSR) Vite app on [AWS](https://blog.canopas.com/sending-email-using-aws-simple-mail-service-ses-and-static-templates-with-golang-fa3b36da7230)?

In this blog, we will see how to deploy the SSR Vite app on AWS and automate the deployment process. Though this article refers to only the Vite app, it works for almost all SSR apps.

This blog will answer many of your questions. Like...

What is SSR?

How does the SSR app deployment work?

How do you implement SSR for SEO and loading time optimizations?

You will learn how to deploy the SSR app on [AWS using](https://blog.canopas.com/custom-php-runtime-layer-in-aws-lambda-functions-fee0e71c7097) the following services.

ECS (Elastic container service)

ECR (Elastic container registry)

ELB (Elastic load balancer)

Cloudformation

Github actions to automate deployment

We will create an [AWS cloudformation stack](https://blog.canopas.com/send-mails-using-ruby-on-rails-action-mailer-and-aws-sdk-ses-gem-without-using-smtp-67fac83e0455), that contains all required resources to deploy the app, and it will be automated by [Github](https://github.com/canopas/canopas-website/tree/master/vue-frontend) actions.

You can read full article here [https://blog.canopas.com/complete-guide-to-deploying-ssr-vite-apps-on-aws-with-automation-27676113d6ac](https://blog.canopas.com/complete-guide-to-deploying-ssr-vite-apps-on-aws-with-automation-27676113d6ac)
Wednesday Links - Edition 2022-04-13
Tags: java, jvm, testcontainers, architecture
Published: 2022-04-13 08:52:44

In defense of simple architectures (8 min)🛡️
https://danluu.com/simple-architectures

JEP 425: Virtual Threads Preview (30 min)🧵
https://openjdk.java.net/jeps/425

IntelliJ IDEA 2022.1 Is Out (8 min)🎉
https://blog.jetbrains.com/idea/2022/04/intellij-idea-2022-1

New milestone, new look, new release, same Testcontainers! (7 min)🎉
https://www.atomicjar.com/2022/04/new-milestone-new-look-new-release-same-testcontainers

CRDT: Conflict-free Replicated Data Type guest: Martin Kleppmann (4 min)💣
https://nurkiewicz.com/70

ArchUnit: Forget Architecture, It’s a Flexible and Intelligent Linter (6 min)🏛️
https://medium.com/nexocode/archunit-forget-architecture-its-a-flexible-and-intelligent-linter-fd3c35f622db
[Chad Tip] Find a string fast in your project (with grep/ no IDE)
Tags: bash, finder, webdev, chad
Published: 2022-04-13 08:51:00

## Most extreme scenario

**Doomer**(Sitting at his desk):

_I know I've already wrote a function like_ _this. But can't remember in which file!!_

_I will have to open each potential file and seek for the line._
_If this becomes recurrent, at this rate, I will hit the deadline soon._
_I am an incompetent._ 
_I bet my girlfriend is cheating on me._
_This distro sucks._
_I need to smoke a cigarette._

**Chad**(Coming from the sky):

_I was just like you before! Let me help you!_

## Usage

```sh
ou <insert your text>
```

## Example

You need to find where you used a function but your IDE stinks.

Type this in your terminal.

```sh
ou aggregate
```
It will find all occurrence of "aggregate" 

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

"ou" means where in french but can be whatever alias you want

## Reasons

A fuzzy finder is the search bar that browse through file name or file content when usually pressing (Ctrl-P, Ctrl-F...) in your IDE.

Why not using **vscode** finder?
I only have a AMD4700 CPU with 12 threads so it won't retrieve the code until the next day!

Why not using **VIM** finder?
I don't want to supercharge nvim/spacevim finder to browse through text.

## Install

Beware !
You can only use it if you master the CLI.
For power users and very advanced linux users only.
I use arch btw.

It's nothing more than a "grep" with multiple arguments.

Just put this in your .bashrc , .zshrc or wherever you may source your aliases.

```sh
# .zshrc
alias ou="grep -rn --exclude=\*.{png,jpg,lock,log} --exclude-dir={.git,node_modules,dist,build}"
```
grep options:
r -> recursive
n -> print line number

If you've been through all these steps you may be kind of a genius yourself.

Congrats.
Never loose hope.
Everyone has a chad in themselves.🙏
Restrain the Rate of Requests with Throttling in Django
Tags: django, python, api
Published: 2022-04-13 08:28:01

If the server is working and the server application is running, there is no way a request can't be executed by the server and not return a response or an error. 

However, there may be times when you want to regulate the number of requests on a specific endpoint. 

## Problem

You have a special endpoint for SMS verification when a password change request is made. Sounds nice, huh? Until you have a **special user** who will click on the button to request the SMS 10 times and the requests will be executed. That means 9 costly SMS were billed. 

Not great! We want a way to only allow the next SMS requested after 1 minute. How to do it in Django?

## Solution

We'll use throttling. It's similar to permissions in a way it determines if a request should be allowed. But it's used to indicate a temporary state and is used to control the rate of requests that clients can make to an API.

Let's say you have the SMS viewset that is registered in the routers.py file like this.

```python
class SMSViewSet(viewsets.ViewSet):
    http_method_names = ("post",)

...
router.register(r"password", viewsets.SMSViewSet, basename="password")
```

Before configuring, we need to add a new attribute to the `SMSViewSet` class called `throttle_scope`. 

```python
class SMSViewSet(viewsets.ViewSet):
    http_method_names = ("post",)
    throttle_scope = "password-reset"
...
```

And finally, in the `REST_FRAMEWORK` configuration in the `settings.py` file, add the `DEFAULT_THROTTLE_CLASSES` and the `DEFAULT_THROTTLE_RATES` settings.

```python
REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_CLASSES': [
        'rest_framework.throttling.ScopedRateThrottle',
    ],
    'DEFAULT_THROTTLE_RATES': {
        'password-reset': '1/minute',
    }
}
``` 

Following the documentation, The `ScopedRateThrottle` class can be used to restrict access to specific parts of the API. This throttle will only be applied if the view that is being accessed includes a `.throttle_scope` property.

You can learn more about throttling [here](https://www.django-rest-framework.org/api-guide/throttling/).

*Article posted using [bloggu.io](https://bloggu.io). Try it for free.*