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

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

    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
    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
    import * as React from 'react';
    import {CityFromSelector} from './components/cityFromSelector';
    import {CountryToSelector} from './components/countryToSelector';
    import {MealsTypeSelector} from './components/mealsTypeSelector';
    import {DepartureDatesRangeSelector} from './components/departureDatesRangeSelector';
    import {HotelCategoriesSelector} from './components/hotelCategoriesSelector';
    import {ResortSelector} from './components/resortSelector';
    import {HotelsSelector} from './components/hotelsSelector';
    import {TouristsSelector} from './components/touristsSelector';
    import {OperatorsSelector} from './components/operatorsSelector';
    import {NightsCountRangeSelector} from './components/nightsCountRangeSelector';
    import {PriceRangeSelector} from './components/priceRangeSelector';
    import {FlightInfo} from './components/flightInfo';
    import {SearchFormActionCreator} from './search/searchFormActionCreator';
    import {HotelsCountPopup} from './components/hotelsCountLimitPopup';
    import * as throttle from 'lodash/throttle';
    import * as filter from 'lodash/filter';
    import * as union from 'lodash/union';
    import * as merge from 'lodash/merge';
    import * as reduce from 'lodash/reduce';
    import * as chunk from 'lodash/chunk';
    import * as difference from 'lodash/difference';
    import * as differenceBy from 'lodash/differenceBy';
    import { Tour } from 'sletat-api-services/lib/ModuleApiServices/Main.svc/GetTours/Tour';
    import { logViewedTours } from 'sletat-api-services/lib/GraphApiServices/Main.svc/LogViewedTours/LogViewedTours';
    import { OilTax } from 'sletat-api-services/lib/ModuleApiServices/Main.svc/GetTours/OilTax';
    import { VisaFee } from 'sletat-api-services/lib/ModuleApiServices/Main.svc/GetTours/VisaFee';
    import { getHotelImageSrc } from 'sletat-common-utils/lib/tour/getHotelImageSrc';
    import { declineByCount } from 'sletat-common-utils/lib/format/declineByCount';
    import { Tour as GetToursTour } from 'sletat-api-services/lib/ModuleApiServices/Main.svc/GetTours/Tour';
    import { Tour } from './tour';
    import { IVisaFee } from './visaFee';
    import { IOilTax } from './oilTaxes';
    import { UiPopup } from 'react-sletat-uikit/lib/ui-popup/UiPopup';
    import { UiLoader } from 'react-sletat-uikit/lib/ui-loader/UiLoader';
    import {
        SendConfirmEmailResults,
        recoverySendConfirmEmail,
        registrationSendConfirmEmail
    } from 'sletat-api-services/lib/SletatServices/Services/SendConfirmEmail/SendConfirmEmail';
    import { authentification } from 'sletat-api-services/lib/SletatServices/Authentification';
    import LoginPopup from './components/Login';
    import RegistrationPopup from './components/Registration';
    import RecoveryPopup from './components/Recovery';
    import SuccessPopup from './components/Success';
    import { PopupTypes } from './constants';

    может это уже нормально в современном фронтенде

    tablecell, 02 Июня 2020

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

    +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
    template <typename F, class = decltype(F()(E()))>
        auto map(F p) -> std::vector< decltype(p(E())) >
        {        
            std::vector< decltype(p(E())) > result;
            std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
                return mutable_(p)(v);
            });
    
            return result;
        }
    
        template <typename F, class = decltype(F()(E(), 0))>
        auto map(F p) -> std::vector< decltype(p(E(), 0)) >
        {        
            std::vector< decltype(p(E(), 0)) > result;
            auto first = &(get())[0];
            std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
                auto index = &v - first;
                return mutable_(p)(v, index);
            });
    
            return result;
        }
    
    // и применение (e) => f()
        auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
        {
            return "X" + x;
        });
    
    // или (e, index) => f()
    
        auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
        {
            return x + i;
        });

    как я выкрутился бля... с разными маперами... как генерики в c#

    ASD_77, 27 Мая 2020

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

    +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
    CStringUtf8::iterator& CStringUtf8::iterator::operator++() 
    { 
        m_ptr += CCharUtf8Ref::s_bytesForUTF8Sequence[*m_ptr]; 
        return *this;
    }
    
    CStringUtf8 CStringUtf8::subString( size_t startChar, size_t count ) const
    {
        iterator start = this->begin();
        while( start!=this->end() && startChar>0 )
        {
            start++;
            startChar--;
        }
    
        iterator afterLast = start;
        while( afterLast!=this->end() && count!=0 )
        {
            afterLast++;
            count--;
        }
        return CStringUtf8( start.c_ptr(), afterLast.c_ptr() );
    }
    
    CStringUtf8::iterator CStringUtf8::findSubString( CStringUtf8 const& sample, CStringUtf8::iterator startFrom ) const
    {
        CStringUtf8::iterator pos = startFrom;
        CStringUtf8::iterator foundPos = pos;
        CStringUtf8::iterator samplePos = sample.begin();
    
        for( ;; )
        {
            if( samplePos==sample.end() )
                return foundPos;
    
            if( pos==this->end() )
                return this->end();
    
            if( *samplePos == *pos )
            {
                if( samplePos==sample.begin() )
                    foundPos = pos;
                samplePos++;
                pos++;
            }
            else
            {
                if( samplePos==sample.begin() )
                    pos++;
                samplePos = sample.begin();
            }
        }
    }
    
    std::vector<CStringUtf8> CStringUtf8::componentsSeparatedByString( CStringUtf8 const& separator ) const
    {
        std::vector<CStringUtf8> comps;
    
        size_t sepLen = std::distance( separator.begin(), separator.end() );
        size_t startPos = 0;
        CStringUtf8::iterator itStart = begin();
    
        if( sepLen > 0 )
        {
            CStringUtf8::iterator itEnd;
            while( ( itEnd = findSubString( separator, itStart ) ) != end() )
            {
                size_t cnt = std::distance( itStart, itEnd );
                CStringUtf8 str = subString( startPos, cnt );
                comps.push_back( str );
    
                itStart = itEnd;
                std::advance( itStart, sepLen );
    
                startPos += cnt + sepLen;
            }
        }
    
        size_t cnt = std::distance( itStart, end() );
        if( cnt > 0 )
        {
            CStringUtf8 str = subString( startPos, cnt );
            comps.push_back( str );
        }
    
        return comps;
    }

    Привычный для всех плюсовиков велосипед по работе со строкой (походу свой в каждом проекте).
    Более 10 лет не замечали тормоза в componentsSeparatedByString, который 100 Кб текст разбирал на строки за 5-10 сек (!!!).

    jojaxon, 26 Апреля 2020

    Комментарии (24)
  5. Python / Говнокод #26379

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    # Python2
    
    import sys
    print sys.stderr, "Pol chasa ne mog ponyat kakoko huya nichego ne vivoditsya"

    3_dar, 23 Января 2020

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $s = $_REQUEST['user_str'];
    $lnk = mysqli_connect('localhost','root','1234','Jelwery') or die("Error ".mysqli_error($connection));
    mysqli_set_charset("utf8");
    $res = mysqli_query($lnk, "SELECT SUBSTRING('".$s."',1,8') as result") or $res = ("Ошибка ".mysqli_error($connection));
    $row = mysqli_fetch_assoc($res);
    $s = $row['t'];
    echo 'Truncated string: '.$s;

    Взятие подстроки (когда запретили substr($s,8) :))

    st4rkc0d3, 19 Января 2020

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

    0

    1. 1
    2. 2
    В УЗБЕКИСТАНЕ ДАН СТАРТ МАСШТАБНОМУ ПРОЕКТУ ONE MILLION UZBEK CODERS
    https://uznews.uz/ru/article/17817

    Проект представляет собой дистанционное бесплатное обучение населения посредством онлайн-портала по четырем IT-специальностям.

    MAKAKA, 27 Ноября 2019

    Комментарии (24)
  8. bash / Говнокод #26048

    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
    # Если вы желаете ограничить диапазон "снизу",
    # то просто производите генерацию псевдослучайных чисел в цикле до тех пор,
    # пока не получите число большее нижней границы.
    
    FLOOR=200
    
    number=0   # инициализация
    while [ "$number" -le $FLOOR ]
    do
      number=$RANDOM
    done
    echo "Случайное число, большее $FLOOR ---  $number"

    https://www.opennet.ru/docs/RUS/bash_scripting_guide/x4812.html

    groser, 26 Ноября 2019

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

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    //замена главной диагонали с n-м столбцом в матрице с менюшкой и печеньками
    
    #include "pch.h"
    #include <iostream>
    #include <conio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <ctime>
    #include <iomanip>
    
    using namespace std;
    
    int a[100][100], n = 3;
    
    void inputN();
    void filling(int);
    void manualfill(int);
    void showmass(int);
    void solving();
    void menu();
    
    int main()
    {
    	setlocale(0, "rus");
    	menu();
    	srand(time(NULL));
    	return 0;
    }
    
    void inputN() {
    	system("cls");
    	cout << "Введите n = "; cin >> n;
    	if (n < 3) {
    		cout << "\nИспользован стандартный размер массива 3х3\n\n";
    		n = 3;
    	}
    	showmass(2);
    	cout << "\n\n";
    	system("pause");
    }
    
    void filling(int n) {
    	system("cls");
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			a[i][j] = rand() % 100 + 1;
    		}
    	}
    	showmass(3);
    }
    
    void manualfill(int n) {
    	system("cls");
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			printf("  a[%d][%d] = ", i + 1, j + 1); cin >> a[i][j];
    		}
    	}
    	system("pause");
    }
    
    void showmass(int status) {
    	if (status == 2 or status == 3) cout << "\n\n";else system("cls");
    	
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			cout << setw(5) << a[i][j];
    		}
    		cout << endl;
    	}
    	if (status==1 or status == 3)system("pause");
    }
    
    void solving() {
    	system("cls");
    	showmass(2);
    	int c = 0;
    	int stolb = 0;
    	cout << "\nКакой столбец меняем?\n>>"; cin >> stolb; 
    	stolb--;
    	for (int i = 0; i < n; i++) {
    		c = a[i][i];
    		a[i][i] = a[i][stolb];
    		a[i][stolb] = c;
    	}
    	printf("\n\n----гл. диагональ меняется с %d столбцом----\n\n",stolb+1);
    	showmass(3);
    
    	for (int i = 0; i < n; i++) {
    		c = a[i][i];
    		a[i][i] = a[i][stolb];
    		a[i][stolb] = c;
    	}
    }
    
    void menu() {
    	system("cls");
    	int ch = 0;
    	while (true) {
    		cout << "     МЕНЮ\n\n";

    ъуъ

    maxrbs, 05 Ноября 2019

    Комментарии (24)
  10. Куча / Говнокод #25978

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    begin 644 /dev/stdout
    M,$M$4FMD0V<P6E11;TU+=S!+1%%H9$-H,%I046]D0T1,0T11;TU+,3!+2%%G
    M.4-G=W)V46].1U))3D-H-&]#83!+2&EG3&MG,$M(:6=+2%%O3D=2,$M(:6=*
    M<E%O34MW,$M$0W1D0V@T;TMS,$M(46EI1%%O9$--,$M(:6=*<E%O3D=624,P
    M=$E.0V<P26)1;V5+075D0V<T;U-7,$M$4VMD0V<P6D5G,$M$46AD0V=W<D%G
    M,$M(46<Y0V<P26)1;V1#4#!+1$-T.4-H,$EO9S!+2%%G.4-H,$E,46].1U8P
    42TAI9TM(46].0T8P2T12;%$]/0H`
    `
    end

    MAPTbIwKA, 19 Октября 2019

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

    +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
    <?php
    
    function split_hash($hash, $sizes) {
        $cnt = count($sizes);                   // количество словарей
        $partSize = floor(128/4/$cnt);          // размер части хэша в тетрадах
        $result = array();
        foreach($sizes as $size) {
            $tmp = substr($hash, 0, $partSize); // разбиваем хэш по тетрадам на равные части
            $hash = substr($hash, $partSize);   
            $result[] = gmp_intval(gmp_mod(gmp_init($tmp, 16), $size)); // возвращаем остаток от деления фрагмента хэша 
                                                                        // на размер словаря
        }
        return $result;
    }
    
    function R($hash, $dicts) {
        $sizes = array_map(function($val){return count($val);}, $dicts); // получаем размеры каждого словаря
        $indices = split_hash($hash, $sizes);
        $result = '';
        foreach($indices as $dictNumber=>$index) {
            $result .= $dicts[$dictNumber][$index]; // сцепляем слово из частей
        }
        return $result;
    }
    
    function make_chain($start, $length, $dicts) {
        for($i = 0; $i < $length; ++$i) {
            $hash = md5($start);
            echo $hash . ' : ' . $start . PHP_EOL;
            $start = R($hash, $dicts);
        }
    }
    
    make_chain('свинособака', 10, array(
          array('свино',  'овце', 'тигро', 'косатко', 'зубро', 'волко', 'кото'),
          array('собака', 'бык',  'лев',   'дельфин', 'бизон')
    ));

    Выводит:

    360629d3cf05cee0240a23e1251c58a0 : свинособака
    1f7ad860b089c0e1141de02ac1e6e3ef : волкобизон
    6f2e4e3025c9dd840f1fa4a78792ef31 : котобизон
    d5812761186013ecca674a2704d5a081 : зубробык
    b4499d259156939bb74cbc1743632c8d : овцебизон
    c28ad194fcc581f538d109f8acb6b1f5 : волкобык
    663a3e06c88185db8fd4f81829e66b85 : котодельфин
    30bb70e972bf073c7aa4ec93c8d5b9a0 : косаткодельфин
    cc31cd8554c1add0128013bba2e47317 : волколев
    d88e78b7340637370628848b1957b4c2 : котособака


    http://ideone.com/rxqpj1

    ropuJIJIa, 10 Октября 2019

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