Skip to content

Instantly share code, notes, and snippets.

@bhardin
Last active August 29, 2015 14:02
Show Gist options
  • Save bhardin/29bdfb305c9cef49e0a7 to your computer and use it in GitHub Desktop.
Save bhardin/29bdfb305c9cef49e0a7 to your computer and use it in GitHub Desktop.
def group(cookies)
return @group if @group
current_set = set_size
i = 0
until @group
if seed <= current_set
@group = groups[i]
else
i += 1
current_set += set_size
end
end
@group
end
def set_size
(1 / @groups.length.to_f)
end
def seed
return @seed if @seed
srand sha
@seed = rand
end
def sha
@sha ||= Digest::SHA1.hexdigest(test_name + ab_cookie_value.to_s).to_i(16)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment