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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
FILE_TYPES_EXTENSIONS.each do |t, e|
      if e.include? extension
        return t
      elsif e.any? {|_e| _e.is_a? Hash}
        if _t = e.reduce({}) { |m, x| m = m.merge(x) if x.is_a?(Hash); m }.find{|_t, _e| _e.include? extension}
          return retrieve_parent ? t : _t.first
        end
      end
    end
    nil

только создатель поймет, насрал и пропал

ruby_noname ruby_noname, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
def index
  categories = params[:category_ids].present? ?
    params[:category_ids].collect {|id| Category.find id } :
      Category.all
    respond_with(:api, categories)
end

когда не знаешь как на это реагировать

AlexKlim AlexKlim, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
@requests  = Request.where(instrument_id: 1).where("state_id not in (12,3,5,8,13,15,4)").where(id: current_user.arr_request_services).order(priority_id: :desc, updated_at: :desc, id: :desc) #.page(params[:page]).per_page(20)
        @requests1 = Request.where(instrument_id: 1).where(locked_by: current_user).where("state_id not in (12,3,5,8,13,15,4)").order(priority_id: :desc, updated_at: :desc, id: :desc)
        @requests2 = Request.where(instrument_id: 1).where(author_id: current_user.id).where("state_id not in (12,3,5,8,13,15,4)").order(priority_id: :desc, updated_at: :desc, id: :desc)
        @requests3 = Request.where(instrument_id: 1).where(owner_id: current_user.id).where("state_id not in (12,3,5,8,13,15,4)").order(priority_id: :desc, updated_at: :desc, id: :desc)
        @requests  = (@requests + @requests1 + @requests2 + @requests3).uniq

Что это ?

eggshke eggshke, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
class Huyomoyo

  attr_reader :hui_razmer

  def initialize(hui_razmer = 0)
    @hui_razmer = case hui_razmer
      when 0
        'Нету'
      when 1..3
        'Пиздец маленький'
      when 4..6
        'Ну... Уже лучше'
      when 7..9
        'Норма'
      when 10..12
        'Ууажюха'
      when 13..17
        'Мдаааа'
      when 18..22
        'НИХУЯСЕБЕ'
      when 23..40
        'Да ты пиздишь'
      else
        'Че??'
    end
  end

  def print_hui
    puts @hui
  end
end

if __FILE__ == $0
  9.times do |i|
    kusokgovnokoda = case i
                       when 0
                         0
                       when 1
                         1
                       when 2
                         4
                       when 3
                         7
                       when 4
                         10
                       when 5
                         13
                       when 6
                         18
                       when 7
                         23
                       when 8
                         41
                     end
    Huyomoyo.new(kusokgovnokoda).print_hui
  end
end

Я не посню што это вообще... Вроде говнокод

The_Nick_Dev The_Nick_Dev, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
def self
  self
end

irb(main):002:0> self
=> main
irb(main):003:0> self.self
=> main
irb(main):004:0> # уииииииииииииииииииииииииииииииии
irb(main):005:0* self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.self
=> main

Stallman Stallman, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
# как надо укуриться чтобы придумать такой синтаксис? вам не кажется что стрелочка немного не там?
my_sum = -> (arg1, arg2) {arg1 + arg2}

# тем более что это полный алиас
my_sum = lambda {|arg1, arg2| arg1 + arg2}
# нафига?!

SemaReal SemaReal, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
Ruby programmers are very particular about how their for-loops are written and will declare you a bad programmer for simply using this one construct wrong. 
They went so far as to break the for-each version of looping so that there are problems with using it, forcing you to conform to their culture. Heed my warning that
 you should always use .each and never for-each for fear of being forever branded bad and shunned. Yes, it is as ridiculous as it sounds.

# запишут в пидарасы
for i in (1..10)
  puts i
end

# зауважают
(1..10).each do |i|
  puts i
end

SemaReal SemaReal, (Updated )

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