teleren/devto huggingface dataset:
Corporate Social Responsibility (CSR) form enhances corporate compliance, aids government monitoring
Tags: csr, corporategovernance, socialresponsibility
Published: 2022-02-22 12:40:58


Experts say while there is a huge increase in the compliance burden with the introduction of the Ministry of Corporate Affairs' extensive reporting format for accounting for corporate social responsibility (CSR), these changes will enable the government to create an extensive database of CSR activities in the country.
Ankit Singhi, partner at Corporate Professionals, stated, "The government is aware of the amount spent on corporate social responsibility, but now it can gain insight into where, how and where this money is being used."

In the Corporate India report, the government mandated that companies provide details of their CSR expenditure in the last three financial years, and details of their current projects. The new form notified by the MCA on February 11 will require companies to provide details of their CSR expenditure in the three preceding financial years.

The ministry of corporate affairs can use this additional information to draft effective CSR policies, according to experts. The focus on CSR spends has intensified over the past few years, and this mandate appears to be another step in that direction. "While it will add some compliance burden on corporations, it will improve transparency and disclosure around CSR activities as well as provide better oversight," said Pratiq Shah, partner at Deloitte India.

Besides the Form AOC-4 for filing a company's financial statement with the Registrar of Companies, companies will also have to file the new CSR-2 for the preceding financial year (2020-21) by March 31, 2022. These disclosures are also required as part of the annual reports the MCA had mandated companies to submit.
Covid-19 will burden companies with compliance costs and burden their finances, which is making them wary of it. Sonam Chandwani, managing partner of KS Legal & Associates, said, "Given CSR-2's policy, it may be helpful to the CSR department."

A company must provide details, such as the address, location, pincode of the property, along with the amount spent and its registered owner, if any capital assets have been created or acquired through CSR spend.

New mechanisms have been developed to ensure that the CSR sum is used in an appropriate and accountable manner, and that un-spent money is not added to the company's or promoter's coffers. Companies were also using CSR money for money laundering or funneling it back into their accounts, which prompted the stringent laws.
Javascript Variables
Tags: javascript, beginners, programming, react
Published: 2022-02-22 13:17:35

Variables are blocks for storing data. 
3 ways to declare variables

- var
- let 
- const

## Declaring the javascript variable

Variable is declared when we create the variable. You can declare the javascript variable with let or var keyword.
var name;
or 
let name;
After the declaration, the variable has no value it is undefined.
To assign a value to the variable, use the equal sign:
name = “awias butt”
Now it is a variable with type string.

## Using var

The var is the oldest keyword to declare a variable in JavaScript. The scope of the var keyword is the global or function scope. It means variables defined outside the function can be accessed globally, and variables defined inside a particular function can be accessed within the function. 
Example: Variable ‘number’ is declared globally. So, the scope of the variable ‘number’ is global, and it can be accessible everywhere in the program. 
`<script>
Var number = 10;
Function call(){
Console.log(number);
}
Call();
Console.log(number);
</script>`
**Output
10
10**

## Using let 

The let keyword is an improved version of the var keyword. It can’t be accessible outside the particular block or function.
`<script>
function call(){
let number = 10;
Console.log(number);
}
Console.log(number);
</script>`
**Output
10
ReferenceError: number is not defined**

## Using const 

The const keyword has all the properties that are the same as the let keyword, except the user cannot update it. When users declare a const variable, they need to initialize it, otherwise, it returns an error.
Splunk - 10K rows limit
Tags: monitoring, sre, devops, logging
Published: 2022-02-22 12:40:34

While you are doing requests in Splunk, especially for dashboards, you will try to optimize it and reuse as much as possible.

But, if you are doing this, be sure that the common request doesn't contains a **sort** operator if you don't need to. Because the usage of the **sort** operator will automatically limit you at the **first 10K rows** for your search.

So if you want to generate a dashboard showing :
- the number of calls
- the timechart
- ...
- and the last logs
be sure that you only have the sort on the subrequest that show the logs. 

Otherwise you will see only 10k in the number of calls and a hole in your timechart.

---

I hope it will help you! 🍺

---

<center><h3>You want to support me?</h3></center>
<a href="https://www.buymeacoffee.com/mxguilbert7" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
Pro Tips to Hire JavaScript Developer
Published: 2022-02-22 13:05:51

JavaScript is now a core technology in the web, and it's not just for building sites. It's also used to build desktop applications, mobile apps, and even server-side applications. If you're creating a new website/app or need to upgrade an existing one, you'll likely want to hire a JavaScript developer.

**So let us look at some important points to consider while hiring JavaScript Developer**

- **Start small -** You don't have to spend all your time building a massive, complex app — start small and get comfortable with the basics. As your skills improve over time, you can expand your project's scope and move on to more advanced features.

- **Focus on quality over quantity -** When you hire someone, there's no guarantee that what they produce is going to be good enough for your needs or even usable at all. So focus on the quality of the skills of developers to build an app that can be compared with the industry leaders in terms of performance.

- **Hiring local vs. remote candidates -** You can't just hire any developer you want; each position requires specific skills, so it's best to find someone who has experience with your exact needs. Based on your skill requirement and the cost associated with that skill you can choose to hire local or remote.

There are multiple tips apart from the ones mentioned above, but if you get in touch with good agency to hire a dedicated JavaScript Developer then the process becomes smooth and easy.

I hope the post helps you in hiring a dedicated JavaScript Developer.
Complete Flask - Part 2: Folder structure and Templating in Flask
Tags: python, flask, webdev, backend
Published: 2022-02-22 12:59:42

In the previous part we looked at how to create a basic hello world web app in Flask.

In this part of the series we are going to look at flask's folder structure and templating.

## Folder Structure
Unless you are creating an API in flask to be used by a frontend framework you are definitely going to need one folder: templates

All of the templates / html files will be in templates folder.
And if you are going to use CSS and JS which you certainly will you need static folder. 

So basically it looks like this:

```
project
|
|---static
     |style.css
     |script.js
|
|---templates
      |index.html
|app.py
```

## Templating

Flask uses a special templating language known as Jinja. 
Before diving into jinja let's see how to show html files to the user / client:

- Import render_template function from flask:

```python
from flask import Flask, render_template
```

- Create an `index.html` file in **templates** folder:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask App</title>
</head>
<body>
    <h3>This is html</h3>
</body>
</html>
```

- Go to app.py and create a new route (name it whatever you want):

```python
@app.route('/html-route')
```

- Create a function and render the template 'index.html':

```python
def htmlRoute():
    return render_template('index.html')
```

Fire up your terminal and use `flask run` command to run the server.
Now go to localhost:5000/html-route and you should see the HTML.

Now try playing around with what you have learnt till now, and solve the challenge below:

**Create a route named /signup that renders an html template with a form. It does not need to actually work, I only expect you to create a static HTML form with name, email and password fields.**

Complete app.py code:

```python 
from flask import Flask, render_template

app = Flask(__name__)

# We created the route below in the part 1 of this series
@app.route('/')
def home():
    return "Hello, World!"

@app.route('/html-route')
def htmlRoute():
    return render_template('index.html')
