1. Pascal / Говнокод #15819

    +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
    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
    96. 96
    97. 97
    98. 98
    while usedthrds<>cn do
              begin
               i:=i+1;
               if manual=0 then
                if i>ccpun then
                 break;
               if manual=1 then
                begin
                 gotoxy(1,stroka);read(cputime[i]);
                end
               else
                begin
                 gotoxy(1,stroka);write(cputime[i]);
                end;
               realsumcpu:=cputime[i]+ost;
               sumcpu:=cputime[i]+ost;
               found:=0;
               bin:=0;
               min:=1;max:=cn;
               search:
               while (min<=max) and (found=0) do
                begin
                 bin:=bin+1;
                 mid:=(min+max)div 2;
                 if sumcpu<sortedthrd[mid] then
                  max:=mid-1
                 else
                  if  sumcpu>sortedthrd[mid] then
                   min:=mid+1
                  else
                   if used[mid]=1 then
                    begin
                     if mid<>cn then
                      begin
                       l:=1;
                       while sortedthrd[mid+l]=sortedthrd[mid] do
                        begin
                         if used[mid+l]<>1 then
                          begin
                            mdldmas:=sortedthrd[mid+l];
                            mdldnum:=sortednum[mid+l];
                            ost:=realsumcpu-mdldmas;
                            used[mid+l]:=1;
                            found:=1;break;
                          end;
                        l:=l+1;
                        if mid+l>cn then break;
                      end;
                  end;
                if (mid<>1) and (found=0) then
                  begin
                    l:=1;
                    while sortedthrd[mid-l]=sortedthrd[mid] do
                      begin
                        if used[mid-l]<>1 then
                          begin
                            mdldmas:=sortedthrd[mid-l];
                            mdldnum:=sortednum[mid-l];
                            ost:=realsumcpu-mdldmas;
                            used[mid-l]:=1;
                            found:=1;break;
                          end;
                        l:=l+1;
                        if mid-l<1 then break;
                      end;
                  end;
                break;
              end
            else
              begin
                mdldmas:=sortedthrd[mid];
                mdldnum:=sortednum[mid];
                used[mid]:=1;
                ost:=realsumcpu-mdldmas;
                found:=1;
                break;
              end;
          end;
    
    if (found=0) and (sumcpu>0) then
      begin
        sumcpu:=sumcpu-1;bin:=0;min:=1;max:=cn;
        goto search;
      end;
    if found=0 then
        ost:=realsumcpu
    else
      begin
        gotoxy(6,stroka);write (realsumcpu);gotoxy (12,stroka);write (mdldmas);gotoxy(18,stroka);write(mdldnum);gotoxy(24,stroka);write(ost);gotoxy(30,stroka);write(bin);
        stroka:=stroka+1;
      end;
    if found=1 then
      begin
        realsumcpu:=ost;
        sumcpu:=ost;
        found:=0;bin:=0;min:=1;max:=cn;
        goto search;
      end;

    Как студенты пишут сортировку (полная версия https://gist.github.com/Karasiq/11184652)

    jkhne4pijgberg, 22 Апреля 2014

    Комментарии (5)
  2. Python / Говнокод #15818

    −98

    1. 1
    2. 2
    3. 3
    4. 4
    if value is False:
        res = ~res
    elif not value is True:
        raise AnalyzeError("Invalid value {0}".format(condition.value))

    hugr, 22 Апреля 2014

    Комментарии (3)
  3. Pascal / Говнокод #15815

    +80

    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
    Procedure ChangeDataBase(var phone:cellphone);
    var ch:char;
    
    Begin clrscr;
    With Phone do
              Begin Line;
    	  TextColor(Cyan); Writeln(' Выберите тип аппарата: '); TextColor(White);
    	  Writeln(' [0-Телефон | 1-Смартфон]');
    
    	  Repeat
    	  Ch:=Readkey;
    	  if (Ch in [#48,#49]) then
    	                                            Begin
    	                                            if (Ch = #48) then Types:=('Телефон');
    	                                            if (Ch = #49) then Types:=('Смартфон');
    	                                            end
    	                                     else
    	                                            Begin
    	                                            TextColor(Red); Writeln(' ОШИБКА: Неверный диапазон! Повторите ввод...')
    	                                            end;
              Until (Ch in [#48,#49]);
    
              TextColor(Cyan); Write(' Тип аппарата: ');TextColor(Yellow); Writeln(Types); Line;
              TextColor(Cyan); Write(' Производитель: '); TextColor(Yellow); Readln(Maker);
              TextColor(Cyan); Write(' Модель: '); TextColor(Yellow); Readln(Model);
              Line;
    
              TextColor(Cyan); Writeln(' Выберите тип корпуса: '); TextColor(White);
              Writeln(' [0-Классический | 1-Раскладной | 2-Слайдер]');
              
              Repeat
              Ch:=Readkey;
              if (Ch in [#48..#50]) then
    	                                              Begin
    	                                              if (Ch = #48) then Body:=('Классический');
    	                                              if (Ch = #49) then Body:=('Раскладной');
    	                                              if (Ch = #50) then Body:=('Слайдер');
    	                                              end
    		                              else
    	                                              Begin
    	                                              TextColor(Red); Writeln(' ОШИБКА: Неверный диапазон! Повторите ввод...')
    	                                              end;
              Until (Ch in [#48..#50]);
    
              TextColor(Cyan); Write(' Тип корпуса: ');TextColor(Yellow); Writeln(Body); Line;
    
              TextColor(Cyan); Writeln(' Выберите операционную систему: '); TextColor(White);
              Writeln(' [0-Asha | 1-Android | 2-Bada OS | 3-iOS | 4-Symbian ]');
    	  Writeln(' [5-Windows Phone 7 | 6-Windows Phone 8 | 7-Другая]');
    	 
              Repeat
    	  Ch:=Readkey;
    	  if (Ch in [#48..#55]) then
    	                                              Begin
    	                                              if (Ch = #48) then Os:=('Asha');
    	                                              if (Ch = #49) then Os:=('Android');
    	                                              if (Ch = #50) then Os:=('Bada OS');
    	                                              if (Ch = #51) then Os:=('iOS');
    	                                              if (Ch = #52) then Os:=('Symbian');
    	                                              if (Ch = #53) then Os:=('Windows Phone 7');
    	                                              if (Ch = #54) then Os:=('Windows Phone 8');
    	                                              if (Ch = #55) then Os:=('Другая');
    	                                              end
    		                              else
    	                                              Begin
    	                                              TextColor(Red); Writeln('ОШИБКА: Неверный диапазон! Повторите ввод...')
    	                                              end;
              Until (Ch in [#48..#55]);
              TextColor(Cyan); Write(' Операционная система: ');TextColor(Yellow); Writeln(Os); Line;
    
              TextColor(Cyan); Write(' Цена: '); TextColor(Yellow); Readln(Price);
    end;
    LastGlobalMenu; {Возврат в основное меню}
    end;

    Serjant, 22 Апреля 2014

    Комментарии (0)
  4. Куча / Говнокод #15814

    +127

    1. 1
    https://www.peereboom.us/assl/assl/html/openssl.html

    laMer007, 22 Апреля 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function commerce_auction_dividable($big, $small) {
      $div = $big / $small;
    
      if (!is_numeric(strpos($div, '.')) === TRUE) {
        return TRUE;
      }
      return FALSE;
    }

    https://drupal.org/node/1721568

    Int, 22 Апреля 2014

    Комментарии (37)
  6. JavaScript / Говнокод #15812

    +158

    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
    for (i in rates) {
       if (CheckFlightInRates(FlightStartRate, rates[i]['dirs'][0]['trips'][0]) == 2) {
          if (CheckFlightInRates(FlightSecondRate, rates[i]['dirs'][0]['trips'][1]) != 0) {
             //var flightNmSecond = rates[i]['dirs'][0]['trips'][1]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][1]['params']['fltNm'];
             if (CheckFlightInRates(FlightSecondRate, rates[i]['dirs'][0]['trips'][1]) == 2) {
                if (CheckFlightInRates(FlightThirdRate, rates[i]['dirs'][0]['trips'][2]) != 0) {
                   //var flightNmThird = rates[i]['dirs'][0]['trips'][2]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][2]['params']['fltNm'];
                   if (CheckFlightInRates(FlightThirdRate, rates[i]['dirs'][0]['trips'][2]) == 2) {
                      if (FlightBackStartRate != '') {
                         if (CheckFlightInRates(FlightBackStartRate, rates[i]['dirs'][1]['trips'][0]) == 2) {
                            if (CheckFlightInRates(FlightBackSecondRate, rates[i]['dirs'][1]['trips'][1]) != 0) {
                               //var flightNmSecond = rates[i]['dirs'][0]['trips'][1]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][1]['params']['fltNm'];
                               if (CheckFlightInRates(FlightBackSecondRate, rates[i]['dirs'][1]['trips'][1]) == 2) {
                                  if (CheckFlightInRates(FlightBackThirdRate, rates[i]['dirs'][1]['trips'][2]) != 0) {
                                     //var flightNmThird = rates[i]['dirs'][0]['trips'][2]['params']['airCmp']+'-'+rates[i]['dirs'][0]['trips'][2]['params']['fltNm'];
                                     if (CheckFlightInRates(FlightBackThirdRate, rates[i]['dirs'][1]['trips'][2]) == 2) {
                                        if (rates[i]['price'] != options.values.price) {
                                           FlightMinPrice3.push(rates[i]['price']);
                                           ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                                        }
                                        else {
                                           FlightMinPrice.push(rates[i]['price']);
                                           ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                                        }
                                     }
                                  }
                                  else {
                                     if (rates[i]['price'] != options.values.price) {
                                        FlightMinPrice3.push(rates[i]['price']);
                                        ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                                     }
                                     else {
    
                                        FlightMinPrice.push(rates[i]['price']);
                                        ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                                     }
                                  }
                               }
                            }
                            else {
                               if (rates[i]['price'] != options.values.price) {
                                  FlightMinPrice3.push(rates[i]['price']);
                                  ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                               }
                               else {
                                  FlightMinPrice.push(rates[i]['price']);
                                  ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                               }
                            }
                         }
                         else {
                            if (rates[i]['price'] != options.values.price) {
                               FlightMinPrice3.push(rates[i]['price']);
                               ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                            }
                            else {
                               FlightMinPriceOther2.push(rates[i]['price']);
                               ButtonToPressOther2[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                            }
                         }
                      }
                      else {
                         if (rates[i]['price'] != options.values.price) {
                            FlightMinPrice3.push(rates[i]['price']);
                            ButtonToPress3[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i
                         }
                         else {
                            FlightMinPrice.push(rates[i]['price']);
                            ButtonToPress[rates[i]['price']] = '#fare_' + rates[i]['id'] + '_' + i;
                         }
                      }
    
                   }

    https://www.svyaznoy.travel/avia/styles/js/Flight.js?cache=20140418-1
    весь русский онлайн-тревел такой

    tablecell, 22 Апреля 2014

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

    +153

    1. 1
    print implode('-', array_reverse(explode('-', trim(substr($project->start_date, 0, count($project->start_date) - 9)))));

    Форматирует дату с Y-m-d в d-m-Y. Альтернатива для
    date_format(new DateTime($project->start_date), 'd-m-Y');

    djumpen, 22 Апреля 2014

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

    +70

    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
    {
    	final int p = page;
    	final boolean current = p == 1;
    	this.pagercell(writer, current, 1, "<<");
    }
    for (int p = page - this.size; p < page; p++) {
    	if (p >= 1) {
    		final boolean current = p == 1;
    		this.pagercell(writer, current, p);
    	}
    }
    {
    	final int p = page;
    	final boolean current = (p - this.size) < 1;
    	this.pagercell(writer, current, p - this.size, "<");
    }
    {
    	final int p = page;
    	final boolean current = p == page;
    	this.pagercell(writer, current, p);
    }
    {
    	final int p = page;
    	final boolean current = (p + this.size) > pages;
    	this.pagercell(writer, current, p + this.size, ">");
    }
    for (int p = page + 1; p <= (page + this.size); p++) {
    	if (p <= pages) {
    		final boolean current = p == pages;
    		this.pagercell(writer, current, p);
    	}
    }
    {
    	final int p = page;
    	final boolean current = p == pages;
    	this.pagercell(writer, current, pages, ">>");
    }

    веселый вывод постраничной навигации (кусок метода)

    Lure Of Chaos, 22 Апреля 2014

    Комментарии (6)
  9. Java / Говнокод #15809

    +64

    1. 1
    short someShort = (short) (someBoolean ? 15 : 42);

    такая удобная Java

    evg_ever, 21 Апреля 2014

    Комментарии (118)
  10. PHP / Говнокод #15808

    +157

    1. 1
    setcookie('password', $passHash , time() + $this::TIME_COOKIE * 1000 +  $remember ? $this::TIME_COOKIE_REMEMBER : 0  * 1000 );

    И я то думал, почему кука не появляется...

    Dart_Sergius, 21 Апреля 2014

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