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

    +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
    double vvod (double a1, double a2, double a3) {
     
    // a1=a a2=b a3=c
     
    	cout<<"Введите значение коэфицента a: ";
    	cin>>a1;
    	cout<<endl;
    	cout<<"Введите значение коэфицента b: ";
    	cin>>a2;
    	cout<<endl;
    	cout<<"Введите значение коэфицента c: ";
    	cin>>a3;
    	cout<<endl;
    	return (a1);
    	return (a2);
    	return (a3);
    }

    Оказывается в С++ можно возвращать 3 значения из функции
    http://ideone.com/tGWRpl - полная версия.

    pabloid, 05 Сентября 2013

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

    −105

    1. 1
    2. 2
    3. 3
    4. 4
    NSArray* arry = [NSArray arrayWithObjects:arrayWithObjects:prev, next, nil];
    [arry performSelector:NSSelectorFromString(@"retain")];
    //---
    [actionSheet performSelector:@selector(setTag:) withObject:arry];

    АРЦ нельзя кастовать указатели? Хватит это терпеть!

    Psionic, 05 Сентября 2013

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

    −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
    #include <iostream>
    using namespace std;
    
    struct NG
    {
    	template<class T>
    	struct get
    	{
    		typedef typename T::f type;
    	};
    };
    
    template <typename T, typename NameGetter>
    struct has_member_impl
    {
        typedef char matched_return_type;
        typedef long unmatched_return_type;
        
        template <typename C>
        static matched_return_type f(typename NameGetter::template get<C>*);
        
        template <typename C>
        static unmatched_return_type f(...);
        
    public:
        static const bool value = (sizeof(f<T>(0)) == sizeof(matched_return_type));
    };
    
    template <typename T, typename NameGetter>
    struct has_member{
       enum { value = has_member_impl<T, NameGetter>::value };
     };
     
     class T{};
    
    int main() {
    	cout<<has_member<T, NG>::value;
    	return 0;
    }

    http://ideone.com/4LDGhZ

    LispGovno, 04 Сентября 2013

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

    +149

    1. 1
    2. 2
    foreach (cms::hooks('template_output') as $hook_file)
       require($hook_file);

    хуки содержатся в отдельных файлах и вставляются в код напрямую.

    fidelcomandante, 04 Сентября 2013

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

    +154

    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
    /* Формируемый запрос через Ajax */
    function MakeSearchQuery() {
        searchQuery = "";
    
        if (SearchDataQuery.CityFrom != "") {
            searchQuery = "CityFrom=" + SearchDataQuery.CityFrom;
    
            if (SearchDataQuery.Country != "") {
                searchQuery += "&Country=" + SearchDataQuery.Country;
    
                if (SearchDataQuery.Station != "" && SearchDataQuery.Station != "&Station=") {
                    searchQuery += "&Station=" + SearchDataQuery.Station;
                }
                if (SearchDataQuery.Date != "" && SearchDataQuery.Date != "&Date=") {
                    searchQuery += "&Date=" + SearchDataQuery.Date;
                }
            }
        }
    }

    Формируемый Ajax запрос

    sladkijBubaleh, 04 Сентября 2013

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

    +151

    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
    $.getJSON(tourListUrlDel, searchQuery, function (resp) {
            var _resp = resp;
            var currentTab = "";
            var count = 0;
           
            if (resp == "" || resp == null) {
                alert("Ничего не найдено!");
    
                return;
            }
            else {
                $('#searchTable').empty();
                MakeTabs("#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5");
    
                $('#tabs-' + currentTab)//#searchTable
                        .append('<tr id=tab' + count + '>')
    
                $.each(_resp, function (key, value) {
                    if (value == "" || value == null) {
                        return null;
                    }
                    count++;
    
                    if (count < 50) {
                        currentTab = 1;
                        $("#liTab1").show();
                    }
                    else if (count > 50 && count < 100) {
                        currentTab = 2;
                        $("#liTab2").show();
                    }
                    else if (count > 100 && count < 150) {
                        currentTab = 3;
                        $("#liTab3").show();
                    }
                    else if (count > 150 && count < 200) {
                        currentTab = 4;
                        $("#liTab4").show();
                    }
                    else {
                        currentTab = 5;
                        $("#liTab5").show();
                    }
    
                    $('#tabs-' + currentTab)
                          .append('<tr id=tab' + count + '>')
    
                    $.each(value, function (k, v) {
                        $('#tab' + count).append('<td>' + v + '</td>');
                    });
    
                    $('#tabs-' + currentTab)
                          .append('</tr>');
                });
                table.show('slow');
            }
        })
        .success(function () {
            $('#progressbar').hide();
        })
        .error(function(XMLHttpRequest){
            if(XMLHttpRequest.statusText != "abort"){
                alert("При попытке отправить сообщение произошла неизвестная ошибка. \n Попробуй еще раз через несколько минут.");      
            }
        })
        .fail(function () { 
            table.hide('slow'); 
        })
    };

    Заполнение таблицы результатами поиска

    sladkijBubaleh, 04 Сентября 2013

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

    +13

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    TAbstractMessageFrame * SwitchIfNeedReceivePackets = create_switch(
    		fnc_ext::bind(this,
    					  fnc_ext::compose2(std::greater<WORD>(),
    										fnc_ext::get_mem(&TThisClass::_totalDataLength),
    										fnc_ext::compose1(std::bind1st(std::minus<WORD>(), static_cast<WORD>(TByteBuffer::MaxCapacity)),
    														  fnc_ext::compose1(fnc_ext::get_mem_func_ref(&TThisClass::TByteBuffer::length),
    																			fnc_ext::get_mem(&TThisClass::_receivedBuffer))))),
    //										fnc_ext::get_mem_func(&TThisClass::FreeBufferSpace))),
    		DataByPackets, DataByLength, "Switch If Need Receive Packets" );

    Говногость, 04 Сентября 2013

    Комментарии (34)
  8. PHP / Говнокод #13735

    +154

    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
    log_info('= Выгрузка метаданных =');
    $cnt = $x->metaCurrencies('/gooddata/'.$folder.'/'.$subfolder.'/x/currencies');
    $cnt = $x->metaRegions('/gooddata/'.$folder.'/'.$subfolder.'/x/regions');
    $cnt = $x->metaCountries('/gooddata/'.$folder.'/'.$subfolder.'/x/countries');
    $cnt = $x->metaSources('/gooddata/'.$folder.'/'.$subfolder.'/x/sources');
    $cnt = $x->metaGroups('/gooddata/'.$folder.'/'.$subfolder.'/x/groups');
    $cnt = $x->metaProviders('/gooddata/'.$folder.'/'.$subfolder.'/x/providers');
    $cnt = $x->metaPS('/gooddata/'.$folder.'/'.$subfolder.'/x/paymentsystems');
    $cnt = $x->metaProjects('/gooddata/'.$folder.'/'.$subfolder.'/x/projects');
    $cnt = $x->metaPayments('/gooddata/'.$folder.'/'.$subfolder.'/x/payments');
    $cnt = $x->metaGeotypes('/gooddata/'.$folder.'/'.$subfolder.'/x/geotypes');
    $cnt = $x->metaPartners('/gooddata/'.$folder.'/'.$subfolder.'/x/partners');
    $cnt = $x->metaEmployees('/gooddata/'.$folder.'/'.$subfolder.'/x/employees');
    $cnt = $x->metaForecast('/gooddata/'.$folder.'/'.$subfolder.'/x/forecast');
    $cnt = $x->metaClusters('/gooddata/'.$folder.'/'.$subfolder.'/x/clusters');
    $cnt = $x->metaPSContr('/gooddata/'.$folder.'/'.$subfolder.'/x/pspartners');
    $cnt = $x->metaClustersMatrix('/gooddata/'.$folder.'/'.$subfolder.'/x/clustersmatrix');
    $cnt = $x->metaAccounts('/gooddata/'.$folder.'/'.$subfolder.'/x/accounts');
    $cnt = $x->metaBalanceType('/gooddata/'.$folder.'/'.$subfolder.'/x/balancetypes');
    $cnt = $x->metaBalanceGame('/gooddata/'.$folder.'/'.$subfolder.'/x/balancegame');
    $cnt = $x->metaBalancePS('/gooddata/'.$folder.'/'.$subfolder.'/x/balanceps');
    $cnt = $x->metaBalancePSContr('/gooddata/'.$folder.'/'.$subfolder.'/x/balancepscontr');
    $cnt = $x->metaBalanceBank('/gooddata/'.$folder.'/'.$subfolder.'/x/balancebank');
    $cnt = $x->metaBalanceLost('/gooddata/'.$folder.'/'.$subfolder.'/x/balancelost');
    $cnt = $x->metaStatuses('/gooddata/'.$folder.'/'.$subfolder.'/x/statuses');
    $cnt = $x->metaTypes('/gooddata/'.$folder.'/'.$subfolder.'/x/types');
    $cnt = $x->metaSupervisors('/gooddata/'.$folder.'/'.$subfolder.'/x/supervisors');
    $cnt = $x->metaGames('/gooddata/'.$folder.'/'.$subfolder.'/x/games');
    $cnt = $x->metaProjectStatus('/gooddata/'.$folder.'/'.$subfolder.'/x/projectstatuses');
    
    log_info('= Создание временных папок на Webdav =');
    $path = $folder;
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
    $path.= '/'.$subfolder;
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
    $path.= '/x';
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
    
    log_info('= Создание папок сетов =');
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/currencies','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/regions','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/countries','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/sources','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/groups','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/providers','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/paymentsystems','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/projects','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/payments','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/geotypes','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/partners','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/employees','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/forecast','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/clusters','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/pspartners','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/clustersmatrix','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/accounts','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancetypes','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancegame','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balanceps','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancepscontr','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancebank','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancelost','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/types','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/statuses','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/supervisors','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/games','MKCOL',array());
    $res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/projectstatuses','MKCOL',array());
    
    log_info('= Выгрузка данных =');
    $cnt = $x->exportCurrencies('dataset.currencies','/gooddata/'.$folder.'/'.$subfolder.'/x/currencies');
    log_info(' - currencies');
    $cnt = $x->exportRegions('dataset.regions','/gooddata/'.$folder.'/'.$subfolder.'/x/regions');
    log_info(' - regions');
    $cnt = $x->exportCountries('dataset.countries','/gooddata/'.$folder.'/'.$subfolder.'/x/countries');
    log_info(' - countries');
    $cnt = $x->exportSources('dataset.sources','/gooddata/'.$folder.'/'.$subfolder.'/x/sources');
    log_info(' - sources');
    //и дальше в таком же духе 600 строк

    Цыклы, массивы? Не, не слышал

    dimkich, 04 Сентября 2013

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <td>
    						<select class="form-control" ng-model="contact.type">
    							<option value="meat">Работоспособный</option>
    							<option value="children">Ребенок</option>
    							<option value="cripple">Пенсионер</option>
    							<option value="cripple">Инвалид</option>
    						</select>
    					</td>

    дети цветы жизни. остальные - мясо и калеки

    rombik, 03 Сентября 2013

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

    +13

    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
    void User::AddFriend(User& newFriend)
    {
        friends_.push_back(&newFriend);
        pDB_->AddFriend(GetName(), newFriend.GetName());
    }
    
    //...VS...
    
    void User::AddFriend(User& newFriend)
    {
        friends_.push_back(&newFriend);
        try
        {
            pDB_->AddFriend(GetName(), newFriend.GetName());
        }
        catch (...)
        {
            friends_.pop_back();
            throw;
        }
    }
    
    //...VS...
    
    class VectorInserter//Глобальный безопасный вектороВставлятель.
    {
    public:
        VectorInserter(std::vector<User*>& v, User& u)
        : container_(v), commit_(false)
        {
            container_.push_back(&u);
        }
        void Commit() throw()
        {
            commit_ = true;
        }
        ~VectorInserter()
        {
            if (!commit_) container_.pop_back();
        }
    private:
        std::vector<User*>& container_;
        bool commit_;
    };
    
    void User::AddFriend(User& newFriend)
    {
        VectorInserter ins(friends_, &newFriend);
        pDB_->AddFriend(GetName(), newFriend.GetName());
        // Everything went fine, commit the vector insertion
        ins.Commit();
    }

    LispGovno, 03 Сентября 2013

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