Skip to content

Instantly share code, notes, and snippets.

View CodeBrotha's full-sized avatar

Tineyi CodeBrotha

  • United States
View GitHub Profile
@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 > 2 #number of orders placed to get the deal
discount = 1000 #discount amount in cents
message = "VIP Customer - $10 off"
end
end
puts discount
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
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|
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
@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: ...
@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 / bootstrap_glyphs_in_rails.md
Created June 23, 2017 16:10 — forked from iamatypeofwalrus/bootstrap_glyphs_in_rails.md
Get Glyphicons up and running in Rails 3.2 without using a gem

Getting Glyphicons from Bootstrap 3.0 in Rails: the easy way

What

Bootstrap 3.0 gives you access to the awesome icon set icon set by these dudes but it's not obvious for a Rails newbie like myself to get it all working together nicely

How

  1. Download the bootstrap-glyphicons.css from here. Save that file to RAILS_ROOT/vendor/assets/stylesheet/bootstrap-glyphicons.css
  2. Save all the font files in /dist/fonts from the Bootstrap 3.0 download to a new folder in your Rails app RAILS_ROOT/vendor/assets/fonts
  3. Add this folder to the asset pipeline by appending config.assets.paths << Rails.root.join("vendor","assets", "fonts") to application.rb after the line that has class Application < Rails::Application.
  4. In bootstrap-glyphicons.css modify the the `url
@CodeBrotha
CodeBrotha / ssl_puma.sh
Created June 26, 2017 15:10 — forked from nathancolgate/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key
$ cd ~/.ssh
$ openssl genrsa -des3 -passout pass:x -out lvh.me.pass.key 2048
# 2) Generate RSA key
$ openssl rsa -passin pass:x -in lvh.me.pass.key -out lvh.me.key
# 3) Get rid of private key
$ rm lvh.me.pass.key
@CodeBrotha
CodeBrotha / buy-X-get-1-free-template.rb
Last active August 18, 2017 05:35
Shopify Plus - Shopify Script - Buy X products of the same vendor, get 1 free.
# Buy X products of the same vendor, get 1 free.
class VendorSelector
def initialize(vendor, tag)
@vendor = vendor
@tag = tag
end
# Returns whether a or not a line item matches the selector.