<commit_before># == Schema Information
#
# Table name: users
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  email      :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  alias      :string(255)
#

class User < ActiveRecord::Base
  attr_accessible :email, :name, :alias, :password, :password_confirmation
  # Not sure if we need to store password_confirmation
  has_secure_password
  
  before_save do |user|
    user.email = user.email.downcase
    user.alias = user.alias.downcase
  end
  before_save :create_remember_token
  
  validates :name, presence: true, length: { maximum: 50 }
  
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true,
                    length: { maximum: 50 },
                    format: { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  
  VALID_ALIAS_REGEX = /\A[a-z]+\w*\z/i
  validates :alias, presence: true,
                    length: { minimum: 5, maximum: 20 },
                    format: { with: VALID_ALIAS_REGEX },
                    uniqueness: { case_sensitive: false }
  
  validates :password, presence: true, length: { minimum: 6 }
  validates :password_confirmation, presence: true

  def friendly_link
    # Should we cache or DB this? 
    # No need to store in db if it is repeat of alias
    Rails.application.routes.url_helpers.users_path + '/' + self.alias
  end 

  private
  
  def create_remember_token
    #self.remember_token = SecureRandom.urlsafe_base64
    seed = "--#{rand(10000)}--#{Time.now}--"
    self.remember_token = Digest::SHA1.hexdigest(seed)
  end
end<commit_msg>added comment<commit_after># == Schema Information
#
# Table name: users
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  email      :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  alias      :string(255)
#

class User < ActiveRecord::Base
  attr_accessible :email, :name, :alias, :password, :password_confirmation
  # Not sure if we need to store password_confirmation
  has_secure_password
  
  before_save do |user|
    user.email = user.email.downcase
    user.alias = user.alias.downcase
  end
  before_save :create_remember_token
  
  validates :name, presence: true, length: { maximum: 50 }
  
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true,
                    length: { maximum: 50 },
                    format: { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  
  VALID_ALIAS_REGEX = /\A[a-z]+\w*\z/i
  validates :alias, presence: true,
                    length: { minimum: 5, maximum: 20 },
                    format: { with: VALID_ALIAS_REGEX },
                    uniqueness: { case_sensitive: false }
  
  validates :password, presence: true, length: { minimum: 6 }
  validates :password_confirmation, presence: true

  def friendly_link
    # Should we cache or DB this? 
    # No need to store in db if it is repeat of alias
    Rails.application.routes.url_helpers.users_path + '/' + self.alias
  end 

  private
  
  def create_remember_token
    #self.remember_token = SecureRandom.urlsafe_base64
    # Possibly more secure/random
    seed = "--#{rand(10000)}--#{Time.now}--"
    self.remember_token = Digest::SHA1.hexdigest(seed)
  end
end
{'fraction_non_alphanumeric': 0.11220930232558139, 'fraction_numerical': 0.014534883720930232, 'mean_word_length': 2.479271991911021, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4779104', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1098, 'n_words': 279}