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

    В номинации:
    За время:
  2. Куча / Говнокод #14325

    +133

    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
    // bormand: Ну что, затестим шейдер в WebGL...
    int iter = 0;
    while (iter < 1000 && length(z) < 2.0) {
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
        iter++;
    }
    // compileShader: 'while' : This type of loop is not allowed
    
    // bormand: WTF?! В обычном OpenGL же работало, ну ок...
    int iter = 0;
    for (; iter < 1000; iter++) {
        if (length(z) < 2.0)
            break;
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
    }
    // compileShader: 'for' : Missing init declaration
    
    // bormand: Да что за херня!?
    for (iter = 0; iter < 1000; iter++) {
    // compileShader: 'for' : Invalid init declaration
    
    // bormand: Подавись, сука!
    int iters = -1;
    for (int iter = 0; iter < 1000; iter++) {
        if (length(z) < 2.0) {
            iters = iter;
            break;
        }
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
    }
    // compileShader: ok.

    bormand vs WebGL

    bormand, 07 Января 2014

    Комментарии (159)
  3. Куча / Говнокод #14297

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    md a
    copy a.bat a
    cd a
    a.bat

    Угадайте, как называется файл с этим содержимым.

    dos_, 29 Декабря 2013

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

    +133

    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
    var firstLocation = new Tuple<Point, Point>(new Point(12, 444 - 38), new Point(30, 446 - 38));
    var secondLocation = new Tuple<Point, Point>(new Point(12, 464 - 38), new Point(30, 464 - 38));
    var thirdLocation = new Tuple<Point, Point>(new Point(12, 486 - 38), new Point(30, 484 - 38));
    
    var first = new Tuple<Control, Control>(chbDimaGaugeNewContractPS, lblDimaGaugeNewContractPS);
    var second = new Tuple<Control, Control>(chbDimaGaugeNewContractIBanking, lblDimaGaugeNewContractIBanking);
    var third = new Tuple<Control, Control>(chbDimaGaugeNewContractActivePS, lblDimaGaugeNewContractActivePS);
    
    var controls = new List<Tuple<Control, Control>> { first, second, third };
    var points = new List<Tuple<Point, Point>> { firstLocation, secondLocation, thirdLocation };
    
    int i = 0;
    
    foreach (var t in controls.Where(x => !x.Item1.Enabled))
    {
      t.Item1.Location = points[i].Item1;
      t.Item2.Location = points[i].Item2;
      i++;
    }

    кортежи в .NET - хорошо или плохо?

    taburetka, 06 Декабря 2013

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public Normalizer(Int32 totalElementsCount)
    {
        _totalElementsCount = totalElementsCount;
        _delta = Int32.MaxValue / (2 * totalElementsCount);
        if (_delta == 0)
            throw new OverflowException("Too much normalizated records.");
    }

    Осталось от старых разработчиков. Долго не могли понять, почему кидается DivideByZeroException

    botinko, 05 Декабря 2013

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

    +133

    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
    function tform1.ExistsFiles(path:string):boolean;
    var
      hfile:thandle;
      fname:string;
      WD:win32_find_dataA;
    begin
      result:=false;
      if directoryexists(path)=false then
      exit;
      path:=includetrailingpathdelimiter(path);
      hfile:=FindFirstFile(pchar(path+'*.*'),wd);
      if hfile <> invalid_handle_value then
      begin
        repeat
          fname:=string(wd.cFileName);
          if (fname <> '.') and (fname <> '..') then
          begin
            if (wd.dwFileAttributes and file_attribute_directory <> 0) then
            begin
              if existsfiles(path+fname)=true then
              begin
              result:=true;
              break;
              end;
            end
            else
            if ansilowercase(extractfileext(fname))='.txt' then
            begin
              result:=true;
            break;
            end;
          end;
        until findnextfile(hfile,wd) <> true;
        windows.findclose(hfile);
      end;
    end;

    Проверяем, есть ли в папке и ее подпапках текстовые документы...

    Stertor, 26 Ноября 2013

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    foreach (var contractBaseViewModel in contractModels)
    {
    	var entity = dbTenderLots.FirstOrDefault(x => x.Uid == contractBaseViewModel.EntityUid);
    	if (entity != null)
    	{
    		contractModels.ForEach(x => x.LotViewUrl = url.Generate<TendersController>(l => l.Lot(entity.Id)));
    	}
    }

    вопрос. какое значение примет LotViewUrl у моделек?

    Silvochka, 09 Сентября 2013

    Комментарии (18)
  8. Java / Говнокод #13691

    +133

    1. 1
    http://www.quizful.net/interview/java/k4gCs7Qmf8YF

    Мне кажется, или кто то накурился?

    если я не прав - обьяните(

    kegdan, 28 Августа 2013

    Комментарии (18)
  9. Си / Говнокод #13690

    +133

    1. 1
    hq->rd_period = (i = hq->rd_period+1) != 0 ? i : 1;

    что именно хотел сказать автор, неизвестно. предполагаю что `while (!++hq->rd_period);`

    Dummy00001, 28 Августа 2013

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

    +133

    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
    private string LineTabsCRLFToSpaces(string line)
            {
                string ret_line = "";
                if (line != null)
                {
                    //    throw new ArgumentNullException("line");
                    if (line.Length == 0) return string.Empty;  // Пустая входная строка
                    for (int i = 0; i < line.Length; i++)
                    {
                        char ch = line[i];
                        if (ch == '\t' || ch == '\r' || ch == '\n')
                            ret_line = ret_line + " ";
                        else
                            ret_line = ret_line + ch;
                    }
                }
                return ret_line;
            }

    - line.Replce()?
    - Не, не слышал!

    nolka4, 12 Августа 2013

    Комментарии (38)
  11. Си / Говнокод #13490

    +133

    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
    void mb_sim_pix(uchar* IN, uchar* OUT, int *WH, int *bSize, int *A, int *pSize, float *threshold){
    	int pos = mb_calc_pos(A, WH, pSize);
    	int nPos;
    	int i, n;
    	int B[2];
    		
    	for(n = 0; n < 4; n++){
    		
    		switch(n){
    			case 0:
    				B[0] = A[0] + 1;
    				B[1] = A[1];
    			
    			case 1:
    				B[0] = A[0];
    				B[1] = A[1] - 1;
    			
    			case 2:
    				B[0] = A[0];
    				B[1] = A[1] + 1;
    			
    			case 3:
    				B[0] = A[0] - 1;
    				B[1] = A[1];
    		}
    		
    		if(	B[0] >= 0 && B[0] < WH[0] &&
    			B[1] >= 0 && B[1] < WH[1]){
    			nPos = mb_calc_pos(B, WH, pSize);
    			if(mb_val_pix(OUT, &nPos, pSize) == 0){
    				if(mb_sim_pack(IN, &pos, &nPos, pSize) >= *threshold){
    					for(i = 0; i < *pSize; i++) OUT[nPos + i] = IN[nPos + i];
    					mb_sim_pix(IN, OUT, WH, bSize, B, pSize, threshold);
    				}
    			}
    		}
    	}
    }

    Тоже самое через if работает, а через switch проваливается на значении 0 все итерации. Почему?

    Stertor, 27 Июля 2013

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