Skip to content

Instantly share code, notes, and snippets.

View npverni's full-sized avatar

Nathan Verni npverni

  • Tropic
  • 56th and Wabasha
View GitHub Profile
# add this to ./features/support/hooks.rb
After('@debug') do
puts response.body
end
# tag any features with @debug to get the output printed
# especially handy for testing json and xml responses
ruby-1.8.7-p249 > s = Chargify::Subscription.find(:first)
ruby-1.8.7-p249 > s.credit_card.expiration_year
=> 2020
ruby-1.8.7-p249 > s.credit_card_attributes = {:expiration_year => "2014"}
ruby-1.8.7-p249 > s.save
ruby-1.8.7-p249 > s.reload
ruby-1.8.7-p249 > s.credit_card.expiration_year
=> 2014
ruby-1.8.7-p249 > s = Chargify::Subscription.find(:first)
#
# Is there a way to override the root name for as_json or to_json?
#
Book.first.to_json
#=> "{\"book\":{\"created_at\":\"2010-03-23
Book.first.to_json(:root => 'libro') # is there an option like this?
#=> "{\"libro\":{\"created_at\":\"2010-03-23
Chargify::Product.find(:all).group_by{|p| p.product_family}.select{|pf| pf[0].id = PRODUCT_FAMILY_ID}.first
if %w(solo app app_master).include?(node[:instance_role])
user = node[:owner_name]
framework_env = node[:environment][:framework_env]
# Be sure to replace APP_NAME with the name of your application.
# The run_for_app method also accepts multiple application name arguments.
run_for_app 'foobar' do |app_name, data|
worker_name = "#{app_name}_delayed_job"
directory "/data/#{app_name}/shared/pids" do
<subscription>
<product_id>'.$product.'</product_id>
<customer_attributes>
<first_name>'.$fname.'</first_name>
<last_name>'.$lname.'</last_name>
<email>'.$email.'</email>
<organization>'.$propertyname.'</organization>
<address>'.$shipadd1.'</address>
<address_2>'.$shipadd2.'</address_2>
</customer_attributes>
require "rubygems"
require "json"
data = '[
{
"name": "John Doe",
"location": {
"name": "New York, New York",
"id": 12746342329
},
"hometown": {
ree-1.8.7-2010.02 > she = She.new
=> #<She:0x1003727f0>
ree-1.8.7-2010.02 > she.respond_to?(:steal)
=> true
ree-1.8.7-2010.02 > she.respond_to?(:rob)
=> false
@npverni
npverni / eggnog.rb
Created December 8, 2010 16:37
ruby egg nog
egg_nog = {
:egg_yolks => 12,
:lbs_sugar => 1,
:cups_rum => 2,
:cups_bourbon => 2,
:quarts_whipping_cream => 2,
:egg_whites => 12,
:nutmeg => "sprinkle"
}
@npverni
npverni / sample.js
Created October 14, 2011 22:27
Chargify - Hosted Page 'Purchase Summary' refresh callback
/*
The 'Purchase Summary' section of the hosted page gets periodically updated via Ajax
when the user:
1) Loads the page
2) Validates a Coupon
3) Validates a VAT number
4) Selects billing/shipping state/country (for tax purposes)
Add this to the 'Custom JavaScript' section of your hosted page settings to respond to this event.