This file contains hidden or 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
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# Note that this schema.rb definition is the authoritative source for your | |
# database schema. If you need to create the application database on another | |
# system, you should be using db:schema:load, not running all the migrations | |
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
# you'll amass, the slower it'll run and the greater likelihood for issues). | |
# |
This file contains hidden or 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 AddAdminFlagToUsers < ActiveRecord::Migration[5.1] | |
def change | |
add_column :users, :admin, :boolean, default: false, null: false | |
end | |
end |
This file contains hidden or 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
# ends the game | |
def end_game | |
puts "\nBye!" | |
end | |
# the game which recursively calls itself until user presses "X" to call end_game and finish the game | |
def game | |
puts "==============================\nPlease choose one from the following:\n(R) Rock\n(P) Paper\n(S) Scissors\n(X) End game\n\n" | |
user_turn = gets.chomp.capitalize! | |
if user_turn != "R" && user_turn != "P" && user_turn != "S" && user_turn != "X" |
This file contains hidden or 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
str.is_a?(Object) | |
str.class | |
# here we extend Ruby's string class meaning that all strings in the environment will belong to this class | |
class String | |
def star | |
self + " *" | |
end | |
end |
This file contains hidden or 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 Cat | |
attr_reader :color, :breed, :name | |
# There is no need for a separate attr_writer and separate attr_reader for name because attr_accessor can combine those methods into one (DRY) | |
# attr_writer :name | |
attr_accessor :name | |
def initialize(color, breed) | |
@color = color # Instances variables are available to other methods inside of this class. This is unlike local variables, which only exist inside the method they're called in. | |
@breed = breed | |
@hungry = true |
This file contains hidden or 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 fav_foods | |
food_array = [] | |
3.times do | |
puts "Name a favorite food." | |
food_array << gets.chomp | |
end | |
food_array.each do |food| # do something to each element in food array; that element is to be referred to as food | |
puts "I like #{food} too!" # the thing we're doing | |
end # ends the loop | |
p food_array |
This file contains hidden or 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 true | |
puts "this is true" | |
else | |
puts "this is false" | |
end |
This file contains hidden or 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 greeting | |
puts "Please enter your name:" | |
name = gets.chomp | |
puts "Hello " + "" + name | |
end | |
greeting |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Calculator</title> | |
<link rel='stylesheet' href='http://d33wubrfki0l68.cloudfront.net/css/ebe0759bf259b6caeadee6137973481046ac5636/css/normalize.css'/> | |
<link rel="stylesheet" href="css/styles.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
This file contains hidden or 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
<!-- ******* in the faq section, if you stare at it for a while, it suddenly changes colors slightly. debug it. in fact, the entire page seems to shift slightly. i think all the carousel images have to be the same size (especially height)--> | |
<!DOCTYPE html><!-- Instructs browser what version of HTML the page is written in. html indicates HTML5 --> | |
<html lang="en"> | |
<!-- Specifies the language of the element's content --> | |
<head> | |
<!-- A container for metadata, data about the HTML document which is not displayed --> | |
<!-- Google Analytics --> | |
<!-- Global Site Tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-107063946-1"></script> | |
<script> |