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
############################################################################### | |
# SGE New Developer Challenge #2 | |
############################################################################### | |
Problem: | |
A colleague of yours has a terrible habit of misspelling their words. The odd | |
thing is that there is a consistent pattern such that it is always the last | |
two letters that get messed up. |
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
pages = @page.country? ? Page.where(:description_type_id => @page.description_type_id, :city_id => nil).limit(10) : | |
Page.for_top.where(:description_type_id => @page.description_type_id || @page.category.try(:description_type_id), | |
:city_id => @page.city_id, | |
:country_id => @page.country_id).limit(10) |
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 AddNewFieldsToComments < ActiveRecord::Migration | |
def self.up | |
add_column :comments, :ip, :string | |
add_column :comments, :rate, :integer | |
add_column :comments, :email, :string | |
add_column :comments, :user_name, :string | |
add_column :comments, :description, :text | |
add_column :comments, :page_id, :integer | |
remove_column :comments, :title | |
remove_column :comments, :comment |
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
<h3 class="title-text title-text-top0">Добавить отзыв</h3> | |
<%= form_for [@page, @comment] do |f| %> | |
<div class="row-form1 clear"> | |
<div class="col-1 fleft"> | |
<div class="row-form1 clear"> | |
<div class="row-form1-left fleft">Имя:</div> | |
<div class="row-form1-right fleft"><%= f.text_field :user_name %></div> | |
</div> | |
</div> | |
<div class="col-2 fleft"> |
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
diff --git a/app/admin/pages.rb b/app/admin/pages.rb | |
index d857bab..fe5c3bb 100644 | |
--- a/app/admin/pages.rb | |
+++ b/app/admin/pages.rb | |
@@ -48,18 +48,17 @@ ActiveAdmin.register Page do | |
end | |
f.inputs 'Working days' do | |
- f.input :monday, :as => :boolean | |
- f.semantic_fields_for :working_date_times, f.object.working_date_times.where(:working_day => 1).first || f.object.working_date_times.new(:working_day => 1) do |cw| |
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
Есть такой вот OrderedHash, причем его порядок может изменяться при каждом создании Hash'а: | |
{"FEDEX_EXPRESS" => {:additional_services_amount=>298, :retail_price=>21.03, :price=>18.05, :total_amount=>2103, :your_cost=>16.824, :you_save=>4.206, :base_amount=>1805}, | |
"PRIORITY_OVERNIGHT"=>{:additional_services_amount=>944, :retail_price=>66.74, :price=>57.3, :total_amount=>6675, :your_cost=>53.392, :you_save=>13.348, :base_amount=>5730}, | |
"FEDEX_2_DAY"=>{:additional_services_amount=>380, :retail_price=>26.85, :price=>23.05, :total_amount=>2685, :your_cost=>21.48, :you_save=>5.37, :base_amount=>2305}, | |
"FEDEX_GROUND"=>{:additional_services_amount=>40, :retail_price=>8.06, :price=>7.66, :total_amount=>806, :your_cost=>7.254, :you_save=>0.806, :base_amount=>766}} | |
Нужно упорядочить этот OrderedHash в порядке следования ключей. Порядок такой: "PRIORITY_OVERNIGHT", "FEDEX_2_DAY", "FEDEX_EXPRESS", "FEDEX_GROUND" | |
Т.е. результат должен быть такой: |
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
<div class="text-box clear"> | |
<% last_index = 3 %> | |
<% @page.single_custom_fields.in_groups_of(3, false) do |g| %> | |
<% g.each_with_index do |f, index| %> | |
<% last_index = index.succ %> | |
<div class='col-<%= last_index %> fleft'> | |
<% unless f.custom_field.icon.blank? %> | |
<h4> | |
<%= image_tag f.custom_field.icon, :alt => f.custom_field.name, :title => f.custom_field.name %> | |
<%= f.custom_field.name %> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<createCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> | |
<merchantAuthentication> | |
<name>833AGyde</name> | |
<transactionKey>8y3992E43WMjegXG</transactionKey> | |
</merchantAuthentication> | |
<customerProfileId>30278293</customerProfileId> | |
<paymentProfile> | |
<customerType>individual</customerType> | |
<billTo> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<createCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> | |
<merchantAuthentication> | |
<name>833AGyde</name> | |
<transactionKey>8y3992E43WMjegXG</transactionKey> | |
</merchantAuthentication> | |
<customerProfileId>6966741</customerProfileId> | |
<paymentProfile> | |
<customerType>individual</customerType> | |
<billTo> |
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
[apsadmin@www ~]$ sudo gem install --with-pg-config=/usr/pgsql-9.0/bin/pg_config | |
ERROR: While executing gem ... (OptionParser::InvalidOption) | |
invalid option: --with-pg-config=/usr/pgsql-9.0/bin/pg_config | |
[apsadmin@www ~]$ sudo gem install pg | |
Building native extensions. This could take a while... | |
ERROR: Error installing pg: | |
ERROR: Failed to build gem native extension. | |
/usr/local/bin/ruby extconf.rb | |
checking for pg_config... no |