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

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

    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
    class NTPTime {
    public:
    	static NTPTime getInvalidTime() { NTPTime t; t.setInvalid(); return t; }
    
    public:
    	NTPTime() : m_Time(0) {}
    	NTPTime(const uint64_t time) : m_Time(time) {}
    	NTPTime(const uint32_t sec, const uint32_t frac)
    	  : m_Time(0)
    	{
    		this->set(sec, frac);
    	}
    
    	NTPTime(const boost::posix_time::ptime& timestamp);
    
    public: // Assignment operators
    	NTPTime& operator=(const uint64_t u) { m_Time = u; return *this; }
    	NTPTime& operator+= (const NTPTime& Q) { m_Time += Q.m_Time; return *this; }
    	NTPTime& operator-= (const NTPTime& Q) { m_Time -= Q.m_Time; return *this; }
    
    public: // Cast operators
    	operator uint64_t() { return this->m_Time; }
    
    public: // comparison operators
    	bool operator==(const NTPTime& other) const { return (m_Time == other.m_Time); }
    	bool operator!=(const NTPTime& other) const { return (m_Time != other.m_Time); }
    	bool operator>=(const NTPTime& other) const { return (m_Time >= other.m_Time); }
    	bool operator>(const NTPTime& other) const { return (m_Time > other.m_Time); }
    	bool operator<=(const NTPTime& other) const { return (m_Time <= other.m_Time); }
    	bool operator<(const NTPTime& other) const { return (m_Time < other.m_Time); }
    
    public: // arithmetic operators
    	NTPTime operator+(const NTPTime& other) const
    	{
    		NTPTime result = *this;
    		result += other;
    		return result;
    	}
    
    	NTPTime operator-(const NTPTime& other) const
    	{
    		NTPTime result = *this;
    		result -= other;
    		return result;
    	}
    
    public:
    	uint32_t getSeconds() const { return ((uint32_t)(m_Time >> 32));}
    	uint32_t getFracSeconds() const { return ((uint32_t)(m_Time & 0xFFFFFFFF));}
    	uint32_t getMilliseconds() const { const uint64_t t = 1000*m_Time ; return (uint32_t)((t>>32)&0xFFFFFFFF);}
    	uint32_t getMicroseconds() const { const uint64_t t = 125*m_Time/536871; return (uint32_t)(t&0xFFFFFFFF);}
    	void getTime_s_us(uint32_t& sec, uint32_t& us) const { sec = getSeconds(); us = getFracSeconds()/4295;}
    	uint64_t getTime(void) const {return m_Time;}
    
    public:
    	/// set the time in seconds and microseconds (micros: 0..1000 0000)
    	///This routine uses the factorization: 2^32/10^6 = 4096 + 256 - 1825/32
    	void setTime_s_us(const uint32_t sec, const uint32_t us) { m_Time = ((uint64_t)sec<<32) | ((us<<12)-((us*1852)>>5)+(us<<8));}
    
    	void set(const uint64_t& u) {m_Time = u;}
    	void set(const uint32_t sec, const uint32_t frac)
    	{
    		m_Time = sec;
    		m_Time = m_Time<<32;
    		m_Time |= frac;
    	}
    
    	void setInvalid() { m_Time = uint64_t(NOT_A_DATE_TIME) << 32; }
    
    	/// 2^32/10^6 = 4096 + 256 - 1825/32
    	void setMicroseconds(const uint32_t u) { const uint64_t t = ((uint64_t)u * 1825) >> 5; m_Time = ((uint64_t)u << 12) + ((uint64_t)u << 8) - t;}
    	void setMicroseconds(const uint64_t u) { const uint64_t t = (u * 1825) >> 5; m_Time = (u << 12) + (u << 8) - t;}
    	void setMilliseconds(const uint32_t u) { m_Time = (uint64_t)u * 536870912 / 125;}
    	void addMilliseconds(const uint32_t u) { NTPTime t; t.setMilliseconds(u); *this += t;}
    	void addMicroseconds(const uint32_t u) { NTPTime t; t.setMicroseconds(u); *this += t;}
    
    protected:
    	static double round(const double v);
    
    private:
    	static const double secondFractionNTPtoNanoseconds;
    	static const double nanosecondsToSecondFractionNTP;
    	static const uint32_t NOT_A_DATE_TIME;
    	static const uint64_t NOT_A_DATE_TIME64;
    	static const boost::posix_time::ptime m_epoch;
    
    protected:
    	uint64_t m_Time; ///< NTP time in 1/2^32 seconds (~233 ps)
    }; // NTPTime

    Чуть г-на и несколько комментов удалил, чтоб влезло. Чтоб понятно было, m_Time хранит время в единицах 1/2^32 сек.

    elapidae, 22 Марта 2018

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

    +2

    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 "stdafx.h"
    #include<iostream>
    #include<fstream>
    #include<string>
    #include<map>
    #include<iomanip>
    using namespace std;
    int main()
    {
    	string word;
    	setlocale(LC_ALL, "Russian");
    	char s[80];
    	fstream inOut;
    	multimap<string, int>my;
    	multimap<string, int>::iterator it;
    	inOut.open("text.txt", ios::in);
    	for (int i = 1; i < 40; i++) {
    		inOut.getline(s, 256);
    		char* pch;
    		pch = strtok(s, " ,-:;");
    		while (pch != NULL) {
    			word = string(pch);
    			my.insert(pair <string, int>(pch, i));
    			//cout << pch <<'\t'<<i<< endl;
    			pch = strtok(NULL, " ,-:");
    		}
    	}
    		inOut.close();
    	//cout << s;
    		for (it = my.begin(); it != my.end(); it++) {
    			cout.width(25);
    			cout << (*it).first <<setw(5) << (*it).second  << endl;
    		}
    	
    	
    	system("pause");
        return 0;
    }

    Берёт из текста строки и сортирует в алфавитном порядке

    ArthurMakaev, 19 Марта 2018

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    // Read option name (can contain spaces)
         while (is >> token && token != "value")
    -        name += string(" ", name.empty() ? 0 : 1) + token;
    +        name += (name.empty() ? "" : " ") + token;

    terminate called after throwing an instance of 'std::length_error'
    what(): basic_string::_M_create


    Replacing string(" ", name.empty() ? 0 : 1) with (name.empty() ? "" : " ") and the same in the while() loop for value fixes the problem (for me).

    Does anyone know if "string(" ", 0)" is invalid C++ ?

    Кресты такие кресты.

    3.14159265, 18 Февраля 2018

    Комментарии (17)
  5. Куча / Говнокод #23794

    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
    https://www.google.de/search?q=случайное+фио
    https://names-generator.ru/
    
        Кудряшова Екатерина Митрофановна
        Ширяев Константин Куприянович
        Тетерина Венера Максимовна
        Калинина Лора Михаиловна
        Осипова Кира Валентиновна
        Абрамова Ираида Григорьевна
        Игнатьев Эдуард Николаевич
        Мухина Оксана Филатовна
        Дьячков Вадим Вячеславович
        Мишин Владлен Лукьевич

    Не разу еще не встречал генератор, который бы учитывал частотное распределение имен.

    syoma, 15 Февраля 2018

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

    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
    function checkAnswer(lastId, connectionString, success, unsuccess, installationNumber) {
      var result;
      for(var i=0;i<3*15/*15min*/;i++) {
        Delay(periodCheckingComponentsInstalled, "Waiting components to be installed");
        result = getDataFromDB(connectionString, lastId);
        var k = [];
        for(var i=0;i<success.length; i++) {
          k.push(false);
        }
        
        for(var i=0;i<success.length;i++) {
          if ((success[i] == "RemoteSuccess") ||  (success[i] == "RemoteUnSuccess")) {
            k[i] = true;
            break;
          }
          else {
            for(var j=0;j<result.length ; j++) {
              if (result[j].length > 40) {
                k[i] = includeArray(result, success[i]);//40 symb
                if (includeArray(result, unsuccess[i])) Log.Error("error while installing, number installation = " + installationNumber);
              }
            }
          }
        }
        var bool = true;
        for (var i=0;i<success.length; i++) {
          bool = bool&&k[i];
        } 
        if (bool) return true; else continue;
        return false;
      }
    }

    Остался скрипт от тестировщика. Блядь, и такого там с мегабайт.

    fluttr, 13 Ноября 2017

    Комментарии (17)
  7. VisualBasic / Говнокод #23423

    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
    Private Function DecodName(ByVal ind As Integer) As String
            ''перекодування назви місяця
            Select Case ind
                Case 1
                    Return "Січень"
                Case 2
                    Return "Лютий"
                Case 3
                    Return "Березень"
                Case 4
                    Return "Квітень"
                Case 5
                    Return "Травень"
                Case 6
                    Return "Червень"
                Case 7
                    Return "Липень"
                Case 8
                    Return "Серпень"
                Case 9
                    Return "Вересень"
                Case 10
                    Return "Жовтень"
                Case 11
                    Return "Листопад"
                Case 12
                    Return "Грудень"
                Case Else
                    Return ""
            End Select
        End Function

    Мои глаза...

    vova94, 17 Октября 2017

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php if (!\MUserAuth::isAuthenticated()) : ?>
                <div id="wrapper-for-cabinet-content" style="display: none;"></div>
            {else}
                <div id="wrapper-for-cabinet-content">
                {include file="/themes/$__theme/en/common/muser_dropdown_part/cabinet.tpl"}
                </div>
            {/if}

    И это #работает#блять... "Smarty" нашего тимлида...

    rez1dent3, 25 Августа 2017

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

    +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
    <?
    
    if(!$_POST){//mpre("Не аякс запрос");
    }elseif(!$name = mpquot(get($_POST, 'name'))){mpre("Регистрационное имя не указано");
    }elseif(!$pass = get($_POST, 'pass')){mpre("Пароль для регистрации не указан");
    }elseif(get($_POST, 'pass') != get($_POST, 'pass2')){mpre("Пароли не совпадают");
    }elseif($users = rb("{$conf['db']['prefix']}users","name","[{$name}]")){mpre("Пользователь уже зарегистрирован");
    }elseif(!$sess = get($conf, 'user', 'sess')){mpre("Ошибка полученя сессии текущего пользователя");
    }elseif(!$mphash = mphash($name, $pass)){mpre("Ошибка генерации пароля");
    }elseif(!$users = fk("{$conf['db']['prefix']}users", $w = array("name"=>$name), $w += array("type_id"=>1, "pass"=>$mphash, "reg_time"=>time(), "last_time"=>time(), "email"=>get($_POST, 'email'), "ref"=>get($conf, 'user', 'sess', 'ref'), "refer"=>get($conf, 'user', 'sess', 'refer')))){mpre("Ошибка регистрации пользователя");
    }elseif(!$grp = get($conf, 'settings', 'user_grp')){mpre("Ошибка определения пользовательской группы");
    }elseif(!$users_grp = rb("users-grp", "name",$w = "[{$grp}]")){mpre("Ошибка выборки группы {$w}");
    }elseif(!$users_mem = fk("users-mem", $w = ["uid"=>$users['id'], "grp_id"=>$users_grp['id']], $w)){mpre("Ошибка добавления пользователя `{$users["name"]}` в группу '{$users_grp["name"]}'");
    }elseif(!$sess = fk("{$conf['db']['prefix']}sess", ["id"=>$sess["id"]], null, ['uid'=>$users["id"]])){mpre("Ошибка обновления сессии пользователя");
    }else{ mpevent("Регистрация нового пользователя", $name, $users['id'], $_POST);
    	 exit(json_encode($users));
    }

    Страница регистрации

    12febraury, 23 Августа 2017

    Комментарии (17)
  10. SQL / Говнокод #23214

    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
    CREATE TABLE [dbo].[TBL_JOUR_PRODUCTION_PLAN_KK_BH](
    	[JPPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_JPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_WC_ID] [int] NOT NULL,
    	[JPPKKBH_DATE] [datetime] NOT NULL,
    	[JPPKKBH_QTY] [numeric](30, 5) NOT NULL,
    	[JPPKKBH_QTYF] [numeric](30, 5) NOT NULL,
    	[JPPKKBH_COMENT] [varchar](8000) NULL,
    	[JPPKKBH_DESCRIPTION] [varchar](8000) NOT NULL,
    	[JPPKKBH_WHO] [varchar](150) NOT NULL,
    	[JPPKKBH_WHO_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBH_WHEN] [datetime] NOT NULL,
    (
    
    CREATE TABLE [dbo].[TBL_JOUR_PRODUCTION_PLAN_KK_BH_HISTORY](
    	[JPPKKBHH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_JPKKBH_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_JPPKKBH_WC_ID] [int] NOT NULL,
    	[JPPKKBHH_JPPKKBH_DATE] [datetime] NOT NULL,
    	[JPPKKBHH_JPPKKBH_QTY] [numeric](30, 5) NOT NULL,
    	[JPPKKBHH_JPPKKBH_QTYF] [numeric](30, 5) NOT NULL,
    	[JPPKKBHH_JPPKKBH_COMENT] [varchar](8000) NULL,
    	[JPPKKBHH_JPPKKBH_DESCRIPTION] [varchar](8000) NOT NULL,
    	[JPPKKBHH_JPPKKBH_WHO_ID] [uniqueidentifier] NULL,
    	[JPPKKBHH_JPPKKBH_WHEN] [datetime] NOT NULL,
    	[JPPKKBHH_OPER] [int] NOT NULL,
    	[JPPKKBHH_WHO_ID] [uniqueidentifier] NOT NULL,
    	[JPPKKBHH_WHEN] [datetime] NOT NULL,
    (

    no comments

    Kaldblpb, 25 Июля 2017

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

    −93

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Для эстетов. Мы за это платим овердохуя, в получаем:
    
    Текст.запроса = Текст.Запроса + Сред(ТекстЗапроса,Врезка8+33,Врезка9-Врезка8+24-33+1) ;
    Мало того - что тут по буквам ТЕКСТ собирают, так еще и ошиблись - не +33 а +33-3 надо! ПИЗДЕЦ!
    Вот эта хуета - Сред(ТекстЗапроса,Врезка8+33,Врезка9-Врезка8+24-33+1)  - возвращает "ОР" - и компилятор орет на ошибку
    А вот эта наша хуета - Сред(ТекстЗапроса,Врезка8+33-3,Врезка9-Врезка8+24-33+1)  - возвращает "ВЫБОР" в все заебись работает.

    Из глубин прикладной 1С

    balabass, 31 Октября 2016

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