1. C++ / Говнокод #3060

    +61

    1. 1
    2. 2
    3. 3
    FILE *h=fopen(fileDMB, "r");
    char *fileDMBtext;
    while(fileDMBtext=fgetc(h)!=EOF){return 0;}

    Я даже знаю компилятор в котором это работает.

    hromjo, 20 Апреля 2010

    Комментарии (30)
  2. Java / Говнокод #3059

    +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
    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
    public class XXX implements YYY
    {
        public static final String UTILITYBATCHES = "utilityBatches";
        public static final String UTILITYCALCULATIONS = "utilityCalculations";
        public static final String WARDREGISTRATION = "wardRegistration";
        public static final String WARDINSPECTIONS = "wardInspections";
        public static final String WARDPRIMARYREGISTRATION = "wardPrimaryRegistration";
        public static final String SOCIALEVENTS2DOCUMENTS = "socialEvents2documents";
        public static final String SOCIALEVENTS = "socialEvents";
        public static final String SOCIALPACKAGES = "socialPackages";
        public static final String SOCIALAIDS = "socialAids";
        public static final String PRIVCATEGORIES = "privCategories";
        public static final String PAYMENTS = "payments";
        public static final String PAYMENTDETAILS = "paymentDetails";
        public static final String PAYMENTBATCHES = "paymentBatches";
        public static final String FAMILYRELATIONS = "familyRelations";
        public static final String FOSTERFAMILIES = "fosterFamilies";
        public static final String FAMILYMEMBERS = "familyMembers";
        public static final String INVALIDNESS = "invalidness";
        public static final String HEALTHINSPECTIONS = "healthInspections";
        public static final String EMPLOYMENTS = "employments";
        public static final String EDUCATION = "education";
        public static final String DOCUMENTS = "documents";
        public static final String FAMILIES = "families";
        public static final String DECORATIONS = "decorations";
        public static final String CALCULATIONS = "calculations";
        public static final String ATTRIBUTEVALUEHISTORY = "attributeValueHistory";
        public static final String ATTRIBUTEVALUES = "attributeValues";
        public static final String ASSIGNMENTS = "assignments";
        public static final String ADDRESSES = "addresses";
        public static final String ATTACHMENTS = "attachments";
        public static final String PERSONS = "persons";
        public static final String OCCUPANCIES = "occupancies";
        public static final String PROPERTIES = "properties";
        public static final String BUILDINGS = "buildings";
        public static final String WELFAREDELIVERY = "welfareDelivery";
    }

    clipper, 20 Апреля 2010

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

    +64.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
    public static Boolean parseBoolean(Object x)
         {
              if(x instanceof Integer)
                   return (Integer) x != 0;
    
              if(x == null)
                   return false;
    
              if(x instanceof Boolean)
                   return (Boolean) x;
    
              if(x instanceof Double)
                   return Math.abs((Double) x) < 0.00001;
    
              return !("" + x).equals("");
         }

    Веселый кусочег из эмулятора сервера Lineage II (Сборка от L2f).

    VirtualVoid, 20 Апреля 2010

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

    +144.8

    1. 1
    2. 2
    3. 3
    <?
    echo $i++ + ++$i;
    ?>

    rvn, 19 Апреля 2010

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

    +57.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
    t1->addAnimation(new QPropertyAnimation(widget, "geometry"));
        t1->addAnimation(new QPropertyAnimation(p1, "pos"));
        t1->addAnimation(new QPropertyAnimation(p2, "pos"));
        t1->addAnimation(new QPropertyAnimation(p3, "pos"));
        t1->addAnimation(new QPropertyAnimation(p4, "pos"));
        t1->addAnimation(new QPropertyAnimation(p5, "pos"));
        t1->addAnimation(new QPropertyAnimation(p6, "pos"));
        t1->addAnimation(new QPropertyAnimation(p1, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p2, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p3, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p4, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p5, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p6, "rotation"));
        t1->addAnimation(new QPropertyAnimation(p1, "opacity"));
        t1->addAnimation(new QPropertyAnimation(p2, "opacity"));
        t1->addAnimation(new QPropertyAnimation(p3, "opacity"));
        t1->addAnimation(new QPropertyAnimation(p4, "opacity"));
        t1->addAnimation(new QPropertyAnimation(p5, "opacity"));
        t1->addAnimation(new QPropertyAnimation(p6, "opacity"));
    
        QAbstractTransition *t2 = state2->addTransition(button, SIGNAL(clicked()), state3);
        t2->addAnimation(new QPropertyAnimation(box, "geometry"));
        t2->addAnimation(new QPropertyAnimation(widget, "geometry"));
        t2->addAnimation(new QPropertyAnimation(p1, "pos"));
        t2->addAnimation(new QPropertyAnimation(p2, "pos"));
        t2->addAnimation(new QPropertyAnimation(p3, "pos"));
        t2->addAnimation(new QPropertyAnimation(p4, "pos"));
        t2->addAnimation(new QPropertyAnimation(p5, "pos"));
        t2->addAnimation(new QPropertyAnimation(p6, "pos"));
        t2->addAnimation(new QPropertyAnimation(p1, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p2, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p3, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p4, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p5, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p6, "rotation"));
        t2->addAnimation(new QPropertyAnimation(p1, "opacity"));
        t2->addAnimation(new QPropertyAnimation(p2, "opacity"));
        t2->addAnimation(new QPropertyAnimation(p3, "opacity"));
        t2->addAnimation(new QPropertyAnimation(p4, "opacity"));
        t2->addAnimation(new QPropertyAnimation(p5, "opacity"));
        t2->addAnimation(new QPropertyAnimation(p6, "opacity"));
    
        QAbstractTransition *t3 = state3->addTransition(button, SIGNAL(clicked()), state1);
        t3->addAnimation(new QPropertyAnimation(box, "geometry"));
        t3->addAnimation(new QPropertyAnimation(widget, "geometry"));
        t3->addAnimation(new QPropertyAnimation(p1, "pos"));
        t3->addAnimation(new QPropertyAnimation(p2, "pos"));
        t3->addAnimation(new QPropertyAnimation(p3, "pos"));
        t3->addAnimation(new QPropertyAnimation(p4, "pos"));
        t3->addAnimation(new QPropertyAnimation(p5, "pos"));
        t3->addAnimation(new QPropertyAnimation(p6, "pos"));
        t3->addAnimation(new QPropertyAnimation(p1, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p2, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p3, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p4, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p5, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p6, "rotation"));
        t3->addAnimation(new QPropertyAnimation(p1, "opacity"));
        t3->addAnimation(new QPropertyAnimation(p2, "opacity"));
        t3->addAnimation(new QPropertyAnimation(p3, "opacity"));
        t3->addAnimation(new QPropertyAnimation(p4, "opacity"));
        t3->addAnimation(new QPropertyAnimation(p5, "opacity"));
        t3->addAnimation(new QPropertyAnimation(p6, "opacity"));

    http://qt.gitorious.org/qt/qt/blobs/4.7/examples/animation/states/main.cpp

    Пример использования Qt animation framework: образцовый быдлокод.

    Lockal, 19 Апреля 2010

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

    +187.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
    HTTP/1.1 404 Not found
    Server: Netscape-Enterprise/4.1
    Date: Mon, 19 Apr 2010 13:05:32 GMT
    Content-type: text/html
    Connection: close
    
    <script language="JavaScript">
                                  port=0
                      while ( port==0 || port==9 || port==7 ){
                                      port=Math.floor(Math.random()*1000)
                 while (port>=100) port-=100
                                              while (port>=10) port-=10
                                                                         }
    location="http://"+"10.1.100.120:8"+port+document.location.pathname+document.location.search+document.location.hash
    </script>

    вот такой суровый редирект. может вам будет смешно но я из-за неизвестного мудака убил полтора часа.
    думаю он хотел рандомом генить порт от 1 до 1000
    а потом смотреть входит оно в диапазон 81-86,88
    оно подтупливало и он придумал "оптимизацию" ))

    дети, никогда так не вычисляйте остатки
    а если сильно хочется рандомов и всего то уж лучше так

    <script language="JavaScript">
    port=Math.floor(Math.random()*8)+1;
    if (port==7) port++;

    location="http://"+"10.1.100.120:8"+port+document.locatio n.pathname+document.location.search+docu ment.location.hash
    </script>

    3.14159265, 19 Апреля 2010

    Комментарии (13)
  8. Java / Говнокод #3052

    +83

    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
    public Map<ComponentType,
    				Map<GameType,
    					Map<SubGameType,
    						Map<String /*currency*/, 
    							Map<Stake /*stake*/, 
    								Map<Integer /*maxplayers*/, IPair<Long /*minChips*/, List<Long /*tableCode*/>>>
    							>
    						>
    					>
    				>
    			>
    			generate(int casinoCode) {
    
    		Map<ComponentType,
    			Map<GameType,
    				Map<SubGameType,
    					Map<String /*currency*/, 
    						Map<Stake /*stake*/, 
    							Map<Integer /*maxplayers*/, IPair<Long /*minChips*/, List<Long /*tableCode*/>>>
    						>
    					>
    				>
    			>
    		> result = new HashMap<ComponentType, Map<GameType,Map<SubGameType,Map<String,Map<Stake,Map<Integer,IPair<Long /*minChips*/, List<Long /*tableCode*/>>>>>>>>();
    
    		Map<GameType,
    		Map<SubGameType,
    			Map<String /*currency*/, 
    				Map<Stake /*stake*/, 
    					Map<Integer /*maxplayers*/, IPair<Long /*minChips*/, List<Long /*tableCode*/>>>
    				>>>> componentTypeMap = new HashMap<GameType, Map<SubGameType,Map<String,Map<Stake,Map<Integer,IPair<Long /*minChips*/, List<Long /*tableCode*/>>>>>>>();
    
    ....
    
    			Map<SubGameType,
    			Map<String /*currency*/, 
    				Map<Stake /*stake*/, 
    					Map<Integer /*maxplayers*/, IPair<Long /*minChips*/, List<Long /*tableCode*/>>>>>> gameTypeMap = new HashMap<SubGameType, Map<String,Map<Stake,Map<Integer,IPair<Long /*minChips*/, List<Long /*tableCode*/>>>>>>();

    Made in Estonia

    bot225, 19 Апреля 2010

    Комментарии (11)
  9. ActionScript / Говнокод #3051

    −180.6

    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
    package org.casalib.util {
        
        /**
            Utilities for constructing and working with Classes.
            
            @author Aaron Clinger
            @version 02/13/10
        */
        public class ClassUtil {
            
            /**
                Dynamically constructs a Class.
                
                @param type: The Class to create.
                @param arguments: Up to ten arguments to the constructor.
                @return Returns the dynamically created instance of the Class specified by <code>type</code> parameter.
                @throws Error if you pass more arguments than this method accepts (accepts ten or less).
                @example
                    <code>
                        var bData:* = ClassUtil.construct(BitmapData, 200, 200);
                        
                        trace(bData is BitmapData, bData.width);
                    </code>
            */
            public static function construct(type:Class, ...arguments):* {
                if (arguments.length > 10)
                    throw new Error('You have passed more arguments than the "construct" method accepts (accepts ten or less).');
                
                switch (arguments.length) {
                        case 0 :
                            return new type();
                        case 1 :
                            return new type(arguments[0]);
                        case 2 :
                            return new type(arguments[0], arguments[1]);
                        case 3 :
                            return new type(arguments[0], arguments[1], arguments[2]);
                        case 4 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3]);
                        case 5 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
                        case 6 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
                        case 7 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
                        case 8 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]);
                        case 9 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
                        case 10 :
                            return new type(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8], arguments[9]);
                }
            }
        }
    }

    Lavir_the_Whiolet, 19 Апреля 2010

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