As configured in my dotfiles.
start new:
tmux
start new with session name:
As configured in my dotfiles.
start new:
tmux
start new with session name:
This document is written to help JavaScript developers to understand JavaScript's weird parts deeply and to prepare for interviews, the following resources was really helpful to write this document:
| class Hash | |
| def nested_each_pair | |
| self.each_pair do |k,v| | |
| if v.is_a?(Hash) | |
| v.nested_each_pair {|k,v| yield k,v} | |
| else | |
| yield(k,v) | |
| end | |
| end |
| class ApiController < ApplicationController | |
| skip_before_action :verify_authenticity_token | |
| respond_to :json | |
| rescue_from UserAuthenticationService::NotAuthorized, with: :not_authorized | |
| rescue_from ActiveRecord::RecordNotFound, with: :not_found | |
| before_filter :api_session_token_authenticate! | |
| private | |
| def signed_in? |
| require 'rails_helper' | |
| RSpec.describe TodosController, :type => :controller do | |
| describe "GET #index" do | |
| #describe "POST #create" do | |
| #describe "GET #show" do | |
| #describe "PATCH #update" do (or PUT #update) | |
| #describe "DELETE #destroy" do | |
| #describe "GET #new" do |
| # install openjdk | |
| sudo apt-get install openjdk-7-jdk | |
| # download android sdk | |
| wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz | |
| tar -xvf android-sdk_r24.2-linux.tgz | |
| cd android-sdk-linux/tools | |
| # install all sdk packages |
Imagine we have a book model and chapter model. Both models have attributes that needs to have sanitized html. We use a gem called sanitizer to sanitize the text. Now how would you refactor this code to be more DRY and scalable? Bonus: How would you test this?
| class API::V1::BaseController < ApplicationController | |
| skip_before_filter :verify_authenticity_token | |
| before_filter :cors_preflight_check | |
| after_filter :cors_set_access_control_headers | |
| def cors_set_access_control_headers | |
| headers['Access-Control-Allow-Origin'] = '*' | |
| headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |