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

    В номинации:
    За время:
  2. Куча / Говнокод #14353

    +123

    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
    (function(win) {
        var hostname_as_int = parseInt((location.hostname || "local").substring(0,10), 36);
        if (typeof win['dpx_'+hostname_as_int] != 'undefined') {
            win['dpx_'+hostname_as_int].run();
            return;    }
        var dpx = {
            sifi_pixel_url: '//i.simpli.fi/dpx?',
            pixels_url: 'http://i.simpli.fi/p?',
            pixels: [],
            matching_pixels: [],
            protocol: (location.protocol == 'https:') ? 'https:' : "http:",
            pixels_to_drop: [],
            dropping_pixels: false,
            rescue_pixel: null,
            company_id: '',
            run: function() {
                dpx.drop_pixels();        },
            drop_pixels: function() {
                var sifi_pixels = dpx.get_sifi_pixels();
                for (var i = sifi_pixels.length-1; i >= 0; i--) {
                    dpx.add_sifi_pixel(sifi_pixels[i]);            }
                if (dpx.does_allow_matching() && !dpx.already_dropped_matching) {
                    dpx.get_matching_pixels();            } else {
                    dpx._drop_matching_pixels();            }        },
            get_sifi_pixels: function() {
                var nodes = document.scripts || document.getElementsByTagName('script'),
                    pixels = [];
                for (var i = nodes.length-1; i >= 0; i--) {
                    var node = nodes[i],
                        src = node.src || '';
                    if (src.indexOf('/dpx.js') > 0 && !node.getAttribute('data-sifi-parsed')) {
                        node.setAttribute('data-sifi-parsed', true);
                        var params = dpx.get_query_string(src);
                        dpx.company_id = (params.match(/cid=(\d+)/) || [])[1] || dpx.company_id
                        pixels.push(params);
                        dpx.pixels.push(params);                }            }
                return pixels;        },
            add_sifi_pixel: function(params) {
                params += "&cbri=" + Math.floor(Math.random()*(new Date().getTime()));
                params += "&referrer=" + escape(document.referrer);
                dpx.pixels_to_drop.push(dpx.sifi_pixel_url + params);        },
            get_matching_pixels: function() {
                var script = document.createElement('script');
                script.src = dpx.pixels_url + 'cid=' + dpx.company_id + '&cb=dpx_' + hostname_as_int + '._hp';
                document.body.appendChild(script);
            },
            get_query_string: function(src) {
                var str = src.substr(src.indexOf('dpx.js?')+7);
                return str;
            },
            _hp: function(pixels) {
                dpx.matching_pixels = pixels && pixels['pixels'] || [];
                dpx._drop_matching_pixels();
            },
            _drop_matching_pixels: function() {
                if (dpx.does_allow_matching() && !dpx.already_dropped_matching) {
                    for (var i = dpx.matching_pixels.length-1; i >= 0; i--) {
                        dpx.pixels_to_drop.push(dpx.matching_pixels[i]);
                    }
                    dpx.already_dropped_matching = true;
                }
                dpx._next_pixel();
            },
            _next_pixel: function() {
                if (dpx.pixels_to_drop.length == 0) return;
                var src = dpx.pixels_to_drop.shift(),
                    img = new Image();
                img.onload = img.onerror = function() {
                  dpx.rescue_pixel = null;
                  dpx._next_pixel();
                };
                img.src = dpx.protocol + src;
                dpx.rescue_pixel = setTimeout(function() {
                  img.onload = img.onerror = null;
                  dpx._next_pixel();
                },1000);        },
            does_allow_matching: function() {
                if (typeof dpx.allow_matching != 'undefined') return dpx.allow_matching;
                if (dpx.protocol == 'https:') {
                    dpx.allow_matching = false;
                    return false;
                }
                for (var i = dpx.pixels.length-1; i >= 0; i--) {
                    var params = dpx.pixels[i];
                    if (params.indexOf('m=0') > 0) {
                        dpx.allow_matching = false;
                        return false;                }            }
                dpx.allow_matching = true;
                return true;        }    };
        win['dpx_'+hostname_as_int] = dpx;
        if (!document.body) {
            if (window.addEventListener) {
                window.addEventListener('load', dpx.run, false);
            } else if (window.attachEvent) {
                window.attachEvent('onload', dpx.run);
            }
        } else {
            dpx.run();    }})(window);

    ты их в дверь - они в окно

    bahamot, 14 Января 2014

    Комментарии (0)
  3. PHP / Говнокод #13938

    +123

    1. 1
    list($ignore, $ignore, $ignore, $ignore,$ignore, $ignore, $radius, $ignore) = get_location_data($request['location']);

    someone, 14 Октября 2013

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

    +123

    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
    strncpy (szString, GetPropChar(ParentPicture,"Faceplate instance1","IN0_text_ON") , sizeof(szString));
    if (strlen(szString)!=0)	
        { SetPropBOOL(lpszPictureName, "Input Bit 0" , "Visible", 1);
         SetPropBOOL(lpszPictureName, "I_b0" , "Visible", 1);
       }
    else
        { SetPropBOOL(lpszPictureName, "Input Bit 0" , "Visible", 0); 
          SetPropBOOL(lpszPictureName, "I_b0" , "Visible", 0);
        }
    
    strncpy (szString, GetPropChar(ParentPicture,"Faceplate instance1","IN1_text_ON") , sizeof(szString));
    if (strlen(szString)!=0)	
        { SetPropBOOL(lpszPictureName, "Input Bit 1" , "Visible", 1);
         SetPropBOOL(lpszPictureName, "I_b1" , "Visible", 1);
       }
    else
        { SetPropBOOL(lpszPictureName, "Input Bit 1" , "Visible", 0); 
          SetPropBOOL(lpszPictureName, "I_b1" , "Visible", 0);
        }

    Скрипт для WinCC. И так 8 раз подряд.
    Написал начальник отдела разработчиков (Си— не его специализация), как часть большого концептуального объекта, с которым мне и надо работать. А я не могу с этим работать, ощущая вот такие говенные внутренности.

    MereNonsense, 29 Июля 2013

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

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @echo off
    :start
    ping -n 1 <destination>
    ping -n 90 127.0.0.1 > NUL 2>&1
    GOTO start

    http://mybroadband.co.za/vb/showthread.php/122641-How-do-you-set-ping-interval
    Попов жив.

    Stallman, 28 Июля 2013

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

    +123

    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
    #include <malloc.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    
    typedef struct {
      char * begin;
      uint64_t size, data_size;
    } str_t;
    
    inline uint64_t max(uint64_t a, uint64_t b) {
      return (a > b) ? a : b;
    }
    
    inline str_t correct_data_size(str_t str, uint64_t new_size) {
      if(str.data_size < new_size) {
        str.data_size = (max(str.data_size, new_size) << 1);
        str.begin = realloc(str.begin, str.data_size);    
      }
      return str;
    }
    
    inline str_t concat(str_t dest, str_t src) {
      uint64_t new_size = (dest.size + src.size - 1);
      dest = correct_data_size(dest, new_size);
      memcpy((dest.begin + dest.size - 1), src.begin, src.size);
      dest.size = new_size;
      return dest;
    }
    
    inline str_t create_str(char * str, uint64_t size) {
      return (str_t){.begin = strcat(malloc(size), str), .size = size, .data_size = size};
    }
    
    inline void print_str_t(str_t str) {
      fprintf(stderr, "str = %ssize = %lu, data_size = %lu\n", str.begin, str.size, str.data_size);
    }
    
    uint64_t test(uint64_t star_n, uint64_t n, str_t str, str_t * gstr) {
      uint64_t end = (star_n + n);
      do {
        *gstr = concat(*gstr, str);
        
        char * pos = gstr->begin;
        while((pos = strstr(pos, "efgh")))
          memcpy(pos,"____",4);
        
      } while((++star_n) != end);
      return star_n;
    }
    
    int main(void) {
      char data[] = "abcdefghefghefgh";
      str_t str = create_str(data, sizeof(data)); 
      str_t gstr = create_str("", 1);
      time_t starttime = time(NULL);
      
      uint64_t block_c = 0;
      
      while((block_c = test(block_c, ((256/16) * 1024), str, &gstr)) != (((256/16) * 1024) * 20))
        printf("%ldsec\t\t%lukb\n",time(NULL)-starttime,gstr.size/1024);
      
    }

    Минимально оптимизированный вариант в царь-стиле теста из предыдущего ГК. Никто не увидел и начали на меня кукарекать. То ещё ГК, давайте объясняйте что здесь говно.

    superhackkiller1997, 11 Июля 2013

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

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Судя по Вашим оценкам, образцы моего кода не так у ж и плохи. Это радует; но в таком случае, получается, что я ошибся форумом. 
    Если это действительно так, я спешу сменить амплуа г.кодера. 
    Непонаслышке зная, что бан тут получить практически нереально, я все таки сделаю отчаянную попытку:
    
    Логин: [email protected]
    Пароль: gcode116
    
    Я желаю Вам всего самого наилучшего. С Вами было весело.  
    За сим, остаюсь, ваш Stertor. Списаться со мной можно по вышеуказанному адресу.

    Stertor, 24 Июня 2013

    Комментарии (9)
  8. C# / Говнокод #13011

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    [Obsolete("Непонятный хлам")]
    public static class CalendarHelper
    {
    }

    musuk, 16 Мая 2013

    Комментарии (3)
  9. Assembler / Говнокод #12876

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    xorl %eax, %eax                           # cx - source, ebx - result
        movw %cx, %ax
        andw $0x8000, %ax
        shrw $15, %ax
        movl $0xFFFFFFFF, %ebx
        addl %eax, %ebx
        notl %ebx
        andl $0xffff0000, %ebx
        addw %cx, %bx

    LispGovno, 10 Апреля 2013

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

    +123

    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(elementNode != null) {
    	//attachGrowingEffectAnimation(elementNode);
    	String shadowMode = elementNode.getUserData(JMEScene3D.SHADOW_MODE);
    	if(shadowMode != null) {
    		if(shadowMode.equals(JMEScene3D.SHADOW_MODE_RECEIVE)) {
    			shadowNodesMap.put(ShadowMode.Receive, elementNode);
    		}
    	}
    	
    	if(elementNode != null) {
    		pyElementsNode.attachChild(elementNode);
    	}
    }

    Ну правда, а вдруг сам по себе станет не null?

    someone, 27 Декабря 2012

    Комментарии (13)
  11. Куча / Говнокод #12181

    +123

    1. 1
    val ret = method.invoke(this, args:_*)

    Превращаем Array[Any] в жабовый Object[] в Scala.

    myaut, 23 Ноября 2012

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