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

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

    +51.6

    1. 1
    if ($name == "ryuzaki") {die("Вы заблокированы");}

    Отличная система бана...
    © nod, 2009

    guest, 10 Января 2009

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

    +51.5

    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
    void CNewAnketaOrg::OnSeachOrg() 
    {
    	if(m_SeachOrg.GetCheck())
    	{
    		m_Create.SetCheck(FALSE);
    		m_SeachOur.SetCheck(FALSE);
    		m_SeachFZ.SetCheck(FALSE);
    		CFindOrganization find(this);
    		if (find.DoModal() == IDOK)
    		{
    			...
    		}
    		...
    	}
    }

    Угадайте какое сообщение привязано к методу с вызовом формы.

    Criperum, 24 Сентября 2009

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

    +51.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    /*
     * adding data into report params array.
     */
    $reportParams = array();
    $reportParams += array(
    			'id'			=> $ID, 
    			'view_class'	=> $viewClass,
    			'direct'		=> $direct,
    			'clone'			=> $clone
    		);

    Суровые узбекские программисты делают так :)

    guest, 30 Мая 2009

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

    +51.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $screen_width = "<script language=\"javascript\">document.write(screen.width);</script>";
    
    if ($screen_width < 400){
             $new_limit = "900";
             $limit_var = "width";
     }elseif ($screen_width > 400){
             $new_limit = "400";
             $limit_var = "width";
          }else {
                          $new_limit = $image_info[0];
             $limit_var = "width";
          }

    Ресайз картинко по ширине экрана %)

    guest, 14 Января 2009

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

    +51.4

    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
    .....
    <table width=100% border=1>
    <colgroup .....>
    .....
    <tr>
      <td colspan=2>(тут шапка)</td>
    </tr>
    <tr>
      <td width=60% colspan>(слева)</td>
      <td width=40% colspan>(справа)</td>
    </tr>
    .....
    </table> 
    .....

    Нету раздела html, поэтому решил наговнокодить тут :) Будет ли это говнокодом если верстать сайты так? Вообщем за и против div'ой и табличной верстки.. примеры данного куска с оптимальным содержанием..

    antigovnokoder, 06 Апреля 2010

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

    +51

    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
    #if defined(alignas) /* check C++ keywords */ \ 
    || defined(alignof) \ 
    || defined(asm) \ 
    || defined(auto) \ 
    || defined(bool) \ 
    
    <...snip...>
    
    || defined(virtual) \ 
    || defined(void) \ 
    || defined(volatile) \ 
    || defined(wchar_t) \ 
    || defined(while) 
    #error keyword defined before including C++ standard header 
    #endif /* defined... */

    Из заголовочных файлов VS 2012.

    http://www.viva64.com/en/b/0146/

    someone, 05 Марта 2015

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

    +51

    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
    #include <ppl.h>
    #include <windows.h>
    #include <ppltasks.h>
    #include <iostream>
    #include <vector>
    
    using namespace Concurrency;
    using namespace std;
    
    CRITICAL_SECTION cs6;
    
    int main(int argc, char* argv[])
    {
    	size_t concurentThreadsSupported = std::thread::hardware_concurrency();
    	cout << concurentThreadsSupported << endl;
    	//deadlock hazard increased with concurentThreadsSupported decreasing
    
    	size_t taskAmountForWasteVirtualCores = concurentThreadsSupported - 1;//must be equal to (virtual processor thread amount from Concurrency::IResourceManager) - 1
    	vector<task<void>> t;
    	for (size_t i = 0; i<taskAmountForWasteVirtualCores; ++i)
    		t.push_back(create_task([]{
    			Sleep(INFINITE);//some very long IO operation or deadlocked by EnterCriticalSection or sql transaction or other
    		}));
    	Sleep(1000);
        cout << "another way:" << endl;
        InitializeCriticalSection(&cs6);
        auto locker = create_task([]{
            cout << "locker" << endl;
            EnterCriticalSection(&cs6);//same as begin sql transaction
            cout << "locker entered cs 6" << endl;
            Concurrency::wait(500);//Deadlock by any concurrency context switching directly or indirectly by std or MFC (events, mutex, etc)
            cout << "locker played" << endl;
            LeaveCriticalSection(&cs6);//same as end sql transaction
            cout << "~locker ok" << endl;
        });
        auto locked = create_task([]{
            cout << "locked" << endl;
            EnterCriticalSection(&cs6);//same as begin sql transaction
            cout << "locked entered cs 6" << endl;
            Concurrency::wait(500);
            cout << "locked played" << endl;
            LeaveCriticalSection(&cs6);//same as end sql transaction
            cout << "~locked ok" << endl;
        });
    	Sleep(1000);
    	cout << "FAIL" << endl;
    	return 0;
    }

    Нашел дидлок)
    http://rextester.com/KHC72232
    http://rextester.com/EMG65441

    laMer007, 04 Марта 2015

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

    +51

    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
    {
    		INT TextTickIdx(-1), MinorCnt( m_AxisX->GetMinorTick() || m_AxisX->GetDisplayMinorGrid() ? (INT)m_AxisX->GetMinorTickSpace() : 0 );
    		std::vector<std::pair<RectF,INT>>::iterator SLRit = SavedLabelRects.begin();
    		std::vector<std::pair<SizeF,SizeF>>::iterator STSit = SavedTextSizes.begin();
    		if(SLRit != SavedLabelRects.end())
    			TextTickIdx = NotEmptyIdxs[SLRit->second];
    
    		BOOL ShowCatLines(m_AxisX->GetShowCategoryLines());
    		std::map<REAL, PointF> CatPts;
    		if(ShowCatLines)
    		{
    			// берём все возможные по всей длине оси
    			REAL CatOff(0);
    			if(m_AxisXPlacement == CAXP_ONTICK)
    				CatOff = CalcScaleIntervalW/2.0f;
    			INT CatLnsCnt = (m_AxisXPlacement == CAXP_ONTICK) ? PointsCount : PointsCount + 1;
    			for(INT i(0);i < CatLnsCnt;i++)
    			{
    				PointF Pt;
    				REAL SecCoord;
    				switch(Position)
    				{
    				case AA_TOP:
    				case AA_BOTTOM:
    					SecCoord = AxisXSelfRect.X + CatOff + i*CalcScaleIntervalW;
    					Pt.X = SecCoord;
    					break;
    				case AA_LEFT:
    				case AA_RIGHT:
    					SecCoord = AxisXSelfRect.Y + CatOff + i*CalcScaleIntervalW;
    					Pt.Y = SecCoord;
    					break;
    				}
    				CatPts.insert(std::make_pair(SecCoord, Pt));
    			}
    		}
    		PointF TickOff(0,0);
    		BOOL TicksBetweenCategories(m_AxisX->GetTicksBetweenCategories());
    		if(TicksBetweenCategories)
    		{
    			switch(Position)
    			{
    			case AA_TOP:
    			case AA_BOTTOM:
    				TickOff.X = ReversedAxisX ? -CalcScaleIntervalW*0.5f : CalcScaleIntervalW*0.5f;
    				break;
    			case AA_LEFT:
    			case AA_RIGHT:
    				TickOff.Y = ReversedAxisX ? CalcScaleIntervalW*0.5f : -CalcScaleIntervalW*0.5f;
    				break;
    			}
    		}
    		std::vector<CDgmAxisTickTextDrawCacheItem>& AxisXTickCache = m_AxisX->GetDrawTickTextCache();
    		long TickInterval = IsDateAxis ? m_AxisX->GetDateAxisSettings()->GetMajorTickUnitInterval() : m_AxisX->GetTickMarksInterval();
    		if(TickInterval < 1)
    			TickInterval = 1;
    		INT TickStartAt = (m_AxisXPlacement == CAXP_ONTICK && !TicksBetweenCategories ? 0 : 1);
    		
    		DATE DateMajorTickStartAt = m_AxisX->GetDateAxisSettings()->GetMajorTickStartAt();
    		INT  CategoryMajorTickStartAt = m_Owner->GetCategoryFromDate(DateMajorTickStartAt) - 1;
    		if (CategoryMajorTickStartAt < 0)
    		{
    			CategoryMajorTickStartAt = 0;
    		}
    
    		CDgmDateAxisUnit MinorLabelTickUnits(DAU_AUTO);
    		if(IsDateAxis)
    		{
    			CDgmDateAxisSettings* ds = m_AxisX->GetDateAxisSettings();
    			MinorLabelTickUnits = ds->GetMinorTickUnit();
    			if(MinorLabelTickUnits == DAU_AUTO)
    				MinorLabelTickUnits = m_CalculatedDateAxisAutoMajorTickUnit;
    			MinorCnt = ds->GetMinorTickUnitInterval();
    			if(MinorCnt < 1)
    				MinorCnt = 1;
    		}
    		INT _k(0);
    		for (INT i(0), Cnt(Names.size());i < Cnt;i++)
    		{
    			CDgmAxisTickTextDrawCacheItem CacheItem;
    			BYTE nShow(0);
    			CacheItem.TickDrawPoint = Names[i].first + TickOff;
    			CacheItem.SetTextVisible(i == TextTickIdx);
    			if(i == TextTickIdx)	// метка с текстом
    			{
    				CacheItem.TextDrawCenter = Names[i].first;	// именно тик, т.к. одная координата у них общая, а вторая
    															// координата тика, ректа и центра после будет
    															// скорректирована по оси Х, из-за того, что ее
    															// размер и положение изменятся
    				CacheItem.PointIdx = Names[i].second.second;
    				if(CacheItem.PointIdx < 0)
    					CacheItem.TextValue = Names[i].second.first->m_text.GetPlainText();
    				CacheItem.TextDrawSize = SLRit->first;
    				CacheItem.FontSize = FontHeight;
    				CacheItem.m_sizefDrawBounds = STSit->first;
    				CacheItem.m_sizefTextBounds = STSit->second;
    
    				if (CacheItem.TextDrawCenter.X + CacheItem.TextDrawSize.Width * 0.5f > Max)
    				{
    					CacheItem.TextDrawCenter.X = Max - CacheItem.TextDrawSize.Width * 0.5f;

    Маааленький фрагментик большущего метода расчета координат для вывода подписей на оси Х на диаграмме. Так принято говнокодить в одной очень крупной российской ИТ-компании, занимающейся разработкой BI-продуктов.

    bulb_suringe, 26 Февраля 2015

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

    +51

    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
    template<class T, size_t N>
    constexpr size_t sa(T (&)[N])
    {
    	return N;
    };
    
    static std::memory_order mmo[] = 
    {
        memory_order_relaxed,
        memory_order_consume,
        memory_order_acquire,
        memory_order_release,
        memory_order_acq_rel,
        memory_order_seq_cst
    };
    
    std::memory_order current_program_memory_order()
    {
    	return mmo[rand()%sa(mmo)];
    }
    
    void current_program_memory_barier()
    {
    	std::atomic_thread_fence(current_program_memory_order());
    }

    LispGovno, 23 Февраля 2015

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

    +51

    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
    void main() {
    	system("color 04");
    
    	setlocale(LC_ALL, "rus");
    
    
    
    	if (start == false)  {
    		logos();
    		loading();
    		start = true;
    		system("cls");
    	}
    
    
    
    	if (get_hero_s == false)  {
    		get_hero();
    		get_hero_s = true;
    	}
    
    
    
    
    	menu();
    	map();
    	if (go_went_gone == 1) {
    		system("cls");
    		cout << "\nВы напали на оборотня в тёмном лесу\n";
    		loading();
    		Sleep(1400);
    		fight("werewolf");
    
    
    		go_went_gone = 0;
    
    		main();
    	}
    	else if (go_went_gone == 3) {
    		system("cls");
    		cout << "\nВы напали на лучника в мрачном поле\n";
    		loading();
    		Sleep(1400);
    		fight("archer");
    
    
    		go_went_gone = 0;
    
    		main();
    	}
    
    
    	if (go_went_gone == 2) {
    		system("cls");
    		cout << "\nВы напали на гоблина в тёмном лесу\n";
    		loading();
    		Sleep(1400);
    		fight("werewolf");
    
    
    		go_went_gone = 0;
    
    		main();
    	}
    	else if (go_went_gone == 4) {
    		system("cls");
    		cout << "\nВы напали на лучника на костяного лучника в подземелье \n";
    		loading();
    		Sleep(1400);
    		fight("archer");
    
    
    		go_went_gone = 0;
    
    		main();
    	}

    Рекурсия мейна, и это курсовая работа!!

    BoMo, 20 Февраля 2015

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