Skip to content

Instantly share code, notes, and snippets.

View bczhc's full-sized avatar
🌴

Zhai Can bczhc

🌴
  • Jiangsu, China
  • 21:35 (UTC +08:00)
  • X @bczhc0
View GitHub Profile
@bczhc
bczhc / a.rs
Created December 4, 2024 14:44
找不到恐龙Unicode,啊啊念头不通达,好难受。
use hex_literal::hex;
use image::{DynamicImage, GenericImageView, Pixel};
use rayon::prelude::*;
use std::fs;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
@bczhc
bczhc / InputFormOfOutput.wl
Created December 2, 2024 03:49
Wolfram将四维超立方体旋转后投影到三维
Manipulate[Module[{tFn$, edges3d$, newEdges$},
tFn$ = Module[{rotated$}, rotated$ = rotate4D[#1, {{x\[Alpha], x\[Beta], x\[Gamma]}, {y\[Alpha], y\[Beta], y\[Gamma]}, {z\[Alpha], z\[Beta], z\[Gamma]}, {w\[Alpha], w\[Beta], w\[Gamma]}}];
perspectiveProject4[rotated$ - {cx, cy, cz, cw}, d]] & ; newEdges$ = ({tFn$[#1[[1]]], tFn$[#1[[2]]]} & ) /@ edges;
Graphics3D[{Thickness[Large], (Line[#1] & ) /@ newEdges$}, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}*Sqrt[1 + 1 + 1 + 1]]], {x\[Alpha], 0, 2*Pi},
{x\[Beta], 0, 2*Pi}, {x\[Gamma], 0, 2*Pi}, {y\[Alpha], 0, 2*Pi}, {y\[Beta], 0, 2*Pi}, {y\[Gamma], 0, 2*Pi}, {z\[Alpha], 0, 2*Pi}, {z\[Beta], 0, 2*Pi}, {z\[Gamma], 0, 2*Pi}, {w\[Alpha], 0, 2*Pi},
{w\[Beta], 0, 2*Pi}, {w\[Gamma], 0, 2*Pi}, {{cx, 0}, -10, 10}, {{cy, 0}, -10, 10}, {{cz, 0}, -10, 10}, {{cw, 5.65}, -10, 10}, {{d, 5.59}, 0.1, 10},
Initialization :> {rotate4D[p_, {x_List, y_List, z_List, w_List}] := Module[{m1, m2, m3, m4}, m1 = r4x /. {\[Alpha] -> x[[1]], \[Beta] -> x[[2]], \[Gamma] -> x[[3]]
@bczhc
bczhc / a.md
Last active December 2, 2024 02:02
几种生物的演化树(来源:中文维基百科Taxonomy模板)

1

  • 麻雀
  • 风神翼龙
  • 棘龙
  • 智人
  • 灰长臂猿
  • 眼镜猴
  • 日本真鲈
  • 紫纹海刺水母
@bczhc
bczhc / a.md
Last active December 2, 2024 02:00
合并生物分类lineage并使用Wolfram绘制演化树

合并

创建文件lineage.txt,格式如下:

[域]真核域
[演化支]单鞭毛生物
[演化支]OBA 超类群
[演化支]后鞭毛生物
[总界]动物总界
@bczhc
bczhc / 3.rs
Last active November 20, 2024 08:37
返回一个大迭代器
use bigdecimal::num_traits::ops::overflowing::OverflowingAdd;
use rand::{thread_rng, RngCore};
use std::iter::{Map, Sum};
use std::ops::Add;
pub struct OverflowingAddWrapper<T: OverflowingAdd>(pub T);
impl<T: OverflowingAdd> From<T> for OverflowingAddWrapper<T> {
fn from(value: T) -> Self {
Self(value)
@bczhc
bczhc / a.md
Created November 13, 2024 12:02
Countdown latch in Rust #rust
@bczhc
bczhc / a.rs
Last active November 15, 2024 02:02
前n个斐波那契数的平均为整数 #fibonacci #math
use bigdecimal::num_traits::Euclid;
use bigdecimal::{ToPrimitive, Zero};
use num_bigint::BigUint;
fn main() {
let mut sum = BigUint::ZERO;
let mut fib_fn = |n: &BigUint, fib: &BigUint| {
// println!("{n} {fib}");
sum += fib;
@bczhc
bczhc / a.rs
Created November 6, 2024 17:25
Bitcoin OP_RETURN messages: write to SQLite database #bitcoin
use bitcoin::{OutPoint, Script};
use bitcoin_demo::{extract_op_return, han_char, new_parser, EncodeHex};
use chrono::TimeZone;
use rusqlite::{params, Connection};
fn main() {
let mut db = Connection::open("./op-return-messages.db").unwrap();
db.execute(
r#"create table if not exists op_return_msg
(
@bczhc
bczhc / a.md
Last active November 6, 2024 17:32
Fetch image inscribed on Bitcoin chain using OP_RETURN #bitcoin

https://gist.github.com/bczhc/0d985a8a6864d9bcb8e1d060f0fd25dd 看到一个有意思的,有位用户在链上通过OP_RETURN放入了一张AVIF图片。

https://mempool.space/address/bc1q3ez0mu6q3y59emtl2nweeevnhu7ualvu3ylapp

其中OP_RETURN内容为可打印文本的两条交易为:

@bczhc
bczhc / a.rs
Created November 4, 2024 08:57
Bitcoin: reward back to the sender! #bitcoin
#![feature(yeet_expr)]
use crate::reward::LocalStorage;
use bitcoin::{Amount, Network, OutPoint, ScriptBuf, TestnetVersion};
use bitcoin_hashes::Hash;
use bitcoincore_rpc::{Auth, Client, RpcApi};
use log::{debug, info};
use once_cell::sync::Lazy;
use std::io;
use std::ops::AddAssign;