Not A Programming Joke

StackUp

StackUp was built by myself and two others at the Flatiron School as part of the ‘project mode’ portion of the curriculum.

StackUp allows you register an email address, and receive daily emails with questions the StackUp team has decided are suitable for newer developers. The questions are selected based on data provided by the Stack Overflow API and attempt to guarantee the following:

  • Each question must be appropriate to a new developer’s level of knowledge

  • Each question must not have been answered at the time the daily email is sent

  • While possible each user must receive a unique question from each other user so that users of StackUp don’t cannibalize their own opportunities to answer questions

  • While possible each user must only receive questions they have not previously been sent

StackUp is powered by an algorithm that tries to differentiate between “easy” and “hard” questions based on the tags appended to a question, the overall length of a question, and the proportion of a question that consists of code. The algorithm is based on the following assumptions:

  • Questions with a single, general tag (e.g., “Ruby”) are easier than questions with multiple, specific tags (e.g., “Ruby”, “Ruby on Rails”, “SQL”, “JavaScript”)

  • Short questions are easier than long questions

  • Questions with little code are easier than questions with lots of code

These assumptions, of course, do not always hold. Long questions with multiple tags and extensive code snippets may be resolved by a single line of code, while brief, code-less questions may harbor difficult questions on language design. Still, the algorithm has been relatively effective at identifying the small number of “easy” questions available on Stack Overflow at any given time. In the future, the StackUp team hopes to train a classifier algorithm with labeled examples to improve StackUp’s ability to deliver questions calibrated to a user’s preferred level of difficulty. StackUp is hosted on Heroku, Ruby on Rails powers the server side, JQuery helps to handle client side interactions, and GitHub’s omniauth service is used for user authentication and registration.

Find it on Github

Every blog needs a code snippet! So here is our User model:

  • it ensures new users have unique emails

  • it checks emails for acceptability using the private method email_check,

  • sends a welcome email after registration

  • connects the user to its questions through a join table, and sets the join table entries to be destroyed if the user is destroyed

  • defines a method create a new user using the GitHub’s OmniAuth response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class User < ActiveRecord::Base
  validates_uniqueness_of :email
  validate :email_check, on: :update

  after_create :send_welcome_email
  has_many :user_questions, dependent: :destroy
  has_many :questions, through: :user_questions

  def self.create_with_omniauth(auth)
    User.create(uid: auth["uid"], name: auth["info"]["name"], email: auth["info"]["email"])
  end

private

  def email_check
    if !email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/)
      errors.add(:email, "Please enter a valid email address.")
    end
  end

  def send_welcome_email
    UserMailer.send_welcome_email(self).deliver
  end

end