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

    −126.7

    1. 1
    <li class="list_item primary_card_<%= index+1 %> <%= primary_card.patient.sex == 'male' ? 'boy' : 'girl' %> critical">

    А можно было изменить имя класса в CSS

    nimnull, 26 Декабря 2009

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

    −129.2

    1. 1
    2. 2
    3. 3
    def true_or_nil bool
      !!bool || nil
    end

    eveel, 01 Ноября 2009

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

    −119.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
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    case @demand.status #зависит также от временных групп
    	when 1,4
    		@status_list[2]=@@statuses[2]	
    	when 2,7,8	
    		@status_list[2]=@@statuses[2]
    		@status_list[3]=@@statuses[3]
    		@status_list[7]=@@statuses[7]
    		@status_list[8]=@@statuses[8]
    	when 3
    		@status_list[3]=@@statuses[3]
    		if @is_admin || @demand.watchers.include?(session[:user]) || @demand.heads.include?(session[:user]) ||@see_later_demands_watchers || @see_later_demands_heads
    			@status_list[4]=@@statuses[4]
    		end
    		if @is_admin || @demand.heads.include?(session[:user]) || @see_later_demands_heads
    			@status_list[6]=@@statuses[6]
    		end
    	when 6
    		if @is_admin || @demand.watchers.include?(session[:user]) || @demand.heads.include?(session[:user]) ||@see_later_demands_watchers || @see_later_demands_heads
    			@status_list[4]=@@statuses[4]
    		end	
    	else
    	end

    магия

    Rommel, 18 Октября 2009

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

    −95.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
    @ids.each_index do |di|
            if @ids[di] then
              @ids[di].each_index do |li|
                @employ[di][li] = Hash.new
                @employ[di][li][:subject] = Subject.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:subject_id]
                 }")[:title] if @ids[di][li]
                @employ[di][li][:class] = SchoolClass.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:school_class_id]
                 }")[:number].to_s +
                  SchoolClass.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:school_class_id]
                 }")[:letter] if @ids[di][li]
                @employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
                 }")[:name] + ' ' +
                  @employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
                 }")[:surname] + ' ' +
                  @employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
                  Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
                 }")[:patronymic] if @ids[di][li]
              end
            end
          end

    Небольшая утренняя ревизия кода раскрыла заговор по свержению власти и захвату мозга остальных кодеров проекта.

    Сидим, рефакторим.

    eveel, 26 Августа 2009

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

    −145.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    # I really hate Western week system (0 - sunday, 6 - saturday),
          # maybe it is better, but this crap is incompatible with
          # Russian week system (0 - monday, 6 - sunday)
          wday = date.wday - 1
          wday = 6 if wday == -1

    Кусок кода из реализации расписания с календарём в текущем проекте.

    Только что оказалось, что для этого как раз есть метод Date#cwday :)

    eveel, 17 Августа 2009

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

    −83

    1. 1
    @archive	= File.open(File.expand_path(__FILE__), "rb"){|f| f.read}.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift

    Жесть

    guest, 26 Июля 2009

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

    −326.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
    def properties_file2hash(_property_file, _link_hash=nil)
        r_hash = Hash.new
        if _property_file &&  FileTest::exist?(_property_file)
          f = File::open(_property_file,'r')
          begin
            _lines = f.readlines
            _lines.each{|_line|
              _strip_line = _line.strip
              if (_strip_line.length > 0)&&(_strip_line[0,1]!='#')
                var_plat = _line.split('::')
                if var_plat.length > 1
                  if (RUBY_PLATFORM.include?(var_plat[0]))
                    _line = var_plat[1]
                    var_plat[2..-1].collect{|x| _line=_line+'::'+x} if var_plat.length > 2
                  else
                    _line = ''
                  end
                end
                var = _line.split('=')
                if var.length > 1
                  _value = var[1].strip
                  var[2..-1].collect{|x| _value=_value+'='+x} if var.length > 2
                  if _link_hash 
                    _value = resolve_link(_value, _link_hash)
                  end
                  r_hash[var[0].strip]=_value
                end
              end
            }
          ensure
            f.close unless f.nil?
          end
          return r_hash      
        end

    Реальный кусок... Весь код проги(не моей)... ТАКОЙ.

    guest, 25 Июня 2009

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

    −298.7

    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
    require "rubygems"
    require 'net/ssh'
    class << Net::SSH
      def butforse(passwordarr)
                begin
                  puts "Try password #{passwordarr}"
                  Net::SSH.start('localhost', 'root', :password => "#{passwordarr}")
                  puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
                  exit
                rescue Net::SSH::AuthenticationFailed
                end
      end
    end
    arrays = Array("a".."zz")
    arr1 = arrays[0, (arrays.size-1) / 2]
    arr2 = arrays[(arrays.size - 1) / 2, arrays.size - 1]
    threadsz = []
    threadsz2 = []
    threadsz << Thread.new(arr1) { |items|
      for item in items
        Net::SSH.butforse(item)
      end
    }
    threadsz2 << Thread.new(arr2) { |items|
      for item in items
        Net::SSH.butforse(item)
      end
    }
    threadsz.each {|i| i.join}
    threadsz2.each {|i| i.join}

    И я решил что лудше сразу создать оптимальное количество нитий,

    guest, 11 Июня 2009

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

    −310.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    for page in pages
      threads << Thread.new(page) { |myPage|
        begin
          puts "Try password #{passwordarr}"
          Net::SSH.start('localhost', 'root', :password => "#{passwordarr}")
          puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
          exit
         rescue Net::SSH::AuthenticationFailed
         end
      }
    end

    "взялся я ту периберать пароли от моего ssh..."

    guest, 11 Июня 2009

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

    −140.2

    1. 1
    :logger => lambda { |xyz| logger.info xyz }

    {
    :logger => lambda { |xyz| logger.info xyz }
    }

    guest, 14 Апреля 2009

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