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

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

    −102

    1. 1
    import com.adobe.protocols.dict.events.ErrorEvent;

    Ну хоть бы циферку добавили...

    wvxvw, 21 Февраля 2011

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

    +117

    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 static class EventExtensions
        {
            public static void Fire(this EventHandler eventHandler, object sender)
            {
                eventHandler.Fire(sender, EventArgs.Empty);
            }
    
            public static void Fire(this EventHandler eventHandler, object sender, EventArgs args)
            {
                eventHandler.FireDelegate(sender, args);
            }
    
            public static void Fire<TEA>(this EventHandler<TEA> eventHandler, object sender, TEA args)
                where TEA : EventArgs
            {
                eventHandler .FireDelegate(sender, args);
            }
    
            public static void FireDelegate(this Delegate eventHandler, params object[] parameters)
            {
                if (eventHandler != null)
                {
                    Delegate[] delegates = eventHandler.GetInvocationList();
                    foreach (var del in delegates)
                    {
                        try
                        {
                            del.Method.Invoke(del.Target, parameters);
                        }
                        catch (Exception e)
                        {
                            // use logger here
                            throw;
                        }
                    }
                }
            }
        }

    Надоело писать инвокаторы для ивентов? Как тебе это?

    walash, 21 Февраля 2011

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

    +163

    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
    /**
     * Callback for gravity gradient menu option. Turn Gravity Gradient profile display on/off.
     */
    void Exf2dMW::toggleGravGradientProfileCb()
    {
      // GV show Gravity Gradient profile here.
      if (_toggleGravGradientProfileAct->isChecked())
        gvWidget()->showProfiles(1);
      else
        gvWidget()->hideProfiles(1);
    }
    
    /**
     * Callback for gravity menu option. Turn Gravity profile display on/off.
     */
    void Exf2dMW::toggleGravProfileCb()
    {
      // GV show Gravity profile here.
      if (_toggleGravProfileAct->isChecked())
        gvWidget()->showProfiles(2);
      else
        gvWidget()->hideProfiles(2);
    }
    
    /**
     * Callback for magnetic menu option. Turn Magnetic profile display on/off.
     */
    void Exf2dMW::toggleMagProfileCb()
    {
      // GV show magnetic profile here.
      if (_toggleMagProfileAct->isChecked())
        gvWidget()->showProfiles(3);
      else
        gvWidget()->hideProfiles(3);
    }

    boolean logic fail.

    kitaec, 21 Февраля 2011

    Комментарии (4)
  5. C# / Говнокод #5723

    +146

    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
    using System;
    
    class Popovkin
    {
        static void Main()
        {
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.WriteLine("Привет, баребухи! Я Ромик Будин!");
            Console.WriteLine("Уже " + DateTime.Now);
            Console.WriteLine("Нажмите Ентер!");
            Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            for (int e = 1; e < 1200000; e++)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.BackgroundColor = ConsoleColor.White;
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                Console.Write("Hello Popovkin!!!");
                for (int i = 0; i < 2; i++)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    Console.Write("Hello Popovkin!!!");
                    for (int q = 0; q < 2; q++)
                    {
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.Write("Hello Popovkin!!!");
                        Console.WriteLine("Hello Popovkin!!!");
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.BackgroundColor = ConsoleColor.Red;
                    }
                }
            }
            Console.ReadLine();
        }
    }

    111111, 19 Февраля 2011

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult SaveLastReport(string gridHtml)
    {
    	var buf = Convert.FromBase64String(gridHtml);
    	var str = System.Text.Encoding.UTF8.GetString(buf, 0, buf.Length);
    	System.IO.File.WriteAllText(Server.MapPath("~/content/lastreport.html"), str);
    	return RedirectToAction("LastReport");
    }

    Вот так иногда закрываются формальные требования по ТЗ...

    St0rm, 16 Февраля 2011

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

    +159

    1. 1
    2. 2
    3. 3
    $ar=$arFields['GROUP_ID'];
    $arFields['GROUP_ID']=array();
    foreach($ar as $a) $arFields['GROUP_ID'][]=$a;

    Смысл данной конструкции не ясен, если так нужно обнулить ключи для массива то array_values() в помощь.

    tkf, 15 Февраля 2011

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

    −364

    1. 1
    Если (ДатаГод(ДатаДок) < 2010) ИЛИ (ДатаГод(ДатаДок) < 2010 ) Тогда

    Строка кода из типовой конфигурации 1С: Бухгалтерия 7.7, релиз 522
    No comments ...

    manan, 10 Февраля 2011

    Комментарии (4)
  9. JavaScript / Говнокод #5613

    +164

    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
    aLength = V_Array.length;
    if(aLength == 1) { 
     if(V_Array[0][0]=='true'){
      document.MainListForm.list_DV[0].checked = true;
      document.MainListForm.list_NE[0].checked = true;
     }else{
      document.MainListForm.list_DV[0].checked = false;
      document.MainListForm.list_NE[0].checked = false;
     }
     if(V_Array[0][1]=='true'){
      document.MainListForm.list_DV[1].checked = true;
      document.MainListForm.list_NE[1].checked = true;
     }else{
      document.MainListForm.list_DV[1].checked = false;
      document.MainListForm.list_NE[1].checked = false;
     }
     if(V_Array[0][2]=='true'){
      document.MainListForm.list_DV[2].checked = true;
      document.MainListForm.list_NE[2].checked = true;
     }else{
      document.MainListForm.list_DV[2].checked = false;
      document.MainListForm.list_NE[2].checked = false;
     }
     if(V_Array[0][3]=='true'){
      document.MainListForm.list_DV[3].checked = true;
      document.MainListForm.list_NE[3].checked = true;
     }else{
      document.MainListForm.list_DV[3].checked = false;
      document.MainListForm.list_NE[3].checked = false;
     }
     return;
    }
    
    for (i = 0; i < aLength ; i++) {
     if(V_Array[i][0]=='true'){
      document.MainListForm[i].list_DV[0].checked = true;
      document.MainListForm[i].list_NE[0].checked = true;
     }else{
      document.MainListForm[i].list_DV[0].checked = false;
      document.MainListForm[i].list_NE[0].checked = false;
     }
     if(V_Array[i][1]=='true'){
      document.MainListForm[i].list_DV[1].checked = true;
      document.MainListForm[i].list_NE[1].checked = true;
     }else{
      document.MainListForm[i].list_DV[1].checked = false;
      document.MainListForm[i].list_NE[1].checked = false;
     }
     if(V_Array[i][2]=='true'){
      document.MainListForm[i].list_DV[2].checked = true;
      document.MainListForm[i].list_NE[2].checked = true;
     }else{
      document.MainListForm[i].list_DV[2].checked = false;
      document.MainListForm[i].list_NE[2].checked = false;
     }
     if(V_Array[i][3]=='true'){
      document.MainListForm[i].list_DV[3].checked = true;
      document.MainListForm[i].list_NE[3].checked = true;
     }else{
      document.MainListForm[i].list_DV[3].checked = false;
      document.MainListForm[i].list_NE[3].checked = false;
     }
    }

    типично китайский привет из реал лайф проект

    kuku, 09 Февраля 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (aNew=='true'){
    	  path = './page.html?show='+ashow+'&avail='+aavail+'&page='+page+'&size='+asize+'&order='+aorder+'&ordera='+aordera+'&refresh='+arefresh+'&letter='+aletter+'&sortcount='+asortcount+'&search=off&new=true';
    }else{
    	  path = './page.html?show='+ashow+'&avail='+aavail+'&page='+page+'&size='+asize+'&order='+aorder+'&ordera='+aordera+'&refresh='+arefresh+'&letter='+aletter+'&sortcount='+asortcount+'&search=off&new=false';
    }

    разница в &new=true/false
    Код из большого серьезного продакшен проекта.

    kuku, 09 Февраля 2011

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
        function is_get($id) {
            return (count(array_unique(str_split($id))) == 1);
        }
    ?>

    Гет или не гет?)

    hidespb, 09 Февраля 2011

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