This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question | |
How can the code below be refactored into one line? | |
arr = [2,3,4,5] | |
arr *= 4 | |
arr.shuffle | |
# Answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#If you define a method does it create a scope within itself? Don't any variables or methods used within a method need to be passed in as arguments? | |
#Here's an example | |
name = "Frank" | |
def say_hello(n) | |
def hello_method | |
"hello" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action@tealeaf-115616:~(master*)$ heroku login | |
/home/action/.parts/packages/heroku_toolbelt/3.5.0/lib/heroku/updater.rb:164:in `spawn': Permission denied - open (Errno::EACCES) | |
from /home/action/.parts/packages/heroku_toolbelt/3.5.0/lib/heroku/updater.rb:164:in `background_update!' | |
from /home/action/.parts/packages/heroku_toolbelt/3.5.0/lib/heroku/updater.rb:144:in `inject_libpath' | |
from /home/action/.parts/bin/heroku:19:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//get the arrays for US states, Canadian Provences, and both | |
// the array names are $us_states, $canadian_provences, $state_array | |
require('state_list.php'); | |
// create an <option> list | |
// | |
// takes in a $key => $value array and the name of the <select> element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "finds no matches from search" do | |
expect(Video.search_by_title('family')).to eq(nil) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe VideosController do | |
describe "GET show" do | |
it "sets the requested video to @video" do | |
video = Video.create(title: "Game of Thrones", description: "A very awesome show!") | |
get :show, id: video.id | |
assigns(:video) == video | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VideosController < ApplicationController | |
before_action :require_user | |
def show | |
@video = Video.find(params[:id]) | |
end | |
def search | |
@search_phrase = params[:search_term] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def total_time_on_job | |
total = 0 | |
self.punches.each do |punch| | |
if punch.punch_out | |
punch_in_time = punch.created_at | |
punch_out_time = punch.punch_out | |
total_time = punch_out_time - punch_in_time | |
total += total_time | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
if the_customer_is_missing | |
@notification.errors[:base] << "Please choose a customer or add a new one." | |
render :index | |
elsif a_new_customer_is_being_added | |
if @customer.valid? | |
send_text_if_notification_and_customer_valid! | |
else | |
@notification.errors.clear | |
render :index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('#individual-notification .notification-container').hide(); | |
$('#individual-notification .header-box').on('click', function(){ | |
$('#individual-notification .notification-container').slideToggle(); | |
}); | |
}); |
OlderNewer