Skip to content

Instantly share code, notes, and snippets.

View mswezey23's full-sized avatar
🎯
Focusing

Swezey, Matt mswezey23

🎯
Focusing
View GitHub Profile
@mswezey23
mswezey23 / Test SafeMath
Created November 16, 2018 05:40
SafeMath Test for uint64
pragma solidity ^0.4.24;
library SafeMathExtensions {
/**
* @dev Casts to uint8, throws on overflow.
*/
function castTo8(uint256 a) internal pure returns (uint8 c) {
c = uint8(a);
assert(a == c);
@mswezey23
mswezey23 / BountyComments.sol
Created November 30, 2018 17:34
BountyOne Contract Review
// endTime is already in day units from the 1st line, making the 2nd `* 1 days' incorrect in the 2nd require() statement
// endTime should be checked for > 0
// the 2nd require() statment is not logical. now + N (N being an unint > 0) will always be > now
uint endTime = _endTimeInDays * 1 days;
require(endTime < maxAuditDuration);
require(block.timestamp + endTime * 1 days > block.timestamp);
require(msg.value > 0 && _maxAuditors > 0 && _stake > 0);
// Lines 14, 16, and 17 do NOT update state. Should be the following:
// 14: audits[_id].remainingReward = audits[_id].remainingReward.sub(_reward);
pragma solidity ^0.5.0;
contract testManager {
address public manager;
modifier onlyManager() {
require(msg.sender == manager);
_;
}
/* file: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol */
pragma solidity ^0.5.0;
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
pragma solidity 0.5.5;
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract TestStructCompactionImproved {
using SafeMath for uint256;
struct Vote {
address account; // The voter's account address.
uint256 votingPower; // Token balance of the account at the proposal's creation time.
pragma solidity 0.5.5;
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract TestStructCompaction {
using SafeMath for uint256;
struct Vote {
address account; // The voter's account address.
uint256 votingPower; // Token balance of the account at the proposal's creation time.
pragma solidity 0.5.5;
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";
contract StoreVsCalculate {
using SafeMath for uint256;
uint256[] _result;
function storeResult(uint256 input) public {
pragma solidity 0.5.6;
interface DeployInterface {
function foo() external returns (uint256);
}
contract DeploySecond is DeployInterface {
function foo() external returns (uint256) {
return 2;
}
@mswezey23
mswezey23 / wsl-redis-start.md
Created February 26, 2020 05:42 — forked from cromat/wsl-redis-start.md
Run redis inside WSL as background service on Windows startup

Step by step guide to run redis-server inside WSL(Windows Subsystem for Linux) on Windows

I have tried to setup redis as starting background task with wsl-autostart, Task Scheduler and with lot vbs scripts including one described here but none of them seemed to work.

In the end I have manually created a simple one that does the job. This script basically starts a hidden Ubuntu Window and starts redis-server inside it.

  1. Install WSL (this is tested with Ubuntu 18.04 version)
  2. Install redis-server inside WSL sudo apt install redis-server
  3. Add sudo permission to your user to execute service command without password
@mswezey23
mswezey23 / wsl-redis-start.md
Created February 26, 2020 05:42 — forked from cromat/wsl-redis-start.md
Run redis inside WSL as background service on Windows startup

Step by step guide to run redis-server inside WSL(Windows Subsystem for Linux) on Windows

I have tried to setup redis as starting background task with wsl-autostart, Task Scheduler and with lot vbs scripts including one described here but none of them seemed to work.

In the end I have manually created a simple one that does the job. This script basically starts a hidden Ubuntu Window and starts redis-server inside it.

  1. Install WSL (this is tested with Ubuntu 18.04 version)
  2. Install redis-server inside WSL sudo apt install redis-server
  3. Add sudo permission to your user to execute service command without password