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

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

    +1

    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
    public class Uptime {
        private short minute;
        private byte hour;
        private short day;
        private short month;
        private short year;
        
        public Uptime() {
            ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
            executorService.scheduleAtFixedRate(() -> {
                minute++;
                if(minute >= 61) {
                    hour++;
                    minute = 0;
                    if(hour >= 25) {
                        day++;
                        hour = 0;
                        if(day >= 31) {
                            month++;
                            day = 0;
                            if(month >= 13) {
                                year++;
                                month = 0;
                            }
                        }
                    }
                }
            }, 1, 1, TimeUnit.MINUTES);
        }
    
        public short getMinute() {
            return minute;
        }
    
        public byte getHour() {
            return hour;
        }
    
        public short getDay() {
            return day;
        }
    
        public short getMonth() {
            return month;
        }
    
        public short getYear() {
            return year;
        }
    }

    Код для получения аптайма приложения.

    Belz, 20 Августа 2019

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

    +1

    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
    <?php
    
    namespace App\Http\Controllers\Admin;
    
    use App\Command\Admin\User\Create\Command as UserCreateCommand;
    use App\Command\Admin\User\Update\Command as UserUpdateCommand;
    use App\Command\Admin\User\Remove\Command as UserRemoveCommand;
    use App\Command\User\Auth\Verify\Command as UserVerifyCommand;
    use App\Command\Admin\User\Draft\Command as UserDraftCommand;
    use App\Command\CommandBus;
    use App\Entity\User\User;
    use App\Http\Controllers\Controller;
    use App\Http\Requests\Admin\Users\CreateRequest;
    use App\Http\Requests\Admin\Users\UpdateRequest;
    use App\Query\Admin\User\FindUsersByDescQuery;
    use App\Query\Admin\User\Role\GetUserRolesQuery;
    use App\Query\Admin\User\Status\GetUserStatusesQuery;
    use App\Query\QueryBus;
    use Illuminate\Database\Eloquent\Builder;
    use Illuminate\Http\Request;
    
    class UsersController extends Controller
    {
        private $commandBus;
        private $queryBus;
    
        public function __construct(CommandBus $commandBus, QueryBus $queryBus)
        {
            $this->commandBus = $commandBus;
            $this->queryBus = $queryBus;
        }
    
        public function index()
        {
            $query = $this->queryBus->query(new FindUsersByDescQuery());
            $users = $query->paginate(20);
    
            $statuses = $this->queryBus->query(new GetUserStatusesQuery());
            $roles = $this->queryBus->query(new GetUserRolesQuery());
    
            return view('admin.users.index', compact('users', 'statuses', 'roles'));
        }
    
        public function create()
        {
            return view('admin.users.create');
        }
    
        public function store(CreateRequest $request)
        {
            $this->commandBus->handle(new UserCreateCommand($request));
    
            return redirect()->route('admin.users.index');
        }
    
        public function show(User $user)
        {
            return view('admin.users.show', compact('user'));
        }
    
        public function edit(User $user)
        {
            $roles = $this->queryBus->query(new GetUserRolesQuery());
    
            return view('admin.users.edit', compact('user', 'roles'));
        }
    
        public function update(UpdateRequest $request, User $user)
        {
            $this->commandBus->handle(new UserUpdateCommand($request, $user));
    
            return redirect()->route('admin.users.index');
        }
    
        public function destroy(User $user)
        {
            $this->commandBus->handle(new UserRemoveCommand($user));
    
            return redirect()->route('admin.users.index');
        }
    
        public function verify(User $user)
        {
            $this->commandBus->handle(new UserVerifyCommand($user));
    
            return redirect()->route('admin.users.show', $user);
        }
    
        public function draft(User $user)
        {
            $this->commandBus->handle(new UserDraftCommand($user));
    
            return redirect()->route('admin.users.show', $user);
        }
    }

    kartoshka, 20 Августа 2019

    Комментарии (30)
  4. Си / Говнокод #25766

    +1

    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
    case 1342:
    	    {
    	        if(!response) return true;
    	        //ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    	        switch(listitem)
    	        {
    				case 0:
    				{
                        //if(!IsAtFishPlace(playerid)) return SendClientMessage(playerid,0x81DA99AA,"Вы должны находиться возле причала");
    	   				if(!GetPVarInt(playerid,"fish_began"))
    	   				{
    	   				    if(!GetPVarInt(playerid,"fish_rod")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет удочки");
    				    	if(!GetPVarInt(playerid,"fish_gear")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет снастей");
    				    	if(!GetPVarInt(playerid,"fish_worms")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет червей");
    	   				    UpdateFish(playerid);
    	   				    PlayerTextDrawShow(playerid,FishingText[playerid]);
    	   				    SetPlayerAttachedObject(playerid, 0,18632,6,0.079376,0.037070,0.007706,181.482910,0.000000,0.000000,1.000000,1.000000,1.000000);
    				   		SetPVarInt(playerid,"fish_began",1);
    				   		DeletePVar(playerid,"fish_time");
    						DeletePVar(playerid,"fish_ready");
    					}
    					else
    					{
    					    //if(ribachit[playerid] == 1) return SendClientMessage(playerid,0x81DA99AA,"В данный момент нельзя завершить рыбалку");
                            RemovePlayerAttachedObject(playerid,0);
                            DeletePVar(playerid,"fish_began");
                            DeletePVar(playerid,"fish_ready");
                            DeletePVar(playerid,"fish_time");
                            ClearAnimations(playerid);
                            PlayerTextDrawHide(playerid,FishingText[playerid]);
    					}
    				}
    				case 1:
    				{
    				    if(!IsPlayerInRangeOfPoint(playerid, 25,1957.3359,206.6625,30.5146) && !IsPlayerInRangeOfPoint(playerid, 25,10.2461,-85.6648,3.1094) &&
    					!IsPlayerInRangeOfPoint(playerid, 25,-200.7619,6.3196,3.1094) && !IsPlayerInRangeOfPoint(playerid, 25,-1120.5344,-997.0002,129.2188) && !IsPlayerInRangeOfPoint(playerid, 25,-224.8588,-1363.7963,7.2658)) return SendClientMessage(playerid,0x81DA99AA,"Неудачное место для поиска");
    					if(random(2) == 1) ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 6.1, 0, 0, 0, 0, 0,1),  SetPVarInt(playerid,"fish_worms",GetPVarInt(playerid,"fish_worms")+10), SendClientMessage(playerid,0x81DA99AA,"Вы нашли 10 червей!"), ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    					else return ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 6.1, 0, 0, 0, 0, 0,1), SendClientMessage(playerid,0x81DA99AA,"Вы ничего не нашли"), ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 2:
    				{
    				    if(PTEMP[playerid][pFishesPach] >= 25) return SendClientMessage(playerid,0x81DA99AA,"У вас 25 / 25 пачек рыбы");
    				    if(PTEMP[playerid][pFishes] < 20) return SendClientMessage(playerid,0x81DA99AA,"Для создания требуется 20 кг. рыбы");
    				    PTEMP[playerid][pFishesPach]++;
    				    PTEMP[playerid][pFishes]-=float(20);
    				    SendMes(playerid,0x81DA99AA,"Вы приготовили рыбу. У вас %i / 25 пачек.",PTEMP[playerid][pFishesPach]);
    				    ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 3:
    				{
                        if(PTEMP[playerid][pFishesPach] < 1) return SendClientMessage(playerid,0x81DA99AA,"Недостаточно рыбы");
                        PTEMP[playerid][pFishesPach]--;
                        PTEMP[playerid][pSatiety]=100;
                        SendMes(playerid,0x81DA99AA,"«Сытость» пополнена до 100. У вас %i / 25 пачек.",PTEMP[playerid][pFishesPach]);
                        ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 4:
    				{
    				    for(new i = 1; i <= TotalBizz; i++)
    					{
    						if(PTEMP[playerid][pFishes] < 2) return SendClientMessage(playerid,0x81DA99AA,"Недостаточно рыбы");
    						if (PlayerToPoint(10, playerid,BizzInfo[i][bBarX], BizzInfo[i][bBarY], BizzInfo[i][bBarZ]) && BizzInfo[i][bType] == 2 && GetPlayerVirtualWorld(playerid) == BizzInfo[i][bVirtualWorld])
    						{
    							PTEMP[playerid][pCash] +=floatround(PTEMP[playerid][pFishes])*5;
    							if(BizzInfo[i][bProducts]+floatround(PTEMP[playerid][pFishes]) < 2000) BizzInfo[i][bProducts]+=floatround(PTEMP[playerid][pFishes]);
    							else BizzInfo[i][bProducts]=2000;
    							format(YCMDstr,sizeof(YCMDstr), "Вы продали %.1f кг. рыбы. Выручка: %i вирт",PTEMP[playerid][pFishes],floatround(PTEMP[playerid][pFishes]));
    							SendClientMessage(playerid,0x81DA99AA,YCMDstr);
    							PTEMP[playerid][pFishes] = 0;
    							ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    							break;
    						}
    					}
    				}

    И так ещё 2мб кода. Кому интересно глянуть полный перл - добро пожаловать на пастбин https://pastebin.com/JCyBWUVy. Язык - обрубок C для неумеющих в управление памятью, который называется Small. Сам кусок перла - часть хайлоад проекта с 1000 игроков онлайн одновременно(http://samp-rp.ru).

    monobogdan, 16 Августа 2019

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

    +1

    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
    switch($ext) {
            case 'bmp':
            case 'BMP':
                $img = imagecreatefrombmp($file_name);
                break;
            case 'gif':
            case 'GIF';
                $img = imagecreatefromgif($file_name);
                break;
            case 'JPG'
            case 'jpg':
            case 'JPEG':
            case 'jpeg':
                $img = imagecreatefromjpeg($file_name);
                break;
            
            case 'PNG':
            case 'png':
                $img = imagecreatefrompng($file_name);
                break;
        }

    Сойдет.

    OlegUP, 09 Августа 2019

    Комментарии (35)
  6. C++ / Говнокод #25752

    +1

    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
    namespace detail
    {
    template <typename Function, typename Tuple, std::size_t... i>
    void applyForEach(Function&& f, Tuple&& t, std::index_sequence<i...>)
    {
      (static_cast<void>(std::invoke(f, std::integral_constant<std::size_t, i>{}, std::get<i>(t))), ...);
    }
    } // namespace detail
    
    template <typename Function, typename Tuple>
    void applyForEach(Tuple&& tuple, Function&& function)
    {
      using Indexes = std::make_index_sequence<std::tuple_size_v<Tuple>>;
      detail::applyForEach(std::forward<Function>(function), std::forward<Tuple>(tuple), Indexes{});
    }

    Строка 6. Мы тут сделали синтаксис для fold expression, только вам его не дадим: у вас документов нет.

    Clang: https://wandbox.org/permlink/lNOFu1sOV9bA2LJF
    GCC: https://wandbox.org/permlink/yqeiYHTgZOz9NkkJ

    Elvenfighter, 07 Августа 2019

    Комментарии (8)
  7. Куча / Говнокод #25751

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Пост SQL-проблем.
    
    Собственно, никогда за весь свой опыт я не использовал join. Большое кол-во выпускников гикбрейнсов говорит, "бла бла бла, джойн даёт нихуёвый перформанс по сравнению с этими вашими инлайн выборками".
    Но конечно гикбрейнсы не понимают, что джойн - не панацея, и блочить реляционку пока она тебе не найдет все связи - по меньшей мере тупо. Ровно как и не понимают, что перформанс им даст нормальный кэш
    который джуны так не любят использовать, или используют криво(кэшируют целые запросы, а не возвращаемые объекты).
    
    Уважаемые говнокодеры, как вам данный высер?

    monobogdan, 07 Августа 2019

    Комментарии (102)
  8. PHP / Говнокод #25747

    +1

    1. 1
    За "PHP".

    BoeHHblu_nemyx, 02 Августа 2019

    Комментарии (35)
  9. Куча / Говнокод #25744

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Note
    pytest by default escapes any non-ascii characters used in unicode strings for the parametrization because it has several downsides. If however you would like to use unicode strings in parametrization and see them in the terminal as is (non-escaped), use this option in your pytest.ini:
    
    [pytest]
    disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True

    Прыщебляди не могут в юникод. Капча ujox согласна.

    syoma, 31 Июля 2019

    Комментарии (8)
  10. C++ / Говнокод #25741

    +1

    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
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        bool b;
        cin >> b;
    
        switch (b) {
        case true:
            cout << "TRUE" << endl;
            break;
        case false:
            cout << "FALSE" << endl;
            break;
        default:
            cout << "WHAT???" << endl;
            break;
        }
    
        return 0;
    }

    Данный код с компилятором MSVC2017 64bit при вводе значения "true" (текстом) выводит в консоль "WHAT???"

    mvngr, 30 Июля 2019

    Комментарии (100)
  11. JavaScript / Говнокод #25735

    +1

    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
    parse: function() {
                    let c = dstack[dstack.length - 1];
                    c = c == ' ' ? '\\s' : s.replace(/[^\w\s]/g, '\\$&');
                    const regex = new RegExp('^[^' + c + ']*', 'g');
                    const match = regex.exec(rest_source);
                    dstack.push(match[0]);
                    rest_source = rest_source.slice(regex.lastIndex, rest_source.length);
                    output.push(match[0]);
                },
                word: function() {
                    let c = dstack[dstack.length - 1];
                    c = c == ' ' ? '\\s' : s.replace(/[^\w\s]/g, '\\$&');
                    const regex = new RegExp('^[' + c + ']*', 'g');
                    const match = regex.exec(rest_source);
                    rest_source = rest_source.slice(regex.lastIndex, rest_source.length);
                    output.push(match[0]);
                    words.parse();
                },
                name: function() {
                    dstack.push(' ');
                    words.word();
                },

    /докт[ао]р,?\s*у\s*м[еи]ня\s*регулярк[аои]\s*г[ао]л[ао]вного\s*мо(ск|зг)а/i

    666_N33D135, 27 Июля 2019

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