Skip to content

Instantly share code, notes, and snippets.

View qiwihui's full-sized avatar
🦉
Focusing

qiwihui qiwihui

🦉
Focusing
View GitHub Profile
@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);
}
@Flouse
Flouse / rgbpp-simple-guilde.md
Last active October 17, 2024 09:52
Simple Technical Guide for RGB++ Development
Error Code
(as uint256 hex number)
Description
0x00 Used for generic compiler inserted panics.
0x01 If you call assert with an argument that evaluates to false.
0x11 If an arithmetic operation results in underflow or overflow outside of an unchecked { ... } block.
0x12 If you divide or modulo by zero (e.g. 5 / 0 or 23 % 0)
0x21 If you convert a value that is too big or negative into an enum type.
0x22 If you access a storage byte array that is incorrectly encoded.
0x31 If you call .pop() on an empty array.
0x32 If you access an array, bytesN or an array slice at an out-of-bounds or negative index (i.e. x[i] where i &gt;= x.length or i &lt; 0).
@itherunder
itherunder / readme.md
Last active April 13, 2022 09:12
修改png并应用到obj与voxel
  • 经查明,发现大狗老师应该是导出时出问题了,所以没有得到这个mtl文件,但这个mtl文件也很简单,直接添加一个即可
newmtl palette
illum 1
Ka 0.000 0.000 0.000
Kd 1.000 1.000 1.000
Ks 0.000 0.000 0.000
map_Kd monu1.vox.png # 可以换成其他图片。
from operator import mul, add
from functools import reduce
def chinese_remainder_theorem(tuple):
transpose = list(zip(*tuple))
product = reduce(mul, transpose[0])
min_result = reduce(add, [
j * l *(l%i) for i,j in tuple for l in [reduce(mul, [k for k in transpose[0] if k != i])]
]) % product
print("The value is: %s + n * %s which n = 0..inf" % (min_result, product))
return min_result, product
@karmacoma-eth
karmacoma-eth / sending-ether-cheat-sheet.md
Last active August 22, 2024 17:07
Sending Ether Cheat Sheet

Sending Ether Cheat Sheet

TLDR

🥇 Instead of sending Ether, use the withdrawal pattern

🥈 If you really need to send Ether, use a safe wrapper like OpenZeppelin's Address.sendValue(addr, amount)

🥉 If you really need to send Ether without dependencies, use (bool success, ) = addr.call{value: amount}("")

@michalc
michalc / sqlite.py
Last active April 3, 2024 17:26
Use libsqlite3 directly from Python with ctypes: without using the built-in sqlite3 Python package, and without compiling anything
# From https://stackoverflow.com/a/68876046/1319998, which is itself inspired by https://stackoverflow.com/a/68814418/1319998
from contextlib import contextmanager
from collections import namedtuple
from ctypes import cdll, byref, string_at, c_char_p, c_int, c_double, c_int64, c_void_p
from ctypes.util import find_library
from sys import platform
def query(db_file, sql, params=()):
@MineRobber9000
MineRobber9000 / donotuse3.py
Last active February 8, 2024 12:48
How to NEVER use lambdas - Python 3 edition
###########################################################
# How to NEVER use lambdas. An inneficient and yet educa- #
# tonal [sic] guide to the proper misuse of the lambda #
# construct in Python 3.x. [DO NOT USE ANY OF THIS EVER] #
# original by (and apologies to): e000 (13/6/11) #
# now in Python 3 courtesy of: khuxkm (17/9/20) #
###########################################################
## Part 1. Basic LAMBDA Introduction ##
# If you're reading this, you've probably already read e000's
@jonhoo
jonhoo / cell-tests.rs
Last active November 14, 2024 08:42
cell-refcell-rc
// these aren't _quite_ functional tests,
// and should all be compile_fail,
// but may be illustrative
#[test]
fn concurrent_set() {
use std::sync::Arc;
let x = Arc::new(Cell::new(42));
let x1 = Arc::clone(&x);
std::thread::spawn(move || {

My GitHub Feature Wishlist for 2020

I use GitHub nearly every day. In general, it's delightful to use and I've been impressed with the rapid pace of improvements, especially as of late.

That said, there's a handful of features that would have a big impact on my day-to-day experience. I'm cataloging them here with the aim of increasing visibility and prompting further discussion.

Disclaimer: It is not my intention that any visual designs be taken literally – I only hope that they may serve as useful source of inspiration.

1. Releases in commit list view