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
use alloy::primitives::U256; | |
fn integer_sqrt(n: U256) -> U256 { | |
// https://en.wikipedia.org/wiki/Integer_square_root | |
if n < U256::from(2) { | |
return n; | |
} | |
let small_candidate = integer_sqrt(n >> 2) << 1; |
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
use alloy::primitives::U256; | |
fn main() { | |
let reserve_ratio: f64 = pool.reserve0.to::<f64>() / pool.reserve1.to::<f64>(); | |
} |
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
use web3::transports::WebSocket; | |
use web3::Web3; | |
def main() { | |
let rpc_url: String = "http://localhost:8545" //"Your RPC URL" | |
// Initialize WebSocket transport | |
let ws = WebSocket::new(&rpc_url).await?; | |
let w3 = Web3::new(ws); | |
info!("Successfully connected to WebSocket RPC."); |
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
## Using hatch but should be similar for other tools | |
# https://hatch.pypa.io/latest/config/build/#pyprojecttoml_5 | |
# Build configs | |
[tool.hatch.build.targets.sdist] | |
include = [ | |
"src/**/*.py", | |
".configs/*" | |
] |
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
from solders.pubkey import Pubkey | |
from solana.rpc.api import Client | |
from solders.pubkey import Pubkey | |
from solders.keypair import Keypair | |
from solana.rpc.types import TokenAccountOpts | |
from rich.pretty import pprint | |
# You can use async client as well | |
http_client = Client("https://api.mainnet-beta.solana.com") | |
private_key = Keypair.from_bytes(bytes(key)) |
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
from spl.token._layouts import MINT_LAYOUT | |
from solana.rpc.api import Client, Pubkey | |
http_client = Client("https://api.mainnet-beta.solana.com") | |
# USDC token address | |
addr = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") | |
info = http_client.get_account_info(addr) | |
decimals = MINT_LAYOUT.parse(info.value.data).decimals |
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
pipx list --short | cut -d ' ' -f1 | while read line; do pipx upgrade $line; done |
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
[Desktop Entry] | |
Name=Filecoin Station | |
Comment=Filecoin Station | |
Exec=/home/avik/tools/filecoin-station-linux-x86_64.AppImage | |
Icon=/home/avik/tools/icons-for-appImage/file-coin-station.jpg | |
Terminal=false | |
Type=Application | |
Categories=Development; |
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
[Desktop Entry] | |
Name=Ledger Live Desktop | |
Comment=Ledger Live Desktop App | |
Exec=/home/avik/tools/ledger-live-desktop-2.77.2-linux-x86_64.AppImage | |
Icon=/home/avik/tools/icons-for-appImage/ledger.webp | |
Type=Application | |
Terminal=false | |
Categories=Development; |
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 | |
# Removes old revisions of snaps | |
# CLOSE ALL SNAPS BEFORE RUNNING THIS | |
echo "Size before cleanup" | |
du -h /var/lib/snapd/snaps | |
set -eu | |
snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; |
NewerOlder