iMustardSoft imustardsoft

View Gist.sublime-settings
1 2 3 4 5 6 7 8 9
"include_users": false,
// "include_users": ["user1", "user2"],
 
// Show the authors of Gists
"show_authors": false,
 
// Proxy server
// Format: "http://user:pass@proxy:port"
"https_proxy": "",
View bench.rb
1 2 3 4 5 6 7
require 'benchmark'
 
result = Benchmark.measure do
"a"*1_000_000_000
end
 
puts result.total
View test1.rb
1 2 3 4 5 6 7 8 9 10
require 'active_support/concern'
 
 
module MyModule
 
def my_val
@my_val ||= 2
end
# def self.included(receiver)
# receiver.instance_variable_set('@my_val',2)
View gist:5148725
1
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpC35S4+PUe8vbraqdRX76aQq8+yhumx7EdQlAaoPUJwqrX/EaY1SBJnkIRczQEpMcxCl66kIpWV1PywIm8zlaVAbUj9xwdtlcG5dHn6hBtpzWBY1B3PbN4nsO/cXOx5yJn0beqo71iJDKq9YRkmQlLU6qEeEx0CRNR/ulx9XsFqOx8tB/5idkQ5algxDLhnyOojKsEWkByr7NOJLNaeeOjm5ivsIzsK7mL+WQPzeJhi2t6q0UWb44YdVTT7GJD9isRNpAnhC19rK6Oj3MD4EEppMGN6inMpZuPhpeIECsAv6Ahc86Jj7MTrGxBx7E1Kp3EiqU62Y3oskCP99QKnHT
View gist:1347759
1 2 3 4 5
 
# total amount of the order, only considering item cost
def amount
self.line_items.map(&:amount).sum
end
View gist:1347754
1 2 3 4 5 6 7 8 9 10
class Calculator::PriceBucket < Calculator
preference :minimal_amount, :decimal, :default => 0
preference :normal_amount, :decimal, :default => 0
preference :discount_amount, :decimal, :default => 0
 
def self.description
I18n.t("price_bucket")
end
 
# as object we always get line items, as calculable we have Coupon, ShippingMethod
View gist:1347631
1 2 3 4 5 6 7 8 9 10
ActionView::Template::Error (undefined method `to_d' for #<Order:0x82cce98>):
14: <h3>Shipping Method:</h3>
15: <div class="method">
16: <% i = 1 %>
17: <% @order.rate_hash.each do |shipping_method| %>
18: <%= radio_button(:order, :shipping_method_id, shipping_method[:id], :class => "radio#{i}", :id => shipping_method[:cost]) %>
19: <label><%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %></label>
20: <div class="clear"></div>
app/views/checkout/_payment.html.erb:17:in `_app_views_checkout__payment_html_erb___481978343_67756860_4938188'
app/views/checkout/edit.html.erb:7:in `_app_views_checkout_edit_html_erb__453920959_66761340_0'
View rails select tag
1 2 3
 
select_tag "people", options_from_collection_for_select(@people, "id", "name"), :prompt => "Select something"
# => <select id="people" name="people"><option value="">Select something</option><option value="1">David</option></select>
View form_tag_helper.rb
1 2 3 4 5 6 7 8 9 10
def select_tag(name, option_tags = nil, options = {})
if Array === option_tags
ActiveSupport::Deprecation.warn 'Passing an array of option_tags to select_tag implicitly joins them without marking them as HTML-safe. Pass option_tags.join.html_safe instead.', caller
end
 
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
if blank = options.delete(:include_blank)
if blank.kind_of?(String)
option_tags = "<option value=\"\">#{blank}</option>".html_safe + option_tags
else
View gist:1042389
1 2
set :gateway, 'YOUR GATEWAY SERVER IP'
role :web, "web1", "web2"
Something went wrong with that request. Please try again.