Skip to content

Instantly share code, notes, and snippets.

View nazariyv's full-sized avatar
🔭
You study mathematics because it is the poetry of the universe

naz nazariyv

🔭
You study mathematics because it is the poetry of the universe
View GitHub Profile
@nazariyv
nazariyv / gist:9d8725ac1cd43872b8ac28ad90a0fffc
Last active June 9, 2024 15:07
creating-ubuntu-live-server
1/ install ubuntu live server (skip docker here and manually post-install (during ubuntu install it will use snap socker and it's utter shit and will cause you headaches), openssh)
2/ set static ip (/etc/netplan/static.yaml):
network:
version: 2
renderer: networkd
ethernets:
<your-interface>:
addresses:
<your-local-static-ip>
@nazariyv
nazariyv / generate_private_key.py
Created July 11, 2023 10:23
throw away ethereum private key
import random
def int_to_privkey(n):
hex_n = hex(n)[2:] # convert to hexadecimal and strip the "0x" prefix
return hex_n.rjust(64, '0') # pad with zeros to the left until it's 64 characters long
int_to_privkey(random.randing(0, 2 ** 256 - 1))
Two pointers: one input, opposite ends
```python3
def fn(arr):
left = ans = 0
right = len(arr) - 1
while left < right:
# do some logic here with left and right
if CONDITION:
@nazariyv
nazariyv / number_to_base.py
Created November 26, 2022 18:22
Converts number n to base b
def number_to_base(n, b):
if n == 0:
return [0]
digits = []
while n:
digits.append(int(n % b))
n //= b
return digits[::-1]
@nazariyv
nazariyv / refund_bids.py
Created April 23, 2022 16:39
Off-chain refund bids script
from typing import Dict, Tuple
from brownie import accounts, chain
from dataclasses import dataclass
# ! 1. losing threshold to be set manually here
# ! 2. bids to be set manually here
# ! 3. set the account to rkl refunder account in main
# if the bid is below this value, it has lost the auction
# it is possible that there may be two bids for the same
@nazariyv
nazariyv / decorator.py
Created October 6, 2021 19:38 — forked from jaantollander/decorator.py
Template for Python decorator function and class
import functools
def decorator(function):
"""A general decorator function"""
@functools.wraps(function)
def wrapper(*args, **kwargs):
# Write decorator function logic here
# Before function call
@nazariyv
nazariyv / linux-cron-tips.txt
Created September 30, 2021 12:02
Linux - Useful for Cron work
to read the logs that cron produced due to running something: cat /var/mail/$USER
to read the logs of when and if cron launched jobs: sudo cat /var/log/cron
to restart the cron service: sudo systemctl restart crond
@nazariyv
nazariyv / crontab.txt
Created September 27, 2021 15:02
crontab quick tips
# https://crontab.guru/every-5-minutes
crontab -e
sudo service crond restart
sudo cat /var/log/cron
@nazariyv
nazariyv / setup-ipfs-on-aws.txt
Created September 26, 2021 17:31
setup-ipfs-on-aws
The tutorials below explain how to start the IPFS node on AWS. Of note are the networking (the ports required to open) as well as
setting up the IPFS env var to persist the data:
https://medium.com/textileio/tutorial-setting-up-an-ipfs-peer-part-i-de48239d82e0
https://talk.fission.codes/t/a-loosely-written-guide-to-hosting-an-ipfs-node-on-aws/234
@nazariyv
nazariyv / create2.py
Last active June 6, 2021 20:23
Uniswap v2 Python CREATE2
# references
# 1. https://uniswap.org/docs/v2/javascript-SDK/getting-pair-addresses/
# 2. https://ethereum.stackexchange.com/questions/90539/how-to-get-the-non-packed-soliditykeccak-hash-in-python-web3
# deps
# Python 3.9.5
# 1. eth-abi==2.1.1
# 2. web3==5.18.0