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

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

    +16

    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
    QVector<Line> Converter::convert(QImage &image, Modes mode/*, int left, int top, int right, int bottom*/){
        QVector<Line> result;
        /* if(left < 0) left = 0;
        if(top < 0) top = 0;
        //if(right > image.width()) right = image.width();
        //if(bottom > image.height()) bottom = image.height();
        //points.clear();
        //pix.fill(Qt::black);
        if(left > right){
            left ^= right;
            right ^= left;
            left ^= right;
        }
        if(top > bottom){
            top ^= bottom;
            bottom ^= top;
            top ^= bottom;
        }*/
        int left = 0,top = 0,right = image.width(),bottom = image.height();
        for( int i = left; i < right; ++i){
            for( int j = top; j < bottom; ++j){
                Line p;
                p.x1 = p.x2 = i;
                p.y1 = p.y2 = j;
                p.z1 = qGray(image.pixel(i,j));
                p.c = p.z1;
                QVector<int> v;
                if(i!=left) v.push_back(qGray(image.pixel(i-1,j)));
                if(i < right-1) v.push_back(qGray(image.pixel(i+1,j)));
                if(j!=top) v.push_back(qGray(image.pixel(i,j-1)));
                if(j < bottom-1) v.push_back(qGray(image.pixel(i,j+1)));
                if(i!=left && j!= top) v.push_back(qGray(image.pixel(i-1,j-1)));
                if(i < right-1 && j!=top) v.push_back(qGray(image.pixel(i+1,j-1)));
                if(j < bottom-1 && i!=left) v.push_back(qGray(image.pixel(i-1,j+1)));
                if(i < right-1 && j < bottom-1) v.push_back(qGray(image.pixel(i+1,j+1)));
                int min = *(std::min_element(v.begin(),v.end()));
                if(min < qGray(image.pixel(i,j))){
                    /* for( unsigned k = 0; k < p.c-min; ++k){
                        Point p0;
                        p0.x = i;
                        p0.y = j;
                        p0.z = qGray(image.pixel(i,j))-(k+1);
                        p0.c = qGray(image.pixel(i,j));
                        points.push_back(p0);
                    }*/
                    p.z2 = p.z1 - min;
                }else{
                    p.z2 = p.z1;
                }
                result.push_back(p);
            }
        }
        /*origin.x = 0;
        origin.y = 0;
        origin.z = 0.0;*/
        switch (mode) {
        case ISO:
            rotate(result, 3.1415/180*35.2,3.1415/4,-3.1415/4);
            //rotate(result, 0,,0);
            //rotate(result, 0,0,-3.1415/4);
            break;
        case BOTTOM:
            rotate(result, 3.1415/180*90,0,0);
            break;
        case LEFT:
            rotate(result, 3.1415/180*90,0,0);
            rotate(result, 0, 3.1415/180*90,0);
            break;
        case RIGHT:
            rotate(result, 3.1415/180*90,0,0);
            rotate(result, 0, -3.1415/180*90,0);
            break;
        default:
            break;
        }
        return result;
    }

    Картинка превращается, превращается...

    Abbath, 20 Января 2014

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

    +138

    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 bool ShowOkIfAllIsCool = true;
    
    book OK()
    {
        return ShowOkIfAllIsCool;
    }
    
    bool GetFileExists(string filePath)
    {
         return File.Exists(filePath);
    }
    
    int GetLengthFileName(string filePath)
    {
        return filePath.Lenght;
    }
    
    int SetMaxValue(int maxValue)
    {
        _OPENWINDOWSAFTERINITIALIZATION = maxValue;
    }

    Программированием занимаюсь много лет, а так и не могу понять, для чего создавать подобные методы в 1 строку и константы заглавными буквами огромной длины? Их люди пишут или это автоматически созданный код какой-то прогой? В чужих программах такое часто можно встретить.

    sbs, 25 Декабря 2013

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static bool ProductGT10(Point p)
        {
            if (p.X * p.Y > 100000)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    Классический пример из MSDN
    http://msdn.microsoft.com/ru-ru/library/bfcke1bz.aspx

    kegdan, 10 Июля 2013

    Комментарии (66)
  5. Си / Говнокод #13069

    +108

    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
    bool getSelectedFile(wchar_t *out, bool skip) {
    	HWND hwndFind = GetForegroundWindow();
    
    	TCHAR g_szPath[BUF_SIZE];
    	TCHAR g_szItem[BUF_SIZE];
    	//g_szPath[0] = TEXT('\0');
    	//g_szItem[0] = TEXT('\0');
    	memset(g_szPath, 0, sizeof(TCHAR) * BUF_SIZE);
    	memset(g_szItem, 0, sizeof(TCHAR) * BUF_SIZE);
    
    	IShellWindows *psw;
    	if(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw) != S_OK) return false;
    	
    	VARIANT v;
    	v.vt = VT_I4;
    	IDispatch  *pdisp;
    	bool fFound = false;
    	bool pExtracted = false;
    	bool nExtracted = false;
    	
    	for (V_I4(&v) = 0; !fFound && psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
    			IWebBrowserApp *pwba;
    			if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
    				HWND hwndWBA;
    				if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)) && hwndWBA == hwndFind) {
    					fFound = true;
    					IServiceProvider *psp;
    					if(SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
    						IShellBrowser *psb;
    						if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
    							IShellView *psv;
    							if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
    								IFolderView *pfv;
    								if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
    									IPersistFolder2 *ppf2;
    									if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
    										LPITEMIDLIST pidlFolder;
    										if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
    											if(SHGetPathFromIDList(pidlFolder, g_szPath)) {
    												pExtracted = true;
    												if(skip) {
    													lstrcpy(out, g_szPath);
    													out[lstrlen(g_szPath)] = 0;
    													return true;
    												}
    											}
    											int iFocus;
    											if(SUCCEEDED(pfv->GetFocusedItem(&iFocus))) {
    												LPITEMIDLIST pidlItem;
    												if (SUCCEEDED(pfv->Item(iFocus, &pidlItem))) {
    													IShellFolder *psf;
    													if (SUCCEEDED(ppf2->QueryInterface(IID_IShellFolder, (void**)&psf))) {
    														STRRET str;
    														if(SUCCEEDED(psf->GetDisplayNameOf(pidlItem, SHGDN_INFOLDER, &str))) {
    															StrRetToBuf(&str, pidlItem, g_szItem, 1024);
    															nExtracted = true;
    															int psz = lstrlen(g_szPath);
    															int isz = lstrlen(g_szItem);
    															if(pExtracted) {
    																lstrcpy(out, g_szPath);
    																out[psz] = '\\';
    															}
    															lstrcpy(out+psz+1, g_szItem);
    															out[psz + isz + 2] = 0;
    														}
    														psf->Release();
    													}
    													CoTaskMemFree(pidlItem);
    												}
    											}
    											CoTaskMemFree(pidlFolder);
    										}
    										ppf2->Release();
    									}
    									pfv->Release();
    								}
    								psv->Release();
    							}
    							psb->Release();
    						}
    						psp->Release();
    					}
    				}
    				pwba->Release();
    			}
    			pdisp->Release();
    	}
    	psw->Release();
    	return (pExtracted && nExtracted);
    }

    Две очаровательных (говно) лестницы из какой-то очередной переназначалки горячих клавиш в Windows.
    Оригинал тут: https://github.com/mapseamoff/KeyBinder/blob/master/ShellHelper/ShellHelper/main.cpp

    kovnogod, 29 Мая 2013

    Комментарии (66)
  6. Pascal / Говнокод #10011

    +129

    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
    function assemble(var w:word;s:string):boolean;
    .....
     else if length(cmd)=3 then
      begin
       {ТРЕХБУКВЕННЫЕ КОМАНДЫ}
       case cmd[1] of
        'a':case cmd[2] of
             'c':if cmd[3]='i' then
                  begin
                   code:=$ce;
                   typ:=7;
                  end;
             'd':case cmd[3] of
                  'd':begin
                       code:=$80;
                       typ:=4;
                      end;
                  'c':begin
                       code:=$88;
                       typ:=4;
                      end;
                  'i':begin
                       code:=$c6;
                       typ:=7;
                      end;
                 end;
    ..... еще 500 подобных строк ....
    end;

    Прочитал http://govnokod.ru/10002 и вспомнил, как когда-то писал асм\дизасм\эмуль для 8080 на паскале.

    bormand, 22 Апреля 2012

    Комментарии (66)
  7. Java / Говнокод #7303

    +90

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    @Override
    public Object clone() {
              try {
                            return super.clone();
    	        } catch (Exception e) {
    			return this;
    		}
    }

    "Клонирование"

    auf1r2, 21 Июля 2011

    Комментарии (66)
  8. Pascal / Говнокод #2304

    +86.6

    1. 1
    if Mode = True then

    из исходников FastReport

    StriderMan, 21 Декабря 2009

    Комментарии (66)
  9. Assembler / Говнокод #1278

    +170.2

    1. 1
    2. 2
    3. 3
    mov eax, pony
    jnz pony
    jmp magiccastle

    Поне!

    Din, 28 Июня 2009

    Комментарии (66)
  10. Python / Говнокод #27113

    +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
    In order to fund the development work on speeding CPython by a factor of five, something like $2M will be required.
    This seems like a sizeable sum, but compared to the amount of money spent on Python development and the 
    cost of running Python applications, it is quite a modest sum.
    
    ---
    
    The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, 
    each stage increasing the speed of CPython by (approximately) 50%.
    
    1.5**4 ≈ 5
    
    ---
    
    The interpreter will adapt to types and values during execution, exploiting [b]type stability[/b] in the program
    
    ---
    
    Improved performance for [b]integers of less than one machine word[/b].
    Improved peformance for [b]binary operators[/b].
    
    ---
    
    Simple "JIT" compiler for small regions. Compile small regions of specialized code, using a relatively simple, fast compiler.
    Extend regions for compilation. Enhance compiler to generate [b]superior machine code[/b].

    питонисты готовят новую версию интерпретатора с революционной фичей - возможностью отъема денег у населения. Ожидается, что нововведение позволит языку быстро заработать очки на рынке пускания пыли в глаза.

    https://github.com/markshannon/faster-cpython

    Fike, 13 Ноября 2020

    Комментарии (65)
  11. Куча / Говнокод #26799

    0

    1. 1
    2. 2
    3. 3
    Илья Перекопский, вице-президент мессенджера «Телеграм», будет на встрече премьера Михаила Мишустина с представителями IT-индустрии в Иннополисе, Казань
    
    Замруководителя фракции "Справедливая Россия" Федот Тумусов планирует организовать в Госдуме круглый стол с онлайн-участием основателя Telegram Павла Дурова

    ДА НЕ ПЕРЕДАВАЛ Я КЛЮЧИ

    https://roem.ru/08-07-2020/282610/tlg-to-russia-with-love/
    https://ria.ru/20200710/1574142863.html

    Fike, 10 Июля 2020

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