Skip to content

Instantly share code, notes, and snippets.

View mayra-cabrera's full-sized avatar
💃
Nothing to do here. Go to https://gitlab.com/mayra-cabrera instead

Mayra Cabrera mayra-cabrera

💃
Nothing to do here. Go to https://gitlab.com/mayra-cabrera instead
View GitHub Profile
@mayra-cabrera
mayra-cabrera / gist:11259459
Created April 24, 2014 15:46
Information from wsCourses script
[{"courseserid"=>"CS22889",
"created"=>Wed, 16 Apr 2014 15:01:06 +0000,
"modified"=>Thu, 24 Apr 2014 11:21:31 +0000,
"location_id"=>"lon",
"startdate"=>Fri, 04 Jul 2014,
"enddate"=>Fri, 04 Jul 2014,
"prod_id"=>"67",
"starttime"=>Mon, 01 Jan -4712 08:30:00 +0000,
"endtime"=>Mon, 01 Jan -4712 16:30:00 +0000,
"description"=>
@mayra-cabrera
mayra-cabrera / gist:11404676
Last active August 29, 2015 14:00
3P & IH issue
=> variant
#<Spree::Variant id: 5637, sku: "PM-AWPPM", weight: #<BigDecimal:7fd03c64cff8,'0.338E3',9(18)>, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: false, product_id: 2384, cost_price: nil, position: 2, cost_currency: "USD", track_inventory: true, is_classroom: false>
* Todos los offerings tienen un offertypecode = "PM" *
=> variant.offerings
[#<Offering id: 7630, offering_osg_id: "O199", name: "Aerial Work Platforms Participant Manuals (10-50)", description: "Aerial Work Platforms Participant Manuals (10-50)", variant_id: 5637, code: "PM-AWPPM", price: #<BigDecimal:7fd03c611840,'0.1595E2',18(18)>,...., range: "(10..50)", offertypecode: "PM">,
#<Offering id: 7678, offering_osg_id: "O573", name: "Aerial Work Platforms Participant Manuals (51-100)", description: "Aerial Work Platforms Participant Manuals (51-100)", variant_id: 5637, code: "PM-AWPPM", price: #<BigDecimal:7fd03c610300,'0.1525E2',18(18)>, ...., range: "(51..100)", offertypecode: "PM">,
#<Offering id: 7679, offering_osg
Failures:
1) Crm::SubscriptionTransactionBuilder#build_payments with no payments imported builds a new payment
Failure/Error: @builder.build_payments(chargify_statement)
NoMethodError:
undefined method `find_by_remote_id' for #<Class:0x007fdbeec54708>
# ./app/models/crm/subscription_transaction_builder.rb:22:in `block in build_payments'
# ./app/models/crm/subscription_transaction_builder.rb:19:in `each'
# ./app/models/crm/subscription_transaction_builder.rb:19:in `build_payments'
# ./spec/models/crm/subscription_transaction_builder_spec.rb:73:in `block (5 levels) in <top (required)>'
def make_donation
if recurring?
customer = create_customer
result = recurrent_donation(customer) if customer.success?
else
result = one_time_donation
end
end
celsius = 100
fahrenheit = (celsius * 9 / 5) + 32
print "The result is: "
print fahrenheit
puts “."

Install home brew

En la terminal pon: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

y luego: brew doctor

Install rbenv

En la terminal:

>> Order.columns_hash["pay_type"]
=> #<ActiveRecord::ConnectionAdapters::SQLiteColumn:0x7fe673f7da80
@name="pay_type", @null=true, @default=nil, @sql_type="varchar(10)",
@type=:string, @scale=nil, @precision=nil, @primary=false,
@limit=10>
product.price_before_type_cast #=> "29.95", a string
product.updated_at_before_type_cast #=> "2008-05-13 10:13:14"
@mayra-cabrera
mayra-cabrera / gist:09d79d828afcd194fbd9
Last active August 29, 2015 14:06
Security Rails Best Practices

Avoid SQL injection attacks

It leaves the database wide open to a SQL injection attack, is effectively the same as publishing your entire database to the whole online world.

Dont's

Lets asume that params[:name] is equals to ' OR 1 --

name = params[:name]

orders = Order.where("name = '#{name}' and pay_type = 'po'")

@mayra-cabrera
mayra-cabrera / gist:e6691f3307322c4e2232
Created November 19, 2014 18:09
database.yml dummy
common: &common
adapter: mysql2
encoding: utf8
reconnect: false
pool: 25
username: admin
password: secret
host: localhost
socket: /tmp/mysql.sock
@mayra-cabrera
mayra-cabrera / gist:45bd31910cff4c771314
Last active August 29, 2015 14:11
Deploy with Capistrano

From scratch

SSH as root into the server:

ssh root@123.123.123.123 # Replace with the real ip

Setup deployer user:

Create deployer user: