1. C++ / Говнокод #19265

    −3

    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
    #include <iostream>
    #include <time.h>
    #include <windows.h>
    #include <thread>
    #include <conio.h>
    #include <locale.h>
    #include <string>
    #include <tchar.h>
    using namespace std;
    //functions
    void DrawUI();
    void setup();
    bool first_r;
    void ShowHelp();
    void Up();
    void Left();
    void Right();
    void Down();
    void ShowFoodMenu();
    //vars
    bool lock = false;
    bool play = false;
    //functions
    float Cal2Weight(float calEat);
    // game center
    int posx = 16; //yes, this is a center of room
    int posz = 5;
    
    static HANDLE _ConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);//console out
    //for game center
    BOOL SetCurrentPos(SHORT x, SHORT y)
    {
    	COORD pos = { x, y };
    	return SetConsoleCursorPosition(_ConsoleOut, pos);
    }
    //some class declarations
    //food
    class Food
    {
    public:
    	Food(float calority, string name);
    	~Food();
    	void SetCalority(float newCalority) { itsCalority = newCalority; };
    	void SetName(string newName) { itsName = newName; };
    	float GetCalority() const { return itsCalority; }
    	string GetName() const { return itsName; };
    private:
    	float calority;
    	float itsCalority;
    	float newCalority;
    	string name;
    	string newName;
    	string itsName;
    };
    //food constructor
    Food::Food(float calority, string name)
    {
    	float itsCalority = calority;
    	string itsName = name;
    }
    //food destructor
    Food::~Food() {}
    //cat
    class Cat
    {
    public:
    	Cat(int age, float weight, string name);
    	~Cat();
    	void SetWeight(float newWeight) { itsWeight = newWeight; };
    	void SetAge(int newAge) { itsAge = newAge; };
    	void SetName(string newName) { itsName = newName; };
    	int GetAge() const { return itsAge; };
    	float GetWeight() const { return itsWeight; };
    	void Eat(string foodname);
    	string GetName() const { return itsName; };
    
    private:
    	int itsAge;
    	float itsWeight;
    	int age;
    	float weight;
    	int newAge;
    	float newWeight;
    	string itsName;
    	string newName;
    	string name;
    	string foodname;
    };
    //cat destructor
    Cat::~Cat() {}
    //making cat
    Cat Cat1(1, 1, "Unnamed");
    //food declaration
    Food Fries(2350, "Fries");
    Food Chips(1540, "Chips");
    Food Potatoes(251, "Potatoes");
    Food Water(0, "Water");
    Food Meat(200, "Meat");
    Food CatFood(65, "Special Cat Food");
    //for eating, bad code because i don't need normal, it works

    Мой очень старый код мелкой игры. Куча бреда для винды.

    catnikita255, 29 Декабря 2015

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

    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
    static public function countHandled()
    {
        $criteria = new CDbCriteria;
    
        $criteria->select .= ', SUM(`su`.`purchase_stage` = "in-progress") AS sum';
        $criteria->having = '`sum` > 0';
    
        $criteria->with = array(
            'siteUser' => array(
                'with' => array(
                    'interest'
                ),
                'join' => 'LEFT JOIN `site_users` AS `su` ON '
                    .'IF(LENGTH(`siteUser`.`phone`) = 11, SUBSTR(`siteUser`.`phone`, 2, 10), `siteUser`.`phone`) = '
                    .'IF(LENGTH(`su`.`phone`) = 11, SUBSTR(`su`.`phone`, 2, 10), `su`.`phone`)'
            )
        );
        $criteria->scopes = array(
            'notDone'
        );
        $criteria->compare('siteUser.purchase_stage', SiteUsers::PURCHASE_STAGE_LOST);
        $criteria->addNotInCondition('interest.reject_reason', array(
            SiteUserInterest::REJECT_REASON_TEST,
            SiteUserInterest::REJECT_REASON_SERVICE_TO
        ));
        $criteria->addCondition('`su`.`date_modified` >= DATE_SUB(NOW(), INTERVAL 2 DAY)');
    
        $criteria->group = '`t`.`site_users_return_id`';
    
        return self::model()->count($criteria);
    }
    
    static public function countCopied()
    {
        $criteria = new CDbCriteria;
    
        $criteria->select .= ', SUM(`su`.`purchase_stage` = "in-progress") AS sum';
        $criteria->having = '`sum` > 0';
    
        $criteria->with = array(
            'siteUser' => array(
                'with' => array(
                    'interest'
                ),
                'join' => 'LEFT JOIN `site_users` AS `su` ON '
                    .'IF(LENGTH(`siteUser`.`phone`) = 11, SUBSTR(`siteUser`.`phone`, 2, 10), `siteUser`.`phone`) = '
                    .'IF(LENGTH(`su`.`phone`) = 11, SUBSTR(`su`.`phone`, 2, 10), `su`.`phone`)'
            )
        );
        $criteria->scopes = array(
            'notDone'
        );
        $criteria->compare('siteUser.purchase_stage', SiteUsers::PURCHASE_STAGE_LOST);
        $criteria->addNotInCondition('interest.reject_reason', array(
            SiteUserInterest::REJECT_REASON_TEST,
            SiteUserInterest::REJECT_REASON_SERVICE_TO
        ));
        $criteria->addCondition('`su`.`date_created` >= DATE_SUB(NOW(), INTERVAL 2 DAY)');
    
        $criteria->group = '`t`.`site_users_return_id`';
    
        return self::model()->count($criteria);
    }

    - Найди мне одно отличие:
    Ответ автора:
    "- можно конешно и параметром
    - Насамом деле это два разных счета и для вычисления совпали критерии - я так это увидел
    - Можно соптимизировать, не вопрос)"

    У класса два статичных метода, в конечном итоге при условие что countHandled() ? countCopied() / countHandled() * 100 : 0
    Ладно, опустим что сам подход не очень оптимальный, но тут явно говнокод, аля контрл-ц\в,

    зы. Спешил походу, лентяй :)

    doommer, 29 Декабря 2015

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

    +7

    1. 1
    2. 2
    function api($method,$params=false) {
    if (!$params) $params = array();

    Олег Илларионов, Разработчик ВКонтакте
    Для тех кто не врубился:
    Можно написать $params = array()

    d_fomenok, 28 Декабря 2015

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

    −10

    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
    if($user_sett['profile'] == '1'){
    		$tpl->set('{display1}', 'none');
    		
    	} else {
    		$tpl->set('{display1}', '');	
    	}
    	
    		if($user_sett['friends'] == '1'){
    		$tpl->set('{display2}', 'none');
    		
    	} else {
    		$tpl->set('{display2}', '');	
    	}
    	
    		if($user_sett['albums'] == '1'){
    		$tpl->set('{display3}', 'none');
    		
    	} else {
    		$tpl->set('{display3}', '');	
    	}
    	
    		if($user_sett['videos'] == '1'){
    		$tpl->set('{display4}', 'none');
    		
    	} else {
    		$tpl->set('{display4}', '');	
    	}
    	
    		if($user_sett['audio'] == '1'){
    		$tpl->set('{display5}', 'none');
    		
    	} else {
    		$tpl->set('{display5}', '');	
    	}
    	
    		if($user_sett['mail'] == '1'){
    		$tpl->set('{display6}', 'none');
    		
    	} else {
    		$tpl->set('{display6}', '');	
    	}
    	
    		if($user_sett['groups'] == '1'){
    		$tpl->set('{display7}', 'none');
    		
    	} else {
    		$tpl->set('{display7}', '');	
    	}
    	
    		if($user_sett['news'] == '1'){
    		$tpl->set('{display8}', 'none');
    		
    	} else {
    		$tpl->set('{display8}', '');	
    	}
    	
    		if($user_sett['fave'] == '1'){
    		$tpl->set('{display9}', 'none');
    		
    	} else {
    		$tpl->set('{display9}', '');	
    	}
    	
    		if($user_sett['notes'] == '1'){
    		$tpl->set('{display10}', 'none');
    		
    	} else {
    		$tpl->set('{display10}', '');	
    	}
    	
    	
    		if($user_sett['settings'] == '1'){
    		$tpl->set('{display11}', 'none');
    		
    	} else {
    		$tpl->set('{display11}', '');	
    	}
    	
    		if($user_sett['apps'] == '1'){
    		$tpl->set('{display12}', 'none');
    		
    	} else {
    		$tpl->set('{display12}', '');	
    	}
    	
    			if($user_sett['ads'] == '1'){
    		$tpl->set('{display13}', 'none');
    		
    	} else {
    		$tpl->set('{display13}', '');	
    	}

    Вот что тяжёлые наркотики с парнем сделали

    d_fomenok, 28 Декабря 2015

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

    −1

    1. 1
    imagepng(imagecreatefromstring(file_get_contents($_FILES['userfile']['tmp_name'])), $_SERVER['DOCUMENT_ROOT'].'/user_imgs/'.$_SESSION["id"].'.png');

    Dego1n, 28 Декабря 2015

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?
    function  Показать($строка){
       print $строка;
    }
    
    ?>

    ааааааа шедевр!!!

    Govnokoders, 28 Декабря 2015

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

    +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
    //  Qt QML >:D
    UI_Button
    {
            id: bt_connect
            height: 40
            width: 150
            radiusBorder: 20
            anchors.right: led_connection.left
            anchors.rightMargin: 10
            anchors.verticalCenter: parent.verticalCenter
            textOn: qsTr("Отключиться")
            textOff: qsTr("Подключиться")
            state: putState(QVipGUI.btConnection)
            onClicked:{
                if(QVipGUI.btConnection !== GuiDefines.DEF_STATE_DIMMED) {
                    if(QVipGUI.btConnection === GuiDefines.DEF_STATE_OFF) {
                        QVipGUI.setLedConnection(GuiDefines.DEF_STATE_OFF)
                        QVipGUI.method_ActionGui(GuiDefines.ID_ACTION_CONNECT)
                        QVipGUI.method_ActionGui(GuiDefines.ID_ACTION_GETPORT) // <!>
    
                        var i = 0;
                        while(++i < 1000000){};
                        QVipGUI.method_ActionGui(GuiDefines.ID_ACTION_GETCONF);
    
    
                    }
                    else {
                        QVipGUI.method_ActionGui(GuiDefines.ID_ACTION_DISCONNECT)
                    }
                }
            }
     }

    Qt-среда, язык описания интерфейса - QML >:D

    eremite88, 28 Декабря 2015

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

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void TMainForm::MakeScreenPrint()
    {
    	MainForm->Print();
    }
    
    void __fastcall TMainForm::N18Click(TObject *Sender)
    {
    	MakeScreenPrint();
    }

    Обертка

    GreatMASTERcpp, 27 Декабря 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $safeGet=$_GET;
    
    $registry = ipsRegistry::instance();
    $registry->init();
    
    $_GET=$safeGet; // fucking ips registry

    Люблю IPB

    ZhoZho, 26 Декабря 2015

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public static bool IsNullOrEmpty(this string str)
    	{
    		return string.IsNullOrEmpty(str);
    	}
    
    	public static bool IsNotNullOrEmpty(this string str)
    	{
    		return !string.IsNullOrEmpty(str);
    	}

    экономия должна быть экономной

    esromhaz, 26 Декабря 2015

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