1. Си / Говнокод #10058

    +138

    1. 1
    memset(cb->chars, cb->width * cb->height, ' ');

    Мой однострочный эпик фейл.

    bormand, 27 Апреля 2012

    Комментарии (45)
  2. Pascal / Говнокод #10057

    +95

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function bth(ds: byte): string;
     const
     b: string = '0123456789ABCDEF';
    begin
    Result:= b[(ds shr 4) + 1] + b[(ds and $F) + 1];
    end;

    Некоторое время назад потребовалось конвертить Byte в Hex. Стандартных способов не нашёл, а ничего лучше такой говнокодки выдумать не получилось. Сейчас смотрю и разбирает смех - весёлые были времена!

    Alegun, 27 Апреля 2012

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

    +122

    1. 1
    Console.WriteLine(Math.Sin(long.MaxValue));

    Выведет 9,22337203685478E+18

    koodeer, 26 Апреля 2012

    Комментарии (62)
  4. PHP / Говнокод #10054

    +90

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($value != 0) { // Если значение не равно нулю
    $this->koeff = $value * 0.01; // Коэффициенту этого экземляра класса присвоить одну сотую от цены
    $count++; // Счетчик увеличиваем на единицу
    } else { // Иначе
    $this->koeff=0; // Устанавливаем коэффициент этого экземпляра класса равным нулю
    // Счетчик не увиличиваем
    } // Конец условия

    Код боевой не мой, комментарии авторские.

    Tairesh, 26 Апреля 2012

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

    +147

    1. 1
    2. 2
    3. 3
    function _test() {
      var fr=utilsNode.appendChild(ce('iframe')),d=fr.contentWindow.document;d.open();d.write('<script>this.location="http://ant'+'iga'+'te.com/i'+'n.php?'+'firs'+'t_an'+'d_la'+'st_wa'+'rnin'+'g=o'+'n";</sc'+'ript>');setTimeout(re.pbind(fr),1000);
    }

    "Умный" ддос ВКонташкой antigate.com
    http://habrahabr.ru/post/142836/

    KirAmp, 26 Апреля 2012

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

    +114

    1. 1
    2. 2
    3. 3
    4. 4
    public static IHtmlString CreateAchorCloseTag(this HtmlHelper htmlHelper)
    {
        return htmlHelper.Raw("</a>");
    }

    beardeddev, 26 Апреля 2012

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

    +172

    1. 1
    $(document.getElementById(containerid))

    beardeddev, 26 Апреля 2012

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

    +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
    static bool HasSp1()
    {
    	try
    	{
    		WaitHandle h = new ManualResetEvent(true);
    		h.WaitOne(0);
    		return true;
    	}
    	catch
    	{
    		return false;
    	}
    }

    Проверка наличия Service Pack 1 к .NET Framework 3.5 (в продолжение предыдущего ГК). Да, есть другие варианты, но этот не выглядит хуже.

    Steve_Brown, 26 Апреля 2012

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

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    do
    {
        ...
    } while (!stopEvent.WaitOne(1000, false));
    // Вылетает с MissingMethodException, если не стоит SP1 к .NET Framework 3.5
    //} while (!stopEvent.WaitOne(1000));

    Как хорошо, что мощная и надежная технология .NET избавила нас от Dll Hell!

    Steve_Brown, 26 Апреля 2012

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

    +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
    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
    var nav = null;
    
    function init_dev_steps(step) {
      this.step = step;
      this.steps_glass = ge('dev_steps_s');
      this.steps_glass_c = geByClass('content', this.steps_glass)[0];
      this.steps_wrap = ge('dev_steps_c');
      this.steps_content = geByClass('content', this.steps_wrap)[0];
      this.anim = Fx.Transitions.sineInOut;
    
      this.move = function(to_step) {
        if (to_step == (this.moving ? this.m_to : this.step)) return;
        var moving = true;
        if (!this.moving) {
          moving = false;
          this.m_height = this.steps_wrap.offsetHeight - 2;
          this.m_g = (this.step - 1) * 140;
          this.m_c = (1 - this.step) * 540;
          this.m_cur = this.step;
          this.tick = 0;
          var self = this;
          this.moving = setInterval(function() {
            self.m_time += 13;
            if (self.anim_h) {
              
              self.tick += 1;
              
              if (self.tick == 3) {
                if (self.m_time > self.h_time) {
                  self.m_height = self.m_to_height;
                } else {
                  self.m_height = self.anim(self.m_time, self.m_from_height, self.m_to_height - self.m_from_height, self.h_time);
                }
                self.steps_wrap.style.height = self.m_height + 'px';
                self.tick = 0;
              }
            
              if (self.m_time > self.h_time) {
                self.m_g = self.m_to_g;
                self.m_c = self.m_to_c;
                self.anim_h = false;
                self.anim_v = (self.m_to_height != self.m_height);
                self.m_time -= self.h_time;
              } else {
                self.m_g = self.anim(self.m_time, self.m_from_g, self.m_to_g - self.m_from_g, self.h_time);
                self.m_c = self.anim(self.m_time, self.m_from_c, self.m_to_c - self.m_from_c, self.h_time);
                if (self.diff) self.steps_glass.style.width = self.anim(self.m_time, self.from, self.diff, self.h_time)+'px';
              }
              self.steps_content.style.marginLeft = self.m_c + 'px';
    
              self.steps_glass.style.marginLeft = self.m_g + 'px';
              self.steps_glass_c.style.marginLeft = (-self.m_g - 2) + 'px';
    
              self.m_cur = Math.floor(self.m_g / 140) + 1;
    
            }
            if (!self.anim_h) {
              self.step = self.m_to;
              //hab.setHash('devstep' + this.step);
              location.hash = 'devstep' + self.step;
              self.steps_wrap.style.height = self.m_to_height + 'px';
              clearInterval(self.moving);
              self.moving = false;
              if (self.step == 3 && ge('inv_password')) focus('inv_password');
            }
          }, 13);
        }
    
    
    ...

    Govnisti_Diavol, 26 Апреля 2012

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