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

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // Load the core Kohana class
    require SYSPATH . 'classes/Kohana/Core' . EXT;
    
    if (is_file(APPPATH . 'classes/Kohana' . EXT)) {
        // Application extends the core
        require APPPATH . 'classes/Kohana' . EXT;
    } else {
        // Load empty core extension
        require SYSPATH . 'classes/Kohana' . EXT;
    }

    нужно как можно больше констант

    1111nomi, 09 Сентября 2024

    Комментарии (1)
  3. C# / Говнокод #28939

    +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
    /// <summary>
    /// перобразуем DateTime? в DateTime, если не получается, то возвращаем текущую дату
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    private DateTime DateTimeHelper(DateTime? date)
    {
        try
        {
            return (DateTime)date;
        }
        catch
        {
            return DateTime.Now;
        }
    }

    reemind, 03 Мая 2024

    Комментарии (1)
  4. Python / Говнокод #28927

    0

    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 razmer(arr):
     b = len (arr) - 1
     return (array_prov(arr,b))
    
    def array_prov (arr,b):
     if b == 0:
         return arr[b]
     else:
         return (arr[b]+array_prov (arr, b-1))
    
    a = [10,12,14,15,18]
    print (razmer (a))

    1004w, 12 Марта 2024

    Комментарии (1)
  5. JavaScript / Говнокод #28888

    0

    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
    const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
        const price = Number(event.target.value);
        setPrice(price);
    
        if (timer) {
          clearTimeout(timer);
          setTimer(null);
        }
    
        const validPrice = validatePrice(price);
        if (event.target.id.includes("cause")) {
          handleOnChange(validPrice);
        } else {
          const timerId: any = setTimeout(() => {
            setPrice(validPrice);
            handleOnChange(validPrice);
          }, 1000);
    
          setTimer(timerId);
        }
      };

    :hang:

    Shannarra_, 14 Декабря 2023

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

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    
    namespace App\Http\Controllers\api\v1;
    
    use App\Http\Controllers\Controller;
    use App\Http\Requests\StandartRequest;
    use App\Models\Attractions;
    use App\Models\AttractionSessionUpdates;
    use App\Models\Locations;
    use App\Models\SessionAttractionHistory;
    use App\Models\SessionsHistoryAttractions;
    use App\Models\SessionsHistoryGames;
    use App\Models\Statistic\CountEndAttractionSessions;
    use Illuminate\Http\Request;
    use Illuminate\Support\Carbon;
    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\Facades\Cache;
    use Illuminate\Support\Facades\Log;
    
    class AttractionEndSessionsCount extends Controller
    {
        public function endSessions(StandartRequest $request){
            $this->now_time = Carbon::now();
    
            $locations = Locations::where('user_id', '=', Auth::user()->id)->get();
            if (count($locations) == 0){
                return response()->json(['code' => "404", 'status' => 'error' , 'message'=> "locations not found"]);
            }
            try {
                $request_from = $request->input('date_from');
                $from = Carbon::parse($request_from."00:00:01");
    
                $date_to = $request->input('date_to');
                $to = Carbon::parse($date_to."11:59:59");
            } catch (\Exception $exception){
                return response()->json(['code' => "422", 'status' => 'error' , 'message'=> "dates have bad format, failed parse"]);
            }
    
            if ($from->timestamp > $to->timestamp){
                return response()->json(['code' => "422", 'status' => 'error' , 'message'=> "the start date is larger than the end date"]);
            }
    
            $is_detail = $request->input('detail', 'daily');
    
            $arr = $this->prepareLocationsAndAttrctions($locations, $from, $to, $is_detail);
    
            $locations_ids = [];
            foreach ($locations as $loc){
                $locations_ids[] = $loc->id;
            }
    
            $history = CountEndAttractionSessions::query()->whereIn('location_id', array_values($locations_ids))
                ->whereBetween('day_date', [$from->startOfDay()->format('Y-m-d H:i:s'), $to->endOfDay()->format('Y-m-d H:i:s')])
                ->get();
    
            $resp = $this->fillResults($arr ,$history, $is_detail);
            if ($this->is_today){
                $resp = $this->fillTodayResult($resp, $locations_ids, $is_detail);
            }
            return response()->json(['code' => "200", 'status' => 'success' , 'data'=> $resp]);
    
        }
    
        private function fillResults($arr ,$history, $is_detail){
            foreach ($history as $value){
                try {
                    if ($is_detail == 'hourly'){
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]['list'][$value->day_date->format('d-m-Y')][$value->day_date->format('H:00:00')] =
                            [
                                // общее количество игр
                                'total_count' => $value->total_count ?? 0,
                                //общее количество обновлений
                                'total_updates_count' => $value->total_updates_count ?? 0,
                                // количество пролонгейт обновлений
                                'add_time' => $value->add_time ?? 0,
                                // количество лет_гейм обновлений
                                'let_game_end' => $value->let_game_end ?? 0,
                                //средняя длина игры в секундах
                                'avg_duration' => [
                                    'sum_seconds' => $value->avg_duration_second_sum,
                                    'count_games' => $value->avg_duration_count_games,
                                ],
                                // минимальная игра в секундах
                                'min_duration' => $value->min_duration,
                                // максимальная игра в секундах
                                'max_duration' => $value->max_duration,
                    ];
                        for ($i = 1; $i <= 10; $i++){
                            $selector = 'max_players_'.$i;
                            $arr['locations'][$value->location_id]
                            ['attractions'][$value->attraction_id]
                            ['list'][$value->day_date->format('d-m-Y')]
                            [$value->day_date->format('H:00:00')]
                            ['max_players'][$i] = (int)$value->$selector;
                        }
                    }elseif ($is_detail == 'daily') {
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]
                        ['list'][$value->day_date->format('d-m-Y')]['total_count'] += $value->total_count;
    
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]

    расчет заранее посчитанной оффлайн и онлайн статистики

    tlen, 06 Октября 2023

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

    0

    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
    #include <ctype.h>
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int evaluatePostfixExpression_2(char *, int memory_smp[], int *count_command);
    int calculate_2(int, int, char, int memory_smp[], int *count_command);
    
    typedef struct mode_intro {
      int type;
      int data[2];
    
    } expr_if;
    
    int main(int argc, char *argv[]) {
    
      expr_if rn_data[125];
    
      /*  !=   */
      rn_data[94].type = 2;
      rn_data[94].data[0] = 4100;
      rn_data[94].data[1] = 4100;
      /*  !=   */
    
      /*  ==   */
      rn_data[122].type = 1;
      rn_data[122].data[0] = 4200;
      /*  ==   */
    
      /*  <=   */
      rn_data[121].type = 2;
      rn_data[121].data[0] = 4200;
      rn_data[121].data[1] = 4100;
      /*  <=   */
    
      /* < Øèâîðîò íà âûâîðîò  */
      rn_data[60].type = 1;
      rn_data[60].data[0] = 4100;
      /*  <   */
    
      /*  >=   */
      rn_data[123].type = 2;
      rn_data[123].data[0] = 4200;
      rn_data[123].data[1] = 4100;
      /*  >=   */
    
      /* > */
      rn_data[62].type = 1;
      rn_data[62].data[0] = 4100;
      /* > */
    
      char infix[150];
      char postfix[150];
    
      int line_simple_comands_input_print(int cmd, data *table, int token,
                                          int memory[]);
    
      int past_in_table_cons_or_value(data * table, char *str_tok);
      int ab = 0;
      int swp = 0;
      int goto_search(data * table, char *token);
    
      int search_cmd(char *dict[15], char *token);
      char *comparison_signs = "> < <= >= == !=";
      int token_string_count = 0;
      data symbolTable[100];
    
      int cnt = 0;
      int d = 0;
      int count_if = 0;
      int flags[100];
    
      int mem_smp[100];
      char copy_buf_data[150][150] = {{0}};
      char post_buf[150];
      int count_cmd = 0;
    
      int sign_ch;
      FILE *file_buf;
    
      char *buffer = 0;
      char *intro_buffer = 0;
      int save_left_side = 0, save_exp = 0;
      int goto_flag = 0;
    
      int count_table_intro = 0;
      int count_table_extra = 0;
      char name_file[100];
    
      char buffer_postfix[150];
      char buf_data[150][150] = {{0}};
      int val_if[3] = {0};
    
      int data_if[150] = {0};
    
     data_if[60] = 4100;
     data_if[61] = 1;

    Симплтрон из задачи по Дейтелам
    1

    gne4do, 02 Октября 2023

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

    +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
    #include "Windows.h"
    void line::draw()
    {
    	CmdWinGUI::draw();
    	uint8_t modB = 0; //modeByte
    	COORD tempSt = lineStart;
    	COORD tempEn = lineEnd;
    	SHORT dX = abs(lineEnd.X - lineStart.X);
    	SHORT dY = abs(lineEnd.Y - lineStart.Y);
    	SHORT sX = lineStart.X < lineEnd.X ? 1 : -1;
    	SHORT sY = lineStart.Y < lineEnd.Y ? 1 : -1;
    	SHORT dErr = dX - dY;
    	SHORT dErr2 = 0;
    	if (scan)
    	{
    		SetConsoleCursorPosition(hCon, lineStart);
    		for (uint8_t a = 0;a <= lineEnd.X-lineStart.X;++a)
    		{
    			modB = lineAtrBuffer[a];
    			SetConsoleTextAttribute(hCon, modB);
    			printf("%c", lineSymBuffer[a]);
    		}
    		if (isChanged)
    			this->editFlagSwitch();
    		return;
    	}
    	for (;;)
    	{
    		SetConsoleCursorPosition(hCon, tempSt);
    		printf("%c", lineSym);
    		if (tempSt.X == tempEn.X&&tempSt.Y == tempEn.Y)
    			break;
    		dErr2 = dErr * 2;
    		if (dErr2 > -dY)
    		{
    			dErr -= dY;
    			tempSt.X += sX;
    		}
    		if (dErr2 < dX)
    		{
    			dErr += dX;
    			tempSt.Y += sY;
    		}
    	}
    	if (isChanged)
    		this->editFlagSwitch();
    }

    Отрисовка произвольной графической линии в консоли

    siclown, 30 Сентября 2023

    Комментарии (1)
  9. JavaScript / Говнокод #28827

    +2

    1. 1
    const disabledConditions = [!element.isDraft].some((v) => Boolean(v) === true);

    Из серии String(true).length === 4

    akosenko, 27 Июля 2023

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

    +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
    using System;
    using System.Linq;
    
    namespace TheBestGenerator
    {
       
        class Symbols
        {
            protected const string Letters = "abcdefghijklmnopqrstuvwxyz";
            protected const string Numbers = "0123456789";
            protected const string DefaultSpecialSymbols = @"!#$%&*@\";
            protected static Random rand = new Random();     
        }
        
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    Console.WriteLine("Введите длину пароля:");
                    int Len = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine(Generator.Password(Len));
                }
            }     
        }
       
        class Generator: Symbols
        {
           
            static char[] Array_()
            {
                return (Numbers+Letters+Letters.ToUpper()+DefaultSpecialSymbols).ToCharArray();
            }
    
             static char[] Password_Symbols()
            {
                return Array_().OrderBy(Symbol => rand.Next()).ToArray();
            }
    
            public static string Password(int Len )
            {
                char[] password = Password_Symbols();
                Array.Resize(ref password, Len);
                return (string.Join("", password));
            }
        }
    }

    Генератор паролей. Говнокод с наследованием. Почти ничего не понимаю в нем, но "прогу" с ним написал.

    utsutsbabyj, 22 Июля 2023

    Комментарии (1)
  11. Java / Говнокод #28791

    0

    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
    public class MathGame {
    
        public static Map<Integer, String> data = new HashMap<Integer, String>();
        public static Map<String, Integer> result = new HashMap<String, Integer>();
        String problem;
        Random random = new Random();
    
        public void NewProblem() {
    
            String sign = null;
    
            for (int i = 1; i < 5; i++) {
    
                switch (GenNumber(3)) {
                    case 1:
                        sign = Sign.MINUS.get();
                        break;
                    case 2:
                        sign = Sign.PLUS.get();
                        break;
                    case 3:
                        sign = Sign.TIMES.get();
                        break;
                    default:
                        sign = Sign.PLUS.get();
                        break;
                }
    
                problem = GenNumber(9) + " " + sign + " " + GenNumber(9);
                result.put(problem + " = ???", Decide(Integer.parseInt(
                        problem.split(" ")[0]), problem.split(" ")[1], Integer
                        .parseInt(problem.split(" ")[2])));
                data.put(i, problem);
    
            }
        }
    
        private int GenNumber(int s) {
            return random.nextInt(s) + 1;
        }
    
        private int Decide(int a, String sign, int b) {
            switch (sign) {
                case "+":
                    return a + b;
                case "-":
                    return a - b;
                case "*":
                    return a * b;
            }
            return 0;
        }
    
        public enum Sign {
            PLUS("+"),
            MINUS("-"),
            TIMES("*");
    
            private final String sign;
    
            Sign(String sign) {
                this.sign = sign;
            }
    
            public String get() {
                return sign;
            }
    
        }
    
    }

    girixok149, 05 Июня 2023

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