1. Список говнокодов пользователя JovialLiX

    Всего: 6

  2. JavaScript / Говнокод #18233

    +141

    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
    api.outboxStatus = function(params){
        angular.forEach($rootScope.outbox, function(outbox, i){
          if( outbox._id == params.outbox._id )
            $rootScope.$apply(function(){
              $rootScope.outbox[i] = params.outbox;
            });
        });
      }
    
    // ----------- 
    шаблон 
    
    <tr ng-repeat="item in fOutbox = (outbox | filter:filterOutbox())">

    JovialLiX, 25 Мая 2015

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

    +156

    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
    function EngineListCtrl($scope, $timeout, $http)
    {
    	$scope.engines = {};
    	$scope.workers = [];
    	
    	$scope.checkEngines = function(){
    		$http.get(engineUrl + '&type=json&jcmd=getClients').success(function(req){
    			var engines = {};
    			var workers = {};
    			$scope.workers = []; // Это в отрисовке не используется.
    			
    // Сначала распихиваю всех по местам
    			angular.forEach(req, function(ob, i){
    				if( ob.info.type == 'engine' )
    					engines[ob.info.engine] = ob;
    				
    				if( ob.info.type == 'worker' ){
    					if( workers[ob.info.engine] == undefined )
    						workers[ob.info.engine] = {};
    					workers[ob.info.engine][ob.info.worker] = ob;
    					if( ob.task && ob.task.state )
    						ob.info.state = ob.task.state;
    					$scope.workers.push(ob);
    				}
    			});
    			
    // Перебераю уже имеющиеся объекты
    			angular.forEach($scope.engines, function(engineOb, engineName){
    				var needRemove = true;
    				angular.forEach(engines, function(val, key){
    					if( engineName == key ){
    						angular.extend($scope.engines[engineName], val);
    						needRemove = false;
    					}
    				});
    				
    				if( needRemove == false && $scope.engines[engineName] ){
    					$scope.checkEngineEvents($scope.engines[engineName]);
    					if( workers[engineName] != undefined ){
    						if( $scope.engines[engineName].workers == undefined )
    							$scope.engines[engineName].workers = {};
    						angular.extend($scope.engines[engineName].workers, workers[engineName]);
    					}else
    						$scope.engines[engineName].workers = {};
    				}
    				
    				if( needRemove == true ){
    					delete $scope.engines[engineName];
    				}
    			});
    			
    // А теперь новые добавляю
    			angular.forEach(engines, function(engineOb, engineName){
    				if( $scope.engines[engineName] == undefined ){
    					$scope.engines[engineName] = engineOb;
    					if( workers[engineName] != undefined ){
    						if( $scope.engines[engineName].workers == undefined )
    							$scope.engines[engineName].workers = {};
    						angular.extend($scope.engines[engineName].workers, workers[engineName]);
    					}
    					$scope.checkEngineEvents($scope.engines[engineName]);
    				}
    			});
    			$timeout($scope.checkEngines, 2000);
    		});
    		
    	}
    	$timeout($scope.checkEngines, 1000);

    JovialLiX, 16 Июня 2014

    Комментарии (14)
  4. Си / Говнокод #3057

    +154.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
    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
    #include <avr/interrupt.h>
    #include <avr/io.h>
    #include <stdio.h>
    
    static void avr_init(void);
    void uart_putchar(char value);
    unsigned char read_adc(unsigned char adc_input);
    
    unsigned char adc_enable;
    
    ISR(SIG_UART_RECV)
    {
    	unsigned char tmp;
    	tmp=UDR;
    	if (tmp=='1') adc_enable=1;
    	else adc_enable=0;
    }
    
    int main(void)
    {
    	avr_init();
      sei();
    	uart_putchar('A');
      for(;;)
      {
        if(adc_enable)
        {
          uart_putchar(read_adc(0x00));
          adc_enable = 0;
        }
      }
      return(0);
    }
    
    static void avr_init(void)
    {
      PORTB=0b00000000;
      DDRB=0b00001111;
    
      PORTD=0b00111100;
      DDRD=0b11000011;
    
      // Baud Rate: 57600
      // Character Size: 8-bit
      // Mode: Asynchronous
      // Parity: Disabled
      // Stop Bit: 1-bit
      // Multi-processor Communication
      UBRRL = 0x0c;
      UBRRH = 0x00;
      UCSRA = 0x01;
      UCSRC = 0x86;
      UCSRB = 0xd8;
    
      ADMUX=0x60;
      ADCSRA=0xA6;
      SFIOR&=0x0F;
      SFIOR|=0x10;
    
      return;
    }
    
    void uart_putchar(char value)
    {
      loop_until_bit_is_set(UCSRA, UDRE);
      UDR = value;
      return;
    }
    
    unsigned char read_adc(unsigned char adc_input)
    {
      ADMUX=adc_input|0x60;
      // Start the AD conversion
      ADCSRA|=0x40;
      // Wait for the AD conversion to complete
      while ((ADCSRA & 0x10)==0);
      ADCSRA|=0x10;
      return ADCH;
    }

    JovialLiX, 19 Апреля 2010

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

    +150.4

    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
    sei();
    			}
    		
    		if( xp_buff_ready > 0 && pc_rec_en == 0 )
    		{
    			for( i=0; xp_buff_ready!=i; i++ )
    				rs232_transmit(xp_response[i]);
    				
    			clear_buff(1);
    			xp_buff_ready = 0;
    			xp_rec_en = 0;
    			my_window = 0;
    		}
    		if( ack == 1 )
    		{
    			rs232_transmit('A');
    			rs232_transmit('C');
    			rs232_transmit('K');
    			rs232_transmit(' ');
    			rs232_transmit('E');
    			rs232_transmit('r');
    			rs232_transmit('r');
    			rs232_transmit('o');
    			rs232_transmit('r');
    			ack = 0;
    			my_window = 0;
    			xp_rec_en = 0;
    		}
    	};
    	return 0;
    }
    
    void clear_buff(unsigned char buff)
    {
    	if( buff == 0 )
    		for( i=0; i<18; i++ )
    			pc_command[i] = 0;
    	if( buff == 1 )
    		for( i=0; i<16; i++ )
    			xp_response[i] = 0;
    	return;
    }
    
    void avr_init(void)
    {
    	// 62500 9bit 1 stop no parity
    	UCSR0A=0x00;
    	UCSR0B=0x9C;
    	UCSR0C=0x86;
    	UBRR0H=0x00;
    	UBRR0L=0x0F;
    
    	// 56000 8bit 1 stop no parity
    	UCSR1A=0x00;
    	UCSR1B=0x98;
    	UCSR1C=0x06;
    	UBRR1H=0x00;
    	UBRR1L=0x11;
    	
    	DDRC = 0b00000011;
    	PORTC= 0b00000000;
    	
    	DDRD = 0b00000001;
    	PORTD= 0b00000000;
    	
    	DDRG  = 0b00011011;  //определить все ножки порта G (PG3 - DE status, PG4 - DE counter) 
        PORTG = 0b11100100;  //включить подтяжку резисторов 
    	
    	DDRD  = 0b11111000;  //PD0, PD1 - SCL-SDA, PD2 -RxD1, PD3 - TxD1 PD4 - STAT/COUN, PD5 - RE STAT, PD6 - RE Coun, PD7 - testLD
    	PORTD = 0b01101111;  //подключить внутренние резисторы на входах, a  выходы установить  в "0"
    	
    	PORTG &=~_BV(PG4);	 //disable DE RS485
    	PORTD &=~_BV(PD5);  //enable RE RS485
    	
    	return;
    }

    JovialLiX, 19 Апреля 2010

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

    +151.4

    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
    if( pc_rbyte == 0xFA && pc_buff_ready == 0 && pc_rec_pos == 0)
    	{
    		pc_rec_en = 1;
    		return;
    	}	
    	return;
    }
    
    ISR(USART0_RX_vect)
    {
    	cli();
    	rbyte = rs485_reciv();
    	
    	if( COMM == 1 && rbyte != 0x42 )
    		xp_rec_en = 1;
    	
    	if(COMM == 1 && rbyte == 0x42)
    	{
    		//xp_rec_pos++;
    		xp_response[xp_rec_pos] = xp_xor;
    		COMM = 0;
    		xp_rec_en = 0;
    		xp_buff_ready = xp_rec_pos;
    		xp_rec_pos = 0;
    		xp_rec_en = 0;
    		xp_xor = 0;
    	}
    	
    	
    	if( xp_rec_en == 1 ) 
    	{
    		if( rbyte != xp_xor && xp_rec_pos<16 )
    		{
    			xp_response[xp_rec_pos] = rbyte;
    			xp_xor = xp_xor^rbyte;
    			xp_rec_pos++;
    		}else{
    			xp_buff_ready = xp_rec_pos;
    			xp_rec_pos = 0;
    			xp_rec_en = 0;
    			xp_xor = 0;
    		}
    	}		
    	
    	if( rbyte == 0x60 )
    	{
    		xp_rec_en = 1;
    		xp_response[0] = rbyte;
    		xp_rec_pos++;
    	}
    	
    	if( rbyte == 0x41 && my_window!=1)
    		COMM = 1;		
    	
    	if( (bit9&0b00000010) == 0b00000010 && (rbyte&0b00011111) == myXPaddress ) 
    	
    		switch( (rbyte&0b01100000) )
    		{
    			case 0b01000000: ack = 0; if( pc_buff_ready == 1 ) my_window = 1; xp_rec_en = 0;break; // NormalInquary
    			case 0b01100000: ack = 0; my_window = 0; xp_rec_en = 1;break; // CallByte
    			case 0b00000000: ack = 1; my_window = 0; xp_rec_en = 0;break; // ACK!
    		}
    	
    	rbyte = 0;
    	sei();
    	
    	return;
    }
    
    int main(void)
    {
    	avr_init();
    	sei();
    
    	//PORTD &=~(1<<transmit_en);
    	//pc_buff_ready = 1;
    	while (1)
    	{
    		//if( pc_buff_ready == 1 ) //pc_buff_ready == 1 && 
    		//{
    			if( my_window == 1 )
    			{
    				cli();
    				_delay_us(30);
    				//PORTD |= (1<<transmit_en);
    				PORTG |=_BV(PG4);	 //disable DE RS485
    				PORTD |=_BV(PD5);  //enable RE RS485
    				//_delay_us(5);
    				for( i=0; pc_rec_pos != i; i++ )
    					rs485_ransmit(pc_command[i]);
    					
    				while ( !( UCSR0A & (1<<UDRE0)) );
    				_delay_us(160);
    				PORTG &=~_BV(PG4);	 //disable DE RS485
    				PORTD &=~_BV(PD5);  //enable RE RS485
    				
    				my_window = 0;
    				clear_buff(0);
    				pc_buff_ready = 0;
    				pc_rec_pos = 0;

    JovialLiX, 19 Апреля 2010

    Комментарии (2)
  7. Си / Говнокод #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)