This file contains 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
# | |
# Created by Eric Lindvall <eric@sevenscale.com> | |
# | |
# WHAT: Provides a simple overview of memory allocation occuring during a | |
# require. | |
# | |
# For a longer explanation, see my post at: | |
# | |
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby | |
# |
This file contains 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 'sunspot' | |
require 'sunspot/session_proxy/abstract_session_proxy' | |
require 'resque' | |
require 'resque-retry' | |
class SunspotResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy | |
attr_reader :session | |
delegate :config, :delete_dirty?, :dirty?, | |
:new_search, :search, |
This file contains 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 'sunspot' | |
require 'sunspot/session_proxy/abstract_session_proxy' | |
require 'resque' | |
require 'resque-retry' | |
class SunspotResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy | |
attr_reader :session | |
delegate :config, :delete_dirty?, :dirty?, | |
:new_search, :search, |
This file contains 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 BackgroundSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy | |
class <<self | |
def async? | |
!!Thread.current[:background_session_proxy_async] | |
end | |
def with_async | |
self.async = true | |
begin | |
yield |
This file contains 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
# Sample code using Sunspot 1.2.1 to retry a search when partialResults=true | |
# | |
# I hope this code will be somewhat deprecated in Sunspot 1.2.2, since we have to | |
# use instance_eval to access the otherwise inaccessible @solr_response instance variable. | |
# | |
class Post | |
# ... |
This file contains 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
# app/models/post.rb | |
class Post | |
searchable :auto_index => false, :auto_remove => false do | |
text :title | |
text :body | |
end | |
after_commit :resque_solr_update, :if => :persisted? |
This file contains 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 Sunspot | |
class ResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy | |
attr_reader :original_session | |
delegate :config, :delete_dirty?, :dirty?, | |
:new_search, :search, | |
:new_more_like_this, :more_like_this, | |
:remove, :remove!, |
This file contains 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 Sunspot | |
class ResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy | |
attr_reader :original_session | |
delegate :config, :delete_dirty?, :dirty?, | |
:new_search, :search, | |
:new_more_like_this, :more_like_this, | |
:remove, :remove!, |
This file contains 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
<?php | |
// Make sure WooCommerce Subscriptions is active | |
if ( class_exists( 'WC_Subscriptions_Switcher' ) ) { | |
// Get the key for the customer's current subscription | |
$subscription_key = WC_Subscriptions_Manager::get_subscription_key( $order_id, $product_id ); | |
// Check if the current subscription can be switched by the customer | |
if ( WC_Subscriptions_Manager::can_subscription_be_changed_to( 'new-subscription', $subscription_key, get_current_user_id() ) ) { |
This file contains 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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
OlderNewer