```

In the next part of this series we will cover the basics of Jinja templating language. See you next time!
Routing in Express.js
Tags: javascript, express, webdev, programming
Published: 2022-02-22 11:52:35

## Introduction
Routing refers to how an application’s endpoints (URIs) respond to client requests. Expressjs official Docs

You define routing using express app object corresponding HTTP methods POST and GET method.

## For example
The following code shows an example of a very basic route.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzval7ksuv8lmyl5bdw6.png)
 
## Route Methods
A route method is derived from one of the HTTP methods and is attached and called on app object, an instance of the express class.

## GET and POST Methods to the root off the app:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52hvh8vm1f16qezhx82z.png)
 
## Route Paths
These routes defined in the above code snippet will map to:
http://localhost:3000/ when app is run locally and matching depends on whether client uses POST or GET method and vice versa.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxhr7fytwhhkgmijhatx.png)
 
The above route matches to http://localhost:3000/about when the app is run locally.
Looking for a way to initialize IOptions<T> manually?
Tags: dotnet, dotnetcore, dependancyinjection, csharp
Published: 2022-02-22 11:41:55

## Background

Ok ... I know what you are thinking you must have thought that DotNet Core's dependency injection handles it for you and we just need to register configuration class then what is the need for manual initialization? And I completely agree with you but sometimes you may need to create an instance of a class that is dependent on IOptions<T> dependency (take an example of Unit test cases) and then real struggle starts.

Let's say we have `ValueController.cs` and it's accepting one parameter of type `IOptions<AppSettings>`

```
public class ValueController : Controller
{
   public ValueController(IOptions<AppSettings> options)
   {
   }
}
```
Also, we have some app configuration in `appsettings.json` file.

```
{
   "AppSettings": {
       "SettingOne": "ValueOne"
   }
}
```
## Issue

If you try to pass an instance of AppSettings class to ValueController then DotNet core will not allow it.

```
var settings = new AppSettings { SettingOne = "ValueOne" };
var obj = new ValueController(settings);
```
Even it will not allow you to explicitly cast the instance to `IOptions<AppSettings>` type. Take a look at the below code which will not work. The below code will throw a runtime exception.

```
var settings = (IOptions<AppSettings>) new AppSettings { SettingOne = "ValueOne" };
var obj = new ValueController(settings);
```
Then how to get it fixed? 

## Solution

Luckily DotNet core provides a static method to create an object of `IOptions<T>` type.

```
var settings = Options.Create(new AppSettings { SettingOne = "ValueOne" });
var obj = new ValueController(settings);
```

Done! You are all set to initialize `IOptions<T>` manually.

Happy Coding!
face-api js react
Published: 2022-02-22 11:32:52

https://github.com/justadudewhohacks/face-api.js#getting-started-utility-classes
https://youtu.be/rVvYAKzaYlY
https://youtu.be/CVClHLwv-4I
https://stackoverflow.com/questions/58711940/how-to-get-the-face-position-detection-inside-video-using-face-api
https://justadudewhohacks.github.io/face-api.js/docs/classes/facelandmarks68.html#getlefteye
https://www.youtube.com/watch?v=EejpxMtDg8M
Platonic solids, and more...
Tags: codepen
Published: 2022-02-22 11:25:26

<p>You can drag the solid with the mouse or screen touch. Set the speed to 0 if you really want to control its position.<br>
Open holes in the faces to see the hidden side. Close the holes to see actual solids (and improve performance).<br>
Becomes slow (down to 3 fps) on my computer when the number of faces is at its maximum, with holes.<br>
No library, as usual.<br>
</p><hr>
A few days ago, I read that the vertices of an icosahedron were on the surface of a cube. This gave me an idea of an easy way to calculate the coordinates of its vertices.<br>
I tried it, and used my perspective projection formulas for a nicer result.<br>
Once this icosahedron was draw, I had the idea to divide its faces into triangles, projecting the intermediate points on the surface of a unity sphere, and iterate this process to get more and more faces.<br>
Then I had the idea this could be done with all Platonic solids. The result is not always as fine as I whished,<br>
Then I added a few features for fun.

{% codepen https://codepen.io/Dillo/pen/OJOjdQp %}
A fluid block CSS which keeps aspect ratio and fits screen
Tags: css
Published: 2022-02-22 11:16:38

Have you ever had a case you want to fit a DIV block to the screen and keep the aspect ratio? Here's an example that I created. The red block keeps the aspect ratio and fits the screen.

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

The code is like this. In the example I used 16:9 as the aspect ratio but you can change as you want. Please change 16 and 9 for your purpose :)

```html
<div class="container">
  <div class="block"></div>
</div>
```

```css
/* quick sanitizer */
* {
  margin: 0;
  padding: 0;
}

.block {
  background-color: red;
  height: 100vh;
  max-width: calc(100vh * 16 / 9);
  max-height: calc(100vw * 9 / 16);
  margin: 0 auto;
  position: relative;
  width: 100vw;
}

.container {
  align-items: center;
  display: flex;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  position: relative;
}
```
Javascript Array Methods Ep.2
Tags: javascript, webdev, programming, beginners
Published: 2022-02-22 10:57:06

Hey There 👋
Welcome to Episode 2 of my Array Methods Explain Show.

as always, if you are here then i suppose you must have pre knowledge of javascript and arrays.

we will be discussing only one method in this episode 
which is : **SPLICE**

This is the best method in javascript arrays armoury, as it can be used to insert, replace or delete an element from an array.

the syntax of splice method is : 
![Syntax](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bk96i9lg8ulbcq2akqt8.png)

- **start** : 
```
The starting index from which you want to modify the array. 
If start > length of array, then start will be set to length of array. 
If start = -1, then start will be set to last element
```

- **deleteCount** (optional) : 
```
The count of elements you want to remove starting from start, if its value is equal or larger than array.length then all elements are removed. 
If its value is 0, then no element is removed, but then providing item1 parameter becomes compulsory.
```

- **item1, item2, item3, .... itemN** : 
```
The elements to add, beginning from start. 
If not provided then only elements are deleted.
```

It returns an element of deleted array elements, if no element is deleted then empty array is returned.

Now, Let's have a look at some of the examples to have better understanding

- To remove n elements from ith index. let’s take start as 1 and n as 1

```javascript
let colors = ["Red", "Blue", "Yellow", "White", "Black"];

colors.splice(1,1); // from index : 1, delete 1 item
console.log(colors); // ["Red", "Yellow", "White", "Black"]
```

- Now, lets delete 2 elements and replace them “pink” and “purple”
```javascript
let colors = ["Red", "Blue", "Yellow", "White", "Black"];

colors.splice(2, 2, "Pink", "Purple"); // from index : 2, delete 2 item, add two items
console.log(colors); // ["Red", "Blue", "Pink", "Purple", "Black"]
```

- Now, lets just add one element “grey” without deleting any element
```javascript
let colors = ["Red", "Blue", "Yellow", "White", "Black"];

colors.splice(1, 0, "Grey"); // from index 1, delete 0 item, add 1 item
console.log(colors); // ["Red", "Grey", "Blue", "Yellow", "White", "Black"]
```

- Last, splice returns the array of deleted elements
```javascript
let colors = ["Red", "Blue", "Yellow", "White", "Black"];

