Skip to content

Instantly share code, notes, and snippets.

View darkerego's full-sized avatar

Darkerego darkerego

View GitHub Profile
darkerego /
Created April 9, 2024 18:55
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.
#! /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" == "" ]
darkerego / equalizer_flash_loan.sol
Last active December 6, 2023 04:11
equalizer flash loan
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
interface IERC3156FlashBorrower {
function onFlashLoan(
address initiator,
darkerego / uniswap-v3-example.sol
Created September 6, 2023 13:04 — forked from mempirate/uniswap-v3-example.sol
Simple example on how to swap on UniswapV3 with the SwapRouter
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
darkerego / gist:edce02f936b6441b93e3ca66ae817780
Last active September 1, 2023 22:00
Attempting to Revert Static Calls
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TestStateChange {
uint public originalValue = 123;
uint public oldValue;
uint public incrementer = 0;
bytes4 public constant CHANGE_SEL = bytes4(keccak256(bytes('changeState(uint256)')));
bytes4 public constant WRAP_CHANGE_SEL = bytes4(keccak256(bytes('wrapChangeState(uint256)')));
error CallFailedError(string reason,address msgSender,address txOrigin);
darkerego / test_call.sol
Last active August 8, 2023 21:34
Solidity Assembly Call & Get Return Data / Revert with Reason
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2
contract TestExec {
address owner;
constructor() {
owner = msg.sender;
darkerego /
Last active July 30, 2023 23:50
AioHttp Client Skeleton Class
import asyncio
import json
import aiohttp
class AsyncHttpClient:
def __init__(self, _headers=None, base_url: str = None, timeout: (int, float) = 60):
A skeletal asynchronous HTTP class. Because I found myself writing this same code
darkerego /
Last active July 25, 2023 07:44
Bloxroute bsc rescue
#!/usr/bin/env python3
# Python 3.7 or higher required due to the use of
import argparse
import asyncio, json, ssl
import math
import os
import json
import re
import websocket
darkerego /
Created July 10, 2023 20:51
Proton Testnet grab snapshot and restart node
echo 'Changing directories ... '
cd /opt/ProtonTestnet/protonNode
echo "Delete old snaps"
rm snapshots/*
echo "Downloading latest snap "
cd snapshots
unzstd latest-snapshot.bin.zst
darkerego /
Created May 17, 2023 21:48
Multichain Web3
import asyncio
import logging
import os
from web3.middleware import geth_poa_middleware
import utils.termstyle
import web3
cp = utils.termstyle.ColorPrinter(0)