Skip to content

Instantly share code, notes, and snippets.

@quackingduck
Created November 9, 2008 07:28
Show Gist options
  • Save quackingduck/23220 to your computer and use it in GitHub Desktop.
Save quackingduck/23220 to your computer and use it in GitHub Desktop.
# 294 ids
$record_ids = %w[
08cxhp6j27ks 0f0vpxd8k26p 0fz6vv0f82h7 0gxjrgdb92v3 0q1p7g72ndr7 0tv2cn69fmhl 0wkfjr347x9k 0xls3bxgq713 0yzqx5d1d6ny 129rnw0f6fff 12j8pn66382p 18wc9f36y263 18z5rjbqhyfp 196n2gzy0zcv 1ckwnx3xn6h7 1dqlkf3zktff 1f3m0zrspypl 1jrs12cfvb9s 1s9yg3f31lg3 1v8jxbvpwv4r 1vs1jw0d350c 1wtp2lhk4m1w 23dxz3d226r9 23rzdyp7t5yg 23z4qvb51w0v 26cchgzz1s10 2cscvhb851zs 2dldd4zslgyb 2jsdl7fk5v1f 2k64kbngnbh4 2l9g33rv7bj1 2mjpdgm1q3lj 2r6tpybytkrk 2ysklrg6t6tw 333r38wr6mfh 34vznw64ly9f 398xpzwl14v3 3qw93q4zc0xt 3y3jb2v654q4 44gg6p6r1hsf 44sj8ncf2pdd 46vj967k2syj 4yrzrzz8qr73 5416rz057zqr 57d7sb1wv4wm 5jh6h5kmd4bv 5nwz0v7m00jj 5s1ywybwfky5 5vlbl1cypsyy 5vm3dkxm9d3s 607p62f0lq04 63ydbhqxy01l 65rfwz5v3frq 6nknp3m22smn 6vrdzsd3sqpg 6w2463ggyk3p 6x3qcgmzzyw6 73y4wcx73737 7f7r1728ksqt 7fsjpvmzp7l6 7q8cp08md59n 7zc2b1qzqzn3 826t80ndhkld 8ckc6qryxy3z 8h5rwltrhjw2 8qwnq22ftfc3 8vg08jcyq78b 95gw17jc8n9f 971m5v5zntrq 97p93f75dbkm 99l11hj22z5n 9cgfhs966x1h 9dgs3kg8dcp3 9gx16fyzq8lf 9ht3vmzry2x4 9kszflxm5gd7 9p305mx8hhrl 9rgqnjgzg21d 9ry7v4gffn09 9smvs94988t5 9xjp5bvvqdjv b1tc4l3gwvc9 b2jnp3jfy3gh b4bhwmjsmfc3 b60syztlgf9m b6dqzcnjbjqt b7g597x31xwx b9h6d4dv1rkr bfmgzrr0jvcg bkxn51qz7yhg blq6bnl4g8dz bndk9x4wv84r br7l349zcrl7 c08t99spxfxp c2qttdr9pmq2 c6v8kxsc12db ccgwbr2c3b1m ccxylrt38z8j cdpsspls4k6j clfbv1vmlc1b cqm1kj9cd4g1 cw5ljgp246mr d1jtxxlh3qkt d2wy9whcf3gj d3bdhcp314q9 d9w9364w00fl dbxp84w7b8ly dlfb2q0g7dnv dvdl99h1ll31 dwkpcckwjn83 dyqj02m04chh fdz1tdhnvqq9 fkmk6hywlbp0 fl3g9f1lvdjk fl93dym59gv9 fpvqcg5p1lly fwgj54k62823 g27bs4jv6sll g8z7n1gqtl31 gdfq1dm9nkln gjdtyn459ckh gsl29846sxrw h1nrgwzpn2f5 h421qfkgxvpy hfn71fn6w37z hgqsbpjdwx3h hk3ybkqbx21x hscb6gfs743d hvqd550fnm8h hxwfddcq08b2 j14jwv8mdk91 j5j215p2f76b j6dzb7m4v1zl j9q06l7z4vfm jbb4kjfghwk1 jbfjz1d8rydk js2h0n4gf2k1 jzd19n4x2w2t k3df2h65srls k5fk4t60mq08 k5lz8tv44lf8 k5r2l0bwt2zp k5rpnkdsxnqd k7h8zty6rl2q k85jmxr33tvm kb1t2jt8j2r7 kbvgt87tpvb6 kbvvhqz24qf4 kfl4p7j5q0jr kgr6k6mxv833 km1qk1fqxrgh ktwbbkfw3xlb kv69sfhxp5mp kvs64stcjlmf kzhm65h5wnww l037b0jxyfjv l0l10sbwpjvz l1579f6csns5 l4gw2ct1qjnq l65rvrwmkhb3 l9rf304b5jk2 lczq6c2bmtfy lrx5bg5x9pv2 lzp9476n1grq m023jr1p58h9 m55f5nx7mx8q m6v7xfwdpc7q m8d3rxvyf7nt m8zblzzhjp48 mfm2npnfdtb9 mkqthq8p8k4g mlhvqtjdpvq6 mmqtr97fkfs9 mpdb2mmdjfn2 mplx4px0r71b mwxgf998yjjf n45r47wwr0gz n4vndr7fdh70 n58rc439z372 ndg5v37t3d5l njl3ld8trryb nl3b5q67cflf nm1yz2wdtdc1 np8kdpcps09p nr9wnv6kjpdq nyffkflmc386 nz1kmr6c8grm p1ld3cmrsrh2 p372qhjprd3v p5yrphlnsr2y p7px8clj39xc pl0sq889z22z plnnjkkkn4pw pnrhk9cz7rlt psjc95xgqjfh pt1lfmb0t1n1 pthncjdp5qxy q0038mns422g q0g68fp1msd5 q1fpxvtq82rs q542drtsh88b q903rpfh7q4j qg72vrmpq289 qhx2lqhdm25l qs8j9q4sb7vc qsngfpq47f7l qtnj2w4vsqwt qw03wsz7ydpz r2h1h03xr8h6 r5y8044hgw0y rcqhttssz7ls rds7yr2qp1bz rklv8dg1dn3r rlml6gqn6qs9 rvc3sq1phjxg s5b726ld0mcj s706n783d5rc s880jzbt2p0f s8nl64q598mn scv2kj5ptl1w shy7h7z9xj46 st2b6y5hz7lv swxgrxgdqvtm szmd0fchjtbf t0mcvhjypypy t2hg5y4vtq0n t31n5gb1rbl5 t4hffb6f0900 t6xfgd9hwf32 tbfbys7rd1wm tz5s79fyfvyy v0fjsbyy3ygq v463pjll1prw v5n6qk6phybf v7tspqx3zqms v81hrjl8llrz vh4dypk5z6yc vkj1dqyhdmpw vl8vzlh4lmdb vqb0z3k62769 vynhjtl2mvm5 vyp4zx2dyzyp vzhy3gs1hyl7 w1ys2cjwhgg9 w244knqx8g0j w3w29mrxry38 w53hhm8c1tk7 w5bqg71n65v7 w5gvk1dls1x4 w7wlbkvkhpb9 whp7bfdvwnnm wkzp9rw5sd5x wp92jsnxmyxk wxm7qhmfcf6n wzy6c0jf3zs5 x84x3190yrnx x9gd1cxmf9jw xdbzx7wyyb7g xhvz6ptqqmcg xndf0509yg13 xpp5nkf0zss6 xqnpdkh8216d xr59plggsr8t xrdw2lq1k2gh xt9mtb2fbv5f xtlhzdtzpnd8 xvyn11skj7pr xxf5n167pdpn y1dgg1ktwxc2 y25qk4kz1cs7 y7112zhfbdvg y9h3r8pw3q5k y9kyrz25pj2t ydj62flv1q28 yfsr6xkhxvsq ylbphhyr889h ynhzhw3qv100 ytx1vmq9856f yw8ttswhghx9 yxts044fbckj yy72nc5szyb3 z27635cb19r9 z6r0s0c70h5n zbfqq36ckdk8 zch4zzjv2bg8 zf9ndg9xg1yb zgd2vp4qrh4y zpl2ql4d3dll zq22yj9ggd09 zqmkc2ds3t1f zstjy8r0ftsc zv1f4jlrxk0n zx95v9nmy4hd zz1r9dj2xmdr]
def record_ids; $record_ids; end
class String
def starts_with?(str)
str == self[0...str.size]
end
end
def shorten_id(full_id, try_length=1)
matches = record_ids.find_all { |id| id.starts_with? full_id[0...try_length] }
matches.size == 1 ? full_id[0...try_length] : shorten_id(full_id,try_length+1)
end
# takes roughly 2ms for each find
record_ids.each { |id|
p shorten_id(id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment