Skip to content

Instantly share code, notes, and snippets.

@joe11051105
Last active December 29, 2016 02:40
Show Gist options
  • Save joe11051105/ede29870ad1819e8ec181307d65f7928 to your computer and use it in GitHub Desktop.
Save joe11051105/ede29870ad1819e8ec181307d65f7928 to your computer and use it in GitHub Desktop.

Part1 Software Engineering Basics

  • How to create a Git remote branch? And how to delete it?
  • What is git rebase and how can it be used to resolve conflicts in a feature branch before merge?
  • What is Git Flow and GitHub Flow ? Briefly describe how it works.

Part2 Web Development Basics

  • List at least 3 HTTP response codes, and describe their meanings.
  • What is JSON format? What are the benefits of using it?
  • When you click a link that directs to https://www.google.com/ , what would happen between the browser and the server? Please describe as much detail as you know.

Part3 Ruby on Rails

  • Suppose that there is a resources :posts line in routes.rb , list all the 7 CRUD actions in the PostsController, and describe what they should do.
  • Given an action controller in Rails as follows, what are the differences between statement (1) and (2)?
class   PostsController  <  ApplicationController  
  def show
    @length = 10_000  # (1)
    length  = 10_000  # (2)  
  end
end
  • Given an action controller in Rails as follows, what are the differences between redirect_to (1) and render (2)?
class UsersController  <  ApplicationController  
  def create
    @user = User.new(name : 'Joe', age: 31)  
    if @user.save
      redirect_to root_path  # (1)  
    else
      render :new  # (2)  
    end
  end
 end
  • The method authenticate_user! will be used in all actions but index action, how do you modify the below code snippet?
before_action :authenticate_user!
  • What’s the problem with the following statement? How would you fix it?
Post.where ("id = #{params[:post_id]}")
@aidanSoles
Copy link

Q1:
Part 1: To create a remote you type (assuming you have checked out the branch):
git push -u <remote_name> <local_branch>
To delete a remote:
git push origin --delete
Part 2: Git rebase is, to my understanding, a way to replicate commits from one branch on another branch. This can help resolve conflicts in a feature branch before a merge because the branch being rebased will have the most recent master commits.
Part 3: From what I can gather, Git Flow and GitHub Flow are both branching based development strategies using GitHub. The basis of these strategies is branching, followed by a commit, then a pull request, then testing/deployment. Once the branch is successfully deployed, you merge with master.

Q2:
Part 1: 100 is "Continue"--this means that the user has sent the appropriate request headers and should now send the request body. 101 is "Switching Protocols"--this means that the user had requested a protocol switch. 102 is "Processing"--this means that the server is processing the request.
Part 2: JSON stands for "JavaScript Object Notation". JSON is an easy to read and easy to parse data interchange format. In my opinion, the formatting is more intuitive than XML. Some of the benefits are: easy to read/parse, it is lightweight, and it is intuitive.
Part 3: From what I can gather, the steps are as follows:
1. The browser finds the IP address for the website.
2. The browser sends an https request to the server.
3. The website sends a redirect which is followed by the browser.
4. The server handles the request(s) made by the browser.
5. An html response is sent back and rendered.
6. The browser continues to send responses for html/ajax requests.

Q3:
Part 1:
posts#index Displays the list of all posts.
posts#new Returns an html form for creating a new post.
posts#create Creates a new post.
posts#show Displays a specific post.
posts#edit Returns an html form for editing a post.
posts#update Updates a specific photo.
posts#destroy Deletes a specific photo.
Part 2: (1) alters the instance variable on the class, which stores a value on a class that is common to only that class. For (2), I'm not really sure what it does, since it is not addressing an instance variable or a class variable. My best guess is that if there is a length variable in the former scope, it alters that.
Part 3: "redirect_to" will reply to a request by redirecting the ApplicationController to a URL. "render" will render an html view.
Part 4: My best guess is the following:
skip_before_action : require_login!, :except => [:index]
Part 5: Unfortunately, I did not have time for this question.

@aidanSoles
Copy link

Thanks Joe! Let me know what you think. I'll be in touch tomorrow.

@joe11051105
Copy link
Author

Q3 Ans:

Part4

skip_before_action :authenticate_user!, only: [:index]

Part5

Post.where(id: params[:post_id])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment