Skip to content

Instantly share code, notes, and snippets.

View Alexfilus's full-sized avatar

Alexfilus Alexfilus

View GitHub Profile
// This is a basic uniswap frontrunning MEV bot
// Made by Merunas follow me on youtube to see how to use it and edit it: https://www.youtube.com/channel/UCJInIwgW1duAEnMHHxDK7XQ
// 1. Setup ethers, required variables, contracts and start function
const { Wallet, ethers } = require('ethers')
const { FlashbotsBundleProvider, FlashbotsBundleResolution } = require('@flashbots/ethers-provider-bundle')
// 1.1 Setup ABIs and Bytecodes
const UniswapAbi = [{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesire
@Alexfilus
Alexfilus / readdb.go
Created April 3, 2023 14:07 — forked from NAKsir-melody/readdb.go
Read ethereum level DB directly
package main
import (
"fmt"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
_ "github.com/ethereum/go-ethereum/common"
@Alexfilus
Alexfilus / latency.txt
Created August 27, 2021 14:46 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@Alexfilus
Alexfilus / print.php
Created May 24, 2020 11:51
print range to count and array
/**
* @param string $range
* @return string
*/
public static function cleanRange(string $range): string
{
return preg_replace('/[^0-9\-,]/', '', $range);
}
/**
@Alexfilus
Alexfilus / pg_to_csv.txt
Created December 9, 2019 11:28
PG to CSV
psql -U postgres -d name -h host.com -p 5432 -c "COPY (SELECT id, name FROM user LIMIT 10) TO STDOUT With CSV HEADER DELIMITER ',';" > foo_data.csv
@Alexfilus
Alexfilus / postgres-upgrade.md
Created November 26, 2019 12:14
Upgrade PG 10->12
/usr/lib/postgresql/12/bin/pg_upgrade \
  --old-datadir=/var/lib/postgresql/10/main \
  --new-datadir=/var/lib/postgresql/12/main \
  --old-bindir=/usr/lib/postgresql/10/bin \
  --new-bindir=/usr/lib/postgresql/12/bin \
  --old-options '-c config_file=/etc/postgresql/10/main/postgresql.conf' \
  --new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
  --check
@Alexfilus
Alexfilus / docker-gitlab.md
Last active November 26, 2019 12:12
docker gitlab
sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 8443:443 --publish 8080:80 --publish 2222:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
 gitlab/gitlab-ce:latest
@Alexfilus
Alexfilus / php-pools.md
Created October 22, 2019 15:38 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@Alexfilus
Alexfilus / redis_session.txt
Created June 28, 2019 14:16
PHP сессии в редисе без настроек сервера
session_start([
'save_handler' => 'redis',
'save_path' => 'tcp://127.0.0.1:6379?database=1',
'cookie_lifetime' => 86400,
'gc_maxlifetime' => 86400,
'serialize_handler' => 'igbinary',
'name' => 'project',
'cookie_httponly' => true
]);