Skip to content

Instantly share code, notes, and snippets.

@rubpy
rubpy / rpc_fetch_pump_token_price.ts
Created June 20, 2024 18:39
Fetching Pump.fun bonding curve state and calculating price of token/SOL.
import * as web3 from "@solana/web3.js";
//////////////////////////////////////////////////
function readBytes(buf: Buffer, offset: number, length: number): Buffer {
const end = offset + length;
if (buf.byteLength < end) throw new RangeError("range out of bounds");
return buf.subarray(offset, end);
}
@marekyggdrasil
marekyggdrasil / mcm.py
Created March 13, 2024 09:10
Computing the bong-bing-bang-and-gong number for https://x.com/botnetzprovider/status/1767680709726978051?s=20
def numberToBase(n, b):
if n == 0:
return [0]
digits = []
while n:
digits.append(int(n % b))
n //= b
return digits[::-1]
@elocremarc
elocremarc / parsesats.js
Last active November 4, 2023 00:26
Script to parse short sat names off the end of sats in your UTXO.
/**
* parsesats.js
*
* This script is used to parse short sat names from a UTXO output it scrapes the explorer html
*
* Command usage:
* node parsesats.js [output] [name] [host]
*
* [output]: The UTXO
* [name]: The name short names like 4 charcters are pretty common. Must be less than 11 characters.
@revofusion
revofusion / rune.ts
Created September 27, 2023 01:13
Rune Scripts: PrefixVarint and Base 26 (A=1) Name
/**
Convert between rune symbols and values using Base 26 (A=1)
Similar rust implementation at https://github.com/ordinals/ord/blob/f3cae5400fdebf31bfd494a02c846a90ea12310d/src/sat.rs#L63
*/
class Rune {
constructor(public value: number) { }
public get name(): string {
let x = this.value;
{
"1": {
"rpcs": [
"https://api.mycryptoapi.com/eth",
"https://rpc.flashbots.net/",
"https://eth-mainnet.gateway.pokt.network/v1/5f3453978e354ab992c4da79",
"https://cloudflare-eth.com/",
"https://mainnet-nethermind.blockscout.com/",
"https://nodes.mewapi.io/rpc/eth",
"https://main-rpc.linkpool.io/",
// 1. Import everything
import { Wallet, BigNumber, ethers, providers } from 'ethers'
const { FlashbotsBundleProvider, FlashbotsBundleResolution } = require('@flashbots/ethers-provider-bundle')
/*
Mainnet
const provider = new providers.JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh')
const wsProvider = new providers.WebSocketProvider('wss://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh')
*/
@cameel
cameel / solidity-enums-with-data.md
Last active September 5, 2024 13:11
Enums with data in Solidity

Use cases

  • Optional/nullable data types.
  • Variant data types.
  • Flag with extra information needed only in some cases (or different in different cases).
  • Modeling states in a state machine where each state can have some data associated with it.
  • List of operations for batch processing, where each operation can have its own arguments.
  • Alternative to function overloading that allows avoiding combinatorial explosion when there are multiple parameters that need variants.
  • Nested data structures with heterogenous nodes.

Syntax and semantics

@strictlymomo
strictlymomo / index.html
Last active May 26, 2022 00:25
Generative Art NFT Visualizer (fork of Ethereum NFT, Autoglyphs)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Momoglyphs Test Visualizer</title>
<link rel='icon' href='favicon/favicon.ico' type='image/x-icon'/ >
<script charset="utf-8" src="https://cdn.ethers.io/scripts/ethers-v4.min.js" type="text/javascript"></script>
<script charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.min.js" type="text/javascript"></script>
@ethcodex
ethcodex / mnemonic.js
Created May 9, 2018 01:41
Generate mnemonic from any hex number.
#!/usr/bin/env node
const assert = require('assert')
const Words = [
"like", "just", "love", "know", "never", "want", "time", "out", "there", "make", "look", "eye",
"down", "only", "think", "heart", "back", "then", "into", "about", "more", "away", "still", "them",
"take", "thing", "even", "through", "long", "always", "world", "too", "friend", "tell", "try", "hand",
"thought", "over", "here", "other", "need", "smile", "again", "much", "cry", "been", "night", "ever",
"little", "said", "end", "some", "those", "around", "mind", "people", "girl", "leave", "dream", "left",
@felixebert
felixebert / large-json-import.cypher
Created April 10, 2017 14:36
Import of large JSON file into neo4j using apoc
CALL apoc.periodic.iterate("
CALL apoc.load.json('file:///Users/f/source/companies.json')
YIELD value UNWIND value.rows AS row RETURN row
", "
MERGE (c:Company {id: row.id})
ON CREATE SET c.id = row.id, c.name = row.name
WITH row
UNWIND row.relatedPersons as item
MERGE (p:Person {id: item.person.id})
ON CREATE SET p.id = item.person.id, p.name = item.person.name