Skip to content

Instantly share code, notes, and snippets.

View CodeBrotha's full-sized avatar

Tineyi CodeBrotha

  • United States
View GitHub Profile
@CodeBrotha
CodeBrotha / Bootsrap 3.0_in_Rails.md
Created June 23, 2017 14:49 — forked from iamatypeofwalrus/Bootsrap 3.0_in_Rails.md
Add Bootstrap to your Rails app without a Gem

Bootstrap 3.0 in Rails without a Gem

What is Bootstrap?

It's a collection of CSS styles and Javascript add-ons that stop your site from looking like a shitty craigslist rip off from 1996. Seriously, who wants that?

Docs: CSS, Components, Javascript

Why Install It This Way?

Finding the right gem, keeping it updated, and learning the syntax is a pain in the ass. Why not install Bootstrap the way you'd install new javascript libraries?

@CodeBrotha
CodeBrotha / backup.rake
Created May 11, 2017 01:30 — forked from tbalthazar/backup.rake
backup heroku db to s3
# Heroku S3 Database backup task
# by Nick Merwin (Lemur Heavy Industries) 10.08.09
# * dumps db to yaml, gzip's and sends to S3
#
# Setup:
# 1) replace APP_NAME and BACKUP_BUCKET with your info
# 2) add config/s3.yml like so (same as Paperclip's):
# production:
# access_key_id: ...
# secret_access_key: ...
discount = Money.new(cents: 100) * 5
discounted_product = 1522083265
products_needed = [592406273, 4283854977, 4284984897]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
discounted_product = 1522083265
products_needed = [592406273, 4283854977, 4284984897]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
Input.cart.line_items.each do |line_item|
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.accepts_marketing? #determines if the customer accepts marketing
discount = 1000 #number of Dollars to discount in cents
message = "Accepts Marketing Discount" #message to customer when they get the discount
end
end
puts discount
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count > 2 #number of orders placed to get the deal
discount = 1000 #discount amount in cents
message = "VIP Customer - $10 off"
end
end
puts discount
@CodeBrotha
CodeBrotha / Shopify Script - X% off if customer placed more than Y orders Since we cannot determine how much the customer has every spent, we are able to determine the total number of orders they have placed
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count > 2 #number of orders needed to get discount
discount = 0.2 #percent discount in decimal form
message = "VIP Customer"
end
end
puts discount
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count == 0
discount = 0.1 #change the discount given here
message = "Thanks for placing your first order" #change the message shown here
end
puts discount
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count < 1
discount = 1000 #discount amount in cents
message = "New Customer - $10 off"
end
end
puts discount
min_discount_order_amount = Money.new(cents:100) * 30 #number of dollars needed in cart to get the discount
total = Input.cart.subtotal_price_was
discount = if total > min_discount_order_amount
0.2 #discount percentage in decimal form
else
0
end
message = "My message"
Input.cart.line_items.each do |line_item|