Skip to content

Instantly share code, notes, and snippets.

View andy4thehuynh's full-sized avatar
🛋️

Andy Huynh andy4thehuynh

🛋️
View GitHub Profile
require "logger"
require "watir"
require "faker"
Watir.default_timeout = 10
class ILoungeVoting
VOTING_URL = "https://itangolounge.com/vote"
CONTESTANT = "Tuý Hoa"
@andy4thehuynh
andy4thehuynh / apple_pay_controller.rb
Last active July 28, 2022 04:27
Integrating Apple Pay with Stripe
class ApplePayController < ApplicationController
layout "marketing_signup"
def show
respond_to do |format|
format.html { render :text => Foobar.foo }
end
end
end
@andy4thehuynh
andy4thehuynh / copying_records_to_different_db.rb
Last active July 28, 2022 04:26
Takes records from one db and opens a connection with another to send it there
1. Get URL of backup db
> heroku pg:credentials:url <database_name> -a kajabi-storefronts-production | tail -1
2. Get URL of live db
> heroku pg:credentials:url <database_name> -a kajabi-storefronts-production | tail -1
3. Open both db with your local psql client to see if your data is being ported to the live db
@andy4thehuynh
andy4thehuynh / member_university_external_user_id.rake
Last active July 28, 2022 04:31
finds mismatched external user ids with users for university site
university = Site.find(ENV["UNIVERSITY_SITE_ID"])
members = university.members
count = 0
member_emails = []
emails_as_eui_count = 0
# find emails as external user ids
members.find_each do |member|
eui = member.external_user_id
@andy4thehuynh
andy4thehuynh / float.rb
Last active July 28, 2022 04:34
Takes a float and determines if should add percentage or dash
def float_to_percentage_or_dash(float, options={})
float = float.to_f
nan = options.delete(:nan) || "&mdash;".html_safe
options[:precision] ||= 0
return nan if float.nan?
float == 0 ? dash : number_to_percentage(float * 100, **options)
end
def percentage_or_dash(value)