Skip to content

Instantly share code, notes, and snippets.

@kolyasapphire
Created March 8, 2023 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolyasapphire/146d90fc7e21e8459c68448a263c1819 to your computer and use it in GitHub Desktop.
Save kolyasapphire/146d90fc7e21e8459c68448a263c1819 to your computer and use it in GitHub Desktop.
Urbit repeating id parts finder
type Star = {
point: number
patp: string // '~havrun-hasnum'
is_listed: boolean
ship_type: string // 'planet'
unbooted: boolean
time_listed: string
time_added: string
price_int: number
child_points: number
unspawned: boolean
currency: string // "ETH"
price_usd: null
price_eth: number
urbitex_contract: null
removed_by_exchange: null
}
const params = new URLSearchParams({
type: 'planet',
price_min: '0',
price_max: '10000000', // 0.01 ETH
unbooted: '1',
sort_order: '-point',
unspawned: '1',
})
const req = await fetch(
'https://urbitex.io:8000/get_listed_ships?' + params.toString()
)
const res = await req.json()
for (const x of res.data as Star[]) {
const halves = x.patp.replace('~', '').split('-')
const parts = halves.flatMap((x) => x.match(/.{1,3}/g)!)
if (parts[0] === parts[2] || parts[1] === parts[3]) {
console.log(
`https://urbitex.io/ship/~${parts[0] + parts[1]}-${parts[2] + parts[3]}`
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment