Skip to content

Instantly share code, notes, and snippets.

iMustardSoft imustardsoft

Block or report user

Report or block imustardsoft

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Gist.sublime-settings
"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
require 'benchmark'
result = Benchmark.measure do
"a"*1_000_000_000
end
puts result.total
@imustardsoft
imustardsoft / test1.rb
Created May 13, 2013
module initialize
View test1.rb
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpC35S4+PUe8vbraqdRX76aQq8+yhumx7EdQlAaoPUJwqrX/EaY1SBJnkIRczQEpMcxCl66kIpWV1PywIm8zlaVAbUj9xwdtlcG5dHn6hBtpzWBY1B3PbN4nsO/cXOx5yJn0beqo71iJDKq9YRkmQlLU6qEeEx0CRNR/ulx9XsFqOx8tB/5idkQ5algxDLhnyOojKsEWkByr7NOJLNaeeOjm5ivsIzsK7mL+WQPzeJhi2t6q0UWb44YdVTT7GJD9isRNpAnhC19rK6Oj3MD4EEppMGN6inMpZuPhpeIECsAv6Ahc86Jj7MTrGxBx7E1Kp3EiqU62Y3oskCP99QKnHT
View gist:1347759
# total amount of the order, only considering item cost
def amount
self.line_items.map(&:amount).sum
end
View gist:1347631
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 gist:1347754
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
@imustardsoft
imustardsoft / rails select tag
Created Oct 15, 2011
examples from rails doc
View rails select tag
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>
@imustardsoft
imustardsoft / form_tag_helper.rb
Created Oct 13, 2011
actionpack-3.0.6/lib/action_view/helpers/form_tag_helper.rb
View form_tag_helper.rb
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
set :gateway, 'YOUR GATEWAY SERVER IP'
role :web, "web1", "web2"
You can’t perform that action at this time.