Skip to content

Instantly share code, notes, and snippets.

View MicrowaveDev's full-sized avatar

Microwave Dev MicrowaveDev

View GitHub Profile
@MicrowaveDev
MicrowaveDev / messagesFuncs.js
Last active December 5, 2022 19:04
Save last telegram messages and autodelete last messages by theme name
const lsMessages = {
};
function pleaseRegister(msg) {
return sendMessageAndClear('register', msg, bot.sendMessage(msg.chat.id, `Please register in bot`, {parse_mode: 'HTML'}));
}
function alreadyRegistered(msg) {
return sendMessageAndClear('register', msg, bot.sendMessage(msg.chat.id, `You already registered`, {parse_mode: 'HTML'}));
library PolygonUtils {
struct PolygonData {
int256[2][] points;
}
function isInsidePolygon(PolygonData storage _polygon, int256[2] memory _point) public view returns (bool) {
bool inside = false;
uint256 j = _polygon.points.length - 1;
@MicrowaveDev
MicrowaveDev / PolygonCheckerV2.sol
Created August 3, 2020 16:17
PolygonCheckerV2
import "./PolygonUtils.sol";
contract PolygonChecker {
mapping(uint256 => PolygonUtils.PolygonData) polygons;
function addPolygonPoint(uint256 polygonId, int256[2] memory point) public {
polygons[polygonId].points.push(point);
}
function isInsidePolygonById(int256[2] memory _point, uint256 _polygonId) public view returns (bool) {
@MicrowaveDev
MicrowaveDev / PolygonCheckerV1.sol
Last active August 3, 2020 16:21
How to optimize ETH smart contract size
contract PolygonChecker {
struct PolygonData {
int256[2][] points;
}
mapping(uint256 => PolygonData) polygons;
function addPolygonPoint(uint256 polygonId, int256[2] memory point) public {
polygons[polygonId].points.push(point);
}
@MicrowaveDev
MicrowaveDev / logContractSizes.js
Created August 3, 2020 15:58
Get all compiled smart contracts sizes
const fs = require('fs');
const Table = require('cli-table');
const table = new Table({
head: ['Contract', 'Size (bytes)'],
colWidths: [50, 15]
});
const testFolder = './build/contracts/';
@MicrowaveDev
MicrowaveDev / Erc721Factory.sol
Last active May 31, 2020 15:05
Erc721 Factory by OpenZeppelin
// File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity ^0.5.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
@MicrowaveDev
MicrowaveDev / gist:ec5835c07aac6d4fd95a754959d5ab16
Last active March 5, 2020 20:56
Mysql to Postgres migration
```
createdb my_database
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo apt install pgloader
mysql -uroot -proot -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"
pgloader --with "quote identifiers" mysql://root:root@localhost/my_database postgresql:///my_database
```
@MicrowaveDev
MicrowaveDev / .block
Created December 17, 2019 21:26
fresh block
license: mit
pragma solidity ^0.5.2;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
This file has been truncated, but you can view the full file.
I[22016-01-22|23:03:52.578] Starting ABCI with Tendermint module=main
I[22016-01-22|23:03:52.627] Loading mem state module=main
I[22016-01-22|23:03:52.627] App loaded module=main time=249.405µs
I[22016-01-22|23:04:07.550] Executed block module=state height=1 validTxs=0 invalidTxs=0
I[22016-01-22|23:04:07.551] Rank calculated module=main time=102.2µs links=0 cids=0
E[22016-01-22|23:04:22.593] SendTimeout module=blockchain peer=7f9db6d13282c1984a6fb180b43bb07e5871a271 reason="peer did not send us anything" timeout=15s
I[22016-01-22|23:04:40.760] Committed state module=state height=1 txs=0 appHash=E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
E[22016-01-22|23:04:40.765] Stopping peer for error module=p2p peer="Peer{MConn{93.125.26.210:34656} 7f9db6d13282c1984a6fb180b43bb07e5871