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

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

    +149.2

    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
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    #include <avr/io.h>
    #include <avr/interrupt.h>
    #include <util/delay.h>
    
    #define myXPaddress 0b00000010
    //#define transmit_en PD0
    
    void avr_init(void);
    void clear_buff(unsigned char buff);
    
    volatile unsigned char bit9 = 0;
    volatile unsigned char rbyte = 0;
    volatile unsigned char pc_rbyte = 0;
    
    volatile unsigned char pc_command[17];
    volatile unsigned char xp_response[15];
    
    volatile unsigned char pc_rec_pos = 0;
    volatile unsigned char xp_rec_pos = 0;
    
    volatile unsigned char pc_rec_en = 0;
    volatile unsigned char xp_rec_en = 0;
    
    volatile unsigned char pc_buff_ready = 0;
    volatile unsigned char xp_buff_ready = 0;
    
    volatile unsigned char my_window = 0;
    volatile unsigned char ack = 0;
    
    volatile unsigned char xp_xor = 0;
    
    volatile unsigned char COMM = 0;
    
    unsigned char i;
    
    void rs485_ransmit( unsigned char data )
    {
    	while ( !( UCSR0A & (1<<UDRE0)) );
    	UCSR0B &= ~(1<<TXB80); // SET 9 BIT IN 0
    	UDR0 = data;
    }
    
    unsigned char rs485_reciv(void)
    {
    	char status,data;
    	
    	status=UCSR0A;
    	bit9 = UCSR0B;
    	data=UDR0;
    	if ( status & ( (1<<FE)|(1<<DOR)|(1<<UPE) ) )
    		return 0;
    	
    	return data;
    }
    
    unsigned char rs232_reciv( void )
    {
    	while ( !(UCSR1A & (1<<RXC1)) );
    	return UDR1;
    }
    void rs232_transmit( unsigned char data )
    {
    	while ( !( UCSR1A & (1<<UDRE1)) );
    	UDR1 = data;
    }
    
    
    ISR(USART1_RX_vect)
    {
    	pc_rbyte = rs232_reciv();
    	
    	if( pc_buff_ready == 1 && pc_rbyte == 0xFA )
    	{
    		pc_rec_en = 0;
    		rs232_transmit('B');
    		rs232_transmit('U');
    		rs232_transmit('F');
    		rs232_transmit('F');
    		rs232_transmit(' ');
    		rs232_transmit('O');
    		rs232_transmit('V');
    		rs232_transmit('F');
    		return;
    	}
    		
    	if( pc_rec_en == 1 )
    		if( pc_rbyte == 0xFF)
    		{
    			pc_rec_en = 0;
    			pc_buff_ready = 1;
    			return;
    		}
    		else
    		{
    			pc_command[pc_rec_pos] = pc_rbyte;
    			pc_rec_pos++;
    			return;
    		}

    JovialLiX, 19 Апреля 2010

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

    +69

    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
    if (isRenderVerifyClaimTab()) {
    			addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.VerifyClaimController");
    		}
    		if (isRenderVerifyAvtoTab()) {
    			addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.VerifyAvtoController");
    		}
    		if (isRenderUntipicalClaimTab()) {
    			addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.UntipicalClaimController");
    		}
    		if (isRenderTypeClaimTab()) {
    			addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.TypeClaimController");
    
    		}

    Профтыкал что можно было делать так:

    if (isRenderCheckClaimTab()) {
    addContrToInit(CheckClaimController.clas s.getName());
    }

    :)

    Lockdog, 01 Апреля 2010

    Комментарии (1)
  4. Java / Говнокод #2890

    +70.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (tp != null) {
    		DocElement d = (DocElement)tp.getLastPathComponent();
    		if (d.getElementType() == Constants.TYPE_FOLDER) {
    			context.setCursor(DragSource.DefaultMoveDrop);
    		if (d.getElementType()==Constants.TYPE_FOLDER) {
    			tree.setSelectionPath(tp);
    			tree.expandPath(tp);
    		}
    		}else {
    			context.setCursor(DragSource.DefaultMoveNoDrop);
    		}
    	}

    моё, так сказать носом ткнули)
    условие if (d.getElementType()==Constants.TYPE_FOLD ER)

    maxt, 29 Марта 2010

    Комментарии (1)
  5. JavaScript / Говнокод #2878

    +164.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function setStyle (id, style, val) {
    if (document.getElementById(id).getAttribute('style').indexOf(style) != -1) {
    document.getElementById(id).setAttribute('style', document.getElementById(id).getAttribute('style').replace(style, val))} else {
    document.getElementById(id).setAttribute('style', document.getElementById(id).getAttribute('style') + style + ':' + val + ';')
    }
    }

    Функция для установки CSS-свойств от китайских умельцев.

    eval, 27 Марта 2010

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

    +144.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    1. #include <stdio.h>
       2.  
       3. void main()
       4. {
       5.  int i = 5;
       6.  i = ++i + ++i;
       7.  printf("%d\n",i);
       8. }

    http://habrahabr.ru/blogs/crazydev/88185/

    stepushyn, 19 Марта 2010

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

    +151.9

    1. 1
    2. 2
    3. 3
    4. 4
    procedure tform1.wmhelp(var msg:tmsg);
    begin
    MessageBox(form1.Handle,'Думай сам!!!','Помощь',MB_HELP or MB_TOPMOST or MB_ICONEXCLAMATION		);
    end;

    Открывается меседжбокс с кнопкой помощь. При нажатии на неё открывается меседжбокс с кнопкой помощь. При нажатии на неё...

    Говногость, 13 Марта 2010

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

    +152.9

    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
    program CDPower;
    uses  windows,mmsystem;
    {$R *.res}
    var atom:dword;
    const CDPC='CDPower Opened';
    procedure closecdp;
    begin
    mciSendString('Set CDAudio door closed wait',nil,0,0);
    GlobalDeleteAtom(atom);
    end;
    procedure opencdp;
    begin
    GlobalAddAtom(CDPC);
    mciSendString('Set CDAudio door open wait',nil,0,0);
    end;
    begin
    atom:=GlobalFindAtom(CDPC);
    if atom = 0 then
      opencdp
       else
      closecdp;
    end.

    Программа при запуске со значка с рабочего стола открывает лоток СD/DVD привода и закрывает.
    Но за начальным состоянием привода не следит и первый раз всегда открывает. :D

    А у меня дома два DVD. Ыыы.))

    Говногость, 13 Марта 2010

    Комментарии (1)
  9. Pascal / Говнокод #2782

    +152.9

    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
    procedure tplayext.play(iname:string);
    begin
    cd:=false;
    try
    form1.MediaPlayer1.Close;
    form1.MediaPlayer1.filename:=iname;
    form1.label10.Caption:=iname;
    form1.MediaPlayer1.Open;
    form1.MediaPlayer1.play;
    except
    next;
    cd:=true;
    end;
    end;
    procedure tplayext.init(iext:string);
    begin
    name:='';
    paused:=false;
    allplayed:=false;
    ext:=iext;
    TRY
    io:=findfirst(ext,faanyfile,f);
    EXCEPT
    END;
    if io<>0 then
    begin
     done;
     exit;
    end;
    name:=f.Name;
    play(name);
    end;
    procedure tplayext.playplease;
    begin
    if stoped then next;
    end;
    procedure tplayext.next;
    begin
    TRY
    io:=findnext(f);
    EXCEPT
    END;
    if io <>0 then
    begin
     done;
     exit;
    end;
    name:=f.Name;
    play(name);
    end;
    procedure tplayext.done;
    begin
    TRY
    form1.MediaPlayer1.close;
    findclose(f);
    EXCEPT
    END;
    allplayed:=true;
    end;

    Особенно прикалывает вызов метода play в методе next и вызов метода next в методе play.
    Рекурсия!!!!!1111

    Говногость, 13 Марта 2010

    Комментарии (1)
  10. Java / Говнокод #2757

    +71

    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
    String ID = httpServletRequest.getParameter("id");
            ChannelData data = new ChannelData();
    
            int pointPos = ID.indexOf(';');
    
            while(pointPos >= 0) {
                String CurrentID = ID.substring(0, pointPos);
                data.setId(new Integer(CurrentID));
    
               ChannelData channel = (ChannelData) channelDao.Get(Integer.valueOf(CurrentID));
    
                channelService.delete(data);
                ID = ID.substring(pointPos + 1, ID.length());
                pointPos = ID.indexOf(';');
            }
            if(ID.length() > 0) {
                ChannelData channel = (ChannelData) channelDao.Get(Integer.valueOf(ID));
                data.setId(new Integer(ID));
                channelService.delete(data);
            }

    prop, 11 Марта 2010

    Комментарии (1)
  11. Java / Говнокод #2713

    +73.8

    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
    List<SomeObj> list = getTodayObjects();
    .....
    int i = list.size() - 1;
    for (; i >= 0; i--) {
        SomeObj oldState = list.get(i);
        if (currentObj.getTimestamp() - oldState.getTimestamp() >= 5 * MINUTE) {
            value5MinAgo = oldState.getValue();
            break;
        }
    }
    for (; i >= 0; i--) {
        SomeObj oldState = list.get(i);
        if (currentObj.getTimestamp() - oldState.getTimestamp() >= 15 * MINUTE) {
            value15MinAgo = oldState.getValue();
            break;
        }
    }
    for (; i >= 0; i--) {
        SomeObj oldState = list.get(i);
        if (currentObj.getTimestamp() - oldState.getTimestamp() >= 30 * MINUTE) {
            value30MinAgo = oldState.getValue();
            break;
        }
    }
    for (; i >= 0; i--) {
        SomeObj oldState = list.get(i);
        if (currentObj.getTimestamp() - oldState.getTimestamp() >= 60 * MINUTE) {
            value60MinAgo = oldState.getValue();
            break;
        }
    }
    .....

    фанданго, не иначе

    Anonimous, 04 Марта 2010

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