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

    +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
    long long int Factorial(long long int m_nValue)
       {
           long long int result=m_nValue;
           long long int result_next;
           long long int pc = m_nValue;
           do
           {
               result_next = result*(pc-1);
               result = result_next;
               pc--;
           }while(pc>2);
           m_nValue = result;
           return m_nValue;
       }

    http://rosettacode.org/wiki/Factorial#C.2B.2B

    Abbath, 22 Сентября 2015

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

    +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
    #include <memory>
    #include <list>
    
    struct ListNode;
    using List = std::unique_ptr<const ListNode>;
    
    struct ListNode {
        const int data;
        const List next;
        
        ~ListNode()
        {
            if(!next)
    	    return;
    	else {
    	    std::list<ListNode*> nodes;
    	    for(auto pn = next.get(); pn->next; pn = pn->next.get()) {
    		nodes.push_back(const_cast<ListNode*>(pn));
    	    }
    	    for(decltype(nodes)::reverse_iterator in = nodes.rbegin(); in != nodes.rend(); ++in) {
    		const_cast<List&>((*in)->next).reset();
    	    }
    	}
        }
    };
    
    List Cons(int head, List tail)
    {
        return List(new ListNode{head, std::move(tail)});
    }
    
    List Nil()
    {
        return List();
    }
    
    size_t len(const List & self)
    {
        if (!self) {
            return 0;
        }
        return 1 + len(self->next);
    }
    
    #include <iostream>
    
    void test(size_t n)
    {
        auto p = Nil();
        for (size_t i = 0; i < n; ++i) {
            auto x = std::move(p);
            p = Cons(1, std::move(x));
        }
        std::cout << "done: " << std::endl;
    }
    
    int main()
    {
        test(131028);
    }

    односвязный список против джависта
    источник: https://www.linux.org.ru/forum/development/11752940?cid=11755489

    CHayT, 22 Сентября 2015

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

    0

    1. 1
    Currently, the official WordPress distribution only supports the MySQL database engine.

    https://codex.wordpress.org/Using_Alternative_Databases

    defecate-plusplus, 21 Сентября 2015

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

    +5

    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
    <script type="text/javascript">
    function gopage1() {
    <? $query = "INSERT INTO  orders2 (id, price, metod, bill) VALUES ('$idp','$price','webmoney','$bill')"; 
    mysql_query($query) or die(mysql_error()); ?>
     }
    
    function gopage2() {
    <? $query = "INSERT INTO  orders2 (id, price, metod, bill) VALUES ('$idp','$price','qiwi','$bill')"; 
    mysql_query($query) or die(mysql_error()); ?>
     }
    
    function gopage3() {
    <? $query = "INSERT INTO  orders2 (id, price, metod, bill) VALUES ('$idp','$price','yandex','$bill')"; 
    mysql_query($query) or die(mysql_error()); ?>
     }
    </script>
                    
    <?php
    if(1 == config_item('site_pwebmoney')){
    echo "<form method='POST' action=''?gpay'>
    <input type='image' onclick='gopage1()' src='http://i.imgur.com/ShsyZEc.png' style='height:45px;' name='webmoney' value='webmoney'>
    </form>";
    }
    else{
    }
    ?>
    <br>
    <?php
     
    if(1 == config_item('site_pqiwi')){    
    echo "<form method='POST' action='?gpay'>
    <input type='image' onclick='gopage2()' src='http://i.imgur.com/RkZSEtW.png' style='height:45px;' name='qiwi' value='qiwi'>
    </form>";
    }
    else{
    }
    ?>
    <br>
    <?php
    if(1 == config_item('site_pyandex')){
    echo "<form method='POST' action='?gpay'>
    <input type='image' onclick='gopage3()' src='http://i.imgur.com/JLR7kHV.png'style='height:45px;' name='yandex' value='yandex'>
    </form>";
    
    }
    else{
    }
    ?>

    нашел это на одном форуме про php .

    а после этого пояснения автор кода , я заржал во весь голос: "Недавно изучил основы JavaScript, и столкнулся с проблемой."

    ishurgaya, 21 Сентября 2015

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    /^.{0}$/.test('')   // true
    /^.{0,}$/.test('')  // true
    /^.{0,1}$/.test('') // true
    /^.{,1}$/.test('')  // false

    http://www.ecma-international.org/ecma-262/5.1/#sec-15.10

    /^.{,1}$/.test('.{,1}') // true

    1024--, 21 Сентября 2015

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    if (value is Int32)
    {
        Int32 prio = Int32.Parse(value.ToString());
    }

    l1pton17, 20 Сентября 2015

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

    +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
    function coolSplit(str, pattern) {
      var result = [];
      while(1){
        var m = str.match(pattern);
        if(!m) {
          if(str) result.push(str);
          return result;
        }
        if(m.index) result.push(str.substr(0, m.index));
        result.push(str.substr(m.index, m[0].length));
        str = str.substr(m.index + m[0].length);
      }
    }

    Из шифроскрипта. https://github.com/1024--/govnokod.ru-userscripts/commit/898e6195b9799853b08a01834ce55f8d780757f3#diff-40cd32e1559d395399816968845cb034R151

    coolSplit(str, /expr/) ≡ str.split(/(expr)/) // Говнокод обучающий

    1024--, 18 Сентября 2015

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

    +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
    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
    string[] array=new string[10];
    array[0] = "?";
    array[1] = "?";
    array[2] = "?";
    array[3] = "?";
    array[4] = "?";
    array[5] = "?";
    array[6] = "?";
    array[7] = "?";
    array[8] = "?";
    
    ....
    
    if (DS.Tables[0].Rows[i][3].ToString() == "1")
    {
    checkBox20.Checked = true;
    }
    if (DS.Tables[0].Rows[i][4].ToString() == "1")
    {
    checkBox23.Checked = true;
    }
    if (DS.Tables[0].Rows[i][5].ToString() == "1")
    {
    checkBox22.Checked = true;
    }
    if (DS.Tables[0].Rows[i][6].ToString() == "1")
    {
    checkBox25.Checked = true;
    }
    if (DS.Tables[0].Rows[i][7].ToString() == "1")
    {
    checkBox24.Checked = true;
    }
    if (DS.Tables[0].Rows[i][8].ToString() == "1")
    {
    checkBox27.Checked = true;
    }
    if (DS.Tables[0].Rows[i][9].ToString() == "1")
    {
    checkBox11.Checked = true;
    }
    
    ...
    
    if (checkBox17.Checked)
    {
    array[0] = "application/";
    }
    if (checkBox18.Checked)
    {
    array[1] = "audio/";
    }
    if (checkBox21.Checked)
    {
    array[2] = "example/";
    }
    if (checkBox20.Checked)
    {
    array[3] = "image/";
    }
    if (checkBox23.Checked)
    {
    array[4] = "message/";
    }
    if (checkBox22.Checked)
    {
    array[5] = "model/";
    }
    if (checkBox25.Checked)
    {
    array[6] = "multipart/";
    }
    if (checkBox24.Checked)
    {
    array[7] = "text/";
    }
    if (checkBox27.Checked)

    Дали на рецензию одну научную работу...

    sgerman, 18 Сентября 2015

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

    +3

    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
    public SomeLongNameSpace.PolicyPremiumReturnType ProcessPremiums(
                        int userID, 
                        int divisionID, 
                        string ObjectCode, 
                        int iPolicyID, 
                        int iBulkEndorsementID, 
                        System.Data.DataTable dtClientPremiums, 
                        System.Data.DataTable dtClientPremiumInterests, 
                        System.Data.DataTable dtRiskCommissions, 
                        System.Data.DataTable dtBrokerages, 
                        System.Data.DataTable dtDiscounts, 
                        System.Data.DataTable dtApportionments, 
                        System.Data.DataTable dtUWGroups, 
                        System.Data.DataTable dtUWGroupSettings, 
                        System.Data.DataTable dtUWGroupPremiums, 
                        System.Data.DataTable dtRiskDeclarations, 
                        System.Data.DataTable dtRiskDeclarationsInterests, 
                        int clientPaymentIntervalDays, 
                        int uwDefaultPaymentIntervalDays, 
                        int uwPaymentIntervalDays, 
                        System.Data.DataTable dtSchedulesLimitDetails, 
                        XII.Integration.GlobalXB.v1_4.PolicyGL.CommissionProcessingFlags commissionProcessingFlags, 
                        bool isOverrideWarranties, 
                        string transactionDescription, 
                        string TechnicalContactName, 
                        bool isCreateDeclarationWithoutInterests, 
                        int clientRPPaymentIntervalDays,
                        System.Data.DataTable deferredPayments)
            {
                return base.Channel.ProcessPremiums(userID, divisionID, ObjectCode, iPolicyID, iBulkEndorsementID, dtClientPremiums, dtClientPremiumInterests, dtRiskCommissions, dtBrokerages, dtDiscounts, dtApportionments, dtUWGroups, dtUWGroupSettings, dtUWGroupPremiums, dtRiskDeclarations, dtRiskDeclarationsInterests, clientPaymentIntervalDays, uwDefaultPaymentIntervalDays, uwPaymentIntervalDays, dtSchedulesLimitDetails, commissionProcessingFlags, isOverrideWarranties, transactionDescription, TechnicalContactName, isCreateDeclarationWithoutInterests, clientRPPaymentIntervalDays, deferredPayments);
            }

    few params

    g10829780, 18 Сентября 2015

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

    −1

    1. 1
    continueSaving(item, item);

    В node.js 3 вызова функции continueSaving, первый объект новый, второй старый из бд, в самой функции проверяется наличие старого объекта и если есть то он используется, в остальных вызовах все нормально.

    styopdev, 18 Сентября 2015

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