Яuбy / Говнокод #7122 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
@hands_by_value.each do |hand|
	if @hands_by_value.slice(@hands_by_value.index(hand)+1..@hands_by_value.index(@hands_by_value.last)).include?(hand)
			@hands_by_value.delete_at(@hands_by_value.index(hand))			
		end
	end

Рукотворный array.uniq! похоже :)

lnk lnk, (Updated )

Комментарии (7, +7)

Яuбy / Говнокод #7112 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
def self.enddayofmonth(year,month)
  stdyear=[31,28,31,30,31,30,31,31,30,31,30,31]
  visyear=[31,29,31,30,31,30,31,31,30,31,30,31]
  if year%4>0
    return stdyear[month-1]
  else
    return visyear[month-1]
  end
end

vlad-druzh vlad-druzh, (Updated )

Комментарии (10, +10)

Яuбy / Говнокод #6751 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
respond_with_error("Lat can't be blank.", :unprocessable_entity) and return if params[:lat].blank?
    respond_with_error("Lon can't be blank.", :unprocessable_entity) and return if params[:lon].blank?
    respond_with_error("Lat is not a number.", :unprocessable_entity) and return if !is_float?(params[:lat])
    respond_with_error("Lon is not a number.", :unprocessable_entity) and return if !is_float?(params[:lon])

индусский кот от Фет Фрумоса

sumskyi sumskyi, (Updated )

Комментарии (13, +13)

Яuбy / Говнокод #6612 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
def parse_response(object)
    return Hashie::Mash.new(JSON.parse(object))
  rescue => e
    #should handle here different error types/levels or else throw the exceptions to the upper layer (client)
    if e.is_a?(JSON::ParserError) && e.message =~ /<html>/
      raise "Invalid response from Platform server - #{self.class.parse_json_error(response.body)}"
    else
      raise e
    end
  end

sumskyi sumskyi, (Updated )

Комментарии (4, +4)