Skip to content

Instantly share code, notes, and snippets.

@bearded-avenger
bearded-avenger / devise.rb
Last active January 11, 2022 17:04
Rails - SSO - WordPress - Authenticating against a WordPress install from a Rails site using oAuth
config.omniauth :wordpress_hosted, ENV['SSO_KEY'], ENV['SSO_SECRET'],
strategy_class: OmniAuth::Strategies::WordpressHosted,
client_options: { site: ENV['SSO_URL'] }
@bearded-avenger
bearded-avenger / easy-digital-downloads-changelog-shortcode
Last active October 19, 2020 07:06
Easy Digital Downloads - Changelog Shortcode (pass the EDD download ID and output a button that opens the changelog in a lightbox) - Completely un-styled and ready to abuse
/*
Use: [changelog id=""]
Atts: "id" is the id of the download in EDD
*/
add_shortcode('changelog','edd_changelog_sc'));
function edd_changelog_sc($atts,$content = null) {
$defaults = array(
namespace :sidekiq do
desc "Clear queued jobs in Sidekiq and reset all stats"
task :reset => :environment do
Sidekiq::Queue.all.each &:clear
Sidekiq::Stats.new.reset
Sidekiq::RetrySet.new.clear
Sidekiq::ScheduledSet.new.clear
end
end
class TenantWebhooksBraintreeController < ApplicationController
protect_from_forgery :except => :process_webhook
skip_before_action :verify_authenticity_token
before_action :verify_event
require 'pp'
def process_webhook
case @event.kind
module TenantServices
class SubscriptionServicePaypal
def initialize(params)
@subscription = params[:subscription]
@coupon = params[:coupon]
@paypal_token = params[:paypal_token]
@plan = @subscription.subscription_plan
@customer = @subscription.customer
@site = @subscription.site
module TenantServices
class CheckoutService
def initialize(params)
@site = params[:site]
@cart = params[:cart]
@customer = params[:customer]
@coupon_code = params[:coupon_code]
@selected_country = params[:selected_country]
class CustomerNotification < ApplicationRecord
belongs_to :site
belongs_to :customer
belongs_to :notifyable, polymorphic: true
acts_as_tenant :site
validates_uniqueness_to_tenant :customer_id, scope: [:notifyable_id, :notifyable_type]
end
class Customer < ApplicationRecord
has_many :following_playlists, class_name:'PlaylistFollower', dependent: :destroy
def follow_playlist!(playlist_id)
following_playlists.create(playlist_id: playlist_id)
end
def unfollow_playlist!(playlist_id)
following_playlists.find_by(playlist_id: playlist_id).destroy
class Playlist < ApplicationRecord
belongs_to :site
belongs_to :customer
belongs_to :user
acts_as_tenant :site
validates_presence_of :title, :content
attr_accessor :spam_answer
class BookmarksController < ApplicationController
BOOKMARKABLES = {
'Course' => Course,
'Lesson' => Lesson,
'Post' => Post,
'LiveStream' => LiveStream,
'Download' => Download,
'Project' => Project,
'Exercise' => Exercise,