1. C# / Говнокод #19722

    +1

    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
    private int GetSroOper(MiscTransactionParams param)
    		{
    			if (param.ExpenseItem != null)
    			{
    				switch (param.ContractType)
    				{
    					case Entities.AT.ContractType.Undefined:
    					case Entities.AT.ContractType.TimeAndMaterials:
    					case Entities.AT.ContractType.Retainer:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.RecurringService:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.FixedPrice:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation500 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					case Entities.AT.ContractType.Incident:
    						switch ((int)param.ExpenseItem.ExpenseCategory)
    						{
    							case 2:
    							case 3:
    							case 29684252:
    							case 29684285:
    							case 29684805:
    								return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation950;
    							default:
    								throw new InvalidOperationException("Unsupported Expense Category value");
    						}
    					default:
    						throw new InvalidOperationException("Unsupported ContractType value");
    				}
    			}
    			else
    			{
    				switch (param.ContractType)
    				{
    					case Entities.AT.ContractType.Undefined:
    					case Entities.AT.ContractType.TimeAndMaterials:
    					case Entities.AT.ContractType.Retainer:
    						return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation600 : Helper.SLServiceOrderOperation900;
    					case Entities.AT.ContractType.RecurringService:
    						return param.BillingItem.IsNonBillable() ? Helper.SLServiceOrderOperation550 : Helper.SLServiceOrderOperation950;
    					case Entities.AT.ContractType.FixedPrice:
    					case Entities.AT.ContractType.Incident:
    						int sroOper = (int)param.OrderOperation.EntityRow()[Constants.ServiceOrderOperation.Field.SroOper];
    						switch (sroOper)
    						{
    							case 500:
    							case 600:
    							case 800:
    							case 850:
    							case 950:
    								return sroOper;
    							default:
    								throw new InvalidOperationException("Unsupported Operation value");
    						}
    					default:
    						throw new InvalidOperationException("Unsupported ContractType value");
    				}
    			}
    		}

    Это наш сеньор написал

    kagetoki, 30 Марта 2016

    Комментарии (19)
  2. C# / Говнокод #19721

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static bool AddStringIfNoExist(this List<string> strlist, string str)
    {
        if (str == "") return true;
        foreach (string s in strlist) if (s == str) return true;
        strlist.Add(str);
        return false;
    }

    Hashset? А что это такое?

    kerman, 29 Марта 2016

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

    0

    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
    $f = fopen("./.htaccess", "r");
    			while (!feof($f)) {
    			    $tmp = fgets($f);
    			    $tmp = str_replace(REDIRECT_USER."/", $_POST["redir_user"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_SHOP."/", $_POST["redir_shop"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_ADMIN."/", $_POST["redir_admin"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_NEWS."/", $_POST["redir_news"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_CART."/", $_POST["redir_cart"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_PAYMENT."/", $_POST["redir_payment"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_INFO."/", $_POST["redir_info"]."/", $tmp);
    			    $line[] = $tmp;
    			}
    			fclose($f);

    Настройка редиректов из админки

    drop_database, 29 Марта 2016

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

    +81

    1. 1
    mov podi,vilov

    d_fomenok, 29 Марта 2016

    Комментарии (12)
  5. PHP / Говнокод #19716

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public function extractPublicPlace($item)
    {
        list($a['name'], list($a['lat'], $a['lon'])) = $item;
        return $a;
    }

    просто оставлю

    akanit, 29 Марта 2016

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

    +6

    1. 1
    2. 2
    http://requests.readthedocs.org/en/master/
    Warning: Recreational use of other HTTP libraries may result in dangerous side-effects, including: security vulnerabilities, verbose code, reinventing the wheel, constantly reading documentation, depression, headaches, or even death.

    Не говнокод, даже не говнокоммент. Наоборот, хороший, годный комментарий.

    хуита, 29 Марта 2016

    Комментарии (3)
  7. Куча / Говнокод #19713

    +5

    1. 1
    2. 2
    3. 3
    .dostali {
    font-weight: bold;
    }

    Достали!!!11

    gk228, 29 Марта 2016

    Комментарии (3)
  8. Куча / Говнокод #19712

    +4

    1. 1
    http://cs543107.vk.me/v543107084/f49c/quBsGLPz-lE.jpg

    Программирование по-русски глазами американцев...
    Сериал: "Агенты Щ.И.Т."; Сезон: 3; Эпизод: 13

    LispGovno, 29 Марта 2016

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public enum Status : byte
    {
            Disabled = 0,
            Enabled
    }

    Мопед не мой, прислала боевая подруга из Канады, реальный проект за недетские деньги.
    Лаконичности була не хватило, лучше свой енум сделать, чем писать bool IsEnabled.
    KISS.

    kerman, 28 Марта 2016

    Комментарии (71)
  10. PHP / Говнокод #19710

    −1

    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
    public function actionTtn($id)
        {
            $tender = $this->findModel($id);
            $htmlContent = '<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <div>
        <div style="margin-left: 30%; margin-right: 30%; font-weight:bold;">
            Транспортный заказ № ' . $id . ' от ' . date("d.m.y", $tender->ts) . '
        </div>
    //////////////////////////////////////////////////////////////////////////
    здесь еще 200 строк html
    //////////////////////////////////////////////////////////////////////////
    </div>
    </body>
    </html>';
            $pdf = Yii::$app->pdf;
            $pdf->content = $htmlContent;
            return $pdf->render();
        }

    action одного из контроллеров

    NotFake, 28 Марта 2016

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