Skip to content

Instantly share code, notes, and snippets.

View jac18281828's full-sized avatar
🦌

John Cairns jac18281828

🦌
View GitHub Profile
@jac18281828
jac18281828 / tokens.yaml
Created April 9, 2025 19:13
Two get tokens
- blockchain: MegaETH
network: megaeth-testnet
name: Wrapped Ether
symbol: WETH
address: "0x776401b9bc8aae31a685731b7147d4445fd9fb19"
decimals: 18
atom: 1000000000000000000
- blockchain: MegaETH
network: megaeth-testnet
name: AWE
@jac18281828
jac18281828 / GTELauncher.sol
Last active April 9, 2025 17:01
GTERouter.sol – what I know so far
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
interface GTELauncher {
function BASE_SCALING() external view returns (uint256);
function BONDING_SUPPLY() external view returns (uint256);
function LAUNCH_FEE() external view returns (uint256);
function QUOTE_SCALING() external view returns (uint256);
function TOTAL_SUPPLY() external view returns (uint256);
function bondingCurve() external view returns (address);
@jac18281828
jac18281828 / Dockerfile
Created April 2, 2025 15:37
Dockerimage to build a Python 3.11.9 optimized binary using manual build and compilation
# Stage 1: Build yamlfmt
FROM golang:1 AS go-builder
# defined from build kit
# DOCKER_BUILDKIT=1 docker build . -t ...
ARG TARGETARCH
# Install yamlfmt
WORKDIR /yamlfmt
RUN go install github.com/google/yamlfmt/cmd/[email protected] && \
strip $(which yamlfmt) && \
@jac18281828
jac18281828 / jinja_perf.py
Created March 13, 2025 15:51
Jinja performance test
""" simple jinja performance sanity check """
from jinja2 import Template
import time
query = """
-- fetch token from db
-- param
-- 1: user_id
@jac18281828
jac18281828 / ide.md
Last active February 26, 2025 15:22
The major races of Middle-earth and the IDE they would use to write their code

Here’s a table listing the major races of Middle-earth and the IDE they would use for writing their code:

Race Preferred IDE
Elves NeoVim (elegant & precise)
Men VS Code (widely used, adaptable)
Dwarves CLion (sturdy & reliable)
Hobbits Sublime Text (lightweight, cozy)
Orcs Notepad++ (raw, brutal efficiency)
Uruk-hai Eclipse (powerful, but rigid)
@jac18281828
jac18281828 / database_persistence.py
Created January 22, 2025 18:49
Postgres persistence in python telegram bot
"""Implements telegram bot persistence using PostgreSQL (Amazon Aurora Serverless)"""
# pass statements below are placeholders for unused but abstract methods
# pylint: disable=unnecessary-pass
# WARNING: this module is not checked for types - this is heavily depended on DictPersistence provided
# by python-telegram-bot library. This is a workaround to use PostgreSQL as a persistence backend.
# The provided code has some mypy issues but fixing them would depart significantly from the original
# mypy: ignore-errors
@jac18281828
jac18281828 / conversationbot.py
Last active January 21, 2025 16:55
Conversation Bot Example .. gist
import asyncio
import sys
import logging
from telegram import Update, ReplyKeyboardMarkup, ReplyKeyboardRemove
from telegram.ext import CommandHandler, ContextTypes, ConversationHandler, MessageHandler, filters, ApplicationBuilder
TOKEN: str = "TOKEN"
BOT_USERNAME: str = "TOKEN"
@jac18281828
jac18281828 / eventjson.py
Created January 17, 2025 17:12
decode an aws lambda log event in python
import json
datastruct = json.loads(open("event/startnew.json").read())
datastruct = json.loads(datastruct)
print(json.dumps(datastruct, indent=4))
@jac18281828
jac18281828 / encrypt.py
Created January 16, 2025 01:10
aes encryption written with cryptography python
"""Encode and decode a message using AES encryption."""
from typing import Optional, Tuple
import secrets
import struct
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.backends import default_backend
@jac18281828
jac18281828 / derive_key.py
Last active January 14, 2025 01:21
generate bip44 (ethereum) key using bip_utils
from bip_utils import Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44, Bip44Changes, Bip44Coins
ADDR_NUM: int = 5
# Generate random mnemonic
mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_24)
print(f"Mnemonic string: {mnemonic}")
# Generate seed from mnemonic
passphrase = "PASSPHRASE"
seed_bytes = Bip39SeedGenerator(mnemonic).Generate(passphrase)