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

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

    +161

    1. 1
    2. 2
    3. 3
    if (($arrRoleInHold = $this->syncByToken($token)) && (!$arrRoleInHold)) {
        throw new Exception('');
    }

    хорошее условие!

    tempfolder, 12 Января 2015

    Комментарии (4)
  3. JavaScript / Говнокод #17404

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (!!window.Worker){
        var worker = new Worker('worker.js');
        worker.postMessage('Hellow World');
        worker.onmessage = function (e){
          alert(e.data);
        };
      }

    Из статьи на швабре: /post/132785/

    kingmonstr, 05 Января 2015

    Комментарии (4)
  4. Pascal / Говнокод #17402

    +107

    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
    var a : int64;
     
    begin
      assign(input, 'input.txt'); reset(input);
      assign(output, 'output.txt'); rewrite(output);
      read(a);
      if a=25 then write ('2.7182818284590452353602875');
      if a=24 then write ('2.718281828459045235360288');
      if a=23 then write ('2.71828182845904523536029');
      if a=22 then write ('2.7182818284590452353603');
      if a=21 then write ('2.718281828459045235360');
      if a=20 then write ('2.71828182845904523536');
      if a=19 then write ('2.7182818284590452354');
      if a=18 then write ('2.718281828459045235');
      if a=17 then write ('2.71828182845904524');
      if a=16 then write ('2.7182818284590452');
      if a=15 then write ('2.718281828459045');
      if a=14 then write ('2.71828182845905');
      if a=13 then write ('2.7182818284590');
      if a=12 then write ('2.718281828459');
      if a=11 then write ('2.71828182846');
      if a=10 then write ('2.7182818285');
      if a=9 then write ('2.718281828');
      if a=8 then write ('2.71828183');
      if a=7 then write ('2.7182818');
      if a=6 then write ('2.718282');
      if a=5 then write ('2.71828');
      if a=4 then write ('2.7183');
      if a=3 then write ('2.718');
      if a=2 then write ('2.72');
      if a=1 then write ('2.7');
      if a=0 then write ('3') 
    end.

    Вывод числа e с заданной точностью

    AndreyZ, 04 Января 2015

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

    +135

    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
    /// <summary>
    /// Converts to number.
    /// </summary>
    /// <param name="value">The value.</param>
    /// <returns>System.String.</returns>
    public static string convertToNumber(string value) {
        string mvalue = "0";
        string wildchars = @"~!@#$%^&*()_+={}[]|\/?><,`:;'";
        bool chknegative = false;
    	if (value == null)
    		value = "";
        try {
            if (value == "") {
                mvalue = "0";
            }
            for (var i = 0; i < wildchars.Length; i++) {
                string wildchar = wildchars.Substring(i, 1);
                //chknegative = value.Contains(wildchar);
                mvalue = value.Replace(wildchar, "");
                value = mvalue;
            }
    
    
            chknegative = value.Contains("-");
    
            if (chknegative) {
                mvalue = value.Replace("-", "");
                mvalue = "-" + mvalue;
            }
            else {
                mvalue = value;
            }
        }
        catch {
            mvalue = "0";
        }
        return mvalue;
    }

    barsv, 29 Декабря 2014

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

    −404

    1. 1
    UIImageView *footerWhite1PxLineThatOnlyAndersWillNotice = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sidebar_line_white"]];

    ох уж этот Андерс!

    besprincypniycentner, 23 Декабря 2014

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    express_static = express.static(static_files.file_path)
        app.use('/files', (req, res, next) ->
            if Math.random() > app.failureProbability
                express_static.handle(req, res, next)
            else
                # server failure or timeout
                if Math.random() < 0.5
                    console.log('\x1B[31mRandom failure\x1B[0m')
                    res.send(500, 'Fuck you')
                else
                    console.log('\x1B[31mRandom timeout\x1B[0m')
        )

    а вот так мы тестируем сетевую нагрузку (нода, кофе)

    makc3d, 21 Декабря 2014

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

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    var resultList = new List<CentralBankRateData>();
    using (var resultSet = m_Service.GetCursOnDate(request.Date))
    using (var reader = new DataTableReader(resultSet.Tables["ValuteCursOnDate"]))
    	while (reader.Read())
    		resultList.Add(new CentralBankRateData
    		{
    			Name = (string) reader["Vname"],
    			Nominal = (decimal) reader["Vnom"],
    			Rate = (decimal) reader["Vcurs"],
    			NumberCode = (int) reader["Vcode"],
    			StringCode = (string) reader["VchCode"]
    		});

    Какой Центробанк, такая и валюта. m_Service типа DailyInfoSoap, это сервис отдачи курсов валют. А еще у них получение актуального списка БИКов возможно только в древнейшем формате dBASE.

    yamamoto, 19 Декабря 2014

    Комментарии (4)
  9. JavaScript / Говнокод #17337

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // В чем смысл переменной knc?
    var knc = 0;
    var k_fr = parent.document.getElementById(kph);
    if (k_fr) {
        knc = 1;
    }

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

    MrFranke, 18 Декабря 2014

    Комментарии (4)
  10. Pascal / Говнокод #17324

    +88

    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
    procedure sr(var q, w: string; j, k: integer);
    begin
      for j := 1 to 100 do
      begin
        if ord(q[j]) - ord(w[j]) > 0 then begin for k := 1 to pos(' ', q) do write(q[k]);exit; end
        else if ord(q[j]) - ord(w[j]) < 0 then begin for k := 1 to pos(' ', w) do write(w[k]);exit; end;
      end;
      for k := 1 to pos(' ', w) do write(w[k]);
    end;
     
    procedure sr2(var q, w, e, r: string; j, k, p: integer);
    begin
      for j := 1 to 101 do
      begin
        if ord(q[j]) - ord(w[j]) > 0 then begin r := q;break; end
        else if ord(q[j]) - ord(w[j]) < 0 then begin r := w;break;end;
        inc(p);
      end;
      if p>100 then r:=w;
      for j := 1 to 100 do
      begin
        IF E[J]=' ' Then break;
        if ord(e[j]) - ord(r[j]) > 0 then begin for k := 1 to pos(' ', e) do write(e[k]);exit; end
        else if ord(e[j]) - ord(r[j]) < 0 then begin for k := 1 to pos(' ', r) do write(r[k]);exit; end;
      end;
      for k := 1 to pos(' ', r) do write(r[k]);
    end;
     
    var
      st, a, b, c, rd: string;
      i, s: integer;
     
    begin
      assign(input, 'input.txt'); reset(input);
      assign(output, 'output.txt'); rewrite(output);
      read(st);
      for i := 1 to 102
      do
      begin
        a := a + ' ';
        b := b + ' ';
        c := c + ' ';
      end;
      for i := 1 to length(st) do
        if st[i] = ' ' then inc(s)
        else
          case s of
            0: a[i] := st[i];
            1: b[i - pos(' ', a)] := st[i];
            2: c[i - pos(' ', a) - pos(' ', b)] := st[i];
          end;
      if (a=b) and (b=c) then for i := 1 to pos(' ', a) do write(a[i])
      else if (pos(' ', a) > pos(' ', b)) and (pos(' ', a) > pos(' ', c)) then for i := 1 to pos(' ', a) do write(a[i])
      else if (pos(' ', b) > pos(' ', a)) and (pos(' ', b) > pos(' ', c)) then for i := 1 to pos(' ', b) do write(b[i])
      else if (pos(' ', c) > pos(' ', b)) and (pos(' ', c) > pos(' ', a)) then for i := 1 to pos(' ', c) do write(c[i])
      else if (pos(' ', a) = pos(' ', b)) and (pos(' ', b) = pos(' ', c)) then sr2(a, b, c, rd, 0, 0, 0)
      else if pos(' ', a) = pos(' ', b) then sr(a, b, 0, 0)
      else if pos(' ', c) = pos(' ', b) then sr(c, b, 0, 0)
      else if pos(' ', a) = pos(' ', c) then sr(a, c, 0, 0);
    end.

    Выбор максимума из 3 целых длинных чисел

    AndreyZ, 17 Декабря 2014

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

    +57

    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
    if (this->IsWhiteFigure())
    		{
    			if (abs(position_x - this->GetPositionX()) == 1 && position_y - this->GetPositionY() == -1)
    			{
    				this->SetPositionX(position_x);
    				this->SetPositionY(position_y);
    			}
    			else
    			{
    				throw IncorrectMoveException();
    			}
    		}
    		else
    		{
    			if (abs(position_x - this->GetPositionX() == 1) && position_y - this->GetPositionY() == 1)
    			{
    				this->SetPositionX(position_x);
    				this->SetPositionY(position_y);
    			}
    			else
    			{
    				throw IncorrectMoveException();
    			}
    		}

    Тест на внимательность. Сможете ли вы догадаться почему это не работает ?

    GreatMASTERcpp, 13 Декабря 2014

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