1. Ruby / Говнокод #3786

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    @timestart = MyModel.lastUpdateTime - 1.hour
    
    day = "#{@timestart.day}"
    day = "0#{day}" if day.size<2
    mon = "#{@timestart.mon}"
    mon = "0#{mon}" if mon.size<2
    
    start1 = "'#{@timestart.year}-#{mon}-#{day} #{@timestart.hour}:#{@timestart.min}:#{@timestart.sec}'"
    a = MyModel.find(:all, :conditions=>[ "`datetime` > #{start1}" ]

    без комментариев

    Запостил: vlad-druzh, 27 Июля 2010

    Комментарии (4)
  2. Ruby / Говнокод #3675

    +9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if html_content.product_id == 11 || html_content.product_id == 8 || html_content.product_id == 15 || html_content.product_id == 20 
      @terms_and_conditions = Page.find(212).contents
    else 
      @terms_and_conditions = Page.find(213).contents  
    end

    Запостил: paveldruzyak, 09 Июля 2010

    Комментарии (8)
  3. Ruby / Говнокод #3672

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    unless cs.blank?
    cs.each do |cc|
    unless cc.nil?
    unless cc['StatsDetail'].nil?
    ccs=cc['StatsDetail']
    ccs=cc['StatsDetail'].to_a
    ccs.each do |cc1|
    cc2=cc1
    ctime = Time.at(cc2.time.to_i).midnight
    c_url_keyword[ctime] = {} if c_url_keyword[ctime].nil?
    k = {:url=>cc2.url, :keyword=>cc2.keyword, um=>0.0}
    c_url_keyword[ctime][k] = {um=>0, :clicks=>0, :id=>cc2.adConditionId} if c_url_keyword[ctime][k].nil?
    c_url_keyword[ctime][k][um]+=cc2.bid.to_f
    c_url_keyword[ctime][k][:clicks]+=1
    end
    end
    end
    end
    end

    что хотелось этим сказать я не помню, а сейчас фиг разберешь

    Запостил: piroman171, 08 Июля 2010

    Комментарии (15)
  4. Ruby / Говнокод #3394

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    def get_next_line(max_level, current_level, current_line_items)
            next_line_items = []
            result_string = ''
    
            if current_level == 1
                    next_line_items.push(1)
                    result_string = "1\n"
            else
                    current_line_number = false
                    current_line_number_count = 0
                    current_index = 0
    
                    current_line_items.each do |line_number|
                            if current_index == 0
                                    current_line_number = line_number
                                    current_line_number_count = 1
                            else
                                    if line_number == current_line_number
                                            current_line_number_count = current_line_number_count + 1
                                    else
                                            next_line_items.push(current_line_number_count)
                                            next_line_items.push(current_line_number)
    
                                            current_line_number_count = 1
                                            current_line_number = line_number
                                    end
                            end
    
                            if current_index >= current_line_items.length - 1
                                    next_line_items.push(current_line_number_count)
                                    next_line_items.push(current_line_number)
                            end
    
                            current_index = current_index + 1
                    end
    
                    result_string = next_line_items.join(' ') + "\n"
            end
    
            if current_level < max_level
                    result_string = result_string + get_next_line(max_level, current_level + 1, next_line_items).to_s
            end
    
            # return result
            result_string
    end
    
    puts 'Input max level:'
    level = gets
    
    puts ''
    puts get_next_line(level.to_i, 1, [])

    реальное тестовое задание кандитата.
    задача - вывести несколько членов последовательности
    1
    11
    21
    1211
    ....

    Запостил: malleus, 04 Июня 2010

    Комментарии (15)
  5. Ruby / Говнокод #3310

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    <% form_tag(advertiser_creatives_path(@advertiser), :method=>'post' ) do %>
      <% content_tag :table, :class => "form-tabular" do %>
        <% content_tag :thead do %>
          <% content_tag :tr do %>
            <% tag :th, :class=>'hide'%>
            <% content_tag :th do %>
              Concept (optional)
            <%end%>
            <% content_tag :th do %>
               Ad Tag
            <%end%>
            <% content_tag :th do %>
               Click-Through URL
            <%end%>
            <th/>
          <%end%>
        <%end%>
        <% content_tag :tbody, :id=>'creative_sub_forms' do %>
          <% creatives.each_with_index do |creative, index| 
              next unless creative.new_record?
            %>
            <% unless creative.errors.empty? %>
              <tr class='nowrap'>
                <td colspan='3'>
                  Error:
                  <% creative.errors.full_messages.each do |msg| %>
                  <%= msg %><br/>
                  <%end%>
                </td>
              </tr>
            <%end%>
            <%=render :partial => 'creative_fields', :locals => {:index => index, :creative => creative}%>
          <%end%>
        <%end%>
        <tr>
          <td colspan='3'><%= link_to_add_creative_fields "Add row"  %></td>
        </tr>
      <%end%>
      <br/>
      <br/>
      <%= submit_tag 'Continue', :class=>'button' %>
    <%end%>

    Товарищи, заставляйте нубой учить HTML. Ну, или HAML.

    Запостил: cheba, 25 Мая 2010

    Комментарии (19)
  6. Ruby / Говнокод #3236

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    class User < ActiveRecord::Base
    
      #Состояния подтвержденности email
      state_machine :email_state, :initial => :unconfirmed, :namespace => 'email' do
        event :confirm do
          transition [:unconfirmed] => :confirmed
        end
    
        event :unconfirm do
          transition [:confirmed] => :unconfirmed
        end
      end
    
    end

    Запостил: antono, 16 Мая 2010

    Комментарии (2)
  7. Ruby / Говнокод #3029

    +4.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    def ordinalize_ru integer
      postfix = case integer
        when 0 then 'ой'
        when 2 then 'ой'
        when 3 then 'ий'
        when 6 then 'ой'
        when 7 then 'ой'
        when 8 then 'ой'
        else 'й'
      end
      [ integer, postfix ].join '-'
    end

    Когда нет времени вникать в правила родного языка и русской речи. Суровый уральский говнокод.

    Запостил: eveel, 17 Апреля 2010

    Комментарии (19)
  8. Ruby / Говнокод #2885

    −2.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    # TODO: выбросить нахер метод with_company_and_state и правильно написать
    # этот named scope
    named_scope :with_company_and_state_non_uniq, lambda { |company, state|
      { :conditions => [ 'products.company_id = :company_id AND ' +
            'state_mask = :state_mask', { :company_id => company,
            :state_mask => OrderSet::STATES.index(state) || 0 } ],
        :order => 'order_sets.created_at DESC',
        :joins => 'INNER JOIN products' }
    }
    
    def self.with_company_and_state(company, state)
      with_company_and_state_non_uniq(company, state).uniq
    end

    Бывает, что SELECT DISTINCT сделать не всегда возможно. На самом деле, такая выборка сосёт.

    Запостил: eveel, 28 Марта 2010

    Комментарии (2)
  9. Ruby / Говнокод #2749

    +1.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    class Vector
      def -@
        map(&:-@)
      end
    end

    Код мой, говнокодом бы не назвал, но без улыбки точно не взглянешь на такое =)
    (тут определение унарного минуса через вызов того же унарного минуса у всех элементов вектора, Кэп)

    Запостил: rakoth3d, 11 Марта 2010

    Комментарии (4)
  10. Ruby / Говнокод #2620

    +3.7

    1. 1
    2. 2
    3. 3
    from app/controllers/test_controller.rb:13:in `index'
    from (irb):4
    from ♥:0>>

    Сразу предупреждаю: не говнокод (и даже не код), можно минусовать.
    День Святого Валентина, Interactive Ruby выдал такое, типа с праздником :)
    PS: незнаю где здесь руби.

    Запостил: hardcoder, 15 Февраля 2010

    Комментарии (2)