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; | |
abstract contract NoReEnter { | |
uint8 internal mutex; | |
bytes32 constant internal ERROR_STATE_LOCKED = 0x07b2e09e00000000000000000000000000000000000000000000000000000000; | |
error StateLocked(); |
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.20; | |
contract Forwarder { | |
// admin of the contract | |
address private immutable owner; | |
// Some randomness to ensure that each deployment has unique bytecode | |
bytes32 public immutable entropy = bytes32(keccak256(abi.encode(uint256(uint160(block.timestamp ^ (block.number / block.timestamp)))))); | |
// this key is set at deploy time and never changes |
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
/*** | |
* Shoutouts: | |
* | |
* Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/ | |
* Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/ | |
* Credits to Jorge Izquierdo (@izqui) for coming up with this design here: https://gist.github.com/izqui/7f904443e6d19c1ab52ec7f5ad46b3a8 | |
* Credits to Stefan George (@Georgi87) for inspiration for many of the improvements from Gnosis Safe: https://github.com/gnosis/gnosis-safe-contracts | |
* | |
* This version has many improvements over the original @izqui's library like using REVERT instead of THROWing on failed calls. | |
* It also implements the awesome design pattern for initializing code as seen in Gnosis Safe Factory: https://github.com/gnosis/gnosis-safe-contracts/blob/master/contracts/ProxyFactory.sol |
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.18; | |
contract MinimalWrappedEther { | |
address public immutable admin; | |
uint256 public totalSupply; | |
uint256 public reservedEther; | |
string public name; | |
string public symbol; |
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.18; | |
interface IERC20 { | |
function totalSupply() external view returns (uint256); | |
function balanceOf(address account) external view returns (uint256); | |
function transfer(address recipient, uint256 amount) external returns (bool); | |
function allowance(address owner, address spender) external view returns (uint256); | |
function approve(address spender, uint256 amount) external returns (bool); | |
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); |
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.18; | |
abstract contract MinimalistErc20 { | |
address public owner; | |
string public name; | |
string public symbol; | |
uint256 public totalSupply; | |
uint8 immutable public decimals; | |
mapping (address => uint256) public balanceOf; |
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
#!/bin/bash | |
# Get the total memory in kilobytes | |
TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') | |
# Calculate half of the total memory | |
HALF_MEM_KB=$((TOTAL_MEM_KB / 2)) | |
# Convert kilobytes to megabytes (MB) | |
HALF_MEM_MB=$((HALF_MEM_KB / 1024)) |
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
#!/usr/bin/env python3 | |
import multiprocessing | |
import os | |
import dotenv | |
import trio | |
import trio_asyncio | |
from asyncio.log import logger | |
from web3 import AsyncWeb3, WebSocketProvider | |
multiprocessing.freeze_support() | |
dotenv.load_dotenv() |
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
import numpy as np | |
import rebound | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
def add_galactic_potential(sim, mass_distribution): | |
""" | |
Simplified function to simulate the galactic potential effect on the simulation. | |
This function modifies the velocities of particles to simulate a basic galactic potential. |
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
#! /bin/bash | |
# Modified to run both (redudantly, yes, I know, I am paranoid, you should be too) checks | |
# | |
set -eu | |
# find path to liblzma used by sshd | |
path="$(ldd $(which sshd) | grep liblzma | grep -o '/[^ ]*')" | |
echo 'Check one: does it even exist?' | |
# does it even exist? | |
if [ "$path" == "" ] |
NewerOlder