Skip to content

Instantly share code, notes, and snippets.

View BrianDunlap89's full-sized avatar

Brian Dunlap BrianDunlap89

View GitHub Profile
@BrianDunlap89
BrianDunlap89 / 00_helper_methods.rb
Last active March 29, 2022 14:34
WMT Stale Tip Disbursement (Latest - March 2022)
# 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,
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
@BrianDunlap89
BrianDunlap89 / gist:9b8cfd7c97bcb03f094e
Created October 28, 2015 13:16
Brian Dunlap -10/28 Quiz
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
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.
@BrianDunlap89
BrianDunlap89 / gist:91dcd2c2b4b69f8c3425
Created October 20, 2015 13:46
Week 5 Quiz - Brian Dunlap
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
@BrianDunlap89
BrianDunlap89 / gist:5aa8a75e487999572b21
Created October 18, 2015 22:55
Results of commitchamp on sinatra/sinatra
➜ 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?:
@BrianDunlap89
BrianDunlap89 / sql_practice
Created October 6, 2015 00:00
SQL Homework - Brian Dunlap
-- 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
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]}
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
require "pry"
require "set"
word_list = [
"chicken", "dog", "duck", "cat", "clown", "brick",
"bananas", "totalitarianism", "Wednesday", "chicanery",
"ruby", "evaluation", "consternation"
]
MAX_TURNS = 6