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
# Paste these into console | |
# Change `#create` to `#build` for dry runs in *2* locations | |
def create_instant_pay_credit_line_item(gig) | |
gig.line_items.create(category: :promotional_credit, amount: 2, description: "Instant pay credit.") | |
end | |
def create_instant_pay_credit_transaction(gig, payment_account, gli) | |
gig.payment_transactions.create( | |
payment_account: payment_account, |
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
select distinct | |
pt.id, | |
pt.gig_id, | |
pt.amount, | |
pt.status, | |
pt.created_at | |
from payment_transactions pt | |
join gigs g on g.id = pt.gig_id | |
join gig_tip_logs pre_tip_log on pre_tip_log.gig_id = g.id and pre_tip_log.operation = 0 | |
left join gig_tip_logs tip_confirmed_log on tip_confirmed_log.gig_id = g.id and tip_confirmed_log.operation = 1 |
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
Path Helpers | |
1. Run the rake routes command in the terminal | |
2. In the routes file, put \'as: "prefix_name"\' | |
3. If there are any variables in the route it prefixes, an argument will be required for each variable. Variables are represented as :symbols in the path. | |
Tying It Back | |
1. All commands are issued to the API via the terminal, whereas changes by way of the website are done through a web browser. | |
2. HTML: form class/action and input class/type. Rails equivalents: form_tag and submit_tag, respectively |
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. |
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
➜ 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
-- 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
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
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
require "pry" | |
require "set" | |
word_list = [ | |
"chicken", "dog", "duck", "cat", "clown", "brick", | |
"bananas", "totalitarianism", "Wednesday", "chicanery", | |
"ruby", "evaluation", "consternation" | |
] | |
MAX_TURNS = 6 |
NewerOlder