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 'rubygems' | |
require 'open-uri' | |
require 'scrapi' | |
require 'hpricot' | |
# url = "http://www.edgewise-media.com/sonmindv60mi.html" | |
# css_selector = "html>body>table:nth-of-type(2) tr>td:nth-of-type(3)>table:nth-of-type(2) tr>td>form>font>table tr:nth-of-type(2)>td:nth-of-type(2)>font:nth-of-type(1)" | |
url = "http://www.tapestockonline.com/son60minprem.html" | |
css_selector = "html>body>table:nth-of-type(2) tr>td:nth-of-type(3)>table tr>td>form>table tr:nth-of-type(5)>td>table tr>td>table tr:nth-of-type(2)>td>table tr>td:nth-of-type(2)" |
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
deploy@web1:~$ sudo gem install rubaidh-google_analytics -source=http://gems.github.com | |
sudo: gem: command not found | |
deploy@web1:~$ sudo echo $PATH | |
/opt/ree/bin:/opt/ree/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games | |
deploy@web1:~$ which gem | |
/opt/ree/bin/gem | |
deploy@web1:~$ |
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
$(document).ajaxSend(function(event, request, settings) { | |
if (typeof(AUTH_TOKEN) == "undefined") return; | |
settings.data = settings.data || ""; | |
settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN); | |
}); |
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 Session < ActiveRecord::Base | |
end | |
s = Session.find_by_session_id 'INSERT-SESSION-ID-HERE' | |
Marshal.load(Base64.decode64(s.data)) |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) | |
daemon_options = { | |
:multiple => false, | |
:dir_mode => :normal, | |
:dir => File.join(dir, 'tmp', 'pids'), | |
:backtrace => true |
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 InventoryTransaction < ActiveRecord::Base | |
belongs_to :inventory_adjustable, :polymorphic => true | |
belongs_to :inventory | |
after_create :adjust_inventory | |
def adjust_inventory | |
puts "current inventory: #{inventory.quantity_on_hand}" | |
inventory.quantity_on_hand += adjustment |
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 Time | |
def is_after_430_pm? | |
((hour == 16) && (min >= 30)) || (hour > 16) | |
end | |
def is_after_5_pm? | |
(hour >= 17) && (min > 0) | |
end | |
end |
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
def set_default | |
if addressable.kind_of?(User) | |
if default_shipping? | |
addressable.addresses.default_shipping.without(self).each{|a| a.update_attribute(:default_shipping, false) } | |
else | |
default_shipping = true if addressable.addresses.default_shipping.empty? | |
end | |
if default_billing? | |
addressable.addresses.default_billing.without(self).each{|a| a.update_attribute(:default_billing, false) } |
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 Address < ActiveRecord::Base | |
belongs_to :addressable, :polymorphic => true | |
named_scope :default, :conditions => { :default => true } | |
named_scope :without, lambda{|address| { :conditions => ["id <> ?", address.to_param] }} | |
before_save :set_default | |
private | |
def set_default |
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 NextNumber < ActiveRecord::Base | |
class << self | |
VALID_CLASSES = [PurchaseOrder, SalesOrder] | |
def get_next_number_for(object) | |
throw Exception.new("Unsaved object not allowed") if object.new_record? | |
throw Exception.new("Invalid object type for NextNumber#get_next_number_for") unless VALID_CLASSES.include?(object.class) | |
begin |
OlderNewer