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

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

    +124

    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
    // System.Web.Security.FormsAuthentication
    /// <summary>Returns the redirect URL for the original request that caused the redirect to the login page.</summary>
    /// <returns>A string that contains the redirect URL.</returns>
    /// <param name="userName">The name of the authenticated user. </param>
    /// <param name="createPersistentCookie">This parameter is ignored.</param>
    public static string GetRedirectUrl(string userName, bool createPersistentCookie)
    {
    	if (userName == null)
    	{
    		return null;
    	}
    	return FormsAuthentication.GetReturnUrl(true);
    }

    http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication. getredirecturl.aspx
    Разработчики ASP.NET'а опять доставляют... И не лень было столько параметров делать, а потом ещё и описывать...

    TauSigma, 04 Июля 2013

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

    +124

    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
    var
      Form1: TForm1;
      tlst:tthreadlist;
    
    implementation
    
    {$R *.dfm}
    
    function getCount : integer;
    begin
        Result := tlst.LockList.Count;
        tlst.UnlockList;
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    tlst:=tthreadlist.Create;
    end;
    
    { tmythread }
    
    constructor tmythread.create(filename: string);
    begin
    self.FreeOnTerminate:=true;
    self.filename:=filename;
    inherited create(true);
    self.Priority:=tphigher;
    self.Resume;
    tlst.LockList.Add(self);
    tlst.UnlockList;
    end;
    
    destructor tmythread.destroy;
    begin
    tlst.Remove(self);
    tlst.UnlockList;
    end;
    
    procedure tmythread.execute;
    begin
    while not terminated do
    sleep(100);    // в качестве примера, чем-то нагружаем цикл.
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      i:integer;
      n:string;
      temp:tmythread;
      s:string;
    begin
      for i:=0 to getcount-1 do
      begin
        temp:=tlst.LockList.Items[i];   // вот это место. Как Вам кажется, это правильно, или не?
        if assigned(temp) then
        n:=temp.filename;
        if n='ololo' then   // это просто пример, не смеемся) АХАХАХАХ )
        begin
          showmessage('Сканирование этого файла уже выполняется') ;
          exit;
        end;
      end;
      tmythread.create('ololo');
    end;
    
    end.

    Стоит задача сканировать файлы в разных потоках. Как Вам кажется, это адекватное решение?

    Stertor, 02 Июля 2013

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

    +147

    1. 1
    А не использовать ли нам пиписюнчик?

    Stertor, 29 Июня 2013

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

    +125

    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
    sh-4.1$ make
    make[1]: Entering directory `/cygdrive/c/CrossCompiler/binutils-2.8/libiberty'
    echo "# !Automatically generated from ./functions.def"\
              "- DO NOT EDIT!" >needed2.awk
    grep '^DEFVAR(' < ./functions.def \
             | sed -e '/DEFVAR/s|DEFVAR.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
             >>needed2.awk
    grep '^DEFFUNC(' < ./functions.def \
             | sed -e '/DEFFUNC/s|DEFFUNC.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
             >>needed2.awk
    gcc -O2 -c -O2 -I. -I./../include -DNEED_sys_siglist -DNEED_basename -DNEED_strsignal ./dummy.c 2>/dev/null
    make[1]: *** [dummy.o] Ошибка 1
    make[1]: Leaving directory `/cygdrive/c/CrossCompiler/binutils-2.8/libiberty'
    make: *** [all-libiberty] Ошибка 2

    Угадайте чего оно хочет. Я не знаю (awk есть, если что).

    Sh1tM4ker, 12 Июня 2013

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    changeFace($arr) {
            switch ($arr['custtype']) {
                    case 2: $facetype = 'Ф'; break; //Физическое
                    case 1: $facetype = 'Ю'; break; //Юридическое лицо
                    default: $facetype = ' '; break;
            }
            return $facetype;
    }

    В этом смысле лицо - "person"

    DIX315, 06 Июня 2013

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

    +121

    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
    public int sum(final Type type, final int increment) {
    	switch(type) {
    	case REDOS: 
    		return redos += increment;
    	case ONCE: 
    		return onceRedoneOrders += increment;
    	case TWICE: 
    		return twiceRedoneOrders += increment;
    	case THRICE: 
    		return thriceRedoneOrders += increment;
    	case MORE: 
    		return moreRedoneOrders += increment;
    	default:
    		break;
    	}
    	
    	throw new RuntimeException();
    }

    Осталось в наследство. Даже не знаю, что хотел изобразить предыдущий оратор...

    someone, 06 Июня 2013

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

    +162

    1. 1
    2. 2
    $('html body table tbody tr td:nth-child(2) table tbody tr td table:nth-child(1) tbody tr:nth-child(2) td table tbody tr td:nth-child(2)')
    from stackoverflow

    computer1, 04 Июня 2013

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

    +162

    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
    function closeLayerInSite(layerName) {
        if (layerName != "count_result") $("#count_result").fadeOut(200);
        if (layerName != "subscribe_layer") $("#subscribe_layer").fadeOut(200);
        if (layerName != "online_contact") $("#online_contact").fadeOut(200);
        if (layerName != "faq_layer") $("#faq_layer").fadeOut(200);
        if (layerName != "layerCity") $("#layerCity").fadeOut(200);
        if (layerName != "ur_service_layer") $("#ur_service_layer").fadeOut(200);
        if (layerName != "fiz_service_layer") $("#fiz_service_layer").fadeOut(200);
        if (layerName != "requestRateMain_layer") $("#requestRateMain_layer").fadeOut(200);
        if (layerName != "exchange_calc") $("#exchange_calc").fadeOut(200);
        if (layerName != "universalForm") $("#universalForm").fadeOut(200);
        if (layerName != "layerCityes") $("#layerCityes").fadeOut(200);
        if (layerName != "vacancy") $("#vacancy").fadeOut(200);
        if (layerName != "cardsAnnotation") $("#cardsAnnotation").fadeOut(200);
        $("#content").css("padding", "0 0 280px");
    }

    Реальный JS-код от самого коммерческий эффективного ТИМЛИДА!

    validol, 29 Мая 2013

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

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Amount_List=[[NSArray alloc] initWithObjects:@"500",@"1000",@"2000",@"5000",@"10000",@"25000",@"50000",@"100000",@"250000",@"350000",@"500000",@"1000000",nil];
    	
    
    	//ShowWonAmout
    	NSString *str1=[NSString stringWithFormat:@"%@",[currencyStyle stringFromNumber:[NSNumber numberWithInt:[[Amount_List objectAtIndex:0] intValue]]]];
    	ShowAmount1.text=[str1 substringToIndex:[str1 length]-3];
            ...	
    	NSString *str12=[NSString stringWithFormat:@"%@",[currencyStyle stringFromNumber:[NSNumber numberWithInt:[[Amount_List objectAtIndex:11] intValue]]]];
    	ShowAmount12.text=[str12 substringToIndex:[str12 length]-3];

    Коллега принес покушать плоды трудов ребят из солнечной Индии

    clockworkman, 29 Мая 2013

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

    +149

    1. 1
    $this->t = (date('w')+1)>6?0:(date('w')+1);

    фак мой мозг

    CRRaD, 13 Мая 2013

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