This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup | |
function isPowerOfTen(uint256 x) public pure returns (bool result) { | |
assembly { | |
let dict := 0x00011c021d0e18031e16140f191104081f1b0d17151310071a0c12060b050a09 | |
let zeroes := 0 | |
for { let offset := 0 } lt(offset, 256) { offset := add(offset, 32) } { | |
let v := and(shr(offset, x), 0xffffffff) | |
switch v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { BN } = require('bn.js'); | |
const { keccak256 } = require('ethereumjs-util'); | |
const { toBN } = require('web3-utils'); | |
// function hash (selector, salt, m) { | |
// return new BN(selector, 'hex').xor(toBN(salt)).toNumber() % 25469 % m; | |
// } | |
function hash (selector, salt, m) { | |
const saltStr = toBN(salt).toString('hex', 8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { BN } = require('bn.js'); | |
const { keccak256 } = require('ethereumjs-util'); | |
const { toBN } = require('web3-utils'); | |
const numberOfSelectors = 1000; | |
const tableSizeKoef = 1.5; | |
const maxBucketSize = 2; | |
function hash (selector, salt, m) { | |
return new BN(selector, 'hex').xor(toBN(salt)).toNumber() % 65537 % m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/utils/Address.sol"; | |
import "@openzeppelin/contracts/utils/Create2.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "github.com/1inch/solidity-utils/contracts/libraries/AddressArray.sol"; | |
contract Caller { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { toBN } = require('web3-utils'); | |
function findBucket(iterations) { | |
const selectors = [ | |
0x12345678, | |
0x11223344, | |
0xaabbccdd, | |
0xabcdefff, | |
0xabbcccdd, | |
0xbbbbbbbb, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval "$(/opt/homebrew/bin/brew shellenv)" | |
export PATH=$PATH:$HOME/.cargo/bin | |
alias stree='/Applications/SourceTree.app/Contents/Resources/stree' | |
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' | |
alias gc='git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef Lohi_h | |
#define Lohi_h | |
namespace lohi { | |
template<typename T> | |
struct Lohi; | |
template<typename T> | |
T zero(thread const T &) { | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.11; | |
contract ModInv { | |
uint256 public constant n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F; | |
function inverseDiv(uint256 a) public pure returns(uint256) { | |
return inverseDiv(a, n); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.0; | |
contract CompressedCaller { | |
function compressedCall( | |
address target, | |
uint256 totalLength, | |
bytes memory zipped | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract ShardedToken { | |
using SafeMath for uint256; | |
address owner = msg.sender; | |
uint256 private _totalSupply; | |
mapping(address => ShardedToken.Extension) private extensions; | |
function register() public { | |
extensions[msg.sender] = new Token.Extension(); | |
} |
NewerOlder