Skip to content

Instantly share code, notes, and snippets.

@AquaGeek
Last active May 6, 2019 01:38
Show Gist options
  • Select an option

  • Save AquaGeek/4566236 to your computer and use it in GitHub Desktop.

Select an option

Save AquaGeek/4566236 to your computer and use it in GitHub Desktop.
Ruby
# Cleaner invocation of presenter on collection
current_user.tickets.map(&TicketPresenter.method(:new))
Digest::MD5.hexdigest("#{SecureRandom.hex(10)}-#{DateTime.now.to_s}") # Doesn't SecureRandom already seed with time?
# http://blog.logeek.fr/2009/7/2/creating-small-unique-tokens-in-ruby
rand(36**8).to_s(36)
# From Ryan Bates (http://railscasts.com/episodes/124-beta-invitations)
Digest::SHA1.hexdigest([Time.now, rand].join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment