Skip to content

Instantly share code, notes, and snippets.

@elyase
elyase / simulate_swap.py
Last active May 5, 2024 11:59
Swap simulation with pyrevm
from eth_abi import decode, encode
from eth_utils import function_signature_to_4byte_selector
from pyrevm import EVM
# https://etherscan.io/tx/0x652bae3b1c11fbcf64309c2dfec5537b9bd1d3f2b521176f71ba1115a313ecbd"
# Swap 0.031485012992133186 ETH for 1,110.686711078457978839 CSWAP on Uniswap v2
block_number = 19726294
caller = "0xc0170e050355408e53800d093f3f13c3a53b29c8"
router = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
token = "0xae41b275aaAF484b541A5881a2dDED9515184CCA"
@elyase
elyase / abi.py
Created January 18, 2024 11:26 — forked from reinforcementwonder/abi.py
uniswap v2 buy & sell
import json
MIN_ERC20_ABI = json.loads(
"""
[{"constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_spender", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@elyase
elyase / gist:e1b5e607d37398814caff149b9c2c567
Created March 12, 2023 14:51
Run command in Warp with pop clip
-- # PopClip Run in Warp
-- { name: Run in Warp, icon: iconify:simple-icons:warp, language: applescript }
tell application "Warp"
activate
tell application "System Events"
tell process "Warp"
delay 0.01
set sourceText to "{popclip text}"
keystroke sourceText
delay 0.01
@elyase
elyase / ibsimu_install.md
Created November 26, 2021 17:45
ibsimu install ubuntu

Tested on ubuntu 20.04.3

Install dependencies

sudo apt-get install build-essential
sudo apt install libcairo2-dev
sudo apt install libgsl-dev
sudo apt install libgtk-3-dev

Download the code

@elyase
elyase / install_debian.md
Last active November 26, 2021 17:52
ibsimu installation debian/ubuntu

Tested on debian buster

Install dependencies

sudo apt install libcairo2-dev
sudo apt install libgsl-dev
sudo apt install libgtk-3-dev

Download the code

@elyase
elyase / convert_mysql_to_sqlite3.sh
Created December 15, 2017 17:04 — forked from grfiv/convert_mysql_to_sqlite3.sh
convert a mysql database to sqlite3
#!/bin/bash
#
# convert a mysql database to sqlite3
#
#see https://stackoverflow.com/questions/5164033/
# export-a-mysql-database-to-sqlite-database
mysql_host=localhost
mysql_user=george
#mysql_passwd=****************
@elyase
elyase / preprocess-twitter.py
Created April 29, 2016 08:26 — forked from tokestermw/preprocess-twitter.py
Python version of Ruby script to preprocess tweets for use in GloVe featurization http://nlp.stanford.edu/projects/glove/
"""
preprocess-twitter.py
python preprocess-twitter.py "Some random text with #hashtags, @mentions and http://t.co/kdjfkdjf (links). :)"
Script for preprocessing tweets by Romain Paulus
with small modifications by Jeffrey Pennington
with translation to Python by Motoki Wu
Translation of Ruby script to create features for GloVe vectors for Twitter data.
@elyase
elyase / recursive_delete.py
Created November 16, 2015 02:10
Recursively deleting a folder in Dropbox to overcome the 10000 files limitation.
# Include the Dropbox SDK
import dropbox
# Get your app key and secret from the Dropbox developer website
# https://www.dropbox.com/developers-v1/apps
app_key = 'key'
app_secret = 'secret'
flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
@elyase
elyase / install.md
Last active August 15, 2020 11:37
ibsimu installation on osx

Tested on ibsimu-1.0.6dev, OSX Yosemite, High Sierra, Catalina.

Install homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install dependencies

brew install autoconf automake libtool gtk+3 gsl