1. PHP / Говнокод #28151

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public function validate($mailAddress)
    {
        $this->mailAddress = $mailAddress;
        if($this->validateMailAddress()) {
            if ($this->checkMXRecord()) {
                throw new \Exception('Mail is valid');
            }
        }
        throw new \Exception('Mail is invalid');
    }

    pefigah572, 04 Мая 2022

    Комментарии (12)
  2. C++ / Говнокод #28148

    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
    // Ручной режим
        if (!botMode) {
            cout << "Manual mode activated\n";
            Sleep(1000);
    
            while (1) {                                             // Основной цикл
    
                MAP = modMap(pos, MAP, PVM);
                auto moveField =  moveMapField(MAP);
                auto TVM = waveViewCheck(pos, MAP);                 // Вызов функции проверки видимости элементов
                PVM = refreshMap(PVM, TVM);
    
                system("cls");                                      // Очистка поля с каждой итерацией
                coutMAP(pos, MAP);                                  // Вывод всей карты
                cout << endl;
                coutMAP(pos, PVM);                                  // Вывод видимой карты
    
                if (MAP[pos.y][pos.x] == END) {
                    cout << endl << "Level Complete!\n";
                    Sleep(3000);
                    return 0;
                }
    
                int k = getch();
                if (k == 113 || k == 81) break;                     // Press Q - exit
                if (k == 224) k = getch();
                switch (k) {                                // Перемещение стрелочками
                    case 72:                                // Вверх
                        if ((moveField[pos.y-1][pos.x] == BLANK || (moveField[pos.y-1][pos.x] > 0 && MAP[pos.y-1][pos.x] % 2 == 1)) && pos.y > 0) {
                            pos.y -= 1;
                        }
                        break;
                    case 75:                                // Влево
                        if ((moveField[pos.y][pos.x-1] != WALL || (moveField[pos.y][pos.x-1] > 0 && MAP[pos.y][pos.x-1] % 2 == 1)) && pos.y > 0) {
                            pos.x -= 1;
                        }
                        break;
                    case 77:                                // Вправо
                        if ((moveField[pos.y][pos.x+1] != WALL || (moveField[pos.y][pos.x+1] > 0 && MAP[pos.y][pos.x+1] % 2 == 1)) && pos.y > 0) {
                            pos.x += 1;
                        }
                        break;
                    case 80:                                // Вниз
                        if ((moveField[pos.y+1][pos.x] != WALL || (moveField[pos.y+1][pos.x] > 0 && MAP[pos.y+1][pos.x] % 2 == 1)) && pos.y > 0) {
                            pos.y += 1;
                        }
                        break;
                }
            }
        }

    kcalbCube, 01 Мая 2022

    Комментарии (32)
  3. Java / Говнокод #28142

    0

    1. 1
    public static final String EMPTY = "";

    Tan seme? Tan seme?!!

    Stallman, 28 Апреля 2022

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

    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
    #include <iostream>
    #include <string_view>
    #include <source_location>
     
    void log(const std::string_view message,
             const std::source_location location = 
                   std::source_location::current())
    {
        std::cout << "file: "
                  << location.file_name() << "("
                  << location.line() << ":"
                  << location.column() << ") `"
                  << location.function_name() << "`: "
                  << message << '\n';
    }
     
    template <typename T> void fun(T x)
    {
        log(x);
    }
     
    int main(int, char*[])
    {
        log("Hello world!");
        fun("Hello C++20!");
    }
    
    file: main.cpp(23:8) `int main(int, char**)`: Hello world!
    file: main.cpp(18:8) `void fun(T) [with T = const char*]`: Hello C++20!

    Previously, functions that desire to obtain this information about the call site (for logging, testing, or debugging purposes) must use macros so that predefined macros like __LINE__ and __FILE__ are expanded in the context of the caller. The source_location class provides a better alternative.

    kcalbCube, 27 Апреля 2022

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

    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
    #include <iostream>
    #include <vector>
    #include <thread>
    int f()
    {
        static int i = 0;
        synchronized { // begin synchronized block
            std::cout << i << " -> ";
            ++i;       // each call to f() obtains a unique value of i
            std::cout << i << '\n';
            return i; // end synchronized block
        }
    }
    int main()
    {
        std::vector<std::thread> v(10);
        for(auto& t: v)
            t = std::thread([]{ for(int n = 0; n < 10; ++n) f(); });
        for(auto& t: v)
            t.join();
    }
    
    0 -> 1
    1 -> 2
    2 -> 3
    ...
    99 -> 100

    https://en.cppreference.com/w/cpp/language/transactional_memory

    kcalbCube, 27 Апреля 2022

    Комментарии (26)
  6. SQL / Говнокод #28138

    0

    1. 1
    delete e from  [Emails] as e where not exists (select 1 from [Emails] group by body having MAX(id)=e.Id)

    говеное удаление дублей

    techlead_seneor_228, 26 Апреля 2022

    Комментарии (0)
  7. C++ / Говнокод #28137

    −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
    #include "property.hpp"
    
    class person {
    public:
       person() = default;
       ~person() = default;
    
       SETTER_PRIM(int, id);
       SETTER_FLAG(bool, merried);
       SETTER_ENUM(human, type);
    
       SETTER_PTR(int, next);
       SETTER_ARR(std::string, address, 3);
    
       SETTER_OBJ_LR(std::string,  name);
       SETTER_OBJ_CLR(std::string, name);
       SETTER_OBJ_RR(std::string,  name);
    
       GETTER_PRIM(int, id);
       GETTER_FLAG(bool, merried);
       GETTER_ENUM(human, type);
    
       GETTER_OBJ_LR(std::string,  name);
       GETTER_OBJ_CLR(std::string, name);
    
       GETTER_PTR(int, next);
       GETTER_ARR(std::string, address);
    
    private:
       int id;
       human type;
    
       std::string name;
       std::string address[5];
    
       bool merried;
       int* next;
    };

    https://habr.com/ru/post/459212/

    kcalbCube, 26 Апреля 2022

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    template<typename Event>
    void bindEvent(auto function)
    {
        connectionGuards.emplace_back(
            std::make_unique<event::EventConnectionGuard<Event>>(
                std::forward(event::emitter().on<Event>(boost::bind(          
                    boost::mem_fn(function), static_cast<T*>(this), _1))                             
                )
            )
        );
    }

    kcalbCube, 23 Апреля 2022

    Комментарии (13)
  9. PHP / Говнокод #28133

    +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
    $ss_n = 0;
    			$ss_nf = 0;
    			$ss_f = 0;
    			$ss_n_pl = 0;
    			$ss_nf_pl = 0;
    			$ss_f_pl = 0;
    			$ids_count = count($ids);
    		for ($i=0;$i < $ids_count;$i++) {
    			$key = $w_dates[$z]."|1|".$ids[$i];
    			$ss_n += $w_n_s[$key]*1;
    			$ss_nf += $w_nf_s[$key]*1;
    			$ss_f += $w_f_s[$key]*1;
    			$key = $w_dates[$z]."|2|".$ids[$i];
    			$ss_n += $w_n_s[$key]*1;
    			$ss_nf += $w_nf_s[$key]*1;
    			$ss_f += $w_f_s[$key]*1;
    			$key = $w_dates[$z]."|3|".$ids[$i];
    			$ss_n += $w_n_s[$key]*1;
    			$ss_nf += $w_nf_s[$key]*1;
    			$ss_f += $w_f_s[$key]*1;
    		}
    		$ids_count = count($ids);
    		for ($i=0;$i < $ids_count;$i++) {
    			$key = $w_dates[$z]."|1|".$ids[$i];
    			$ss_n_pl = $ss_n_pl + $w_n_s_pl[$key]*1;
    			$ss_nf_pl = $ss_nf_pl + $w_nf_s_pl[$key]*1;
    			$ss_f_pl = $ss_f_pl + $w_f_s_pl[$key]*1;
    			$key = $w_dates[$z]."|2|".$ids[$i];
    			$ss_n_pl = $ss_n_pl + $w_n_s_pl[$key]*1;
    			$ss_nf_pl = $ss_nf_pl + $w_nf_s_pl[$key]*1;
    			$ss_f_pl = $ss_f_pl + $w_f_s_pl[$key]*1;
    			$key = $w_dates[$z]."|3|".$ids[$i];
    			$ss_n_pl = $ss_n_pl + $w_n_s_pl[$key]*1;
    			$ss_nf_pl = $ss_nf_pl + $w_nf_s_pl[$key]*1;
    			$ss_f_pl = $ss_f_pl + $w_f_s_pl[$key]*1;
    		}
    
    		echo "<td class='Field' rowspan='3' style='vertical-align: middle;'><b>".OutNF($ss_n,$ss_nf,$ss_f)."</b></td>\n";
    		echo "<td class='Field' rowspan='3' style='vertical-align: middle;'><b style='color:#aa0000;'>".OutNF($ss_n_pl,$ss_nf_pl,$ss_f_pl)."</b></td>\n";
    
    		echo "</tr><tr>";
    
    		////////////////////////////////////////////////////////////
    		echo "<td class='Field' width='40' style='vertical-align: middle;'><b>II</b></td>\n";
    			$s_n = 0;
    			$s_nf = 0;
    			$s_f = 0;
    			$s_n_pl = 0;
    			$s_nf_pl = 0;
    			$s_f_pl = 0;
    		for ($i=0;$i < count($ids);$i++) {
    			$key = $w_dates[$z]."|2|".$ids[$i];
    			$s_n = $s_n + $w_n_s[$key]*1;
    			$s_nf = $s_nf + $w_nf_s[$key]*1;
    			$s_f = $s_f + $w_f_s[$key]*1;
    			$s_n_pl = $s_n_pl + $w_n_s_pl[$key]*1;
    			$s_nf_pl = $s_nf_pl + $w_nf_s_pl[$key]*1;
    			$s_f_pl = $s_f_pl + $w_f_s_pl[$key]*1;
    			if ($edti_stat[$key]==1){
    				echo "<td class='Field'>".OutNF($w_n_s[$key],$w_nf_s[$key],$w_f_s[$key])."</td>\n";
    			}
    			if ($edti_stat[$key]==0){
    				$link_dat = explode("|", $key);
    				$link_dat2 = $link_dat[0];
    				$link_dat3 = $link_dat[1];
    				echo "<td class='Field'><a target='_bland' href='index.php?do=show&formid=64&p0=".$link_dat2."&p1=".$link_dat3."'><b style='color:#aa0000;'>".OutNF($w_n_s_pl[$key],$w_nf_s_pl[$key],$w_f_s_pl[$key])."</b></a></td>\n";
    			}
    		}
    		echo "<td class='Field'></td>\n";
    		echo "<td class='Field'><b>".OutNF($s_n,$s_nf,$s_f)."</b></td>\n";
    		echo "<td class='Field'></td>\n";
    		echo "<td class='Field'></td>\n";
    		echo "<td class='Field'><b style='color:#aa0000;'>".OutNF($s_n_pl,$s_nf_pl,$s_f_pl)."</b></td>\n";
    		echo "<td class='Field'></td>\n";
    		////////////////////////////////////////////////////////////

    kib0rg, 22 Апреля 2022

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

    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
    if ($arr_tbl_1[$key_1] !== $cur_vid){
    		$cur_vid_key = $key_1;
    		$cur_vid_w = $arr_tbl_1[$key_1];
    		$cur_v_ind = $cur_v_ind + 1;
    		while ($arr_tbl_1[$cur_vid_key] == $cur_vid_w){
    			$sum_cur_v_6 += (float)$arr_tbl_6[$cur_vid_key];
    			$sum_cur_v_7 += (float)$arr_tbl_7[$cur_vid_key];
    			$sum_cur_v_10 += (float)$arr_tbl_10[$cur_vid_key];
    			$cur_vid_key += 1;
    		}
    		if ($sum_cur_v_6==0) { $sum_cur_v_6_0 = 1;}else{ $sum_cur_v_6_0 = $sum_cur_v_6;}
    		if ($sum_cur_v_7==0) { $sum_cur_v_7_0 = 1;}else{ $sum_cur_v_7_0 = $sum_cur_v_7;}
    		if (strlen(substr(strstr($sum_cur_v_6, "."), 1))==0) { $tbl_1_6 = $sum_cur_v_6.".00";}
    		if (strlen(substr(strstr($sum_cur_v_6, "."), 1))==1) { $tbl_1_6 = $sum_cur_v_6."0";}
    		if (strlen(substr(strstr($sum_cur_v_6, "."), 1))==2) { $tbl_1_6 = $sum_cur_v_6;}
    		if (strlen(substr(strstr($sum_cur_v_6, "."), 1))>2) { $tbl_1_6 = number_format($sum_cur_v_6, 2, '.', '');}
    		if (strlen(substr(strstr($sum_cur_v_7, "."), 1))==0) { $tbl_1_7 = $sum_cur_v_7.".00";}
    		if (strlen(substr(strstr($sum_cur_v_7, "."), 1))==1) { $tbl_1_7 = $sum_cur_v_7."0";}
    		if (strlen(substr(strstr($sum_cur_v_7, "."), 1))==2) { $tbl_1_7 = $sum_cur_v_7;}
    		if (strlen(substr(strstr($sum_cur_v_7, "."), 1))>2) { $tbl_1_7 = number_format($sum_cur_v_7, 2, '.', '');}
    		if (strlen(substr(strstr(($sum_cur_v_6-$sum_cur_v_7), "."), 1))==0) { $tbl_1_8 = ($sum_cur_v_6-$sum_cur_v_7).".00";}
    		if (strlen(substr(strstr(($sum_cur_v_6-$sum_cur_v_7), "."), 1))==1) { $tbl_1_8 = ($sum_cur_v_6-$sum_cur_v_7)."0";}
    		if (strlen(substr(strstr(($sum_cur_v_6-$sum_cur_v_7), "."), 1))==2) { $tbl_1_8 = ($sum_cur_v_6-$sum_cur_v_7);}
    		if (strlen(substr(strstr(($sum_cur_v_6-$sum_cur_v_7), "."), 1))>2) { $tbl_1_8 = number_format(($sum_cur_v_6-$sum_cur_v_7), 2, '.', '');}
    		if (strlen(substr(strstr(($sum_cur_v_7/$sum_cur_v_6_0*100), "."), 1))==0) { $tbl_1_9 = ($sum_cur_v_7/$sum_cur_v_6_0*100).".00";}
    		if (strlen(substr(strstr(($sum_cur_v_7/$sum_cur_v_6_0*100), "."), 1))==1) { $tbl_1_9 = ($sum_cur_v_7/$sum_cur_v_6_0*100)."0";}
    		if (strlen(substr(strstr(($sum_cur_v_7/$sum_cur_v_6_0*100), "."), 1))==2) { $tbl_1_9 = ($sum_cur_v_7/$sum_cur_v_6_0*100);}
    		if (strlen(substr(strstr(($sum_cur_v_7/$sum_cur_v_6_0*100), "."), 1))>2) { $tbl_1_9 = number_format(($sum_cur_v_7/$sum_cur_v_6_0*100), 2, '.', '');}
    		if (strlen(substr(strstr($sum_cur_v_10, "."), 1))==0) { $tbl_1_10 = $sum_cur_v_10.".00";}
    		if (strlen(substr(strstr($sum_cur_v_10, "."), 1))==1) { $tbl_1_10 = $sum_cur_v_10."0";}
    		if (strlen(substr(strstr($sum_cur_v_10, "."), 1))==2) { $tbl_1_10 = $sum_cur_v_10;}
    		if (strlen(substr(strstr($sum_cur_v_10, "."), 1))>2) { $tbl_1_10 = number_format($sum_cur_v_10, 2, '.', '');}
    		if (strlen(substr(strstr(($sum_cur_v_10/$sum_cur_v_7_0), "."), 1))==0) { $tbl_1_11 = ($sum_cur_v_10/$sum_cur_v_7_0).".00";}
    		if (strlen(substr(strstr(($sum_cur_v_10/$sum_cur_v_7_0), "."), 1))==1) { $tbl_1_11 = ($sum_cur_v_10/$sum_cur_v_7_0)."0";}
    		if (strlen(substr(strstr(($sum_cur_v_10/$sum_cur_v_7_0), "."), 1))==2) { $tbl_1_11 = ($sum_cur_v_10/$sum_cur_v_7_0);}
    		if (strlen(substr(strstr(($sum_cur_v_10/$sum_cur_v_7_0), "."), 1))>2) { $tbl_1_11 = number_format(($sum_cur_v_10/$sum_cur_v_7_0), 2, '.', '');}
    		echo "<tr>
    		<td class='field' style='background:#CBDEF4;' colspan='5'><b class='not_tr' name='arr_tbl_1_".$cur_v_ind."' style='cursor:pointer; border:1px solid #000; border-radius:6px;' onclick='show_tr_1(this.getAttribute(\"name\"), this.getAttribute(\"class\"), this);'> + </b><b class='not_tr' name='arr_tbl_1_".$cur_v_ind."' style='display:none; cursor:pointer; border:1px solid #000; border-radius:6px;' onclick='show_tr_2(this.getAttribute(\"name\"), this.getAttribute(\"class\"), this);'> -  </b> ".$arr_tbl_1[$key_1]."</td>
    		<td name='max_numb_6' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_6."</td>
    		<td name='max_numb_7' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_7."</td>
    		<td name='max_numb_8' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_8."</td>
    		<td name='max_numb_9' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_9."</td>
    		<td name='max_numb_10' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_10."</td>
    		<td name='max_numb_11' class='field' style='text-align:right; background:#CBDEF4;'>".$tbl_1_11."</td>
    		</tr>";
    		$itog_sum_6 += $sum_cur_v_6;
    		$itog_sum_7 += $sum_cur_v_7;
    		$itog_sum_10 += $sum_cur_v_10;
    		
    		$tbl_1_6 = "";
    		$tbl_1_7 = "";
    		$tbl_1_8 = "";
    		$tbl_1_9 = "";
    		$tbl_1_10 = "";
    		$tbl_1_11 = "";
    		$sum_cur_v_6 = 0;
    		$sum_cur_v_7 = 0;
    		$sum_cur_v_10 = 0;
    	}

    kib0rg, 22 Апреля 2022

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