source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/replica_lag_watcher.rb | Ruby | mit | 8,966 | main | 2,994 | # frozen_string_literal: true
## Will check replicas for lag every second, and sleep for a few seconds if they are.
#
# Typical usage:
# Model.find_each do |record|
# ReplicaLagWatcher.watch
# record.update!(field: new_value)
# end
# Try to not update/delete more than ~1000 rows at once between checks,
# o... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/referrer.rb | Ruby | mit | 8,966 | main | 603 | # frozen_string_literal: true
class Referrer
DEFAULT_VALUE = "direct"
def self.extract_domain(url)
return DEFAULT_VALUE if url.blank? || url == "direct"
domain = begin
url = URI::DEFAULT_PARSER.unescape(url)
url.encode!("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "")
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/sidekiq_utility.rb | Ruby | mit | 8,966 | main | 2,333 | # frozen_string_literal: true
class SidekiqUtility
INSTANCE_ID_ENDPOINT = "http://169.254.169.254/latest/meta-data/instance-id"
def initialize
@process_set = Sidekiq::ProcessSet.new
graceful_shutdown_timeout = ENV.fetch("SIDEKIQ_GRACEFUL_SHUTDOWN_TIMEOUT", 4).to_i.hours
@timeout_at = Time.current + g... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/credit_card_utility.rb | Ruby | mit | 8,966 | main | 1,108 | # frozen_string_literal: true
class CreditCardUtility
CARD_TYPE_NAMES = {
"Visa" => CardType::VISA,
"American Express" => CardType::AMERICAN_EXPRESS,
"MasterCard" => CardType::MASTERCARD,
"Discover" => CardType::DISCOVER,
"JCB" => CardType::JCB,
"Diners Club" => CardType::DINERS_CLUB
}.free... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/compliance.rb | Ruby | mit | 8,966 | main | 997 | # frozen_string_literal: true
module Compliance
DEFAULT_TOS_VIOLATION_REASON = "intellectual property infringement"
EXPLICIT_NSFW_TOS_VIOLATION_REASON = "Sexually explicit or fetish-related"
TOS_VIOLATION_REASONS = {
"A consulting service" => "consulting services",
"Adult (18+) content" => "adult content... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/global_config.rb | Ruby | mit | 8,966 | main | 1,883 | # frozen_string_literal: true
# GlobalConfig provides a centralized way to access environment variables and Rails credentials
class GlobalConfig
class << self
# Retrieve a value by its name from environment variables or Rails credentials
# @param name [String] The name of the environment variable
# @para... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/compliance/countries.rb | Ruby | mit | 8,966 | main | 11,119 | # frozen_string_literal: true
module Compliance
module Countries
ISO3166::Country.all.each do |country|
self.const_set(country.alpha3, country)
end
def self.mapping
ISO3166::Country.all.to_h { |country| [country.alpha2, country.common_name] }
end
def self.find_by_name(country_name)
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/validators/hex_color_validator.rb | Ruby | mit | 8,966 | main | 407 | # frozen_string_literal: true
class HexColorValidator < ActiveModel::EachValidator
HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/i
def validate_each(record, attribute, value)
return if self.class.matches?(value)
record.errors.add(attribute, (options[:message] || "is not a valid hexadecimal color"))
end
def self... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/extras/sidekiq_makara_reset_context_middleware.rb | Ruby | mit | 8,966 | main | 700 | # frozen_string_literal: true
# There are places in the codebase sticking the DB connection to master instead of replicas.
# Makara, via an included Rack middleware, resets those contexts before each web request (after master_ttl).
# This automatic reset doesn't exist for Sidekiq, so a thread executing many jobs may b... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/errors/gumroad_runtime_error.rb | Ruby | mit | 8,966 | main | 234 | # frozen_string_literal: true
class GumroadRuntimeError < RuntimeError
def initialize(message = nil, original_error: nil)
super(message || original_error)
set_backtrace(original_error.backtrace) if original_error
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/one_off_mailer_preview.rb | Ruby | mit | 8,966 | main | 770 | # frozen_string_literal: true
class OneOffMailerPreview < ActionMailer::Preview
def email
subject = "Try our premium features, for free!"
body = <<~BODY
You can now try out our premium features with a 14-day free trial. They make Gumroad a lot more powerful. It also comes with cheaper per-charge pricing.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/follower_mailer_preview.rb | Ruby | mit | 8,966 | main | 484 | # frozen_string_literal: true
class FollowerMailerPreview < ActionMailer::Preview
def confirm_follower
if Follower.count.zero?
follower_user = User.last
User.first&.add_follower(
follower_user&.email,
follower_user_id: follower_user&.id,
source: Follower::From::FOLLOW_PAGE,
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/internal_notification_mailer_preview.rb | Ruby | mit | 8,966 | main | 1,510 | # frozen_string_literal: true
class InternalNotificationMailerPreview < ActionMailer::Preview
def payment_notification
InternalNotificationMailer.notify(
room_name: "payments",
sender: "Canada Sales Fees Reporting",
message_text: "Canada 2026-03 sales fees report is ready - https://s3.amazonaws... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/accounting_mailer_preview.rb | Ruby | mit | 8,966 | main | 689 | # frozen_string_literal: true
class AccountingMailerPreview < ActionMailer::Preview
def email_outstanding_balances_csv
AccountingMailer.email_outstanding_balances_csv
end
def funds_received_report
last_month = Time.current.last_month
AccountingMailer.funds_received_report(last_month.month, last_mont... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/post_resend_api_preview.rb | Ruby | mit | 8,966 | main | 4,535 | # frozen_string_literal: true
class PostResendApiPreview < ActionMailer::Preview
def post_with_attachment
post = Installment.joins(:product_files).find_each(order: :desc).find(&:has_files?)
post ||= begin
record = create_generic_post
record.product_files.create!(url: "#{AWS_S3_ENDPOINT}/gumroad_d... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/affiliate_request_mailer_preview.rb | Ruby | mit | 8,966 | main | 811 | # frozen_string_literal: true
class AffiliateRequestMailerPreview < ActionMailer::Preview
def notify_requester_of_request_submission
AffiliateRequestMailer.notify_requester_of_request_submission(AffiliateRequest.last&.id)
end
def notify_seller_of_new_request
AffiliateRequestMailer.notify_seller_of_new_r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/two_factor_authentication_mailer_preview.rb | Ruby | mit | 8,966 | main | 227 | # frozen_string_literal: true
class TwoFactorAuthenticationMailerPreview < ActionMailer::Preview
def authentication_token
TwoFactorAuthenticationMailer.authentication_token(User.where.not(email: nil).last&.id)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/creator_mailer_preview.rb | Ruby | mit | 8,966 | main | 3,269 | # frozen_string_literal: true
class CreatorMailerPreview < ActionMailer::Preview
include CdnUrlHelper
def gumroad_day_fee_saved
CreatorMailer.gumroad_day_fee_saved(seller_id: seller&.id)
end
def year_in_review
CreatorMailer.year_in_review(seller:, year:, analytics_data:)
end
def year_in_review_wi... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/customer_mailer_preview.rb | Ruby | mit | 8,966 | main | 3,857 | # frozen_string_literal: true
class CustomerMailerPreview < ActionMailer::Preview
def grouped_receipt
purchase_ids = Purchase.successful.order(id: :desc).limit(3).ids
CustomerMailer.grouped_receipt(purchase_ids)
end
def giftee_receipt
purchase = Gift.last&.giftee_purchase
CustomerMailer.receipt(... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/post_sendgrid_api_preview.rb | Ruby | mit | 8,966 | main | 4,606 | # frozen_string_literal: true
class PostSendgridApiPreview < ActionMailer::Preview
def post_with_attachment
post = Installment.joins(:product_files).find_each(order: :desc).find(&:has_files?)
post ||= begin
record = create_generic_post
record.product_files.create!(url: "#{AWS_S3_ENDPOINT}/gumroad... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/affiliate_mailer_preview.rb | Ruby | mit | 8,966 | main | 2,162 | # frozen_string_literal: true
class AffiliateMailerPreview < ActionMailer::Preview
def direct_affiliate_invitation
AffiliateMailer.direct_affiliate_invitation(DirectAffiliate.last&.id)
end
def notify_direct_affiliate_of_sale
purchase = Purchase.where(affiliate_id: DirectAffiliate.pluck(:id)).last
Af... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/team_mailer_preview.rb | Ruby | mit | 8,966 | main | 234 | # frozen_string_literal: true
class TeamMailerPreview < ActionMailer::Preview
def invite
TeamMailer.invite(TeamInvitation.last)
end
def invitation_accepted
TeamMailer.invitation_accepted(TeamMembership.last)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/customer_low_priority_mailer_preview.rb | Ruby | mit | 8,966 | main | 4,005 | # frozen_string_literal: true
class CustomerLowPriorityMailerPreview < ActionMailer::Preview
def credit_card_expiring_membership
CustomerLowPriorityMailer.credit_card_expiring_membership(Subscription.last&.id)
end
def deposit
CustomerLowPriorityMailer.deposit(Payment.last&.id)
end
def preorder_canc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/user_signup_mailer_preview.rb | Ruby | mit | 8,966 | main | 797 | # frozen_string_literal: true
class UserSignupMailerPreview < ActionMailer::Preview
def confirmation_instructions
UserSignupMailer.confirmation_instructions(User.last, {})
end
def reset_password_instructions
User.last&.mark_compliant!(author_name: "Gullible Admin")
UserSignupMailer.reset_password_in... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/merchant_registration_mailer_preview.rb | Ruby | mit | 8,966 | main | 489 | # frozen_string_literal: true
class MerchantRegistrationMailerPreview < ActionMailer::Preview
def stripe_charges_disabled
MerchantRegistrationMailer.stripe_charges_disabled(User.last&.id)
end
def account_needs_registration_to_user
MerchantRegistrationMailer.account_needs_registration_to_user(Affiliate.l... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/contacting_creator_mailer_preview.rb | Ruby | mit | 8,966 | main | 7,034 | # frozen_string_literal: true
class ContactingCreatorMailerPreview < ActionMailer::Preview
def cannot_pay
ContactingCreatorMailer.cannot_pay(Payment.last&.id)
end
def preorder_release_reminder
ContactingCreatorMailer.preorder_release_reminder(PreorderLink.last&.link&.id)
end
def preorder_summary
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/mailer_previews/community_chat_recap_mailer_preview.rb | Ruby | mit | 8,966 | main | 390 | # frozen_string_literal: true
class CommunityChatRecapMailerPreview < ActionMailer::Preview
def community_chat_recap_notification
CommunityChatRecapMailer.community_chat_recap_notification(User.first.id, User.last.id, CommunityChatRecap.status_finished.where(community_chat_recap_run_id: CommunityChatRecapRun.rec... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/tasks/js_export.rake | Ruby | mit | 8,966 | main | 796 | # typed: strict
# frozen_string_literal: true
extend Rake::DSL
namespace :js do
desc "Generate JavaScript translations, icons and routes"
task export: :environment do
routes_dir = Rails.root.join("app", "javascript", "utils")
JsRoutes.generate!(routes_dir.join("routes.js"))
JsRoutes.definitions!(rout... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | docker/base/irbrc.rb | Ruby | mit | 8,966 | main | 246 | # frozen_string_literal: true
if ENV["RAILS_ENV"] == "production"
original_prompt = IRB.conf[:PROMPT][:DEFAULT][:PROMPT_I]
new_prompt = "\033[33mPRODUCTION \033[m" + original_prompt
IRB.conf[:PROMPT][:DEFAULT][:PROMPT_I] = new_prompt
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/boot.rb | Ruby | mit | 8,966 | main | 767 | # frozen_string_literal: true
# Chromedriver crashes when spawned with jemalloc in LD_PRELOAD.
# By the time Rails is booted, jemalloc is already linked and keeping it in ENV is not necessary.
ENV["LD_PRELOAD"] = ""
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" # Set up gem... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/domain.rb | Ruby | mit | 8,966 | main | 4,318 | # frozen_string_literal: true
configuration_by_env = {
production: {
protocol: "https",
domain: "gumroad.com",
asset_domain: "assets.gumroad.com",
root_domain: "gumroad.com",
short_domain: "gum.co",
discover_domain: "gumroad.com",
api_domain: "api.gumroad.com",
third_party_analytics_d... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/application.rb | Ruby | mit | 8,966 | main | 3,352 | # frozen_string_literal: true
require_relative "boot"
require "rails/all"
require "action_cable/engine"
require "socket"
require_relative "../lib/catch_bad_request_errors"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/routes.rb | Ruby | mit | 8,966 | main | 49,836 | # frozen_string_literal: true
require "api_domain_constraint"
require "product_custom_domain_constraint"
require "user_custom_domain_constraint"
require "gumroad_domain_constraint"
require "discover_domain_constraint"
require "discover_taxonomy_constraint"
require "sidekiq/cron/web"
require "sidekiq_unique_jobs/web"
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/puma.rb | Ruby | mit | 8,966 | main | 2,761 | # frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minim... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/routes/admin.rb | Ruby | mit | 8,966 | main | 5,576 | # frozen_string_literal: true
concern :commentable do
resources :comments, only: [:index, :create]
end
namespace :admin do
get "/", to: "base#index"
get :impersonate, to: "base#impersonate"
delete :unimpersonate, to: "base#unimpersonate"
get :redirect_to_stripe_dashboard, to: "base#redirect_to_stripe_dashbo... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/bots.rb | Ruby | mit | 8,966 | main | 102,264 | # frozen_string_literal: true
BOT_MAP = {
"Mozilla/5.0 (Windows; U; cs-CZ) AppleWebKit/526.9+ (KHTML, like Gecko) AdobeAIR/1.5.1" => "Adobe AIR runtime",
"BinGet/1.00.A (http://www.bin-co.com/php/scripts/load/)" => "BinGet",
"Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)" => "Chilkat HTTP .NET",
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/003_stripe.rb | Ruby | mit | 8,966 | main | 784 | # frozen_string_literal: true
Stripe.api_version = Rails.env.test? ? "2023-10-16" : "2023-10-16; risk_in_requirements_beta=v1; retrieve_tax_forms_beta=v1;"
# Ref: https://github.com/gumroad/web/issues/17770, https://stripe.com/docs/rate-limits#object-lock-timeouts
Stripe.max_network_retries = 3
if Rails.env.production... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/mime_types.rb | Ruby | mit | 8,966 | main | 477 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register "image/svg+xml", :svg
Mime::Type.register "application/smil+xml"... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/money.rb | Ruby | mit | 8,966 | main | 1,147 | # frozen_string_literal: true
Money.locale_backend = :i18n
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
Money.default_currency = "USD"
# technically KRW does have subunits but they are not used anymore
# our currencies.yml assumes KRW to have 100 subunits and that's how we store them in the database
# the gem 'mon... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/rpush.rb | Ruby | mit | 8,966 | main | 6,131 | # frozen_string_literal: true
Rpush.configure do |config|
# Supported clients are :active_record and :redis
config.client = :redis
# Options passed to Redis.new
config.redis_options = { url: "redis://#{ENV["RPUSH_REDIS_HOST"]}" }
# Frequency in seconds to check for new notifications.
config.push_poll = 2... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/active_support_cache_notifications.rb | Ruby | mit | 8,966 | main | 659 | # frozen_string_literal: true
Rails.application.config.after_initialize do
cache_to_metric_keys = {
ProfileSectionsPresenter::CACHE_KEY_PREFIX => "#{ProfileSectionsPresenter::CACHE_KEY_PREFIX}-metrics",
ProductPresenter::ProductProps::SALES_COUNT_CACHE_KEY_REFIX => ProductPresenter::ProductProps::SALES_COUNT... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/cookie_rotator.rb | Ruby | mit | 8,966 | main | 892 | # frozen_string_literal: true
Rails.application.config.after_initialize do
Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies|
authenticated_encrypted_cookie_salt = Rails.application.config.action_dispatch.authenticated_encrypted_cookie_salt
signed_cookie_salt = Rails.application.conf... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/lograge.rb | Ruby | mit | 8,966 | main | 993 | # frozen_string_literal: true
Rails.application.config.lograge.custom_options = lambda do |event|
params = { remote_ip: event.payload[:remote_ip] }
headers = event.payload[:headers]
uuid = event.payload[:uuid]
payload_params = event.payload[:params]
if payload_params.present?
if payload_params["control... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/blocked_object_types.rb | Ruby | mit | 8,966 | main | 260 | # frozen_string_literal: true
BLOCKED_OBJECT_TYPES = {
ip_address: "ip_address",
browser_guid: "browser_guid",
email: "email",
email_domain: "email_domain",
charge_processor_fingerprint: "charge_processor_fingerprint",
product: "product"
}.freeze |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/app_store_info.rb | Ruby | mit | 8,966 | main | 344 | # frozen_string_literal: true
IOS_APP_ID = GlobalConfig.get("IOS_APP_ID", "916819108")
IOS_APP_STORE_URL = "https://itunes.apple.com/app/id#{IOS_APP_ID}"
ANDROID_BUNDLE_ID = GlobalConfig.get("ANDROID_BUNDLE_ID", "com.gumroad.app")
ANDROID_APP_STORE_URL = "https://play.google.com/store/apps/details?i... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/openai.rb | Ruby | mit | 8,966 | main | 214 | # frozen_string_literal: true
request_timeout_in_seconds = 3
OpenAI.configure do |config|
config.access_token = GlobalConfig.get("OPENAI_ACCESS_TOKEN")
config.request_timeout = request_timeout_in_seconds
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/api_v2_methods.rb | Ruby | mit | 8,966 | main | 19,782 | # frozen_string_literal: true
GUMROAD_API_V2_METHODS = [
{
name: "Products",
methods: [
{
type: :get,
path: "/products",
description: "Retrieve all of the existing products for the authenticated user.",
response_layout: :products,
curl_layout: :get_products
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/permissions_policy.rb | Ruby | mit | 8,966 | main | 511 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
# Rails.application.config.permissions_policy do |policy|
# policy.camera ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/alterity.rb | Ruby | mit | 8,966 | main | 1,707 | # frozen_string_literal: true
Alterity.configure do |config|
config.command = -> (altered_table, alter_argument) {
password_argument = "--password='#{config.password}'" if config.password.present?
<<~SHELL.squish
pt-online-schema-change
-h #{config.host}
-P #{config.port}
-u #{config.us... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/custom_domain.rb | Ruby | mit | 8,966 | main | 683 | # frozen_string_literal: true
if Rails.env.production?
CUSTOM_DOMAIN_CNAME = GlobalConfig.get("CUSTOM_DOMAIN_CNAME_PROD", "domains.gumroad.com")
# CUSTOM_DOMAIN_STATIC_IP_HOST is for internal use. It will be used only to
# check if the custom domain is pointed to the static IP address.
CUSTOM_DOMAIN_STATIC_IP... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/doorkeeper.rb | Ruby | mit | 8,966 | main | 1,693 | # frozen_string_literal: true
require "cgi"
module VisibleScopes
# Public Method: public_scopes
# These are the scopes that the public should be aware of. Update this list when adding scopes to Doorkeeper.
# Mobile Api scope is not included because we don't want the public to have knowledge of that scope.
def... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/sidekiq_cron.rb | Ruby | mit | 8,966 | main | 269 | # frozen_string_literal: true
Sidekiq.configure_server do |config|
config.on(:startup) do
sidekiq_schedule = YAML.load_file(Rails.root.join("config", "sidekiq_schedule.yml"))
Sidekiq::Cron::Job.load_from_hash!(sidekiq_schedule, source: "schedule")
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/gumroad.rb | Ruby | mit | 8,966 | main | 2,432 | # frozen_string_literal: true
GUMROAD_VAT_REGISTRATION_NUMBER = GlobalConfig.get("VAT_REGISTRATION_NUMBER", "EU372030009")
GUMROAD_AUSTRALIAN_BUSINESS_NUMBER = GlobalConfig.get("AUSTRALIAN_BUSINESS_NUMBER", "3000 3814 4483")
GUMROAD_CANADA_GST_REGISTRATION_NUMBER = GlobalConfig.get("CANADA_GST_REGISTRATION_NUMBER", "7... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/elasticsearch.rb | Ruby | mit | 8,966 | main | 329 | # frozen_string_literal: true
EsClient = Elasticsearch::Model.client = Elasticsearch::Client.new(
host: ENV.fetch("ELASTICSEARCH_HOST"),
retry_on_failure: 5,
transport_options: { request: { timeout: 5 } },
log: true
)
USE_ES_ALIASES = Rails.env.production? || (Rails.env.staging? && ENV["BRANCH_DEPLOYMENT"] !=... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/mailer.rb | Ruby | mit | 8,966 | main | 4,989 | # frozen_string_literal: true
require_relative "../../app/models/mailer_info"
require_relative "../../app/models/mailer_info/delivery_method"
if Rails.env.production?
FOLLOWER_CONFIRMATION_MAIL_DOMAIN = GlobalConfig.get("FOLLOWER_CONFIRMATION_MAIL_DOMAIN_PROD", "followers.gumroad.com")
CREATOR_CONTACTING_CUSTOMER... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/sentry.rb | Ruby | mit | 8,966 | main | 701 | # frozen_string_literal: true
Sentry.init do |config|
config.dsn = GlobalConfig.get("SENTRY_DSN")
config.enabled_environments = %w[production staging]
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
config.send_default_pii = true
config.traces_sample_rate = 0.01
config.excluded_exception... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/friendly_id.rb | Ruby | mit | 8,966 | main | 4,039 | # frozen_string_literal: true
# FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `friendly_id` class method or defining
# methods in your mode... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/geoip.rb | Ruby | mit | 8,966 | main | 206 | # frozen_string_literal: true
require "maxmind/geoip2"
database_path = "#{Rails.root}/lib/GeoIP2-City.mmdb"
GEOIP = File.exist?(database_path) ? MaxMind::GeoIP2::Reader.new(database: database_path) : nil |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/assets.rb | Ruby | mit | 8,966 | main | 851 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
Rails.application.config.assets.digest = true
# Add additional assets to the asset load path
# Rails.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/state_machine.rb | Ruby | mit | 8,966 | main | 229 | # frozen_string_literal: true
module StateMachines::Integrations::ActiveModel
alias around_validation_protected around_validation
def around_validation(*args, &block)
around_validation_protected(*args, &block)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/time_formats.rb | Ruby | mit | 8,966 | main | 268 | # frozen_string_literal: true
Time::DATE_FORMATS[:long_formatted_datetime] = "%e %b %Y %l:%M %p"
Time::DATE_FORMATS[:formatted_date_full_month] = "%B %-d, %Y"
Time::DATE_FORMATS[:formatted_date_abbrev_month] = "%b %-d, %Y"
Time::DATE_FORMATS[:slashed] = "%-m/%-d/%Y" |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/feature_toggle.rb | Ruby | mit | 8,966 | main | 813 | # frozen_string_literal: true
Flipper.configure do |config|
config.adapter { Flipper::Adapters::Redis.new($redis) }
end
Rails.application.config.flipper.preload = false
Flipper::UI.configuration.application_breadcrumb_href = "/admin"
Flipper::UI.configuration.cloud_recommendation = false
Flipper::UI.configuration.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/mysql_missing_table_handler.rb | Ruby | mit | 8,966 | main | 475 | # frozen_string_literal: true
module Mysql2
class Client
MISSING_TABLE_GRACE_PERIOD = 5.seconds
alias original_query query
def query(sql, options = {})
original_query(sql, options)
rescue Mysql2::Error => e
raise unless /Table .* doesn't exist/.match?(e.message)
warn "Error: missin... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/discord.rb | Ruby | mit | 8,966 | main | 406 | # frozen_string_literal: true
DISCORD_OAUTH_TOKEN_URL = GlobalConfig.get("DISCORD_OAUTH_TOKEN_URL", "https://discord.com/api/oauth2/token")
DISCORD_GUMROAD_BOT_ID = GlobalConfig.get("DISCORD_BOT_ID", "951121634046140416")
DISCORD_CLIENT_ID = GlobalConfig.get("DISCORD_CLIENT_ID")
DISCORD_CLIENT_SECRET = GlobalConfig.g... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/cors.rb | Ruby | mit | 8,966 | main | 644 | # frozen_string_literal: true
# Allow requests from all origins to API domain
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "*"
resource "*",
headers: :any,
methods: [:get, :post, :put, :delete],
if: proc { |env| VALID_API_REQUEST_H... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/prefix_for_branch_apps_es_index.rb | Ruby | mit | 8,966 | main | 389 | # frozen_string_literal: true
if Rails.env.staging? && ENV["BRANCH_DEPLOYMENT"] == "true"
Rails.application.config.after_initialize do
[Link, Balance, Purchase, Installment, ConfirmedFollowerEvent, ProductPageView].each do |model|
model.index_name("branch-app-#{ENV['DATABASE_NAME']}__#{model.name.parameter... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/devise.rb | Ruby | mit | 8,966 | main | 14,914 | # frozen_string_literal: true
require "omniauth-apple"
require "omniauth-google-oauth2"
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to ge... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/rack_attack.rb | Ruby | mit | 8,966 | main | 14,197 | # frozen_string_literal: true
class Rack::Attack
redis_url = ENV.fetch("RACK_ATTACK_REDIS_HOST")
redis_client = Redis.new(url: "redis://#{redis_url}")
Rack::Attack.cache.store = Rack::Attack::StoreProxy::RedisProxy.new(redis_client)
class Request < ::Rack::Request
# When the server is behind a load bal... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/braintree.rb | Ruby | mit | 8,966 | main | 569 | # frozen_string_literal: true
Braintree::Configuration.environment = Rails.env.production? ? :production : :sandbox
Braintree::Configuration.merchant_id = GlobalConfig.get("BRAINTREE_MERCHANT_ID")
Braintree::Configuration.public_key = GlobalConfig.get("BRAINTREE_PUBLIC_KEY")
Braintree::Configuration.private_key = Glob... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/secure_headers.rb | Ruby | mit | 8,966 | main | 5,917 | # frozen_string_literal: true
cookie_config = if PROTOCOL == "https"
{
httponly: true,
secure: true,
samesite: { none: true }
}
else
{
httponly: true,
secure: SecureHeaders::OPT_OUT,
samesite: { lax: true }
}
end
SecureHeaders::Configuration.default do |config|
config.cookies = cooki... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/aws.rb | Ruby | mit | 8,966 | main | 4,146 | # frozen_string_literal: true
# aws credentials for the web app are stored in the secrets
AWS_ACCESS_KEY = GlobalConfig.get("AWS_ACCESS_KEY_ID")
AWS_SECRET_KEY = GlobalConfig.get("AWS_SECRET_ACCESS_KEY")
AWS_S3_ENDPOINT = GlobalConfig.get("AWS_S3_ENDPOINT", "https://s3.amazonaws.com")
AWS_DEFAULT_REGION = GlobalConfig... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/sidekiq_web_csp.rb | Ruby | mit | 8,966 | main | 293 | # frozen_string_literal: true
class SidekiqWebCSP
def initialize(app)
@app = app
end
def call(env)
SecureHeaders.append_content_security_policy_directives(
Rack::Request.new(env),
{
script_src: %w('unsafe-inline')
}
)
@app.call(env)
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/notification_purchase.rb | Ruby | mit | 8,966 | main | 253 | # frozen_string_literal: true
Rails.application.config.after_initialize do
ActiveSupport::Notifications.subscribe(ChargeProcessor::NOTIFICATION_CHARGE_EVENT) do |_, _, _, _, payload|
Purchase.handle_charge_event(payload[:charge_event])
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/js-routes.rb | Ruby | mit | 8,966 | main | 250 | # frozen_string_literal: true
JsRoutes.setup do |config|
config.url_links = true
# Don't determine protocol from window.location (prerendering)
config.default_url_options = { protocol: PROTOCOL, host: DOMAIN }
config.exclude = [/^api_/]
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/tax_id_pro.rb | Ruby | mit | 8,966 | main | 299 | # frozen_string_literal: true
# Tax ID Pro allows us to create multiple API keys.
# We're using two — one for Development, and one for Production.
# We're using the Production key in production, and the Development key everywhere else.
TAX_ID_PRO_API_KEY = GlobalConfig.get("TAX_ID_PRO_API_KEY") |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/session_store.rb | Ruby | mit | 8,966 | main | 1,017 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Use tld_length 3 in staging to support subdomains like username.staging.gumroad.com
tld_length = Rails.env.staging? ? 3 : 2
expire_after = Rails.env.test? ? 10.years : 1.month
domain = :all
base_cookie_name = "_gumroad_app_se... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/005_apple.rb | Ruby | mit | 8,966 | main | 2,286 | # frozen_string_literal: true
APPLE_CLIENT_ID = GlobalConfig.get("APPLE_WEB_CLIENT_ID")
APPLE_TEAM_ID = GlobalConfig.get("APPLE_WEB_TEAM_ID")
APPLE_KEY_ID = GlobalConfig.get("APPLE_WEB_KEY_ID")
APPLE_PRIVATE_KEY = GlobalConfig.get("APPLE_WEB_PRIVATE_KEY")
APPLE_OAUTH_COOKIE_NAME = "_apple_oauth_nonce"
APPLE_OAUTH_COO... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/paypal.rb | Ruby | mit | 8,966 | main | 1,830 | # frozen_string_literal: true
# Gumroad's PayPal merchant account details
PAYPAL_CLIENT_ID = GlobalConfig.get("PAYPAL_CLIENT_ID")
PAYPAL_CLIENT_SECRET = GlobalConfig.get("PAYPAL_CLIENT_SECRET")
PAYPAL_MERCHANT_EMAIL = GlobalConfig.get("PAYPAL_MERCHANT_EMAIL")
# Gumroad's PayPal partner account details
PAYPAL_BN... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/currency.rb | Ruby | mit | 8,966 | main | 511 | # frozen_string_literal: true
OPEN_EXCHANGE_RATES_API_BASE_URL = "https://openexchangerates.org/api"
OPEN_EXCHANGE_RATE_KEY = GlobalConfig.get("OPEN_EXCHANGE_RATES_APP_ID")
CURRENCY_SOURCE = if Rails.env.development? || Rails.env.test?
"#{Rails.root}/lib/currency/backup_rates.json"
else
"#{OPEN_EXCHANGE... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/rack_profiler.rb | Ruby | mit | 8,966 | main | 1,432 | # frozen_string_literal: true
require "rack-mini-profiler"
Rack::MiniProfilerRails.initialize!(Rails.application)
Rack::MiniProfiler.config.authorization_mode = :allow_authorized
Rack::MiniProfiler.config.skip_paths = [
/#{ASSET_DOMAIN}/o,
]
Rack::MiniProfiler.config.start_hidden = true
Rack::MiniProfiler.confi... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/hash.rb | Ruby | mit | 8,966 | main | 423 | # frozen_string_literal: true
class Hash
def deep_reject!(&block)
reject! do |key, value|
value.deep_reject!(&block) if value.is_a?(Hash)
yield(key, value)
end
self
end
def deep_values_strip!
transform_values! do |value|
if value.is_a?(String)
value.strip
elsif v... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/000_facebook.rb | Ruby | mit | 8,966 | main | 286 | # frozen_string_literal: true
FACEBOOK_APP_ID = GlobalConfig.get("FACEBOOK_APP_ID")
FACEBOOK_APP_SECRET = GlobalConfig.get("FACEBOOK_APP_SECRET")
FACEBOOK_OG_NAMESPACE = GlobalConfig.get("FACEBOOK_OG_NAMESPACE")
FACEBOOK_API_VERSION = GlobalConfig.get("FACEBOOK_API_VERSION", "v19.0") |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/new_framework_defaults_7_1.rb | Ruby | mit | 8,966 | main | 12,231 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
#
# This file eases your Rails 7.1 framework defaults upgrade.
#
# Uncomment each configuration one by one to switch to the new default.
# Once your application is ready to run with all new defaults, you can remove
# this file an... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/countries.rb | Ruby | mit | 8,966 | main | 4,067 | # frozen_string_literal: true
# Historically, we've gotten country names from a variety of sources:
# the `iso_country_codes` gem, `maxmind/geoip2`, and most recently the `countries` gem.
#
# With the modifications here, a call to `ISO3166::Country.find_country_by_any_name`
# will return the correct country from the `... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/004_constants.rb | Ruby | mit | 8,966 | main | 5,097 | # frozen_string_literal: true
GOOGLE_CLOUD_PROJECT_ID = GlobalConfig.get("GOOGLE_CLOUD_PROJECT_ID")
GUMROAD_ADMIN_ID = GlobalConfig.get("GUMROAD_ADMIN_ID", Rails.env.staging? ? 978 : 767082) # admin@gumroad.com
GUMROAD_STARTED_DATE = Date.parse("2011-04-04")
PRODUCT_EVENT_TRACKING_STARTED_DATE = Date.parse("2012-10-1... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/kaminari.rb | Ruby | mit | 8,966 | main | 388 | # frozen_string_literal: true
# `will_paginate` is known to cause problems when used with `kaminari`
# This configuration file enables using `page_with_kaminari()` instead of `page()` when pagination via `kaminari` is desired
# Ref: https://github.com/kaminari/kaminari/issues/162#issuecomment-28673272
Kaminari.config... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/filter_parameter_logging.rb | Ruby | mit | 8,966 | main | 653 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/united_states_zip_codes.rb | Ruby | mit | 8,966 | main | 627 | # frozen_string_literal: true
# Known zip codes that don't show up in the US Zip Codes database.
KNOWN_ZIP_CODES = { "85144" => "AZ" }
# The United States Zip Codes website recommends that we update this file annually. https://www.unitedstateszipcodes.org/zip-code-database/
# Changes to 5-digit zip codes are infreque... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/mail_encodings.rb | Ruby | mit | 8,966 | main | 733 | # frozen_string_literal: true
# TODO (vishal): Remove this initializer when we start relying on a Rails
# version that includes this change https://github.com/rails/rails/pull/46650.
#
# Following code overrides the Mail::Encodings::QuoatedPritable class
# as per https://github.com/mikel/mail/pull/1210.
# See https://... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/pry.rb | Ruby | mit | 8,966 | main | 335 | # frozen_string_literal: true
if defined?(PryByebug)
Pry.commands.alias_command "c", "continue"
Pry.commands.alias_command "s", "step"
Pry.commands.alias_command "n", "next"
Pry.commands.alias_command "f", "finish"
Pry.commands.alias_command "bt", "pry-backtrace"
Pry.config.editor = "vim"
Pry.config.pag... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/vatstack.rb | Ruby | mit | 8,966 | main | 258 | # frozen_string_literal: true
# Vatstack gives us two API keys — one for Development, and one for Production.
# We're using the Production key in production, and the Development key everywhere else.
VATSTACK_API_KEY = GlobalConfig.get("VATSTACK_API_KEY") |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/inflections.rb | Ruby | mit | 8,966 | main | 551 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
ActiveSupport::Inflecto... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/id_headers.rb | Ruby | mit | 8,966 | main | 329 | # frozen_string_literal: true
if Rails.env.staging? || Rails.env.production?
REVISION = ENV.fetch("REVISION")
else
REVISION = GlobalConfig.get("REVISION_DEFAULT", "no-revision")
end
GR_NUM = if Rails.env.production?
GlobalConfig.get("ENV_IDENTIFIER_PROD", "PROD")
else
GlobalConfig.get("ENV_IDENTIFIER_DEV", "D... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/rack_timeout.rb | Ruby | mit | 8,966 | main | 335 | # frozen_string_literal: true
unless ENV["DISABLE_RACK_TIMEOUT"] == "1"
Rails.application.config.middleware.insert_before(
Rack::Runtime,
Rack::Timeout,
service_timeout: 120,
wait_overtime: 24.hours.to_i,
wait_timeout: false
)
Rack::Timeout::Logger.disable unless ENV["ENABLE_RACK_TIMEOUT_LOG... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/backtrace_silencers.rb | Ruby | mit | 8,966 | main | 571 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silence... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/taxjar.rb | Ruby | mit | 8,966 | main | 362 | # frozen_string_literal: true
# TaxJar gives us two API keys: one for Sandbox, and one for Live.
# We're using the Live key in production, and the Sandbox key everywhere else.
TAXJAR_API_KEY = GlobalConfig.get("TAXJAR_API_KEY")
if Rails.env.production?
TAXJAR_ENDPOINT = "https://api.taxjar.com"
else
TAXJAR_ENDPOI... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/makara.rb | Ruby | mit | 8,966 | main | 455 | # frozen_string_literal: true
module Makara
class ConnectionWrapper
# Rails 7.0 compatibility, from: https://github.com/instacart/makara/pull/358
# TODO: Remove this file after the makara gem is updated, including this PR.
def execute(*args, **kwargs)
SQL_REPLACE.each do |find, replace|
if ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/sidekiq.rb | Ruby | mit | 8,966 | main | 2,005 | # frozen_string_literal: true
# `sidekiq-pro` is now only autoloaded in staging/production due to the Gemfile
# group. This ensures `sidekiq-pro` is correctly loaded in all environments
# when available.
begin
require "sidekiq-pro"
rescue LoadError
warn "sidekiq-pro is not installed"
end
require Rails.root.join("... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/chat_rooms.rb | Ruby | mit | 8,966 | main | 665 | # frozen_string_literal: true
INTERNAL_NOTIFICATION_EMAIL = GlobalConfig.get("INTERNAL_NOTIFICATION_EMAIL", "hi@gumroad.com")
PAYMENTS_NOTIFICATION_EMAIL = GlobalConfig.get("PAYMENTS_NOTIFICATION_EMAIL", "hi@gumroad.com")
CHAT_ROOMS = {
announcements: { email: INTERNAL_NOTIFICATION_EMAIL },
awards: { email: INTER... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | config/initializers/wrap_parameters.rb | Ruby | mit | 8,966 | main | 495 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_con... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.