Skip to content

Instantly share code, notes, and snippets.

@knwang
Last active August 29, 2015 14:26
Show Gist options
  • Save knwang/99556a6b97f49f88013c to your computer and use it in GitHub Desktop.
Save knwang/99556a6b97f49f88013c to your computer and use it in GitHub Desktop.

Ruby and General Programming:

  • What is a class? What is an object? What are the differences in Ruby?

  • Are instance variables available to class methods?

  • What are the differences between blocks, procs and lambdas in Ruby?

  • Write a method that sorts the keys in a hash by the length of the key as a string. For instance, the hash:

    { abc: 'hello', 'another_key' => 123, 4567 => 'third' }

    should result in:

    [ "abc", "4567", "another_key" ]
  • Write a function to return the Nth number of Fibonacci sequence.

  • Write a method that returns if a string is a palindrome. For example, "racecar" is a palindrome but "apple" is not.

    def palindrome?(string)
    end
  • Pangrams are sentences constructed by using every letter of the alphabet at least once. For example, this sentence "The quick brown fox jumps over the lazy dog" is a pangram. Write a method that given a string, it tells if it is a pangram.

  • Find all job postings with the word "Ruby" in it from here: https://news.ycombinator.com/item?id=9996333

Web:

  • What happens when you type "www.google.com" into your browser? Give me as much details as possible
  • Tell me some HTTP headers in HTTP request and response
  • What does "Cross Site Scripting" mean?

SQL/DB:

  • what are the 4 basic commands of SQL? What do they do?
  • what is a join? what are differnet types of SQL joins?
  • what is an index? what does it do?
  • what is a foreign key? what does it do?

Rails

  • What are Rails helpers? Why would you use them?

  • What is "SQL Injection"?

  • Explain how Rails handles an incoming request

  • What's the difference between render vs redirect

  • what's "Strong Parameters"?

  • What's the issue with the controller code below? How would you fix it?

    class CommentsController < ApplicationController
      def users_comments
        posts = Post.all
        comments = posts.map(&:comments).flatten
        @user_comments = comments.select do |comment|
          comment.author.username == params[:username]
        end
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment