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
| num = rand(1..100) | |
| puts "I'm thinking of a number between 1 and 100." | |
| puts "What's your first guess?" | |
| guess = gets.chomp.to_i | |
| while guess != num | |
| if guess > num | |
| puts "Oops, that guess was too high. Try again!" | |
| else |
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
| require "pry" | |
| word_list = [ | |
| "chicken", "dog", "duck", "cat", "clown", "brick", | |
| "bananas", "totalitarianism", "Wednesday", "chicanery", | |
| "ruby", "evaluation", "consternation" | |
| ] | |
| turn_count = 6 | |
| answer = word_list.sample.downcase |
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
| require "pry" | |
| require "set" | |
| word_list = [ | |
| "chicken", "dog", "duck", "cat", "clown", "brick", | |
| "bananas", "totalitarianism", "Wednesday", "chicanery", | |
| "ruby", "evaluation", "consternation" | |
| ] | |
| MAX_TURNS = 6 |
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
| require "pry" | |
| require "set" | |
| word_list = [ | |
| "chicken", "dog", "duck", "cat", "clown", "brick", | |
| "bananas", "totalitarianism", "Wednesday", "chicanery", | |
| "ruby", "evaluation", "consternation" | |
| ] | |
| MAX_TURNS = 6 |
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
| board = (0..8).to_a | |
| WINNING_COMBINATIONS = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] | |
| PLAYER1_MARK = "X" | |
| PLAYER2_MARK = "O" | |
| def greeting | |
| puts "Welcome to Tic Tac Toe!\n" | |
| 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
| board = (1..9).to_a | |
| WINNING_COMBINATIONS = [[0, 1, 2], [3, 4, 5], [6, 7, 8], | |
| [0, 3, 6], [1, 4, 7], [2, 5, 8], | |
| [0, 4, 8], [2, 4, 6]] | |
| def show_board(board) | |
| puts " | |
| #{board[0]} | #{board[1]} | #{board[2]} | |
| #{board[3]} | #{board[4]} | #{board[5]} |
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
| -- PLEB MODE -- | |
| -- 1 | |
| -- SQL: SELECT COUNT(id) FROM users; | |
| -- A: 50 | |
| -- 2 | |
| -- SQL: SELECT title, price FROM items ORDER BY price DESC LIMIT 5; | |
| -- A: Small Cotton Gloves, Small Wooden Computer, Awesome Granite Pants, | |
| -- Sleek Wooden Hat, Ergonomic Steel Car |
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
| ➜ commitchamp git:(master) test | |
| Please provide an authentication token to proceed: | |
| 11ce3e171dd6133484b190f050f2fc7ceb24ff06 | |
| Would you like to get information from an individual user or organization? (u/o) | |
| u | |
| Which user's data would you like to access? | |
| sinatra | |
| Which repository? | |
| sinatra | |
| How would you like to sort contributors?: |
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
| Section 1 | |
| 1. You can infer that there are at least two models, and that of the two, Student objects will have many assignments. This association will allow users to access individual assignments using the syntax student.assignments(method). It also implies that the assignments table has a student_id column. | |
| Section 2 | |
| 1. (a) Four major parts of a request: a verb, a route, headers, and parameters(?). | |
| (b) Three major parts of a response: status code, a body, and headers | |
| 2. | |
| 3. PUT/PATCH are more aligned with updated or revising existing information, whereas POST creates a new entry/information altogether. | |
| Section 3 |
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
| Section 1 | |
| 1a. It would destroy the first post (based on its unique id) that belonged to the user who owned that particular comment. | |
| 1b. You would need the association User has_many :posts | |
| 2a. For the post titled "New Years Resolution" it would create a comment with the column values listed in the hash. | |
| 2b. We can infer that the Post table has a value :title. Because it has an association with User, we can also infer there is a user_id column in the table. | |
| Section 2 | |
| 1. Queries and post requests | |
| 2. Form data can be dynamically received (in a search bar, for instance), packaged by the browser, and then received and interpreted by the server. |
OlderNewer