- Install the Stripe CLI with:
brew install stripe/stripe-cli/stripe
- Login to our Stripe account:
stripe login
- Listen for Stripe webhooks using Latest API version and forward to:
yarn stripe:listen
, which does:stripe listen --latest --forward-to http://localhost:3000/webhook_events/stripe
- Replay events locally with
stripe trigger <event type>
: stripe trigger checkout.session.completed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationPresenter | |
attr_reader :model | |
delegate_missing_to :@model | |
delegate :helpers, to: 'ActionController::Base' | |
delegate :url_helpers, to: 'Rails.application.routes' | |
delegate :to_param, :to_json, :to_query, :to_yaml, :to_enum, to: :@model | |
delegate :model_name, :model_name_const, :model_name_underscore, to: :class | |
def initialize(model) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
Rails.application.eager_load! | |
unused_routes = {} | |
# Iterating over all non-empty routes from RouteSet | |
Rails.application.routes.routes.map(&:requirements).reject(&:empty?).each do |route| | |
name = route[:controller].camelcase | |
next if name.start_with?('Rails') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Publisher | |
def subscribe(subscribers) | |
@subscribers ||= [] # if @subscribers is nil, we initialize it as empty array, else we do nothing | |
@subscribers += subscribers | |
end | |
def broadcast(event, *payload) | |
@subscribers ||= [] # @subscribers is nil, we can't do each on it | |
@subscribers.each do |subscriber| | |
# If event is :item_added occured with payload item itself |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render StimulusComponent.new controller: "test" do |component| %> | |
<button <%= component.action :click, :test, :test %>>Hello, Stimulus Component!</button> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "open-uri" | |
module Imports | |
class PageCrawler | |
attr_reader :current_page, :pages, :crawled | |
attr_accessor :follow_patterns, :ignore_patterns | |
def initialize(start_url, max_depth: 3, max_pages: 1000) | |
@max_depth, @max_pages = max_depth, max_pages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SoftDeletable | |
extend ActiveSupport::Concern | |
included do | |
scope :deleted, ->{ where.not(deleted_at: nil) } | |
scope :without_deleted, ->{ where(deleted_at: nil) } | |
scope :with_deleted, ->{ unscope(where: :deleted_at) } | |
default_scope { without_deleted } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Entry::TrackerBlocking | |
extend ActiveSupport::Concern | |
included do | |
has_many :blocked_trackers | |
end | |
email_service_blockers = { | |
"ActiveCampaign" => /lt\.php(.*)?l\=open/, | |
"AWeber" => "openrate.aweber.com", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def defaults args | |
args.outputs.static_background_color = [0, 0, 0] | |
args.grid.origin_center! | |
args.state.texture_size = 64 | |
args.state.texture_path = 'sprites/square-orange.png' | |
return if args.state.squares | |
cols = args.grid.w.idiv(args.state.texture_size) + 2 | |
rows = args.grid.h.half.idiv(args.state.texture_size) * 2 | |
args.state.squares = cols.numbers.product(rows.numbers).map do |x, y| | |
{ |