Skip to content

Instantly share code, notes, and snippets.

View zouzanyan's full-sized avatar
🌴
On vacation

zouzanyan zouzanyan

🌴
On vacation
  • 10:22 (UTC +08:00)
View GitHub Profile
@zouzanyan
zouzanyan / gist:3a3b7f4d1028ca3bb5bbcb4a72fd237f
Created May 26, 2026 03:53
chainlink中获取btc价格示例
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/*
Chainlink BTC/USD Price Feed
Network: Sepolia
*/
interface AggregatorV3Interface {
git config --global https.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
git config --global --unset http.proxy
git config --global --unset https.proxy
@zouzanyan
zouzanyan / git_proxy_switch.py
Created March 2, 2026 06:01
切换git 代理python脚本
#!/usr/bin/env python3
import subprocess
import sys
# 固定代理地址
PROXY = "http://127.0.0.1:10808"
def run(cmd):
result = subprocess.run(
@zouzanyan
zouzanyan / gist:025fb1de61af7b3e405e02c0ef24f881
Last active March 25, 2025 11:04
基于cow思想用无锁实现的线程安全的hashmap
public class CopyOnWriteHashMap<K, V> implements Map<K, V>, Cloneable {
private volatile Map<K, V> internalMap = new HashMap<>();
private static final Unsafe UNSAFE;
private static final long INTERNAL_MAP_OFFSET;
static {
try {
Field theUnsafeField = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafeField.setAccessible(true);
UNSAFE = (Unsafe) theUnsafeField.get(null);
@zouzanyan
zouzanyan / gist:688719924379cbe9050eaea581d1af83
Last active March 26, 2025 02:19
无锁实现的雪花算法
class SnowflakeIdGenerator {
// 起始时间戳 (2024-01-01 00:00:00)
private final long START_TIMESTAMP = 1704038400000L;
// 每部分占用位数
private final long SEQUENCE_BIT = 12; // 序列号占12位
private final long MACHINE_BIT = 5; // 机器ID占5位
private final long DATACENTER_BIT = 5; // 数据中心占5位
// 最大值