let value = colors.splice(3, 1); // from index 3, delete 1 item
console.log(value); // ["White"]
console.log(colors); // ["Red", "Blue", "Yellow", "Black"]
```
863. All Nodes Distance K in Binary Tree
Tags: cpp, algorithms, programming, 100daysofcode
Published: 2022-02-22 10:51:51



# Description

Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return *an array of the values of all nodes that have a distance* `k` *from the target node.*

You can return the answer in **any order**.

## Example 1:


```
Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
Output: [7,4,1]
Explanation: The nodes that are a distance 2 from the target node (with value 5) have values 7, 4, and 1.
```

## Example 2:

```
Input: root = [1], target = 1, k = 3
Output: []
```

## Constraints:

- The number of nodes in the tree is in the range `[1, 500]`.
- `0 <= Node.val <= 500`
- All the values `Node.val` are **unique**.
- `target` is the value of one of the nodes in the tree.
- `0 <= k <= 1000`

---

# Solutions

## Solution 1

### Intuition

1. turn this tree to a undirected graph
2. dfs from target node, find k-distance node

### Code

```cpp
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public : 
    unordered_map<TreeNode*, vector<TreeNode*>> g;
    vector<int> res;

    void dfs(TreeNode* node) {
        if (node -> left) {
            g[node].push_back(node -> left);
            g[node -> left].push_back(node);
            dfs(node -> left);
        }
        if (node -> right) {
            g[node].push_back(node -> right);
            g[node -> right].push_back(node);
            dfs(node -> right);
        }
    }

    void find(TreeNode* node, TreeNode* father, int k) {
        if (!k) {
            res.push_back(node -> val);
        } else {
            for (auto son : g[node]) {
                if (son != father)
                    find(son, node, k - 1);
            }
        }
    }

    vector<int> distanceK(TreeNode* root, TreeNode* target, int k) {
        dfs(root);
        find(target, NULL, k);
        return res;
    }
};
```

### Complexity

- Time: O(N)
- Space: O(N)

---
Formdata in expo app is being recieved in _parts
Published: 2022-02-22 10:42:54

I am sending form to backend by using FormData and using multer on backend to recieve the data, it works fine on my web app but on doing the same axios call to submit data in react-native shows that data fields are being received on backend in following form

`{ _parts: [ [ 'firstname', 'fahad' ], [ 'firstname', 'RAO' ] ] }`
i am doing following call in my web app (which works there) and in my expo app
`
const testFOrmData = ()=>{
        
        var data = new FormData()
        data.append("firstname","fahad")
        data.append("firstnae","RAO")
        const adata  = {
            firsn:"rew"
        }
axios.post("http://192.168.10.8:3309/api/testform",data)
.then((res)=>{
    console.log(res)
})
alert("SANS")
    }`
How to receive it in object form such that i dont have to make changes in my existing code in backend as i have so many forms and i have submitted them using form data in my web app and have to do same in mobile app but i dont want to submit without FormData(by sending object in axios)

my backend

`router.post("/testform",upload.none(),(req,res)=>{
    console.log(req.body)
    res.json({resp:req.body})
})`
Magento2 stock update via REST API
Tags: magento2, php, stock, rest
Published: 2022-02-22 10:19:40

Simple way to retrieve and update Magento2 product stock via REST API:

1. Fetch the authorization token:

```rest
curl -X POST \
  https://my.magento2store.com/rest/default/V1/integration/admin/token \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
  "username": "username",
  "password": "password"
}'
```
It should return a string token as result:

```
"0m4l40jicu4luxr2npf7nucr4wslb75s"
```

2. Fetch live product stock:

```rest
curl -X GET \
  https://my.magento2store.com/rest/V1/stockItems/SKU-0001 \
  -H 'authorization: Bearer <auth_token>' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json'
```
Result:
```json
{
    "item_id": 101,
    "product_id": 123,
    "stock_id": 1,
    "qty": 33,
    "is_in_stock": true,
    "is_qty_decimal": false,
    "show_default_notification_message": false,
    "use_config_min_qty": true,
    "min_qty": 0,
    "use_config_min_sale_qty": 1,
    "min_sale_qty": 1,
    "use_config_max_sale_qty": true,
    "max_sale_qty": 10000,
    "use_config_backorders": true,
    "backorders": 0,
    "use_config_notify_stock_qty": true,
    "notify_stock_qty": 1,
    "use_config_qty_increments": true,
    "qty_increments": 0,
    "use_config_enable_qty_inc": true,
    "enable_qty_increments": false,
    "use_config_manage_stock": true,
    "manage_stock": true,
    "low_stock_date": null,
    "is_decimal_divided": false,
    "stock_status_changed_auto": 0
}
```

3. Update live stock:

```
curl -X PUT \
  https://my.magento2store.com/rest/V1/products/SKU-0001/stockItems/1 \
  -H 'authorization: Bearer <auth_token>' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{"stockItem":{"qty":100, "is_in_stock": true}}'
```