1. Лучший говнокод

    В номинации:
    За время:
  2. Pascal / Говнокод #17956

    +101

    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
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    var
      Excel: OleVariant;
      Rows, Cols: integer;
      WorkSheet: OleVariant;
      DebugList: TStringList;
      I, j, CSeek: integer;
      R, ArrV: OleVariant;
      ObjData: TDataContainer;
      D: integer;
    begin
     {$IFDEF DEBUG}
      DebugList := TStringList.Create;
     {$ENDIF}
      try
        Excel := CreateOleObject('Excel.Application');
        Excel.Visible := false;
        Excel.Workbooks.Open[DocPath, 0, True];
        WorkSheet := Excel.ActiveWorkbook.ActiveSheet;
        R := Excel.Intersect(WorkSheet.UsedRange,
          WorkSheet.UsedRange.Offset[14, 0]);
        ArrV := R.Value;
        Rows := VarArrayHighBound(ArrV, 1);
        Cols := VarArrayHighBound(ArrV, 2);
        {$IFDEF DEBUG}
        DebugList.Add(Format('Количество ячеек в таблице = %d', [(Rows) * Cols]));
        DebugList.Add(Format('Rows = %d, Cols = %d', [Rows, Cols]));
        {$ENDIF}
        CSeek := 0;
        D := 1;
        for I := 1 to Rows do
        begin
          if (CompareStr(Trim(VarToStr(ArrV[I, 1])), Trim('Итого')) = 0) then
            Break;
          if (CompareStr(Trim(VarToStr(ArrV[I, 1])),
            Trim('отдел')) = 0) or
            (CompareStr(Trim(VarToStr(ArrV[I, 1])), Trim('10.05')) = 0) or
            (CompareStr(Trim(VarToStr(ArrV[I, 1])), Trim('10.06')) = 0) or
            (CompareStr(Trim(VarToStr(ArrV[I, 1])), Trim('10.09')) = 0) then
          begin
            CSeek := I + 2;
            Continue;
          end;
          if CSeek > I then
            Continue;
          for j := 1 to Cols do
          begin
            case j of
              1:
                begin
                  if VarToStr(ArrV[I, j]) <> '' then
                  begin
                    ObjData := TDataContainer.Create;
                    ObjData.Name := ArrV[I, j];
                  end;
                end;
              3:
                begin
                  if VarToStr(ArrV[I, j]) <> '' then
                    ObjData.InventoryNumber := GetInventoryNumber(ArrV[I, j]);
                end;
              10:
                begin
                  if (D mod 2 <> 0) then
                  begin
                    if VarToStr(ArrV[I, j]) <> '' then
                      ObjData.DataCount := ArrV[I, j];
                  end
                  else
                    ObjData.Cost := ArrV[I, j];
     
                  if (ObjData <> nil) and (ObjData.DataCount > 0) then
                  begin
                    FData.Add(ObjData);
                    DebugList.Add(ObjData.AsString);
                  end;
                end;
            end;
            Inc(D);
          end;
        end;
        {$IFDEF DEBUG}
        DebugList.Add('Objects created: ' + IntToStr(FData.Count));
        D:=1;
        for ObjData in FData.Items.Values do
           D := D + ObjData.DataCount;
        DebugList.Add('Total objects count: ' + IntToStr(D));
        DebugList.SaveToFile('C:\ExcelDebug.txt');
        {$ENDIF}
      finally
        {$IFDEF DEBUG}
        DebugList.Free;
        {$ENDIF}
        Excel.Quit;
      end;
    end;

    При разборе выхлопа из 1С в Excel - excel и формат выгрузки сделали всё, чтобы я люто наговнокодил-(

    Cynicrus, 08 Апреля 2015

    Комментарии (4)
  3. PHP / Говнокод #17897

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function isRequisitesCorrect()
        {
            switch (true) {
                case $this->isRequisitesSigned() :
                    return true;
                default:
                    return false;
            }
        }

    dimkich, 31 Марта 2015

    Комментарии (4)
  4. PHP / Говнокод #17887

    +160

    1. 1
    eval('function func($what) {global $arr, $USER, $SCRIPT; '.$func.'}');

    3371, 30 Марта 2015

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

    −91

    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
    def update
        error = false
        if params[:geografic].present? && ((params[:geografic] & IsoCountryCodes.all.map{|c|c.alpha2.downcase}) == params[:geografic])
          current_user.profile.geografic = params[:geografic]
        else
          error = true
          flash[:alert] ||= ''
          flash[:alert] << "Need select countries. "
        end
        begin
          current_user.profile.sectors_of_interests = Sector.find(params[:sectors_of_interests])
        rescue
          error = true
          flash[:alert] ||= ''
          flash[:alert] << 'Can not find sectors. '
        end
        if params[:profession_id].present? && profession = Profession.find(params[:profession_id])
          current_user.profile.update_attribute(:profession_id, params[:profession_id])
        else
          error = true
          flash[:alert] ||= ''
          flash[:alert] << 'Can not find profession. '
        end
        if ['cn', 'gb'].include?(params[:language_iso])
          current_user.profile.update_attribute(:country_iso, params[:language_iso])
        else
          error = true
          flash[:alert] ||= ''
          flash[:alert] << "Need select language. "
        end
        if params[:telephone].present?
          current_user.profile.update_attribute(:phone, params[:telephone])
        else
          error = true
          flash[:alert] ||= ''
          flash[:alert] << "Need input phone number. "
        end
    
        require_additional_info = (current_user.geografic.blank? || current_user.sectors_of_interests.blank? || current_user.profession.blank? || current_user.phone.blank?)
        if require_additional_info || error
          redirect_to user_path(current_user) and return
        else
          redirect_to root_path
        end
      end

    Первый раз я видел такое два года назад, думал, что за это время что-то поменялось в людях, неа. А вы говорите индусы

    Ignat_Z, 30 Марта 2015

    Комментарии (4)
  6. PHP / Говнокод #17883

    +162

    1. 1
    <td valign="top" class="pt" <?echo "style='width:20%;max-width: 237px;'";?>>

    В шаблоне сайта Битрикса.

    supercode, 30 Марта 2015

    Комментарии (4)
  7. PHP / Говнокод #17871

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?
      include 'const.php';
      PrintUP("404");
      Echo "<img src='https://lh4.googleusercontent.com/-WnF8tpKQA20/AAAAAAAAAAI/AAAAAAAAEEE/IDe9WUshb8c/s120-c/photo.jpg'>Страница не найдена. =(";
      PrintDOWN();
    ?>

    Не спрашивайте, что делают функции PrintUP() и PrintDOWN(). Первая - 600 строк пхп кода со вставками вида echo ' function() { js-код } ' ; , вторая - 140 строк с очень странными манипуляциями с файлами "базы данных".

    Arris, 26 Марта 2015

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

    +77

    1. 1
    String value = paramValue; //make new instance

    eugene_k, 25 Марта 2015

    Комментарии (4)
  9. C++ / Говнокод #17811

    +54

    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
    std::list<CCPoint> GameMap::stringToCCPArray(std::string points_string, float _x, float _y)
    {
    	points_string.push_back(' ');
    	std::list<CCPoint> CCPList = list<CCPoint>();
    	float x = 0.0f;
    	float y = 0.0f;
    	unsigned int len = 0;
    	bool isCurrentX = true;
    	for(std::string::iterator it = points_string.begin(); it != points_string.end(); ++it){
    		int q = 0;
    		len > 0 ? 
    			--len: (isdigit(*it) ? 
    				(q = atoi(&(*it)), len = countNumbersInInt(q), 
    				isCurrentX ?
    					x = atoi(&(*it)): y = atoi(&(*it))) : 
    				*it == ',' ? 
    					(isCurrentX = false): (CCPList.push_back(ccp(x,(-1 * y))), x = 0.0f, y = 0.0f, isCurrentX = true)) ;
    	}
    
    	return CCPList;
    }

    t0rmund, 18 Марта 2015

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

    −397

    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
    [array_static removeAllObjects];
    [array_static addObject:@"Files"];
    [array addObjectsFromArray:[filemanager contentsOfDirectoryAtPath:DOCUMENTS error:nil]];
    
    for (int l=0; l<array.count; l++) {
    	for (int j=0; j<array.count; j++) {
    		for (int i=0; i<array.count; i++) {
    			if ([[array objectAtIndex:i] rangeOfString:@"."].location != NSNotFound) {
    				[array removeObjectAtIndex:i];
    			}
    		}
    	}
    }
    
    for (int i = 0; i<array.count; i++) {
    	if (![array_static containsObject:[array objectAtIndex:i]]) {
    		[array_static addObject:[array objectAtIndex:i]];
    	}
    }

    Дали задание добавить фичу в один старый проект. Открыл проект, сижу и наслаждаюсь видом 8)

    OUrsus, 16 Марта 2015

    Комментарии (4)
  11. PHP / Говнокод #17784

    +156

    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
    <?php
    
    error_reporting(E_ALL);
    require_once('project.php');
    $loader = new Twig_Loader_Filesystem('templates');
    $twig = new Twig_Environment($loader,
        array(
            'cache' => 'compilation_cache',
            'debug' => true
        )
    );
    $twig->addExtension(new Twig_Extension_Debug());
    $data='';
    $data .= summ('summa','zvit');
    $payments =getPayments();//tableM(getPayments());
    
    
    if (array_key_exists('go', $_REQUEST))
        {
        $go=$_REQUEST['go'];
        }
        else
        {
        $go='';
        }
    switch ($go) {
        case '':
            echo $twig->render('index.html',array('payments' => $payments)); ); //
            break;
        case 'addData':
            $form = showForm();
            echo "$form";
            break;
        case 'add':
            $data=$_POST['data'];
            $summa=$_POST['summa'];
            addDate($data,$summa);
            redirect('index.php');
            break;
        case 'delete':
            $id = $_GET['id'];
            delete($id);
            redirect('index.php');
            break;
    }

    vityapro, 13 Марта 2015

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