Skip to content

Instantly share code, notes, and snippets.

@631068264
Last active April 1, 2026 18:59
Show Gist options
  • Select an option

  • Save 631068264/c5b085382e30828c00b9a696fec90c16 to your computer and use it in GitHub Desktop.

Select an option

Save 631068264/c5b085382e30828c00b9a696fec90c16 to your computer and use it in GitHub Desktop.
Specify Caude code buddy userID
#!/usr/bin/env node
// buddy-reroll-node.js
const crypto = require('crypto')
const SALT = 'friend-2026-401'
const SPECIES = ['duck','goose','blob','cat','dragon','octopus','owl',
'penguin','turtle','snail','ghost','axolotl','capybara','cactus',
'robot','rabbit','mushroom','chonk']
const RARITIES = ['common','uncommon','rare','epic','legendary']
const RARITY_WEIGHTS = { common:60, uncommon:25, rare:10, epic:4, legendary:1 }
const RARITY_RANK = { common:0, uncommon:1, rare:2, epic:3, legendary:4 }
function mulberry32(seed) {
let a = seed >>> 0
return function() {
a |= 0; a = (a + 0x6d2b79f5) | 0
let t = Math.imul(a ^ (a >>> 15), 1 | a)
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
}
}
function hashString(s) {
// return Number(BigInt(Bun.hash(s)) & 0xffffffffn)
let h = 2166136261
for (let i = 0; i < s.length; i++) {
h ^= s.charCodeAt(i)
h = Math.imul(h, 16777619)
}
return h >>> 0
}
function pick(rng, arr) { return arr[Math.floor(rng() * arr.length)] }
function rollRarity(rng) {
let roll = rng() * 100
for (const r of RARITIES) { roll -= RARITY_WEIGHTS[r]; if (roll < 0) return r }
return 'common'
}
const TARGET = process.argv[2] || 'duck'
const MAX = parseInt(process.argv[3]) || 500000
let best = { rarity: 'common', uid: '' }
for (let i = 0; i < MAX; i++) {
const uid = crypto.randomBytes(32).toString('hex')
const rng = mulberry32(hashString(uid + SALT))
const rarity = rollRarity(rng)
const species = pick(rng, SPECIES)
if (species === TARGET && RARITY_RANK[rarity] > RARITY_RANK[best.rarity]) {
best = { rarity, uid }
console.log(`found: ${rarity} ${species} -> ${uid}`)
if (rarity === 'legendary') break
}
}
console.log(`\nBest: ${best.rarity} ${TARGET} -> ${best.uid}`)
@631068264

631068264 commented Apr 1, 2026

Copy link
Copy Markdown
Author
node node_pet.js duck 500000
found: uncommon duck -> d46874661d8e45167f33dc1b16e2c41a00f85d99a42e31dac6793c649d7597e8
found: rare duck -> 69af711a9db198e29227b47bc5ec6908714dc0a6da00deb5e40e63e6c6601577
found: epic duck -> ebbc1c6988fb4b4305107ce69d81f378e28008d73ae423a8fa069f0d5b0ce8d2
found: legendary duck -> 943d202962d42169614f253798c68cf8eb3cb6693665d94b047cd6628ac48d0a

Best: legendary duck -> 943d202962d42169614f253798c68cf8eb3cb6693665d94b047cd6628ac48d0a

把刷到的 userID 写进 ~/.claude.json(确保 companion 字段已删除),重启后 /buddy 领取即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment